add option to disable input/pasterules

This commit is contained in:
Chrissi2812 2019-04-24 16:13:57 +02:00
parent cf7ff907a1
commit 9f38f36447
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA
2 changed files with 16 additions and 6 deletions

View File

@ -31,6 +31,8 @@ export default class Editor {
}],
},
useBuiltInExtensions: true,
disabledInputRules: [],
disabledPasteRules: [],
dropCursor: {},
parseOptions: {},
onInit: () => {},
@ -121,12 +123,14 @@ export default class Editor {
createInputRules() {
return this.extensions.inputRules({
schema: this.schema,
excludedExtensions: this.options.disabledInputRules,
})
}
createPasteRules() {
return this.extensions.pasteRules({
schema: this.schema,
excludedExtensions: this.options.disabledPasteRules,
})
}

View File

@ -74,13 +74,16 @@ export default class ExtensionManager {
].map(keys => keymap(keys))
}
inputRules({ schema }) {
const extensionInputRules = this.extensions
inputRules({ schema, excludedExtensions }) {
const allowedExtensions = this.extensions
.filter(extension => !excludedExtensions.includes(extension.name))
const extensionInputRules = allowedExtensions
.filter(extension => ['extension'].includes(extension.type))
.filter(extension => extension.inputRules)
.map(extension => extension.inputRules({ schema }))
const nodeMarkInputRules = this.extensions
const nodeMarkInputRules = allowedExtensions
.filter(extension => ['node', 'mark'].includes(extension.type))
.filter(extension => extension.inputRules)
.map(extension => extension.inputRules({
@ -97,13 +100,16 @@ export default class ExtensionManager {
]), [])
}
pasteRules({ schema }) {
const extensionPasteRules = this.extensions
pasteRules({ schema, excludedExtensions }) {
const allowedExtensions = this.extensions
.filter(extension => !excludedExtensions.includes(extension.name))
const extensionPasteRules = allowedExtensions
.filter(extension => ['extension'].includes(extension.type))
.filter(extension => extension.pasteRules)
.map(extension => extension.pasteRules({ schema }))
const nodeMarkPasteRules = this.extensions
const nodeMarkPasteRules = allowedExtensions
.filter(extension => ['node', 'mark'].includes(extension.type))
.filter(extension => extension.pasteRules)
.map(extension => extension.pasteRules({