tiptap/packages/core/src/Node.ts

30 lines
744 B
TypeScript
Raw Normal View History

2020-09-09 05:44:45 +08:00
import { NodeSpec, NodeType } from 'prosemirror-model'
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
2020-09-09 18:57:50 +08:00
import { Editor } from './Editor'
2019-12-17 06:20:05 +08:00
2020-09-09 18:57:50 +08:00
interface Callback {
name: string
editor: Editor
options: any
type: NodeType
2020-09-09 05:44:45 +08:00
}
2019-12-17 06:20:05 +08:00
2020-09-09 18:57:50 +08:00
export interface NodeExtends extends ExtensionExtends<Callback> {
2020-09-09 05:44:45 +08:00
topNode: boolean
schema: (params: Callback) => NodeSpec
}
2020-09-09 18:57:50 +08:00
export default class Node<Options = {}> extends Extension<Options, Callback, NodeExtends> {
2020-09-09 05:44:45 +08:00
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
}