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 {eventToHotkeyString} from '@github/hotkey'
|
||||||
import {mergeAttributes} from '@tiptap/core'
|
import {mergeAttributes} from '@tiptap/core'
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
import {isEditorContentEmpty} from '@/helpers/editorContentEmpty'
|
||||||
|
|
||||||
const {t} = useI18n()
|
const {t} = useI18n()
|
||||||
|
|
||||||
@ -267,7 +268,7 @@ const {
|
|||||||
const emit = defineEmits(['update:modelValue', 'save'])
|
const emit = defineEmits(['update:modelValue', 'save'])
|
||||||
|
|
||||||
const inputHTML = ref('')
|
const inputHTML = ref('')
|
||||||
const isEmpty = computed(() => inputHTML.value === '' || inputHTML.value === '<p></p>')
|
const isEmpty = computed(() => isEditorContentEmpty(inputHTML.value))
|
||||||
const internalMode = ref<Mode>(initialMode)
|
const internalMode = ref<Mode>(initialMode)
|
||||||
const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled)
|
const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
v-model="task.description"
|
v-model="task.description"
|
||||||
@update:model-value="saveWithDelay"
|
@update:model-value="saveWithDelay"
|
||||||
@save="save"
|
@save="save"
|
||||||
:initial-mode="task.description !== '' ? 'preview' : 'edit'"
|
:initial-mode="isEditorContentEmpty(task.description) ? 'preview' : 'edit'"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -39,6 +39,7 @@ import Editor from '@/components/input/AsyncEditor'
|
|||||||
import type {ITask} from '@/modelTypes/ITask'
|
import type {ITask} from '@/modelTypes/ITask'
|
||||||
import {useTaskStore} from '@/stores/tasks'
|
import {useTaskStore} from '@/stores/tasks'
|
||||||
import TaskModel from '@/models/task'
|
import TaskModel from '@/models/task'
|
||||||
|
import {isEditorContentEmpty} from '@/helpers/editorContentEmpty'
|
||||||
|
|
||||||
type AttachmentUploadFunction = (file: File, onSuccess: (attachmentUrl: string) => void) => Promise<string>
|
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