improve new extensions

This commit is contained in:
Philipp Kühn
2020-11-16 09:43:17 +01:00
parent 034ee139a3
commit c87f49c1fe
50 changed files with 296 additions and 377 deletions

View File

@@ -28,10 +28,10 @@ export default class ExtensionManager {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
const commands = extension.addCommands.bind(context)()
const commands = extension.config.addCommands.bind(context)()
editor.registerCommands(commands)
})
@@ -43,10 +43,10 @@ export default class ExtensionManager {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return extension.addProseMirrorPlugins.bind(context)()
return extension.config.addProseMirrorPlugins.bind(context)()
})
.flat()
@@ -64,10 +64,10 @@ export default class ExtensionManager {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return extension.addInputRules.bind(context)()
return extension.config.addInputRules.bind(context)()
})
.flat()
}
@@ -78,10 +78,10 @@ export default class ExtensionManager {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return extension.addPasteRules.bind(context)()
return extension.config.addPasteRules.bind(context)()
})
.flat()
}
@@ -91,10 +91,10 @@ export default class ExtensionManager {
const context = {
options: extension.options,
editor: this.editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
return keymap(extension.addKeyboardShortcuts.bind(context)())
return keymap(extension.config.addKeyboardShortcuts.bind(context)())
})
}
@@ -104,17 +104,17 @@ export default class ExtensionManager {
const allAttributes = getAttributesFromExtensions(this.extensions)
return Object.fromEntries(nodeExtensions
.filter(extension => !!extension.addNodeView)
.filter(extension => !!extension.config.addNodeView)
.map(extension => {
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.config.name)
const context = {
options: extension.options,
editor,
type: getSchemaTypeByName(extension.name, this.schema),
type: getSchemaTypeByName(extension.config.name, this.schema),
}
// @ts-ignore
const renderer = extension.addNodeView?.bind(context)?.() as NodeViewRenderer
const renderer = extension.config.addNodeView?.bind(context)?.() as NodeViewRenderer
const nodeview = (
node: ProsemirrorNode,
@@ -133,7 +133,7 @@ export default class ExtensionManager {
})
}
return [extension.name, nodeview]
return [extension.config.name, nodeview]
}))
}