@stll/folio-core 0.44.0 → 0.46.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 (263) hide show
  1. package/dist/ai-edits/__fixtures__/paragraphs.js +2 -2
  2. package/dist/ai-edits/apply.js +59 -19
  3. package/dist/ai-edits/headless.js +2 -1
  4. package/dist/compare/compare.js +2 -5
  5. package/dist/compare/content-alignment.js +78 -53
  6. package/dist/compare/inline-atoms.js +34 -20
  7. package/dist/compare/scenario.js +2 -5
  8. package/dist/compare/types.d.ts +9 -1
  9. package/dist/compare/types.js +12 -1
  10. package/dist/compat/eigenpal.d.ts +2 -1
  11. package/dist/compat/eigenpal.js +2 -1
  12. package/dist/content-controls/checkboxDisplay.d.ts +11 -0
  13. package/dist/content-controls/checkboxDisplay.js +40 -0
  14. package/dist/content-controls/findContentControls.js +3 -1
  15. package/dist/content-controls/mutateContentControls.js +21 -4
  16. package/dist/controller/contentControlWidgetController.d.ts +1 -0
  17. package/dist/controller/contentControlWidgetController.js +3 -0
  18. package/dist/controller/hiddenEditorApi.js +3 -1
  19. package/dist/controller/hiddenEditorManager.d.ts +1 -1
  20. package/dist/controller/hiddenEditorManager.js +6 -3
  21. package/dist/display-list/build/buildDisplayList.js +20 -1
  22. package/dist/display-list/build/imagePrimitives.d.ts +1 -1
  23. package/dist/display-list/build/imagePrimitives.js +3 -1
  24. package/dist/display-list/build/paragraphPrimitives.js +21 -2
  25. package/dist/display-list/dom/renderDisplayListToDom.js +18 -10
  26. package/dist/display-list/types.d.ts +17 -0
  27. package/dist/document-operations.js +14 -3
  28. package/dist/docx/attributeRemainder.d.ts +43 -0
  29. package/dist/docx/attributeRemainder.js +65 -0
  30. package/dist/docx/blockContentParser.d.ts +1 -1
  31. package/dist/docx/blockContentParser.js +87 -63
  32. package/dist/docx/blockPlainText.d.ts +3 -4
  33. package/dist/docx/blockPlainText.js +1 -0
  34. package/dist/docx/bookmarkPlacement.js +2 -0
  35. package/dist/docx/borderParser.js +5 -5
  36. package/dist/docx/commentAnchorIndex.d.ts +30 -0
  37. package/dist/docx/commentAnchorIndex.js +50 -0
  38. package/dist/docx/commentParser.d.ts +1 -1
  39. package/dist/docx/commentParser.js +78 -50
  40. package/dist/docx/commentRangeIntegrity.d.ts +16 -1
  41. package/dist/docx/commentRangeIntegrity.js +42 -1
  42. package/dist/docx/commentRangeJoin.d.ts +9 -0
  43. package/dist/docx/commentRangeJoin.js +33 -0
  44. package/dist/docx/commentReferenceCompletion.d.ts +9 -0
  45. package/dist/docx/commentReferenceCompletion.js +47 -0
  46. package/dist/docx/commentReferenceNormalization.js +1 -0
  47. package/dist/docx/commentReplyMarkers.js +11 -19
  48. package/dist/docx/commentThreadKey.d.ts +18 -0
  49. package/dist/docx/commentThreadKey.js +22 -0
  50. package/dist/docx/compatibility.js +1 -0
  51. package/dist/docx/containerChildren.d.ts +111 -0
  52. package/dist/docx/containerChildren.gen.d.ts +28 -0
  53. package/dist/docx/containerChildren.gen.js +246 -0
  54. package/dist/docx/containerChildren.js +103 -0
  55. package/dist/docx/diagramPreview.js +87 -27
  56. package/dist/docx/documentParser.d.ts +1 -1
  57. package/dist/docx/documentParser.js +3 -3
  58. package/dist/docx/ensureParaIds.js +17 -7
  59. package/dist/docx/fieldParser.d.ts +1 -1
  60. package/dist/docx/fieldParser.js +4 -4
  61. package/dist/docx/fieldState.d.ts +26 -0
  62. package/dist/docx/fieldState.js +53 -0
  63. package/dist/docx/footnoteParser.d.ts +1 -1
  64. package/dist/docx/graphicFrameLocks.d.ts +16 -4
  65. package/dist/docx/graphicFrameLocks.js +19 -6
  66. package/dist/docx/groupDrawingParser.js +3 -3
  67. package/dist/docx/headerFooterParser.js +1 -1
  68. package/dist/docx/headerFooterReferenceNormalization.js +1 -0
  69. package/dist/docx/hyperlinkParser.d.ts +27 -8
  70. package/dist/docx/hyperlinkParser.js +78 -20
  71. package/dist/docx/imageParser.d.ts +9 -1
  72. package/dist/docx/imageParser.js +91 -20
  73. package/dist/docx/imageRawXml.d.ts +14 -1
  74. package/dist/docx/imageRawXml.js +30 -6
  75. package/dist/docx/inlineWrapperContent.d.ts +85 -0
  76. package/dist/docx/inlineWrapperContent.js +84 -0
  77. package/dist/docx/mathToMathml.js +12 -14
  78. package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
  79. package/dist/docx/nonVisualDrawingProps.js +46 -0
  80. package/dist/docx/normalizeBaseDirection.js +10 -1
  81. package/dist/docx/paraIdAttribute.d.ts +21 -0
  82. package/dist/docx/paraIdAttribute.js +64 -0
  83. package/dist/docx/paragraphParser.d.ts +1 -1
  84. package/dist/docx/paragraphParser.js +277 -168
  85. package/dist/docx/paragraphPropertySource.js +5 -1
  86. package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
  87. package/dist/docx/paragraphTextBoxEnrichment.js +9 -52
  88. package/dist/docx/paragraphTraversal.js +7 -4
  89. package/dist/docx/parseWarningMessage.js +2 -1
  90. package/dist/docx/parser.js +2 -2
  91. package/dist/docx/preservedRunContent.d.ts +32 -0
  92. package/dist/docx/preservedRunContent.js +86 -0
  93. package/dist/docx/previewBudget.d.ts +64 -0
  94. package/dist/docx/previewBudget.js +88 -0
  95. package/dist/docx/renderedPageBreakNormalization.js +2 -4
  96. package/dist/docx/revisionIdNormalization.js +17 -5
  97. package/dist/docx/rezip.js +91 -36
  98. package/dist/docx/runParser.d.ts +1 -1
  99. package/dist/docx/runParser.js +16 -12
  100. package/dist/docx/sdtPropertiesPatch.js +24 -18
  101. package/dist/docx/sectionParser.js +8 -1
  102. package/dist/docx/sectionReferenceHistory.js +2 -2
  103. package/dist/docx/selectiveSave.js +6 -6
  104. package/dist/docx/selectiveXmlPatch.d.ts +46 -2
  105. package/dist/docx/selectiveXmlPatch.js +86 -39
  106. package/dist/docx/serializer/blockSdtSerializer.js +38 -26
  107. package/dist/docx/serializer/borderSerializer.d.ts +1 -1
  108. package/dist/docx/serializer/borderSerializer.js +15 -14
  109. package/dist/docx/serializer/commentSerializer.d.ts +41 -16
  110. package/dist/docx/serializer/commentSerializer.js +87 -92
  111. package/dist/docx/serializer/documentSerializer.js +8 -11
  112. package/dist/docx/serializer/fontTableSerializer.js +6 -6
  113. package/dist/docx/serializer/headerFooterSerializer.js +12 -14
  114. package/dist/docx/serializer/markupRangeAttributes.js +2 -2
  115. package/dist/docx/serializer/noteSerializer.js +8 -8
  116. package/dist/docx/serializer/numberingSerializer.js +7 -6
  117. package/dist/docx/serializer/paragraphSerializer.js +93 -72
  118. package/dist/docx/serializer/partNamespaces.js +2 -2
  119. package/dist/docx/serializer/runSerializer.js +73 -44
  120. package/dist/docx/serializer/sectionPropertiesSerializer.js +19 -14
  121. package/dist/docx/serializer/settingsSerializer.js +4 -3
  122. package/dist/docx/serializer/stylesSerializer.js +6 -6
  123. package/dist/docx/serializer/tableSerializer.js +28 -17
  124. package/dist/docx/serializer/textFormattingSerializer.js +29 -28
  125. package/dist/docx/serializer/themeSerializer.js +6 -6
  126. package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
  127. package/dist/docx/serializer/xmlUtils.d.ts +1 -2
  128. package/dist/docx/serializer/xmlUtils.js +1 -13
  129. package/dist/docx/server/boundedArchive.d.ts +12 -0
  130. package/dist/docx/server/boundedArchive.js +20 -1
  131. package/dist/docx/server/createBilingualDocument.js +3 -1
  132. package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
  133. package/dist/docx/server/materializeYjsDocx.js +9 -1
  134. package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
  135. package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
  136. package/dist/docx/server/validateDocxConformance.js +22 -1
  137. package/dist/docx/shapeParser.js +12 -10
  138. package/dist/docx/tableParser.d.ts +1 -1
  139. package/dist/docx/tableParser.js +206 -85
  140. package/dist/docx/textBoxParser.d.ts +25 -2
  141. package/dist/docx/textBoxParser.js +59 -4
  142. package/dist/docx/unzip.d.ts +23 -0
  143. package/dist/docx/unzip.js +37 -26
  144. package/dist/docx/verbatimCapture.js +1 -1
  145. package/dist/docx/vmlImageParser.d.ts +17 -1
  146. package/dist/docx/vmlImageParser.js +20 -3
  147. package/dist/docx/vmlPreview.d.ts +1 -3
  148. package/dist/docx/vmlPreview.js +2 -30
  149. package/dist/docx/xmlEncoding.d.ts +5 -0
  150. package/dist/docx/xmlEncoding.js +12 -0
  151. package/dist/docx/xmlParser.d.ts +26 -2
  152. package/dist/docx/xmlParser.js +70 -27
  153. package/dist/docx/xmlResourceLimits.d.ts +89 -9
  154. package/dist/docx/xmlResourceLimits.js +105 -24
  155. package/dist/headless-layout.js +10 -1
  156. package/dist/index.d.ts +2 -1
  157. package/dist/index.js +2 -1
  158. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
  159. package/dist/internal/paragraphFormattingSerialization.js +3 -2
  160. package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
  161. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  162. package/dist/layout-engine/measure/tableCellFloating.js +2 -0
  163. package/dist/layout-engine/types.d.ts +23 -1
  164. package/dist/layout-painter/renderImage.d.ts +5 -1
  165. package/dist/layout-painter/renderImage.js +14 -6
  166. package/dist/layout-painter/renderPage.d.ts +2 -0
  167. package/dist/layout-painter/renderPage.js +4 -0
  168. package/dist/layout-painter/renderParagraph.d.ts +13 -1
  169. package/dist/layout-painter/renderParagraph.js +26 -6
  170. package/dist/managers/autoSaveCodec.d.ts +9 -1
  171. package/dist/managers/autoSaveCodec.js +14 -12
  172. package/dist/markdown/images.js +1 -4
  173. package/dist/markdown/renderBlock.js +1 -0
  174. package/dist/markdown/renderRuns.d.ts +1 -1
  175. package/dist/markdown/renderRuns.js +28 -5
  176. package/dist/markdown/renderTable.js +22 -5
  177. package/dist/markdown/trailers.js +4 -1
  178. package/dist/pdf/images.js +142 -6
  179. package/dist/prosemirror/attrs/index.d.ts +14 -3
  180. package/dist/prosemirror/attrs/index.js +224 -2
  181. package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
  182. package/dist/prosemirror/authoredTransformAttrs.js +64 -0
  183. package/dist/prosemirror/commands/contentControls.js +10 -2
  184. package/dist/prosemirror/commands/image.d.ts +9 -2
  185. package/dist/prosemirror/commands/image.js +43 -28
  186. package/dist/prosemirror/commands/pageBreak.js +1 -1
  187. package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
  188. package/dist/prosemirror/commentReferenceAttrs.js +33 -0
  189. package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
  190. package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
  191. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
  192. package/dist/prosemirror/conversion/fromProseDoc.js +338 -99
  193. package/dist/prosemirror/conversion/index.d.ts +2 -2
  194. package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
  195. package/dist/prosemirror/conversion/toProseDoc.js +551 -327
  196. package/dist/prosemirror/extensions/StarterKit.js +8 -58
  197. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  198. package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
  199. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
  200. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
  201. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
  202. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
  203. package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
  204. package/dist/prosemirror/extensions/markRegistry.js +75 -0
  205. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
  206. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
  207. package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
  208. package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
  209. package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
  210. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
  211. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
  212. package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
  213. package/dist/prosemirror/extensions/nodes/ImageExtension.js +20 -0
  214. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
  215. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
  216. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
  217. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
  218. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +10 -2
  219. package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
  220. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +13 -5
  221. package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
  222. package/dist/prosemirror/inlineWrapperStack.js +75 -0
  223. package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
  224. package/dist/prosemirror/pageBreakRunProjection.js +19 -9
  225. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +6 -3
  226. package/dist/prosemirror/paragraphFormattingProvenance.js +12 -3
  227. package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
  228. package/dist/prosemirror/replacedAnnotations.js +165 -0
  229. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
  230. package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
  231. package/dist/prosemirror/schema/index.d.ts +3 -3
  232. package/dist/prosemirror/schema/marks.d.ts +25 -1
  233. package/dist/prosemirror/schema/nodes.d.ts +139 -3
  234. package/dist/prosemirror/schema/nodes.js +16 -1
  235. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
  236. package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
  237. package/dist/prosemirror/validation.js +16 -2
  238. package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
  239. package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
  240. package/dist/prosemirror/zeroWidthAnchors.js +2 -0
  241. package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
  242. package/dist/render-dom/commentAnchorAttributes.js +54 -0
  243. package/dist/server.d.ts +3 -1
  244. package/dist/server.js +3 -1
  245. package/dist/types/content.d.ts +2 -2
  246. package/dist/utils/base64.d.ts +36 -0
  247. package/dist/utils/base64.js +40 -0
  248. package/dist/utils/clipboard.d.ts +9 -1
  249. package/dist/utils/clipboard.js +29 -2
  250. package/dist/utils/findReplace.js +1 -1
  251. package/dist/utils/imageLuminance.d.ts +15 -0
  252. package/dist/utils/imageLuminance.js +32 -0
  253. package/dist/utils/mergeDocumentContent.js +7 -17
  254. package/dist/utils/replaceText.js +1 -0
  255. package/dist/utils/units.d.ts +10 -1
  256. package/dist/utils/units.js +12 -1
  257. package/dist/utils/urlSecurity.d.ts +8 -2
  258. package/dist/utils/urlSecurity.js +21 -3
  259. package/package.json +2 -2
  260. package/dist/docx/blockRangeMarkers.d.ts +0 -36
  261. package/dist/docx/blockRangeMarkers.js +0 -59
  262. package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
  263. package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
