rename
This commit is contained in:
@@ -2,7 +2,7 @@ import { Plugin } from 'prosemirror-state'
|
|||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
import { GlobalAttributes } from './types'
|
import { GlobalAttributes } from './types'
|
||||||
|
|
||||||
export interface ExtensionSpec<Options = any, Commands = {}> {
|
export interface ExtensionConfig<Options = any, Commands = {}> {
|
||||||
/**
|
/**
|
||||||
* Name
|
* Name
|
||||||
*/
|
*/
|
||||||
@@ -64,7 +64,7 @@ export interface ExtensionSpec<Options = any, Commands = {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Extension<Options = any, Commands = any> {
|
export class Extension<Options = any, Commands = any> {
|
||||||
config: Required<ExtensionSpec> = {
|
config: Required<ExtensionConfig> = {
|
||||||
name: 'extension',
|
name: 'extension',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
addGlobalAttributes: () => [],
|
addGlobalAttributes: () => [],
|
||||||
@@ -77,7 +77,7 @@ export class Extension<Options = any, Commands = any> {
|
|||||||
|
|
||||||
options!: Options
|
options!: Options
|
||||||
|
|
||||||
constructor(config: ExtensionSpec<Options, Commands>) {
|
constructor(config: ExtensionConfig<Options, Commands>) {
|
||||||
this.config = {
|
this.config = {
|
||||||
...this.config,
|
...this.config,
|
||||||
...config,
|
...config,
|
||||||
@@ -86,13 +86,13 @@ export class Extension<Options = any, Commands = any> {
|
|||||||
this.options = this.config.defaultOptions
|
this.options = this.config.defaultOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
static create<O, C>(config: ExtensionSpec<O, C>) {
|
static create<O, C>(config: ExtensionConfig<O, C>) {
|
||||||
return new Extension<O, C>(config)
|
return new Extension<O, C>(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(options: Partial<Options>) {
|
configure(options: Partial<Options>) {
|
||||||
return Extension
|
return Extension
|
||||||
.create<Options, Commands>(this.config as ExtensionSpec<Options, Commands>)
|
.create<Options, Commands>(this.config as ExtensionConfig<Options, Commands>)
|
||||||
.#configure({
|
.#configure({
|
||||||
...this.config.defaultOptions,
|
...this.config.defaultOptions,
|
||||||
...options,
|
...options,
|
||||||
@@ -108,10 +108,10 @@ export class Extension<Options = any, Commands = any> {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<ExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
|
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<ExtensionConfig<ExtendedOptions, ExtendedCommands>>) {
|
||||||
return new Extension<ExtendedOptions, ExtendedCommands>({
|
return new Extension<ExtendedOptions, ExtendedCommands>({
|
||||||
...this.config,
|
...this.config,
|
||||||
...extendedConfig,
|
...extendedConfig,
|
||||||
} as ExtensionSpec<ExtendedOptions, ExtendedCommands>)
|
} as ExtensionConfig<ExtendedOptions, ExtendedCommands>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
MarkType,
|
MarkType,
|
||||||
} from 'prosemirror-model'
|
} from 'prosemirror-model'
|
||||||
import { Plugin } from 'prosemirror-state'
|
import { Plugin } from 'prosemirror-state'
|
||||||
import { ExtensionSpec } from './Extension'
|
import { ExtensionConfig } from './Extension'
|
||||||
import { Attributes, Overwrite } from './types'
|
import { Attributes, Overwrite } from './types'
|
||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
export interface MarkExtensionSpec<Options = any, Commands = {}> extends Overwrite<ExtensionSpec<Options, Commands>, {
|
export interface MarkConfig<Options = any, Commands = {}> extends Overwrite<ExtensionConfig<Options, Commands>, {
|
||||||
/**
|
/**
|
||||||
* Inclusive
|
* Inclusive
|
||||||
*/
|
*/
|
||||||
@@ -110,7 +110,7 @@ export interface MarkExtensionSpec<Options = any, Commands = {}> extends Overwri
|
|||||||
}> {}
|
}> {}
|
||||||
|
|
||||||
export class Mark<Options = any, Commands = {}> {
|
export class Mark<Options = any, Commands = {}> {
|
||||||
config: Required<MarkExtensionSpec> = {
|
config: Required<MarkConfig> = {
|
||||||
name: 'mark',
|
name: 'mark',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
addGlobalAttributes: () => [],
|
addGlobalAttributes: () => [],
|
||||||
@@ -130,7 +130,7 @@ export class Mark<Options = any, Commands = {}> {
|
|||||||
|
|
||||||
options!: Options
|
options!: Options
|
||||||
|
|
||||||
constructor(config: MarkExtensionSpec<Options, Commands>) {
|
constructor(config: MarkConfig<Options, Commands>) {
|
||||||
this.config = {
|
this.config = {
|
||||||
...this.config,
|
...this.config,
|
||||||
...config,
|
...config,
|
||||||
@@ -139,13 +139,13 @@ export class Mark<Options = any, Commands = {}> {
|
|||||||
this.options = this.config.defaultOptions
|
this.options = this.config.defaultOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
static create<O, C>(config: MarkExtensionSpec<O, C>) {
|
static create<O, C>(config: MarkConfig<O, C>) {
|
||||||
return new Mark<O, C>(config)
|
return new Mark<O, C>(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(options: Partial<Options>) {
|
configure(options: Partial<Options>) {
|
||||||
return Mark
|
return Mark
|
||||||
.create<Options, Commands>(this.config as MarkExtensionSpec<Options, Commands>)
|
.create<Options, Commands>(this.config as MarkConfig<Options, Commands>)
|
||||||
.#configure({
|
.#configure({
|
||||||
...this.config.defaultOptions,
|
...this.config.defaultOptions,
|
||||||
...options,
|
...options,
|
||||||
@@ -161,10 +161,10 @@ export class Mark<Options = any, Commands = {}> {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
|
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<MarkConfig<ExtendedOptions, ExtendedCommands>>) {
|
||||||
return new Mark<ExtendedOptions, ExtendedCommands>({
|
return new Mark<ExtendedOptions, ExtendedCommands>({
|
||||||
...this.config,
|
...this.config,
|
||||||
...extendedConfig,
|
...extendedConfig,
|
||||||
} as MarkExtensionSpec<ExtendedOptions, ExtendedCommands>)
|
} as MarkConfig<ExtendedOptions, ExtendedCommands>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
NodeType,
|
NodeType,
|
||||||
} from 'prosemirror-model'
|
} from 'prosemirror-model'
|
||||||
import { Plugin } from 'prosemirror-state'
|
import { Plugin } from 'prosemirror-state'
|
||||||
import { ExtensionSpec } from './Extension'
|
import { ExtensionConfig } from './Extension'
|
||||||
import { Attributes, NodeViewRenderer, Overwrite } from './types'
|
import { Attributes, NodeViewRenderer, Overwrite } from './types'
|
||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
export interface NodeExtensionSpec<Options = any, Commands = {}> extends Overwrite<ExtensionSpec<Options, Commands>, {
|
export interface NodeConfig<Options = any, Commands = {}> extends Overwrite<ExtensionConfig<Options, Commands>, {
|
||||||
/**
|
/**
|
||||||
* TopNode
|
* TopNode
|
||||||
*/
|
*/
|
||||||
@@ -154,7 +154,7 @@ export interface NodeExtensionSpec<Options = any, Commands = {}> extends Overwri
|
|||||||
}> {}
|
}> {}
|
||||||
|
|
||||||
export class Node<Options = any, Commands = {}> {
|
export class Node<Options = any, Commands = {}> {
|
||||||
config: Required<NodeExtensionSpec> = {
|
config: Required<NodeConfig> = {
|
||||||
name: 'node',
|
name: 'node',
|
||||||
defaultOptions: {},
|
defaultOptions: {},
|
||||||
addGlobalAttributes: () => [],
|
addGlobalAttributes: () => [],
|
||||||
@@ -182,7 +182,7 @@ export class Node<Options = any, Commands = {}> {
|
|||||||
|
|
||||||
options!: Options
|
options!: Options
|
||||||
|
|
||||||
constructor(config: NodeExtensionSpec<Options, Commands>) {
|
constructor(config: NodeConfig<Options, Commands>) {
|
||||||
this.config = {
|
this.config = {
|
||||||
...this.config,
|
...this.config,
|
||||||
...config,
|
...config,
|
||||||
@@ -191,13 +191,13 @@ export class Node<Options = any, Commands = {}> {
|
|||||||
this.options = this.config.defaultOptions
|
this.options = this.config.defaultOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
static create<O, C>(config: NodeExtensionSpec<O, C>) {
|
static create<O, C>(config: NodeConfig<O, C>) {
|
||||||
return new Node<O, C>(config)
|
return new Node<O, C>(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(options: Partial<Options>) {
|
configure(options: Partial<Options>) {
|
||||||
return Node
|
return Node
|
||||||
.create<Options, Commands>(this.config as NodeExtensionSpec<Options, Commands>)
|
.create<Options, Commands>(this.config as NodeConfig<Options, Commands>)
|
||||||
.#configure({
|
.#configure({
|
||||||
...this.config.defaultOptions,
|
...this.config.defaultOptions,
|
||||||
...options,
|
...options,
|
||||||
@@ -213,10 +213,10 @@ export class Node<Options = any, Commands = {}> {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeExtensionSpec<ExtendedOptions, ExtendedCommands>>) {
|
extend<ExtendedOptions = Options, ExtendedCommands = Commands>(extendedConfig: Partial<NodeConfig<ExtendedOptions, ExtendedCommands>>) {
|
||||||
return new Node<ExtendedOptions, ExtendedCommands>({
|
return new Node<ExtendedOptions, ExtendedCommands>({
|
||||||
...this.config,
|
...this.config,
|
||||||
...extendedConfig,
|
...extendedConfig,
|
||||||
} as NodeExtensionSpec<ExtendedOptions, ExtendedCommands>)
|
} as NodeConfig<ExtendedOptions, ExtendedCommands>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user