replace extensions

This commit is contained in:
Philipp Kühn
2020-09-08 23:44:45 +02:00
parent 678b6444d2
commit 26ecc20a50
16 changed files with 590 additions and 491 deletions

View File

@@ -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
}
}