In-page visual editor silently strips superscript and subscript marks on save
Description
The in-page visual editor (InlinePortableTextEditor, mounted by InlineEditor.astro when a template spreads {...entry.edit.content}) drops superscript and subscript marks when it loads Portable Text. Any save from that editor, including one that only edits unrelated text, writes the content back without those marks. No error or warning is shown.
Expected: the marks survive, as they do in the admin editor since #2199; or, failing that, the editor refuses the lossy save with the error #2493 added to the admin editor. The design decision on #2430 set that guarantee ("opening and saving Portable Text can never silently remove unsupported marks"). #2493 applied it to packages/admin and the core converters. The in-page editor has its own copies of the converters and was not covered.
Cause, in [email protected] src/components/InlinePortableTextEditor.tsx:
convertPTMarks(line 797) mapsstrong,em,underline,strike-throughandcode, and resolvesmarkDefslinks indefault.superscriptandsubscriptfall throughdefaultand are discarded, so they never enter editor state.- The TipTap
extensionsarray (line 2256) registers no Superscript or Subscript extension, andemdashdoes not depend on@tiptap/extension-superscript/-subscript(@emdash-cms/admindoes). mark-safety.tsis not imported, so no unsupported-mark check runs.
The reverse converter convertPMMark (line 411) passes unknown mark types through, but that doesn't help: the marks are lost at load, before save.
Same behaviour on 0.35.0 and 0.38.0. No release from 0.39.0 to 1.0.1 touches this file's mark handling.
Steps to reproduce
Create a published entry whose Portable Text field contains:
[{"_type":"block","_key":"blk1","style":"normal", "markDefs":[{"_type":"link","_key":"fn1link","href":"#fn-1"}], "children":[ {"_type":"span","_key":"s1","text":"This claim has a footnote marker","marks":[]}, {"_type":"span","_key":"s2","text":"1","marks":["superscript","fn1link"]}, {"_type":"span","_key":"s3","text":" and here is a plain ordinal","marks":[]}, {"_type":"span","_key":"s4","text":"2","marks":["superscript"]}, {"_type":"span","_key":"s5","text":" and a subscript value H","marks":[]}, {"_type":"span","_key":"s6","text":"2","marks":["subscript"]}, {"_type":"span","_key":"s7","text":"O for good measure.","marks":[]}]}]Render it on a page with
<PortableText value={entry.data.content} />inside an element spread with{...entry.edit.content}.Sign in, enter Edit mode, and click the body. The editor DOM contains no
<sup>or<sub>; the marker renders as<a href="#fn-1">1</a>.Type a few characters at the end of the paragraph and click outside to save.
Read the draft revision. Stored content:
{"_type":"block","style":"normal","children":[ {"_type":"span","text":"This claim has a footnote marker"}, {"_type":"span","text":"1","marks":["2sywibw1c"]}, {"_type":"span","text":" and here is a plain ordinal2 and a subscript value H2O for good measure. EDITED."}], "markDefs":[{"_type":"link","_key":"2sywibw1c","href":"#fn-1","blank":false}]}superscriptandsubscriptare gone, and the formerly marked spans merge into the surrounding text.
Control: the same content opened in the admin editor shows <sup>/<sub>, and a trivial edit plus save keeps ["fn1link","superscript"], ["superscript"] and ["subscript"].
Impact: sites that use superscript links as footnote markers (or subscript for chemical formulas) lose that formatting whenever an editor makes any in-page change to the body.
Environment
- emdash version: 1.0.1 (also reproduced by source inspection on 0.38.0; first observed on 0.35.0)
- @emdash-cms/cloudflare: 1.0.1
- Node.js version: 22.23.1
- Runtime: Cloudflare Workers (local
astro dev, D1 via Miniflare) - OS: Linux
- Browser: Chrome
Screenshots
Not applicable. The loss is in stored data, shown as before/after JSON above; the only visible symptom is <sup>/<sub> missing from the editor DOM (step 3).
Logs / error output
No error or mark-related warning. The only console message while editing is unrelated:
[tiptap warn]: Duplicate extension names found: ['link', 'underline']Source: emdash-cms/emdash