Skip to content

fix(html): editing scope paragraph holds the range, not the style - #909

Merged
andiwand merged 2 commits into
mainfrom
fix/format-is-held-by-the-range
Sep 20, 2026
Merged

andiwand merged 2 commits into
mainfrom
fix/format-is-held-by-the-range

Conversation

@andiwand

@andiwand andiwand commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

odr.editing.format refused every call under scope paragraph, so a host that narrows the scope could not offer any formatting at all - not bold on one word, not a highlight inside a sentence. Marking runs inside one paragraph opens no paragraph and joins none, so the scope was refusing something it is not about.

It now refuses on the same test every other edit uses, outOfScope(at): a range that starts and ends in one paragraph is taken, and one reaching over two is refused.

Where the gate stays

Which styles are offered is the host's to decide, because the host draws the buttons. The one path it cannot draw is the keyboard, so the formatBold chords keep the scope gate: a host that offers less has no way to take a key away. HtmlConfig::keyboard_shortcuts stays the blunt switch, and it is too blunt for this on its own - it also carries undo and redo, which every edition offers.

So the split is: what the host draws, the host gates; what it cannot draw, the scope gates.

This is what a tiered app needs: OpenDocument Reader's free edition narrows the scope to paragraph and wants to offer one formatting tool rather than none.

Checked

test/browser/text: 196 checks, none failing. The scope group now checks that the chord is still refused, that the host's own format marks a run inside one paragraph, and that a format over two paragraphs is refused as outOfScope.

@andiwand
andiwand force-pushed the fix/format-is-held-by-the-range branch from f8292b2 to 3410833 Compare September 20, 2026 09:06
`odr.editing.format` refused every call under scope `paragraph`, so a
host that narrows the scope could offer no formatting at all - not bold
on one word, not a highlight inside a sentence. Marking runs inside one
paragraph opens no paragraph and joins none, so the scope was refusing
something it is not about.

It now refuses on the test every other edit uses, `outOfScope(at)`: a
range inside one paragraph is taken, one over two is refused.

Which styles are offered stays the host's, because the host draws the
buttons. The one path it cannot draw is the keyboard, so the `formatBold`
chords stay behind the gate, and `keyboard_shortcuts` remains the switch
that takes every chord away.

Checked with `test/browser/text` - 196 checks, none failing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJJdfqpnVCKBNHXjAVxSou
@andiwand
andiwand force-pushed the fix/format-is-held-by-the-range branch from 3410833 to d61f21a Compare September 20, 2026 09:35
The reason a chord keeps the gate belongs at the chord, and `format` only
needs to say that the scope holds the range.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149gFxhkvKTBQidz6brU8Vt
@andiwand
andiwand merged commit 5ad051c into main Sep 20, 2026
23 checks passed
@andiwand
andiwand deleted the fix/format-is-held-by-the-range branch September 20, 2026 09:40
andiwand added a commit to opendocument-app/OpenDocument.droid that referenced this pull request Sep 20, 2026
…ol (#668)

* Rebuild the editing UI around one tool per tap, and sell it by the tool

The strip under the edit bar was up to eleven targets wide and scrolled on
a phone: every marking tool carried a second button for its colour, and
undo and redo sat at the end where a pdf pushed them off the screen.

The strip is now formatting alone. Undo, redo and save are `menu/edit.xml`,
so they stand in the bar and do not scroll away, and `EditActionModeCallback`
dims them on what the page reports. A sheet or a plain text file shows no
strip at all. Every tool is one 48dp square: a tap does the tool's one job
and a long press opens the colours it applies, so the chevrons are gone.
The colour bar under an icon is what the next tap uses, and it sits at the
foot of a deep slot - close under the ink, a squiggle that dips and a
strikethrough that stops high read as bars at different heights. The
fourteen font sizes are a row under the strip rather than a menu down the
screen, scrolled to the size the text is in.

A pdf's tools no longer arm themselves. `odr.annotation.press` marks a
standing selection and arms only what it could not mark, so
`PageView.pressMarkTool` puts every tool but the pen back down. With
nothing selected the answer is the `action_annotate_banner` snackbar. The
page's `markOnSelection` is therefore off: it marked as the selection was
made, which is the opposite order. The bridge states the sheet's gesture
too, because an android WebView reports a fine pointer on an emulator.

The gate moved from the mode to the tool. Every edition opens every kind
the core calls editable, and a locked strip dims what only offers pro and
leaves the highlighter working - `highlight` being the formatting style
and the pdf's marking tool alike. A mode nobody can do anything in is not
worth opening. The two offers say what is still pro; their translations
are dropped rather than left stating the old, now false, thing.

No string is new: every label reuses one the app already has in nineteen
languages, and `action_edit_banner` is gone from all of them.

The free highlighter in a text document wants a core carrying
opendocument-app/OpenDocument.core#909, which is unreleased: against 7.1.0
the page refuses it and the offer of pro comes up, as it does today.

Checked on a Pixel 6 Pro emulator in both themes and both editions: 97
instrumented tests on pro, 97 on lite, the unit tests, lint, and all three
flavors build.

* Draw the highlighter as one, rather than as a third pencil

`ic_marker` was Material's `edit` icon, so the highlight tool, the Draw
tool and the Edit button were all pencils: `ic_edit` on the button that
edits a document, `ic_marker` on the one that marks up a pdf and on the
highlighter beside `ic_draw` in the strip. At 22dp they were not worth
telling apart.

It is now a highlighter: the wedge nib that says the ink goes on in a
band, the barrel, and the cap at the back. The colour it lays down is
still the bar under it.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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