Expand description
Changing the text of a paragraph, and what an edit may refuse.
A paragraph’s text is not one string in the tree. It is text nodes, inside
spans and links and marks, with text:s, text:tab and text:line-break
standing for the whitespace ODF will not write literally, and with elements
that contribute no characters at all — a bookmark, a frame, a note, a field
— sitting between them. An editor works on the flat string and this module
maps the edit back: characters are deleted from the nodes that hold them,
new text goes into the node at the insertion point, and every zero-length
element stays where it was. DESIGN.md §11.
The string the editor sees, text, is built from the tree and not from
the renderer’s layout, because the two differ: the renderer draws a tab as
four spaces and a footnote as its citation. Here a tab is a tab, and a
footnote contributes nothing and is kept.
Enums§
- Refused
- Why an edit was not made. Each is a state of the document rather than a failure, and the window says which.
Functions§
- apply
- Replace the paragraph at a path under a root with what the editor hands back, which may be several paragraphs. Answers how many now stand there.
- join
- Join a paragraph onto the end of another. The first keeps its style; the second’s contents, markers included, follow the first’s.
- join_
with_ previous - Join the paragraph at a path onto the paragraph before it among its parent’s children, and answer where the joined paragraph is.
- replace
- Replace a range of the paragraph’s text, in characters, with new text.
- rewrite
- What a paragraph becomes when its whole text is replaced by what an editor hands back: one paragraph, or several where the new text holds newlines the old one did not.
- split
- Split a paragraph at a character offset into the paragraph before it and the paragraph after, each with the original’s style and attributes.
- text
- The paragraph’s text as an editor sees it: every character the tree holds, in order, with ODF’s whitespace elements as the characters they stand for.