@docx-editor.dev/core 2.14.1 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +42 -0
  2. package/dist/automation.cjs +1 -1
  3. package/dist/automation.d.ts +6 -5
  4. package/dist/automation.js +1 -1
  5. package/dist/binding.cjs +1 -1
  6. package/dist/binding.d.ts +16 -10
  7. package/dist/binding.js +1 -1
  8. package/dist/chunk-24APKZAN.cjs +11 -0
  9. package/dist/chunk-2YH4MSHX.cjs +2 -0
  10. package/dist/chunk-5Y7AADI6.js +1 -0
  11. package/dist/chunk-AREFLNUP.js +11 -0
  12. package/dist/chunk-AS7YZNQE.cjs +2 -0
  13. package/dist/chunk-AVGCKH6A.cjs +20 -0
  14. package/dist/chunk-CDYVDQRI.cjs +5 -0
  15. package/dist/chunk-FGBADUSK.cjs +1 -0
  16. package/dist/chunk-HOEWFH5U.cjs +1 -0
  17. package/dist/chunk-KFELX7CN.js +2 -0
  18. package/dist/{chunk-OKEDGR65.js → chunk-KXPVOPR5.js} +1 -1
  19. package/dist/chunk-LGFKIF4M.cjs +1 -0
  20. package/dist/chunk-M52QXFKI.js +1 -0
  21. package/dist/chunk-MNUKSXRO.js +1 -0
  22. package/dist/chunk-PBOIGBDO.js +2 -0
  23. package/dist/chunk-PMHGONET.cjs +1 -0
  24. package/dist/chunk-PXKZUTHX.cjs +2 -0
  25. package/dist/chunk-Q4AB7E4O.cjs +1 -0
  26. package/dist/chunk-QJYH6AYD.js +1 -0
  27. package/dist/chunk-QRC37MWG.cjs +20 -0
  28. package/dist/chunk-RJSB6RJ7.js +20 -0
  29. package/dist/chunk-SB54HLFJ.js +20 -0
  30. package/dist/chunk-VP7SDFCM.js +1 -0
  31. package/dist/chunk-XCESLTJL.js +2 -0
  32. package/dist/{chunk-KIAP7PFQ.cjs → chunk-YL4Q5LZP.cjs} +1 -1
  33. package/dist/chunk-Z4527AXR.js +5 -0
  34. package/dist/collaboration/replication.cjs +1 -1
  35. package/dist/collaboration/replication.d.ts +4 -3
  36. package/dist/collaboration/replication.js +1 -1
  37. package/dist/collaboration.d.ts +4 -3
  38. package/dist/contracts/editor.d.ts +7 -7
  39. package/dist/contracts/interaction.d.ts +7 -7
  40. package/dist/contracts/modules.d.ts +8 -7
  41. package/dist/{custom-node-writes-DntmaAVW.d.ts → custom-node-writes-C9ArIlJh.d.ts} +2 -2
  42. package/dist/{editor-a6VvsfYU.d.ts → editor-sRxrFJd8.d.ts} +29 -21
  43. package/dist/editor.cjs +1 -1
  44. package/dist/editor.d.ts +27 -58
  45. package/dist/editor.js +1 -1
  46. package/dist/export.cjs +2 -0
  47. package/dist/export.d.ts +337 -0
  48. package/dist/export.js +2 -0
  49. package/dist/font-resolver-BYEHQGTw.d.ts +251 -0
  50. package/dist/headless-document-view-DELC4E5v.d.ts +134 -0
  51. package/dist/hf-references-DTrHkktY.d.ts +70 -0
  52. package/dist/{index-C5ZnSRkF.d.ts → index-C3Gvq4jN.d.ts} +55 -246
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.d.ts +18 -16
  55. package/dist/index.js +1 -1
  56. package/dist/{shaped-measurer-CFPnXFs9.d.cts → layout-shaping-DoGR5cf8.d.ts} +86 -12
  57. package/dist/layout.cjs +1 -1
  58. package/dist/layout.d.ts +1106 -729
  59. package/dist/layout.js +1 -1
  60. package/dist/{note-properties-CDFiNXcD.d.ts → note-properties-DSe8igrz.d.ts} +2 -2
  61. package/dist/{omml-equation-BY49UOIF.d.ts → omml-equation-BpRmfDAf.d.ts} +1 -1
  62. package/dist/output.cjs +1 -1
  63. package/dist/output.d.ts +6 -6
  64. package/dist/output.js +1 -1
  65. package/dist/{protocol-gOY5GA8K.d.cts → protocol-DZzKxH5r.d.ts} +18 -12
  66. package/dist/{review-items-CCS1h93f.d.ts → review-items-DYRx187i.d.ts} +2 -2
  67. package/dist/{review-reads-BjZYeMd4.d.ts → review-reads-LbGUdNzn.d.ts} +22 -25
  68. package/dist/{revision-projection-BeXVrSSV.d.ts → revision-projection-DHRJH48u.d.ts} +1 -1
  69. package/dist/{semantic-cell-selection-BK91NCCG.d.ts → semantic-cell-selection-BXVWCBYm.d.ts} +4 -4
  70. package/dist/{semantic-interaction-BmQ7h2cq.d.ts → semantic-interaction-DZsDmPg5.d.ts} +1 -1
  71. package/dist/{semantic-paint-WJD2KeG1.d.ts → semantic-paint-f7SqN4oW.d.ts} +2 -2
  72. package/dist/{semantic-records-BpozY7-j.d.cts → semantic-records-EIdwId-a.d.ts} +301 -205
  73. package/dist/store.cjs +1 -1
  74. package/dist/store.d.ts +15 -65
  75. package/dist/store.js +1 -1
  76. package/dist/{tree-op-types-D6HzlPR4.d.ts → tree-op-types-egdarvH_.d.ts} +7 -3
  77. package/dist/{tree-package-fragment-CWFjgH6a.d.ts → tree-package-fragment-DjkH4ESI.d.ts} +4 -70
  78. package/dist/{tree-session-contract-B2HfGt79.d.ts → tree-session-contract-CGOOgPjW.d.ts} +29 -23
  79. package/dist/{tree-store-APgWx6qn.d.ts → tree-store-DKJB0IcA.d.ts} +2 -2
  80. package/package.json +7 -2
  81. package/dist/automation.d.cts +0 -82
  82. package/dist/binding.d.cts +0 -153
  83. package/dist/chunk-2PIHW2QM.cjs +0 -1
  84. package/dist/chunk-2QTY5S6T.js +0 -1
  85. package/dist/chunk-4Z5MODAE.cjs +0 -2
  86. package/dist/chunk-5TKAPFZT.cjs +0 -2
  87. package/dist/chunk-DRQHIQ4R.cjs +0 -1
  88. package/dist/chunk-F2K6SDHA.cjs +0 -20
  89. package/dist/chunk-FBA57EUJ.js +0 -2
  90. package/dist/chunk-KTAQ7BRQ.js +0 -20
  91. package/dist/chunk-LBAHXZCU.cjs +0 -5
  92. package/dist/chunk-MCDUQYWP.js +0 -5
  93. package/dist/chunk-MQP26KCF.js +0 -1
  94. package/dist/chunk-NDJGSR6M.cjs +0 -19
  95. package/dist/chunk-NJNFJPGB.cjs +0 -11
  96. package/dist/chunk-O5M4CR4P.cjs +0 -2
  97. package/dist/chunk-UKUOZXUD.js +0 -19
  98. package/dist/chunk-VQ4R5LTU.js +0 -2
  99. package/dist/chunk-ZBEJHJN2.js +0 -11
  100. package/dist/chunk-ZVTW7RGD.js +0 -2
  101. package/dist/collaboration/replication.d.cts +0 -216
  102. package/dist/collaboration.d.cts +0 -176
  103. package/dist/contracts/document.d.cts +0 -273
  104. package/dist/contracts/editor.d.cts +0 -10
  105. package/dist/contracts/interaction.d.cts +0 -10
  106. package/dist/contracts/modules.d.cts +0 -130
  107. package/dist/contracts/types.d.cts +0 -562
  108. package/dist/custom-node-writes-C46r3_5O.d.cts +0 -310
  109. package/dist/document-properties-D6Ahr8D6.d.cts +0 -28
  110. package/dist/document-properties-D6Ahr8D6.d.ts +0 -28
  111. package/dist/editor-AJ06hyyg.d.cts +0 -1994
  112. package/dist/editor.d.cts +0 -393
  113. package/dist/failure-BnGjoXf0.d.cts +0 -64
  114. package/dist/index-Cbw4lkOt.d.cts +0 -3391
  115. package/dist/index.d.cts +0 -23
  116. package/dist/layout.d.cts +0 -2486
  117. package/dist/note-properties-Y6qYh2Hv.d.cts +0 -67
  118. package/dist/omml-equation-DB8d-jCq.d.cts +0 -84
  119. package/dist/output.d.cts +0 -74
  120. package/dist/protocol-BsmQgblT.d.ts +0 -1358
  121. package/dist/review-items-CaAkgi5s.d.cts +0 -360
  122. package/dist/review-reads-DEsV0OOW.d.cts +0 -163
  123. package/dist/revision-projection-DXbrfNGD.d.cts +0 -156
  124. package/dist/semantic-cell-selection-BMhku3B1.d.cts +0 -451
  125. package/dist/semantic-interaction-DUAnxbgf.d.cts +0 -160
  126. package/dist/semantic-paint-DufNL1Zr.d.cts +0 -247
  127. package/dist/semantic-records-92UnKeU_.d.ts +0 -2821
  128. package/dist/shaped-measurer-BWbindlI.d.ts +0 -168
  129. package/dist/store.d.cts +0 -2500
  130. package/dist/tree-op-types-BUulYD5y.d.cts +0 -3099
  131. package/dist/tree-package-fragment-Dhyw7oPm.d.cts +0 -732
  132. package/dist/tree-session-contract-BY9xd7s_.d.cts +0 -613
  133. package/dist/tree-store-DEEQ9wz_.d.cts +0 -416
