diff --git a/js/widgets/jseditor.js b/js/widgets/jseditor.js index 6ca9960f60..f9cebc6b2c 100644 --- a/js/widgets/jseditor.js +++ b/js/widgets/jseditor.js @@ -550,15 +550,18 @@ class JSEditor { this._editor.appendChild(editorconsole); const highlight = editor => { - // Configure highlight.js for JavaScript - hljs.configure({ - languages: ["javascript"] - }); - - // Apply highlight.js syntax highlighting for JavaScript - hljs.highlightElement(editor); + if (window.hljs) { + hljs.configure({ + languages: ["javascript"] + }); + + if (typeof hljs.highlightElement === "function") { + hljs.highlightElement(editor); + } else if (typeof hljs.highlightBlock === "function") { + hljs.highlightBlock(editor); + } + } - // Add error highlighting this._highlightErrors(editor); };