diff --git a/src/components/input/editor/TipTap.vue b/src/components/input/editor/TipTap.vue index e7efdbb67..5dd8608ac 100644 --- a/src/components/input/editor/TipTap.vue +++ b/src/components/input/editor/TipTap.vue @@ -173,6 +173,7 @@ import {Placeholder} from '@tiptap/extension-placeholder' import {eventToHotkeyString} from '@github/hotkey' import {mergeAttributes} from '@tiptap/core' import {createRandomID} from '@/helpers/randomId' +import {isEditorContentEmpty} from '@/helpers/editorContentEmpty' const {t} = useI18n() @@ -267,7 +268,7 @@ const { const emit = defineEmits(['update:modelValue', 'save']) const inputHTML = ref('') -const isEmpty = computed(() => inputHTML.value === '' || inputHTML.value === '

') +const isEmpty = computed(() => isEditorContentEmpty(inputHTML.value)) const internalMode = ref(initialMode) const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled) diff --git a/src/components/tasks/partials/description.vue b/src/components/tasks/partials/description.vue index 043cf6321..78b5753fb 100644 --- a/src/components/tasks/partials/description.vue +++ b/src/components/tasks/partials/description.vue @@ -25,7 +25,7 @@ v-model="task.description" @update:model-value="saveWithDelay" @save="save" - :initial-mode="task.description !== '' ? 'preview' : 'edit'" + :initial-mode="isEditorContentEmpty(task.description) ? 'preview' : 'edit'" /> @@ -39,6 +39,7 @@ import Editor from '@/components/input/AsyncEditor' import type {ITask} from '@/modelTypes/ITask' import {useTaskStore} from '@/stores/tasks' import TaskModel from '@/models/task' +import {isEditorContentEmpty} from '@/helpers/editorContentEmpty' type AttachmentUploadFunction = (file: File, onSuccess: (attachmentUrl: string) => void) => Promise diff --git a/src/helpers/editorContentEmpty.ts b/src/helpers/editorContentEmpty.ts new file mode 100644 index 000000000..11fd2ae76 --- /dev/null +++ b/src/helpers/editorContentEmpty.ts @@ -0,0 +1,3 @@ +export function isEditorContentEmpty(content: string): boolean { + return content === '' || content === '

' +}