Use if to conditionally add escape hotkey
This commit is contained in:
parent
308a98c876
commit
ecd44059e4
@ -194,6 +194,7 @@ import {Extension, mergeAttributes} from '@tiptap/core'
|
||||
import {isEditorContentEmpty} from '@/helpers/editorContentEmpty'
|
||||
import inputPrompt from '@/helpers/inputPrompt'
|
||||
import {setLinkInEditor} from '@/components/input/editor/setLinkInEditor'
|
||||
import {Extensions} from '@tiptap/core/src/types'
|
||||
|
||||
const {
|
||||
modelValue,
|
||||
@ -325,10 +326,7 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
const editor = useEditor({
|
||||
// eslint-disable-next-line vue/no-ref-object-destructure
|
||||
editable: isEditing.value,
|
||||
extensions: [
|
||||
const extensions : Extensions = [
|
||||
// Starterkit:
|
||||
Blockquote,
|
||||
Bold,
|
||||
@ -427,11 +425,11 @@ const editor = useEditor({
|
||||
suggestion: suggestionSetup(t),
|
||||
}),
|
||||
BubbleMenu,
|
||||
]
|
||||
|
||||
// Add a custom extension for the Escape key
|
||||
...(
|
||||
discardShortcutEnabled
|
||||
?[discardShortcutEnabled && Extension.create({
|
||||
// Add a custom extension for the Escape key
|
||||
if (discardShortcutEnabled) {
|
||||
extensions.push(Extension.create({
|
||||
name: 'escapeKey',
|
||||
|
||||
addKeyboardShortcuts() {
|
||||
@ -442,10 +440,13 @@ const editor = useEditor({
|
||||
},
|
||||
}
|
||||
},
|
||||
})]
|
||||
: []
|
||||
),
|
||||
],
|
||||
}))
|
||||
}
|
||||
|
||||
const editor = useEditor({
|
||||
// eslint-disable-next-line vue/no-ref-object-destructure
|
||||
editable: isEditing.value,
|
||||
extensions: extensions,
|
||||
onUpdate: () => {
|
||||
bubbleNow()
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user