ooxml.js 3.0.1 → 3.1.1

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.
@@ -0,0 +1,211 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_typed_util = require("../util.cjs");
3
+ //#region src/typed/docx/constructs.ts
4
+ const NON_CONTENT_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
5
+ "w:pPr",
6
+ "w:bookmarkStart",
7
+ "w:bookmarkEnd",
8
+ "w:commentRangeStart",
9
+ "w:commentRangeEnd",
10
+ "w:proofErr",
11
+ "w:permStart",
12
+ "w:permEnd",
13
+ "w:moveFromRangeStart",
14
+ "w:moveFromRangeEnd",
15
+ "w:moveToRangeStart",
16
+ "w:moveToRangeEnd"
17
+ ]);
18
+ const INERT_RUN_CHILDREN = /* @__PURE__ */ new Set(["w:rPr", "w:lastRenderedPageBreak"]);
19
+ function isContentBearingChild(child) {
20
+ if (NON_CONTENT_PARAGRAPH_CHILDREN.has(child.tag)) return false;
21
+ if (child.tag !== "w:r") return true;
22
+ return child.children.some((grandChild) => grandChild.type === "element" && !INERT_RUN_CHILDREN.has(grandChild.tag));
23
+ }
24
+ function indexParagraphContent(paragraph) {
25
+ const elements = [];
26
+ for (const child of paragraph.children) if (child.type === "element") elements.push(child);
27
+ let firstContentIndex = -1;
28
+ let lastContentIndex = -1;
29
+ elements.forEach((element, index) => {
30
+ if (!isContentBearingChild(element)) return;
31
+ if (firstContentIndex === -1) firstContentIndex = index;
32
+ lastContentIndex = index;
33
+ });
34
+ return {
35
+ elements,
36
+ firstContentIndex,
37
+ lastContentIndex
38
+ };
39
+ }
40
+ function contentBearingChildren(index) {
41
+ return index.elements.filter(isContentBearingChild);
42
+ }
43
+ function compareExtents(a, b) {
44
+ return a.startIndex - b.startIndex || b.endIndex - a.endIndex || a.order - b.order;
45
+ }
46
+ function acceptProperlyNested(extents) {
47
+ const sorted = [...extents].sort(compareExtents);
48
+ const accepted = [];
49
+ const open = [];
50
+ for (const extent of sorted) {
51
+ while (open.length > 0 && open[open.length - 1].endIndex <= extent.startIndex) open.pop();
52
+ const enclosing = open[open.length - 1];
53
+ if (enclosing !== void 0 && enclosing.endIndex < extent.endIndex) continue;
54
+ accepted.push(extent);
55
+ open.push(extent);
56
+ }
57
+ return accepted;
58
+ }
59
+ function insertConstructMarkers(blocks, extents) {
60
+ if (extents.length === 0) return [...blocks];
61
+ const nested = acceptProperlyNested(extents);
62
+ const openingAt = /* @__PURE__ */ new Map();
63
+ for (const extent of nested) {
64
+ const existing = openingAt.get(extent.startIndex);
65
+ if (existing === void 0) openingAt.set(extent.startIndex, [extent]);
66
+ else existing.push(extent);
67
+ }
68
+ const out = [];
69
+ const open = [];
70
+ for (let index = 0; index <= blocks.length; index++) {
71
+ while (open.length > 0 && open[open.length - 1].endIndex === index) {
72
+ open.pop();
73
+ out.push({ kind: "constructEnd" });
74
+ }
75
+ for (const extent of openingAt.get(index) ?? []) {
76
+ out.push({
77
+ kind: "constructStart",
78
+ descriptor: extent.descriptor
79
+ });
80
+ if (extent.endIndex === index) out.push({ kind: "constructEnd" });
81
+ else open.push(extent);
82
+ }
83
+ const block = blocks[index];
84
+ if (block !== void 0) out.push(block);
85
+ }
86
+ return out;
87
+ }
88
+ const CONTROL_TYPE_BY_TAG = /* @__PURE__ */ new Map([
89
+ ["w:richText", "richText"],
90
+ ["w:text", "plainText"],
91
+ ["w:comboBox", "comboBox"],
92
+ ["w:dropDownList", "dropDown"],
93
+ ["w:date", "date"],
94
+ ["w:picture", "picture"],
95
+ ["w:group", "group"],
96
+ ["w:checkbox", "checkbox"],
97
+ ["w14:checkbox", "checkbox"],
98
+ ["w:repeatingSection", "repeatingSection"],
99
+ ["w15:repeatingSection", "repeatingSection"]
100
+ ]);
101
+ const LOCK_BY_VALUE = /* @__PURE__ */ new Map([
102
+ ["contentLocked", "content"],
103
+ ["sdtLocked", "container"],
104
+ ["sdtContentLocked", "both"]
105
+ ]);
106
+ const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
107
+ function readControlType(sdtPr) {
108
+ if (sdtPr === void 0) return "richText";
109
+ for (const child of sdtPr.children) {
110
+ if (child.type !== "element") continue;
111
+ const mapped = CONTROL_TYPE_BY_TAG.get(child.tag);
112
+ if (mapped !== void 0) return mapped;
113
+ if (child.tag === "w:docPartObj" || child.tag === "w:docPartList") {
114
+ const gallery = require_typed_util.childrenWithTag(child, "w:docPartGallery")[0];
115
+ return (gallery === void 0 ? void 0 : require_typed_util.attr(gallery, "w:val")) === "Table of Contents" ? "index" : "richText";
116
+ }
117
+ }
118
+ return "richText";
119
+ }
120
+ function readListItemOptions(sdtPr) {
121
+ const list = require_typed_util.childrenWithTag(sdtPr, "w:dropDownList")[0] ?? require_typed_util.childrenWithTag(sdtPr, "w:comboBox")[0];
122
+ if (list === void 0) return;
123
+ const options = [];
124
+ for (const item of require_typed_util.childrenWithTag(list, "w:listItem")) {
125
+ const value = require_typed_util.attr(item, "w:displayText") ?? require_typed_util.attr(item, "w:value");
126
+ if (value !== void 0) options.push(require_typed_util.decodeEntities(value));
127
+ }
128
+ return options.length === 0 ? void 0 : options;
129
+ }
130
+ function readCheckboxState(sdtPr) {
131
+ const checkbox = require_typed_util.childrenWithTag(sdtPr, "w14:checkbox")[0] ?? require_typed_util.childrenWithTag(sdtPr, "w:checkbox")[0];
132
+ if (checkbox === void 0) return;
133
+ const checked = require_typed_util.childrenWithTag(checkbox, "w14:checked")[0] ?? require_typed_util.childrenWithTag(checkbox, "w:checked")[0];
134
+ if (checked === void 0) return false;
135
+ const val = require_typed_util.attr(checked, "w14:val") ?? require_typed_util.attr(checked, "w:val");
136
+ return val === void 0 || val !== "0" && val !== "false" && val !== "off";
137
+ }
138
+ function readContentControlDescriptor(sdt) {
139
+ const sdtPr = require_typed_util.childrenWithTag(sdt, "w:sdtPr")[0];
140
+ const descriptor = {
141
+ kind: "contentControl",
142
+ controlType: readControlType(sdtPr)
143
+ };
144
+ if (sdtPr === void 0) return descriptor;
145
+ const tag = require_typed_util.childrenWithTag(sdtPr, "w:tag")[0];
146
+ const tagVal = tag === void 0 ? void 0 : require_typed_util.attr(tag, "w:val");
147
+ if (tagVal !== void 0) descriptor.tag = require_typed_util.decodeEntities(tagVal);
148
+ const alias = require_typed_util.childrenWithTag(sdtPr, "w:alias")[0];
149
+ const aliasVal = alias === void 0 ? void 0 : require_typed_util.attr(alias, "w:val");
150
+ if (aliasVal !== void 0) descriptor.alias = require_typed_util.decodeEntities(aliasVal);
151
+ const lock = require_typed_util.childrenWithTag(sdtPr, "w:lock")[0];
152
+ const lockVal = lock === void 0 ? void 0 : require_typed_util.attr(lock, "w:val");
153
+ const mappedLock = lockVal === void 0 ? void 0 : LOCK_BY_VALUE.get(lockVal);
154
+ if (mappedLock !== void 0) descriptor.lock = mappedLock;
155
+ const options = readListItemOptions(sdtPr);
156
+ if (options !== void 0) descriptor.options = options;
157
+ const checked = readCheckboxState(sdtPr);
158
+ if (checked !== void 0) descriptor.checked = checked;
159
+ const date = require_typed_util.childrenWithTag(sdtPr, "w:date")[0];
160
+ const fullDate = date === void 0 ? void 0 : require_typed_util.attr(date, "w:fullDate");
161
+ if (fullDate !== void 0) descriptor.value = require_typed_util.decodeEntities(fullDate);
162
+ return descriptor;
163
+ }
164
+ const PROVENANCE_CHANGE_BY_TAG = /* @__PURE__ */ new Map([
165
+ ["w:ins", "insertion"],
166
+ ["w:del", "deletion"],
167
+ ["w:moveFrom", "moveFrom"],
168
+ ["w:moveTo", "moveTo"]
169
+ ]);
170
+ function isDeletedChange(change) {
171
+ return change === "deletion" || change === "moveFrom";
172
+ }
173
+ function readProvenanceDescriptor(element, change) {
174
+ const descriptor = {
175
+ kind: "provenance",
176
+ change
177
+ };
178
+ const author = require_typed_util.attr(element, "w:author");
179
+ if (author !== void 0) descriptor.author = require_typed_util.decodeEntities(author);
180
+ const date = require_typed_util.attr(element, "w:date");
181
+ if (date !== void 0) descriptor.dateIso = require_typed_util.decodeEntities(date);
182
+ return descriptor;
183
+ }
184
+ function bookmarkAnchorDescriptor(name) {
185
+ return {
186
+ kind: "anchor",
187
+ anchorType: "bookmark",
188
+ name
189
+ };
190
+ }
191
+ function runInstructionText(run) {
192
+ let text = "";
193
+ for (const child of run.children) if (child.type === "element" && (child.tag === "w:instrText" || child.tag === "w:delInstrText")) text += require_typed_util.textContent(child);
194
+ return text;
195
+ }
196
+ function fieldCharType(run) {
197
+ const fldChar = require_typed_util.childrenWithTag(run, "w:fldChar")[0];
198
+ return fldChar === void 0 ? void 0 : require_typed_util.attr(fldChar, "w:fldCharType");
199
+ }
200
+ //#endregion
201
+ exports.PROVENANCE_CHANGE_BY_TAG = PROVENANCE_CHANGE_BY_TAG;
202
+ exports.TABLE_OF_CONTENTS_GALLERY = TABLE_OF_CONTENTS_GALLERY;
203
+ exports.bookmarkAnchorDescriptor = bookmarkAnchorDescriptor;
204
+ exports.contentBearingChildren = contentBearingChildren;
205
+ exports.fieldCharType = fieldCharType;
206
+ exports.indexParagraphContent = indexParagraphContent;
207
+ exports.insertConstructMarkers = insertConstructMarkers;
208
+ exports.isDeletedChange = isDeletedChange;
209
+ exports.readContentControlDescriptor = readContentControlDescriptor;
210
+ exports.readProvenanceDescriptor = readProvenanceDescriptor;
211
+ exports.runInstructionText = runInstructionText;
@@ -0,0 +1,27 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
2
+ import { AnchorDescriptor, ConstructDescriptor, ContentBlock, ContentControlDescriptor, ProvenanceChange, ProvenanceDescriptor } from "document-schema.js";
3
+ //#region src/typed/docx/constructs.d.ts
4
+ interface ParagraphContentIndex {
5
+ readonly elements: readonly XmlElement[];
6
+ readonly firstContentIndex: number;
7
+ readonly lastContentIndex: number;
8
+ }
9
+ declare function indexParagraphContent(paragraph: XmlElement): ParagraphContentIndex;
10
+ declare function contentBearingChildren(index: ParagraphContentIndex): XmlElement[];
11
+ interface ConstructExtent {
12
+ readonly startIndex: number;
13
+ readonly endIndex: number;
14
+ readonly order: number;
15
+ readonly descriptor: ConstructDescriptor;
16
+ }
17
+ declare function insertConstructMarkers(blocks: readonly ContentBlock[], extents: readonly ConstructExtent[]): ContentBlock[];
18
+ declare const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
19
+ declare function readContentControlDescriptor(sdt: XmlElement): ContentControlDescriptor;
20
+ declare const PROVENANCE_CHANGE_BY_TAG: ReadonlyMap<string, ProvenanceChange>;
21
+ declare function isDeletedChange(change: ProvenanceChange): boolean;
22
+ declare function readProvenanceDescriptor(element: XmlElement, change: ProvenanceChange): ProvenanceDescriptor;
23
+ declare function bookmarkAnchorDescriptor(name: string): AnchorDescriptor;
24
+ declare function runInstructionText(run: XmlElement): string;
25
+ declare function fieldCharType(run: XmlElement): string | undefined;
26
+ //#endregion
27
+ export { ConstructExtent, PROVENANCE_CHANGE_BY_TAG, ParagraphContentIndex, TABLE_OF_CONTENTS_GALLERY, bookmarkAnchorDescriptor, contentBearingChildren, fieldCharType, indexParagraphContent, insertConstructMarkers, isDeletedChange, readContentControlDescriptor, readProvenanceDescriptor, runInstructionText };
@@ -0,0 +1,27 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.js";
2
+ import { AnchorDescriptor, ConstructDescriptor, ContentBlock, ContentControlDescriptor, ProvenanceChange, ProvenanceDescriptor } from "document-schema.js";
3
+ //#region src/typed/docx/constructs.d.ts
4
+ interface ParagraphContentIndex {
5
+ readonly elements: readonly XmlElement[];
6
+ readonly firstContentIndex: number;
7
+ readonly lastContentIndex: number;
8
+ }
9
+ declare function indexParagraphContent(paragraph: XmlElement): ParagraphContentIndex;
10
+ declare function contentBearingChildren(index: ParagraphContentIndex): XmlElement[];
11
+ interface ConstructExtent {
12
+ readonly startIndex: number;
13
+ readonly endIndex: number;
14
+ readonly order: number;
15
+ readonly descriptor: ConstructDescriptor;
16
+ }
17
+ declare function insertConstructMarkers(blocks: readonly ContentBlock[], extents: readonly ConstructExtent[]): ContentBlock[];
18
+ declare const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
19
+ declare function readContentControlDescriptor(sdt: XmlElement): ContentControlDescriptor;
20
+ declare const PROVENANCE_CHANGE_BY_TAG: ReadonlyMap<string, ProvenanceChange>;
21
+ declare function isDeletedChange(change: ProvenanceChange): boolean;
22
+ declare function readProvenanceDescriptor(element: XmlElement, change: ProvenanceChange): ProvenanceDescriptor;
23
+ declare function bookmarkAnchorDescriptor(name: string): AnchorDescriptor;
24
+ declare function runInstructionText(run: XmlElement): string;
25
+ declare function fieldCharType(run: XmlElement): string | undefined;
26
+ //#endregion
27
+ export { ConstructExtent, PROVENANCE_CHANGE_BY_TAG, ParagraphContentIndex, TABLE_OF_CONTENTS_GALLERY, bookmarkAnchorDescriptor, contentBearingChildren, fieldCharType, indexParagraphContent, insertConstructMarkers, isDeletedChange, readContentControlDescriptor, readProvenanceDescriptor, runInstructionText };
@@ -0,0 +1,200 @@
1
+ import { attr, childrenWithTag, decodeEntities, textContent } from "../util.js";
2
+ //#region src/typed/docx/constructs.ts
3
+ const NON_CONTENT_PARAGRAPH_CHILDREN = /* @__PURE__ */ new Set([
4
+ "w:pPr",
5
+ "w:bookmarkStart",
6
+ "w:bookmarkEnd",
7
+ "w:commentRangeStart",
8
+ "w:commentRangeEnd",
9
+ "w:proofErr",
10
+ "w:permStart",
11
+ "w:permEnd",
12
+ "w:moveFromRangeStart",
13
+ "w:moveFromRangeEnd",
14
+ "w:moveToRangeStart",
15
+ "w:moveToRangeEnd"
16
+ ]);
17
+ const INERT_RUN_CHILDREN = /* @__PURE__ */ new Set(["w:rPr", "w:lastRenderedPageBreak"]);
18
+ function isContentBearingChild(child) {
19
+ if (NON_CONTENT_PARAGRAPH_CHILDREN.has(child.tag)) return false;
20
+ if (child.tag !== "w:r") return true;
21
+ return child.children.some((grandChild) => grandChild.type === "element" && !INERT_RUN_CHILDREN.has(grandChild.tag));
22
+ }
23
+ function indexParagraphContent(paragraph) {
24
+ const elements = [];
25
+ for (const child of paragraph.children) if (child.type === "element") elements.push(child);
26
+ let firstContentIndex = -1;
27
+ let lastContentIndex = -1;
28
+ elements.forEach((element, index) => {
29
+ if (!isContentBearingChild(element)) return;
30
+ if (firstContentIndex === -1) firstContentIndex = index;
31
+ lastContentIndex = index;
32
+ });
33
+ return {
34
+ elements,
35
+ firstContentIndex,
36
+ lastContentIndex
37
+ };
38
+ }
39
+ function contentBearingChildren(index) {
40
+ return index.elements.filter(isContentBearingChild);
41
+ }
42
+ function compareExtents(a, b) {
43
+ return a.startIndex - b.startIndex || b.endIndex - a.endIndex || a.order - b.order;
44
+ }
45
+ function acceptProperlyNested(extents) {
46
+ const sorted = [...extents].sort(compareExtents);
47
+ const accepted = [];
48
+ const open = [];
49
+ for (const extent of sorted) {
50
+ while (open.length > 0 && open[open.length - 1].endIndex <= extent.startIndex) open.pop();
51
+ const enclosing = open[open.length - 1];
52
+ if (enclosing !== void 0 && enclosing.endIndex < extent.endIndex) continue;
53
+ accepted.push(extent);
54
+ open.push(extent);
55
+ }
56
+ return accepted;
57
+ }
58
+ function insertConstructMarkers(blocks, extents) {
59
+ if (extents.length === 0) return [...blocks];
60
+ const nested = acceptProperlyNested(extents);
61
+ const openingAt = /* @__PURE__ */ new Map();
62
+ for (const extent of nested) {
63
+ const existing = openingAt.get(extent.startIndex);
64
+ if (existing === void 0) openingAt.set(extent.startIndex, [extent]);
65
+ else existing.push(extent);
66
+ }
67
+ const out = [];
68
+ const open = [];
69
+ for (let index = 0; index <= blocks.length; index++) {
70
+ while (open.length > 0 && open[open.length - 1].endIndex === index) {
71
+ open.pop();
72
+ out.push({ kind: "constructEnd" });
73
+ }
74
+ for (const extent of openingAt.get(index) ?? []) {
75
+ out.push({
76
+ kind: "constructStart",
77
+ descriptor: extent.descriptor
78
+ });
79
+ if (extent.endIndex === index) out.push({ kind: "constructEnd" });
80
+ else open.push(extent);
81
+ }
82
+ const block = blocks[index];
83
+ if (block !== void 0) out.push(block);
84
+ }
85
+ return out;
86
+ }
87
+ const CONTROL_TYPE_BY_TAG = /* @__PURE__ */ new Map([
88
+ ["w:richText", "richText"],
89
+ ["w:text", "plainText"],
90
+ ["w:comboBox", "comboBox"],
91
+ ["w:dropDownList", "dropDown"],
92
+ ["w:date", "date"],
93
+ ["w:picture", "picture"],
94
+ ["w:group", "group"],
95
+ ["w:checkbox", "checkbox"],
96
+ ["w14:checkbox", "checkbox"],
97
+ ["w:repeatingSection", "repeatingSection"],
98
+ ["w15:repeatingSection", "repeatingSection"]
99
+ ]);
100
+ const LOCK_BY_VALUE = /* @__PURE__ */ new Map([
101
+ ["contentLocked", "content"],
102
+ ["sdtLocked", "container"],
103
+ ["sdtContentLocked", "both"]
104
+ ]);
105
+ const TABLE_OF_CONTENTS_GALLERY = "Table of Contents";
106
+ function readControlType(sdtPr) {
107
+ if (sdtPr === void 0) return "richText";
108
+ for (const child of sdtPr.children) {
109
+ if (child.type !== "element") continue;
110
+ const mapped = CONTROL_TYPE_BY_TAG.get(child.tag);
111
+ if (mapped !== void 0) return mapped;
112
+ if (child.tag === "w:docPartObj" || child.tag === "w:docPartList") {
113
+ const gallery = childrenWithTag(child, "w:docPartGallery")[0];
114
+ return (gallery === void 0 ? void 0 : attr(gallery, "w:val")) === "Table of Contents" ? "index" : "richText";
115
+ }
116
+ }
117
+ return "richText";
118
+ }
119
+ function readListItemOptions(sdtPr) {
120
+ const list = childrenWithTag(sdtPr, "w:dropDownList")[0] ?? childrenWithTag(sdtPr, "w:comboBox")[0];
121
+ if (list === void 0) return;
122
+ const options = [];
123
+ for (const item of childrenWithTag(list, "w:listItem")) {
124
+ const value = attr(item, "w:displayText") ?? attr(item, "w:value");
125
+ if (value !== void 0) options.push(decodeEntities(value));
126
+ }
127
+ return options.length === 0 ? void 0 : options;
128
+ }
129
+ function readCheckboxState(sdtPr) {
130
+ const checkbox = childrenWithTag(sdtPr, "w14:checkbox")[0] ?? childrenWithTag(sdtPr, "w:checkbox")[0];
131
+ if (checkbox === void 0) return;
132
+ const checked = childrenWithTag(checkbox, "w14:checked")[0] ?? childrenWithTag(checkbox, "w:checked")[0];
133
+ if (checked === void 0) return false;
134
+ const val = attr(checked, "w14:val") ?? attr(checked, "w:val");
135
+ return val === void 0 || val !== "0" && val !== "false" && val !== "off";
136
+ }
137
+ function readContentControlDescriptor(sdt) {
138
+ const sdtPr = childrenWithTag(sdt, "w:sdtPr")[0];
139
+ const descriptor = {
140
+ kind: "contentControl",
141
+ controlType: readControlType(sdtPr)
142
+ };
143
+ if (sdtPr === void 0) return descriptor;
144
+ const tag = childrenWithTag(sdtPr, "w:tag")[0];
145
+ const tagVal = tag === void 0 ? void 0 : attr(tag, "w:val");
146
+ if (tagVal !== void 0) descriptor.tag = decodeEntities(tagVal);
147
+ const alias = childrenWithTag(sdtPr, "w:alias")[0];
148
+ const aliasVal = alias === void 0 ? void 0 : attr(alias, "w:val");
149
+ if (aliasVal !== void 0) descriptor.alias = decodeEntities(aliasVal);
150
+ const lock = childrenWithTag(sdtPr, "w:lock")[0];
151
+ const lockVal = lock === void 0 ? void 0 : attr(lock, "w:val");
152
+ const mappedLock = lockVal === void 0 ? void 0 : LOCK_BY_VALUE.get(lockVal);
153
+ if (mappedLock !== void 0) descriptor.lock = mappedLock;
154
+ const options = readListItemOptions(sdtPr);
155
+ if (options !== void 0) descriptor.options = options;
156
+ const checked = readCheckboxState(sdtPr);
157
+ if (checked !== void 0) descriptor.checked = checked;
158
+ const date = childrenWithTag(sdtPr, "w:date")[0];
159
+ const fullDate = date === void 0 ? void 0 : attr(date, "w:fullDate");
160
+ if (fullDate !== void 0) descriptor.value = decodeEntities(fullDate);
161
+ return descriptor;
162
+ }
163
+ const PROVENANCE_CHANGE_BY_TAG = /* @__PURE__ */ new Map([
164
+ ["w:ins", "insertion"],
165
+ ["w:del", "deletion"],
166
+ ["w:moveFrom", "moveFrom"],
167
+ ["w:moveTo", "moveTo"]
168
+ ]);
169
+ function isDeletedChange(change) {
170
+ return change === "deletion" || change === "moveFrom";
171
+ }
172
+ function readProvenanceDescriptor(element, change) {
173
+ const descriptor = {
174
+ kind: "provenance",
175
+ change
176
+ };
177
+ const author = attr(element, "w:author");
178
+ if (author !== void 0) descriptor.author = decodeEntities(author);
179
+ const date = attr(element, "w:date");
180
+ if (date !== void 0) descriptor.dateIso = decodeEntities(date);
181
+ return descriptor;
182
+ }
183
+ function bookmarkAnchorDescriptor(name) {
184
+ return {
185
+ kind: "anchor",
186
+ anchorType: "bookmark",
187
+ name
188
+ };
189
+ }
190
+ function runInstructionText(run) {
191
+ let text = "";
192
+ for (const child of run.children) if (child.type === "element" && (child.tag === "w:instrText" || child.tag === "w:delInstrText")) text += textContent(child);
193
+ return text;
194
+ }
195
+ function fieldCharType(run) {
196
+ const fldChar = childrenWithTag(run, "w:fldChar")[0];
197
+ return fldChar === void 0 ? void 0 : attr(fldChar, "w:fldCharType");
198
+ }
199
+ //#endregion
200
+ export { PROVENANCE_CHANGE_BY_TAG, TABLE_OF_CONTENTS_GALLERY, bookmarkAnchorDescriptor, contentBearingChildren, fieldCharType, indexParagraphContent, insertConstructMarkers, isDeletedChange, readContentControlDescriptor, readProvenanceDescriptor, runInstructionText };