fix(author): store plain text boxes as plain text, though their fields list tags
Merged
AL
10d ago+162+162+012345678901234567890123456789-32-32-01234567890123456789
Closes #164
Changes
- The rule (
packages/author/lib/text.mjs):editorWidget(field)is the widget H5P's editor draws a field with:widget ?? type, or for a ShowWhen, the widget inside it.takesMarkup(field)is true only where that widget ishtmland the field liststags. Both are exported from./core, for a tool beside the build. - The build (
generator.mjs): written text is markup only wheretakesMarkupsays so; everything else is stored as plain text. Its problem messages name the kind the same way.- Saved content (
checkContent) still goes bytags, as the content check keeps it. - Defaults also still go by
tags: the editor puts a default in unescaped, and the server filters it bytags(translate.mjs, comment only).
- Saved content (
- Apostrophes (
plainText(value, note, { filtered })): in a plain box whose field liststags,'is stored as typed. The editor's box would write', which H5P.Components 1.0.101 (upstream's newest) shows as written; the content check's filter keeps a bare apostrophe."stays":ns.createTextputs a stored value back intovalue="…"unescaped, so a bare quote would cut the text short in the editor.&,<and>stay escaped, as the filter would escape them, with a note saying to write "and" and “ ” instead.
- The type file:
H5P.QuestionSet.md, regenerated bysync:skill.introPage.title,endGame.messageand the two old greetings are nowtext, nothtml: …; the other type files came out unchanged. - design/author.md: the text rule now names the widget, plus a new point with the census and the apostrophe rule.
Testing
pnpm --filter @missing-elements/h5p-author test: 153 passed, browser tests included. New tests:takesMarkupandeditorWidgetagainst Question Set's and Speak the Words Set's field shapes;plainTextwithfiltered;- a Question Set build: the title and results heading stored plain, the introduction still
<p>, markup noted, and a German title with umlauts, „“,&and".
pnpm --filter @missing-elements/h5p-skills test: 77 passed: the type files are current, and every example builds and plays untrusted.pnpm --filter @missing-elements/h5p-author typecheck: clean.- The same Question Set source, played by the verifier:
- 0.5.0's cover shows
<div>World War II: Five Historic Events</div>; this branch shows the title alone. - A German title with umlauts and ß, and "Germany's Surrender", show correctly, played trusted and untrusted, with no warnings.
- 0.5.0's cover shows
- Umlauts are stored as typed throughout. Neither the editor nor the platforms escape them, and the test above covers them.
Not verified: the results page in a browser (the stored value is tested, and ResultScreen draws it with textContent, as the cover does), and a Moodle upload of a fixed package.
Release
A fix, so author 0.5.1. It also adds takesMarkup and editorWidget to ./core and an option to plainText, none of them breaking. After publishing:
- embed-my.github.io's build page needs the bump, still on 0.5.0 and showing the
<div>. Its branchfix/build-page-file-namesis ready, with download names that keep umlauts. - Run
npx skills update -gfor the regenerated type file.
Summary by cubic
Fixes text fields that list tags but are plain text boxes in H5P's editor being stored as markup, which showed <div>World War II: Five Historic Events</div> on Question Set's cover.
Bug Fixes
- New
takesMarkupandeditorWidgetdecide from the editor's widget whether a field holds markup; the build, its problem messages, and the type files use them. - Saved content and defaults still go by
tags, as the content check and server keep them. - In a plain box whose field lists
tags, an apostrophe is stored as typed;",&,<, and>stay escaped and are noted. - Regenerated
H5P.QuestionSet.md: the intro title, results heading, and two old greetings are nowtext, nothtml. - A census in
design/author.mdcounts the pack's 1,252textfields whatever widget draws them, and names these five as the only ones stored otherwise than their widgets store them.