Add loading indicator to DefaultEditor initialization (#7756)

pull/7762/head^2
Ryan Wang 2025-09-20 23:35:01 +08:00 committed by GitHub
parent 83117058bc
commit 8a7805f869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 6 deletions

View File

@ -63,6 +63,7 @@ import {
IconFolder, IconFolder,
IconLink, IconLink,
IconUserFollow, IconUserFollow,
VLoading,
VTabItem, VTabItem,
VTabs, VTabs,
} from "@halo-dev/components"; } from "@halo-dev/components";
@ -75,6 +76,7 @@ import {
defineAsyncComponent, defineAsyncComponent,
inject, inject,
markRaw, markRaw,
nextTick,
onBeforeUnmount, onBeforeUnmount,
onMounted, onMounted,
ref, ref,
@ -412,6 +414,8 @@ const presetExtensions = [
}), }),
]; ];
const isInitialized = ref(false);
onMounted(async () => { onMounted(async () => {
const extensionsFromPlugins: Extensions = []; const extensionsFromPlugins: Extensions = [];
@ -451,11 +455,14 @@ onMounted(async () => {
debounceOnUpdate(); debounceOnUpdate();
}, },
onCreate() { onCreate() {
isInitialized.value = true;
nextTick(() => {
if (editor.value?.isEmpty && !props.title) { if (editor.value?.isEmpty && !props.title) {
editorTitleRef.value.focus(); editorTitleRef.value.focus();
} else { } else {
editor.value?.commands.focus(); editor.value?.commands.focus();
} }
});
}, },
}); });
}); });
@ -501,7 +508,8 @@ function handleFocusEditor(event) {
</script> </script>
<template> <template>
<div> <VLoading v-if="!isInitialized" />
<div v-else>
<AttachmentSelectorModal <AttachmentSelectorModal
v-bind="attachmentOptions" v-bind="attachmentOptions"
v-model:visible="attachmentSelectorModal" v-model:visible="attachmentSelectorModal"