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.

Fixes

Smaug6739f76a07415b10
diff --git a/frontend/components/AppHint.vue b/frontend/components/AppHint.vue
index 5bbbc19b..46131259 100644
--- a/frontend/components/AppHint.vue
+++ b/frontend/components/AppHint.vue
@@ -15,8 +15,10 @@ const show = ref(false);
<style scoped lang="scss">
.hint-wrapper {
position: relative;
- display: inline-block;
margin-left: 0.25rem;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.hint-icon {
diff --git a/frontend/components/AppSelect.vue b/frontend/components/AppSelect.vue
index d13a06f8..726c14bd 100644
--- a/frontend/components/AppSelect.vue
+++ b/frontend/components/AppSelect.vue
@@ -1,10 +1,10 @@
<template>
- <div class="category-select">
+ <div class="category-select" :style="{ width: size + 'px' }">
<button class="select-button" @click="toggleDropdown">
{{ selected?.title || placeholder }}
</button>
- <div v-if="open" class="dropdown">
+ <div v-show="open" class="dropdown">
<ul class="tree-list">
<AppSelectNode v-for="item in items" :key="item.id" :node="item" :level="0" @select="handleSelect" />
</ul>
@@ -14,11 +14,12 @@
<script setup lang="ts">
const props = defineProps<{
- items: Item[];
+ items: ANode[];
placeholder?: string;
- modelValue?: string;
+ modelValue?: string | number;
+ size?: string;
}>();
-const selectedId = ref<string>(props.modelValue || '');
+const selectedId = ref<string | number>(props.modelValue || '');
const emit = defineEmits(['update:modelValue']);
@@ -26,7 +27,7 @@ const open = ref(false);
const selected = computed(() => {
// Find the selected item based on the selectedId
// Recursively search through the items (and their children) to find the selected item
- const findSelected = (items: Item[]): Item | null => {
+ const findSelected = (items: ANode[]): ANode | null => {
for (const item of items) {
if (item.id === selectedId.value) {
return item;
@@ -49,7 +50,7 @@ function toggleDropdown() {
function handleSelect(node: Item) {
selectedId.value = node.id;
- emit('update:modelValue', node);
+ emit('update:modelValue', node.id);
open.value = false;
}
</script>
@@ -57,13 +58,12 @@ function handleSelect(node: Item) {
<style scoped>
.category-select {
position: relative;
- width: 100%;
- max-width: 400px;
+ width: 200px;
}
.select-button {
width: 100%;
- padding: 8px 12px;
+ padding: 6px 12px;
border: 1px solid #ccc;
background: white;
text-align: left;
diff --git a/frontend/components/AppSelectNode.vue b/frontend/components/AppSelectNode.vue
index 4dc980e2..5382d526 100644
--- a/frontend/components/AppSelectNode.vue
+++ b/frontend/components/AppSelectNode.vue
@@ -11,7 +11,7 @@
<script setup lang="ts">
const props = defineProps<{
- node: Item;
+ node: ANode;
level: number;
}>();
diff --git a/frontend/components/MarkdownEditor/MarkdownEditor.vue b/frontend/components/MarkdownEditor/MarkdownEditor.vue
index 4291a718..d5659c13 100644
--- a/frontend/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/components/MarkdownEditor/MarkdownEditor.vue
@@ -1,6 +1,6 @@
<template>
<div class="editor-container" @keydown="editor.handleKeydown">
- <Toolbar :document="document" :minimal="options?.toolbar == 'minimal'" @execute-action="(a:string) => editor.actions(a)" />
+ <Toolbar :document="document" :minimal="options?.toolbar == 'minimal'" />
<div style="padding: 15px; height: 100%; width: 100%">
<input placeholder="Title" class="title" v-model="document.name" />
<input placeholder="Description" class="description" v-model="document.description" />
@@ -77,6 +77,7 @@ function debounce(fn: Function, wait: number) {
width: 100%;
box-shadow: 0 0 10px 0 var(--border-color);
border-radius: 15px;
+ padding: 10px;
}
.markdown {
diff --git a/frontend/components/MarkdownEditor/Toolbar.vue b/frontend/components/MarkdownEditor/Toolbar.vue
index fa453f36..97406975 100644
--- a/frontend/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/components/MarkdownEditor/Toolbar.vue
@@ -1,14 +1,10 @@
<template>
<div class="toolbar">
<button v-for="item in toolbar" :key="item.name" v-html="item.icon" @click="emitAction(item.action)" :title="item.name"></button>
- <select v-if="!minimal" v-model="document.accessibility" style="margin-right: 5px">
- <option :value="1">Visible</option>
- <option :value="2">Draf</option>
- <option :value="3">Archive</option>
- </select>
- <AppSelect v-model="document.category" :items="categories" placeholder="Select category" />
+ <AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Select accessibility" size="100" />
+ <AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="220" />
<input type="text" v-model="document.tags" placeholder="Tags" style="margin-right: 5px" />
- <button @click="() => emitAction('exit')" style="margin-left: auto"><Icon name="close" :big="true" /></button>
+ <AppHint text="Markdown supported" />
</div>
</template>
@@ -18,6 +14,23 @@ 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);
+const accessibilities: ANode[] = [
+ {
+ id: 1,
+ title: 'Visible',
+ parent_id: '',
+ },
+ {
+ id: 2,
+ title: 'Draft',
+ parent_id: '',
+ },
+ {
+ id: 3,
+ title: 'Archive',
+ parent_id: '',
+ },
+];
const toolbar = [
{
name: 'Bold',
@@ -89,7 +102,7 @@ const toolbar = [
<style scoped lang="scss">
button {
- padding: 0 3px;
+ padding: 0;
margin: 0;
transform: none;
}
@@ -97,13 +110,16 @@ button {
.toolbar {
user-select: none;
display: flex;
- align-items: center;
+ align-items: stretch;
flex-wrap: wrap;
background-color: var(--bg-contrast-2);
- border-top-left-radius: 15px;
- border-top-right-radius: 15px;
- padding: 0.5rem;
+ border-radius: 8px;
+ border: 1px solid var(--border-color);
+ padding: 0.25rem;
color: var(--font-color-dark);
+ * {
+ margin-right: 5px;
+ }
}
svg,
@@ -114,8 +130,7 @@ svg,
input,
select {
display: inline-block;
- width: min-content;
- padding: 0;
- background-color: var(--bg-contrast-2);
+ padding: 0.25rem;
+ max-width: 350px;
}
</style>
diff --git a/frontend/components/ModalManager.vue b/frontend/components/ModalManager.vue
index f8e09dc7..b0b82015 100644
--- a/frontend/components/ModalManager.vue
+++ b/frontend/components/ModalManager.vue
@@ -1,8 +1,5 @@
-<!-- Modal BUS -->
-<!-- This component is used to manage modals in the application. -->
<template>
<Transition name="modal">
- <!-- Mettre le v-if directement sur le div à animer -->
<div v-if="modals.length">
<div v-for="(modal, index) in modals" :key="modal.name" class="modal-mask modal-pos" :style="{ zIndex: 120 + index }">
<div v-if="index !== modals.length - 1" class="modal-overlay"></div>
@@ -29,7 +26,7 @@ const close = (modal: Modal) => {
<style scoped lang="scss">
.modal-container {
margin: auto;
- padding: 20px;
+ padding: 15px 20px;
background-color: var(--bg-contrast);
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);
diff --git a/frontend/composables/SidebarTreeManager.ts b/frontend/composables/SidebarTreeManager.ts
index 6441f10f..fe6fcb90 100644
--- a/frontend/composables/SidebarTreeManager.ts
+++ b/frontend/composables/SidebarTreeManager.ts
@@ -1,14 +1,19 @@
import type { Document, Category } from '~/stores';
import type { DefaultItem } from '../components/Sidebar/helpers';
-export interface Item<T = Document | Category | DefaultItem> {
- id: string;
+export interface ANode {
+ id: string | number;
title: string;
parent_id: string;
+ childrens?: ANode[];
+}
+
+export interface Item<T = Document | Category | DefaultItem> extends ANode {
+ id: string;
route: string;
data: T;
- childrens?: Item<T>[];
show: Ref<boolean>;
+ childrens?: Item<T>[];
}
export class TreeStructure {
private itemMap: Map<string, Item>; // Utilisation de Map pour les recherches rapides
diff --git a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
index 79d2953c..369cfc45 100644
--- a/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
+++ b/frontend/pages/dashboard/categories/_modals/CreateCategoryModal.vue
@@ -11,11 +11,13 @@
<option :value="null">None</option>
<option v-for="pc in categoriesStore.getParents.filter(c => c.role == 1)" :key="pc.id" :value="pc.id">{{ pc.name }}</option>
</select>
- <label>Workspace <AppHint text="Only for root categories" /></label>
- <select v-model="category.workspace_id">
- <option :value="null">None</option>
- <option v-for="wp in categoriesStore.getAll.filter(a => a.role == 2)" :key="wp.id" :value="wp.id">{{ wp.name }}</option>
- </select>
+ <div v-if="role == 1">
+ <label>Workspace <AppHint text="Only for root categories" /></label>
+ <select v-model="category.workspace_id" style="width: 100%">
+ <option :value="null">None</option>
+ <option v-for="wp in categoriesStore.getAll.filter(a => a.role == 2)" :key="wp.id" :value="wp.id">{{ wp.name }}</option>
+ </select>
+ </div>
<label for="order">Order</label>
<input type="number" v-model.number="category.order" id="order" />
<AppButton type="primary">Create</AppButton>
diff --git a/frontend/pages/dashboard/categories/index.vue b/frontend/pages/dashboard/categories/index.vue
index 5c062026..92abce0e 100644
--- a/frontend/pages/dashboard/categories/index.vue
+++ b/frontend/pages/dashboard/categories/index.vue
@@ -5,7 +5,7 @@
<div style="display: flex; gap: 8px">
<AppButton type="primary" @click="createWorkspace">+ Workspace</AppButton>
<AppButton type="primary" @click="createCategory">+ Category</AppButton>
- <AppButton type="secondary" variant="outline">Importer</AppButton>
+ <AppButton type="secondary" variant="outline">Import</AppButton>
</div>
</header>
<div style="padding: 10px 0; border-top: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center">
@@ -21,12 +21,11 @@
</template>
<script setup lang="ts">
-import type { Category } from '~/stores';
import CreateCategoryModal from './_modals/CreateCategoryModal.vue';
import WorkspaceTree from './_components/WorkspaceTree.vue';
-const tree = useSidebarTree().tree;
+import type { Category } from '~/stores';
-const custom_tree = tree.value.filter(i => i.data.type === 'category' && i.data.role == 2) as Item<Category>[];
+const custom_tree = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2) as Item<Category>[];
function createWorkspace() {
useModal().modals.value?.push(new Modal(shallowRef(CreateCategoryModal), '', { role: 2 }));
diff --git a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index cf6e41ef..4662dadc 100644
--- a/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -12,33 +12,25 @@
/>
</svg>
</NuxtLink>
- <NuxtLink @click="showDeleteModal = true">
+ <NuxtLink @click="openDeleteModal">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">
<path d="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z" />
</svg>
</NuxtLink>
- <Modal :show="showDeleteModal">
- <h3>Delete document</h3>
- <p>Are you sure you want to delete this document?</p>
- <p style="opacity: 0.7">This action is irreversible</p>
- <AppButton @click="deleteDoc" style="float: right" type="danger">Confirm</AppButton>
- <AppButton @click="showDeleteModal = false" style="float: right" type="link">Cancel</AppButton>
- </Modal>
</span>
</template>
<script setup lang="ts">
+import DeleteDocumentModal from '../_modals/DeleteDocumentModal.vue';
import { useDocumentsStore } from '~/stores';
const router = useRouter();
const documentsStore = useDocumentsStore();
-const showDeleteModal = ref(false);
const props = defineProps<{ doc_id: string }>();
const print = () => window.print();
-const deleteDoc = () => {
- showDeleteModal.value = false;
- documentsStore.delete(props.doc_id).then(() => router.push('/dashboard'));
+const openDeleteModal = () => {
+ const modal = useModal().modals.value.push(new Modal(DeleteDocumentModal, 'Delete modal', {}));
};
</script>
diff --git a/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue b/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
new file mode 100644
index 00000000..bcf1f448
--- /dev/null
+++ b/frontend/pages/dashboard/docs/_modals/DeleteDocumentModal.vue
@@ -0,0 +1,41 @@
+<template>
+ <div class="modal">
+ <h3>Delete document</h3>
+ <p>Are you sure you want to delete this document?</p>
+ <p style="opacity: 0.7">This action is irreversible</p>
+ <AppButton @click="deleteDoc" style="float: right" type="danger">Confirm</AppButton>
+ <AppButton @click="close" style="float: right" type="link">Cancel</AppButton>
+ </div>
+</template>
+
+<script setup lang="ts">
+import type { Category } from '~/stores';
+
+const categoriesStore = useCategoriesStore();
+const props = defineProps<{ role: number }>();
+
+const category = ref<Category>({
+ name: '',
+ type: 'category',
+ id: '',
+ role: props.role,
+});
+
+const deleteDoc = () => {
+ // categoriesStore.post(category.value)
+};
+// Emit close event to parent component
+const emit = defineEmits(['close']);
+const close = () => {
+ emit('close');
+};
+</script>
+
+<style scoped lang="scss">
+.modal {
+ background-color: var(--bg-contrast);
+ padding: 0 1rem;
+ border-radius: 8px;
+ min-width: 700px;
+}
+</style>