π 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: Adds the ability to create a child document from the context menu (#404)
Danil28d9b84c3ba3
diff --git a/frontend/app/components/Node/Action/ContextMenu.vue b/frontend/app/components/Node/Action/ContextMenu.vueindex b3315d54..ea4a9f7d 100644--- a/frontend/app/components/Node/Action/ContextMenu.vue+++ b/frontend/app/components/Node/Action/ContextMenu.vue@@ -11,6 +11,7 @@<div class="menu-group"><button class="menu-item" @click="action('open')"><Icon name="file_open" />{{ t('common.actions.open') }}<kbd>Enter</kbd></button><button class="menu-item" @click="action('edit')"><Icon name="edit_page" />{{ t('common.actions.edit') }}<kbd>E</kbd></button>+ <button class="menu-item" @click="action('new')"><Icon name="add_file" />{{ t('common.actions.new') }}</button></div><div class="menu-group">@@ -65,6 +66,9 @@ async function action(name: string) {case 'edit':router.push(`/dashboard/docs/edit/${props.node.id}`);break;+ case 'new':+ router.push(`/dashboard/docs/new?parent_id=${props.node.id}`);+ break;case 'duplicate':nodeStore.duplicate(props.node);break;diff --git a/frontend/app/components/Sidebar/SidebarItem.vue b/frontend/app/components/Sidebar/SidebarItem.vueindex c6769907..05557869 100644--- a/frontend/app/components/Sidebar/SidebarItem.vue+++ b/frontend/app/components/Sidebar/SidebarItem.vue@@ -20,7 +20,7 @@<NuxtLink v-if="item.data.role === 2 && nodesStore.hasPermissions(item.data as Node, 2)" :to="`/dashboard/categories/${item.id}/edit`" class="nav close"><Icon name="settings" /></NuxtLink>- <NuxtLink v-if="item.data.role === 2" :to="`/dashboard/docs/new?cat=${item.id}`" :prefetch="false" class="nav close">+ <NuxtLink v-if="item.data.role === 2" :to="`/dashboard/docs/new?parent_id=${item.id}`" :prefetch="false" class="nav close"><Icon name="plus" /></NuxtLink><Icon v-if="item.data.order === -1" name="pin" fill="var(--text-secondary)" />diff --git a/frontend/app/pages/dashboard/docs/new.vue b/frontend/app/pages/dashboard/docs/new.vueindex 45c7cf3b..a25e1018 100644--- a/frontend/app/pages/dashboard/docs/new.vue+++ b/frontend/app/pages/dashboard/docs/new.vue@@ -4,18 +4,24 @@<script lang="ts" setup>import type { Node } from '~/stores';+interface NewDocumentQuery {+ parent_id?: string+}+definePageMeta({ breadcrumb: {i18n: 'common.actions.new'} });const store = useNodesStore();+const notifications = useNotifications();+const route = useRoute();+const sidebar = useSidebar();-const defaultParent = (useRoute().query.cat as string | undefined) || useSidebar().workspaceId.value || undefined;--const document = ref<Partial<Node>>({+const routeQuery = computed<NewDocumentQuery>(() => route.query);+const defaultParent = computed(() => routeQuery.value.parent_id || sidebar.workspaceId.value || undefined);+const document = computed<Partial<Node>>(() => ({accessibility: 1,- parent_id: ['root', 'shared'].includes(defaultParent || '') ? undefined : defaultParent,+ parent_id: ['root', 'shared'].includes(defaultParent.value || '') ? undefined : defaultParent.value,role: 3,-});-const notifications = useNotifications();+}));function save(doc: Node) {store