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.

Enhance MarkdownEditor with auto-save event handling and update template bindings

Axel MINART0b501f4b516b
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
index 43d6fa4a..33aec9e5 100644
--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -44,7 +44,7 @@ const resourcesStore = useRessourcesStore();
const preferencesStore = usePreferences();
const props = defineProps<{ doc?: Partial<Document>; minimal?: boolean }>();
-const emit = defineEmits(['save', 'exit']);
+const emit = defineEmits(['save', 'exit', 'autoSave']);
const editorContainer = ref<HTMLDivElement>();
const markdownPreview = ref<HTMLDivElement>();
@@ -389,7 +389,7 @@ const autoSave = debounceDelayed(() => {
const content = editorView.value?.state.doc.toString() || '';
document.value.content_markdown = content;
document.value.content_html = compile(content);
- emit('save', document.value);
+ emit('autoSave', document.value);
}, 2000)
</script>
diff --git a/frontend/app/pages/dashboard/docs/edit/[id].vue b/frontend/app/pages/dashboard/docs/edit/[id].vue
index 8854a0ea..6f5775e3 100644
--- a/frontend/app/pages/dashboard/docs/edit/[id].vue
+++ b/frontend/app/pages/dashboard/docs/edit/[id].vue
@@ -1,5 +1,5 @@
<template>
- <MarkdownEditor v-if="document" ref="editor" :doc="document" @save="data => save(data)" @exit="exit" />
+ <MarkdownEditor v-if="document" ref="editor" :doc="document" @save="data => save(data)" @autoSave="data => autoSave(data)" @exit="exit" />
</template>
<script lang="ts" setup>
import type { Document } from '~/stores';
@@ -32,6 +32,11 @@ function save(doc: Document) {
.then(() => notifications.add({ type: 'success', title: 'Document successfully updated' }))
.catch(e => notifications.add({ type: 'error', title: 'Error', message: e }));
}
+
+function autoSave(doc: Document) {
+ store.update(doc)
+}
+
function exit() {
useRouter().push(`/dashboard/docs/${doc_id}`);
}