Skip to content

The source arrives laid out, and a link that carried it follows it - #29

Merged
alekswebnet merged 3 commits into
mainfrom
feat/source-laid-out
Nov 11, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/source-laid-out

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #28.

The Format button goes. A source arrives laid out, so nobody has to ask for it, and a page opened by a link that carried the source keeps the link in step with it.

What changes

  • A source arrives laid out. One opened from a link or a file, or pasted over all of the text (or into an empty editor), is laid out, two spaces and a field to a line, and taken out of the code fence a chat put it in. A paste into the text goes in as it is, and so does text that is not JSON: the line under the source says where it stops being JSON. Where the editor cannot load, the textarea lays a whole paste out too. formatSource moves to json-scan.ts, so the editor's chunk can use it without the author package.
  • A link that carried the source follows it. A page opened with #source= replaces its address when the source changes to another JSON source: the source on one line, compressed with raw deflate where the browser has CompressionStream and that is shorter, so the link stays short to send on. It is history.replaceState, so the history gets no new entry and the page does not read the address back. A change of layout writes nothing, and text that is not JSON leaves the address as it was, so a link never carries a broken source. An emptied editor leaves #source= with nothing after it, so the next source is written; a link that could not be read gives way to the source the person writes. A page opened with no source in its address never writes one. The write waits for a pause in the typing, as Safari allows a hundred in thirty seconds, and one it refuses is tried again at the next change.
  • index.njk and site.css: the button and its row go. The line that says where the JSON is wrong keeps a line of its own, two below 700 px where its message wraps, so what is under it does not move as a mistake comes and goes: at 1100, 768 and 390 px the usual message moves it by 3 px at most, and a long one that wraps once more by a line; at 320 px every message wraps to three lines and moves it by one. The hint under the source says the two things above.
  • docs/h5p-build-page.md says it, under The source editor, and links editor.ts and json-scan.ts now that both are on main.

Nothing is sent anywhere: the address is written in the browser, and a fragment no server sees. The page's script is 396 kB (138 kB gzip), up 1 kB; the editor's chunk is the size it was.

Tested

pnpm build, pnpm typecheck and pnpm e2e: 35 pass, where 29 did. The Format test is two now: a whole paste laid out, out of its code fence, and any other paste as it is (into the text, or of text that is not JSON); and a file laid out, with no Format button on the page. A link's source is asserted laid out, and Tab leaves the editor for the next control. New:

  • the address following a link's source: nothing written on arrival, one write for a new source, none for a change of layout or for text that is not JSON, no new history entry, a reload that builds what the address carries, and the next source written after the editor was emptied;
  • a page opened with no source in its address writing none;
  • a link that cannot be read giving way to the source the person writes;
  • the JSON as it is where there is no CompressionStream;
  • the textarea, where the editor cannot load, laying a whole paste out, and its link following it.

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, with a mistake in the JSON and without.

The Format button goes: a source that arrives is laid out and taken out of its
code fence, so nobody has to ask. A source opened from a link or a file, and
one pasted over all of the text (or into an empty editor), arrives that way; a
paste into the text, and text that is not JSON, go in as they are. Where the
editor cannot load, the textarea lays a whole paste out too.

A page opened by a link that carried a source (#source=) now keeps the link in
step: when the source changes to another JSON source, the address is replaced,
not added to the history, with the new source on one line, deflated where the
browser can. A change of layout, and text that is not JSON, leave it as it was;
an emptied editor leaves #source= with nothing after it, so the next source is
written; a link that cannot be read gives way to the source the person writes.
A page opened with no source in its address never writes one.

formatSource moves to json-scan.ts, which the editor's chunk can use without
the author package.
The editor section loses the Format button and gains the two behaviours that
replace it, the source laid out as it arrives and the address kept in step with
it. editor.ts and json-scan.ts are linked now that both are on main.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/assets/site.css Resolved
On a phone the message and its Show where button wrap to two lines, and the one
line that was kept for it moved what is under it when a mistake appeared. Below
700px the line keeps two. Measured at 1100, 768, 390 and 320px: the usual
message moves what is under it by at most 3px, and a long one that wraps once
more by a line.
@alekswebnet
alekswebnet merged commit 8a24be5 into main Nov 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The build page: a source arrives laid out, and a link that carried it follows it

1 participant