mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-14 18:49:02 +08:00
Merge pull request #272 from Chrissi2812/disabled-paste-input-rules
add option to disable input/pasterules
This commit is contained in:
commit
2225dc3f72
@ -35,6 +35,8 @@ export default class Editor extends Emitter {
|
||||
}],
|
||||
},
|
||||
useBuiltInExtensions: true,
|
||||
disableInputRules: false,
|
||||
disablePasteRules: false,
|
||||
dropCursor: {},
|
||||
parseOptions: {},
|
||||
onInit: () => {},
|
||||
@ -141,12 +143,14 @@ export default class Editor extends Emitter {
|
||||
createInputRules() {
|
||||
return this.extensions.inputRules({
|
||||
schema: this.schema,
|
||||
excludedExtensions: this.options.disableInputRules,
|
||||
})
|
||||
}
|
||||
|
||||
createPasteRules() {
|
||||
return this.extensions.pasteRules({
|
||||
schema: this.schema,
|
||||
excludedExtensions: this.options.disablePasteRules,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -78,13 +78,18 @@ export default class ExtensionManager {
|
||||
].map(keys => keymap(keys))
|
||||
}
|
||||
|
||||
inputRules({ schema }) {
|
||||
const extensionInputRules = this.extensions
|
||||
inputRules({ schema, excludedExtensions }) {
|
||||
if (!(excludedExtensions instanceof Array) && excludedExtensions) return []
|
||||
|
||||
const allowedExtensions = (excludedExtensions instanceof Array) ? this.extensions
|
||||
.filter(extension => !excludedExtensions.includes(extension.name)) : this.extensions
|
||||
|
||||
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({
|
||||
@ -101,13 +106,18 @@ export default class ExtensionManager {
|
||||
]), [])
|
||||
}
|
||||
|
||||
pasteRules({ schema }) {
|
||||
const extensionPasteRules = this.extensions
|
||||
pasteRules({ schema, excludedExtensions }) {
|
||||
if (!(excludedExtensions instanceof Array) && excludedExtensions) return []
|
||||
|
||||
const allowedExtensions = (excludedExtensions instanceof Array) ? this.extensions
|
||||
.filter(extension => !excludedExtensions.includes(extension.name)) : this.extensions
|
||||
|
||||
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({
|
||||
|
Loading…
Reference in New Issue
Block a user