replace extensions
This commit is contained in:
@@ -1,20 +1,44 @@
|
||||
import Extension from './Extension'
|
||||
import { NodeSpec } from 'prosemirror-model'
|
||||
import { NodeSpec, NodeType } from 'prosemirror-model'
|
||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||
|
||||
export default abstract class Node extends Extension {
|
||||
// export default abstract class Node extends Extension {
|
||||
|
||||
constructor(options = {}) {
|
||||
super(options)
|
||||
}
|
||||
// constructor(options = {}) {
|
||||
// super(options)
|
||||
// }
|
||||
|
||||
public extensionType = 'node'
|
||||
// public extensionType = 'node'
|
||||
|
||||
public topNode = false
|
||||
// public topNode = false
|
||||
|
||||
abstract schema(): NodeSpec
|
||||
// abstract schema(): NodeSpec
|
||||
|
||||
get type() {
|
||||
return this.editor.schema.nodes[this.name]
|
||||
}
|
||||
// get type() {
|
||||
// return this.editor.schema.nodes[this.name]
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
export interface NodeCallback extends ExtensionCallback {
|
||||
// TODO: fix optional
|
||||
type?: NodeType
|
||||
}
|
||||
|
||||
export interface NodeExtends<Callback = NodeCallback> extends ExtensionExtends<Callback> {
|
||||
topNode: boolean
|
||||
schema: (params: Callback) => NodeSpec
|
||||
}
|
||||
|
||||
export default class Node<Options = {}> extends Extension<Options, NodeExtends> {
|
||||
type = 'node'
|
||||
|
||||
public topNode(value: NodeExtends['topNode'] = true) {
|
||||
this.storeConfig('topNode', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
||||
public schema(value: NodeExtends['schema']) {
|
||||
this.storeConfig('schema', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user