Repository navigation
fix(smart-toolbar): keep a Paint format press made before the engine loads - #77
Merged
Merged
Conversation
The phone status pill spans the docked bar's width 8px above it, in the band where the presence and Discord/GitHub/Privacy chips float, so a refused "/" pick, a removed format's Undo or an unavailable cell's reason covered them. Hide the chips while the bar holds a pill, as they already hide for the selection bar; they come back when it closes.
The colour hover preview drew one decoration over each selection range,
so Red text or Yellow highlight showed over inline code and code blocks
although applying never colours them: inlineCode excludes every mark
and a code block allows none.
setActionPreview now takes { attrs, mark } and decorates only the inline
nodes addMark would mark (the parent allows the mark and no mark on the
node excludes it), merging adjacent runs. A collaborator's redraw keeps
the same rule.
A highlight preview's run that starts after the selection nests the
blurred selection's span inside its mark, so the colour panel's
stylesheet keeps that tint off.
…loads A brush press before the lazy formatting engine landed went through runWithEngine, which runs a queued action only if the selection has not moved. For Paint format the next selection is the intended next step, so the press was dropped and the brush never showed pressed. The brushes now keep the press in paint-pending.ts: pressed at once, with the copy cursor and the pill, the pressed text kept as a session range that follows edits. Once the engine lands it arms on that range and paints a mouse selection made meanwhile (on touch, the second tap). Other queued actions keep the unmoved-selection rule.
A pointer-up that started in the text set the pending press's apply flag even for a plain click, and landing then painted whatever was selected, a keyboard selection too. Read the selection a frame after the pointer-up, as the armed listener does, keep it only when it is other text, and on landing paint only if it is still that selection; otherwise just arm. The touch second press keeps its selection the same way.
Contributor
Author
|
Review blockers fixed in 2a853fe (code + tests) and d802534 (docs). 1.
Tests
Checks
Budgets
Screenshots. The early-press screenshots (1440 bubble, 375 phone, light and dark) were re-shot and show no visual change; this fix only changes behaviour. |
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # tests/TESTING.md
A "/" typed while an earlier fetch of the menu chunk was still failing (the chunk runtime fetches a failed chunk once more, a moment later) joined that fetch. When it failed, nothing loaded the chunk again while the menu stayed open, so the menu never showed even once the chunk could load. A failed load is now fetched once more straight away.
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.
What and why
Clicking the Paint format brush (selection bubble or phone selection cells) before the lazy formatting engine had loaded showed nothing, and the press was dropped as soon as the user selected the text to paint. For Paint format, selecting the target is the intended next step, so the brush must survive that move.
Now the brush shows pressed at once, with the copy cursor and the "Select text to paint · Esc to cancel" pill (touch: "Select text, then tap the brush again"). It keeps the text it was pressed on, and once the engine lands it arms on that text. If a mouse selection of other text ended in the meantime (on touch, the brush was tapped again on new text), it paints that selection too. A second press on the same text, or Esc in the text, cancels. A failed load says "Couldn’t load formatting tools." with Retry, which presses again on the same text. Other queued E actions (Repeat key, palette rows, ⋯ menu) keep the "only if the selection has not moved" rule.
Root cause
PaintFormatButtonwent throughrunWithEngine(lib/editor-actions/v11-actions.ts). That runs a queued action only if the selection has not moved, and the brush had no pending state to render.Changes
components/smart-toolbar/formats/paint-pending.ts(new, lazy surface chunks only). It holds the pending press per editor (WeakMap), theusePaintinghook (moved fromuse-e-action.ts, its only user is the brush) andpressBrush. Its listeners exist only while a press is pending. The range is a Yjs-relativeSessionRange(absolute positions mapped per transaction without a binding). A landing in the middle of a drag waits for that drag's pointer-up.lib/editor-actions/paint-format.ts:togglePaint(editor, touch, source?)arms on a given range. The bundle is read fromEditorState.create({ doc, selection }), sobundle.tsis untouched (the palette imports it).lib/editor-actions/paint-format-ui.ts(new):PAINTING_CLASSandPAINT_PILLS, shared by the engine and the pending press without pulling the engine in.v11-actions.ts:ENGINE_LOAD_FAILEDis now exported for both failure paths. Thetoggletype gains asourceargument.relative-range.ts:toSessionRangetakes{ anchor, head }(type only).How verified
bun run check,bun run lint,bun run typecheck,bun run test(1239 pass).tests/unit/components/paint-pending.test.ts:holdChunk()helper until after the selection moved):paint-format.spec.ts:mobile-bar.spec.ts: the touch caseselection-bubble.spec.ts: the queued-click test now also asserts the immediate pressed state--repeat-each=5after the final code change (30/30).paint-format,selection-bubble,lazy-surfaces(its 404 + Retry brush case included),mobile-bar,paletteandeditor-leak(chromium, own servers on 6504/4504).wf2/paint-early-click/{before,after}). Before: the brush stays unpressed, and on the phone it ends up armed on the target instead of painting it. After: pressed with the pill right away, and the target painted with "Formatting applied".PAINT_EARLY_SCREENS_DIR=<dir>regenerates them.Budgets
ENGINE_LOAD_FAILED). The Hocus URL is not in the eager group, so the two builds compare cleanly.PALETTE_BUDGET=1, production build): 20,475 → 20,475 B, 0 B (same chunk hashes).Follow-ups
tr.insert(paragraph.create(...))dispatched throughview.dispatchmade the next mouse drag collapse to a caret near the end of the document (via ProseMirror'sreadDOMChange). It happens without the brush. The e2e test usesinsertContentAtinstead.palette.spec.ts,lazy-surfaces.spec.tsandselection-bubble.spec.tseach keep a local copy of the hold-chunk helper. They could useholdChunk().