@@ -0,0 +1,246 @@
1
+ //#region src/docx/containerChildren.gen.ts
2
+ /**
3
+ * GENERATED FILE — do not edit.
4
+ *
5
+ * Every child the Transitional content model declares for a container folio
6
+ * dispatches, derived from the committed schema graph by
7
+ * `scripts/generate-container-children.ts`. The shared child dispatcher makes
8
+ * a handler map total over these names, so a container cannot gain a declared
9
+ * child without somebody deciding whether it is modelled or captured.
10
+ * Regenerate with:
11
+ *
12
+ * bun run generate:container-children
13
+ */
14
+ const CONTAINER_CHILDREN = {
15
+ "w:comment": [
16
+ "altChunk",
17
+ "bookmarkEnd",
18
+ "bookmarkStart",
19
+ "commentRangeEnd",
20
+ "commentRangeStart",
21
+ "customXml",
22
+ "customXmlDelRangeEnd",
23
+ "customXmlDelRangeStart",
24
+ "customXmlInsRangeEnd",
25
+ "customXmlInsRangeStart",
26
+ "customXmlMoveFromRangeEnd",
27
+ "customXmlMoveFromRangeStart",
28
+ "customXmlMoveToRangeEnd",
29
+ "customXmlMoveToRangeStart",
30
+ "del",
31
+ "ins",
32
+ "moveFrom",
33
+ "moveFromRangeEnd",
34
+ "moveFromRangeStart",
35
+ "moveTo",
36
+ "moveToRangeEnd",
37
+ "moveToRangeStart",
38
+ "p",
39
+ "permEnd",
40
+ "permStart",
41
+ "proofErr",
42
+ "sdt",
43
+ "tbl"
44
+ ],
45
+ "run-level-content": [
46
+ "bdo",
47
+ "bookmarkEnd",
48
+ "bookmarkStart",
49
+ "commentRangeEnd",
50
+ "commentRangeStart",
51
+ "customXml",
52
+ "customXmlDelRangeEnd",
53
+ "customXmlDelRangeStart",
54
+ "customXmlInsRangeEnd",
55
+ "customXmlInsRangeStart",
56
+ "customXmlMoveFromRangeEnd",
57
+ "customXmlMoveFromRangeStart",
58
+ "customXmlMoveToRangeEnd",
59
+ "customXmlMoveToRangeStart",
60
+ "del",
61
+ "dir",
62
+ "fldSimple",
63
+ "hyperlink",
64
+ "ins",
65
+ "moveFrom",
66
+ "moveFromRangeEnd",
67
+ "moveFromRangeStart",
68
+ "moveTo",
69
+ "moveToRangeEnd",
70
+ "moveToRangeStart",
71
+ "pPr",
72
+ "permEnd",
73
+ "permStart",
74
+ "proofErr",
75
+ "r",
76
+ "sdt",
77
+ "smartTag",
78
+ "smartTagPr",
79
+ "subDoc"
80
+ ],
81
+ "table-content": [
82
+ "bookmarkEnd",
83
+ "bookmarkStart",
84
+ "commentRangeEnd",
85
+ "commentRangeStart",
86
+ "customXml",
87
+ "customXmlDelRangeEnd",
88
+ "customXmlDelRangeStart",
89
+ "customXmlInsRangeEnd",
90
+ "customXmlInsRangeStart",
91
+ "customXmlMoveFromRangeEnd",
92
+ "customXmlMoveFromRangeStart",
93
+ "customXmlMoveToRangeEnd",
94
+ "customXmlMoveToRangeStart",
95
+ "customXmlPr",
96
+ "del",
97
+ "ins",
98
+ "moveFrom",
99
+ "moveFromRangeEnd",
100
+ "moveFromRangeStart",
101
+ "moveTo",
102
+ "moveToRangeEnd",
103
+ "moveToRangeStart",
104
+ "permEnd",
105
+ "permStart",
106
+ "proofErr",
107
+ "sdt",
108
+ "tblGrid",
109
+ "tblPr",
110
+ "tr"
111
+ ],
112
+ "row-content": [
113
+ "bookmarkEnd",
114
+ "bookmarkStart",
115
+ "commentRangeEnd",
116
+ "commentRangeStart",
117
+ "customXml",
118
+ "customXmlDelRangeEnd",
119
+ "customXmlDelRangeStart",
120
+ "customXmlInsRangeEnd",
121
+ "customXmlInsRangeStart",
122
+ "customXmlMoveFromRangeEnd",
123
+ "customXmlMoveFromRangeStart",
124
+ "customXmlMoveToRangeEnd",
125
+ "customXmlMoveToRangeStart",
126
+ "del",
127
+ "ins",
128
+ "moveFrom",
129
+ "moveFromRangeEnd",
130
+ "moveFromRangeStart",
131
+ "moveTo",
132
+ "moveToRangeEnd",
133
+ "moveToRangeStart",
134
+ "permEnd",
135
+ "permStart",
136
+ "proofErr",
137
+ "sdt",
138
+ "tblPrEx",
139
+ "tc",
140
+ "tr",
141
+ "trPr"
142
+ ],
143
+ "w:hyperlink": [
144
+ "bdo",
145
+ "bookmarkEnd",
146
+ "bookmarkStart",
147
+ "commentRangeEnd",
148
+ "commentRangeStart",
149
+ "customXml",
150
+ "customXmlDelRangeEnd",
151
+ "customXmlDelRangeStart",
152
+ "customXmlInsRangeEnd",
153
+ "customXmlInsRangeStart",
154
+ "customXmlMoveFromRangeEnd",
155
+ "customXmlMoveFromRangeStart",
156
+ "customXmlMoveToRangeEnd",
157
+ "customXmlMoveToRangeStart",
158
+ "del",
159
+ "dir",
160
+ "fldSimple",
161
+ "hyperlink",
162
+ "ins",
163
+ "moveFrom",
164
+ "moveFromRangeEnd",
165
+ "moveFromRangeStart",
166
+ "moveTo",
167
+ "moveToRangeEnd",
168
+ "moveToRangeStart",
169
+ "permEnd",
170
+ "permStart",
171
+ "proofErr",
172
+ "r",
173
+ "sdt",
174
+ "smartTag",
175
+ "subDoc"
176
+ ],
177
+ "w:fldSimple": [
178
+ "bdo",
179
+ "bookmarkEnd",
180
+ "bookmarkStart",
181
+ "commentRangeEnd",
182
+ "commentRangeStart",
183
+ "customXml",
184
+ "customXmlDelRangeEnd",
185
+ "customXmlDelRangeStart",
186
+ "customXmlInsRangeEnd",
187
+ "customXmlInsRangeStart",
188
+ "customXmlMoveFromRangeEnd",
189
+ "customXmlMoveFromRangeStart",
190
+ "customXmlMoveToRangeEnd",
191
+ "customXmlMoveToRangeStart",
192
+ "del",
193
+ "dir",
194
+ "fldData",
195
+ "fldSimple",
196
+ "hyperlink",
197
+ "ins",
198
+ "moveFrom",
199
+ "moveFromRangeEnd",
200
+ "moveFromRangeStart",
201
+ "moveTo",
202
+ "moveToRangeEnd",
203
+ "moveToRangeStart",
204
+ "permEnd",
205
+ "permStart",
206
+ "proofErr",
207
+ "r",
208
+ "sdt",
209
+ "smartTag",
210
+ "subDoc"
211
+ ],
212
+ "block-content": [
213
+ "altChunk",
214
+ "bookmarkEnd",
215
+ "bookmarkStart",
216
+ "commentRangeEnd",
217
+ "commentRangeStart",
218
+ "customXml",
219
+ "customXmlDelRangeEnd",
220
+ "customXmlDelRangeStart",
221
+ "customXmlInsRangeEnd",
222
+ "customXmlInsRangeStart",
223
+ "customXmlMoveFromRangeEnd",
224
+ "customXmlMoveFromRangeStart",
225
+ "customXmlMoveToRangeEnd",
226
+ "customXmlMoveToRangeStart",
227
+ "del",
228
+ "ins",
229
+ "moveFrom",
230
+ "moveFromRangeEnd",
231
+ "moveFromRangeStart",
232
+ "moveTo",
233
+ "moveToRangeEnd",
234
+ "moveToRangeStart",
235
+ "p",
236
+ "permEnd",
237
+ "permStart",
238
+ "proofErr",
239
+ "sdt",
240
+ "sectPr",
241
+ "tbl",
242
+ "tcPr"
243
+ ]
244
+ };
245
+ //#endregion
246
+ export { CONTAINER_CHILDREN };
@@ -0,0 +1,103 @@
1
+ import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen.js";
2
+ import { captureVerbatimXml } from "./verbatimCapture.js";
3
+ import { WORDPROCESSINGML_NAMESPACE_URIS, getChildElements, getLocalName, getNamespaceUri } from "./xmlParser.js";
4
+ //#region src/docx/containerChildren.ts
5
+ /** Keep this child's markup verbatim, in place. */
6
+ const CAPTURE = "capture";
7
+ /**
8
+ * Another reader owns this child, and re-emits it.
9
+ *
10
+ * `w:rPr` under a run, read by `parseRunProperties`; `w:commentReference`
11
+ * under a run, lifted out by the paragraph parser. Capturing one of these as
12
+ * well would write it twice, so the disposition has to be stated rather than
13
+ * left to a bare `break`.
14
+ */
15
+ const OWNED_ELSEWHERE = "owned-elsewhere";
16
+ /**
17
+ * This child goes with the wrapper folio does not keep.
18
+ *
19
+ * `w:smartTagPr` is the case: folio unwraps `w:smartTag` and splices its
20
+ * content into the paragraph, so the properties describing the wrapper have
21
+ * nothing left to describe and capturing them would put a `w:smartTagPr`
22
+ * where the schema does not admit one. The drop is stated here and recorded
23
+ * in `specifications/container-contract/contract.json`, which is the whole
24
+ * difference between this and a `default` that says nothing.
25
+ */
26
+ const DROPPED_WITH_ITS_WRAPPER = "dropped-with-its-wrapper";
27
+ /**
28
+ * The Transitional spelling of a namespace, so one disposition covers both.
29
+ *
30
+ * ISO Strict writes the same content model under its own URIs: maths is
31
+ * `purl.oclc.org/ooxml/officeDocument/math` rather than
32
+ * `schemas.openxmlformats.org/officeDocument/2006/math`. A namespace-keyed
33
+ * disposition written in Transitional would otherwise send a Strict
34
+ * document's maths to the sink, which models it as bytes instead of an
35
+ * equation. The pairs come from the generated table rather than a second list
36
+ * here, so a namespace cannot be paired in one place and forgotten in the
37
+ * other.
38
+ */
39
+ const transitionalNamespaceOf = (namespace) => TRANSITIONAL_NAMESPACE_BY_STRICT_URI.get(namespace) ?? namespace;
40
+ /**
41
+ * Walk a container's children, handing each to its handler and the rest to the
42
+ * sink.
43
+ *
44
+ * @returns the container's unmodelled markup, or `undefined` when it held
45
+ * none — an empty record is never written, so a fully modelled container
46
+ * stays byte-identical in the model.
47
+ */
48
+ const dispatchChildren = ({ element, handlers, modelledCount, undeclared, undeclaredNamespaces }) => {
49
+ const children = [];
50
+ const capture = (child) => {
51
+ children.push({
52
+ index: modelledCount(),
53
+ xml: captureVerbatimXml(child)
54
+ });
55
+ };
56
+ const declared = new Map(Object.entries(handlers));
57
+ const byName = new Map(Object.entries(undeclared ?? {}));
58
+ const byNamespace = new Map(Object.entries(undeclaredNamespaces ?? {}));
59
+ for (const child of getChildElements(element)) {
60
+ const localName = getLocalName(child.name);
61
+ const namespace = getNamespaceUri(child);
62
+ const disposition = namespace === void 0 || WORDPROCESSINGML_NAMESPACE_URIS.has(namespace) ? declared.get(localName) ?? byName.get(localName) : byName.get(localName) ?? byNamespace.get(transitionalNamespaceOf(namespace));
63
+ if (disposition === void 0 || disposition === "capture") {
64
+ capture(child);
65
+ continue;
66
+ }
67
+ if (disposition === "dropped-with-its-wrapper" || disposition === "owned-elsewhere") continue;
68
+ disposition(child);
69
+ }
70
+ return children.length === 0 ? void 0 : { children };
71
+ };
72
+ /**
73
+ * Put a container's modelled children back with its preserved ones between
74
+ * them, in source position.
75
+ *
76
+ * Where the content model demands schema order the caller has already put its
77
+ * modelled children in that order; the sink's `index` then places each capture
78
+ * between the same two siblings it sat between when it was read.
79
+ *
80
+ * @param wrap turns one capture's markup into whatever the caller's list holds
81
+ */
82
+ const withPreservedChildren = (modelled, preserved, wrap) => {
83
+ const captures = preserved?.children;
84
+ if (captures === void 0 || captures.length === 0) return [...modelled];
85
+ const byIndex = /* @__PURE__ */ new Map();
86
+ for (const { index, xml } of captures) {
87
+ const slot = Math.min(Math.max(index, 0), modelled.length);
88
+ const bucket = byIndex.get(slot);
89
+ if (bucket) {
90
+ bucket.push(wrap(xml));
91
+ continue;
92
+ }
93
+ byIndex.set(slot, [wrap(xml)]);
94
+ }
95
+ const items = [];
96
+ for (const [index, item] of modelled.entries()) items.push(...byIndex.get(index) ?? [], item);
97
+ items.push(...byIndex.get(modelled.length) ?? []);
98
+ return items;
99
+ };
100
+ /** {@link withPreservedChildren} for a caller that already holds markup. */
101
+ const serializeWithPreservedChildren = (modelled, preserved) => withPreservedChildren(modelled, preserved, (xml) => xml).join("");
102
+ //#endregion
103
+ export { CAPTURE, DROPPED_WITH_ITS_WRAPPER, OWNED_ELSEWHERE, dispatchChildren, serializeWithPreservedChildren, transitionalNamespaceOf, withPreservedChildren };
@@ -1,5 +1,7 @@
1
- import { resolveRelativePath } from "./relsParser.js";
2
- import { findChildByNamespaceUri, getAttribute, getLocalName, parseNumericAttribute, parseXmlDocument } from "./xmlParser.js";
1
+ import { bytesToDataUrl } from "../utils/base64.js";
2
+ import { PREVIEW_KINDS } from "./previewBudget.js";
3
+ import { resolveRelationshipIdOfType, resolveRelativePath } from "./relsParser.js";
4
+ import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, findChildByNamespaceUri, getAttribute, getAttributeByNamespaceUri, getLocalName, parseNumericAttribute, parseXmlDocument } from "./xmlParser.js";
3
5
  //#region src/docx/diagramPreview.ts
