Skip to content

A paragraph is edited where it sits - #15

Merged
anderix merged 1 commit into
a-shape-is-moved-by-handfrom
a-paragraph-is-edited-where-it-sits
Sep 21, 2026
Merged

anderix merged 1 commit into
a-shape-is-moved-by-handfrom
a-paragraph-is-edited-where-it-sits

Conversation

@anderix

@anderix anderix commented Sep 21, 2026

Copy link
Copy Markdown
Member

The fifth slice of 0.4.0, on top of #14. In edit mode a click on a paragraph opens it as a text box in place, at the paragraph's own font, size, colour, indent and width, in xodt for the flow and in xodp for a shape's label. Escape puts it back, Ctrl+Enter or a click elsewhere keeps what was typed, Enter is a new paragraph once kept, and Backspace at the very start joins the paragraph onto the one before it.

What is written is the difference between what the box was given and what it hands back: odox_core::edit::rewrite replaces only the middle that changed, into the node that held the old text, so spans and markers outside the change are untouched and what replaces a bold word is bold; a newline inside the change splits the paragraph. The renderer keeps a path as it walks and reports the paragraph a click landed on; the canvas tells the flow where a label's root sits under the page.

Two fixes found on the way: a text box in a measuring pass surrendered the focus of the real one (a sizing pass is an invisible, and so disabled, ui), and a proportional line height was resolved against the paragraph's size rather than each run's, which put a title in a thirteen-point line.

Checked: clippy with -D warnings, fmt, the catalogue check, the full test suite (the edit suite now covers the diff, the split on typed newlines, and apply and join by path), and on X11: a paragraph typed into and saved, a paragraph split with Enter, a paragraph joined into the heading before it with Backspace, and the corpus deck's title edited inside its span and saved as odox corpus deck edited.

🤖 Generated with Claude Code

In edit mode a click on a paragraph opens it as a text box in place, at
the paragraph's own font, size, colour, indent and width, on the page's
paper: in xodt for the flow, and in xodp for a shape's label, which is
the same paragraph through the same box. Escape puts the paragraph
back, Ctrl+Enter or a click elsewhere keeps what was typed, Enter is a
new paragraph once it is kept, and Backspace with the caret at the very
start joins the paragraph onto the one before it and reopens the box
there with the caret at the join.

What is written is the difference between what the box was given and
what it hands back. `odox_core::edit::rewrite` compares the two from
both ends and replaces only the middle, putting the new text into the
node that held the old before the old comes out, so a span or a marker
outside the change is untouched and what replaces a bold word is bold;
a newline inside the change splits the paragraph, each half with the
original's style. `apply` and `join_with_previous` do that by a path
under a root, which is how both views reach a paragraph again.

The renderer keeps a path of child indices as it walks, reports the
paragraph a click landed on, and draws the box in place of the
paragraph the path names. A slide's label is drawn from the shape and
edited from the page, so the canvas tells the flow where its root sits
and hands the box's state through. A frame anchored inside a paragraph
is reached by a clone, so nothing in it is edited in place. On a slide
in edit mode a drag moves the shape and does not select its text.

Two things found on the way. A measuring pass is an invisible ui, and
an invisible ui is disabled: a text box added in one surrendered the
focus the real one had just taken, so the box closed itself on the
next frame; a sizing pass now takes the box's height and no box. And a
proportional line height was resolved against the paragraph's size and
applied to every run, so a title whose size lives on its span sat in a
line thirteen points tall and its click target with it; each run now
takes its own.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@anderix anderix mentioned this pull request Sep 21, 2026
@anderix
anderix merged commit 7a980d5 into a-shape-is-moved-by-hand Sep 21, 2026
@anderix
anderix deleted the a-paragraph-is-edited-where-it-sits branch September 21, 2026 22:21
@anderix anderix mentioned this pull request Sep 21, 2026
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