From 8d1155224df75bac8578728c411ab4b06c480c83 Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Fri, 10 Jul 2026 17:49:36 +0200 Subject: [PATCH] fix: resolve Prism syntax highlighting error in peer config modal The PeerViewModal and InterfaceViewModal components displayed: Error: The language "undefined" has no grammar. Root cause: vue-prism-component bundles its own instance of prismjs (separate from the one imported elsewhere), so registering the ini grammar on a different Prism instance had no effect on the one actually performing the highlighting. Fix: bypass vue-prism-component entirely. Import a single Prism instance via a new helper (frontend/src/helpers/prism-setup.js) that also registers the ini grammar, then render highlighted HTML directly with
. This ensures the same
Prism object that owns the ini grammar is the one calling highlight().

Affected files:
- frontend/src/helpers/prism-setup.js (new): imports prismjs, defines
  the ini grammar on the Prism instance, re-exports it
- frontend/src/components/PeerViewModal.vue: replaces  with
  v-html using the shared Prism instance
- frontend/src/components/InterfaceViewModal.vue: same replacement
- frontend/src/main.js: removes the now-unused prism-setup import

Fixes #726
---
 .../src/components/InterfaceViewModal.vue     | 13 +++++--
 frontend/src/components/PeerViewModal.vue     | 12 +++++-
 frontend/src/helpers/prism-setup.js           | 39 +++++++++++++++++++
 frontend/src/main.js                          |  1 -
 4 files changed, 59 insertions(+), 6 deletions(-)
 create mode 100644 frontend/src/helpers/prism-setup.js

diff --git a/frontend/src/components/InterfaceViewModal.vue b/frontend/src/components/InterfaceViewModal.vue
index b71c400..453cd6e 100644
--- a/frontend/src/components/InterfaceViewModal.vue
+++ b/frontend/src/components/InterfaceViewModal.vue
@@ -3,8 +3,7 @@ import Modal from "./Modal.vue";
 import {computed, ref, watch} from "vue";
 import { useI18n } from 'vue-i18n';
 import {interfaceStore} from "@/stores/interfaces";
-import Prism from 'vue-prism-component'
-import 'prismjs/components/prism-ini'
+import Prism from '@/helpers/prism-setup';
 
 const { t } = useI18n()
 
@@ -17,6 +16,14 @@ const props = defineProps({
 
 const configString = ref("")
 
+const highlightedConfig = computed(() => {
+  const grammar = Prism.languages.ini
+  if (grammar) {
+    return Prism.highlight(configString.value, grammar, 'ini')
+  }
+  return configString.value
+})
+
 const emit = defineEmits(['close'])
 
 const selectedInterface = computed(() => {
@@ -51,7 +58,7 @@ function close() {