Skip to content

Fix literal   characters appearing in the editor after closing…#150

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jun 15, 2026
Merged

Fix literal   characters appearing in the editor after closing…#150
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Fix literal   characters appearing in the editor after closing and reopening a document. A space at the edge of a paragraph, bold/italic run, inline code, or list item is stored by the byte-fidelity engine as the numeric character reference   (or 	 for a tab); on a cold reopen that reference was restored as the visible literal text   instead of a real space. Whitespace numeric character references now display as the decoded space/tab in the editor while still serializing to the exact same bytes on disk, so source byte-fidelity is unchanged. User-authored entity references (&, A) and escaped \  are untouched, and the sourceLiteral security gate continues to reject any non-whitespace divergence between displayed text and persisted bytes.

… (#1853)

* fix(open-knowledge): decode boundary-whitespace char-refs for display

A phrasing-boundary space stored by the byte-fidelity serializer as a bare
  (or 	 for a tab) was restored as literal   text in the WYSIWYG
on a cold reopen. Decode inline-whitespace numeric char-refs to the real
space/tab for editor display while keeping sourceRaw, so the source bytes
round-trip byte-identically.

A contiguous run of these refs is coalesced into one sourceLiteral segment
carrying the full concatenated sourceRaw: otherwise ProseMirror merges two
equal-mark decoded nodes into one whose lone sourceRaw no longer covers the
visible run, the serialize gate rejects it, and the decoded spaces overwrite
the   bytes on disk.

Adds a third legitimate divergence class to the sourceLiteral security gate,
scoped strictly to runs of space/tab refs whose decoded whitespace equals the
visible text; vertical whitespace and non-whitespace refs stay rejected.
Covered by PM-altitude regression tests (single + adjacent + run), a run-decoder
unit test, gate security tests, and a server cold-reopen CRDT integration test.

* chore(open-knowledge): regenerate ng-anchors catalog after boundary-whitespace fix

* test(open-knowledge): address review nits on boundary-whitespace fix

Three Consider-tier reviewer suggestions on PR #1853:
- wysiwyg-x20-cold-reopen: UUID-suffixed docName in the cold-restart test,
  matching the file's other tests and avoiding propagation of the hardcoded
  'test-doc' anti-pattern into future Playwright tests.
- boundary-whitespace-pm-display: pin coalescence termination on an
  interleaved non-whitespace entity (a & b stays three
  sourceLiteral segments) plus a byte-stable round-trip case.
- whitespace-char-ref: document why decodeInlineWhitespaceNumericCharRef is
  exported (directly unit-tested primitive; cross-module callers use the run
  variant).

Regenerate byte-preservation-audit.json for the shifted test line numbers.

GitOrigin-RevId: a1368912cc79378bc43ef833fc8f66994eca4df3

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/27520911534). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.

@inkeep-oss-sync inkeep-oss-sync Bot merged commit 524721f into main Jun 15, 2026
@inkeep-oss-sync inkeep-oss-sync Bot deleted the copybara/sync branch June 15, 2026 02:46
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.

1 participant