mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +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,
|
useBuiltInExtensions: true,
|
||||||
|
disableInputRules: false,
|
||||||
|
disablePasteRules: false,
|
||||||
dropCursor: {},
|
dropCursor: {},
|
||||||
parseOptions: {},
|
parseOptions: {},
|
||||||
onInit: () => {},
|
onInit: () => {},
|
||||||
@ -141,12 +143,14 @@ export default class Editor extends Emitter {
|
|||||||
createInputRules() {
|
createInputRules() {
|
||||||
return this.extensions.inputRules({
|
return this.extensions.inputRules({
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
|
excludedExtensions: this.options.disableInputRules,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
createPasteRules() {
|
createPasteRules() {
|
||||||
return this.extensions.pasteRules({
|
return this.extensions.pasteRules({
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
|
excludedExtensions: this.options.disablePasteRules,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +78,18 @@ export default class ExtensionManager {
|
|||||||
].map(keys => keymap(keys))
|
].map(keys => keymap(keys))
|
||||||
}
|
}
|
||||||
|
|
||||||
inputRules({ schema }) {
|
inputRules({ schema, excludedExtensions }) {
|
||||||
const extensionInputRules = this.extensions
|
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'].includes(extension.type))
|
||||||
.filter(extension => extension.inputRules)
|
.filter(extension => extension.inputRules)
|
||||||
.map(extension => extension.inputRules({ schema }))
|
.map(extension => extension.inputRules({ schema }))
|
||||||
|
|
||||||
const nodeMarkInputRules = this.extensions
|
const nodeMarkInputRules = allowedExtensions
|
||||||
.filter(extension => ['node', 'mark'].includes(extension.type))
|
.filter(extension => ['node', 'mark'].includes(extension.type))
|
||||||
.filter(extension => extension.inputRules)
|
.filter(extension => extension.inputRules)
|
||||||
.map(extension => extension.inputRules({
|
.map(extension => extension.inputRules({
|
||||||
@ -101,13 +106,18 @@ export default class ExtensionManager {
|
|||||||
]), [])
|
]), [])
|
||||||
}
|
}
|
||||||
|
|
||||||
pasteRules({ schema }) {
|
pasteRules({ schema, excludedExtensions }) {
|
||||||
const extensionPasteRules = this.extensions
|
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'].includes(extension.type))
|
||||||
.filter(extension => extension.pasteRules)
|
.filter(extension => extension.pasteRules)
|
||||||
.map(extension => extension.pasteRules({ schema }))
|
.map(extension => extension.pasteRules({ schema }))
|
||||||
|
|
||||||
const nodeMarkPasteRules = this.extensions
|
const nodeMarkPasteRules = allowedExtensions
|
||||||
.filter(extension => ['node', 'mark'].includes(extension.type))
|
.filter(extension => ['node', 'mark'].includes(extension.type))
|
||||||
.filter(extension => extension.pasteRules)
|
.filter(extension => extension.pasteRules)
|
||||||
.map(extension => extension.pasteRules({
|
.map(extension => extension.pasteRules({
|
||||||
|
Loading…
Reference in New Issue
Block a user