Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add highlight js using github gist theme
Tianzhou Chend5a7435efd01
diff --git a/frontend/package.json b/frontend/package.jsonindex 94569e2524..38ed8027fc 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -15,6 +15,7 @@"axios": "^0.20.0","faker": "^5.1.0","focus-visible": "^5.2.0",+ "highlight.js": "^10.6.0","lodash-es": "^4.17.20","miragejs": "^0.1.41","moment": "^2.29.1",diff --git a/frontend/src/bbkit/directives/highlight.js b/frontend/src/bbkit/directives/highlight.jsnew file mode 100644index 0000000000..b7edebe851--- /dev/null+++ b/frontend/src/bbkit/directives/highlight.js@@ -0,0 +1,13 @@+import hljs from "highlight.js";+import "highlight.js/styles/github-gist.css";++const directive = {+ beforeMount(el) {+ let blocks = el.querySelectorAll("pre code");+ blocks.forEach((block) => {+ hljs.highlightBlock(block);+ });+ },+};++export default directive;diff --git a/frontend/src/layouts/DashboardLayout.vue b/frontend/src/layouts/DashboardLayout.vueindex 78676b9089..131f3640a8 100644--- a/frontend/src/layouts/DashboardLayout.vue+++ b/frontend/src/layouts/DashboardLayout.vue@@ -5,6 +5,9 @@<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/main.js b/frontend/src/main.jsindex 45eabb3ad1..2841f40eed 100644--- a/frontend/src/main.js+++ b/frontend/src/main.js@@ -1,6 +1,7 @@import { createApp } from "vue";-import App from "./App.vue";import moment from "moment";+import highlight from "./bbkit/directives/highlight";+import App from "./App.vue";import { store } from "./store";import { router } from "./router";import "./assets/css/tailwind.css";@@ -39,6 +40,10 @@ app.config.globalProperties.isDevOrDemo = isDevOrDemo();app.config.globalProperties.sizeToFit = sizeToFit;app+ // Need to use a directive on the element.+ // The normal hljs.initHighlightingOnLoad() won't work because router change would cause vue+ // to re-render the page and remove the event listener required for+ .directive("highlight", highlight).use(store).use(router).component("BBAlert", BBAlert)diff --git a/frontend/yarn.lock b/frontend/yarn.lockindex 958cea758d..b4bac81968 100644--- a/frontend/yarn.lock+++ b/frontend/yarn.lock@@ -496,6 +496,11 @@ hash-sum@^2.0.0:resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-2.0.0.tgz#81d01bb5de8ea4a214ad5d6ead1b523460b0b45a"integrity sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==+highlight.js@^10.6.0:+ version "10.6.0"+ resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.6.0.tgz#0073aa71d566906965ba6e1b7be7b2682f5e18b6"+ integrity sha512-8mlRcn5vk/r4+QcqerapwBYTe+iPL5ih6xrNylxrnBdHQiijDETfXX7VIxC3UiCRiINBJfANBAsPzAvRQj8RpQ==+html-tags@^3.1.0:version "3.1.0"resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"