📚 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: add option to use parent thumbnail in document settings and update related components
Smaug67396890bbc29c21
diff --git a/backend/repositories/node.repository.go b/backend/repositories/node.repository.goindex efe20cf5..cf80199f 100644--- a/backend/repositories/node.repository.go+++ b/backend/repositories/node.repository.go@@ -40,7 +40,8 @@ func (r *NodeRepositoryImpl) GetAll(userId types.Snowflake) ([]*models.Node, errWITH RECURSIVE user_nodes AS (-- 1. Every node owned by the userSELECT n.id, n.user_id, n.parent_id, n.name, n.description, n.tags, n.role, n.color, n.icon, n.theme,- n.accessibility, n.access, n.display, n.`+"`order`"+`, n.size, n.metadata, n.created_timestamp, n.updated_timestamp+ n.accessibility, n.access, n.display, n.`+"`order`"+`, n.size, n.metadata, n.created_timestamp, n.updated_timestamp,+ CASE WHEN n.role IN (1, 2) THEN n.thumbnail ELSE NULL END AS thumbnailFROM nodes nWHERE n.user_id = ?@@ -48,7 +49,8 @@ func (r *NodeRepositoryImpl) GetAll(userId types.Snowflake) ([]*models.Node, err-- 2. Child nodes of owned nodes (even if not owned by the user)SELECT c.id, c.user_id, c.parent_id, c.name, c.description, c.tags, c.role, c.color, c.icon, c.theme,- c.accessibility, c.access, c.display, c.`+"`order`"+`, c.size, c.metadata, c.created_timestamp, c.updated_timestamp+ c.accessibility, c.access, c.display, c.`+"`order`"+`, c.size, c.metadata, c.created_timestamp, c.updated_timestamp,+ CASE WHEN c.role IN (1, 2) THEN c.thumbnail ELSE NULL END AS thumbnailFROM nodes cJOIN user_nodes un ON un.id = c.parent_id)diff --git a/frontend/app/components/Node/Document/Thumbnail.vue b/frontend/app/components/Node/Document/Thumbnail.vueindex 949554e4..f5bea9dc 100644--- a/frontend/app/components/Node/Document/Thumbnail.vue+++ b/frontend/app/components/Node/Document/Thumbnail.vue@@ -1,7 +1,7 @@<template><div class="illustration"><!-- eslint-disable-next-line vue/no-v-html -->- <div v-if="document?.thumbnail" class="user-image" v-html="document.thumbnail"></div>+ <div v-if="thumbnail" class="user-image" v-html="thumbnail"></div><svg v-else-if="defaultThumbnail" src="/svg/thumbnail.svg"><use href="/svg/thumbnail.svg" /></svg>@@ -11,9 +11,29 @@<script setup lang="ts">import type { Node } from '~/stores';-defineProps<{ document?: Node }>();+const props = defineProps<{ document?: Node }>();-const defaultThumbnail = usePreferencesStore().get('documentDefaultThumbnail');+const preferencesStore = usePreferencesStore();+const nodesStore = useNodesStore();++const defaultThumbnail = preferencesStore.get('documentDefaultThumbnail');+const useParentThumbnail = preferencesStore.get('documentUseParentThumbnail');++const thumbnail = computed(() => {+ if (!props.document) return null;++ if (props.document.thumbnail) return props.document.thumbnail;++ if (useParentThumbnail.value && props.document.parent_id) {+ let parent = nodesStore.getById(props.document.parent_id);+ while (parent) {+ if (parent.thumbnail) return parent.thumbnail;+ if (!parent.parent_id) break;+ parent = nodesStore.getById(parent.parent_id);+ }+ }+ return '';+});</script><style lang="scss" scoped>diff --git a/frontend/app/components/Node/Modals/Metadata.vue b/frontend/app/components/Node/Modals/Metadata.vueindex 66ee3da6..79ce4c05 100644--- a/frontend/app/components/Node/Modals/Metadata.vue+++ b/frontend/app/components/Node/Modals/Metadata.vue@@ -49,14 +49,22 @@ const { t } = useI18nT();const nodeStore = useNodesStore();const nodesTree = useNodesTree();-const node = ref<Node>(props.doc);+const node = ref<Node>({ ...props.doc });const pinnedToggle = ref(node.value.order == -1);const parentsTree = nodesTree.treeUpToRole(node.value.role);+onBeforeMount(async () => {+ const latestNode = await nodeStore.fetch({ id: node.value.id });+ if (latestNode) node.value = { ...latestNode }; // CLONE+});+watch(pinnedToggle, val => (node.value.order = val ? -1 : 0));watch(- node.value,- debounce(() => nodeStore.update(node.value), 500),+ node,+ debounce(async val => {+ await nodeStore.update({ ...(val as Node) }); // clone → avoid mutating the original object which is still used in the parent component+ }, 500),+ { deep: true },);</script>diff --git a/frontend/app/pages/dashboard/settings/_views/documents.vue b/frontend/app/pages/dashboard/settings/_views/documents.vueindex 5c039e3e..d0413008 100644--- a/frontend/app/pages/dashboard/settings/_views/documents.vue+++ b/frontend/app/pages/dashboard/settings/_views/documents.vue@@ -52,6 +52,12 @@ const options = computed<Array<{ label: string; options: InterfaceOption[] }>>((type: 'toggle',key: 'documentDefaultThumbnail',},+ {+ label: t('settings.documents.documentUseParentThumbnail'),+ description: t('settings.documents.documentUseParentThumbnailDesc'),+ type: 'toggle',+ key: 'documentUseParentThumbnail',+ },{label: t('settings.documents.defaultFontSize'),description: t('settings.documents.defaultFontSizeDesc'),diff --git a/frontend/app/stores/preferences/constants.ts b/frontend/app/stores/preferences/constants.tsindex 5ac0c31a..b71f365e 100644--- a/frontend/app/stores/preferences/constants.ts+++ b/frontend/app/stores/preferences/constants.ts@@ -22,6 +22,7 @@ export const DEFAULT_PREFERENCES = {documentLineHeight: 1.5 as number,documentShowAttachments: false as boolean,documentDefaultThumbnail: false as boolean,+ documentUseParentThumbnail: false as boolean,sidebarItems: {manageCategories: true as boolean,cdn: true as boolean,@@ -102,6 +103,7 @@ export const EDITOR_KEYS: PreferenceKey[] = ['documentLineHeight','documentShowAttachments','documentDefaultThumbnail',+ 'documentUseParentThumbnail','editorFontFamily','editorFontSize','editorSpellCheck',diff --git a/frontend/i18n/locales/en/settings.ts b/frontend/i18n/locales/en/settings.tsindex 55765775..90223e70 100644--- a/frontend/i18n/locales/en/settings.ts+++ b/frontend/i18n/locales/en/settings.ts@@ -113,6 +113,9 @@ export default {documentShowAttachmentsDesc: 'Show attached resources (images, PDFs, etc.) at the end of the document.',documentDefaultThumbnail: 'Default thumbnail',documentDefaultThumbnailDesc: "Show a default thumbnail for documents that don't have one, using the standard document icon.",+ documentUseParentThumbnail: 'Use parent thumbnail',+ documentUseParentThumbnailDesc:+ "Show the parent's thumbnail for documents that don't have their own thumbnail. If the parent doesn't have a thumbnail either, show the default thumbnail.",enablePrintMode: 'Enable print mode',enablePrintModeDesc: 'Simplify document header when printing (remove thumbnail, tags and description)',hideTOC: 'Hide table of contents',diff --git a/frontend/i18n/locales/fr/settings.ts b/frontend/i18n/locales/fr/settings.tsindex 7752624d..83ad9977 100644--- a/frontend/i18n/locales/fr/settings.ts+++ b/frontend/i18n/locales/fr/settings.ts@@ -114,6 +114,9 @@ export default {documentShowAttachmentsDesc: 'Afficher les ressources jointes (images, PDFs, etc.) à la fin du document.',documentDefaultThumbnail: 'Miniature par défaut',documentDefaultThumbnailDesc: "Afficher une miniature par défaut pour les documents qui n'en ont pas, en utilisant l'icône de document standard.",+ documentUseParentThumbnail: 'Utiliser la miniature du parent',+ documentUseParentThumbnailDesc:+ "Afficher la miniature du parent pour les documents qui n'ont pas leur propre miniature. Si le parent n'a pas de miniature non plus, afficher la miniature par défaut.",enablePrintMode: 'Activer le mode impression',enablePrintModeDesc: "Simplifier l'en-tête des documents imprimés (supprimer la miniature, les tags, la description et garder uniquement le titre)",hideTOC: 'Masquer la table des matières',