π 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
feat: new docs options and refactor content compiled to dedicate component
Smaug67398a5f85060f9f
diff --git a/frontend/app/components/AppPreferenceInputSection.vue b/frontend/app/components/AppPreferenceInputSection.vueindex bdc069a3..b406c419 100644--- a/frontend/app/components/AppPreferenceInputSection.vue+++ b/frontend/app/components/AppPreferenceInputSection.vue@@ -53,6 +53,17 @@spellcheck="false"@input="opt.onChange?.(p(opt.key).value)"/>++ <!-- Number -->+ <input+ v-else-if="opt.type === 'number'"+ v-model.number="p(opt.key).value"+ type="number"+ class="entry number-entry"+ :min="opt.min"+ :max="opt.max"+ :step="opt.step"+ /></div></div></template>@@ -133,4 +144,7 @@ h3 {opacity: 0.7;}}+.number-entry {+ width: 40%;+}</style>diff --git a/frontend/app/components/MarkdownEditor/MarkdownEditor.vue b/frontend/app/components/MarkdownEditor/MarkdownEditor.vueindex 5a55cbad..a3b43baa 100644--- a/frontend/app/components/MarkdownEditor/MarkdownEditor.vue+++ b/frontend/app/components/MarkdownEditor/MarkdownEditor.vue@@ -24,7 +24,7 @@<div class="panel-header"><span class="panel-label">Preview</span></div>- <div ref="markdownPreview" :class="['markdown-preview', `${theme}-theme`, `document-content`]" v-html="document.content_compiled" />+ <NodeDocumentContentCompiled ref="markdownPreviewComponent" :node="document" /></div></div></div>@@ -40,6 +40,7 @@ import { createUploadsHandlers } from './modules/editorUploads';import { createSnippetSource } from './modules/editorUtils';import { createCommands } from './modules/editorCommands';import Toolbar from './Toolbar.vue';+import NodeDocumentContentCompiled from '~/components/Node/Document/ContentCompiled.vue';import compile from '~/helpers/markdown';import type { Node } from '~/stores';@@ -51,11 +52,11 @@ const props = defineProps<{ doc?: Partial<Node> }>();const emit = defineEmits(['save', 'exit', 'autoSave']);const editorContainer = ref<HTMLDivElement>();-const markdownPreview = ref<HTMLDivElement>();+const markdownPreviewComponent = ref<InstanceType<typeof NodeDocumentContentCompiled>>();+const markdownPreview = computed(() => markdownPreviewComponent.value?.rootElement as HTMLElement | undefined);const editorView = ref<EditorView | null>(null);const showPreview = ref(false);-const theme = preferences.get('theme');const autoSaveEnabled = preferences.get('documentAutoSave');const document = ref<Partial<Node>>({diff --git a/frontend/app/components/Node/Document/ContentCompiled.vue b/frontend/app/components/Node/Document/ContentCompiled.vuenew file mode 100644index 00000000..9ec79712--- /dev/null+++ b/frontend/app/components/Node/Document/ContentCompiled.vue@@ -0,0 +1,35 @@+<template>+ <!-- eslint-disable vue/no-v-html -->+ <article+ ref="rootElement"+ :class="['markdown-preview', `${theme}-theme`, `document-content`]"+ :style="{ fontSize: documentFontSize + 'px', fontFamily: documentFontFamily, lineHeight: documentLineHeight }"+ v-html="node?.content_compiled"+ />+</template>++<script setup lang="ts">+import type { Node } from '~/stores';++const props = defineProps<{ node?: Partial<Node> }>();++const preferences = usePreferences();++const theme = computed(() => {+ if (props.node?.theme) return props.node.theme;+ return preferences.get('theme').value;+});+const documentFontSize = preferences.get('documentFontSize');+const documentFontFamily = preferences.get('documentFontFamily');+const documentLineHeight = preferences.get('documentLineHeight');++const rootElement = ref<HTMLElement>();++defineExpose({ rootElement });+</script>++<style lang="scss" scoped>+article {+ max-width: 100%;+}+</style>diff --git a/frontend/app/composables/usePreferences.ts b/frontend/app/composables/usePreferences.tsindex f6a3213d..bee1127b 100644--- a/frontend/app/composables/usePreferences.ts+++ b/frontend/app/composables/usePreferences.ts@@ -18,6 +18,9 @@ export const DEFAULT_PREFERENCES = {style: 'default' as 'default' | 'glassmorphism',theme: 'alexandrie' as string,documentAutoSave: true as boolean, // Enable automatic saving of documents+ documentFontSize: 16 as number,+ documentFontFamily: 'Poppins' as string,+ documentLineHeight: 1.5 as number,sidebarItems: {manageCategories: true as boolean,cdn: true as boolean,@@ -117,7 +120,7 @@ export function usePreferences() {};}-type OptionType = 'toggle' | 'select' | 'color' | 'radio' | 'groupCheckbox' | 'anode' | 'textarea';+type OptionType = 'toggle' | 'select' | 'color' | 'radio' | 'groupCheckbox' | 'anode' | 'textarea' | 'number';interface BaseOption<K extends PreferenceKey = PreferenceKey> {label: string;description?: string;@@ -164,5 +167,13 @@ interface TextareaOption<K extends PreferenceKey = PreferenceKey> extends BaseOponChange?: (value: Preferences[K]) => void;}-export type Option = ToggleOption | ColorOption | SelectOption | RadioOption | GroupCheckboxOption | AnodeOption | TextareaOption;-export type { ColorOption, SelectOption, RadioOption, ToggleOption, GroupCheckboxOption, AnodeOption, TextareaOption };+interface NumberOption<K extends PreferenceKey = PreferenceKey> extends BaseOption<K> {+ type: 'number';+ min?: number;+ max?: number;+ step?: number;+ onChange?: (value: Preferences[K]) => void;+}++export type Option = ToggleOption | ColorOption | SelectOption | RadioOption | GroupCheckboxOption | AnodeOption | TextareaOption | NumberOption;+export type { ColorOption, SelectOption, RadioOption, ToggleOption, GroupCheckboxOption, AnodeOption, TextareaOption, NumberOption };diff --git a/frontend/app/pages/(public)/doc/[id]/index.vue b/frontend/app/pages/(public)/doc/[id]/index.vueindex f8fed271..56b772b5 100644--- a/frontend/app/pages/(public)/doc/[id]/index.vue+++ b/frontend/app/pages/(public)/doc/[id]/index.vue@@ -14,13 +14,7 @@<NodeDocumentHeader :doc="article" :public="true" style="margin: 20px 0" /><!-- Document content if available -->- <article- v-if="hasContent"- ref="element"- :class="[`${article.theme || theme}-theme`, 'document-content']"- style="max-width: 100%"- v-html="article.content_compiled"- />+ <NodeDocumentContentCompiled v-if="hasContent" :node="article" ref="elementComponent" /><!-- Hierarchical children tree --><NodeTree v-if="children.length > 0" :nodes="children" :parent-id="article.id" />@@ -43,6 +37,7 @@</div></template><script setup lang="ts">+import NodeDocumentContentCompiled from '~/components/Node/Document/ContentCompiled.vue';import type { Node } from '~/stores';const documentsStore = useNodesStore();@@ -54,10 +49,10 @@ const { isOpened } = useSidebar();const { isTablet } = useDevice();const hideTOC = preferencesStore.get('hideTOC');-const theme = preferencesStore.get('theme');-const element = ref<HTMLElement>();const children = ref<Node[]>([]);+const elementComponent = ref<InstanceType<typeof NodeDocumentContentCompiled>>();+const element = computed(() => elementComponent.value?.rootElement as HTMLElement | undefined);const { data: article, error } = await useAsyncData(`public-doc-${route.params.id}`, async (): Promise<Node | undefined> => {const documentId = route.params.id;diff --git a/frontend/app/pages/dashboard/docs/[id].vue b/frontend/app/pages/dashboard/docs/[id].vueindex 3a9312fd..7c391b48 100644--- a/frontend/app/pages/dashboard/docs/[id].vue+++ b/frontend/app/pages/dashboard/docs/[id].vue@@ -5,13 +5,7 @@<div :style="{ maxWidth: width }" class="doc-container"><NodeDocumentHeader :doc="node" style="margin-bottom: 20px" />- <article- v-if="node"- ref="element"- :class="[`${node.theme || theme}-theme`, 'document-content']"- style="max-width: 100%"- v-html="node.content_compiled"- />+ <NodeDocumentContentCompiled v-if="node" ref="elementComponent" :node="node" /><NodeDocumentSkeleton v-else /><NodeDocumentFooter :document="node" :next="next" :previous="previous" /></div>@@ -34,6 +28,7 @@<script setup lang="ts">import NodeContextMenu from '~/components/Node/Action/ContextMenu.vue';import DeleteNodeModal from '~/components/Node/Modals/Delete.vue';+import NodeDocumentContentCompiled from '~/components/Node/Document/ContentCompiled.vue';import type { Node } from '~/stores';import type { RouteLocationNormalizedLoaded } from 'vue-router';@@ -47,10 +42,11 @@ const route = useRoute();const router = useRouter();const hideTOC = preferencesStore.get('hideTOC');-const theme = preferencesStore.get('theme');const docSize = preferencesStore.get('docSize');-const element = ref<HTMLElement>();+const elementComponent = ref<InstanceType<typeof NodeDocumentContentCompiled>>();+const element = computed(() => elementComponent.value?.rootElement as HTMLElement | undefined);+const node = ref<Node | undefined>();const error = ref<false | string>(false);diff --git a/frontend/app/pages/dashboard/settings/_views/documents.vue b/frontend/app/pages/dashboard/settings/_views/documents.vueindex 8211a46e..ea8d3183 100644--- a/frontend/app/pages/dashboard/settings/_views/documents.vue+++ b/frontend/app/pages/dashboard/settings/_views/documents.vue@@ -8,7 +8,7 @@</template><script setup lang="ts">-import { DOCUMENT_SIZES, DOCUMENT_THEMES } from '~/helpers/constants';+import { DOCUMENT_SIZES, DOCUMENT_THEMES, EDITOR_FONTS } from '~/helpers/constants';type InterfaceOption = Option & {tag?: string;@@ -38,6 +38,25 @@ const options: Array<{ label: string; options: InterfaceOption[] }> = [key: 'theme',choices: DOCUMENT_THEMES,},+ {+ label: 'Default font size',+ description: 'Set the default font size for all your documents.',+ type: 'number',+ key: 'documentFontSize',+ },+ {+ label: 'Default font family',+ description: 'Set the default font family for all your documents.',+ type: 'select',+ choices: EDITOR_FONTS,+ key: 'documentFontFamily',+ },+ {+ label: 'Default line height',+ description: 'Set the default line height for all your documents.',+ type: 'number',+ key: 'documentLineHeight',+ },],},];diff --git a/frontend/app/pages/dashboard/settings/index.vue b/frontend/app/pages/dashboard/settings/index.vueindex 316d5b89..ccea8ee5 100644--- a/frontend/app/pages/dashboard/settings/index.vue+++ b/frontend/app/pages/dashboard/settings/index.vue@@ -14,7 +14,9 @@</div></div><template v-for="section in navSections" :key="section.title">- <span>{{ section.title }}</span>+ <span+ >{{ section.title }} <tag v-if="section.tag" blue>{{ section.tag }}</tag></span+ ><template v-for="item in section.items" :key="item.label"><NuxtLink v-if="item.type === 'link'" :to="item.to" @click="close"> <Icon :name="item.icon" />{{ item.label }} </NuxtLink><NuxtLink v-else-if="item.type === 'action'" @click="item.action?.()"> <Icon :name="item.icon" />{{ item.label }} </NuxtLink>@@ -56,6 +58,7 @@ interface NavItem {interface NavSection {title: string;+ tag?: string;items: NavItem[];}@@ -98,12 +101,13 @@ const navSections: NavSection[] = [title: 'General',items: [{ key: 'profile', label: 'My profile', icon: 'profil' },- { key: 'apparence', label: 'Apparence', icon: 'brush' },+ { key: 'apparence', label: 'Apparence', icon: 'brush', bubble: true },{ key: 'security', label: 'Security', icon: 'security' },],},{title: 'Preferences',+ tag: 'New',items: [{ key: 'documents', label: 'Documents settings', icon: 'bookmark-stack' },{ key: 'editor', label: 'Editor settings', icon: 'editor' },diff --git a/frontend/app/styles/features/document-theme.scss b/frontend/app/styles/features/document-theme.scssindex e7267bec..530656c6 100644--- a/frontend/app/styles/features/document-theme.scss+++ b/frontend/app/styles/features/document-theme.scss@@ -19,7 +19,7 @@.latex-theme {max-width: 100%;- font-family: "LMRoman10", serif;+ font-family: "LMRoman10", serif !important;font-size: 17px;h1 {@@ -106,7 +106,7 @@font-size: 18px;.text {- font-family: 'Libertinus Math', serif;+ font-family: 'Libertinus Math', serif !important;font-size: 14px;}}@@ -115,7 +115,7 @@.latex-colored-theme {max-width: 100%;- font-family: "LMRoman10", serif;+ font-family: "LMRoman10", serif !important;font-size: 17px;h1 {@@ -250,7 +250,7 @@font-size: 18px;.text {- font-family: 'Libertinus Math', serif;+ font-family: 'Libertinus Math', serif !important;font-size: 14px;}}@@ -260,7 +260,7 @@.modern-theme {max-width: 100%;padding: 0 0.5rem;- font-family: $font-sans;+ font-family: $font-sans !important;font-size: 16px;color: var(--text-body);@@ -302,7 +302,6 @@code,pre {border-radius: var(--radius-sm);- font-family: 'Roboto Mono', monospace;font-size: 0.95em;color: var(--text-body);}@@ -416,7 +415,7 @@font-size: 18px;.text {- font-family: 'Libertinus Math', serif;+ font-family: 'Libertinus Math', serif !important;font-size: 14px;}}