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.

feat: enhance file upload management with new FileInline component and attachment visibility settings

Smaug67395d0523b9bbec
diff --git a/frontend/app/components/AppDrop.vue b/frontend/app/components/AppDrop.vue
index aa4e06a8..a789b53d 100644
--- a/frontend/app/components/AppDrop.vue
+++ b/frontend/app/components/AppDrop.vue
@@ -13,7 +13,7 @@
<div v-if="selectedFiles.length" class="files">
<div class="list">
<div v-for="(file, index) in selectedFiles" :key="file.name + '-' + file.size + '-' + file.lastModified" class="item">
- <NodeResourceInline :file="file" :remove-file="() => removeFile(index)" class="file-card" />
+ <FileInline :file="file" :remove-file="() => removeFile(index)" class="file-card" />
</div>
</div>
<footer>
diff --git a/frontend/app/components/FileInline.vue b/frontend/app/components/FileInline.vue
new file mode 100644
index 00000000..3bc09d8e
--- /dev/null
+++ b/frontend/app/components/FileInline.vue
@@ -0,0 +1,85 @@
+<template>
+ <div class="file-card">
+ <img v-if="preview" :src="preview" :alt="file.name" class="file-preview" />
+ <Icon v-else :name="resolveFileIcon(file.type)" display="xl" />
+ <div class="file-info">
+ <span class="file-name">{{ file.name }}</span>
+ <span class="file-size">{{ readableFileSize(file.size) }}</span>
+ </div>
+ <button class="file-remove" @click="removeFile">
+ <Icon name="close" />
+ </button>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { readableFileSize, resolveFileIcon } from '~/helpers/resources';
+
+const props = defineProps<{
+ file: File;
+ removeFile: () => void;
+}>();
+
+const preview = ref<string | null>(null);
+
+onMounted(async () => {
+ if (props.file.type.startsWith('image/')) {
+ preview.value = URL.createObjectURL(props.file);
+ }
+});
+
+onBeforeUnmount(() => {
+ if (preview.value) URL.revokeObjectURL(preview.value);
+});
+</script>
+
+<style scoped lang="scss">
+.file-card {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding: 0.5rem 0.75rem;
+ border-radius: var(--radius-md);
+ border: 1px solid var(--border);
+ background-color: var(--surface-base);
+ width: 100%;
+
+ .file-preview {
+ width: 48px;
+ height: 48px;
+ border-radius: var(--radius-sm);
+ object-fit: cover;
+ }
+
+ .file-info {
+ flex: 1;
+ min-width: 0;
+
+ .file-name {
+ display: block;
+ font-weight: 500;
+ color: var(--text-body);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .file-size {
+ font-size: 0.8rem;
+ color: var(--text-muted);
+ }
+ }
+
+ .file-remove {
+ padding: 0.25rem;
+ border-radius: var(--radius-sm);
+ color: var(--text-muted);
+ cursor: pointer;
+
+ &:hover {
+ background: var(--bg-tertiary);
+ color: var(--red);
+ }
+ }
+}
+</style>
diff --git a/frontend/app/components/Node/Document/Footer.vue b/frontend/app/components/Node/Document/Footer.vue
index 2e5cef9b..587da725 100644
--- a/frontend/app/components/Node/Document/Footer.vue
+++ b/frontend/app/components/Node/Document/Footer.vue
@@ -1,5 +1,10 @@
<template>
<footer v-if="document">
+ <div v-if="showAttachments" class="attachments">
+ <div v-for="attachment in attachments" :key="attachment.id" class="attachment">
+ <NodeResourceInline :node="attachment.data" />
+ </div>
+ </div>
<div class="footer-top-row">
<NuxtLink :to="`/dashboard/docs/edit/${document.id}`" :prefetch="false" class="edit-link">
<Icon name="edit_page" display="sm" />
@@ -26,10 +31,19 @@
<script lang="ts" setup>
import type { Node } from '~/stores';
-defineProps<{ document?: Node; next?: Node; previous?: Node }>();
+const props = defineProps<{ document?: Node; next?: Node; previous?: Node }>();
+
+const preferences = usePreferencesStore();
const { t } = useI18nT();
const { formatRelativeDate } = useDateFormatters();
+const nodesTree = useNodesTree();
+
+const showAttachments = preferences.get('documentShowAttachments');
+const attachments = computed(() => {
+ const children = nodesTree.getChildren(props.document?.id);
+ return children.filter(child => child.data.role === 4);
+});
</script>
<style scoped lang="scss">
@@ -37,6 +51,15 @@ footer {
margin: 50px 0 40px;
}
+.attachments {
+ gap: 10px;
+ margin-bottom: 20px;
+ width: 100%;
+ .attachment {
+ margin: 5px 0;
+ }
+}
+
.edit-link {
display: flex;
padding: 8px 14px;
diff --git a/frontend/app/components/Node/Resource/Inline.vue b/frontend/app/components/Node/Resource/Inline.vue
index 58a70ff6..e4b782fe 100644
--- a/frontend/app/components/Node/Resource/Inline.vue
+++ b/frontend/app/components/Node/Resource/Inline.vue
@@ -1,38 +1,23 @@
<template>
- <div class="file-card">
- <img v-if="preview" :src="preview" :alt="file.name" class="file-preview" />
- <Icon v-else :name="resolveFileIcon(file.type)" display="lg" />
+ <NuxtLink class="file-card" :to="`/dashboard/cdn/${node.id}/preview`">
+ <img v-if="preview" :src="preview" :alt="node.name" class="file-preview" />
+ <Icon v-else :name="resolveFileIcon(node.metadata?.filetype || 'file')" display="xl" />
<div class="file-info">
- <span class="file-name">{{ file.name }}</span>
- <span class="file-size">{{ readableFileSize(file.size) }}</span>
+ <span class="file-name">{{ node.name }}</span>
+ <span class="file-size">{{ readableFileSize(node.size ?? 0) }}</span>
</div>
- <button class="file-remove" @click="removeFile">
- <Icon name="close" />
- </button>
- </div>
+ </NuxtLink>
</template>
<script setup lang="ts">
-import { readableFileSize, resolveFileIcon } from '~/helpers/resources';
+import { isImageFile, readableFileSize, resolveFileIcon, resolvePreviewUrl } from '~/helpers/resources';
+import type { Node } from '~/stores';
-
-const props = defineProps<{
- file: File;
- removeFile: () => void;
-}>();
+const props = defineProps<{ node: Node }>();
const preview = ref<string | null>(null);
-onMounted(async () => {
- if (props.file.type.startsWith('image/')) {
- preview.value = URL.createObjectURL(props.file);
- }
-});
-
-onBeforeUnmount(() => {
- if (preview.value) URL.revokeObjectURL(preview.value);
-});
-
+if (isImageFile(props.node.metadata?.filetype)) preview.value = resolvePreviewUrl(props.node);
</script>
<style scoped lang="scss">
@@ -45,43 +30,34 @@ onBeforeUnmount(() => {
border: 1px solid var(--border);
background-color: var(--surface-base);
width: 100%;
-
- .file-preview {
- width: 48px;
- height: 48px;
- border-radius: var(--radius-sm);
- object-fit: cover;
+ &:hover {
+ background-color: var(--surface-raised);
}
+}
- .file-info {
- flex: 1;
- min-width: 0;
-
- .file-name {
- display: block;
- font-weight: 500;
- color: var(--text-body);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
+.file-preview {
+ width: 48px;
+ height: 48px;
+ border-radius: var(--radius-sm);
+ object-fit: cover;
+}
- .file-size {
- font-size: 0.8rem;
- color: var(--text-muted);
- }
+.file-info {
+ flex: 1;
+ min-width: 0;
+
+ .file-name {
+ display: block;
+ font-weight: 500;
+ color: var(--text-body);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
- .file-remove {
- padding: 0.25rem;
- border-radius: var(--radius-sm);
+ .file-size {
+ font-size: 0.8rem;
color: var(--text-muted);
- cursor: pointer;
-
- &:hover {
- background: var(--bg-tertiary);
- color: var(--red);
- }
}
}
</style>
diff --git a/frontend/app/helpers/resources.ts b/frontend/app/helpers/resources.ts
index bc84b0a0..8f01ad8c 100644
--- a/frontend/app/helpers/resources.ts
+++ b/frontend/app/helpers/resources.ts
@@ -14,7 +14,7 @@ const readableFileSize = (bytes: number): string => {
};
/** Check if a filetype MIME string represents an image */
-const isImageFile = (filetype: string): boolean => filetype.startsWith('image/');
+const isImageFile = (filetype?: string): boolean => filetype?.startsWith('image/') ?? false;
/** Check if a filetype MIME string represents a video */
const isVideoFile = (filetype: string): boolean => filetype.startsWith('video/');
diff --git a/frontend/app/pages/dashboard/settings/_views/documents.vue b/frontend/app/pages/dashboard/settings/_views/documents.vue
index 8526eae6..40a5615f 100644
--- a/frontend/app/pages/dashboard/settings/_views/documents.vue
+++ b/frontend/app/pages/dashboard/settings/_views/documents.vue
@@ -40,6 +40,12 @@ const options = computed<Array<{ label: string; options: InterfaceOption[] }>>((
key: 'theme',
choices: DOCUMENT_THEMES,
},
+ {
+ label: t('settings.documents.documentShowAttachments'),
+ description: t('settings.documents.documentShowAttachmentsDesc'),
+ type: 'toggle',
+ key: 'documentShowAttachments',
+ },
{
label: t('settings.documents.defaultFontSize'),
description: t('settings.documents.defaultFontSizeDesc'),
diff --git a/frontend/app/pages/dashboard/share-target.vue b/frontend/app/pages/dashboard/share-target.vue
index af39b1f8..18830c5b 100644
--- a/frontend/app/pages/dashboard/share-target.vue
+++ b/frontend/app/pages/dashboard/share-target.vue
@@ -21,7 +21,7 @@
<!-- Shared files preview -->
<section v-if="sharedFiles.length" class="share-section">
<div class="files-grid">
- <NodeResourceInline v-for="(file, index) in sharedFiles" :key="index" :file="file" :remove-file="() => removeFile(index)" class="file-card" />
+ <FileInline v-for="(file, index) in sharedFiles" :key="index" :file="file" :remove-file="() => removeFile(index)" class="file-card" />
</div>
</section>
@@ -215,7 +215,6 @@ async function uploadFiles() {
}
notifications.add({ type: 'success', title: `${uploadedCount} file(s) uploaded successfully` });
- cleanupPreviews();
router.push('/dashboard/cdn');
} catch (e) {
notifications.add({ message: String(e), title: 'Error uploading files', type: 'error' });
diff --git a/frontend/app/stores/preferences/constants.ts b/frontend/app/stores/preferences/constants.ts
index af456a9b..e7ce84fb 100644
--- a/frontend/app/stores/preferences/constants.ts
+++ b/frontend/app/stores/preferences/constants.ts
@@ -21,6 +21,7 @@ export const DEFAULT_PREFERENCES = {
documentFontSize: 16 as number,
documentFontFamily: 'Poppins' as string,
documentLineHeight: 1.5 as number,
+ documentShowAttachments: false as boolean,
sidebarItems: {
manageCategories: true as boolean,
cdn: true as boolean,
@@ -80,6 +81,8 @@ export const GENERAL_KEYS: PreferenceKey[] = [
'docSize',
'style',
'theme',
+ 'sidebarItems',
+ 'navbarItems',
];
export const EDITOR_KEYS: PreferenceKey[] = [
@@ -87,6 +90,7 @@ export const EDITOR_KEYS: PreferenceKey[] = [
'documentFontSize',
'documentFontFamily',
'documentLineHeight',
+ 'documentShowAttachments',
'editorFontFamily',
'editorFontSize',
'editorSpellCheck',
@@ -96,8 +100,6 @@ export const EDITOR_KEYS: PreferenceKey[] = [
];
export const ADVANCED_KEYS: PreferenceKey[] = [
- 'sidebarItems',
- 'navbarItems',
'snippets',
'developerMode',
'stylesInjectionEnabled',
diff --git a/frontend/i18n/locales/en/settings.ts b/frontend/i18n/locales/en/settings.ts
index 2ffd5951..ff60d2d8 100644
--- a/frontend/i18n/locales/en/settings.ts
+++ b/frontend/i18n/locales/en/settings.ts
@@ -2,7 +2,7 @@ export default {
about: {
changelog: 'Changelog',
client: 'Client',
- contact: "If you have questions, suggestions or found a bug, feel free to contact us! You can open an issue on the",
+ contact: 'If you have questions, suggestions or found a bug, feel free to contact us! You can open an issue on the',
description: 'Alexandrie is a personal knowledge management tool designed to help you organize and retrieve notes efficiently.',
features: 'It provides features like document organization, tagging and advanced search.',
githubRepo: 'GitHub repo',
@@ -17,8 +17,7 @@ export default {
advanced: {
resetLocalStorage: 'Reset local storage',
resetLocalStorageBtn: 'Clear local storage',
- resetLocalStorageDesc:
- 'This will reset all your local storage data. This action cannot be undone. Preferences will also be reset.',
+ resetLocalStorageDesc: 'This will reset all your local storage data. This action cannot be undone. Preferences will also be reset.',
resetPreferences: 'Reset all preferences',
resetPreferencesBtn: 'Reset preferences',
resetPreferencesDesc: 'This will restore all preferences to their default values. This action cannot be undone.',
@@ -111,6 +110,8 @@ export default {
defaultLineHeight: 'Default line height',
defaultLineHeightDesc: 'Set the default line height for all your documents.',
documentSize: 'Document size',
+ documentShowAttachments: 'Show attachments',
+ documentShowAttachmentsDesc: 'Show attached resources (images, PDFs, etc.) at the end of the document.',
enablePrintMode: 'Enable print mode',
enablePrintModeDesc: 'Simplify document header when printing (remove thumbnail, tags and description)',
hideTOC: 'Hide table of contents',
@@ -249,8 +250,7 @@ export default {
title: 'Security',
unlink: 'Unlink',
unrecognizedSession: 'Unrecognized session?',
- unrecognizedSessionDesc:
- 'If you see a session you do not recognize, change your password immediately and click "Sign out from all devices" below.',
+ unrecognizedSessionDesc: 'If you see a session you do not recognize, change your password immediately and click "Sign out from all devices" below.',
},
shortcuts: {
diff --git a/frontend/i18n/locales/fr/settings.ts b/frontend/i18n/locales/fr/settings.ts
index 2d97b269..1c9220a2 100644
--- a/frontend/i18n/locales/fr/settings.ts
+++ b/frontend/i18n/locales/fr/settings.ts
@@ -111,6 +111,8 @@ export default {
defaultLineHeight: 'Hauteur de ligne par défaut',
defaultLineHeightDesc: 'Définir la hauteur de ligne par défaut pour tous vos documents.',
documentSize: 'Taille du document',
+ documentShowAttachments: 'Afficher les pièces jointes',
+ documentShowAttachmentsDesc: 'Afficher les ressources jointes (images, PDFs, etc.) à la fin du document.',
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',