π 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 advanced search
Smaug67392a4d2f4236c5
diff --git a/frontend/app/components/AppSelect.vue b/frontend/app/components/AppSelect.vueindex 2d6997fb..c4320705 100644--- a/frontend/app/components/AppSelect.vue+++ b/frontend/app/components/AppSelect.vue@@ -1,10 +1,13 @@<template><div class="app-select" :style="{ width: size || '100%' }">- <div v-if="!open">- <button @click.stop="toggleDropdown">{{ selected?.label || placeholder }}</button>+ <div v-if="!open" style="display: flex; justify-content: space-between; align-items: center; padding: 1px">+ <button @click.stop="toggleDropdown">{{ selected?.label || placeholder }}</button+ ><svg :class="{ rotated: !open }" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">+ <path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" />+ </svg></div><div v-else>- <input ref="searchInput" v-model="search" type="text" placeholder="Search..." class="search-input" @keydown="handleKeyDown" >+ <input ref="searchInput" v-model="search" type="text" placeholder="Search..." class="search-input" @keydown="handleKeyDown" /><div class="dropdown"><ul><AppSelectNode v-for="item in filteredItems" :key="item.id" :node="item" :level="0" :disabled="disabled" @select="handleSelect" />@@ -78,8 +81,8 @@ function handleClickOutside(_: MouseEvent) {open.value = false;}-onMounted(() => document.addEventListener('click', handleClickOutside));-onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside));+onMounted(() => window.addEventListener('click', handleClickOutside));+onBeforeUnmount(() => window.removeEventListener('click', handleClickOutside));</script><style scoped lang="scss">@@ -87,9 +90,15 @@ onBeforeUnmount(() => document.removeEventListener('click', handleClickOutside))position: relative;width: 200px;border: 1px solid var(--border-color);- border-radius: 10px;+ margin: 0;+ background: var(--bg-color);+ border: 1px solid var(--border-color);+ color: var(--font-color);+ border-radius: 6px;+ font-size: 1rem;+ font-family: Inter;&:focus {- outline: 2px solid var(--border-color);+ outline: 1px solid var(--primary);}}@@ -98,19 +107,14 @@ button,width: 100%;padding: 8px 10px;text-align: left;- font-size: 16px;+ font-size: 1rem;cursor: pointer;+ border-radius: 6px;}.search-input {cursor: text;border: none;- padding: 6px 10px;-}--.app-select:has(.dropdown) button,-.app-select:has(.dropdown) .search-input {- outline: 2px solid var(--border-color);}.dropdown {diff --git a/frontend/app/components/AppSelectNode.vue b/frontend/app/components/AppSelectNode.vueindex 6aabb5b9..697e2892 100644--- a/frontend/app/components/AppSelectNode.vue+++ b/frontend/app/components/AppSelectNode.vue@@ -1,6 +1,6 @@<template><li>- <div class="tree-node" :style="{ marginLeft: `${level * 20}px`, fontWeight: node.childrens?.length ? 600 : 500 }" :disabled="disabled && disabled(node)" @click.stop="select">+ <div class="tree-node" :style="{ marginLeft: `${level * 20}px`, fontWeight: node.childrens?.length ? 500 : 400 }" :disabled="disabled && disabled(node)" @click.stop="select">{{ node.label }}</div><ul v-if="node.childrens?.length">@@ -32,7 +32,7 @@ function select() {text-align: left;cursor: pointer;font-size: 14px;- margin: 0 auto;+ margin: 2px auto;}.tree-node:hover {background-color: var(--selection-color);diff --git a/frontend/app/components/GlobalSearch/AdvancedSearchTab.vue b/frontend/app/components/GlobalSearch/AdvancedSearchTab.vueindex f97fd93c..ec3d97d2 100644--- a/frontend/app/components/GlobalSearch/AdvancedSearchTab.vue+++ b/frontend/app/components/GlobalSearch/AdvancedSearchTab.vue@@ -3,103 +3,100 @@<div class="search-filters"><div class="filters-header"><h3 class="filters-title">Advanced Filters</h3>- <button @click="toggleFilters" class="toggle-filters-btn" :class="{ collapsed: !showFilters }">+ <button class="toggle-filters-btn" :class="{ collapsed: !showFilters }" @click="toggleFilters"><Icon :name="showFilters ? 'collapse' : 'expand'" /></button></div>-+<div v-show="showFilters" class="filters-content"><div class="filter-group"><label class="filter-label">Date Range</label>- <div class="date-filters">- <div class="date-input">- <label>From</label>- <input v-model="dateFrom" type="date" class="date-picker" />- </div>- <div class="date-input">- <label>To</label>- <input v-model="dateTo" type="date" class="date-picker" />+ <div class="date-filters">+ <div class="date-input">+ <label>From</label>+ <input v-model="dateFrom" type="date" class="date-picker" />+ </div>+ <div class="date-input">+ <label>To</label>+ <input v-model="dateTo" type="date" class="date-picker" />+ </div></div></div>- </div>- <div class="filter-group">- <label class="filter-label">Date Type</label>- <div class="radio-group">- <label class="radio-option">- <input v-model="dateType" type="radio" value="created" />- <span>Created</span>- </label>- <label class="radio-option">- <input v-model="dateType" type="radio" value="modified" />- <span>Modified</span>- </label>+ <div class="filter-group">+ <label class="filter-label">Date Type</label>+ <div class="radio-group">+ <label class="radio-option">+ <input v-model="dateType" type="radio" value="created" />+ <span>Created</span>+ </label>+ <label class="radio-option">+ <input v-model="dateType" type="radio" value="modified" />+ <span>Modified</span>+ </label>+ </div></div>- </div>- <div class="filter-group">- <label class="filter-label">Tags</label>- <div class="tags-filter">- <div class="tags-input-wrapper">- <div class="tags-input">- <input- v-model="tagInput"- type="text"- placeholder="Add tag filter..."- class="tag-input"- @keydown.enter="handleEnter"- @keydown.arrow-up="handleArrowUp"- @keydown.arrow-down="handleArrowDown"- @keydown.escape="hideSuggestions"- @input="handleTagInput"- @focus="showSuggestions = true"- @blur="hideSuggestions"- />- <button @click="addTag" class="add-tag-btn">- <Icon name="plus" />- </button>+ <div class="filter-group">+ <label class="filter-label">Tags</label>+ <div class="tags-filter">+ <div class="tags-input-wrapper">+ <div class="tags-input">+ <input+ v-model="tagInput"+ type="text"+ placeholder="Add tag filter..."+ class="tag-input"+ @keydown.enter="handleEnter"+ @keydown.arrow-up="handleArrowUp"+ @keydown.arrow-down="handleArrowDown"+ @keydown.escape="hideSuggestions"+ @input="handleTagInput"+ @focus="showSuggestions = true"+ @blur="hideSuggestions"+ />+ <button class="add-tag-btn" @click="addTag">+ <Icon name="plus" fill="#fff" />+ </button>+ </div>++ <div v-if="showSuggestions && filteredTagSuggestions.length > 0" class="tag-suggestions">+ <div v-for="(tag, index) in filteredTagSuggestions" :key="tag" class="tag-suggestion" :class="{ selected: selectedSuggestionIndex === index }" @mousedown="selectTag(tag)" @mouseenter="selectedSuggestionIndex = index">+ {{ tag }}+ </div>+ </div></div>-- <div v-if="showSuggestions && filteredTagSuggestions.length > 0" class="tag-suggestions">- <div- v-for="(tag, index) in filteredTagSuggestions"- :key="tag"- class="tag-suggestion"- :class="{ selected: selectedSuggestionIndex === index }"- @mousedown="selectTag(tag)"- @mouseenter="selectedSuggestionIndex = index"- >+ <div class="selected-tags">+ <span v-for="tag in selectedTags" :key="tag" class="tag-chip">{{ tag }}- </div>+ <button class="remove-tag" @click="removeTag(tag)">+ <Icon name="close" />+ </button>+ </span></div></div>- <div class="selected-tags">- <span v-for="tag in selectedTags" :key="tag" class="tag-chip">- {{ tag }}- <button @click="removeTag(tag)" class="remove-tag">- <Icon name="close" />- </button>- </span>- </div></div>- </div>- <div class="filter-group">- <label class="filter-label">Category</label>- <select v-model="selectedCategory" class="category-select">- <option value="">All Categories</option>- <option v-for="category in categories" :key="category.id" :value="category.id">- {{ category.name }}- </option>- </select>- </div>+ <div class="filter-group">+ <label class="filter-label">Category</label>+ <select v-model="selectedCategory" class="category-select">+ <option value="">All Categories</option>+ <option v-for="category in categories" :key="category.id" :value="category.id">+ {{ category.name }}+ </option>+ </select>++ <br />+ <br />+ <AppSelect v-model="selectedCategory" :items="categoriesTree" placeholder="Select a category" />+ </div>- <div class="filter-actions">- <button @click="clearFilters" class="clear-filters-btn">Clear Filters</button>- <button @click="applyFilters" class="apply-filters-btn">Apply Filters</button>- </div>+ <div class="filter-actions">+ <button class="clear-filters-btn" @click="clearFilters">Clear Filters</button>+ <button class="apply-filters-btn">Apply Filters</button></div></div>+ </div><div class="search-results"><div v-if="filteredDocuments.length === 0" class="no-results">@@ -151,6 +148,7 @@ const selectedSuggestionIndex = ref(0);const categoryStore = useCategoriesStore();const categories = computed(() => categoryStore.getAll);+const categoriesTree = new TreeStructure(useSidebarTree().categories.value).generateTree().filter(i => i.data.type === 'category' && i.data.role == 2);const allTags = computed(() => {const tags = new Set<string>();@@ -165,12 +163,7 @@ const allTags = computed(() => {const filteredTagSuggestions = computed(() => {if (!tagInput.value) return [];const input = tagInput.value.toLowerCase();- return allTags.value- .filter(tag =>- tag.toLowerCase().includes(input) &&- !selectedTags.value.includes(tag)- )- .slice(0, 5);+ return allTags.value.filter(tag => tag.toLowerCase().includes(input) && !selectedTags.value.includes(tag)).slice(0, 5);});const filteredDocuments = computed(() => {@@ -220,7 +213,8 @@ function addTag() {}}-function selectTag(tag: string) {+function selectTag(tag?: string) {+ if (!tag) return;selectedTags.value.push(tag);tagInput.value = '';showSuggestions.value = false;@@ -249,18 +243,14 @@ function handleEnter(event: KeyboardEvent) {function handleArrowUp(event: KeyboardEvent) {event.preventDefault();if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {- selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0- ? selectedSuggestionIndex.value - 1- : filteredTagSuggestions.value.length - 1;+ selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0 ? selectedSuggestionIndex.value - 1 : filteredTagSuggestions.value.length - 1;}}function handleArrowDown(event: KeyboardEvent) {event.preventDefault();if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {- selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredTagSuggestions.value.length - 1- ? selectedSuggestionIndex.value + 1- : 0;+ selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredTagSuggestions.value.length - 1 ? selectedSuggestionIndex.value + 1 : 0;}}@@ -279,10 +269,6 @@ function clearFilters() {selectedCategory.value = '';}-function applyFilters() {- // Filters are applied automatically via computed-}-function selectDocument(doc: Document) {emit('selectDocument', doc);}@@ -306,7 +292,10 @@ function formatDate(timestamp: string) {function parseTags(tags: string): string[] {if (typeof tags === 'string') {- return tags.split(',').map(tag => tag.trim()).filter(Boolean);+ return tags+ .split(',')+ .map(tag => tag.trim())+ .filter(Boolean);}return [];}@@ -431,7 +420,7 @@ function parseTags(tags: string): string[] {font-size: 14px;color: var(--text-color);- input[type="radio"] {+ input[type='radio'] {accent-color: var(--primary);}}diff --git a/frontend/app/components/GlobalSearch/QuickSearchTab.vue b/frontend/app/components/GlobalSearch/QuickSearchTab.vueindex 5ad91c3d..ecc8aeb5 100644--- a/frontend/app/components/GlobalSearch/QuickSearchTab.vue+++ b/frontend/app/components/GlobalSearch/QuickSearchTab.vue@@ -26,17 +26,15 @@<script setup lang="ts">import { quickActions, availablePages, type SearchResult, type BaseCommand } from '@/helpers/navigation';import Icon from '~/components/Icon.vue';+import type { Document } from '~/stores';const props = defineProps<{searchQuery: string;selectedIndex: number;- documents: any[];+ documents: Document[];}>();-const emit = defineEmits<{- selectItem: [];- updateSelectedIndex: [index: number];-}>();+defineEmits<{ selectItem: []; updateSelectedIndex: [index: number] }>();function tokenize(text: string) {return text.trim().toLowerCase().split(/\s+/).filter(Boolean);diff --git a/frontend/app/components/GlobalSearch/TabNavigation.vue b/frontend/app/components/GlobalSearch/TabNavigation.vueindex b74bde4f..b689d18b 100644--- a/frontend/app/components/GlobalSearch/TabNavigation.vue+++ b/frontend/app/components/GlobalSearch/TabNavigation.vue@@ -1,12 +1,6 @@<template><div class="tab-navigation">- <button- v-for="tab in tabs"- :key="tab.id"- class="tab-button"- :class="{ active: activeTab === tab.id }"- @click="$emit('changeTab', tab.id)"- >+ <button v-for="tab in tabs" :key="tab.id" class="tab-button" :class="{ active: activeTab === tab.id }" @click="$emit('changeTab', tab.id)"><Icon :name="tab.icon" class="tab-icon" /><span class="tab-label">{{ tab.label }}</span></button>@@ -22,11 +16,11 @@ interface Tab {icon: string;}-const props = defineProps<{+defineProps<{activeTab: string;}>();-const emit = defineEmits<{+defineEmits<{changeTab: [tabId: string];}>();@@ -54,6 +48,7 @@ const tabs: Tab[] = [.tab-button {display: flex;align-items: center;+ justify-content: center;gap: 8px;padding: 16px 20px;background: transparent;@@ -64,7 +59,8 @@ const tabs: Tab[] = [font-weight: 500;transition: all 0.2s ease;border-bottom: 2px solid transparent;-+ flex: 1;+ border-radius: 0;&:hover {color: var(--text-color);background: var(--bg-color-secondary);diff --git a/frontend/app/components/GlobalSearch/index.ts b/frontend/app/components/GlobalSearch/index.tsdeleted file mode 100644index e4011ff8..00000000--- a/frontend/app/components/GlobalSearch/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export { default as TabNavigation } from './TabNavigation.vue';-export { default as QuickSearchTab } from './QuickSearchTab.vue';-export { default as AdvancedSearchTab } from './AdvancedSearchTab.vue';diff --git a/frontend/app/components/GlobalSearch.vue b/frontend/app/components/GlobalSearch/index.vuesimilarity index 78%rename from frontend/app/components/GlobalSearch.vuerename to frontend/app/components/GlobalSearch/index.vueindex 6949396c..59804db5 100644--- a/frontend/app/components/GlobalSearch.vue+++ b/frontend/app/components/GlobalSearch/index.vue@@ -1,7 +1,7 @@<template><Teleport to="body">- <div v-if="isOpen" class="global-search-overlay" @click="closeSearch">- <div class="global-search-modal" @click.stop>+ <div v-if="isOpen" class="command-center-overlay" @click="closeSearch">+ <div class="command-center-modal"><!-- Header --><div class="search-header"><div class="search-input-wrapper">@@ -18,31 +18,14 @@<!-- Tab Content --><div class="tab-content">- <QuickSearchTab- v-if="activeTab === 'quick'"- :search-query="searchQuery"- :selected-index="selectedIndex"- :documents="documentsStore.getAll"- @select-item="closeSearch"- @update-selected-index="updateSelectedIndex"- ref="quickSearchTab"- />-- <AdvancedSearchTab- v-else-if="activeTab === 'advanced'"- :documents="documentsStore.getAll"- @select-document="handleDocumentSelect"- />+ <QuickSearchTab v-if="activeTab === 'quick'" ref="quickSearchTab" :search-query="searchQuery" :selected-index="selectedIndex" :documents="documentsStore.getAll" @select-item="closeSearch" @update-selected-index="updateSelectedIndex" />++ <AdvancedSearchTab v-else-if="activeTab === 'advanced'" :documents="documentsStore.getAll" @select-document="handleDocumentSelect" /></div><!-- Footer --><div class="search-footer">- <div class="shortcuts">- <kbd>ββ</kbd> Navigate- <kbd>Enter</kbd> Select- <kbd>Tab</kbd> Switch tabs- <kbd>Escape</kbd> Close- </div>+ <div class="shortcuts"><kbd>ββ</kbd> or <kbd>Tab</kbd>Navigate <kbd>Enter</kbd> Select <kbd>β</kbd> Switch tabs <kbd>Escape</kbd> Close</div></div></div></div>@@ -51,10 +34,11 @@<script setup lang="ts">import CreateCategoryModal from '~/pages/dashboard/categories/_modals/CreateCategoryModal.vue';-import TabNavigation from './GlobalSearch/TabNavigation.vue';-import QuickSearchTab from './GlobalSearch/QuickSearchTab.vue';-import AdvancedSearchTab from './GlobalSearch/AdvancedSearchTab.vue';+import TabNavigation from './TabNavigation.vue';+import QuickSearchTab from './QuickSearchTab.vue';+import AdvancedSearchTab from './AdvancedSearchTab.vue';import { useModal, Modal } from '~/composables/ModalBus';+import type { Document } from '~/stores';const router = useRouter();const isOpen = ref(false);@@ -79,7 +63,7 @@ onMounted(() => {useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));} else if (e.key === 'Escape' && isOpen.value) {closeSearch();- } else if (e.key === 'Tab' && isOpen.value) {+ } else if ((e.key === 'ArrowRight' || e.key === 'ArrowLeft') && isOpen.value) {e.preventDefault();changeTab(activeTab.value === 'quick' ? 'advanced' : 'quick');}@@ -100,16 +84,15 @@ onMounted(() => {};document.addEventListener('keydown', handleGlobalKeydown);- document.addEventListener('wheel', handleWheel, { passive: false });document.addEventListener('touchmove', handleTouchMove, { passive: false });const openListener = () => openSearch();- window.addEventListener('global-search-open', openListener as EventListener);+ window.addEventListener('command-center-open', openListener as EventListener);onUnmounted(() => {document.removeEventListener('keydown', handleGlobalKeydown);document.removeEventListener('wheel', handleWheel);document.removeEventListener('touchmove', handleTouchMove);- window.removeEventListener('global-search-open', openListener as EventListener);+ window.removeEventListener('command-center-open', openListener as EventListener);});});@@ -119,11 +102,11 @@ function openSearch() {selectedIndex.value = 0;searchQuery.value = '';activeTab.value = 'quick';- document.body.style.overflow = 'hidden';nextTick(() => searchInput.value?.focus());}-function closeSearch() {+function closeSearch(e?: MouseEvent) {+ if (e && e.target && (e.target as Element).closest('.command-center-modal')) return;isOpen.value = false;searchQuery.value = '';selectedIndex.value = 0;@@ -142,7 +125,7 @@ function updateSelectedIndex(index: number) {selectedIndex.value = index;}-function handleDocumentSelect(document: any) {+function handleDocumentSelect(document: Document) {navigateTo(`/dashboard/docs/${document.id}`);closeSearch();}@@ -152,7 +135,7 @@ function handleSearchKeydown(e: KeyboardEvent) {return;}- if (e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey && selectedIndex.value < (quickSearchTab.value?.flattenedItems?.length || 0) - 1)) {+ if ((e.key === 'ArrowDown' || (e.key === 'Tab' && !e.shiftKey)) && selectedIndex.value < (quickSearchTab.value?.flattenedItems?.length || 0) - 1) {e.preventDefault();const maxIndex = (quickSearchTab.value?.flattenedItems?.length || 0) - 1;selectedIndex.value = (selectedIndex.value + 1) % Math.max(maxIndex + 1, 1);@@ -178,7 +161,7 @@ watch(searchQuery, () => {</script><style scoped lang="scss">-.global-search-overlay {+.command-center-overlay {position: fixed;top: 0;left: 0;@@ -191,10 +174,9 @@ watch(searchQuery, () => {align-items: flex-start;justify-content: center;padding-top: 10vh;- overflow: hidden;}-.global-search-modal {+.command-center-modal {background: var(--bg-color);border: 1px solid var(--border-color);border-radius: 16px;@@ -204,10 +186,9 @@ watch(searchQuery, () => {max-height: 80vh;display: flex;flex-direction: column;- overflow: hidden;+ overflow: auto;animation: slideIn 0.2s ease-out;position: relative;- overscroll-behavior: contain;}.search-header {@@ -265,7 +246,7 @@ watch(searchQuery, () => {.tab-content {flex: 1;- overflow: hidden;+ overflow: auto;min-height: 0;position: relative;}@@ -279,8 +260,9 @@ watch(searchQuery, () => {.shortcuts {display: flex;- gap: 16px;- font-size: 12px;+ gap: 10px;+ font-size: 13px;+ font-weight: 500;color: var(--text-muted);kbd {@@ -304,7 +286,7 @@ watch(searchQuery, () => {}@media (max-width: 768px) {- .global-search-modal {+ .command-center-modal {width: 95%;margin: 20px;max-height: 80vh;diff --git a/frontend/app/components/Navbar.vue b/frontend/app/components/Navbar.vueindex 04ee44ce..0d23992b 100644--- a/frontend/app/components/Navbar.vue+++ b/frontend/app/components/Navbar.vue@@ -23,7 +23,7 @@<script lang="ts" setup>const { toggleSidebar, isOpened } = useSidebar();-const openGlobalSearch = () => window.dispatchEvent(new CustomEvent('global-search-open'));+const openGlobalSearch = () => window.dispatchEvent(new CustomEvent('command-center-open'));</script><style lang="scss" scoped>header {diff --git a/frontend/app/pages/dashboard/home.vue b/frontend/app/pages/dashboard/home.vueindex 9ab929b8..8ef86cf5 100644--- a/frontend/app/pages/dashboard/home.vue+++ b/frontend/app/pages/dashboard/home.vue@@ -3,7 +3,7 @@<h1>Alexandrie dashboard</h1><img style="max-width: 300px; max-height: 300px" :src="`/empty-${colorMode.value}.png`" /> <br />- <div class="global-search-hint">+ <div class="command-center-hint"><Icon name="search" class="hint-icon" /><span>Press <kbd>Ctrl+K</kbd> for quick global search</span></div>@@ -80,7 +80,7 @@ h1 {margin-bottom: 20px;}-.global-search-hint {+.command-center-hint {display: flex;align-items: center;justify-content: center;diff --git a/frontend/app/styles/theme.scss b/frontend/app/styles/theme.scssindex 14b540c6..4d1da0af 100644--- a/frontend/app/styles/theme.scss+++ b/frontend/app/styles/theme.scss@@ -116,7 +116,7 @@ textarea {}&:focus {- outline: 2px solid var(--border-color);+ outline: 1px solid var(--primary);}}