feat(html): the document editor formats text - #897
Merged
Conversation
andiwand
force-pushed
the
feat/set-text-style-ooxml
branch
from
September 13, 2026 16:42
1454edb to
dfafb19
Compare
`odr.editing.format(style)` states any of bold, italic, underline, strikethrough, highlight, colour and size on the selection, and ctrl/cmd+B, I and U toggle through the `formatBold` family of input types. A run the selection covers in part is cut first, and each covered run gets one `setTextStyle`. A collapsed caret inside a word marks the word. Formatting sits behind the scope gate whole: `paragraph` refuses it with `outOfScope`. The editor writes what `translate_text_style` writes, so an edited page looks like a fresh render, and `odr.onSelectionChange` reports the computed style the covered runs agree on. Two marks on one run fold into one op unless an operation naming that run lies between them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137vd79NGaB8nfLsdPoghM4
andiwand
force-pushed
the
feat/format-editor
branch
from
September 13, 2026 16:53
55e5cbf to
126d77d
Compare
`odr.editing.toggle(property)` is the chord's rule for a host's button: a mixed selection turns on. On a collapsed caret at a word boundary, or in a paragraph holding no run, the mark is pending: nothing changes until the next typed text, which is cut into a run of its own and marked, so what follows stays marked on its own. `onSelectionChange` reports the pending mark meanwhile; a caret that moves away, a commit and a narrowed scope drop it. The text fold steps over a style op on the same run and the style fold over a text op, since the two are independent, so typing after a pending mark still folds into the insert that opened the run. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137vd79NGaB8nfLsdPoghM4
andiwand
added a commit
that referenced
this pull request
Sep 13, 2026
The two editor scripts under `resources/` follow #897 in both repositories; no page moved. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137vd79NGaB8nfLsdPoghM4
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.
🤖 Generated with Claude Code
Step 4 of the inline formatting plan (
docs/design/document-editing.md, decisions 15 and 16). Rebased onto main after #896 merged.Two ways in.
odr.editing.format(style)is the host's button: it states any ofbold,italic,underline,strikethrough(a bool),highlight(#rrggbbor null),color(#rrggbb) andsize(14pt) on the selection, answers false where refused, and the refusal channel says why.formatBold,formatItalic,formatUnderlineandformatStrikeThrough, which Chrome raises for ctrl/cmd+B, I and U, leave the refused list and toggle; a mixed selection turns on, as Word does. They are the shortcuts key class, so where a host keeps that class the editor cancels the browser's own mark and does nothing else.The gate. Formatting sits behind
HtmlConfig::editing_scopewhole: underparagraphevery chord and everyformat()refuses withoutOfScope(1010).The cut. A run the selection covers in part is cut first (
setTextplusinsertText), and each covered run gets onesetTextStyle, which is the shape #895 and #896 replay. A range over a picture marks the text on both sides; one over a text box refuses, as a replace does.Toggle and the pending mark.
odr.editing.toggle("bold")is the chord's rule for a host's button: a mixed selection turns on. A collapsed caret inside a word marks the word, as Word does. At a word boundary, or in a paragraph holding no run, the mark is pending: nothing changes until the next typed text, which is cut into a run of its own and marked, so what follows stays marked on its own.onSelectionChangereports the pending mark meanwhile, and a caret that moves away, a commit or a narrowed scope drops it.The page stays a fresh render. The editor writes what
translate_text_stylewrites into the run'sstyleattribute.odr.onSelectionChange(style)reports the computed style the covered runs agree on, one key per property and none where they differ, and is quiet while nothing changes. Two marks on one run fold into one op unless an operation naming that run lies between them. Undo restores thestyleattribute, stating it before removing it, since Chrome serialises a declaration set throughstyleinto an empty attribute after a bareremoveAttribute.Verified. The text check page grows from 118 to 172 checks (headless Chrome, 0 failed): the cut and its ops, the chord toggling both ways and folding, the word rule, every property's css, the selection report, undo and redo, a picture, a text box, and both refusals under scope
paragraph. The sheet pages (61, 14, 22, 8) and the plaintext page (45) still pass, sinceediting.jschanged. No rendering changes, so no reference output moves.