Skip to content

API reference / Common / Engine types / WordprocessingSelection

Type Alias: WordprocessingSelection ​

ts
type WordprocessingSelection = 
  | "none"
  | {
  sectionText: {
     section: SectionId;
     selection: TextSelection;
  };
}
  | {
  headerText: {
     section: SectionId;
     header: HeaderId;
     selection: TextSelection;
  };
}
  | {
  footerText: {
     section: SectionId;
     footer: FooterId;
     selection: TextSelection;
  };
}
  | {
  documentText: {
     anchor: WordprocessingTextEndpoint;
     focus: WordprocessingTextEndpoint;
  };
};

The selection of a wordprocessing document's editor — presence state beside the CRDT, never in it (see [Selection]).

Two flavors, as in the other doc types. The edit-mode variants are confined to one flow: a text selection's two ends share a story, so a gesture that stays in one is a caret or range in it, and one that leaves the anchor's section collapses to the anchor caret. The view-mode DocumentText flows across sections.

The three flow variants are the three flows a page paints, and each names the doc type's scope and nothing below it: the caret / range itself is the shared text sub-domain's [TextSelection], which names its own story. They are the selection twins of WordprocessingHit's, scope for scope — a pick and what it selects describe the same place. The docx analogue of the presentation editor's ShapeText.

A section is the body's scope rather than its story, because a section is more than its body: its w:sectPr governs the page geometry and the band references, and addressing it by its story would leave anything that is not about the text with no name to use.

A band's scope is the section and the part, because neither alone addresses it: a w:hdr is a part of its own that a section merely references, one section fills three slots, and one part is referenced by any number of sections. They are coordinates of one address, not a path and the level above it — which is why this is not the forbidden repeat. A band is laid out at its section's body width, so the same part under a portrait section and a landscape one puts the same offset's caret in two different places, and a caret naming only the part could not say which.