4
6
  const MAX_PREVIEW_SHAPES = 128;
5
7
  const MAX_PREVIEW_PIXELS = 144e4;
@@ -7,21 +9,47 @@ const MAX_PREVIEW_PAINT_PIXELS = MAX_PREVIEW_PIXELS * 4;
7
9
  const DRAWINGML_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/drawingml/2006/main", "http://purl.oclc.org/ooxml/drawingml/main"]);
8
10
  const DIAGRAM_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/drawingml/2006/diagram", "http://purl.oclc.org/ooxml/drawingml/diagram"]);
9
11
  const DIAGRAM_DRAWING_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.microsoft.com/office/drawing/2008/diagram"]);
12
+ const DIAGRAM_DATA_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData";
13
+ const DIAGRAM_DRAWING_RELATIONSHIP_TYPE = "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing";
14
+ const DOCUMENT_PART_PATH = "word/document.xml";
10
15
  const WORD_DRAWING_NAMESPACE_URIS = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing"]);
16
+ /**
17
+ * The preview is a megapixel raster, so both checksums run over megabytes.
18
+ * `for (const byte of bytes)` drives the array iterator protocol once per
19
+ * byte, which profiles as the dominant cost of parsing a SmartArt document;
20
+ * indexed loops and a table-driven CRC produce the same numbers without it.
21
+ */
22
+ const CRC32_TABLE = (() => {
23
+ const table = /* @__PURE__ */ new Uint32Array(256);
24
+ for (let index = 0; index < 256; index += 1) {
25
+ let value = index;
26
+ for (let bit = 0; bit < 8; bit += 1) value = value >>> 1 ^ (value & 1 ? 3988292384 : 0);
27
+ table[index] = value >>> 0;
28
+ }
29
+ return table;
30
+ })();
11
31
  const crc32 = (bytes) => {
12
32
  let crc = 4294967295;
13
- for (const byte of bytes) {
14
- crc ^= byte;
15
- for (let bit = 0; bit < 8; bit += 1) crc = crc >>> 1 ^ (crc & 1 ? 3988292384 : 0);
16
- }
33
+ for (let index = 0; index < bytes.length; index += 1) crc = crc >>> 8 ^ CRC32_TABLE[(crc ^ bytes[index]) & 255];
17
34
  return (crc ^ 4294967295) >>> 0;
18
35
  };
