// import { NodeSpec, NodeType } from 'prosemirror-model' // import Extension, { ExtensionMethods } from './Extension' // import { Editor } from './Editor' // export interface NodeProps { // name: string // editor: Editor // options: Options // type: NodeType // } // export interface NodeMethods extends ExtensionMethods { // topNode: boolean // schema: (params: Omit) => NodeSpec // } // export default class Node< // Options = {}, // Props = NodeProps, // Methods extends NodeMethods = NodeMethods, // > extends Extension { // type = 'node' // public topNode(value: Methods['topNode'] = true) { // this.storeConfig('topNode', value, 'overwrite') // return this // } // public schema(value: Methods['schema']) { // this.storeConfig('schema', value, 'overwrite') // return this // } // } // import { DOMOutputSpec, DOMOutputSpecArray } from 'prosemirror-model' // import Extension from './Extension' // export interface INode { // type: string // topNode: boolean // group: string // content: string // createAttributes(): any // parseHTML(): any // renderHTML(props: number): DOMOutputSpec // } // export default class Node extends Extension implements INode { // type = 'node' // topNode = false // group = '' // content = '' // createAttributes() { // return {} // } // parseHTML() { // return [] // } // renderHTML() { // return null // } // } import { DOMOutputSpec, NodeSpec, Node } from 'prosemirror-model' import { ExtensionSpec } from './Extension' export interface NodeExtensionSpec extends ExtensionSpec { topNode?: boolean, content?: NodeSpec['content'], marks?: NodeSpec['marks'], group?: NodeSpec['group'], inline?: NodeSpec['inline'], atom?: NodeSpec['atom'], selectable?: NodeSpec['selectable'], draggable?: NodeSpec['draggable'], code?: NodeSpec['code'], defining?: NodeSpec['defining'], isolating?: NodeSpec['isolating'], parseHTML?: () => NodeSpec['parseDOM'], renderHTML?: (props: { node: Node, attributes: { [key: string]: any, }, }) => DOMOutputSpec, } export type NodeExtension = Required & { type: string, options: { [key: string]: any }, }> const defaultNode: NodeExtension = { type: 'node', name: 'node', options: {}, topNode: false, content: null, marks: null, group: null, inline: null, atom: null, selectable: null, draggable: null, code: null, defining: null, isolating: null, createCommands: () => ({}), parseHTML: () => null, renderHTML: () => null, } export function createNode(config: NodeExtensionSpec) { const extend = (extendedConfig: Partial>) => { return createNode({ ...config, ...extendedConfig, } as NodeExtensionSpec) } const setOptions = (options?: Partial) => { const { defaultOptions, ...rest } = config return { ...defaultNode, ...rest, options: { ...defaultOptions, ...options, } as Options, } } return Object.assign(setOptions, { config, extend }) }