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.

New tags management system

Smaug6739c832faf7ebd1
diff --git a/frontend/app/components/AppTagInput.vue b/frontend/app/components/AppTagInput.vue
new file mode 100644
index 00000000..d5617a10
--- /dev/null
+++ b/frontend/app/components/AppTagInput.vue
@@ -0,0 +1,80 @@
+<template>
+ <div class="tag-input">
+ <div v-for="(tag, index) in tagsArray" :key="index">
+ <tag class="primary" style="padding: 5px 6px">{{ tag }}<button type="button" class="remove" @click="removeTag(index)">Γ—</button></tag>
+ </div>
+
+ <input v-model="input" @keydown.enter.prevent="addTag" @keydown.delete="removeLastTag" placeholder="Add a tag (enter to add)..." />
+ </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)
+ : [],
+);
+
+function updateModel(newTags: string[]) {
+ emit('update:modelValue', newTags.join(', '));
+}
+
+function addTag() {
+ const value = input.value?.trim();
+ if (value && !tagsArray.value.includes(value)) {
+ updateModel([...tagsArray.value, value]);
+ }
+ input.value = '';
+}
+
+function removeTag(index: number) {
+ updateModel(tagsArray.value.filter((_, i) => i !== index));
+}
+
+function removeLastTag() {
+ if (!input.value && tagsArray.value.length) {
+ updateModel(tagsArray.value.slice(0, -1));
+ }
+}
+</script>
+
+<style scoped lang="scss">
+.tag-input {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ background: var(--bg-color);
+ padding: 0 7px;
+ border-radius: 10px;
+ width: 100%;
+}
+button {
+ margin: 0;
+ padding: 0;
+}
+
+.remove {
+ background: none;
+ border: none;
+ color: inherit;
+ cursor: pointer;
+ font-weight: bold;
+ margin-left: 4px;
+}
+
+input {
+ border: none;
+ outline: none;
+ background: transparent;
+ min-width: 80px;
+ flex: 1;
+ padding: 0 4px;
+}
+</style>
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
index 9a6dd030..1b39c2d4 100644
--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -5,6 +5,7 @@
<div style="padding: 6px; flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 8px">
<input placeholder="Title" class="title" v-model="document.name" v-if="!minimal" />
<input placeholder="Description" class="description" v-model="document.description" v-if="!minimal" />
+ <AppTagInput v-model="document.tags" style="margin-bottom: 10px" />
<div class="markdown" ref="container">
<div ref="editorContainer" class="codemirror-editor" style="border-right: 1px solid var(--border-color)" />
<div v-if="showPreview" :class="['markdown-preview', `${usePreferences().get('theme')}-theme`]" ref="markdownPreview" style="position: relative" v-html="document.content_html"></div>
@@ -314,10 +315,12 @@ input {
.title {
font-size: 1.5rem;
font-weight: bold;
+ padding: 6px 10px;
}
.description {
font-size: 1.1rem;
font-weight: 600;
+ padding: 4px 10px;
}
</style>
diff --git a/frontend/app/components/MarkdownEditor/Toolbar.vue b/frontend/app/components/MarkdownEditor/Toolbar.vue
index c78748ee..16b06cac 100644
--- a/frontend/app/components/MarkdownEditor/Toolbar.vue
+++ b/frontend/app/components/MarkdownEditor/Toolbar.vue
@@ -3,8 +3,8 @@
<button v-for="item in toolbar" :key="item.name" v-html="item.icon" @click="emitAction(item.action)" :title="item.name"></button>
<AppSelect v-model="document.accessibility" :items="accessibilities" placeholder="Access" size="100px" class="entry" v-if="!minimal" />
<AppSelect v-model="document.category" :items="categories" placeholder="Select category" size="300px" class="entry" v-if="!minimal" />
- <input type="text" v-model="document.tags" placeholder="Tags" class="entry" />
- <AppHint text="Tags separated with a comma" />
+ <AppHint text="Tags has been moved down" />
+ <!-- TODO: Remove on release 7.4.0 -->
</div>
</template>