add commands to extension manager
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import collect from 'collect.js'
|
||||
import { keymap } from 'prosemirror-keymap'
|
||||
import { inputRules } from 'prosemirror-inputrules'
|
||||
import { Editor } from './Editor'
|
||||
import { Editor, CommandSpec } from './Editor'
|
||||
import Extension from './Extension'
|
||||
import Node from './Node'
|
||||
|
||||
@@ -16,11 +16,20 @@ export default class ExtensionManager {
|
||||
this.extensions.forEach(extension => {
|
||||
extension.bindEditor(editor)
|
||||
editor.on('schemaCreated', () => {
|
||||
this.registerCommands(extension.commands())
|
||||
extension.created()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
registerCommands(commands: CommandSpec) {
|
||||
Object
|
||||
.entries(commands)
|
||||
.forEach(([name, command]) => {
|
||||
this.editor.registerCommand(name, command)
|
||||
})
|
||||
}
|
||||
|
||||
get topNode() {
|
||||
const topNode = collect(this.extensions).firstWhere('topNode', true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user