Merge branch 'main' into feature/tables
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { keymap } from 'prosemirror-keymap'
|
import { keymap } from 'prosemirror-keymap'
|
||||||
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
|
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
|
||||||
import { inputRules } from 'prosemirror-inputrules'
|
import { inputRules as inputRulesPlugin } from 'prosemirror-inputrules'
|
||||||
import { EditorView, Decoration } from 'prosemirror-view'
|
import { EditorView, Decoration } from 'prosemirror-view'
|
||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
import { Extensions, NodeViewRenderer } from './types'
|
import { Extensions, NodeViewRenderer } from './types'
|
||||||
@@ -66,7 +66,7 @@ export default class ExtensionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get plugins() {
|
get plugins() {
|
||||||
const plugins = this.extensions
|
return this.extensions
|
||||||
.map(extension => {
|
.map(extension => {
|
||||||
const context = {
|
const context = {
|
||||||
options: extension.options,
|
options: extension.options,
|
||||||
@@ -74,66 +74,26 @@ export default class ExtensionManager {
|
|||||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
type: getSchemaTypeByName(extension.config.name, this.schema),
|
||||||
}
|
}
|
||||||
|
|
||||||
return extension.config.addProseMirrorPlugins.bind(context)()
|
const keymapPlugin = keymap(extension.config.addKeyboardShortcuts.bind(context)())
|
||||||
})
|
const inputRules = extension.config.addInputRules.bind(context)()
|
||||||
.flat()
|
const inputRulePlugins = this.editor.options.enableInputRules && inputRules.length
|
||||||
|
? [inputRulesPlugin({ rules: inputRules })]
|
||||||
|
: []
|
||||||
|
const pasteRulePlugins = this.editor.options.enablePasteRules
|
||||||
|
? extension.config.addPasteRules.bind(context)()
|
||||||
|
: []
|
||||||
|
const plugins = extension.config.addProseMirrorPlugins.bind(context)()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
keymapPlugin,
|
||||||
|
...inputRulePlugins,
|
||||||
|
...pasteRulePlugins,
|
||||||
...plugins,
|
...plugins,
|
||||||
...this.keymaps,
|
|
||||||
...this.pasteRules,
|
|
||||||
inputRules({ rules: this.inputRules }),
|
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
|
||||||
get inputRules() {
|
|
||||||
if (!this.editor.options.enableInputRules) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.extensions
|
|
||||||
.map(extension => {
|
|
||||||
const context = {
|
|
||||||
options: extension.options,
|
|
||||||
editor: this.editor,
|
|
||||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension.config.addInputRules.bind(context)()
|
|
||||||
})
|
})
|
||||||
.flat()
|
.flat()
|
||||||
}
|
}
|
||||||
|
|
||||||
get pasteRules() {
|
|
||||||
if (!this.editor.options.enablePasteRules) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.extensions
|
|
||||||
.map(extension => {
|
|
||||||
const context = {
|
|
||||||
options: extension.options,
|
|
||||||
editor: this.editor,
|
|
||||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
|
||||||
}
|
|
||||||
|
|
||||||
return extension.config.addPasteRules.bind(context)()
|
|
||||||
})
|
|
||||||
.flat()
|
|
||||||
}
|
|
||||||
|
|
||||||
get keymaps() {
|
|
||||||
return this.extensions.map(extension => {
|
|
||||||
const context = {
|
|
||||||
options: extension.options,
|
|
||||||
editor: this.editor,
|
|
||||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
|
||||||
}
|
|
||||||
|
|
||||||
return keymap(extension.config.addKeyboardShortcuts.bind(context)())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
get nodeViews() {
|
get nodeViews() {
|
||||||
const { editor } = this
|
const { editor } = this
|
||||||
const { nodeExtensions } = splitExtensions(this.extensions)
|
const { nodeExtensions } = splitExtensions(this.extensions)
|
||||||
|
|||||||
Reference in New Issue
Block a user