mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
add option to disable input/pasterules
This commit is contained in:
parent
cf7ff907a1
commit
9f38f36447
@ -31,6 +31,8 @@ export default class Editor {
|
|||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
useBuiltInExtensions: true,
|
useBuiltInExtensions: true,
|
||||||
|
disabledInputRules: [],
|
||||||
|
disabledPasteRules: [],
|
||||||
dropCursor: {},
|
dropCursor: {},
|
||||||
parseOptions: {},
|
parseOptions: {},
|
||||||
onInit: () => {},
|
onInit: () => {},
|
||||||
@ -121,12 +123,14 @@ export default class Editor {
|
|||||||
createInputRules() {
|
createInputRules() {
|
||||||
return this.extensions.inputRules({
|
return this.extensions.inputRules({
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
|
excludedExtensions: this.options.disabledInputRules,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
createPasteRules() {
|
createPasteRules() {
|
||||||
return this.extensions.pasteRules({
|
return this.extensions.pasteRules({
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
|
excludedExtensions: this.options.disabledPasteRules,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,13 +74,16 @@ export default class ExtensionManager {
|
|||||||
].map(keys => keymap(keys))
|
].map(keys => keymap(keys))
|
||||||
}
|
}
|
||||||
|
|
||||||
inputRules({ schema }) {
|
inputRules({ schema, excludedExtensions }) {
|
||||||
const extensionInputRules = this.extensions
|
const allowedExtensions = this.extensions
|
||||||
|
.filter(extension => !excludedExtensions.includes(extension.name))
|
||||||
|
|
||||||
|
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({
|
||||||
@ -97,13 +100,16 @@ export default class ExtensionManager {
|
|||||||
]), [])
|
]), [])
|
||||||
}
|
}
|
||||||
|
|
||||||
pasteRules({ schema }) {
|
pasteRules({ schema, excludedExtensions }) {
|
||||||
const extensionPasteRules = this.extensions
|
const allowedExtensions = this.extensions
|
||||||
|
.filter(extension => !excludedExtensions.includes(extension.name))
|
||||||
|
|
||||||
|
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