Repository navigation
A JSON editor on the build page, where the textarea only shows the source - #27
Merged
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
alekswebnet
added a commit
that referenced
this pull request
Nov 11, 2026
alekswebnet
added a commit
that referenced
this pull request
Nov 11, 2026
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.
Closes #26.
The source field of the build page is an editor, where it was a textarea that only showed the JSON. A person who gets a source from a chat is a teacher, not a developer: a missing comma or quote was invisible until Build said "The source cannot be read", with no place.
What changes
src/h5p/build/editor.ts, the editor: CodeMirror 6, loaded apart from the page, with JSON in the site's own token colours, line numbers, matching brackets and undo. The textarea stays under it, hidden, holding the same text, so the rest of the page reads the source as it always did. Where the editor cannot load, the textarea stays as the source and the page works.Not valid JSON at line 3, column 3: A comma is missing here, after the value before it.src/h5p/build/json-scan.ts, which reads JSON text with no DOM for where a mistake is and where a path points.JSON.parsesays where differently in each browser and Safari does not say at all, and the build names a problem by path (params.chapters[0].metadata.title), not by line.JSON.parsestill decides whether text is JSON; this says where.parseSourcesays where, in every browser: the problem text, and so the copy for the chat, now readsis not valid JSON at line 1, column 24: …, where it carried the browser's own words.package.jsonand the lockfile: eight@codemirror/*and@lezer/*packages, pinned exactly; the lockfile change is their added entries.What it respects
style-src 'self'refuses a<style>that an editor injects. The editor is mounted in a shadow root, where CodeMirror adopts its styles as a constructed stylesheet, which the policy does not govern. Its colours are the site's custom properties, which reach into the shadow root, so light and dark need no code.styleattribute from Chrome, which the policy refuses and reports (I saw it with select all, then a letter;contenteditable="plaintext-only"did not stop it). The editor takes that typing itself, through its input handlers, so a bracket typed over a selection still wraps it and the policy is never asked.Tested
pnpm build,pnpm typecheckandpnpm e2e: 29 pass, and they passed five runs in a row. The 16 that were there pass, and the build page's 10 of them fill the source through the editor now. New: 7 for the reader of JSON, with no browser (each kind of mistake at its offset, and thatJSON.parseagrees which texts are JSON; paths found, and what is missing found in its object), and 6 for the editor (a mistake marked and put right; Format and the code fence; a problem marked and its name going there, a text that is not JSON as a problem with a place; the editor's name, its label and Tab; typing over a selection, which a bracket wraps, with no policy report; and the textarea where the editor cannot load). The tests that watch the page still fail on any policy report or page error. I looked at it in light and dark at desktop width and at 390 px.The documentation of the build page, in the README as it is on
mainand indocs/h5p-build-page.mdof #25, is not part of this: #25 moves it, so it is written there.