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.

Remove uesless transition

Smaug6739699729b0f82c
diff --git a/frontend/app/components/GlobalSearch.vue b/frontend/app/components/GlobalSearch.vue
index 5f621e4f..54c6b42e 100644
--- a/frontend/app/components/GlobalSearch.vue
+++ b/frontend/app/components/GlobalSearch.vue
@@ -1,198 +1,173 @@
<template>
<Teleport to="body">
- <Transition name="search-modal">
- <div v-if="isOpen" class="global-search-overlay" @click="closeSearch">
- <div class="global-search-modal" @click.stop>
- <div class="search-header">
- <div class="search-input-wrapper">
- <Icon name="search" class="search-icon" />
- <input
- ref="searchInput"
- v-model="searchQuery"
- type="text"
- placeholder="Search for a page or action..."
- class="search-input"
- @keydown="handleKeydown"
- @input="filterResults"
- />
- </div>
- <button class="close-btn" @click="closeSearch">
- <Icon name="close" />
- </button>
+ <div v-if="isOpen" class="global-search-overlay" @click="closeSearch">
+ <div class="global-search-modal" @click.stop>
+ <div class="search-header">
+ <div class="search-input-wrapper">
+ <Icon name="search" class="search-icon" />
+ <input ref="searchInput" v-model="searchQuery" type="text" placeholder="Search for a page or action..." class="search-input" @keydown="handleKeydown" @input="filterResults" />
</div>
-
- <div class="search-results">
- <div v-if="searchQuery && combinedNavItems.length === 0 && filteredDocuments.length === 0" class="no-results">
- <Icon name="search" class="no-results-icon" />
- <p>No results found for "{{ searchQuery }}"</p>
- </div>
-
- <div class="search-results-list">
- <template v-if="combinedNavItems.length || filteredDocuments.length">
- <div class="section" v-if="combinedNavItems.length">
- <div class="section-title">Pages & actions</div>
- <div
- v-for="(nav, nIdx) in combinedNavItems"
- :key="nav.id"
- class="search-result-item"
- :class="{ 'selected': selectedIndex === nIdx }"
- @click="nav.onClick()"
- @mouseenter="selectedIndex = nIdx"
- >
- <Icon :name="nav.icon" class="result-icon" />
- <div class="result-content">
- <span class="result-title">{{ nav.title }}</span>
- <span class="result-description">{{ nav.description }}</span>
- </div>
- <kbd v-if="nav.shortcut" class="shortcut">{{ nav.shortcut }}</kbd>
- <Icon v-else name="new_tab" class="navigate-icon" />
+ <button class="close-btn" @click="closeSearch">
+ <Icon name="close" />
+ </button>
+ </div>
+
+ <div class="search-results">
+ <div v-if="searchQuery && combinedNavItems.length === 0 && filteredDocuments.length === 0" class="no-results">
+ <Icon name="search" class="no-results-icon" />
+ <p>No results found for "{{ searchQuery }}"</p>
+ </div>
+
+ <div class="search-results-list">
+ <template v-if="combinedNavItems.length || filteredDocuments.length">
+ <div class="section" v-if="combinedNavItems.length">
+ <div class="section-title">Pages & actions</div>
+ <div v-for="(nav, nIdx) in combinedNavItems" :key="nav.id" class="search-result-item" :class="{ selected: selectedIndex === nIdx }" @click="nav.onClick()" @mouseenter="selectedIndex = nIdx">
+ <Icon :name="nav.icon" class="result-icon" />
+ <div class="result-content">
+ <span class="result-title">{{ nav.title }}</span>
+ <span class="result-description">{{ nav.description }}</span>
</div>
+ <kbd v-if="nav.shortcut" class="shortcut">{{ nav.shortcut }}</kbd>
+ <Icon v-else name="new_tab" class="navigate-icon" />
</div>
-
- <div class="section" v-if="filteredDocuments.length">
- <div class="section-title">Documents</div>
- <div
- v-for="(doc, dIdx) in filteredDocuments"
- :key="`doc-${doc.id}`"
- class="search-result-item"
- :class="{ 'selected': selectedIndex === combinedNavItems.length + dIdx }"
- @click="navigateTo(doc)"
- @mouseenter="selectedIndex = combinedNavItems.length + dIdx"
- >
- <Icon :name="doc.icon" class="result-icon" />
- <div class="result-content">
- <span class="result-title">{{ doc.title }}</span>
- <span class="result-description">{{ doc.description }}</span>
- </div>
- <Icon name="new_tab" class="navigate-icon" />
+ </div>
+
+ <div class="section" v-if="filteredDocuments.length">
+ <div class="section-title">Documents</div>
+ <div
+ v-for="(doc, dIdx) in filteredDocuments"
+ :key="`doc-${doc.id}`"
+ class="search-result-item"
+ :class="{ selected: selectedIndex === combinedNavItems.length + dIdx }"
+ @click="navigateTo(doc)"
+ @mouseenter="selectedIndex = combinedNavItems.length + dIdx"
+ >
+ <Icon :name="doc.icon" class="result-icon" />
+ <div class="result-content">
+ <span class="result-title">{{ doc.title }}</span>
+ <span class="result-description">{{ doc.description }}</span>
</div>
+ <Icon name="new_tab" class="navigate-icon" />
</div>
- </template>
- </div>
+ </div>
+ </template>
</div>
-
- <div class="search-footer">
- <div class="shortcuts">
- <kbd>↑↓</kbd> Navigate
- <kbd>Enter</kbd> Select
- <kbd>Escape</kbd> Close
- </div>
- </div>
+ </div>
+
+ <div class="search-footer">
+ <div class="shortcuts"><kbd>↑↓</kbd> Navigate <kbd>Enter</kbd> Select <kbd>Escape</kbd> Close</div>
</div>
</div>
- </Transition>
+ </div>
</Teleport>
</template>
<script setup lang="ts">
-import { Icon } from '#components'
-import CreateCategoryModal from '@/pages/dashboard/categories/_modals/CreateCategoryModal.vue'
+import { Icon } from '#components';
+import CreateCategoryModal from '@/pages/dashboard/categories/_modals/CreateCategoryModal.vue';
interface SearchResult {
- id: string
- title: string
- description: string
- icon: string
- path: string
- category: string
+ id: string;
+ title: string;
+ description: string;
+ icon: string;
+ path: string;
+ category: string;
}
interface QuickAction {
- id: string
- title: string
- description: string
- icon: string
- shortcut: string
- action: () => void
-}
-
-const router = useRouter()
-const isOpen = ref(false)
-const searchQuery = ref('')
-const selectedIndex = ref(0)
-const searchInput = ref<HTMLInputElement>()
-
- const availablePages: SearchResult[] = [
- {
- id: 'home',
- title: 'Home',
- description: 'Main dashboard',
- icon: 'dashboard',
- path: '/dashboard',
- category: 'Navigation'
- },
- {
- id: 'docs',
- title: 'Documents',
- description: 'Manage your documents',
- icon: 'file',
- path: '/dashboard/docs',
- category: 'Management'
- },
- {
- id: 'categories',
- title: 'Categories',
- description: 'Organize your categories',
- icon: 'categories',
- path: '/dashboard/categories',
- category: 'Management'
- },
- {
- id: 'cdn',
- title: 'CDN',
- description: 'Manage your resources',
- icon: 'cdn',
- path: '/dashboard/cdn',
- category: 'Management'
- },
- {
- id: 'import',
- title: 'Import',
- description: 'Import documents',
- icon: 'import',
- path: '/dashboard/import',
- category: 'Actions'
- },
- {
- id: 'settings',
- title: 'Settings',
- description: 'Configure the application',
- icon: 'settings',
- path: '/dashboard/settings',
- category: 'Configuration'
- }
- ]
-
-const filteredResults = ref<SearchResult[]>([])
+ id: string;
+ title: string;
+ description: string;
+ icon: string;
+ shortcut: string;
+ action: () => void;
+}
+
+const router = useRouter();
+const isOpen = ref(false);
+const searchQuery = ref('');
+const selectedIndex = ref(0);
+const searchInput = ref<HTMLInputElement>();
+
+const availablePages: SearchResult[] = [
+ {
+ id: 'home',
+ title: 'Home',
+ description: 'Main dashboard',
+ icon: 'dashboard',
+ path: '/dashboard',
+ category: 'Navigation',
+ },
+ {
+ id: 'docs',
+ title: 'Documents',
+ description: 'Manage your documents',
+ icon: 'file',
+ path: '/dashboard/docs',
+ category: 'Management',
+ },
+ {
+ id: 'categories',
+ title: 'Categories',
+ description: 'Organize your categories',
+ icon: 'categories',
+ path: '/dashboard/categories',
+ category: 'Management',
+ },
+ {
+ id: 'cdn',
+ title: 'CDN',
+ description: 'Manage your resources',
+ icon: 'cdn',
+ path: '/dashboard/cdn',
+ category: 'Management',
+ },
+ {
+ id: 'import',
+ title: 'Import',
+ description: 'Import documents',
+ icon: 'import',
+ path: '/dashboard/import',
+ category: 'Actions',
+ },
+ {
+ id: 'settings',
+ title: 'Settings',
+ description: 'Configure the application',
+ icon: 'settings',
+ path: '/dashboard/settings',
+ category: 'Configuration',
+ },
+];
+
+const filteredResults = ref<SearchResult[]>([]);
// Unified filtering across actions and pages
-const query = computed(() => searchQuery.value.trim().toLowerCase())
+const query = computed(() => searchQuery.value.trim().toLowerCase());
function tokenize(text: string) {
- return text.trim().toLowerCase().split(/\s+/).filter(Boolean)
+ return text.trim().toLowerCase().split(/\s+/).filter(Boolean);
}
function matchesTokens(haystack: string, tokens: string[]) {
- const value = haystack.toLowerCase()
- return tokens.every(t => value.includes(t))
+ const value = haystack.toLowerCase();
+ return tokens.every(t => value.includes(t));
}
const filteredActions = computed<QuickAction[]>(() => {
- const tokens = tokenize(searchQuery.value)
- if (tokens.length === 0) return quickActions
- return quickActions.filter(a =>
- matchesTokens(a.title, tokens) || matchesTokens(a.description, tokens)
- )
-})
+ const tokens = tokenize(searchQuery.value);
+ if (tokens.length === 0) return quickActions;
+ return quickActions.filter(a => matchesTokens(a.title, tokens) || matchesTokens(a.description, tokens));
+});
// Documents from store (filter by title and tags)
-const documentsStore = useDocumentsStore()
+const documentsStore = useDocumentsStore();
const filteredDocuments = computed<SearchResult[]>(() => {
- const tokens = tokenize(searchQuery.value)
- if (tokens.length === 0) return []
+ const tokens = tokenize(searchQuery.value);
+ if (tokens.length === 0) return [];
return documentsStore.getAll
.filter((d: any) => {
- const name = String(d.name || '').toLowerCase()
- const tags = Array.isArray(d.tags)
- ? d.tags.join(' ')
- : String(d.tags || '').replace(/[#,]/g, ' ')
- return tokens.every(t => name.includes(t) || tags.toLowerCase().includes(t))
+ const name = String(d.name || '').toLowerCase();
+ const tags = Array.isArray(d.tags) ? d.tags.join(' ') : String(d.tags || '').replace(/[#,]/g, ' ');
+ return tokens.every(t => name.includes(t) || tags.toLowerCase().includes(t));
})
.map((d: any) => ({
id: d.id,
@@ -200,17 +175,17 @@ const filteredDocuments = computed<SearchResult[]>(() => {
description: d.tags ? `#${String(d.tags)}` : 'Document',
icon: 'files',
path: `/dashboard/docs/${d.id}`,
- category: 'Documents'
- }))
-})
+ category: 'Documents',
+ }));
+});
const filteredPages = computed<SearchResult[]>(() => {
- const tokens = tokenize(searchQuery.value)
- if (tokens.length === 0) return availablePages
+ const tokens = tokenize(searchQuery.value);
+ if (tokens.length === 0) return availablePages;
return availablePages.filter(page => {
- const pool = `${page.title} ${page.description} ${page.category}`
- return matchesTokens(pool, tokens)
- })
-})
+ const pool = `${page.title} ${page.description} ${page.category}`;
+ return matchesTokens(pool, tokens);
+ });
+});
const combinedNavItems = computed(() => {
return [
...filteredActions.value.map(a => ({
@@ -219,148 +194,142 @@ const combinedNavItems = computed(() => {
title: a.title,
description: a.description,
shortcut: a.shortcut,
- onClick: () => executeAction(a)
+ onClick: () => executeAction(a),
})),
...filteredPages.value.map(p => ({
id: `page-${p.id}`,
icon: p.icon,
title: p.title,
description: p.description,
- onClick: () => navigateTo(p)
- }))
- ]
-})
+ onClick: () => navigateTo(p),
+ })),
+ ];
+});
const flattenedItems = computed(() => {
const nav = combinedNavItems.value.map(i => ({
kind: 'nav' as const,
- onClick: i.onClick
- }))
+ onClick: i.onClick,
+ }));
const docs = filteredDocuments.value.map(d => ({
kind: 'doc' as const,
- onClick: () => navigateTo(d)
- }))
- return [...nav, ...docs]
-})
-
- const quickActions: QuickAction[] = [
- {
- id: 'new-doc',
- title: 'New document',
- description: 'Create a new document',
- icon: 'add_file',
- shortcut: 'Ctrl+N',
- action: () => router.push('/dashboard/docs/new')
- },
- {
- id: 'new-category',
- title: 'New category',
- description: 'Create a new category',
- icon: 'add_folder',
- shortcut: 'Ctrl+Shift+N',
- action: () => router.push('/dashboard/categories')
- },
- {
- id: 'search-docs',
- title: 'Search in docs',
- description: 'Search in your documents',
- icon: 'search',
- shortcut: 'Ctrl+q',
- action: () => router.push('/dashboard/docs')
- },
- {
- id: 'upload-file',
- title: 'Upload file',
- description: 'Add a resource to CDN',
- icon: 'import',
- shortcut: 'Ctrl+U',
- action: () => router.push('/dashboard/cdn')
- }
- ]
+ onClick: () => navigateTo(d),
+ }));
+ return [...nav, ...docs];
+});
+
+const quickActions: QuickAction[] = [
+ {
+ id: 'new-doc',
+ title: 'New document',
+ description: 'Create a new document',
+ icon: 'add_file',
+ shortcut: 'Ctrl+N',
+ action: () => router.push('/dashboard/docs/new'),
+ },
+ {
+ id: 'new-category',
+ title: 'New category',
+ description: 'Create a new category',
+ icon: 'add_folder',
+ shortcut: 'Ctrl+Shift+N',
+ action: () => router.push('/dashboard/categories'),
+ },
+ {
+ id: 'search-docs',
+ title: 'Search in docs',
+ description: 'Search in your documents',
+ icon: 'search',
+ shortcut: 'Ctrl+q',
+ action: () => router.push('/dashboard/docs'),
+ },
+ {
+ id: 'upload-file',
+ title: 'Upload file',
+ description: 'Add a resource to CDN',
+ icon: 'import',
+ shortcut: 'Ctrl+U',
+ action: () => router.push('/dashboard/cdn'),
+ },
+];
onMounted(() => {
const handleKeydown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
- e.preventDefault()
- openSearch()
- }
- else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'u') {
- e.preventDefault()
- router.push('/dashboard/cdn')
- }
- else if ((e.ctrlKey || e.metaKey) && e.altKey && e.key.toLowerCase() === 'n') {
- e.preventDefault()
- useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }))
+ e.preventDefault();
+ openSearch();
+ } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'u') {
+ e.preventDefault();
+ router.push('/dashboard/cdn');
+ } else if ((e.ctrlKey || e.metaKey) && e.altKey && e.key.toLowerCase() === 'n') {
+ e.preventDefault();
+ useModal().add(new Modal(shallowRef(CreateCategoryModal), { role: 1 }));
}
if (e.key === 'Escape' && isOpen.value) {
- closeSearch()
+ closeSearch();
}
- }
-
- document.addEventListener('keydown', handleKeydown)
- const openListener = () => openSearch()
- window.addEventListener('global-search-open', openListener as EventListener)
-
+ };
+
+ document.addEventListener('keydown', handleKeydown);
+ const openListener = () => openSearch();
+ window.addEventListener('global-search-open', openListener as EventListener);
+
onUnmounted(() => {
- document.removeEventListener('keydown', handleKeydown)
- window.removeEventListener('global-search-open', openListener as EventListener)
- })
-})
+ document.removeEventListener('keydown', handleKeydown);
+ window.removeEventListener('global-search-open', openListener as EventListener);
+ });
+});
function openSearch() {
- isOpen.value = true
- selectedIndex.value = 0
- searchQuery.value = ''
+ isOpen.value = true;
+ selectedIndex.value = 0;
+ searchQuery.value = '';
nextTick(() => {
- searchInput.value?.focus()
- })
+ searchInput.value?.focus();
+ });
}
function closeSearch() {
- isOpen.value = false
- searchQuery.value = ''
- selectedIndex.value = 0
+ isOpen.value = false;
+ searchQuery.value = '';
+ selectedIndex.value = 0;
}
function filterResults() {
// Reset selection when query changes
- selectedIndex.value = 0
+ selectedIndex.value = 0;
}
function handleKeydown(e: KeyboardEvent) {
if (e.key === 'ArrowDown') {
- e.preventDefault()
- selectedIndex.value = flattenedItems.value.length === 0
- ? 0
- : (selectedIndex.value + 1) % flattenedItems.value.length
+ e.preventDefault();
+ selectedIndex.value = flattenedItems.value.length === 0 ? 0 : (selectedIndex.value + 1) % flattenedItems.value.length;
} else if (e.key === 'ArrowUp') {
- e.preventDefault()
- selectedIndex.value = flattenedItems.value.length === 0
- ? 0
- : (selectedIndex.value - 1 + flattenedItems.value.length) % flattenedItems.value.length
+ e.preventDefault();
+ selectedIndex.value = flattenedItems.value.length === 0 ? 0 : (selectedIndex.value - 1 + flattenedItems.value.length) % flattenedItems.value.length;
} else if (e.key === 'Enter') {
- e.preventDefault()
+ e.preventDefault();
if (flattenedItems.value.length > 0) {
- const entry = flattenedItems.value[selectedIndex.value]!
- entry.onClick()
+ const entry = flattenedItems.value[selectedIndex.value]!;
+ entry.onClick();
}
}
}
function navigateTo(result: SearchResult) {
- router.push(result.path)
- closeSearch()
+ router.push(result.path);
+ closeSearch();
}
function executeAction(action: QuickAction) {
- action.action()
- closeSearch()
+ action.action();
+ closeSearch();
}
defineExpose({
openSearch,
- closeSearch
-})
+ closeSearch,
+});
</script>
<style scoped lang="scss">
@@ -422,7 +391,7 @@ defineExpose({
color: var(--text-color);
font-size: 16px;
outline: none;
-
+
&::placeholder {
color: var(--text-muted);
}
@@ -436,7 +405,7 @@ defineExpose({
padding: 8px;
border-radius: 8px;
transition: all 0.2s ease;
-
+
&:hover {
background: var(--border-color);
color: var(--text-color);
@@ -450,7 +419,7 @@ defineExpose({
.quick-actions {
padding: 20px;
-
+
h3 {
margin: 0 0 16px 0;
font-size: 14px;
@@ -477,11 +446,11 @@ defineExpose({
cursor: pointer;
transition: all 0.2s ease;
text-align: left;
-
+
&:hover {
background: var(--border-color);
}
-
+
&:active {
transform: scale(0.98);
}
@@ -532,7 +501,7 @@ defineExpose({
padding: 12px 20px;
cursor: pointer;
transition: all 0.2s ease;
-
+
&:hover,
&.selected {
background: var(--border-color);
@@ -595,14 +564,14 @@ defineExpose({
padding: 40px 20px;
text-align: center;
color: var(--text-muted);
-
+
.no-results-icon {
width: 48px;
height: 48px;
margin-bottom: 16px;
opacity: 0.5;
}
-
+
p {
margin: 0;
font-size: 14px;
@@ -620,7 +589,7 @@ defineExpose({
gap: 16px;
font-size: 12px;
color: var(--text-muted);
-
+
kbd {
background: var(--border-color);
padding: 2px 6px;
@@ -629,22 +598,6 @@ defineExpose({
font-weight: 600;
}
}
-
-.search-modal-enter-active,
-.search-modal-leave-active {
- transition: all 0.2s ease;
-}
-
-.search-modal-enter-from {
- opacity: 0;
- transform: scale(0.95);
-}
-
-.search-modal-leave-to {
- opacity: 0;
- transform: scale(0.95);
-}
-
@keyframes slideIn {
from {
opacity: 0;
@@ -662,7 +615,7 @@ defineExpose({
margin: 20px;
max-height: 80vh;
}
-
+
.shortcuts {
flex-direction: column;
gap: 8px;