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.

New Ctrl+X to exit editor

Smaug6739ae87cd60b67d
diff --git a/frontend/components/MarkdownEditor/Editor.ts b/frontend/components/MarkdownEditor/Editor.ts
index 7244a341..3b36e832 100644
--- a/frontend/components/MarkdownEditor/Editor.ts
+++ b/frontend/components/MarkdownEditor/Editor.ts
@@ -105,6 +105,13 @@ export class Editor extends EventTarget {
event.preventDefault();
this.dispatchEvent(new Event('save'));
}
+ if (event.ctrlKey && event.key === 'x') {
+ // If no text is selected, exit editor
+ if (this.area.value!.selectionStart === this.area.value!.selectionEnd) {
+ event.preventDefault();
+ this.dispatchEvent(new Event('exit'));
+ }
+ }
// Ctrl + P for preview
if (event.ctrlKey && event.key === 'p') {
event.preventDefault();
diff --git a/frontend/components/MarkdownEditor/MarkdownEditor.vue b/frontend/components/MarkdownEditor/MarkdownEditor.vue
index 91ddc314..3b22215c 100644
--- a/frontend/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/components/MarkdownEditor/MarkdownEditor.vue
@@ -33,7 +33,9 @@ const emit = defineEmits(['save']);
const update = () => (document.value.content_html = compile(textarea.value?.value || ''));
const handleClick = () => editor.handleInlineToolbar();
const markdownPreview = ref<HTMLDivElement>();
-editor.addEventListener('save', emitSave);
+
+editor.addEventListener('save', () => exec('save'));
+editor.addEventListener('exit', () => exec('exit'));
onMounted(() => window.addEventListener('mouseup', handleClick));
onBeforeUnmount(() => window.removeEventListener('mouseup', handleClick));