π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Refactor auto-save logic in MarkdownEditor to use a conditional function based on user preferences + Call autoSave inside OnBeforeUnmount based on preferences
Axel MINART2e68dd9aa5cb
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vueindex 72542bfd..ccc9b762 100644--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue@@ -4,9 +4,9 @@<div class="editor-container"><Toolbar v-model="document" :minimal="minimal" @execute-action="exec" /><div style="display: flex; min-height: 0; padding: 6px; flex: 1; flex-direction: column; gap: 8px">- <input v-if="!minimal" v-model="document.name" placeholder="Title" class="title" @input="autoSave" />- <input v-if="!minimal" v-model="document.description" placeholder="Description" class="description" @input="autoSave" />- <AppTagInput v-model="document.tags" style="margin-bottom: 10px" @update:model-value="autoSave" />+ <input v-if="!minimal" v-model="document.name" placeholder="Title" class="title" @input="autoSaveConditional" />+ <input v-if="!minimal" v-model="document.description" placeholder="Description" class="description" @input="autoSaveConditional" />+ <AppTagInput v-model="document.tags" style="margin-bottom: 10px" @update:model-value="autoSaveConditional" /><div ref="container" class="markdown"><div ref="editorContainer" class="codemirror-editor" style="border-right: 1px solid var(--border-color)" /><!-- eslint-disable-next-line vue/no-v-html -->@@ -314,11 +314,7 @@ const updateListener = EditorView.updateListener.of(v => {const content = v.state.doc.toString();document.value.content_markdown = content;document.value.content_html = compile(content);-- if(preferencesStore.get('documentAutoSave').value){- // delayed autoSave- autoSave();- }+ autoSaveConditional();}});const state = EditorState.create({@@ -352,6 +348,10 @@ onMounted(() => {});onBeforeUnmount(() => {+ if (preferencesStore.get('documentAutoSave').value) {+ updateDocumentContent();+ emit('autoSave', document.value);+ }if (editorView.value) editorView.value.destroy();editorView.value?.scrollDOM.removeEventListener('scroll', syncScroll);window.removeEventListener('keydown', handleGlobalKeys);@@ -378,6 +378,12 @@ function syncScroll() {markdownPreview.value.scrollTop = scrollPercentage * (markdownPreview.value.scrollHeight - markdownPreview.value.clientHeight);}+function autoSaveConditional() {+ if (preferencesStore.get('documentAutoSave').value) {+ autoSave();+ }+}+function updateDocumentContent() {const content = editorView.value?.state.doc.toString() || '';document.value.content_markdown = content;