Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: use NTabs for markdown editor tabs (#17293)

boojackcf65a36ff720
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index fa1435038f..f16cd465ec 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -1,5 +1,5 @@
<template>
- <div class="flex flex-col gap-y-4">
+ <div class="flex flex-col">
<ul>
<IssueCreatedComment :issue-comments="issueComments" :issue="issue" />
<IssueCommentView
@@ -68,9 +68,6 @@
</div>
<div class="min-w-0 flex-1">
<h3 class="sr-only" id="issue-comment-editor"></h3>
- <label for="comment" class="sr-only">
- {{ $t("issue.add-a-comment") }}
- </label>
<MarkdownEditor
mode="editor"
:content="state.newComment"
@@ -79,10 +76,9 @@
@change="(val: string) => (state.newComment = val)"
@submit="doCreateComment(state.newComment)"
/>
- <div class="mt-3 flex items-center justify-start">
+ <div class="mt-3 flex items-center justify-end">
<NButton
type="primary"
- size="small"
:disabled="state.newComment.length == 0"
@click.prevent="doCreateComment(state.newComment)"
>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
index 27fcc08418..7137042e90 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentView.vue
@@ -7,7 +7,9 @@
aria-hidden="true"
></span>
<div class="relative flex items-start">
- <ActionIcon :issue-comment="issueComment" />
+ <div class="pt-1.5">
+ <ActionIcon :issue-comment="issueComment" />
+ </div>
<IssueCommentAction
:issue="issue"
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index b903430134..3f9cfb0985 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -1,37 +1,21 @@
<template>
<div>
- <div
+ <NTabs
v-if="mode === 'editor'"
- class="flex gap-x-1 mb-3 text-sm border-b border-gray-200"
+ v-model:value="state.activeTab"
+ type="line"
+ class="mb-3"
+ @update:value="handleTabChange"
>
- <div
- :class="[
- 'px-3 py-2 cursor-pointer transition-colors',
- state.showPreview
- ? 'text-gray-500 hover:text-gray-700'
- : 'text-gray-900 border-b-2 border-gray-900',
- ]"
- @click="state.showPreview = false"
- >
- {{ $t("issue.comment-editor.write") }}
- </div>
- <div
- :class="[
- 'px-3 py-2 cursor-pointer transition-colors',
- state.showPreview
- ? 'text-gray-900 border-b-2 border-gray-900'
- : 'text-gray-500 hover:text-gray-700',
- ]"
- @click="state.showPreview = true"
- >
- {{ $t("issue.comment-editor.preview") }}
- </div>
- <div
- v-if="!state.showPreview"
- class="flex-1 flex items-center justify-end"
- >
- <div v-for="(toolbar, i) in toolbarItems" :key="i">
- <NTooltip :show-arrow="true">
+ <NTab name="write" :tab="$t('issue.comment-editor.write')" />
+ <NTab name="preview" :tab="$t('issue.comment-editor.preview')" />
+ <template v-if="state.activeTab === 'write'" #suffix>
+ <div class="flex items-center justify-end">
+ <NTooltip
+ v-for="(toolbar, i) in toolbarItems"
+ :key="i"
+ :show-arrow="true"
+ >
<template #trigger>
<NButton quaternary size="small" @click="toolbar.action">
<component :is="toolbar.icon" class="w-4 h-4" />
@@ -42,10 +26,11 @@
</span>
</NTooltip>
</div>
- </div>
- </div>
+ </template>
+ </NTabs>
+
<iframe
- v-if="state.showPreview"
+ v-if="state.activeTab === 'preview' || state.showPreview"
ref="contentPreviewArea"
:srcdoc="renderedContent"
class="rounded-md w-full overflow-hidden"
@@ -55,7 +40,7 @@
ref="contentTextArea"
v-model="state.content"
rows="4"
- class="block w-full px-4 py-3 resize-none whitespace-pre-wrap rounded-lg border border-gray-300 focus:border-blue-500 focus:ring-1 focus:ring-blue-500 focus:outline-none transition-colors text-sm"
+ class="block w-full px-4 py-3 resize-none whitespace-pre-wrap rounded-lg border border-gray-300 outline-none ring-0 text-sm"
:placeholder="placeholder || $t('issue.leave-a-comment')"
@mousedown="clearIssuePanel"
@input="(e: any) => sizeToFit(e.target)"
@@ -76,7 +61,7 @@
<li
v-for="issue in filterIssueList"
:key="issue.name"
- class="p-3 rounded hover:bg-blue-500 hover:text-white cursor-pointer flex items-center gap-x-2"
+ class="px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-x-2"
@click="onIssueSelect(issue)"
>
<IssueStatusIcon
@@ -102,7 +87,7 @@ import {
BoldIcon,
HeadingIcon,
} from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
+import { NButton, NTooltip, NTabs, NTab } from "naive-ui";
import { nextTick, ref, reactive, watch, toRef, onMounted } from "vue";
import type { Component } from "vue";
import { useI18n } from "vue-i18n";
@@ -120,6 +105,7 @@ import { useRenderMarkdown } from "./useRenderMarkdown";
interface LocalState {
showPreview: boolean;
content: string;
+ activeTab: "write" | "preview";
}
interface Toolbar {
@@ -148,12 +134,16 @@ const emit = defineEmits<{
const state = reactive<LocalState>({
showPreview: props.mode === "preview",
content: props.content,
+ activeTab: props.mode === "preview" ? "preview" : "write",
});
const { t } = useI18n();
watch(
() => props.mode,
- (mode) => (state.showPreview = mode === "preview")
+ (mode) => {
+ state.showPreview = mode === "preview";
+ state.activeTab = mode === "preview" ? "preview" : "write";
+ }
);
const contentTextArea = ref<HTMLTextAreaElement>();
@@ -185,6 +175,11 @@ watch(
}
);
+const handleTabChange = (value: string) => {
+ state.showPreview = value === "preview";
+ state.activeTab = value as "write" | "preview";
+};
+
watch(
() => state.showPreview,
(preview) => {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 4210091e1d..ebedac800a 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -857,7 +857,6 @@
}
},
"add-some-description": "Add some description...",
- "add-a-comment": "Add a comment",
"leave-a-comment": "Leave a comment...",
"comment-editor": {
"write": "Write",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 2b20a6d8b7..73c54dce71 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -857,7 +857,6 @@
}
},
"add-some-description": "Agregar alguna descripción...",
- "add-a-comment": "Agregar un comentario",
"leave-a-comment": "Dejar un comentario...",
"comment-editor": {
"write": "Escribir",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index af526c6539..936821ff30 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -857,7 +857,6 @@
}
},
"add-some-description": "説明を追加してください…",
- "add-a-comment": "コメントを追加",
"leave-a-comment": "コメントを残す…",
"comment-editor": {
"write": "編集",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index fb3af71b90..8f5b027d7e 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -857,7 +857,6 @@
}
},
"add-some-description": "Thêm mô tả...",
- "add-a-comment": "Thêm bình luận",
"leave-a-comment": "Để lại bình luận...",
"comment-editor": {
"write": "Viết",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 967a83a024..a235cc8ffa 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -857,7 +857,6 @@
}
},
"add-some-description": "添加一些描述…",
- "add-a-comment": "添加评论",
"leave-a-comment": "发表一条评论…",
"comment-editor": {
"write": "编辑",