π 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
New search navigation
Smaug6739b72093054ef1
diff --git a/frontend/components/sidebar/Search.vue b/frontend/components/sidebar/Search.vuenew file mode 100644index 00000000..ca361455--- /dev/null+++ b/frontend/components/sidebar/Search.vue@@ -0,0 +1,162 @@+<template>+ <div v-if="showSearchModal" class="modal-mask">+ <div class="modal-container" ref="searchContainer">+ <span class="search-input">+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"+ stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"+ class="mr-2 h-4 w-4 shrink-0 opacity-50">+ <circle cx="11" cy="11" r="8"></circle>+ <path d="m21 21-4.3-4.3"></path>+ </svg>+ <input type="text" v-model="filter" placeholder="Search document" ref="searchInput" />+ <button @click="close"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"+ fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"+ class="h-4 w-4">+ <path d="M18 6 6 18"></path>+ <path d="m6 6 12 12"></path>+ </svg>+ </button>+ </span>+ <span class="title">Documents</span>+ <NuxtLink v-if="docs.length" v-for="doc of docs" class="item" :to="`/dashboard/doc/${doc.id}`" @click="close">+ <i class="icon">+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"+ stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2 h-4 w-4">+ <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path>+ <polyline points="14 2 14 8 20 8"></polyline>+ </svg>+ </i>+ <span>{{ doc.name }}</span>+ </NuxtLink>+ <p v-else class="no-result">+ No result found.+ </p>+ </div>+ </div>+</template>++<script setup lang="ts">+import { useDocumentsStore } from '~/store';++const documents = computed(() => useDocumentsStore().getAll.filter(c => c.name.toLowerCase().includes(filter.value.toLowerCase())));+const filter = ref<string>('');+const showSearchModal = ref<boolean>(false);++// Docs = max 5 docs+const docs = computed(() => documents.value.slice(0, 5));++const close = () => {+ showSearchModal.value = false;+ filter.value = '';+};+const searchContainer = ref<HTMLElement | null>(null);+const searchInput = ref<HTMLInputElement | null>(null);++const handleTab = (event: KeyboardEvent) => {+ if (!searchContainer.value) return;+ const focusableItems = Array.from(searchContainer.value.querySelectorAll('a'));+ const currentIndex = focusableItems.findIndex(item => item === document.activeElement);+ let nextIndex;+ if (event.shiftKey) {+ nextIndex = (currentIndex - 1 + focusableItems.length) % focusableItems.length;+ } else {+ nextIndex = (currentIndex + 1) % focusableItems.length;+ }+ focusableItems[nextIndex].focus();+ event.preventDefault();+}++onMounted(() => document.addEventListener('keydown', handleSearchShortCut));+onBeforeUnmount(() => document.removeEventListener('keydown', handleSearchShortCut));+const handleSearchShortCut = (e: KeyboardEvent) => {+ if (e.ctrlKey && e.key === 'q') {+ if (!showSearchModal.value) {+ showSearchModal.value = true;+ nextTick(() => searchInput.value?.focus());+ } else close();+ }+ if (showSearchModal.value) {+ if (e.key === 'Escape') close();+ if (e.key === 'Tab') handleTab(e);+ }+};+</script>++<style lang="scss" scoped>+.modal-mask {+ position: fixed;+ z-index: 100;+ top: 0;+ left: 0;+ width: 100vw;+ height: 100vh;+ background-color: rgba(0, 0, 0, 0.5);+ display: flex;+ transition: opacity 0.3s ease;+ font-size: initial;+}++.modal-container {+ width: 600px;+ margin: auto;+ padding: 20px;+ background-color: var(--bg-color);+ border-radius: 10px;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);+ transition: all 0.3s ease;+}++.search-input {+ display: flex;+ align-items: center;++ input {+ background-color: var(--bg-color);+ border: none;+ outline: none;+ }++ svg {+ fill: var(--bg-contrast);+ }+}++.title {+ font-weight: 500;+ font-size: 0.75rem;+ color: #737373;+ padding: 10px 0;+}++.item {+ display: flex;+ justify-content: flex-start;+ align-items: center;+ margin: 2.5px 0;+ padding: 10px 0;+ border-radius: 5px;+ color: var(--font-color);+ cursor: pointer;++ &:hover,+ &.router-link-active {+ background: var(--bg-contrast-2);+ }++ .icon {+ display: flex;+ align-items: center;++ &:deep(svg) {+ width: 35px;+ margin-right: 5px;+ }+ }+}++.no-result {+ text-align: center;+ font-weight: 500;+ font-size: 0.85rem;+}+</style>diff --git a/frontend/components/sidebar/Sidebar.vue b/frontend/components/sidebar/Sidebar.vueindex 715647ce..465763dc 100644--- a/frontend/components/sidebar/Sidebar.vue+++ b/frontend/components/sidebar/Sidebar.vue@@ -2,10 +2,14 @@<Resizable><div class="sidebar-content"><section class="header">- <span class="name"><IconApp /><NuxtLink style="font-size: 19px;font-weight: 600;" to="/">Alexandrie</NuxtLink></span>+ <span class="name">+ <IconApp />+ <NuxtLink style="font-size: 19px;font-weight: 600;" to="/">Alexandrie</NuxtLink>+ </span><IconClose class="btn" /></section><input type="text" placeholder="Search" class="search" v-model="filter" />+ <Search /><CollapseItem v-for="(item, index) in items " :key="index" :item="item" :root="true" /></div></Resizable>@@ -16,16 +20,22 @@ import CollapseItem from './CollapseItem.vue';import Resizable from './Resizable.vue';import IconClose from './IconClose.vue';import IconApp from './IconApp.vue';+import Search from './Search.vue';import { useCategoriesStore, useDocumentsStore, type Category } from '~/store';import { ItemsManager, type Item } from './tree_builder';import { navigationItems } from "./helpers";+const { isOpened, hasSidebar } = useSidebar();const categoriesStore = useCategoriesStore();const documentsStore = useDocumentsStore();const filter = ref<string>('');+const showSearchModal = ref<boolean>(false);const isMobile = () => import.meta.client ? window.innerWidth <= 768 : false;+const handleSearchShortCut = (e: KeyboardEvent) => {+ if (e.ctrlKey && e.key === 'q') showSearchModal.value = !showSearchModal.value;+};const items = computed((): Item[] => {const navigation: Item[] = navigationItems.map((item) => ({ id: item.id, parent_id: '', title: item.title, route: item.route, icon: item.icon, type: 'navigation', data: item }))@@ -57,11 +67,14 @@ const handleClickOutside = (e: MouseEvent) => {onMounted(() => {hasSidebar.value = true;if (isMobile()) return window.addEventListener('click', handleClickOutside);+ // ELSE: DesktopisOpened.value = true;+ document.addEventListener('keypress', handleSearchShortCut)});onBeforeUnmount(() => {hasSidebar.value = false;window.removeEventListener('click', handleClickOutside);+ document.removeEventListener('keypress', handleSearchShortCut)});// Watch isOpened@@ -72,6 +85,7 @@ if (isMobile()) {});}+</script><style scoped lang="scss">@@ -92,11 +106,11 @@ if (isMobile()) {}.name {- display: flex;- align-items: center;+ display: flex;+ align-items: center;font-size: 1rem;font-weight: 400;- font-family: Inter;+ font-family: Inter;}}diff --git a/frontend/styles/theme.scss b/frontend/styles/theme.scssindex a138e742..026ebe21 100644--- a/frontend/styles/theme.scss+++ b/frontend/styles/theme.scss@@ -33,8 +33,7 @@ button {width: fit-content;&:hover {- transform: translateY(-2px);- background-color: var(--primary-color-light);+ transform: scale(1.1);}&:disabled {