@docx-editor.dev/core 2.4.1 → 2.5.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.
- package/dist/automation.cjs +1 -1
- package/dist/automation.d.cts +6 -6
- package/dist/automation.d.ts +6 -6
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +12 -12
- package/dist/binding.d.ts +12 -12
- package/dist/binding.js +1 -1
- package/dist/chunk-2GSRLGUI.cjs +10 -0
- package/dist/chunk-2QIA75K3.js +2 -0
- package/dist/chunk-32NXPFYL.js +5 -0
- package/dist/chunk-3C533HSQ.cjs +18 -0
- package/dist/{chunk-YMIMLEX4.cjs → chunk-3FRSOOND.cjs} +1 -1
- package/dist/chunk-45FL7KH4.js +1 -0
- package/dist/chunk-7GYF33B5.cjs +2 -0
- package/dist/chunk-H3DZP4LE.cjs +5 -0
- package/dist/chunk-IJ4V3LGV.cjs +2 -0
- package/dist/chunk-JDHTCMFA.cjs +2 -0
- package/dist/chunk-L2GMLEHX.cjs +14 -0
- package/dist/chunk-LJIX4ZDF.js +10 -0
- package/dist/chunk-QUZM6LWQ.js +14 -0
- package/dist/chunk-T252F4US.js +18 -0
- package/dist/chunk-UVIUNAQ6.js +2 -0
- package/dist/chunk-YTZIGUXT.js +2 -0
- package/dist/{content-control-walk-CbTqHq6O.d.cts → content-control-walk-BeAFh6Xi.d.cts} +1 -1
- package/dist/{content-control-walk-D06GijR0.d.ts → content-control-walk-CQp8l6eS.d.ts} +1 -1
- package/dist/contracts/editor.d.cts +9 -9
- package/dist/contracts/editor.d.ts +9 -9
- package/dist/contracts/interaction.d.cts +9 -9
- package/dist/contracts/interaction.d.ts +9 -9
- package/dist/contracts/modules.d.cts +5 -5
- package/dist/contracts/modules.d.ts +5 -5
- package/dist/{custom-node-writes-BkMgMXxs.d.ts → custom-node-writes-2clI36T9.d.ts} +22 -7
- package/dist/{custom-node-writes-C5YRoPcc.d.cts → custom-node-writes-CIC_-wad.d.cts} +22 -7
- package/dist/{editor-DYvC9CZs.d.cts → editor-CUul9IuY.d.cts} +22 -5
- package/dist/{editor-D1qHfzOt.d.ts → editor-DIwctMcU.d.ts} +22 -5
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +32 -0
- package/dist/editor.d.cts +24 -24
- package/dist/editor.d.ts +24 -24
- package/dist/editor.js +1 -1
- package/dist/{hf-references-CgEOSw3i.d.cts → hf-references-BPET4tlK.d.cts} +2 -2
- package/dist/{hf-references-BdjsQNE_.d.ts → hf-references-CAp1xTv6.d.ts} +2 -2
- package/dist/{image-resources-DXvPZvXD.d.cts → image-resources-CSlQmPIm.d.cts} +10 -10
- package/dist/{image-resources-BG9DLyW7.d.ts → image-resources-e13t-pgy.d.ts} +10 -10
- package/dist/{index-Bb-QAg_f.d.cts → index-8t44iXTY.d.cts} +79 -14
- package/dist/{index-DpY3WZuP.d.ts → index-BUsYjxF5.d.ts} +79 -14
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +114 -50
- package/dist/layout.d.ts +114 -50
- package/dist/layout.js +1 -1
- package/dist/{note-nodes-C6DLxlvj.d.cts → note-nodes-B2wWES2L.d.cts} +1 -1
- package/dist/{note-nodes-BPSTVDMr.d.ts → note-nodes-CZQXU6Fg.d.ts} +1 -1
- package/dist/{review-reads-CQmU9Lcl.d.ts → note-properties-BS66XmcC.d.ts} +91 -67
- package/dist/{review-reads-CxgN62yp.d.cts → note-properties-Dhqkro--.d.cts} +91 -67
- package/dist/{ooxml-package-D_CtywTW.d.ts → ooxml-package-BrxTmTsZ.d.ts} +115 -115
- package/dist/{ooxml-package-CR5us6ad.d.cts → ooxml-package-Cmbe_M04.d.cts} +115 -115
- package/dist/{ooxml-tree-BU0e3DVi.d.cts → ooxml-tree-CG0odFyi.d.cts} +1 -1
- package/dist/{ooxml-tree-BU0e3DVi.d.ts → ooxml-tree-CG0odFyi.d.ts} +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +7 -7
- package/dist/output.d.ts +7 -7
- package/dist/output.js +1 -1
- package/dist/{protocol-CD7slqvl.d.cts → protocol-B5oSt08P.d.cts} +2 -2
- package/dist/{protocol-DsbfgBwA.d.ts → protocol-ooK7PAXz.d.ts} +2 -2
- package/dist/{review-support-DgXTIYBW.d.ts → review-support-Bl9sN8cv.d.ts} +47 -3
- package/dist/{review-support-BJ-YjGmD.d.cts → review-support-CHuJxHmz.d.cts} +47 -3
- package/dist/{revision-projection-DHAkcD_L.d.ts → revision-projection-DRZMzoLD.d.cts} +54 -3
- package/dist/{revision-projection-72ZApe-g.d.cts → revision-projection-u4nT52xT.d.ts} +54 -3
- package/dist/{semantic-cell-selection-DZtyMXkH.d.ts → semantic-cell-selection-CdNQ-a9-.d.cts} +8 -5
- package/dist/{semantic-cell-selection--ezfezTe.d.cts → semantic-cell-selection-Dc-_enhm.d.ts} +8 -5
- package/dist/{semantic-interaction-DrgbgKg6.d.ts → semantic-interaction-CCVwyw2A.d.ts} +2 -30
- package/dist/{semantic-interaction-2yxdv7q0.d.cts → semantic-interaction-DgaWs-5w.d.cts} +2 -30
- package/dist/{semantic-paint-BYjE0Xbl.d.cts → semantic-paint-6iIB4fhx.d.cts} +2 -2
- package/dist/{semantic-paint-BedBxkyY.d.ts → semantic-paint-CKIbFkQ7.d.ts} +2 -2
- package/dist/{semantic-records-CR5hTqMK.d.ts → semantic-records-B-qbrnp2.d.ts} +107 -9
- package/dist/{semantic-records-DSD8WENa.d.cts → semantic-records-Dq8SlCY8.d.cts} +107 -9
- package/dist/{shaped-measurer-BL8g4AcW.d.ts → shaped-measurer-BT4FqYe9.d.ts} +1 -1
- package/dist/{shaped-measurer-CBOTJTV_.d.cts → shaped-measurer-Dx4llNhK.d.cts} +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +254 -231
- package/dist/store.d.ts +254 -231
- package/dist/store.js +1 -1
- package/dist/{tree-op-types-8a6xyRCN.d.ts → tree-op-types-CZw9QhWX.d.ts} +219 -219
- package/dist/{tree-op-types-EZXbR8bW.d.cts → tree-op-types-DOYNkKqD.d.cts} +219 -219
- package/dist/{tree-session-SucW0znF.d.ts → tree-session-CF_EOhTW.d.ts} +14 -8
- package/dist/{tree-session-DrMm8Cj2.d.cts → tree-session-CtK3KgFU.d.cts} +14 -8
- package/dist/{tree-store-BoM6eXaL.d.ts → tree-store-9TaX-L0V.d.ts} +31 -4
- package/dist/{tree-store-UYrGKF_Q.d.cts → tree-store-Jg-q7fyf.d.cts} +31 -4
- package/package.json +3 -3
- package/dist/chunk-33F6TRXO.js +0 -2
- package/dist/chunk-4WWEDTTE.js +0 -2
- package/dist/chunk-BS554B6D.cjs +0 -2
- package/dist/chunk-DQ5HGUWG.cjs +0 -12
- package/dist/chunk-EQO762XH.cjs +0 -10
- package/dist/chunk-F6WNPYOM.js +0 -2
- package/dist/chunk-FL4GWK76.js +0 -12
- package/dist/chunk-GWG5IVVX.cjs +0 -5
- package/dist/chunk-IZIL6BAW.cjs +0 -12
- package/dist/chunk-LIJPSHRA.js +0 -5
- package/dist/chunk-MHDO6HLI.cjs +0 -2
- package/dist/chunk-SG7OH2EK.js +0 -12
- package/dist/chunk-TCX3PVWR.js +0 -10
- package/dist/chunk-YTYKNA6X.cjs +0 -2
- package/dist/chunk-ZACHY6OS.js +0 -1
|
@@ -1,4 +1,221 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as OoxmlContentControlNode, O as OoxmlNode, d as OoxmlContentControlContentNode, o as OoxmlContentControlEndPropertiesNode, p as OoxmlContentControlPropertiesNode, a as OoxmlElement, q as OoxmlDrawingNode, e as OoxmlPart } from './ooxml-tree-CG0odFyi.js';
|
|
2
|
+
|
|
3
|
+
/** How deep controls may nest before a walk stops descending. Shared by every lane. */
|
|
4
|
+
declare const MAX_CONTENT_CONTROL_NESTING = 32;
|
|
5
|
+
/** Cap on controls one walk reports, so a hostile file cannot make a read unbounded. */
|
|
6
|
+
declare const MAX_CONTENT_CONTROLS_PER_PART = 10000;
|
|
7
|
+
/** `CT_SdtPr/w:id` is `ST_DecimalNumber`; Word treats it as a signed 32-bit integer. */
|
|
8
|
+
declare const CONTENT_CONTROL_ID_MAX = 2147483647;
|
|
9
|
+
/** `ST_Lock` (§17.5.2.24). An absent `w:lock` is `unlocked`. */
|
|
10
|
+
/**
|
|
11
|
+
* `w:lock` — what a control refuses.
|
|
12
|
+
*
|
|
13
|
+
* `sdtLocked` protects the wrapper, `contentLocked` the text inside it, and `sdtContentLocked`
|
|
14
|
+
* both. A control inside a locked one is locked in effect regardless of its own value.
|
|
15
|
+
*/
|
|
16
|
+
type ContentControlLock = 'unlocked' | 'sdtLocked' | 'contentLocked' | 'sdtContentLocked';
|
|
17
|
+
/**
|
|
18
|
+
* What kind of control this is.
|
|
19
|
+
*
|
|
20
|
+
* `checkbox` is the Microsoft `w14:checkbox` extension rather than an ECMA-376 type
|
|
21
|
+
* element, and the two are not mutually exclusive with "declares no type": four controls
|
|
22
|
+
* in the comprehensive fixture declare the extension and no `w:`-prefixed type, so a scan
|
|
23
|
+
* that read only the ECMA-376 choice reported them untyped. `untyped` means the control
|
|
24
|
+
* declares neither — a rich-text container, which is what Word treats it as.
|
|
25
|
+
*/
|
|
26
|
+
/** Which kind of control a `w:sdt` is, and therefore what a written value must look like. */
|
|
27
|
+
type ContentControlKind = 'richText' | 'plainText' | 'checkbox' | 'dropDownList' | 'comboBox' | 'date' | 'picture' | 'docPartObj' | 'docPartList' | 'group' | 'citation' | 'bibliography' | 'equation' | 'untyped';
|
|
28
|
+
/** One declared option of a dropdown or combo box: its display text and its stored value. */
|
|
29
|
+
interface ContentControlListItem {
|
|
30
|
+
readonly displayText: string;
|
|
31
|
+
readonly value: string;
|
|
32
|
+
}
|
|
33
|
+
/** A date picker's authored format and locale, for rendering and for parsing what it stores. */
|
|
34
|
+
interface ContentControlDateFormat {
|
|
35
|
+
readonly fullDate?: string;
|
|
36
|
+
readonly dateFormat?: string;
|
|
37
|
+
readonly lid?: string;
|
|
38
|
+
readonly storeMappedDataAs?: string;
|
|
39
|
+
readonly calendar?: string;
|
|
40
|
+
}
|
|
41
|
+
/** One of a checkbox's two glyphs: the font and code point it is drawn with. */
|
|
42
|
+
interface ContentControlCheckboxState {
|
|
43
|
+
/** The `w14:val` hex code point of the glyph, exactly as the control declares it. */
|
|
44
|
+
readonly value: string;
|
|
45
|
+
readonly font?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A checkbox's state and the two glyphs it chooses between.
|
|
49
|
+
*
|
|
50
|
+
* Both glyphs matter on a write: setting the value has to update `w14:checked` AND the run's
|
|
51
|
+
* character, or the document's glyph and its recorded state disagree.
|
|
52
|
+
*/
|
|
53
|
+
interface ContentControlCheckbox {
|
|
54
|
+
readonly checked: boolean;
|
|
55
|
+
readonly checkedState?: ContentControlCheckboxState;
|
|
56
|
+
readonly uncheckedState?: ContentControlCheckboxState;
|
|
57
|
+
}
|
|
58
|
+
/** `CT_DataBinding` — preserved metadata. Never resolved, never fetched. */
|
|
59
|
+
/** `w:dataBinding` — the custom-XML part and XPath a control's value is bound to. */
|
|
60
|
+
interface ContentControlDataBinding {
|
|
61
|
+
readonly xpath?: string;
|
|
62
|
+
readonly storeItemID?: string;
|
|
63
|
+
readonly prefixMappings?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A control's whole `w:sdtPr`, projected into one typed shape.
|
|
67
|
+
*
|
|
68
|
+
* What every other lane reads instead of walking `localName` strings — which also means a Word
|
|
69
|
+
* re-save that demotes the properties node to generic does not break the projection.
|
|
70
|
+
*/
|
|
71
|
+
interface ContentControlProperties {
|
|
72
|
+
readonly type: ContentControlKind;
|
|
73
|
+
readonly alias?: string;
|
|
74
|
+
readonly tag?: string;
|
|
75
|
+
/** `@w:val` of `w:id` when the file declares a parseable one. Never fabricated. */
|
|
76
|
+
readonly id?: number;
|
|
77
|
+
readonly lock: ContentControlLock;
|
|
78
|
+
/** The glossary entry named by `w:placeholder/w:docPart`. Preserved, never loaded. */
|
|
79
|
+
readonly placeholderDocPart?: string;
|
|
80
|
+
readonly temporary: boolean;
|
|
81
|
+
readonly showingPlaceholder: boolean;
|
|
82
|
+
readonly dataBinding?: ContentControlDataBinding;
|
|
83
|
+
readonly label?: string;
|
|
84
|
+
readonly tabIndex?: number;
|
|
85
|
+
/** Items a dropdown or combo box offers. Empty for every other type. */
|
|
86
|
+
readonly listItems: readonly ContentControlListItem[];
|
|
87
|
+
readonly lastValue?: string;
|
|
88
|
+
readonly date?: ContentControlDateFormat;
|
|
89
|
+
readonly multiLine?: boolean;
|
|
90
|
+
readonly checkbox?: ContentControlCheckbox;
|
|
91
|
+
}
|
|
92
|
+
/** Whether a node is a `w:sdt` wrapper. */
|
|
93
|
+
declare function isContentControlNode(node: OoxmlNode): node is OoxmlContentControlNode;
|
|
94
|
+
/** Whether a node is a `w:sdtContent` — the container holding a control's actual content. */
|
|
95
|
+
declare function isContentControlContentNode(node: OoxmlNode): node is OoxmlContentControlContentNode;
|
|
96
|
+
/**
|
|
97
|
+
* A `w:sdt` wrapper, TYPED or DEMOTED.
|
|
98
|
+
*
|
|
99
|
+
* Flattening predates typing and must not stop at a control the reader refused to type: a
|
|
100
|
+
* demoted wrapper still renders its content in place in Word, so a walk that only saw the
|
|
101
|
+
* typed kind would drop every paragraph inside a malformed control out of the story.
|
|
102
|
+
*/
|
|
103
|
+
declare function isContentControlWrapper(node: OoxmlNode): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The children of a wrapper's `w:sdtContent`, typed or demoted, in order.
|
|
106
|
+
*
|
|
107
|
+
* The one place that knows a control's content is reached through an intermediate element,
|
|
108
|
+
* so the four flattening walks (story blocks, layout, header/footer references, list
|
|
109
|
+
* resolution) ask the same question rather than each re-deriving it.
|
|
110
|
+
*/
|
|
111
|
+
declare function contentControlContentChildren(wrapper: OoxmlNode): readonly OoxmlNode[];
|
|
112
|
+
/**
|
|
113
|
+
* A container's children with every content-control wrapper flattened away, bounded in depth.
|
|
114
|
+
*
|
|
115
|
+
* ONE unwrap rule, for the places where a control sits between a container and the children that
|
|
116
|
+
* container is defined in terms of. `CT_SdtRow` puts it between `w:tbl` and `w:tr`, `CT_SdtCell`
|
|
117
|
+
* between `w:tr` and `w:tc`, and a walk that filtered on the child's kind dropped the row or cell
|
|
118
|
+
* entirely: not measured, not painted, not addressable. Flattening at the point of the filter
|
|
119
|
+
* means a controlled row is the same row to the grid pass, the pagination pass and the story walk.
|
|
120
|
+
*
|
|
121
|
+
* Returns the SAME array identity when there is nothing to unwrap, so the tables that carry no
|
|
122
|
+
* controls — nearly all of them — allocate nothing and the incremental layout cache still sees
|
|
123
|
+
* its own inputs.
|
|
124
|
+
*/
|
|
125
|
+
declare function flattenContentControls(children: readonly OoxmlNode[], maxDepth?: number): readonly OoxmlNode[];
|
|
126
|
+
/** A control's `w:sdtPr`, or null. Matches structurally, so a Word-demoted node still resolves. */
|
|
127
|
+
declare function contentControlPropertiesNodeOf(control: OoxmlNode): OoxmlContentControlPropertiesNode | undefined;
|
|
128
|
+
/** A control's `w:sdtEndPr` — the run properties applied to its closing marker. */
|
|
129
|
+
declare function contentControlEndPropertiesNodeOf(control: OoxmlNode): OoxmlContentControlEndPropertiesNode | undefined;
|
|
130
|
+
/** A control's `w:sdtContent`, or null when the wrapper has none. */
|
|
131
|
+
declare function contentControlContentNodeOf(control: OoxmlNode): OoxmlContentControlContentNode | undefined;
|
|
132
|
+
/** A signed 32-bit `ST_DecimalNumber`, or undefined when the file wrote something else. */
|
|
133
|
+
declare function parseContentControlId(raw: string | undefined): number | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Read a control's properties.
|
|
136
|
+
*
|
|
137
|
+
* Total: a control with no `w:sdtPr` at all answers the same shape with the defaults an
|
|
138
|
+
* absent property means, so no caller has to branch on the container's existence.
|
|
139
|
+
*/
|
|
140
|
+
declare function contentControlPropertiesOf(control: OoxmlNode): ContentControlProperties;
|
|
141
|
+
/** Where a control sits, read off what its content holds. */
|
|
142
|
+
type ContentControlLevel = 'block' | 'inline' | 'row' | 'cell' | 'empty';
|
|
143
|
+
/**
|
|
144
|
+
* How deeply a control is nested inside other controls.
|
|
145
|
+
*
|
|
146
|
+
* Bounded by {@link MAX_CONTENT_CONTROL_NESTING}: nesting depth comes from a file and is a
|
|
147
|
+
* recursion bound.
|
|
148
|
+
*/
|
|
149
|
+
declare function contentControlLevelOf(control: OoxmlNode): ContentControlLevel;
|
|
150
|
+
/** One control, plus how deeply it is nested and the controls that enclose it. */
|
|
151
|
+
interface ContentControlEntry {
|
|
152
|
+
readonly node: OoxmlContentControlNode;
|
|
153
|
+
/** 0 for a top-level control; the nesting depth otherwise. */
|
|
154
|
+
readonly depth: number;
|
|
155
|
+
/** Enclosing controls, outermost first. Empty at depth 0. */
|
|
156
|
+
readonly ancestors: readonly OoxmlContentControlNode[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Every control under a node, in document order, bounded in depth and in count.
|
|
160
|
+
*
|
|
161
|
+
* ONE walk, shared. The nesting bound is the same one layout flattens with, so a control
|
|
162
|
+
* a lane can address is a control every lane can address — and a file that nests past it
|
|
163
|
+
* keeps its content in the tree (the serializer never stops) while no walk recurses
|
|
164
|
+
* further.
|
|
165
|
+
*/
|
|
166
|
+
declare function contentControlsIn(root: OoxmlNode, options?: {
|
|
167
|
+
readonly maxDepth?: number;
|
|
168
|
+
readonly limit?: number;
|
|
169
|
+
}): readonly ContentControlEntry[];
|
|
170
|
+
/** Find one control by canonical node id, with the same bounded walk. */
|
|
171
|
+
declare function findContentControl(root: OoxmlNode, nodeId: string): ContentControlEntry | null;
|
|
172
|
+
/**
|
|
173
|
+
* The plain text a control's content holds, in reading order.
|
|
174
|
+
*
|
|
175
|
+
* `w:delText` is excluded: struck text is not the control's value, and a dropdown whose
|
|
176
|
+
* old item is still present as a tracked deletion would otherwise report both.
|
|
177
|
+
*/
|
|
178
|
+
declare function contentControlTextOf(control: OoxmlNode): string;
|
|
179
|
+
/**
|
|
180
|
+
* Resolve the lock a position inherits from the controls enclosing it.
|
|
181
|
+
*
|
|
182
|
+
* CONSERVATIVE, because a template that says a field cannot be edited and sits inside a
|
|
183
|
+
* section that says it cannot be removed means both. Each half of `ST_Lock` is taken
|
|
184
|
+
* independently and the strongest wins, so an unlocked control inside a `contentLocked`
|
|
185
|
+
* one is still content-locked — a nested control cannot grant a permission its parent
|
|
186
|
+
* withheld, which is the only reading under which a lock is a lock.
|
|
187
|
+
*/
|
|
188
|
+
declare function resolveContentControlLock(chain: readonly ContentControlLock[]): ContentControlLock;
|
|
189
|
+
/** Whether a resolved lock forbids editing the content it covers. */
|
|
190
|
+
declare function lockForbidsEdit(lock: ContentControlLock): boolean;
|
|
191
|
+
/** Whether a resolved lock forbids removing the control itself. */
|
|
192
|
+
declare function lockForbidsRemoval(lock: ContentControlLock): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* `CT_SdtPr`'s declared child order (§17.5.2.38), followed by the type choice.
|
|
195
|
+
*
|
|
196
|
+
* Serialization re-emits children in tree order, so the ONLY way a write keeps the
|
|
197
|
+
* sequence valid is to place the child it authors at its schema position — which is what
|
|
198
|
+
* {@link orderedContentControlProperties} does.
|
|
199
|
+
*/
|
|
200
|
+
declare const CONTENT_CONTROL_PROPERTY_ORDER: readonly string[];
|
|
201
|
+
/**
|
|
202
|
+
* Rebuild a `w:sdtPr`'s children in schema order.
|
|
203
|
+
*
|
|
204
|
+
* Modelled children sort to their declared position and the type element follows them,
|
|
205
|
+
* as the sequence requires. Everything else — a `w15:repeatingSection`, a vendor
|
|
206
|
+
* extension, the `w14:checkbox` that is not part of the ECMA-376 choice — keeps the order
|
|
207
|
+
* it was authored in and follows the modelled block, so a write that touches one property
|
|
208
|
+
* neither drops nor reorders anything it does not name.
|
|
209
|
+
*/
|
|
210
|
+
declare function orderedContentControlProperties(children: readonly OoxmlNode[]): readonly OoxmlNode[];
|
|
211
|
+
/**
|
|
212
|
+
* The next `w:id` to write, seeded from the document's own maximum plus one.
|
|
213
|
+
*
|
|
214
|
+
* Never a clock, a timestamp, a random source or a hash: those collide with ids already
|
|
215
|
+
* in the file and produce values Word rejects. Null when the document already reaches the
|
|
216
|
+
* signed 32-bit bound, so the caller refuses rather than wrapping into a negative id.
|
|
217
|
+
*/
|
|
218
|
+
declare function allocateContentControlId(root: OoxmlNode): number | null;
|
|
2
219
|
|
|
3
220
|
/** The relationship namespace `r:id` lives in. */
|
|
4
221
|
declare const OFFICE_RELATIONSHIP_NAMESPACE_URI = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
@@ -327,223 +544,6 @@ declare function projectDrawing(drawing: OoxmlDrawingNode, context: Readonly<{
|
|
|
327
544
|
resolveRelationship?: RelationshipTargetResolver;
|
|
328
545
|
}>): DrawingProjection | null;
|
|
329
546
|
|
|
330
|
-
/** How deep controls may nest before a walk stops descending. Shared by every lane. */
|
|
331
|
-
declare const MAX_CONTENT_CONTROL_NESTING = 32;
|
|
332
|
-
/** Cap on controls one walk reports, so a hostile file cannot make a read unbounded. */
|
|
333
|
-
declare const MAX_CONTENT_CONTROLS_PER_PART = 10000;
|
|
334
|
-
/** `CT_SdtPr/w:id` is `ST_DecimalNumber`; Word treats it as a signed 32-bit integer. */
|
|
335
|
-
declare const CONTENT_CONTROL_ID_MAX = 2147483647;
|
|
336
|
-
/** `ST_Lock` (§17.5.2.24). An absent `w:lock` is `unlocked`. */
|
|
337
|
-
/**
|
|
338
|
-
* `w:lock` — what a control refuses.
|
|
339
|
-
*
|
|
340
|
-
* `sdtLocked` protects the wrapper, `contentLocked` the text inside it, and `sdtContentLocked`
|
|
341
|
-
* both. A control inside a locked one is locked in effect regardless of its own value.
|
|
342
|
-
*/
|
|
343
|
-
type ContentControlLock = 'unlocked' | 'sdtLocked' | 'contentLocked' | 'sdtContentLocked';
|
|
344
|
-
/**
|
|
345
|
-
* What kind of control this is.
|
|
346
|
-
*
|
|
347
|
-
* `checkbox` is the Microsoft `w14:checkbox` extension rather than an ECMA-376 type
|
|
348
|
-
* element, and the two are not mutually exclusive with "declares no type": four controls
|
|
349
|
-
* in the comprehensive fixture declare the extension and no `w:`-prefixed type, so a scan
|
|
350
|
-
* that read only the ECMA-376 choice reported them untyped. `untyped` means the control
|
|
351
|
-
* declares neither — a rich-text container, which is what Word treats it as.
|
|
352
|
-
*/
|
|
353
|
-
/** Which kind of control a `w:sdt` is, and therefore what a written value must look like. */
|
|
354
|
-
type ContentControlKind = 'richText' | 'plainText' | 'checkbox' | 'dropDownList' | 'comboBox' | 'date' | 'picture' | 'docPartObj' | 'docPartList' | 'group' | 'citation' | 'bibliography' | 'equation' | 'untyped';
|
|
355
|
-
/** One declared option of a dropdown or combo box: its display text and its stored value. */
|
|
356
|
-
interface ContentControlListItem {
|
|
357
|
-
readonly displayText: string;
|
|
358
|
-
readonly value: string;
|
|
359
|
-
}
|
|
360
|
-
/** A date picker's authored format and locale, for rendering and for parsing what it stores. */
|
|
361
|
-
interface ContentControlDateFormat {
|
|
362
|
-
readonly fullDate?: string;
|
|
363
|
-
readonly dateFormat?: string;
|
|
364
|
-
readonly lid?: string;
|
|
365
|
-
readonly storeMappedDataAs?: string;
|
|
366
|
-
readonly calendar?: string;
|
|
367
|
-
}
|
|
368
|
-
/** One of a checkbox's two glyphs: the font and code point it is drawn with. */
|
|
369
|
-
interface ContentControlCheckboxState {
|
|
370
|
-
/** The `w14:val` hex code point of the glyph, exactly as the control declares it. */
|
|
371
|
-
readonly value: string;
|
|
372
|
-
readonly font?: string;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* A checkbox's state and the two glyphs it chooses between.
|
|
376
|
-
*
|
|
377
|
-
* Both glyphs matter on a write: setting the value has to update `w14:checked` AND the run's
|
|
378
|
-
* character, or the document's glyph and its recorded state disagree.
|
|
379
|
-
*/
|
|
380
|
-
interface ContentControlCheckbox {
|
|
381
|
-
readonly checked: boolean;
|
|
382
|
-
readonly checkedState?: ContentControlCheckboxState;
|
|
383
|
-
readonly uncheckedState?: ContentControlCheckboxState;
|
|
384
|
-
}
|
|
385
|
-
/** `CT_DataBinding` — preserved metadata. Never resolved, never fetched. */
|
|
386
|
-
/** `w:dataBinding` — the custom-XML part and XPath a control's value is bound to. */
|
|
387
|
-
interface ContentControlDataBinding {
|
|
388
|
-
readonly xpath?: string;
|
|
389
|
-
readonly storeItemID?: string;
|
|
390
|
-
readonly prefixMappings?: string;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* A control's whole `w:sdtPr`, projected into one typed shape.
|
|
394
|
-
*
|
|
395
|
-
* What every other lane reads instead of walking `localName` strings — which also means a Word
|
|
396
|
-
* re-save that demotes the properties node to generic does not break the projection.
|
|
397
|
-
*/
|
|
398
|
-
interface ContentControlProperties {
|
|
399
|
-
readonly type: ContentControlKind;
|
|
400
|
-
readonly alias?: string;
|
|
401
|
-
readonly tag?: string;
|
|
402
|
-
/** `@w:val` of `w:id` when the file declares a parseable one. Never fabricated. */
|
|
403
|
-
readonly id?: number;
|
|
404
|
-
readonly lock: ContentControlLock;
|
|
405
|
-
/** The glossary entry named by `w:placeholder/w:docPart`. Preserved, never loaded. */
|
|
406
|
-
readonly placeholderDocPart?: string;
|
|
407
|
-
readonly temporary: boolean;
|
|
408
|
-
readonly showingPlaceholder: boolean;
|
|
409
|
-
readonly dataBinding?: ContentControlDataBinding;
|
|
410
|
-
readonly label?: string;
|
|
411
|
-
readonly tabIndex?: number;
|
|
412
|
-
/** Items a dropdown or combo box offers. Empty for every other type. */
|
|
413
|
-
readonly listItems: readonly ContentControlListItem[];
|
|
414
|
-
readonly lastValue?: string;
|
|
415
|
-
readonly date?: ContentControlDateFormat;
|
|
416
|
-
readonly multiLine?: boolean;
|
|
417
|
-
readonly checkbox?: ContentControlCheckbox;
|
|
418
|
-
}
|
|
419
|
-
/** Whether a node is a `w:sdt` wrapper. */
|
|
420
|
-
declare function isContentControlNode(node: OoxmlNode): node is OoxmlContentControlNode;
|
|
421
|
-
/** Whether a node is a `w:sdtContent` — the container holding a control's actual content. */
|
|
422
|
-
declare function isContentControlContentNode(node: OoxmlNode): node is OoxmlContentControlContentNode;
|
|
423
|
-
/**
|
|
424
|
-
* A `w:sdt` wrapper, TYPED or DEMOTED.
|
|
425
|
-
*
|
|
426
|
-
* Flattening predates typing and must not stop at a control the reader refused to type: a
|
|
427
|
-
* demoted wrapper still renders its content in place in Word, so a walk that only saw the
|
|
428
|
-
* typed kind would drop every paragraph inside a malformed control out of the story.
|
|
429
|
-
*/
|
|
430
|
-
declare function isContentControlWrapper(node: OoxmlNode): boolean;
|
|
431
|
-
/**
|
|
432
|
-
* The children of a wrapper's `w:sdtContent`, typed or demoted, in order.
|
|
433
|
-
*
|
|
434
|
-
* The one place that knows a control's content is reached through an intermediate element,
|
|
435
|
-
* so the four flattening walks (story blocks, layout, header/footer references, list
|
|
436
|
-
* resolution) ask the same question rather than each re-deriving it.
|
|
437
|
-
*/
|
|
438
|
-
declare function contentControlContentChildren(wrapper: OoxmlNode): readonly OoxmlNode[];
|
|
439
|
-
/**
|
|
440
|
-
* A container's children with every content-control wrapper flattened away, bounded in depth.
|
|
441
|
-
*
|
|
442
|
-
* ONE unwrap rule, for the places where a control sits between a container and the children that
|
|
443
|
-
* container is defined in terms of. `CT_SdtRow` puts it between `w:tbl` and `w:tr`, `CT_SdtCell`
|
|
444
|
-
* between `w:tr` and `w:tc`, and a walk that filtered on the child's kind dropped the row or cell
|
|
445
|
-
* entirely: not measured, not painted, not addressable. Flattening at the point of the filter
|
|
446
|
-
* means a controlled row is the same row to the grid pass, the pagination pass and the story walk.
|
|
447
|
-
*
|
|
448
|
-
* Returns the SAME array identity when there is nothing to unwrap, so the tables that carry no
|
|
449
|
-
* controls — nearly all of them — allocate nothing and the incremental layout cache still sees
|
|
450
|
-
* its own inputs.
|
|
451
|
-
*/
|
|
452
|
-
declare function flattenContentControls(children: readonly OoxmlNode[], maxDepth?: number): readonly OoxmlNode[];
|
|
453
|
-
/** A control's `w:sdtPr`, or null. Matches structurally, so a Word-demoted node still resolves. */
|
|
454
|
-
declare function contentControlPropertiesNodeOf(control: OoxmlNode): OoxmlContentControlPropertiesNode | undefined;
|
|
455
|
-
/** A control's `w:sdtEndPr` — the run properties applied to its closing marker. */
|
|
456
|
-
declare function contentControlEndPropertiesNodeOf(control: OoxmlNode): OoxmlContentControlEndPropertiesNode | undefined;
|
|
457
|
-
/** A control's `w:sdtContent`, or null when the wrapper has none. */
|
|
458
|
-
declare function contentControlContentNodeOf(control: OoxmlNode): OoxmlContentControlContentNode | undefined;
|
|
459
|
-
/** A signed 32-bit `ST_DecimalNumber`, or undefined when the file wrote something else. */
|
|
460
|
-
declare function parseContentControlId(raw: string | undefined): number | undefined;
|
|
461
|
-
/**
|
|
462
|
-
* Read a control's properties.
|
|
463
|
-
*
|
|
464
|
-
* Total: a control with no `w:sdtPr` at all answers the same shape with the defaults an
|
|
465
|
-
* absent property means, so no caller has to branch on the container's existence.
|
|
466
|
-
*/
|
|
467
|
-
declare function contentControlPropertiesOf(control: OoxmlNode): ContentControlProperties;
|
|
468
|
-
/** Where a control sits, read off what its content holds. */
|
|
469
|
-
type ContentControlLevel = 'block' | 'inline' | 'row' | 'cell' | 'empty';
|
|
470
|
-
/**
|
|
471
|
-
* How deeply a control is nested inside other controls.
|
|
472
|
-
*
|
|
473
|
-
* Bounded by {@link MAX_CONTENT_CONTROL_NESTING}: nesting depth comes from a file and is a
|
|
474
|
-
* recursion bound.
|
|
475
|
-
*/
|
|
476
|
-
declare function contentControlLevelOf(control: OoxmlNode): ContentControlLevel;
|
|
477
|
-
/** One control, plus how deeply it is nested and the controls that enclose it. */
|
|
478
|
-
interface ContentControlEntry {
|
|
479
|
-
readonly node: OoxmlContentControlNode;
|
|
480
|
-
/** 0 for a top-level control; the nesting depth otherwise. */
|
|
481
|
-
readonly depth: number;
|
|
482
|
-
/** Enclosing controls, outermost first. Empty at depth 0. */
|
|
483
|
-
readonly ancestors: readonly OoxmlContentControlNode[];
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Every control under a node, in document order, bounded in depth and in count.
|
|
487
|
-
*
|
|
488
|
-
* ONE walk, shared. The nesting bound is the same one layout flattens with, so a control
|
|
489
|
-
* a lane can address is a control every lane can address — and a file that nests past it
|
|
490
|
-
* keeps its content in the tree (the serializer never stops) while no walk recurses
|
|
491
|
-
* further.
|
|
492
|
-
*/
|
|
493
|
-
declare function contentControlsIn(root: OoxmlNode, options?: {
|
|
494
|
-
readonly maxDepth?: number;
|
|
495
|
-
readonly limit?: number;
|
|
496
|
-
}): readonly ContentControlEntry[];
|
|
497
|
-
/** Find one control by canonical node id, with the same bounded walk. */
|
|
498
|
-
declare function findContentControl(root: OoxmlNode, nodeId: string): ContentControlEntry | null;
|
|
499
|
-
/**
|
|
500
|
-
* The plain text a control's content holds, in reading order.
|
|
501
|
-
*
|
|
502
|
-
* `w:delText` is excluded: struck text is not the control's value, and a dropdown whose
|
|
503
|
-
* old item is still present as a tracked deletion would otherwise report both.
|
|
504
|
-
*/
|
|
505
|
-
declare function contentControlTextOf(control: OoxmlNode): string;
|
|
506
|
-
/**
|
|
507
|
-
* Resolve the lock a position inherits from the controls enclosing it.
|
|
508
|
-
*
|
|
509
|
-
* CONSERVATIVE, because a template that says a field cannot be edited and sits inside a
|
|
510
|
-
* section that says it cannot be removed means both. Each half of `ST_Lock` is taken
|
|
511
|
-
* independently and the strongest wins, so an unlocked control inside a `contentLocked`
|
|
512
|
-
* one is still content-locked — a nested control cannot grant a permission its parent
|
|
513
|
-
* withheld, which is the only reading under which a lock is a lock.
|
|
514
|
-
*/
|
|
515
|
-
declare function resolveContentControlLock(chain: readonly ContentControlLock[]): ContentControlLock;
|
|
516
|
-
/** Whether a resolved lock forbids editing the content it covers. */
|
|
517
|
-
declare function lockForbidsEdit(lock: ContentControlLock): boolean;
|
|
518
|
-
/** Whether a resolved lock forbids removing the control itself. */
|
|
519
|
-
declare function lockForbidsRemoval(lock: ContentControlLock): boolean;
|
|
520
|
-
/**
|
|
521
|
-
* `CT_SdtPr`'s declared child order (§17.5.2.38), followed by the type choice.
|
|
522
|
-
*
|
|
523
|
-
* Serialization re-emits children in tree order, so the ONLY way a write keeps the
|
|
524
|
-
* sequence valid is to place the child it authors at its schema position — which is what
|
|
525
|
-
* {@link orderedContentControlProperties} does.
|
|
526
|
-
*/
|
|
527
|
-
declare const CONTENT_CONTROL_PROPERTY_ORDER: readonly string[];
|
|
528
|
-
/**
|
|
529
|
-
* Rebuild a `w:sdtPr`'s children in schema order.
|
|
530
|
-
*
|
|
531
|
-
* Modelled children sort to their declared position and the type element follows them,
|
|
532
|
-
* as the sequence requires. Everything else — a `w15:repeatingSection`, a vendor
|
|
533
|
-
* extension, the `w14:checkbox` that is not part of the ECMA-376 choice — keeps the order
|
|
534
|
-
* it was authored in and follows the modelled block, so a write that touches one property
|
|
535
|
-
* neither drops nor reorders anything it does not name.
|
|
536
|
-
*/
|
|
537
|
-
declare function orderedContentControlProperties(children: readonly OoxmlNode[]): readonly OoxmlNode[];
|
|
538
|
-
/**
|
|
539
|
-
* The next `w:id` to write, seeded from the document's own maximum plus one.
|
|
540
|
-
*
|
|
541
|
-
* Never a clock, a timestamp, a random source or a hash: those collide with ids already
|
|
542
|
-
* in the file and produce values Word rejects. Null when the document already reaches the
|
|
543
|
-
* signed 32-bit bound, so the caller refuses rather than wrapping into a negative id.
|
|
544
|
-
*/
|
|
545
|
-
declare function allocateContentControlId(root: OoxmlNode): number | null;
|
|
546
|
-
|
|
547
547
|
/** The value a control accepts, by what kind of control it is. */
|
|
548
548
|
type ContentControlValueInput = {
|
|
549
549
|
readonly kind: 'text';
|
|
@@ -1488,4 +1488,4 @@ type TreeOpResult = {
|
|
|
1488
1488
|
readonly detail?: string;
|
|
1489
1489
|
};
|
|
1490
1490
|
|
|
1491
|
-
export { contentControlTextOf as $, ACCEPTED_PARAGRAPH_PROPERTIES as A, type HyperlinkKind as B, type ContentControlKind as C, type DrawingProjection as D, type HyperlinkTarget as E, MAX_CONTENT_CONTROL_NESTING as F, OFFICE_RELATIONSHIP_NAMESPACE_URI as G, HYPERLINK_RELATIONSHIP_TYPE as H, type ImpactClass as I, type RelationshipTargetResolver as J, TABLE_BORDER_STYLES as K, TREE_DOC_OP_KINDS as L, MAX_CONTENT_CONTROLS_PER_PART as M, type TreeDocOpKind as N, type OoxmlProperty as O, type TreeOpEffect as P, allocateContentControlId as Q, type RevisionAddress as R, type SourceCrop as S, type TreeDocOp as T, contentControlContentChildren as U, type VectorShapeProjection as V, contentControlContentNodeOf as W, contentControlEndPropertiesNodeOf as X, contentControlLevelOf as Y, contentControlPropertiesNodeOf as Z, contentControlPropertiesOf as _, type TreeOpRejection as a, contentControlsIn as a0, findContentControl as a1, flattenContentControls as a2, hyperlinkAnchorOf as a3, hyperlinkRelationshipIdOf as a4, hyperlinkTargetOf as a5, isContentControlContentNode as a6, isContentControlNode as a7, isContentControlWrapper as a8, isHyperlinkNode as a9, lockForbidsEdit as aa, lockForbidsRemoval as ab, orderedContentControlProperties as ac, parseContentControlId as ad, projectDrawing as ae, resolveContentControlLock as af, type ImageWrapTarget as b, type DrawingKind as c, type DrawingPositionInput as d, type DrawingLocks as e, type DrawingHorizontalReferenceFrame as f, type DrawingVerticalReferenceFrame as g, type TreeDocColorValue as h, IMAGE_WRAP_TARGETS as i, type
|
|
1491
|
+
export { contentControlTextOf as $, ACCEPTED_PARAGRAPH_PROPERTIES as A, type HyperlinkKind as B, type ContentControlKind as C, type DrawingProjection as D, type HyperlinkTarget as E, MAX_CONTENT_CONTROL_NESTING as F, OFFICE_RELATIONSHIP_NAMESPACE_URI as G, HYPERLINK_RELATIONSHIP_TYPE as H, type ImpactClass as I, type RelationshipTargetResolver as J, TABLE_BORDER_STYLES as K, TREE_DOC_OP_KINDS as L, MAX_CONTENT_CONTROLS_PER_PART as M, type TreeDocOpKind as N, type OoxmlProperty as O, type TreeOpEffect as P, allocateContentControlId as Q, type RevisionAddress as R, type SourceCrop as S, type TreeDocOp as T, contentControlContentChildren as U, type VectorShapeProjection as V, contentControlContentNodeOf as W, contentControlEndPropertiesNodeOf as X, contentControlLevelOf as Y, contentControlPropertiesNodeOf as Z, contentControlPropertiesOf as _, type TreeOpRejection as a, contentControlsIn as a0, findContentControl as a1, flattenContentControls as a2, hyperlinkAnchorOf as a3, hyperlinkRelationshipIdOf as a4, hyperlinkTargetOf as a5, isContentControlContentNode as a6, isContentControlNode as a7, isContentControlWrapper as a8, isHyperlinkNode as a9, lockForbidsEdit as aa, lockForbidsRemoval as ab, orderedContentControlProperties as ac, parseContentControlId as ad, projectDrawing as ae, resolveContentControlLock as af, type ImageWrapTarget as b, type DrawingKind as c, type DrawingPositionInput as d, type DrawingLocks as e, type DrawingHorizontalReferenceFrame as f, type DrawingVerticalReferenceFrame as g, type TreeDocColorValue as h, IMAGE_WRAP_TARGETS as i, type DrawingTreeDocOp as j, type DrawingAccessibility as k, type DrawingTransform as l, type TableBorderStyle as m, type ContentControlLevel as n, type ContentControlLock as o, type ContentControlDataBinding as p, type TreeOpResult as q, ACCEPTED_RUN_PROPERTIES as r, CONTENT_CONTROL_ID_MAX as s, CONTENT_CONTROL_PROPERTY_ORDER as t, type ContentControlCheckbox as u, type ContentControlCheckboxState as v, type ContentControlDateFormat as w, type ContentControlEntry as x, type ContentControlListItem as y, type ContentControlProperties as z };
|