forked from vikunja/frontend
fix(editor): check for empty content
This commit is contained in:
parent
e02a106c64
commit
ba766a29af
@ -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 === '<p></p>')
|
||||
const isEmpty = computed(() => isEditorContentEmpty(inputHTML.value))
|
||||
const internalMode = ref<Mode>(initialMode)
|
||||
const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled)
|
||||
|
||||
|
@ -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'"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@ -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<string>
|
||||
|
||||
|
3
src/helpers/editorContentEmpty.ts
Normal file
3
src/helpers/editorContentEmpty.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function isEditorContentEmpty(content: string): boolean {
|
||||
return content === '' || content === '<p></p>'
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user