Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Refactor MarkdownEditor to consolidate content update logic into a reusable function

Axel MINART404f68b3b395
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
index 33aec9e5..72542bfd 100644
--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -378,17 +378,19 @@ function syncScroll() {
markdownPreview.value.scrollTop = scrollPercentage * (markdownPreview.value.scrollHeight - markdownPreview.value.clientHeight);
}
-const save = debounce(() => {
+function updateDocumentContent() {
const content = editorView.value?.state.doc.toString() || '';
document.value.content_markdown = content;
document.value.content_html = compile(content);
+}
+
+const save = debounce(() => {
+ updateDocumentContent();
emit('save', document.value);
}, 1000);
const autoSave = debounceDelayed(() => {
- const content = editorView.value?.state.doc.toString() || '';
- document.value.content_markdown = content;
- document.value.content_html = compile(content);
+ updateDocumentContent();
emit('autoSave', document.value);
}, 2000)
</script>