remove registerCommands
This commit is contained in:
@@ -4,7 +4,7 @@ import { inputRules as inputRulesPlugin } from 'prosemirror-inputrules'
|
||||
import { EditorView, Decoration } from 'prosemirror-view'
|
||||
import { Plugin } from 'prosemirror-state'
|
||||
import { Editor } from './Editor'
|
||||
import { Extensions, NodeViewRenderer } from './types'
|
||||
import { Extensions, NodeViewRenderer, Commands } from './types'
|
||||
import getSchema from './helpers/getSchema'
|
||||
import getSchemaTypeByName from './helpers/getSchemaTypeByName'
|
||||
import getNodeType from './helpers/getNodeType'
|
||||
@@ -32,11 +32,6 @@ export default class ExtensionManager {
|
||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
||||
}
|
||||
|
||||
const commands = extension.config.addCommands.bind(context)()
|
||||
|
||||
// @ts-ignore
|
||||
editor.registerCommands(commands)
|
||||
|
||||
if (typeof extension.config.onCreate === 'function') {
|
||||
this.editor.on('create', extension.config.onCreate.bind(context))
|
||||
}
|
||||
@@ -67,6 +62,21 @@ export default class ExtensionManager {
|
||||
})
|
||||
}
|
||||
|
||||
get commands(): Commands {
|
||||
return this.extensions.reduce((extensions, extension) => {
|
||||
const context = {
|
||||
options: extension.options,
|
||||
editor: this.editor,
|
||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
||||
}
|
||||
|
||||
return {
|
||||
...extensions,
|
||||
...extension.config.addCommands.bind(context)(),
|
||||
}
|
||||
}, {} as Commands)
|
||||
}
|
||||
|
||||
get plugins(): Plugin[] {
|
||||
return [...this.extensions]
|
||||
.reverse()
|
||||
|
||||
Reference in New Issue
Block a user