From 923cc13c125e578e37b8913cfdbbf9c9373c1d6b Mon Sep 17 00:00:00 2001 From: Arild Matsson Date: Tue, 11 Jun 2024 13:18:37 +0200 Subject: [PATCH] feat: Code highlighting Fixes #30 --- CHANGELOG.md | 4 +++ package.json | 2 ++ src/components/HeightResizable.vue | 12 +++++++ src/components/SyntaxHighlight.vue | 21 ++++++++++++ src/components/TerminalOutput.vue | 2 +- src/components/TextData.vue | 11 ++++-- src/corpus/config/CorpusConfigCustom.vue | 10 +++--- src/corpus/config/CorpusConfiguration.vue | 10 ++++-- src/corpus/job/JobStatus.vue | 13 +++---- src/corpus/sources/SourceText.vue | 4 ++- src/corpus/sources/SourceView.vue | 2 ++ src/highlight.ts | 12 +++++++ src/library/AdminResourcePreview.vue | 7 ++-- src/main.ts | 2 ++ yarn.lock | 41 +++++++++++++++++++++-- 15 files changed, 125 insertions(+), 28 deletions(-) create mode 100644 src/components/HeightResizable.vue create mode 100644 src/components/SyntaxHighlight.vue create mode 100644 src/highlight.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe36f2..9efd5f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ As this project is a user-facing application, the places in the semantic version ## [Unreleased] +### Added + +- Code highlighting for XML and YAML [#30](https://github.com/spraakbanken/mink-frontend/issues/30) + ### Changed - Drop unnecessary async usage of the `js-yaml` package diff --git a/package.json b/package.json index 55f9b1c..ab436a1 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/vue-fontawesome": "^3.0.1", + "@highlightjs/vue-plugin": "^2.1.0", "@modyfi/vite-plugin-yaml": "^1.0.4", "@vitejs/plugin-vue": "^5", "@vue/tsconfig": "^0.5.1", @@ -31,6 +32,7 @@ "datatransfer-files-promise": "^2.0.0", "eslint": "^8.15.0", "filesize": "^10.0.6", + "highlight.js": "^11", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "pinia": "^2.0.28", diff --git a/src/components/HeightResizable.vue b/src/components/HeightResizable.vue new file mode 100644 index 0000000..fa58c61 --- /dev/null +++ b/src/components/HeightResizable.vue @@ -0,0 +1,12 @@ + + + + + diff --git a/src/components/SyntaxHighlight.vue b/src/components/SyntaxHighlight.vue new file mode 100644 index 0000000..253c350 --- /dev/null +++ b/src/components/SyntaxHighlight.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/src/components/TerminalOutput.vue b/src/components/TerminalOutput.vue index b8eb0d6..567242c 100644 --- a/src/components/TerminalOutput.vue +++ b/src/components/TerminalOutput.vue @@ -1,5 +1,5 @@ diff --git a/src/components/TextData.vue b/src/components/TextData.vue index 8aec42f..50513f1 100644 --- a/src/components/TextData.vue +++ b/src/components/TextData.vue @@ -1,15 +1,20 @@