36
+ /**
37
+ * `a` and `b` stay below 2^31 for 5552 iterations from any legal state, so the
38
+ * modulo runs per block rather than per byte.
39
+ */
40
+ const ADLER32_BLOCK = 5552;
19
41
  const adler32 = (bytes) => {
20
42
  let a = 1;
21
43
  let b = 0;
22
- for (const byte of bytes) {
23
- a = (a + byte) % 65521;
24
- b = (b + a) % 65521;
44
+ let index = 0;
45
+ while (index < bytes.length) {
46
+ const end = Math.min(index + ADLER32_BLOCK, bytes.length);
47
+ for (; index < end; index += 1) {
48
+ a += bytes[index];
49
+ b += a;
50
+ }
51
+ a %= 65521;
52
+ b %= 65521;
25
53
  }
26
54
  return b << 16 | a;
27
55
  };
@@ -88,9 +116,8 @@ const previewPng = (width, height, shapes) => {
88
116
  cursor += length;
89
117
  offset += length;
90
118
  }
91
- const output = new Uint8Array(cursor + 4);
92
- output.set(compressed.subarray(0, cursor));
93
- new DataView(output.buffer).setUint32(cursor, adler32(pixels));
119
+ new DataView(compressed.buffer).setUint32(cursor, adler32(pixels));
120
+ const output = compressed;
94
121
  const signature = new Uint8Array([
95
122
  137,
96
123
  80,
@@ -127,13 +154,38 @@ const extent = (drawing) => {
127
154
  height: parseNumericAttribute(value, null, "cy") ?? 0
128
155
  };
129
156
  };
130
- const cachedDiagramShapes = (rels, media) => {
131
- const matches = [...rels.values()].filter((relationship) => relationship.type === "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing");
132
- if (matches.length !== 1 || !matches[0]?.target) return [];
133
- const path = resolveRelativePath("word/document.xml", matches[0].target);
134
- const file = media.get(path);
135
- if (!file?.data) return [];
136
- const root = parseXmlDocument(new TextDecoder().decode(file.data));
157
+ /** Parse the part a relationship of the given type names, by that relationship's id. */
158
+ const partByRelationshipId = ({ rels, media, rId, type }) => {
159
+ const resolved = resolveRelationshipIdOfType(rels, rId ?? void 0, type);
160
+ if (resolved.status !== "resolved" || !resolved.relationship.target) return null;
161
+ const file = media.get(resolveRelativePath(DOCUMENT_PART_PATH, resolved.relationship.target));
162
+ return file?.data ? parseXmlDocument(new TextDecoder().decode(file.data)) : null;
163
+ };
164
+ /**
165
+ * The drawing cache this diagram points at, reached through its own ids.
166
+ *
167
+ * `dgm:relIds/@r:dm` names the data part, and that part's `dsp:dataModelExt`
168
+ * extension names the cached drawing. Scanning the relationship map for a type
169
+ * instead of following the ids reads the wrong diagram whenever a document has
170
+ * more than one, which is why the scan refused outright on a second match:
171
+ * both diagrams in a two-diagram document then got no preview at all.
172
+ */
173
+ const cachedDiagramShapes = (graphicData, rels, media) => {
174
+ const relIds = findChildByNamespaceUri(graphicData, DIAGRAM_NAMESPACE_URIS, "relIds");
175
+ const data = partByRelationshipId({
176
+ rels,
177
+ media,
178
+ rId: getAttributeByNamespaceUri(relIds, OFFICE_RELATIONSHIP_NAMESPACE_URIS, "dm"),
179
+ type: DIAGRAM_DATA_RELATIONSHIP_TYPE
180
+ });
181
+ if (!data) return [];
182
+ const dataModelExt = descendantsByNamespace(data, DIAGRAM_DRAWING_NAMESPACE_URIS, "dataModelExt").at(0);
183
+ const root = partByRelationshipId({
184
+ rels,
185
+ media,
186
+ rId: getAttribute(dataModelExt, null, "relId"),
187
+ type: DIAGRAM_DRAWING_RELATIONSHIP_TYPE
188
+ });
137
189
  if (!root) return [];
138
190
  const shapes = [];
139
191
  for (const shape of descendantsByNamespace(root, DIAGRAM_DRAWING_NAMESPACE_URIS, "sp").slice(0, MAX_PREVIEW_SHAPES)) {
@@ -155,31 +207,39 @@ const cachedDiagramShapes = (rels, media) => {
155
207
  }
156
208
  return shapes;
157
209
  };
210
+ const matchesNamespace = (element, namespaceUris, localName) => element.namespaceUri !== void 0 && namespaceUris.has(element.namespaceUri) && getLocalName(element.name ?? "") === localName;
158
211
  const descendantsByNamespace = (root, namespaceUris, localName) => {
159
212
  const result = [];
160
213
  const visit = (element) => {
161
- if (element.namespaceUri && namespaceUris.has(element.namespaceUri) && getLocalName(element.name ?? "") === localName) result.push(element);
214
+ if (matchesNamespace(element, namespaceUris, localName)) result.push(element);
162
215
  for (const child of element.elements ?? []) if (child.type === "element") visit(child);
163
216
  };
164
217
  visit(root);
165
218
  return result;
166
219
  };
220
+ /** The first match in document order, without walking the rest of the subtree. */
221
+ const firstDescendantByNamespace = (root, namespaceUris, localName) => {
222
+ if (matchesNamespace(root, namespaceUris, localName)) return root;
223
+ for (const child of root.elements ?? []) {
224
+ if (child.type !== "element") continue;
225
+ const found = firstDescendantByNamespace(child, namespaceUris, localName);
226
+ if (found) return found;
227
+ }
228
+ return null;
229
+ };
167
230
  /** Create a deliberately simple, bounded preview; it is never an editable diagram projection. */
168
231
  const parseDiagramPreview = (drawing, rels, media) => {
169
232
  if (!rels || !media) return null;
170
- const graphicData = descendantsByNamespace(drawing, DRAWINGML_NAMESPACE_URIS, "graphicData").at(0);
233
+ const graphicData = firstDescendantByNamespace(drawing, DRAWINGML_NAMESPACE_URIS, "graphicData");
171
234
  if (!graphicData || !DIAGRAM_NAMESPACE_URIS.has(getAttribute(graphicData, null, "uri") ?? "")) return null;
172
235
  const { width, height } = extent(drawing);
173
236
  if (width <= 0 || height <= 0) return null;
174
- const png = previewPng(width, height, cachedDiagramShapes(rels, media));
175
- let binary = "";
176
- for (let offset = 0; offset < png.length; offset += 32768) binary += String.fromCodePoint(...png.subarray(offset, offset + 32768));
177
237
  return {
178
238
  type: "image",
179
239
  rId: "",
180
- src: `data:image/png;base64,${btoa(binary)}`,
181
- mimeType: "image/png",
182
- filename: "smartart-preview.png",
240
+ src: bytesToDataUrl(previewPng(width, height, cachedDiagramShapes(graphicData, rels, media)), PREVIEW_KINDS.smartArt.mimeType),
241
+ mimeType: PREVIEW_KINDS.smartArt.mimeType,
242
+ filename: PREVIEW_KINDS.smartArt.filename,
183
243
  size: {
184
244
  width,
185
245
  height
@@ -1,7 +1,7 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { NumberingMap } from "./numberingParser.js";
3
- import { StyleMap } from "./styleParser.js";
4
3
  import { ParseContext } from "./parseContext.js";
4
+ import { StyleMap } from "./styleParser.js";
5
5
  //#region src/docx/documentParser.d.ts
6
6
  /**
7
7
  * Extract template variables from text
@@ -49,7 +49,7 @@ function extractTableVariables(table) {
49
49
  for (const row of table.rows) for (const cell of row.cells) for (const cellContent of cell.content) if (cellContent.type === "paragraph") {
50
50
  const vars = extractTemplateVariables(getParagraphText(cellContent));
51
51
  for (const v of vars) if (!variables.includes(v)) variables.push(v);
52
- } else {
52
+ } else if (cellContent.type === "table") {
53
53
  const nestedVars = extractTableVariables(cellContent);
54
54
  for (const v of nestedVars) if (!variables.includes(v)) variables.push(v);
55
55
  }
@@ -149,7 +149,7 @@ function getAllParagraphs(body) {
149
149
  function getTableParagraphs(table) {
150
150
  const paragraphs = [];
151
151
  for (const row of table.rows) for (const cell of row.cells) for (const content of cell.content) if (content.type === "paragraph") paragraphs.push(content);
152
- else paragraphs.push(...getTableParagraphs(content));
152
+ else if (content.type === "table") paragraphs.push(...getTableParagraphs(content));
153
153
  return paragraphs;
154
154
  }
155
155
  /**
@@ -193,7 +193,7 @@ function getTableText(table) {
193
193
  for (const cell of row.cells) {
194
194
  const cellTexts = [];
195
195
  for (const content of cell.content) if (content.type === "paragraph") cellTexts.push(getParagraphText(content));
196
- else cellTexts.push(getTableText(content));
196
+ else if (content.type === "table") cellTexts.push(getTableText(content));
197
197
  rowTexts.push(cellTexts.join("\n"));
198
198
  }
199
199
  lines.push(rowTexts.join(" "));
@@ -1,5 +1,5 @@
1
1
  import { deterministicHexId } from "../utils/hexId.js";
2
- import { isXmlNameBoundary } from "./selectiveXmlPatch.js";
2
+ import { isXmlNameBoundary, spliceXml } from "./selectiveXmlPatch.js";
3
3
  import { loadDocxArchive } from "./server/boundedArchive.js";
4
4
  import { TaggedError } from "better-result";
5
5
  import JSZip from "jszip";
@@ -97,11 +97,21 @@ const OPEN_TAG_TEXT_ID_PATTERN = /\sw(?:14)?:textId=(?<quote>["'])(?<id>[\s\S]*?
97
97
  const XMLNS_W14_PATTERN = /\sxmlns:w14=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
98
98
  const XMLNS_MC_PATTERN = /\sxmlns:mc=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
99
99
  const MC_IGNORABLE_PATTERN = /\smc:Ignorable=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
100
- const applySplices = (xml, edits) => {
101
- const ordered = [...edits].sort((a, b) => b.start - a.start);
102
- let result = xml;
103
- for (const { start, end, text } of ordered) result = result.slice(0, start) + text + result.slice(end);
104
- return result;
100
+ /**
101
+ * Stamp the edits into the part through the splice owner, which refuses a
102
+ * result that would leave a comment range with only one half. These edits
103
+ * rewrite `<w:p …>` open tags and the root element's attributes, so they
104
+ * should never cut across a range marker; the owner is what makes that
105
+ * structural rather than a reading of the scanner.
106
+ */
107
+ const applySplices = (xml, edits, partPath) => {
108
+ const patched = spliceXml(xml, edits.map(({ start, end, text }) => ({
109
+ start,
110
+ end,
111
+ newXml: text
112
+ })));
113
+ if (patched === null) throw createEnsureParaIdsError(`Stamping paragraph ids into ${partPath} broke a comment range`);
114
+ return patched;
105
115
  };
106
116
  const createEnsureParaIdsError = (message, cause) => new EnsureParaIdsError({
107
117
  message,
@@ -382,7 +392,7 @@ const ensureParaIdsInternal = async (docx, options) => {
382
392
  if (scan.edits.length === 0) continue;
383
393
  assigned += scan.assigned;
384
394
  deduplicated += scan.deduplicated;
385
- updates.set(partPath, applySplices(xml, [...scan.edits, ...ensureRootNamespaces(xml, partPath)]));
395
+ updates.set(partPath, applySplices(xml, [...scan.edits, ...ensureRootNamespaces(xml, partPath)], partPath));
386
396
  }
387
397
  if (updates.size === 0) return {
388
398
  docx: toUint8Array(docx),
@@ -1,6 +1,6 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
- import { StyleMap } from "./styleParser.js";
3
2
  import { XmlElement } from "./xmlParser.js";
3
+ import { StyleMap } from "./styleParser.js";
4
4
  //#region src/docx/fieldParser.d.ts
5
5
  /**
6
6
  * All known field types from OOXML specification
@@ -1,7 +1,8 @@
1
+ import { parseFieldState } from "./fieldState.js";
1
2
  import { formatOoxmlCounter } from "./ooxmlCounterFormatter.js";
2
3
  import { FieldTypeSchema, narrowEnum } from "./parserEnums.js";
3
4
  import { parseRun } from "./runParser.js";
4
- import { findChildren, getAttribute, parseOnOffAttribute } from "./xmlParser.js";
5
+ import { findChildren, getAttribute } from "./xmlParser.js";
5
6
  //#region src/docx/fieldParser.ts
6
7
  /**
7
8
  * All known field types from OOXML specification
@@ -162,10 +163,9 @@ function parseSimpleField(node, styles, theme) {
162
163
  type: "simpleField",
163
164
  instruction,
164
165
  fieldType: parseFieldType(instruction),
165
- content: []
166
+ content: [],
167
+ ...parseFieldState(node)
166
168
  };
167
- if (parseOnOffAttribute(node, "w", "fldLock") === true) field.fldLock = true;
168
- if (parseOnOffAttribute(node, "w", "dirty") === true) field.dirty = true;
169
169
  const children = findChildren(node, "w", "r");
170
170
  for (const child of children) {
171
171
  const run = parseRun(child, styles, theme);
@@ -0,0 +1,26 @@
1
+ import { XmlElement } from "./xmlParser.js";
2
+ //#region src/docx/fieldState.d.ts
3
+ /** What a field element states about its lock and dirty flags. */
4
+ type FieldState = {
5
+ fldLock?: boolean;
6
+ dirty?: boolean;
7
+ };
8
+ /** Read both attributes off a `w:fldSimple` or `w:fldChar`, keeping an explicit off. */
9
+ declare const parseFieldState: (element: XmlElement) => FieldState;
10
+ /**
11
+ * The stated flags of a field, without the rest of it.
12
+ *
13
+ * The complex-field assembly carries the begin `w:fldChar`'s state across the
14
+ * runs between `begin` and `end`, and this is the one place that knows which
15
+ * fields that state is made of.
16
+ */
17
+ declare const fieldStateOf: ({ fldLock, dirty }: FieldState) => FieldState;
18
+ /**
19
+ * The attributes to write for a field's stated flags, in schema order.
20
+ *
21
+ * `1`/`0` is what Word writes and what the table, section and border
22
+ * serializers write.
23
+ */
24
+ declare const fieldStateAttributes: ({ fldLock, dirty }: FieldState) => string[];
25
+ //#endregion
26
+ export { FieldState, fieldStateAttributes, fieldStateOf, parseFieldState };