fix(editor): use edit enable

This commit is contained in:
kolaente 2023-10-21 19:29:19 +02:00
parent 80dc35eabb
commit 34420b623c
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -1,12 +1,12 @@
<template> <template>
<div class="tiptap"> <div class="tiptap">
<EditorToolbar <EditorToolbar
v-if="editor" v-if="editor && isEditEnabled"
:editor="editor" :editor="editor"
:upload-callback="uploadCallback" :upload-callback="uploadCallback"
/> />
<BubbleMenu <BubbleMenu
v-if="editor" v-if="editor && isEditEnabled"
:editor="editor" :editor="editor"
class="editor-bubble__wrapper" class="editor-bubble__wrapper"
> >
@ -62,11 +62,12 @@
<editor-content <editor-content
class="tiptap__editor" class="tiptap__editor"
:class="{'tiptap__editor-is-empty': isEmpty}" :class="{'tiptap__editor-is-empty': isEmpty, 'tiptap__editor-is-edit-enabled': isEditEnabled}"
:editor="editor" :editor="editor"
/> />
<input <input
v-if="isEditEnabled"
type="file" type="file"
id="tiptap__image-upload" id="tiptap__image-upload"
class="is-hidden" class="is-hidden"
@ -74,7 +75,7 @@
@change="addImage" @change="addImage"
/> />
<ul class="actions d-print-none" v-if="bottomActions.length > 0"> <ul class="tiptap__editor-actions d-print-none" v-if="bottomActions.length > 0">
<li v-if="isEditEnabled && showSave"> <li v-if="isEditEnabled && showSave">
<BaseButton <BaseButton
@click="bubbleSave" @click="bubbleSave"
@ -260,10 +261,17 @@ function bubbleSave() {
const editor = useEditor({ const editor = useEditor({
content: inputHTML.value, content: inputHTML.value,
editable: isEditEnabled,
extensions: [ extensions: [
StarterKit, StarterKit,
Placeholder.configure({ Placeholder.configure({
placeholder: t('input.editor.placeholder'), placeholder: () => {
if (!isEditEnabled) {
return ''
}
return t('input.editor.placeholder')
},
}), }),
Typography, Typography,
Underline, Underline,