Fix content editor performances issue by debouncing and removing the link search

This commit is contained in:
2024-11-10 23:10:23 +01:00
parent 42658558c5
commit 60f1fbb4aa
5 changed files with 12 additions and 2 deletions

View File

@@ -19,7 +19,7 @@
</SplitterPanel>
<SplitterResizeHandle class="bg-light-35 dark:bg-dark-35 w-px xl!mx-4 mx-2" />
<SplitterPanel asChild>
<div class="flex-1 max-h-full !overflow-y-auto px-8"><Markdown :content="page.content" /></div>
<div class="flex-1 max-h-full !overflow-y-auto px-8"><Markdown :content="debounced" :proses="{ 'a': FakeA }" /></div>
</SplitterPanel>
</SplitterGroup>
</template>
@@ -41,6 +41,8 @@
</template>
<script setup lang="ts">
import FakeA from '~/components/prose/FakeA.vue';
const route = useRouter().currentRoute;
const path = computed(() => Array.isArray(route.value.params.path) ? route.value.params.path[0] : route.value.params.path);
const { user, loggedIn } = useUserSession();
@@ -49,6 +51,8 @@ const toaster = useToast();
const saveStatus = ref<'idle' | 'pending' | 'success' | 'error'>('idle');
const { data: page, status, error } = await useLazyFetch(`/api/file/${encodeURIComponent(path.value)}`, { watch: [ route, path ]});
const content = computed(() => page.value?.content);
const debounced = useDebounce(content, 250);
if(!loggedIn || (page.value && page.value.owner !== user.value?.id))
{