Fix literal   characters appearing in the editor after closing…#150
Merged
Conversation
… (#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
Contributor
There was a problem hiding this comment.
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.
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.
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.