add keepOnSplit option for marks
This commit is contained in:
@@ -11,6 +11,7 @@ import getNodeType from './helpers/getNodeType'
|
||||
import splitExtensions from './helpers/splitExtensions'
|
||||
import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'
|
||||
import getRenderedAttributes from './helpers/getRenderedAttributes'
|
||||
import callOrReturn from './utilities/callOrReturn'
|
||||
|
||||
export default class ExtensionManager {
|
||||
|
||||
@@ -20,6 +21,8 @@ export default class ExtensionManager {
|
||||
|
||||
extensions: Extensions
|
||||
|
||||
splittableMarks: string[] = []
|
||||
|
||||
constructor(extensions: Extensions, editor: Editor) {
|
||||
this.editor = editor
|
||||
this.extensions = extensions
|
||||
@@ -32,6 +35,14 @@ export default class ExtensionManager {
|
||||
type: getSchemaTypeByName(extension.config.name, this.schema),
|
||||
}
|
||||
|
||||
if (extension.type === 'mark') {
|
||||
const keepOnSplit = callOrReturn(extension.config.keepOnSplit, context) ?? true
|
||||
|
||||
if (keepOnSplit) {
|
||||
this.splittableMarks.push(extension.config.name)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof extension.config.onCreate === 'function') {
|
||||
this.editor.on('create', extension.config.onCreate.bind(context))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user