add basic schema extender

This commit is contained in:
Philipp Kühn
2021-02-19 09:54:39 +01:00
parent 85eceb32b8
commit 6f9557294e
7 changed files with 88 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ import { Plugin, Transaction } from 'prosemirror-state'
import { Command as ProseMirrorCommand } from 'prosemirror-commands'
import { InputRule } from 'prosemirror-inputrules'
import { Editor } from './Editor'
import { Node } from './Node'
import mergeDeep from './utilities/mergeDeep'
import { GlobalAttributes, RawCommands } from './types'
@@ -65,6 +66,30 @@ export interface ExtensionConfig<Options = any> {
editor: Editor,
}) => Plugin[],
/**
* Extend Node Schema
*/
extendNodeSchema?: ((
this: {
options: Options,
},
extension: Node,
) => {
[key: string]: any,
}) | null,
/**
* Extend Mark Schema
*/
extendMarkSchema?: ((
this: {
options: Options,
},
extension: Node,
) => {
[key: string]: any,
}) | null,
/**
* The editor is ready.
*/
@@ -149,6 +174,8 @@ export class Extension<Options = any> {
addInputRules: () => [],
addPasteRules: () => [],
addProseMirrorPlugins: () => [],
extendNodeSchema: null,
extendMarkSchema: null,
onCreate: null,
onUpdate: null,
onSelection: null,