From 17e322638672de1548169bb61a4c6b54978a0e50 Mon Sep 17 00:00:00 2001 From: mytlogos Date: Sun, 12 Dec 2021 11:21:18 +0100 Subject: [PATCH] feat(website): add syntax highlight to regex --- .../src/components/customHook/regex.vue | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/website/src/components/customHook/regex.vue b/packages/website/src/components/customHook/regex.vue index 9a6571c0..39c2f25e 100644 --- a/packages/website/src/components/customHook/regex.vue +++ b/packages/website/src/components/customHook/regex.vue @@ -2,7 +2,7 @@
- +
@@ -14,9 +14,17 @@ import { JsonRegex } from "enterprise-scraper/dist/externals/custom/types"; import { defineComponent, PropType } from "vue"; import { createComputedProperty } from "../../init"; +import { PrismEditor } from "vue-prism-editor"; +// @ts-expect-error +import { highlight, languages } from "prismjs/components/prism-core"; +import "prismjs/components/prism-regex.js"; +import "prismjs/themes/prism-tomorrow.css"; // import syntax highlighting styles export default defineComponent({ name: "Regex", + components: { + PrismEditor, + }, props: { modelValue: { type: Object as PropType, @@ -32,5 +40,40 @@ export default defineComponent({ pattern: createComputedProperty("modelValue", "pattern"), flags: createComputedProperty("modelValue", "flags"), }, + methods: { + highlighter(code: string) { + return highlight(code, languages.regex); // languages. to return html with markup + }, + }, }); +