Stop cleanUpNbsps orphaning CKEditor's zero-width filling char in titles (BL-16808) - #8332
Stop cleanUpNbsps orphaning CKEditor's zero-width filling char in titles (BL-16808)#8332andrew-polk wants to merge 1 commit into
Conversation
|
[Claude Fable 5.1] Consulted Devin on 2026-09-08 20:27 UTC up to commit |
|
[Claude Fable 5.1] Consulted Devin on 2026-09-08 21:11 UTC up to commit |
|
[Claude Fable 5.1] Consulted Devin on 2026-09-08 21:48 UTC up to commit |
…lling char in titles (BL-16808) Follow-up to #8305. A title typed "One Two" with Enter or Shift+Enter at the start of "Two" still published as "OneTwo" on 6.4: Show Hidden Characters showed a U+200B at the start of the second line, and Chromium renders a newline adjacent to U+200B as nothing. CKEditor plants that "filling char" whenever it re-selects a caret next to an inline element (the bloom-linebreak span, for one) and removes it later by node reference. Bloom's half-second tidy-up after every keystroke took and restored a CKEditor bookmark, which is such a re-select, and assigned the box's innerHTML whether or not anything had changed. Each rewrite detached the tracked node, so the character stayed as text, a fresh one was planted on the next pause, and the result was saved. Reproduced in a running 6.4 build over CDP; master fixed both halves in BL-16558 and BL-16717. Port those two changes: - cleanUpNbsps assigns innerHTML only when it actually converted an nbsp. - The tidy-up takes a bookmark only when a tool is active or the box holds a comment or an nbsp (editableMightBeRewritten), the only cases in which anything rewrites it. With both, Enter and Shift+Enter are clean at every step in a running Bloom, Show Hidden Characters included, and the saved title is "One \nTwo". Five new tests check node identity, the bookmark refill on both paths, and the gate. Not done: cleaning books that already carry a stray U+200B, and master's save-time strip (BL-16490), judged too risky for 6.4 because Khmer, Thai and Myanmar text uses U+200B legitimately. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
cd867a2 to
daeef6b
Compare
Problem. Follow-up to #8305. A tester found that on 6.4 a title typed as "One Two" with Enter (or Shift+Enter) pressed at the start of "Two" still reaches the Publish tab and bloomlibrary.org as "OneTwo", even though #8305 now puts a line break between the two lines. Show Hidden Characters reveals a zero-width space at the start of the second line. 6.5 does not have the problem.
Cause. CKEditor plants a zero-width "filling char" (U+200B) at the caret whenever it re-selects a caret that sits next to an inline element, such as the line-break span Shift+Enter inserts, and removes it later by holding a reference to that text node. Bloom's half-second tidy-up after every keystroke took a CKEditor bookmark and restored it, which is such a re-select, and it also assigned the box's
innerHTMLwhether or not anything had changed. Each rewrite detached the node CKEditor was tracking, so the character stayed as ordinary text, a fresh one was planted on the next pause, and the result was saved. Chromium renders a newline adjacent to U+200B as nothing at all, so the line break became invisible. Reproduced in a running 6.4 build over CDP, and master fixed both halves in BL-16558 and BL-16717, which is why 6.5 is clean.What the PR does. Ports the two master changes:
cleanUpNbspsassignsinnerHTMLonly when it actually converted a non-breaking space, and the tidy-up takes a bookmark only when a tool is active or the box holds a comment or an nbsp, the only cases in which anything rewrites it. With both, the tester's Enter and Shift+Enter sequences are clean at every step in a running Bloom, Show Hidden Characters included, and the saved title is "One \nTwo". Five new tests check node identity and the gate. Not done: cleaning books that already carry a stray zero-width space, and stripping one that CKEditor itself plants after, say, a Backspace next to a line break and that Show Hidden Characters then orphans; master strips those at save (BL-16490), which was judged too risky for 6.4 because Khmer, Thai and Myanmar text uses U+200B legitimately.Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16808
Devin review
This change is