@@ -1,156 +0,0 @@
1
- import { a as OoxmlNode } from './tree-op-types-BUulYD5y.cjs';
2
-
3
- /**
4
- * What a revision wrapper asserts about the content inside it.
5
- *
6
- * `moveFrom` / `moveTo` are deliberately distinct from `delete` / `insert`: a move is one
7
- * decision with two halves, and presenting it as an unrelated deletion and insertion invites
8
- * resolving one without the other, which duplicates or loses the content.
9
- */
10
- type RevisionKind = 'insert' | 'delete' | 'moveFrom' | 'moveTo' | 'format';
11
- /**
12
- * One revision wrapper's provenance, as authored.
13
- *
14
- * `id` is the verbatim `@w:id` string rather than a number: `ST_DecimalNumber` restricts
15
- * `xsd:integer` with no bounds, so a file may carry a value outside the safe integer range, and
16
- * parsing it to a number would silently merge two distinct revisions.
17
- *
18
- * `date` is absent when the file omits it. `@w:date` is optional on `CT_TrackChange`, and
19
- * inventing one is a silent content change.
20
- */
21
- interface RevisionAttribution {
22
- readonly kind: RevisionKind;
23
- readonly id: string;
24
- readonly author: string;
25
- readonly date?: string;
26
- /** The wrapper's node id, so a surface can address this exact site. */
27
- readonly nodeId: string;
28
- }
29
- /**
30
- * Which revisions layout resolves before producing pages.
31
- *
32
- * - `all-markup` shows both halves of every change.
33
- * - `proposed` shows what the document becomes if every change is accepted.
34
- * - `original` shows what it was before any of them.
35
- *
36
- * The last two are specified as equal to accept-all and reject-all OUTPUT, which is what makes
37
- * them testable, without either applying an op.
38
- */
39
- type RevisionDisplayMode = 'all-markup' | 'proposed' | 'original';
40
- /**
41
- * How a document renders tracked changes when nothing says otherwise.
42
- *
43
- * `all-markup` matches Word's own default: a reader who opens a document with pending changes
44
- * sees them, rather than a clean-looking document hiding edits nobody has accepted.
45
- */
46
- declare const DEFAULT_REVISION_DISPLAY_MODE: RevisionDisplayMode;
47
- /**
48
- * A view-time tracked-change filter. Revisions rejected by `includes` use the filter's accepted
49
- * or rejected projection, while included revisions keep the display mode's normal projection.
50
- *
51
- * `cacheKey` is a canonical, content-based identity for layout caches. The set itself is kept
52
- * because author names are attacker-controlled strings and must never be parsed back from a
53
- * delimiter-based key.
54
- */
55
- interface RevisionFilter {
56
- readonly hiddenAuthors: ReadonlySet<string>;
57
- readonly includes?: (revision: RevisionAttribution) => boolean;
58
- readonly includesNode?: (nodeId: string, author: string) => boolean;
59
- /** Accepted/original projection for a revision excluded by `includesNode`. */
60
- readonly excludedNodeMode?: (nodeId: string, author: string) => 'proposed' | 'original';
61
- readonly cacheKey: string;
62
- }
63
- /** @deprecated Use {@link RevisionFilter}. */
64
- interface RevisionAuthorFilter extends RevisionFilter {
65
- }
66
- /** Build a canonical reviewer filter. An empty input returns `undefined` for the fast path. */
67
- declare function revisionAuthorFilter(hiddenAuthors: Iterable<string>): RevisionAuthorFilter | undefined;
68
- /**
69
- * Whether content under this stack of revisions is laid out in the given mode.
70
- *
71
- * Containment governs, so a single enclosing wrapper the mode resolves away suppresses
72
- * everything inside it regardless of what the inner wrappers say. An insertion inside a
73
- * deletion does not survive the proposed result: the deletion it sits in was accepted.
74
- */
75
- declare function revisionsVisible(revisions: readonly RevisionAttribution[], mode: RevisionDisplayMode, authorFilter?: RevisionAuthorFilter): boolean;
76
- /**
77
- * Every revision on a paragraph's own MARK, from `w:pPr/w:rPr/w:ins|w:del|w:moveFrom|w:moveTo`.
78
- *
79
- * All four members of `EG_ParaRPrTrackChanges`. A moved paragraph carries `w:moveFrom` on the
80
- * mark of the copy it left and `w:moveTo` on the mark of the copy it arrived at, so a move
81
- * that spans whole paragraphs is recorded here and nowhere else.
82
- *
83
- * `EG_ParaRPrTrackChanges` records that the pilcrow itself was inserted or deleted, which is how
84
- * Word writes a paragraph split or merge. It is not content — there is no text to decorate — so
85
- * a surface shows it as a mark of its own beside the paragraph, the way Word draws a struck-
86
- * through ¶.
87
- *
88
- * A LIST, because the group is `ins? del? moveFrom? moveTo?` and the first two can both be
89
- * there: that pair is what Word writes when a second author proposes removing a mark the first
90
- * proposed adding, and it is what this engine's own writer emits (`tree-op-tracked.ts`).
91
- * Answering with the first one hid the second author's decision from the PAGE. The review pane
92
- * walks the tree itself and always listed both, which is the worse shape of the two: a card
93
- * offering a decision the reader could see no sign of.
94
- *
95
- * Ordered as the file orders them, which is the order the group declares.
96
- *
97
- * Property-position `w:ins`/`w:del` stay `generic` in the tree deliberately, so this reads them
98
- * by name rather than by kind.
99
- */
100
- declare function paragraphMarkRevisionsOf(paragraph: OoxmlNode): readonly RevisionAttribution[];
101
- /**
102
- * The tracked FORMAT change on a paragraph's own mark, from `w:pPr/w:rPr/w:rPrChange`.
103
- *
104
- * `CT_ParaRPr` ends with it (§17.13.5.32), and Word writes it when a user changes the mark's
105
- * own run properties with tracking on. It reaches the fragment rather than a span because it
106
- * decorates no characters, and it is not in `props`: a fragment's `props` carry the mark's
107
- * `w:rPr` by NAME only, with none of its children.
108
- *
109
- * Note that `w:rPrChange/w:rPr` is `CT_ParaRPrOriginal`, which may carry its own revision
110
- * marks. Those describe the mark as it WAS and must not be read as live ones, which is why
111
- * this reads the change element's own attributes and never descends into it.
112
- */
113
- declare function paragraphMarkFormatRevisionOf(paragraph: OoxmlNode): RevisionAttribution | null;
114
- /**
115
- * The single decision a one-field reader sees.
116
- *
117
- * A DELETION wins when a mark carries both, for the reason paint draws it that way: a break
118
- * proposed and then unproposed ends up removed, so that is the decision a reader who can only
119
- * see one must see. One function decides it, so the deprecated field, the deprecated function
120
- * and the painted glyph cannot answer differently.
121
- */
122
- declare function shownMarkRevision(revisions: readonly RevisionAttribution[]): RevisionAttribution | undefined;
123
- /**
124
- * Does this decision, taken, remove the paragraph mark?
125
- *
126
- * A deletion does, and so does a `moveFrom`: the copy the paragraph moved OUT of goes away
127
- * when the move is accepted. `insert` and `moveTo` are the other half of each pair, and they
128
- * keep the break. Paint, the change bar and the resolved views all ask this one question, so
129
- * a `moveFrom` cannot end up struck through in the margin and blue on the glyph.
130
- */
131
- declare function markRevisionRemovesMark(revision: RevisionAttribution): boolean;
132
- /**
133
- * The one decision on a paragraph's mark that a single-field reader sees.
134
- *
135
- * @deprecated Reads one of the revisions a mark can carry. Use {@link paragraphMarkRevisionsOf},
136
- * which answers with all of them.
137
- */
138
- declare function paragraphMarkRevisionOf(paragraph: OoxmlNode): RevisionAttribution | null;
139
- /**
140
- * The tracked FORMAT change on a property list, from `w:rPrChange` or `w:pPrChange`.
141
- *
142
- * A property change alters no characters, so it has no span of its own to strike or underline.
143
- * Word marks the affected text and says what changed; the minimum a reader needs is to see that
144
- * this text's formatting is itself a pending decision.
145
- *
146
- * Read from the flattened property list because that is what layout already carries — the
147
- * change wrapper is a `w:rPr`/`w:pPr` child like any other.
148
- */
149
- declare function formatRevisionOf(properties: readonly {
150
- readonly localName: string;
151
- readonly attributes?: Readonly<Record<string, string>>;
152
- }[]): RevisionAttribution | null;
153
- /** True when this stack of revisions marks its content as deleted from the live document. */
154
- declare function revisionsAreDeletion(revisions: readonly RevisionAttribution[]): boolean;
155
-
156
- export { DEFAULT_REVISION_DISPLAY_MODE as D, type RevisionDisplayMode as R, type RevisionAuthorFilter as a, type RevisionAttribution as b, type RevisionFilter as c, type RevisionKind as d, paragraphMarkRevisionOf as e, formatRevisionOf as f, paragraphMarkRevisionsOf as g, revisionsAreDeletion as h, revisionsVisible as i, markRevisionRemovesMark as m, paragraphMarkFormatRevisionOf as p, revisionAuthorFilter as r, shownMarkRevision as s };
@@ -1,451 +0,0 @@
1
- import { O as OoxmlPart, g as OoxmlElement, a as OoxmlNode } from './tree-op-types-BUulYD5y.cjs';
2
- import { P as PageGeometry, I as InlineDrawingRecord, A as AnchoredDrawingRecord, T as TextMeasurer, L as LineRecord, a as StyleSpanRecord, S as SemanticLayout, C as ContentControlBoundaryRecord, e as TableRowFragmentRecord, f as TableCellFragmentRecord } from './semantic-records-BpozY7-j.cjs';
3
- import { R as RevisionDisplayMode, a as RevisionAuthorFilter } from './revision-projection-DXbrfNGD.cjs';
4
- import { S as SemanticPosition, C as CaretGeometry, a as SemanticSelection } from './semantic-interaction-DUAnxbgf.cjs';
5
-
6
- /**
7
- * Hard ceiling on sections enumerated from a document (matches write-path
8
- * `MAX_SECTIONS` in note/hf lifecycle). Hostile packages with unbounded `w:sectPr`
9
- * marks fail closed here rather than amplifying layout props arrays.
10
- */
11
- declare const MAX_DOCUMENT_SECTIONS = 4096;
12
- /** A section's margins in twips, including the header and footer reserve bands. */
13
- interface SectionMargins {
14
- readonly topTwips: number;
15
- readonly rightTwips: number;
16
- readonly bottomTwips: number;
17
- readonly leftTwips: number;
18
- readonly headerTwips: number;
19
- readonly footerTwips: number;
20
- readonly gutterTwips: number;
21
- }
22
- /** One explicit `w:col`: its width and the gap after it. */
23
- interface SectionColumnDefinition {
24
- readonly widthTwips: number;
25
- /** Space after this column; zero on the final column. */
26
- readonly gapTwips: number;
27
- }
28
- /**
29
- * A section's column layout.
30
- *
31
- * Equal-width and explicit-width columns are one type because a file may declare `w:num` with no
32
- * `w:col` children at all, and layout must handle both without branching at every use site.
33
- */
34
- interface SectionColumns {
35
- readonly count: number;
36
- /** Shared gap for equal-width columns and fallback gap for incomplete explicit definitions. */
37
- readonly gapTwips: number;
38
- readonly equalWidth?: boolean;
39
- readonly separator?: boolean;
40
- /** Authored `w:col` geometry when `equalWidth` is false. */
41
- readonly definitions?: readonly SectionColumnDefinition[];
42
- }
43
- /**
44
- * How this section is placed relative to the previous one (ECMA-376 17.6.22,
45
- * `ST_SectionMark`).
46
- *
47
- * All five schema values are read. `nextColumn` paginates like `nextPage` for now: in a
48
- * single-column section that IS Word's behaviour, and multi-column flow is not modelled,
49
- * so collapsing it at the parse boundary would only hide the authored value from a
50
- * consumer that asks.
51
- */
52
- type SectionBreakType = 'nextPage' | 'continuous' | 'evenPage' | 'oddPage' | 'nextColumn';
53
- /**
54
- * Authored `w:pgNumType` (ECMA-376 CT_PageNumber).
55
- *
56
- * Distinguishes three states via {@link SectionProperties.pageNumbering}:
57
- * - element absent → `undefined` (Word defaults; no empty element to re-emit)
58
- * - empty `<w:pgNumType/>` → `{}` (present, no authored attrs; must round-trip empty)
59
- * - attributes set → only those keys appear (never invent schema defaults like `fmt=decimal`)
60
- *
61
- * `chapStyle` / `chapSep` are preserved for consumers; PAGE projection does not yet compose
62
- * chapter numbers (heading outline resolution is out of this slice).
63
- */
64
- interface SectionPageNumbering {
65
- /** Authored `@w:start` when present and in range; otherwise omitted. */
66
- readonly start?: number;
67
- /** Authored `@w:fmt` (ST_NumberFormat) when present; otherwise omitted. */
68
- readonly fmt?: string;
69
- /** Authored `@w:chapStyle` outline level when present and in range. */
70
- readonly chapStyle?: number;
71
- /** Authored `@w:chapSep` when present (hyphen / period / colon / emDash / enDash). */
72
- readonly chapSep?: string;
73
- }
74
- /**
75
- * One section's resolved `w:sectPr`, as layout needs it.
76
- *
77
- * Resolved, not raw: defaults the file omitted are filled in here (an absent `w:type` is
78
- * `nextPage`), so layout never has to know which attributes were authored and which were
79
- * inherited.
80
- */
81
- interface SectionProperties {
82
- readonly pageSize: {
83
- readonly widthTwips: number;
84
- readonly heightTwips: number;
85
- };
86
- readonly margins: SectionMargins;
87
- readonly columns: SectionColumns;
88
- readonly landscape: boolean;
89
- readonly titlePage: boolean;
90
- /** Absent `w:type` defaults to `nextPage`. */
91
- readonly breakType: SectionBreakType;
92
- /**
93
- * Authored page-number type. Absent when `w:pgNumType` is missing; empty object when the
94
- * element is present with no attributes (comprehensive-fixture shape).
95
- */
96
- readonly pageNumbering?: SectionPageNumbering;
97
- }
98
- /**
99
- * One section of the body story: contiguous top-level blocks plus the properties that end it.
100
- *
101
- * `blockStart` / `blockEndExclusive` index into `storyBlocks(part)`.
102
- */
103
- interface DocumentSection {
104
- readonly index: number;
105
- readonly properties: SectionProperties;
106
- readonly blockStart: number;
107
- readonly blockEndExclusive: number;
108
- }
109
- /** US Letter, portrait, one-inch margins: Word's own default when a section says nothing. */
110
- declare const DEFAULT_SECTION_PROPERTIES: SectionProperties;
111
- /**
112
- * Parse authored `w:pgNumType` without inventing schema defaults.
113
- *
114
- * Returns `undefined` when the element is absent. An empty element yields `{}` so callers
115
- * can tell "present but unauthored" from "missing" and serialization can re-emit empty.
116
- * Hostile / out-of-range attribute values are dropped rather than clamped into meaning.
117
- */
118
- declare function parsePageNumbering(sectPr: OoxmlNode): SectionPageNumbering | undefined;
119
- /** Parse one `w:sectPr` into geometry/break properties (null reads as Word's defaults). */
120
- declare function parseSectionProperties(sectPr: OoxmlNode | null | undefined): SectionProperties;
121
- /** `w:sectPr` nested under a paragraph's `w:pPr`, if present. */
122
- declare function paragraphSectionNode(paragraph: OoxmlElement): OoxmlElement | undefined;
123
- /**
124
- * The section properties a part declares, or Word's defaults where it says nothing.
125
- *
126
- * Returns the FINAL section (body-level `w:sectPr`, else the last paragraph-level one).
127
- * Multi-section geometry belongs to `enumerateDocumentSections`; chrome that needs "the
128
- * document's page" still reads the last section, which is what Word's body-level sectPr is.
129
- */
130
- declare function readSectionProperties(part: OoxmlPart): SectionProperties;
131
- /**
132
- * Split the body story into sections.
133
- *
134
- * A paragraph carrying `w:pPr/w:sectPr` ends the current section (that paragraph is IN the
135
- * section being ended). The body-level `w:sectPr` ends the final section. A document with
136
- * neither yields one section of Word defaults covering every block.
137
- *
138
- * Enumeration is capped at {@link MAX_DOCUMENT_SECTIONS}. Further paragraph-level section
139
- * breaks are ignored and remaining blocks fold into the last accepted section (fail closed).
140
- *
141
- * `displayMode` MUST match the one the caller passes to `storyBlocks`. `blockStart` /
142
- * `blockEndExclusive` are indices into that list, and the list changes shape with the mode:
143
- * the proposed view drops a paragraph whose mark and content a revision both removed. Slicing
144
- * a filtered list with indices counted over an unfiltered one puts body text under another
145
- * section's page geometry — the wrong paper size, the wrong margins, the wrong header.
146
- */
147
- declare function enumerateDocumentSections(part: OoxmlPart, displayMode?: RevisionDisplayMode, authorFilter?: RevisionAuthorFilter): DocumentSection[];
148
- /**
149
- * Canonical section index behind each section in a revision-projected body.
150
- *
151
- * A removed paragraph mark can collapse an entire section. The projected section keeps the
152
- * surviving paragraph's geometry, while package APIs such as header/footer resolution remain
153
- * indexed over the canonical tree. This bridge prevents those two index spaces from being
154
- * paired positionally.
155
- */
156
- declare function projectedSectionSourceIndexes(part: OoxmlPart, displayMode?: RevisionDisplayMode, authorFilter?: RevisionAuthorFilter): readonly number[];
157
- /**
158
- * Every section in a document, with a flag saying whether the list was cut short.
159
- *
160
- * `truncated` is reported rather than silent: section count comes from a file, so a crafted
161
- * document declaring thousands of paragraph-level `w:sectPr` marks is bounded, and a reader
162
- * should be able to tell that happened.
163
- */
164
- interface DocumentSectionsEnumeration {
165
- readonly sections: DocumentSection[];
166
- /** True when paragraph-level sectPr marks beyond {@link MAX_DOCUMENT_SECTIONS} were dropped. */
167
- readonly truncated: boolean;
168
- }
169
- /**
170
- * Like {@link enumerateDocumentSections}, but reports whether the section bound clipped
171
- * hostile input. Prefer the plain enumerator for normal layout; use this when a caller
172
- * needs a named fail-closed diagnostic.
173
- */
174
- declare function enumerateDocumentSectionsBounded(part: OoxmlPart, displayMode?: RevisionDisplayMode, authorFilter?: RevisionAuthorFilter): DocumentSectionsEnumeration;
175
- /**
176
- * Section properties as the geometry layout paginates against.
177
- *
178
- * The gutter is added to the LEFT margin: it is binding allowance, extra space on the inner
179
- * edge, and folding it into the content width instead would silently narrow every line.
180
- */
181
- declare function geometryOfSection(section: SectionProperties): PageGeometry;
182
-
183
- /** A point in the coordinate space named by the function taking it. */
184
- interface HitPoint {
185
- readonly x: number;
186
- readonly y: number;
187
- }
188
- /** The innermost table cell a point resolved through. */
189
- interface TableCellAddress {
190
- /** Canonical node id of the `w:tbl`. */
191
- readonly tableId: string;
192
- /** Canonical node id of the `w:tr`. */
193
- readonly rowId: string;
194
- /** Canonical node id of the `w:tc`. */
195
- readonly cellId: string;
196
- /** Ordinal in the WHOLE table, stable across fragments and header repeats. */
197
- readonly rowIndex: number;
198
- readonly gridColumn: number;
199
- readonly gridSpan: number;
200
- }
201
- /** Stable inline drawing identity when a hit resolves to a drawing atom. */
202
- interface SemanticHitDrawing {
203
- readonly drawingNodeId: string;
204
- readonly paragraphId: string;
205
- readonly start: number;
206
- }
207
- /** What a point landed on: a semantic position, its caret geometry, and where it sits. */
208
- interface SemanticHit {
209
- readonly position: SemanticPosition;
210
- readonly caret: CaretGeometry;
211
- readonly pageIndex: number;
212
- readonly lineId: string;
213
- /** Null outside a table; the innermost cell when tables nest. */
214
- readonly cell: TableCellAddress | null;
215
- /**
216
- * True when the point was inside the resolved line's box AND inside one of its spans.
217
- *
218
- * A caller distinguishing a click ON text from a click BESIDE it — to decide whether to
219
- * claim the gesture at all — needs this, and cannot recover it from the position.
220
- */
221
- readonly onGlyphs: boolean;
222
- /**
223
- * Innermost content-control boundary covering the hit point, or null outside every control.
224
- *
225
- * Resolved from layout-published boundary geometry (not DOM). Nested controls prefer the
226
- * deepest {@link ContentControlBoundaryRecord.nestingDepth}.
227
- */
228
- readonly contentControlId: string | null;
229
- /** Non-null when the hit resolved to an inline drawing atom. */
230
- readonly drawing: SemanticHitDrawing | null;
231
- }
232
- /**
233
- * How precisely a hit resolves within a run.
234
- *
235
- * Without a measurer the offset is INTERPOLATED across the span's advance, which is exact only
236
- * for monospaced text — supply one for proportional fonts, or a click lands a character or two
237
- * away from the glyph under the pointer.
238
- */
239
- interface HitTestOptions {
240
- /**
241
- * Exact resolution of the character within a run.
242
- *
243
- * Absent, the offset is interpolated across the span's own advance, which is exact only for
244
- * a uniform advance. Pass the measurer layout was produced with, or the answer can disagree
245
- * with what was painted.
246
- */
247
- readonly measurer?: TextMeasurer;
248
- /** Vertical weight for the nearest-block rule. */
249
- readonly verticalWeight?: number;
250
- }
251
- /**
252
- * How much more a point of vertical distance counts than a point of horizontal distance.
253
- *
254
- * Without it, clicking far out in the right margin beside a two-word line picks whichever
255
- * block happens to be directly below, because that block is horizontally nearer. Weighting
256
- * the vertical axis makes "the line I am level with" win, which is what the pointer meant.
257
- */
258
- declare const DEFAULT_VERTICAL_WEIGHT = 8;
259
- /**
260
- * The page a sheet-space y belongs to.
261
- *
262
- * The gutter between page *i* and page *i+1* resolves to page *i*, because the nearest text
263
- * to a point in that gap is the last line of the page above it. That falls out of searching
264
- * for the last page whose top is at or above the point, with no special case: the gutter is
265
- * inside `[top(i), top(i+1))` by construction. A point above the first page clamps to it, and
266
- * a point past the last page clamps to that.
267
- */
268
- declare function pageAtY(layout: SemanticLayout, sheetY: number): number;
269
- /** True when a sheet-space point falls inside a page's header or footer box. */
270
- declare function isFurniturePoint(layout: SemanticLayout, point: HitPoint): boolean;
271
- /** Hit test a point given in PAGE-CONTENT coordinates, the space the fragment boxes use. */
272
- declare function hitTestPage(layout: SemanticLayout, pageIndex: number, point: HitPoint, options?: HitTestOptions): SemanticHit | null;
273
- /**
274
- * Hit test a point given in SHEET coordinates — the space `page.box` lives in, and the space
275
- * a surface's own pixel offsets convert into.
276
- */
277
- declare function hitTestSheet(layout: SemanticLayout, point: HitPoint, options?: HitTestOptions): SemanticHit | null;
278
- /**
279
- * Innermost content control whose published boundary geometry contains `point` on `pageIndex`.
280
- *
281
- * Nested controls that share the same content box resolve to the deepest nesting depth.
282
- */
283
- declare function contentControlAtPoint(layout: SemanticLayout, pageIndex: number, point: HitPoint): ContentControlBoundaryRecord | null;
284
- /**
285
- * The end position of a line, as Word places it.
286
- *
287
- * On a SOFT-WRAPPED line the space that caused the break is painted at the end of the line
288
- * but the caret belongs before it — otherwise clicking in the right margin puts the caret
289
- * visually at the start of the NEXT line, which reads as the click having missed. The last
290
- * line of a paragraph has no such space to discount.
291
- *
292
- * A HARD BREAK is the same story with a character that is always there: the position after
293
- * it belongs to the line the break opened (`caretAt` places it there), so a click in the
294
- * right margin of the line the break ENDED has to stop in front of it or the caret appears
295
- * a row below the click.
296
- *
297
- * A PAGE break is discounted even on the paragraph's LAST line, which is the one case the
298
- * last-line shortcut got wrong. The position after such a break is on the next page — and
299
- * when the remainder is empty it has no line anywhere, because Word Online starts the
300
- * following block flush at the top of that page. So the caret for it stays behind on the
301
- * line the break ended, and a click in the wide blank space beside the mark resolved to a
302
- * position a page away from where it landed: the caret appeared under the pointer and the
303
- * typing came out on the next page. `<w:p><w:r><w:br w:type="page"/></w:r></w:p>` is the
304
- * commonest way to end a page, so that blank space is most of a page wide.
305
- */
306
- declare function lineEndOffset(layout: SemanticLayout, line: LineRecord): number;
307
- /**
308
- * The x of a model offset inside a span — the inverse of {@link offsetWithinSpan}.
309
- *
310
- * Shares the measurement, and the cache, with the hit test. Interpolating across the span's
311
- * advance instead is exact only for a uniform one: in a proportional face the caret for
312
- * offset 4 of an 8-character span is drawn at half its width, which lands in the middle of a
313
- * glyph rather than between two.
314
- */
315
- declare function spanOffsetX(span: StyleSpanRecord, offset: number, measurer: TextMeasurer | undefined): number;
316
- /**
317
- * Where a caret sits on a line: its x, and the box it should be drawn at.
318
- *
319
- * The height comes from the RUN at the insertion point, not from the line. A line is as tall
320
- * as its largest run, so a caret in 11pt text on a line that also carries 36pt text was drawn
321
- * three times the height of the text it sits in. Word sizes the insertion point to the run it
322
- * would type into, which is also how the painter already draws the selection band: every run
323
- * is its own inline box, and the band steps with the text.
324
- *
325
- * Affinity at a shared model boundary:
326
- * - after a layout-sized atom (tab / projected field), prefer the DOWNSTREAM span so the
327
- * caret sits at the aligned destination (e.g. before CONFIDENTIAL after a right tab),
328
- * matching hit-testing and caretStops;
329
- * - otherwise the run BEFORE the offset wins — the run a keystroke would continue —
330
- * except at the start of the line, where there is nothing before it.
331
- */
332
- declare function caretBoxOnLine(line: LineRecord, offset: number, measurer: TextMeasurer | undefined, segment?: {
333
- readonly spans: readonly StyleSpanRecord[];
334
- readonly drawings: readonly InlineDrawingRecord[];
335
- } | null): {
336
- x: number;
337
- y: number;
338
- height: number;
339
- };
340
- /** Page-content overlay rectangle for a drawing's painted extent. */
341
- interface DrawingOverlayFrame {
342
- readonly pageIndex: number;
343
- /** Relative to {@link PageRecord.contentBox}. */
344
- readonly x: number;
345
- readonly y: number;
346
- readonly width: number;
347
- readonly height: number;
348
- readonly record: InlineDrawingRecord | AnchoredDrawingRecord;
349
- }
350
- /**
351
- * Locate a drawing's painted extent on the published layout.
352
- *
353
- * Coordinates are page-content relative — the same space {@link hitTestPage} uses — so an
354
- * overlay can position from records without reading painted DOM geometry.
355
- */
356
- declare function findDrawingOverlayFrameInLayout(layout: SemanticLayout, drawingNodeId: string): DrawingOverlayFrame | null;
357
-
358
- /** A rectangle of table cells. */
359
- interface CellSelection {
360
- readonly kind: 'cells';
361
- /** Canonical node id of the `w:tbl`. */
362
- readonly tableId: string;
363
- /** Every selected `w:tc`, in document order, with merges resolved. */
364
- readonly cellIds: readonly string[];
365
- /** Inclusive row ordinals within the table. */
366
- readonly rows: {
367
- readonly from: number;
368
- readonly to: number;
369
- };
370
- /** Inclusive grid columns. */
371
- readonly columns: {
372
- readonly from: number;
373
- readonly to: number;
374
- };
375
- /**
376
- * The equivalent text range.
377
- *
378
- * Every existing reader of a selection — deletion, the clipboard, the DOM mirror, viewport
379
- * pinning — takes this and needs no knowledge that a rectangle produced it.
380
- */
381
- readonly text: SemanticSelection;
382
- }
383
- /** One painted occurrence of a cell, and where it sits. */
384
- interface PlacedCell {
385
- readonly pageIndex: number;
386
- readonly tableId: string;
387
- readonly row: TableRowFragmentRecord;
388
- readonly cell: TableCellFragmentRecord;
389
- /** Ordinal within the whole table, shared by a header row and every repeat of it. */
390
- readonly rowIndex: number;
391
- readonly isHeaderRepeat: boolean;
392
- /**
393
- * What to add to the cell's box to reach the page's content-box space.
394
- *
395
- * Zero for the body, whose fragments are already laid out from that box. A header's are laid
396
- * out from the header's own box, which sits ABOVE it, and a footer's from a box past the
397
- * bottom of it. `cellSelectionRects` promises page-content coordinates and the overlay
398
- * painter places what it returns against `page.contentBox`, so a story's raw box painted a
399
- * header's selection band down in the body text.
400
- */
401
- readonly offsetX: number;
402
- /** The vertical half of the same offset. See {@link PlacedCell.offsetX}. */
403
- readonly offsetY: number;
404
- }
405
- /**
406
- * The rectangle two cells define.
407
- *
408
- * Grown to a fixpoint rather than taken literally: a cell that spans two columns cannot be
409
- * half selected, and a vertically merged run cannot be selected in the middle. Word grows the
410
- * rectangle until every cell it touches is wholly inside it, so dragging into a merged cell
411
- * pulls the selection out to that cell's full extent.
412
- */
413
- declare function cellSelectionBetween(layout: SemanticLayout, anchor: TableCellAddress, head: TableCellAddress): CellSelection | null;
414
- /** Paragraph ids inside a set of cells, in document order, each once. */
415
- declare function paragraphsInCells(layout: SemanticLayout, cellIds: readonly string[]): readonly string[];
416
- /** The style spans a cell selection covers, for reporting active formatting. */
417
- declare function spansInCells(layout: SemanticLayout, cellIds: readonly string[]): readonly StyleSpanRecord[];
418
- /** One rectangle per painted occurrence of a selected cell, in page-content coordinates. */
419
- declare function cellSelectionRects(layout: SemanticLayout, cellIds: readonly string[]): readonly {
420
- pageIndex: number;
421
- x: number;
422
- y: number;
423
- width: number;
424
- height: number;
425
- }[];
426
- /**
427
- * A cell selection as plain text: tabs between cells, newlines between rows.
428
- *
429
- * What a spreadsheet and every other word processor put on the clipboard for a rectangle, and
430
- * the only shape that survives the trip: the text range a rectangle stands in for would paste
431
- * back as one run of characters with the grid gone.
432
- */
433
- declare function cellSelectionText(layout: SemanticLayout, selection: CellSelection): string;
434
- /** Where a paragraph sits in a table, if it sits in one. */
435
- interface TableCellContext {
436
- readonly tableId: string;
437
- readonly rows: number;
438
- readonly columns: number;
439
- readonly rowIndex: number;
440
- readonly columnIndex: number;
441
- }
442
- /**
443
- * The table context of one paragraph — what a toolbar reflects when the caret is in a cell.
444
- *
445
- * Answers for a plain caret, not only for a cell selection, because "am I in a table" is a
446
- * question about where the caret is and a toolbar that only knew during a rectangle drag
447
- * would show its table controls disabled while the user was typing in a cell.
448
- */
449
- declare function tableContextAt(layout: SemanticLayout, paragraphId: string): TableCellContext | null;
450
-
451
- export { pageAtY as A, paragraphSectionNode as B, type CellSelection as C, DEFAULT_SECTION_PROPERTIES as D, paragraphsInCells as E, parsePageNumbering as F, parseSectionProperties as G, type HitPoint as H, projectedSectionSourceIndexes as I, readSectionProperties as J, spanOffsetX as K, spansInCells as L, MAX_DOCUMENT_SECTIONS as M, tableContextAt as N, type PlacedCell as P, type SectionProperties as S, type TableCellAddress as T, type SectionColumns as a, DEFAULT_VERTICAL_WEIGHT as b, type DocumentSection as c, type DocumentSectionsEnumeration as d, type DrawingOverlayFrame as e, type HitTestOptions as f, type SectionBreakType as g, type SectionColumnDefinition as h, type SectionMargins as i, type SectionPageNumbering as j, type SemanticHit as k, type SemanticHitDrawing as l, type TableCellContext as m, caretBoxOnLine as n, cellSelectionBetween as o, cellSelectionRects as p, cellSelectionText as q, contentControlAtPoint as r, enumerateDocumentSections as s, enumerateDocumentSectionsBounded as t, findDrawingOverlayFrameInLayout as u, geometryOfSection as v, hitTestPage as w, hitTestSheet as x, isFurniturePoint as y, lineEndOffset as z };