fix(jseditor): fallback to hljs.highlightBlock for older highlight.js…#5340
Merged
walterbender merged 1 commit intosugarlabs:masterfrom Jan 31, 2026
Merged
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
1 similar comment
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Member
|
Maybe we should update lib/codejar/highlight.pack.js to a newer version? |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
|
❌ Some Jest tests failed. Please check the logs and fix the issues before merging. Failed Tests: |
Addresses Walter's feedback to update the bundled highlight.js library to a newer version instead of adding fallback logic. The v11 API uses highlightElement() which is what jseditor.js expects.
fe6ed6c to
3fcfbcf
Compare
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
updated lib/codejar/highlight.pack.js to a newer version |
vanshika2720
pushed a commit
to vanshika2720/musicblocks
that referenced
this pull request
Feb 11, 2026
Addresses Walter's feedback to update the bundled highlight.js library to a newer version instead of adding fallback logic. The v11 API uses highlightElement() which is what jseditor.js expects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5334 - Regression where the highlighter used by the js-editor is not loading.
Problem
The JS Editor widget was calling
hljs.highlightElement()which only exists in Highlight.js v11+. However, the bundled lib/codejar/highlight.pack.js is v10.1.2 which useshljs.highlightBlock()instead.Solution
Added feature detection to check for the presence of
highlightElement:hljs.highlightElement(editor)if available (Highlight.js v11+)hljs.highlightBlock(editor)for older versions (v10.x)This ensures compatibility with both the local bundled library and any CDN-loaded version.
Changes
Testing
Related Issue
Closes #5334