2020-09-09 05:44:45 +08:00
|
|
|
import { NodeSpec, NodeType } from 'prosemirror-model'
|
|
|
|
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
// export default abstract class Node extends Extension {
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
// constructor(options = {}) {
|
|
|
|
// super(options)
|
|
|
|
// }
|
|
|
|
|
|
|
|
// public extensionType = 'node'
|
|
|
|
|
|
|
|
// public topNode = false
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
// abstract schema(): NodeSpec
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
// get type() {
|
|
|
|
// return this.editor.schema.nodes[this.name]
|
|
|
|
// }
|
2020-03-06 07:15:36 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
// }
|
|
|
|
|
|
|
|
export interface NodeCallback extends ExtensionCallback {
|
|
|
|
// TODO: fix optional
|
|
|
|
type?: NodeType
|
|
|
|
}
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
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
|
2020-03-30 18:40:25 +08:00
|
|
|
}
|
|
|
|
|
2020-09-09 05:44:45 +08:00
|
|
|
public schema(value: NodeExtends['schema']) {
|
|
|
|
this.storeConfig('schema', value, 'overwrite')
|
|
|
|
return this
|
|
|
|
}
|
2019-12-17 06:20:05 +08:00
|
|
|
}
|