π 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: new global tags completion system
Smaug67394149689a418c
diff --git a/frontend/app/components/AppTagInput.vue b/frontend/app/components/AppTagInput.vueindex 5203dd9a..5b9b216d 100644--- a/frontend/app/components/AppTagInput.vue+++ b/frontend/app/components/AppTagInput.vue@@ -1,96 +1,245 @@<template>- <div class="tags">- <tag v-for="(tag, index) in tagsArray" :key="index" class="primary">- {{ tag }}<button type="button" class="remove" @click="removeTag(index)">Γ</button>- </tag>- <input v-model="input" placeholder="Add a tag (enter to add)" @keydown.enter.prevent="addTag" @keydown.delete="removeLastTag" />+ <div :class="[display === 'row' ? 'row' : 'column']">+ <div class="tags-input-wrapper">+ <div class="tags-input">+ <input+ v-model="tagInput"+ type="text"+ placeholder="Enter to add tag"+ :class="{ minimal: minimal }"+ @keydown.enter="handleEnter"+ @keydown.arrow-up="tagHandleArrowUp"+ @keydown.arrow-down="tagHandleArrowDown"+ @keydown.escape="hideSuggestions"+ @input="handleTagInput"+ @focus="showSuggestions = true"+ @blur="hideSuggestions"+ />+ <button v-if="!minimal" 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="addTag(tag)"+ @mouseenter="selectedSuggestionIndex = index"+ >+ {{ tag }}+ </div>+ </div>+ </div>+ <div v-if="selectedTags?.length" :class="`selected-tags `">+ <span v-for="tag in selectedTags" :key="tag" class="tag-chip">+ {{ tag }}+ <button class="remove-tag" @click.stop="removeTag(tag)">Γ</button>+ </span>+ </div></div></template><script setup lang="ts">-const props = defineProps<{ modelValue?: string }>(); // Separated by commas-const emit = defineEmits<{ (e: 'update:modelValue', value: string): void }>();-const input = ref('');--const tagsArray = computed(() =>- props.modelValue- ? props.modelValue- .split(',')- .map(t => t?.trim())- .filter(Boolean)- : [],+const props = defineProps<{+ display?: 'column' | 'row';+ minimal?: boolean;+ modelValue?: string; // separate tags with commas+}>();+const emit = defineEmits<{+ (e: 'update:modelValue', value: string): void;+}>();++const selectedTags = ref<string[]>(stringToTags(props.modelValue || ''));+const tagInput = ref('');+const showSuggestions = ref(false);+const selectedSuggestionIndex = ref(-1);++const nodesStore = useNodesStore();++watch(+ () => props.modelValue,+ newVal => {+ selectedTags.value = stringToTags(newVal || '');+ },);-function updateModel(newTags: string[]) {- emit('update:modelValue', newTags.join(', '));+function stringToTags(str: string): string[] {+ return str+ .split(',')+ .map(tag => tag.trim())+ .filter(tag => tag.length > 0);+}++const filteredTagSuggestions = computed(() => {+ if (!tagInput.value) return [];+ const input = tagInput.value.toLowerCase();+ return nodesStore.allTags.filter(tag => tag.toLowerCase().includes(input) && !tagInput.value.includes(tag)).slice(0, 5);+});++function addTag(tag?: string) {+ const newTag = tag?.trim() || tagInput.value.trim();+ if (newTag && !selectedTags.value.includes(newTag)) {+ selectedTags.value.push(newTag);+ tagInput.value = '';+ showSuggestions.value = false;+ emit('update:modelValue', selectedTags.value.join(','));+ }+}++function handleTagInput() {+ selectedSuggestionIndex.value = 0;+ showSuggestions.value = filteredTagSuggestions.value.length > 0;+}++function hideSuggestions() {+ setTimeout(() => {+ showSuggestions.value = false;+ }, 200);}-function addTag() {- const value = input.value?.trim();- if (value && !tagsArray.value.includes(value)) {- updateModel([...tagsArray.value, value]);+function handleEnter(event: KeyboardEvent) {+ event.preventDefault();+ let tagToAdd: string | undefined = '';+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ tagToAdd = filteredTagSuggestions.value[selectedSuggestionIndex.value];}- input.value = '';+ addTag(tagToAdd);}-function removeTag(index: number) {- updateModel(tagsArray.value.filter((_, i) => i !== index));+function tagHandleArrowUp(event: KeyboardEvent) {+ event.preventDefault();+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0 ? selectedSuggestionIndex.value - 1 : filteredTagSuggestions.value.length - 1;+ }}-function removeLastTag() {- if (!input.value && tagsArray.value.length) {- updateModel(tagsArray.value.slice(0, -1));+function tagHandleArrowDown(event: KeyboardEvent) {+ event.preventDefault();+ if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {+ selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredTagSuggestions.value.length - 1 ? selectedSuggestionIndex.value + 1 : 0;}}++function removeTag(tag: string) {+ selectedTags.value = selectedTags.value.filter(t => t !== tag);+ emit('update:modelValue', selectedTags.value.join(','));+}</script><style scoped lang="scss">-.tags {+.column {display: flex;- width: 100%;- padding: 0 7px;- align-items: center;- flex-wrap: wrap;+ flex-direction: column;+ gap: 6px;+}+.row {+ display: flex;+ flex-direction: row;+ gap: 12px;+ align-items: baseline;+}+.tags-input-wrapper {+ position: relative;}-tag {- padding: 5px 6px;+.tags-input {+ display: flex;+ gap: 6px;}-button {- margin: 0;- padding: 0;+input {+ flex: 1;+ min-width: 150px;++ &:focus {+ border-color: var(--primary);+ }+ &.minimal {+ font-size: 12px;+ padding: 6px 8px;+ border: none;+ &:hover,+ &:focus {+ background: var(--bg-ui);+ }+ }}-.remove {+.add-tag-btn {+ display: flex;+ padding: 6px 10px;border: none;- font-weight: bold;- color: inherit;- background: none;+ border-radius: 4px;+ color: white;+ background: var(--primary);+ align-items: center;cursor: pointer;- margin-left: 4px;+ justify-content: center;++ &:hover {+ background: var(--primary-dark);+ }}-input {- min-width: 100px;- padding: 4px 8px;- border: none;- border-radius: $radius-sm;- font-size: 0.85rem;- color: var(--font-color);- background: transparent;- transition: background 0.15s ease;- flex: 1 1 150px;- outline: none;+.tag-suggestions {+ position: absolute;+ top: 100%;+ right: 40px;+ left: 0;+ z-index: 10;+ max-height: 150px;+ border: 1px solid var(--border-color);+ border-radius: 4px;+ background: var(--bg-color);+ box-shadow: 0 4px 12px rgb(0 0 0 / 15%);+ margin-top: 2px;+ overflow-y: auto;+}++.tag-suggestion {+ padding: 6px 10px;+ font-size: 12px;+ cursor: pointer;&:hover,- &:focus {- background: var(--bg-ui);+ &.selected {+ background: var(--border-color);}+}++.selected-tags {+ display: flex;+ flex-wrap: wrap;+ gap: 4px;+ margin-top: 6px;+}++.tag-chip {+ display: inline-flex;+ padding: 3px 6px;+ border-radius: 10px;+ font-size: 12px;+ background: var(--border-color);+ align-items: center;+ gap: 4px;++ .remove-tag {+ display: flex;+ width: 14px;+ height: 14px;+ padding: 0;+ border: none;+ border-radius: 50%;+ background: none;+ align-items: center;+ cursor: pointer;+ justify-content: center;- &::placeholder {- color: var(--font-color-light);- opacity: 0.7;+ &:hover {+ color: var(--opposite-color);+ }}}</style>diff --git a/frontend/app/components/CommandCenter/AdvancedSearchTab.vue b/frontend/app/components/CommandCenter/AdvancedSearchTab.vueindex 08eda35f..cad6a7e3 100644--- a/frontend/app/components/CommandCenter/AdvancedSearchTab.vue+++ b/frontend/app/components/CommandCenter/AdvancedSearchTab.vue@@ -45,46 +45,7 @@<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..."- class="tag-input"- @keydown.enter="handleEnter"- @keydown.arrow-up="tagHandleArrowUp"- @keydown.arrow-down="tagHandleArrowDown"- @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="selectedTags?.length" class="selected-tags">- <span v-for="tag in selectedTags" :key="tag" class="tag-chip">- {{ tag }}- <button class="remove-tag" @click.stop="removeTag(tag)">Γ</button>- </span>- </div>- </div>+ <AppTagInput v-model="selectedTags" @update:model-value="tagInput = $event" /></div><div class="filter-group full-width">@@ -118,8 +79,6 @@ const categoriesTree = new TreeStructure(useSidebarTree().nodes.value.filter(n =// UI Stateconst showFilters = ref(true);-const showSuggestions = ref(false);-const selectedSuggestionIndex = ref(0);// Search Stateconst searchInContent = ref(true);@@ -128,7 +87,7 @@ const dateFrom = ref('');const dateTo = ref('');const dateType = ref<'created' | 'modified'>('modified');const tagInput = ref('');-const selectedTags = ref<string[]>([]);+const selectedTags = ref<string>('');const selectedCategory = ref('');/**@@ -156,7 +115,10 @@ async function localSearch() {dateType: dateType.value,fromDate: dateFrom.value ? new Date(dateFrom.value) : undefined,toDate: dateTo.value ? new Date(dateTo.value) : undefined,- tags: selectedTags.value,+ tags: selectedTags.value+ .split(',')+ .map(t => t.trim())+ .filter(t => t.length > 0),role: 3,});}@@ -177,7 +139,10 @@ function applyFilters(results: (NodeSearchResult | Node)[]): (NodeSearchResult |filtered = filtered.filter(d => {if (!d.tags) return false;const nodeTags = d.tags.split(',').map(t => t.trim());- return selectedTags.value.some(tag => nodeTags.includes(tag));+ return selectedTags.value+ .split(',')+ .map(t => t.trim())+ .some(tag => nodeTags.includes(tag));});}@@ -209,12 +174,6 @@ watch({ immediate: true, deep: true },);-const filteredTagSuggestions = computed(() => {- if (!tagInput.value) return [];- const input = tagInput.value.toLowerCase();- return nodesStore.allTags.filter(tag => tag.toLowerCase().includes(input) && !tagInput.value.includes(tag)).slice(0, 5);-});-const flattenedItems = computed(() => {return searchResults.value.map((doc, idx) => ({id: doc.id,@@ -271,66 +230,12 @@ function escapeHtml(text: string): string {return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');}-function addTag() {- const tag = tagInput.value.trim();- if (tag && !selectedTags.value.includes(tag)) {- selectedTags.value.push(tag);- tagInput.value = '';- showSuggestions.value = false;- }-}--function selectTag(tag?: string) {- if (!tag) return;- selectedTags.value.push(tag);- tagInput.value = '';- showSuggestions.value = false;-}--function handleTagInput() {- selectedSuggestionIndex.value = 0;- showSuggestions.value = filteredTagSuggestions.value.length > 0;-}--function hideSuggestions() {- setTimeout(() => {- showSuggestions.value = false;- }, 200);-}--function handleEnter(event: KeyboardEvent) {- event.preventDefault();- if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {- selectTag(filteredTagSuggestions.value[selectedSuggestionIndex.value]);- } else {- addTag();- }-}--function tagHandleArrowUp(event: KeyboardEvent) {- event.preventDefault();- if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {- selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0 ? selectedSuggestionIndex.value - 1 : filteredTagSuggestions.value.length - 1;- }-}--function tagHandleArrowDown(event: KeyboardEvent) {- event.preventDefault();- if (showSuggestions.value && filteredTagSuggestions.value.length > 0) {- selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredTagSuggestions.value.length - 1 ? selectedSuggestionIndex.value + 1 : 0;- }-}-function toggleFilters() {showFilters.value = !showFilters.value;}-function removeTag(tag: string) {- selectedTags.value = selectedTags.value.filter(t => t !== tag);-}-function clearFilters() {- selectedTags.value = [];+ selectedTags.value = '';tagInput.value = '';selectedCategory.value = '';dateFrom.value = '';@@ -445,10 +350,6 @@ defineExpose({ flattenedItems });.date-picker {width: 100%;- padding: 6px 8px;- border: 1px solid var(--border-color);- border-radius: 4px;- font-size: 13px;background: var(--bg-color);outline: none;@@ -474,105 +375,6 @@ defineExpose({ flattenedItems });}}-.tags-filter {- .tags-input-wrapper {- position: relative;- }-- .tags-input {- display: flex;- gap: 6px;- }-- .tag-input {- border: 1px solid var(--border-color);- font-size: 13px;- background: var(--bg-color);- flex: 1;- outline: none;-- &:focus {- border-color: var(--primary);- }- }-- .add-tag-btn {- display: flex;- padding: 6px 10px;- border: none;- border-radius: 4px;- color: white;- background: var(--primary);- align-items: center;- cursor: pointer;- justify-content: center;-- &:hover {- background: var(--primary-dark);- }- }-}--.tag-suggestions {- position: absolute;- top: 100%;- right: 40px;- left: 0;- z-index: 10;- max-height: 150px;- border: 1px solid var(--border-color);- border-radius: 4px;- background: var(--bg-color);- box-shadow: 0 4px 12px rgb(0 0 0 / 15%);- margin-top: 2px;- overflow-y: auto;-}--.tag-suggestion {- padding: 6px 10px;- font-size: 12px;- cursor: pointer;-- &:hover,- &.selected {- background: var(--border-color);- }-}--.selected-tags {- display: flex;- flex-wrap: wrap;- gap: 4px;- margin-top: 6px;-}--.tag-chip {- display: inline-flex;- padding: 2px 6px;- border-radius: 10px;- font-size: 11px;- background: var(--border-color);- align-items: center;- gap: 4px;-- .remove-tag {- display: flex;- width: 14px;- height: 14px;- padding: 0;- border: none;- border-radius: 50%;- background: none;- align-items: center;- cursor: pointer;- justify-content: center;-- &:hover {- color: var(--opposite-color);- }- }-}-.filter-actions {display: flex;gap: 8px;@@ -608,12 +410,4 @@ defineExpose({ flattenedItems });font-size: 10px;color: var(--font-color-light);}--.tag {- padding: 2px 6px;- border-radius: 4px;- font-size: 10px;- color: white;- background: var(--primary);-}</style>diff --git a/frontend/app/components/MarkdownEditor/MarkdownEditor.vue b/frontend/app/components/MarkdownEditor/MarkdownEditor.vueindex e43fd54b..f6b4c5af 100644--- a/frontend/app/components/MarkdownEditor/MarkdownEditor.vue+++ b/frontend/app/components/MarkdownEditor/MarkdownEditor.vue@@ -7,11 +7,12 @@<!-- Compact Document Metadata --><div v-if="!minimal" class="document-meta">- <input v-model="document.name" placeholder="Document title" class="meta-title" @input="autoSaveConditional" />- <input v-model="document.description" placeholder="Description" class="meta-description" @input="autoSaveConditional" />- <AppTagInput v-model="document.tags" class="meta-tags" @update:model-value="autoSaveConditional" />+ <div class="line">+ <input v-model="document.name" placeholder="Document title" class="meta-title" @input="autoSaveConditional" />+ <input v-model="document.description" placeholder="Description" class="meta-description" @input="autoSaveConditional" />+ </div>+ <AppTagInput v-model="document.tags" display="row" minimal @update:modelValue="autoSaveConditional" /></div>- <AppTagInput v-else v-model="document.tags" style="margin: 4px 0" @update:model-value="autoSaveConditional" /><!-- Editor Content Section --><div ref="container" class="editor-content">@@ -161,13 +162,16 @@ const autoSave = debounceDelayed(() => {// Compact Document Metadata - Single line.document-meta {- display: flex;+ .line {+ display: flex;+ align-items: center;+ flex-wrap: wrap;+ }+padding: 6px 12px;border: 1px solid var(--border-color);border-radius: 10px;background: var(--bg-color);- align-items: center;- flex-wrap: wrap;gap: 8px;}