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.

Fix syntax

Smaug67396268811bd897
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
index 4c311d10..5daa5057 100644
--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -42,23 +42,11 @@ const document = ref<Partial<Document>>({
content_html: compile(props.doc?.content_markdown || ''),
});
-function exec(action: string, _doc?: any, payload?: any) {
- if (action === 'preview') {
- showPreview.value = !showPreview.value;
- return;
- }
- if (action === 'openColorPicker') {
- openColorModal();
- return;
- }
- if (action === 'save') {
- save();
- return;
- }
- if (action === 'goto') {
- if (document.value.id) useRouter().push(`/dashboard/docs/${document.value.id}`);
- return;
- }
+function exec(action: string, payload?: string) {
+ if (action === 'preview') return (showPreview.value = !showPreview.value);
+ if (action === 'openColorPicker') return openColorModal();
+ if (action === 'save') return save();
+ if (action === 'goto') if (document.value.id) return useRouter().push(`/dashboard/docs/${document.value.id}`);
if (!editorView.value) return;
@@ -102,12 +90,12 @@ function exec(action: string, _doc?: any, payload?: any) {
changes = { from, to, insert: `1. ${selectedText}\n` };
break;
case 'color': {
- const color = String(payload || '').trim()
- if (!color) return
- const value = selectedText || 'text'
- const insert = `{color:${color}}(${value})`
- changes = { from, to, insert }
- break
+ const color = String(payload || '').trim();
+ if (!color) return;
+ const value = selectedText || 'text';
+ const insert = `{color:${color}}(${value})`;
+ changes = { from, to, insert };
+ break;
}
}
view.dispatch({
@@ -119,40 +107,44 @@ function exec(action: string, _doc?: any, payload?: any) {
}
function openColorModal() {
- const rootDoc = window.document
- const container = rootDoc.createElement('div')
- const modal = rootDoc.createElement('div')
- container.className = 'color-modal-overlay'
- modal.className = 'color-modal'
+ const rootDoc = window.document;
+ const container = rootDoc.createElement('div');
+ const modal = rootDoc.createElement('div');
+ container.className = 'color-modal-overlay';
+ modal.className = 'color-modal';
modal.innerHTML = `
<div class="panel">
<div class="swatches">
- ${['blue','red','green','yellow','primary','purple','pink','teal'].map(c => `<button class="swatch" data-color="${c}"></button>`).join('')}
+ ${['blue', 'red', 'green', 'yellow', 'primary', 'purple', 'pink', 'teal'].map(c => `<button class="swatch" data-color="${c}"></button>`).join('')}
</div>
<div class="custom">
<input class="hex" placeholder="#RRGGBB" />
<button class="apply">Apply</button>
</div>
</div>
- `
- container.appendChild(modal)
- rootDoc.body.appendChild(container)
- const close = () => { if (container.parentNode) rootDoc.body.removeChild(container) }
- container.addEventListener('click', e => { if (e.target === container) close() })
+ `;
+ container.appendChild(modal);
+ rootDoc.body.appendChild(container);
+ const close = () => {
+ if (container.parentNode) rootDoc.body.removeChild(container);
+ };
+ container.addEventListener('click', e => {
+ if (e.target === container) close();
+ });
modal.querySelectorAll('.swatch').forEach(el => {
el.addEventListener('click', () => {
- const color = (el as HTMLElement).getAttribute('data-color') || ''
- exec('color', undefined, color)
- close()
- })
- })
- const input = modal.querySelector('.hex') as HTMLInputElement | null
- const apply = modal.querySelector('.apply') as HTMLButtonElement | null
+ const color = (el as HTMLElement).getAttribute('data-color') || '';
+ exec('color', color);
+ close();
+ });
+ });
+ const input = modal.querySelector('.hex') as HTMLInputElement | null;
+ const apply = modal.querySelector('.apply') as HTMLButtonElement | null;
apply?.addEventListener('click', () => {
- const val = input?.value?.trim() || ''
- if (val) exec('color', undefined, val)
- close()
- })
+ const val = input?.value?.trim() || '';
+ if (val) exec('color', val);
+ close();
+ });
}
const snippets: Record<string, string> = {
'!blue': ':::blue\n$0\n:::',
@@ -375,22 +367,91 @@ input {
</style>
<style lang="scss">
-.color-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 99999 }
-.color-modal { background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 14px; padding: 16px; min-width: 280px; box-shadow: 0 20px 60px rgba(0,0,0,.3) }
-.color-modal .panel { display: grid; gap: 12px }
-.color-modal .swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px }
-.color-modal .swatch { width: 30px; height: 30px; border-radius: 999px; border: 1px solid var(--border-color); cursor: pointer; transition: transform .1s ease, box-shadow .2s ease }
-.color-modal .swatch:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.15) }
-.color-modal .swatch[data-color="blue"] { background: #3b82f6 }
-.color-modal .swatch[data-color="red"] { background: #ef4444 }
-.color-modal .swatch[data-color="green"] { background: #22c55e }
-.color-modal .swatch[data-color="yellow"] { background: #eab308 }
-.color-modal .swatch[data-color="primary"] { background: var(--primary) }
-.color-modal .swatch[data-color="purple"] { background: #a855f7 }
-.color-modal .swatch[data-color="pink"] { background: #ec4899 }
-.color-modal .swatch[data-color="teal"] { background: #14b8a6 }
-.color-modal .custom { display: flex; gap: 8px; align-items: center }
-.color-modal .hex { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color) }
-.color-modal .apply { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-contrast); font-weight: 600; cursor: pointer; transition: background .2s ease }
-.color-modal .apply:hover { background: var(--border-color) }
+.color-modal-overlay {
+ position: fixed;
+ inset: 0;
+ background: rgba(0, 0, 0, 0.45);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 99999;
+}
+.color-modal {
+ background: var(--bg-color);
+ border: 1px solid var(--border-color);
+ border-radius: 14px;
+ padding: 16px;
+ min-width: 280px;
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
+}
+.color-modal .panel {
+ display: grid;
+ gap: 12px;
+}
+.color-modal .swatches {
+ display: grid;
+ grid-template-columns: repeat(8, 1fr);
+ gap: 8px;
+}
+.color-modal .swatch {
+ width: 30px;
+ height: 30px;
+ border-radius: 999px;
+ border: 1px solid var(--border-color);
+ cursor: pointer;
+ transition: transform 0.1s ease, box-shadow 0.2s ease;
+}
+.color-modal .swatch:hover {
+ transform: translateY(-1px);
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
+}
+.color-modal .swatch[data-color='blue'] {
+ background: #3b82f6;
+}
+.color-modal .swatch[data-color='red'] {
+ background: #ef4444;
+}
+.color-modal .swatch[data-color='green'] {
+ background: #22c55e;
+}
+.color-modal .swatch[data-color='yellow'] {
+ background: #eab308;
+}
+.color-modal .swatch[data-color='primary'] {
+ background: var(--primary);
+}
+.color-modal .swatch[data-color='purple'] {
+ background: #a855f7;
+}
+.color-modal .swatch[data-color='pink'] {
+ background: #ec4899;
+}
+.color-modal .swatch[data-color='teal'] {
+ background: #14b8a6;
+}
+.color-modal .custom {
+ display: flex;
+ gap: 8px;
+ align-items: center;
+}
+.color-modal .hex {
+ flex: 1;
+ padding: 8px 10px;
+ border-radius: 8px;
+ border: 1px solid var(--border-color);
+ background: var(--bg-color);
+ color: var(--text-color);
+}
+.color-modal .apply {
+ padding: 8px 12px;
+ border-radius: 8px;
+ border: 1px solid var(--border-color);
+ background: var(--bg-contrast);
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 0.2s ease;
+}
+.color-modal .apply:hover {
+ background: var(--border-color);
+}
</style>
diff --git a/frontend/app/components/MarkdownEditor/Toolbar.vue b/frontend/app/components/MarkdownEditor/Toolbar.vue
index 17d6fb42..f531a7e2 100644
--- a/frontend/app/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/app/components/MarkdownEditor/Toolbar.vue
@@ -1,11 +1,7 @@
<template>
<div class="toolbar">
<button v-for="item in toolbar" :key="item.name" v-html="item.icon" @click="emitAction(item.action)" :title="item.name" class="btn"></button>
- <div class="color-picker">
- <button class="btn color" title="Color" @click.stop="openColorPicker">
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12 3a9 9 0 0 0-9 9c0 4.97 4.03 9 9 9h4a3 3 0 0 0 0-6h-1a1 1 0 1 1 0-2h1a5 5 0 0 0 0-10h-4Zm-3 8a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Zm3-2a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Zm3 2a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3Z"/></svg>
- </button>
- </div>
+ <div class="color-picker"></div>
<AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Access" size="100px" class="entry" v-if="!minimal" />
<AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="300px" class="entry" v-if="!minimal" />
<AppHint text="Tags has been moved down" />
@@ -20,9 +16,6 @@ const categories = new TreeStructure(useSidebarTree().categories.value).generate
const props = defineProps<{ document: Partial<Document>; minimal?: boolean }>();
const emit = defineEmits(['execute-action']);
const emitAction = (action: string) => emit('execute-action', action, props.document);
-function openColorPicker() {
- emit('execute-action', 'openColorPicker', props.document)
-}
const openModal = () => useModal().add(new Modal(shallowRef(ModalSyntax), {}, () => {}, true));
const accessibilities: ANode[] = [
{
@@ -92,6 +85,11 @@ const toolbar = [
icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M680-80v-60h100v-30h-60v-60h60v-30H680v-60h120q17 0 28.5 11.5T840-280v40q0 17-11.5 28.5T800-200q17 0 28.5 11.5T840-160v40q0 17-11.5 28.5T800-80H680Zm0-280v-110q0-17 11.5-28.5T720-510h60v-30H680v-60h120q17 0 28.5 11.5T840-560v70q0 17-11.5 28.5T800-450h-60v30h100v60H680Zm60-280v-180h-60v-60h120v240h-60ZM120-200v-80h480v80H120Zm0-240v-80h480v80H120Zm0-240v-80h480v80H120Z"/></svg>',
action: 'orderedList',
},
+ {
+ name: 'Color',
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#1f1f1f"><path d="M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 32.5-156t88-127Q256-817 330-848.5T488-880q80 0 151 27.5t124.5 76q53.5 48.5 85 115T880-518q0 115-70 176.5T640-280h-74q-9 0-12.5 5t-3.5 11q0 12 15 34.5t15 51.5q0 50-27.5 74T480-80Zm0-400Zm-220 40q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120-160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm200 0q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm120 160q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17ZM480-160q9 0 14.5-5t5.5-13q0-14-15-33t-15-57q0-42 29-67t71-25h70q66 0 113-38.5T800-518q0-121-92.5-201.5T488-800q-136 0-232 93t-96 227q0 133 93.5 226.5T480-160Z"/></svg>`,
+ action: 'openColorPicker',
+ },
{
name: 'Preview',
icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-480H200v480Zm280-80q-82 0-146.5-44.5T240-440q29-71 93.5-115.5T480-600q82 0 146.5 44.5T720-440q-29 71-93.5 115.5T480-280Zm0-60q56 0 102-26.5t72-73.5q-26-47-72-73.5T480-540q-56 0-102 26.5T306-440q26 47 72 73.5T480-340Zm0-100Zm0 60q25 0 42.5-17.5T540-440q0-25-17.5-42.5T480-500q-25 0-42.5 17.5T420-440q0 25 17.5 42.5T480-380Z"/></svg>',