Skip to content

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

SQL highlighting on description and comment field in none-edit state.

Tianzhou Chend1c8d2ab346a
diff --git a/frontend/src/bbkit/directives/highlight.js b/frontend/src/bbkit/directives/highlight.js
index b7edebe851..786f7e5e0f 100644
--- a/frontend/src/bbkit/directives/highlight.js
+++ b/frontend/src/bbkit/directives/highlight.js
@@ -1,12 +1,13 @@
import hljs from "highlight.js";
import "highlight.js/styles/github-gist.css";
+hljs.configure({
+ languages: ["sql"],
+});
+
const directive = {
beforeMount(el) {
- let blocks = el.querySelectorAll("pre code");
- blocks.forEach((block) => {
- hljs.highlightBlock(block);
- });
+ hljs.highlightBlock(el);
},
};
diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vue
index 131f3640a8..78676b9089 100644
--- a/frontend/src/layouts/DashboardLayout.vue
+++ b/frontend/src/layouts/DashboardLayout.vue
@@ -5,9 +5,6 @@
<div>
<ProvideContext>
<div class="relative h-screen overflow-hidden flex flex-col">
- <pre
- v-highlight
- ><code>SELECT * FROM a WHERE b = 'xxx' GROUP BY 'yyy' ORDER BY 'zzz' HAVING c = 'jjj'</code></pre>
<BannerDemo v-if="isDemo()" />
<nav class="bg-white border-b border-block-border">
<div class="max-w-full mx-auto px-4">
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index 6964bd382a..8ba8af47a2 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -177,37 +177,38 @@
<template
v-if="activity.actionType == 'bytebase.task.comment.create'"
>
- <div class="mt-2 text-sm text-control whitespace-pre-wrap">
- <template
- v-if="
- state.editCommentMode &&
- state.activeComment.id == activity.id
+ <template
+ v-if="
+ state.editCommentMode &&
+ state.activeComment.id == activity.id
+ "
+ >
+ <label for="comment" class="sr-only">Edit Comment</label>
+ <textarea
+ ref="editCommentTextArea"
+ class="textarea block w-full resize-none mt-1 text-sm text-control whitespace-pre-wrap"
+ placeholder="Leave a comment..."
+ v-model="editComment"
+ @input="
+ (e) => {
+ sizeToFit(e.target);
+ }
"
- >
- <label for="comment" class="sr-only"
- >Edit Comment</label
- >
- <textarea
- ref="editCommentTextArea"
- rows="3"
- class="textarea block w-full resize-none"
- placeholder="Leave a comment..."
- v-model="editComment"
- @input="
- (e) => {
- sizeToFit(e.target);
- }
- "
- @focus="
- (e) => {
- sizeToFit(e.target);
- }
- "
- ></textarea>
- </template>
- <template v-else>
+ @focus="
+ (e) => {
+ sizeToFit(e.target);
+ }
+ "
+ ></textarea>
+ </template>
+ <!-- The margin value is intentionally set to avoid flickering when switching between edit mode. -->
+ <div
+ v-else
+ class="text-sm ml-1.5 mt-2 mb-0.5 whitespace-pre-wrap"
+ >
+ <div v-highlight>
{{ activity.payload.comment }}
- </template>
+ </div>
</div>
</template>
</div>
diff --git a/frontend/src/views/TaskDescription.vue b/frontend/src/views/TaskDescription.vue
index 9c63d196be..d9b4f3dc05 100644
--- a/frontend/src/views/TaskDescription.vue
+++ b/frontend/src/views/TaskDescription.vue
@@ -41,32 +41,35 @@
</div>
<!-- Description -->
<label for="description" class="sr-only">Edit Description</label>
- <!-- Use border-white focus:border-white to have the invisible border width
- otherwise it will have 1px jiggling switching between focus/unfocus state -->
- <textarea
- ref="editDescriptionTextArea"
- :rows="$props.new ? 10 : 5"
- class="mt-2 w-full resize-none whitespace-pre-wrap border-white focus:border-white outline-none"
- :class="state.edit ? 'focus:ring-control focus-visible:ring-2' : ''"
- :style="
- state.edit
- ? ''
- : '-webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none'
- "
- placeholder="Add some description..."
- :readonly="!state.edit"
- v-model="state.editDescription"
- @input="
- (e) => {
- sizeToFit(e.target);
- }
- "
- @focus="
- (e) => {
- sizeToFit(e.target);
- }
- "
- ></textarea>
+ <!-- TODO: Has control flickering switching between edit/non-edit mode -->
+ <template v-if="state.edit">
+ <textarea
+ ref="editDescriptionTextArea"
+ :rows="$props.new ? 10 : 5"
+ class="whitespace-pre-wrap mt-2 w-full focus:ring-control focus-visible:ring-2 resize-none border-white focus:border-white outline-none"
+ placeholder="Add some description..."
+ v-model="state.editDescription"
+ @input="
+ (e) => {
+ sizeToFit(e.target);
+ }
+ "
+ @focus="
+ (e) => {
+ sizeToFit(e.target);
+ }
+ "
+ ></textarea>
+ </template>
+ <div
+ v-else
+ class="mt-4"
+ style="margin-left: 5px; margin-top: 9px; margin-bottom: 23px"
+ >
+ <div v-highlight class="whitespace-pre-wrap">
+ {{ state.editDescription }}
+ </div>
+ </div>
</template>
<script lang="ts">