From 9ee0378d4e1538383a15c9e9b4240e7951f041a5 Mon Sep 17 00:00:00 2001 From: Ruby Date: Wed, 8 May 2024 16:32:43 +0200 Subject: [PATCH 1/4] fix(docs): hljs depcrecation and new directive couldn't figure out how to get hljs-vue to work so this was just the easiest way to fix it --- dashboard/src/components/docs/MarkdownBlock.vue | 2 +- dashboard/src/directives/highlightjs.ts | 8 ++++++++ dashboard/src/init-vue.ts | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 dashboard/src/directives/highlightjs.ts diff --git a/dashboard/src/components/docs/MarkdownBlock.vue b/dashboard/src/components/docs/MarkdownBlock.vue index 14ff83b2..9da61dd2 100644 --- a/dashboard/src/components/docs/MarkdownBlock.vue +++ b/dashboard/src/components/docs/MarkdownBlock.vue @@ -18,7 +18,7 @@ elem.parentNode.classList.add('codeblock'); } - hljs.highlightBlock(elem); + hljs.highlightElement(elem); }); } }, diff --git a/dashboard/src/directives/highlightjs.ts b/dashboard/src/directives/highlightjs.ts new file mode 100644 index 00000000..85794428 --- /dev/null +++ b/dashboard/src/directives/highlightjs.ts @@ -0,0 +1,8 @@ +import Vue from "vue"; +import hljs from "highlight.js/lib/core"; + +Vue.directive("highlightjs", { + bind(el, binding) { + hljs.highlightElement(el) + }, +}); diff --git a/dashboard/src/init-vue.ts b/dashboard/src/init-vue.ts index d953bd37..e6705379 100644 --- a/dashboard/src/init-vue.ts +++ b/dashboard/src/init-vue.ts @@ -4,13 +4,14 @@ import Vue from "vue"; import VueHighlightJS from "@highlightjs/vue-plugin"; import hljs from "highlight.js/lib/core"; -import hljsYaml from "highlight.js/lib/languages/yaml.js"; +import hljsYaml from "highlight.js/lib/languages/yaml"; import "highlight.js/styles/base16/ocean.css"; import { router } from "./routes"; import { RootStore } from "./store"; import "./directives/trim-indents"; +import "./directives/highlightjs"; import App from "./components/App.vue"; From 68211168d3085a0d7dfd8b72be06a3d2b329cb17 Mon Sep 17 00:00:00 2001 From: Ruby Date: Wed, 8 May 2024 17:02:09 +0200 Subject: [PATCH 2/4] formatting --- dashboard/src/directives/highlightjs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/directives/highlightjs.ts b/dashboard/src/directives/highlightjs.ts index 85794428..b81dd51e 100644 --- a/dashboard/src/directives/highlightjs.ts +++ b/dashboard/src/directives/highlightjs.ts @@ -3,6 +3,6 @@ import hljs from "highlight.js/lib/core"; Vue.directive("highlightjs", { bind(el, binding) { - hljs.highlightElement(el) + hljs.highlightElement(el); }, }); From bb02fd079cca0a00aa26b6a5457c31f0fe3bebef Mon Sep 17 00:00:00 2001 From: Ruby Date: Wed, 8 May 2024 18:50:14 +0200 Subject: [PATCH 3/4] respect code-lang=plain --- dashboard/src/components/docs/CodeBlock.vue | 2 +- dashboard/src/directives/highlightjs.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dashboard/src/components/docs/CodeBlock.vue b/dashboard/src/components/docs/CodeBlock.vue index c4c6a7cd..fbb1102f 100644 --- a/dashboard/src/components/docs/CodeBlock.vue +++ b/dashboard/src/components/docs/CodeBlock.vue @@ -1,5 +1,5 @@