@stll/folio-core 0.15.1 → 0.15.3

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 (156) hide show
  1. package/dist/ai-edits/apply.js +2 -2
  2. package/dist/ai-edits/blockRange.js +1 -1
  3. package/dist/ai-edits/headless.js +9 -9
  4. package/dist/ai-edits/index.js +5 -5
  5. package/dist/ai-edits/read.js +1 -1
  6. package/dist/ai-edits/table-cell-mutations.js +2 -2
  7. package/dist/compat/eigenpal.js +19 -19
  8. package/dist/content-controls/mutateContentControls.js +1 -1
  9. package/dist/controller/contentControlWidgetController.js +1 -1
  10. package/dist/controller/headerFooterEditorManager.js +5 -5
  11. package/dist/controller/hiddenEditorManager.js +5 -5
  12. package/dist/controller/layoutPipeline.js +10 -10
  13. package/dist/controller/noteEditorManager.js +5 -5
  14. package/dist/docx/blockContentParser.js +4 -4
  15. package/dist/docx/commentParser.js +30 -2
  16. package/dist/docx/documentParser.js +27 -3
  17. package/dist/docx/drawingIdNormalization.d.ts +5 -0
  18. package/dist/docx/drawingIdNormalization.js +35 -0
  19. package/dist/docx/drawingUtils.d.ts +1 -1
  20. package/dist/docx/drawingUtils.js +111 -27
  21. package/dist/docx/encryption/agileDecryption.js +1 -1
  22. package/dist/docx/encryption/encryptionInfo.js +1 -1
  23. package/dist/docx/encryption/index.js +1 -1
  24. package/dist/docx/encryption/openEncryptedDocx.js +3 -3
  25. package/dist/docx/fieldParser.js +1 -1
  26. package/dist/docx/footnoteParser.js +2 -2
  27. package/dist/docx/groupDrawingParser.js +1 -1
  28. package/dist/docx/headerFooterParser.js +3 -3
  29. package/dist/docx/headerFooterVerbatim.d.ts +2 -1
  30. package/dist/docx/headerFooterVerbatim.js +6 -1
  31. package/dist/docx/hyperlinkParser.js +1 -1
  32. package/dist/docx/imageParser.js +3 -3
  33. package/dist/docx/index.js +1 -1
  34. package/dist/docx/paragraphParser.js +8 -5
  35. package/dist/docx/paragraphTextBoxEnrichment.js +4 -4
  36. package/dist/docx/paragraphTraversal.d.ts +5 -3
  37. package/dist/docx/paragraphTraversal.js +20 -13
  38. package/dist/docx/parser.js +17 -7
  39. package/dist/docx/parserEnums.d.ts +4 -1
  40. package/dist/docx/parserEnums.js +5 -2
  41. package/dist/docx/rezip.js +9 -9
  42. package/dist/docx/runConsolidator.js +0 -1
  43. package/dist/docx/runParser.js +22 -6
  44. package/dist/docx/sectionParser.js +2 -2
  45. package/dist/docx/selectiveSave.js +7 -7
  46. package/dist/docx/serializer/commentSerializer.js +13 -8
  47. package/dist/docx/serializer/documentSerializer.js +7 -3
  48. package/dist/docx/serializer/headerFooterSerializer.js +3 -3
  49. package/dist/docx/serializer/noteSerializer.js +2 -2
  50. package/dist/docx/serializer/numberingSerializer.js +1 -1
  51. package/dist/docx/serializer/paragraphSerializer.js +2 -2
  52. package/dist/docx/serializer/runSerializer.js +19 -13
  53. package/dist/docx/serializer/sectionPropertiesSerializer.js +4 -3
  54. package/dist/docx/serializer/stylesSerializer.js +3 -3
  55. package/dist/docx/serializer/tableSerializer.js +1 -1
  56. package/dist/docx/server/docxToMarkdown.js +1 -1
  57. package/dist/docx/server/evaluateDocxXmlPatchProposal.js +1 -1
  58. package/dist/docx/server/extractDocxText.js +1 -1
  59. package/dist/docx/server/validateDocxConformance.js +3 -3
  60. package/dist/docx/shapeParser.js +5 -113
  61. package/dist/docx/styleParser.js +3 -3
  62. package/dist/docx/tableParser.js +11 -9
  63. package/dist/docx/textBoxParser.js +2 -2
  64. package/dist/docx/vmlImageParser.js +2 -2
  65. package/dist/fonts/embeddedFonts.js +2 -2
  66. package/dist/index.js +18 -18
  67. package/dist/layout-bridge/convert/footnoteLayout.js +2 -2
  68. package/dist/layout-bridge/convert/headerFooterLayout.js +2 -2
  69. package/dist/layout-bridge/convert/paragraphFrames.js +2 -2
  70. package/dist/layout-bridge/convert/toFlowBlocks.js +10 -10
  71. package/dist/layout-bridge/engine/clickToPosition.js +2 -2
  72. package/dist/layout-bridge/engine/hitTest.js +1 -1
  73. package/dist/layout-bridge/engine/measuring/index.js +6 -6
  74. package/dist/layout-bridge/engine/selectionRects.js +5 -5
  75. package/dist/layout-engine/index.js +6 -6
  76. package/dist/layout-engine/measure/cache.js +2 -2
  77. package/dist/layout-engine/measure/index.js +6 -6
  78. package/dist/layout-engine/measure/lineBreaks.js +1 -1
  79. package/dist/layout-engine/measure/listMarkerWidth.js +1 -1
  80. package/dist/layout-engine/measure/measureBlocks.js +7 -7
  81. package/dist/layout-engine/measure/measureContainer.js +3 -3
  82. package/dist/layout-engine/measure/measureHelpers.js +1 -1
  83. package/dist/layout-engine/measure/measureParagraph.js +7 -7
  84. package/dist/layout-engine/measure/tableCellFlow.js +1 -1
  85. package/dist/layout-engine/paginator.js +1 -1
  86. package/dist/layout-engine/tableRowBreak.js +2 -2
  87. package/dist/layout-painter/index.js +5 -5
  88. package/dist/layout-painter/registry/modules/textBox.js +1 -1
  89. package/dist/layout-painter/renderImage.js +1 -1
  90. package/dist/layout-painter/renderPage.js +7 -7
  91. package/dist/layout-painter/renderParagraph.js +13 -13
  92. package/dist/layout-painter/renderTable.js +6 -6
  93. package/dist/layout-painter/renderTextBox.js +1 -1
  94. package/dist/managers/DocumentLoaderManager.js +3 -3
  95. package/dist/managers/TableSelectionManager.js +1 -1
  96. package/dist/managers/editorShortcuts.js +1 -1
  97. package/dist/markdown/fromMarkdown.js +1 -1
  98. package/dist/markdown/index.js +1 -1
  99. package/dist/markdown/renderRuns.js +1 -1
  100. package/dist/markdown/renderTable.js +1 -1
  101. package/dist/model.d.ts +3 -3
  102. package/dist/model.js +3 -3
  103. package/dist/prosemirror/attrs/index.d.ts +4 -2
  104. package/dist/prosemirror/attrs/index.js +17 -2
  105. package/dist/prosemirror/commands/comments.js +3 -3
  106. package/dist/prosemirror/commands/contentControls.js +1 -1
  107. package/dist/prosemirror/commands/contentControlsBlockFill.js +1 -1
  108. package/dist/prosemirror/commands/formatting.js +1 -1
  109. package/dist/prosemirror/commands/hyperlink.js +1 -1
  110. package/dist/prosemirror/commands/image.js +2 -2
  111. package/dist/prosemirror/commands/index.js +6 -6
  112. package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
  113. package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
  114. package/dist/prosemirror/commentOps.js +1 -1
  115. package/dist/prosemirror/conversion/fromProseDoc.js +13 -9
  116. package/dist/prosemirror/conversion/index.js +1 -1
  117. package/dist/prosemirror/conversion/toProseDoc.js +9 -9
  118. package/dist/prosemirror/extensions/StarterKit.js +4 -4
  119. package/dist/prosemirror/extensions/core/ParagraphExtension.js +4 -4
  120. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +2 -2
  121. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -3
  122. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -2
  123. package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +1 -1
  124. package/dist/prosemirror/extensions/features/ImagePasteExtension.js +2 -2
  125. package/dist/prosemirror/extensions/features/ListExtension.js +3 -3
  126. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -1
  127. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +2 -2
  128. package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +1 -1
  129. package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +1 -1
  130. package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +1 -1
  131. package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
  132. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +1 -1
  133. package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
  134. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  135. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
  136. package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
  137. package/dist/prosemirror/extensions/nodes/TabExtension.js +32 -9
  138. package/dist/prosemirror/extensions/nodes/TableExtension.js +1 -1
  139. package/dist/prosemirror/index.js +15 -15
  140. package/dist/prosemirror/insertOperations.js +3 -3
  141. package/dist/prosemirror/plugins/templateDirectives.js +1 -1
  142. package/dist/prosemirror/schema/index.d.ts +2 -2
  143. package/dist/prosemirror/schema/nodes.d.ts +4 -1
  144. package/dist/prosemirror/styles/styleResolver.js +1 -1
  145. package/dist/prosemirror/validation.js +5 -3
  146. package/dist/redline.js +1 -1
  147. package/dist/render-dom/BodySelectionOverlay.js +2 -2
  148. package/dist/server.js +15 -15
  149. package/dist/style-sets/extract.js +1 -1
  150. package/dist/types/content.d.ts +2 -2
  151. package/dist/types/documentEnumValues.d.ts +4 -1
  152. package/dist/types/documentEnumValues.js +14 -1
  153. package/dist/types/index.d.ts +2 -1
  154. package/dist/utils/formatToStyle.js +1 -1
  155. package/dist/version-comparison.js +2 -2
  156. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, ShapeOutlineStyleSchema, narrowEnum } from "./parserEnums.js";
2
- import { findByFullName, getAttribute, getChildElements, getTextContent, parseNumericAttribute } from "./xmlParser.js";
2
+ import { elementToXml, findByFullName, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, getTextContent, parseNumericAttribute } from "./xmlParser.js";
3
3
  //#region src/docx/drawingUtils.ts
4
4
  /**
5
5
  * Map OOXML scheme names to standard theme color slots.
@@ -119,9 +119,8 @@ function parseColorElement(element) {
119
119
  */
120
120
  function parseFill(spPr) {
121
121
  if (!spPr) return;
122
- const children = getChildElements(spPr);
123
- if (children.some((el) => el.name === "a:noFill")) return { type: "none" };
124
- const solidFill = children.find((el) => el.name === "a:solidFill");
122
+ if (findChildByLocalName(spPr, "noFill")) return { type: "none" };
123
+ const solidFill = findChildByLocalName(spPr, "solidFill");
125
124
  if (solidFill) {
126
125
  const color = parseColorElement(solidFill);
127
126
  return color !== void 0 ? {
@@ -129,31 +128,105 @@ function parseFill(spPr) {
129
128
  color
130
129
  } : { type: "solid" };
131
130
  }
132
- if (children.some((el) => el.name === "a:gradFill")) return { type: "gradient" };
131
+ const gradientFill = findChildByLocalName(spPr, "gradFill");
132
+ if (gradientFill) return parseGradientFill(gradientFill);
133
+ }
134
+ function parseGradientFill(gradientFill) {
135
+ let type = "linear";
136
+ let angle;
137
+ const linear = findChildByLocalName(gradientFill, "lin");
138
+ if (linear) {
139
+ const authoredAngle = getAttribute(linear, null, "ang");
140
+ if (authoredAngle) {
141
+ const parsedAngle = Number.parseInt(authoredAngle, 10);
142
+ angle = Number.isNaN(parsedAngle) ? void 0 : parsedAngle / 6e4;
143
+ }
144
+ }
145
+ const path = findChildByLocalName(gradientFill, "path");
146
+ if (path) {
147
+ const pathType = getAttribute(path, null, "path");
148
+ if (pathType === "circle") type = "radial";
149
+ else if (pathType === "rect") type = "rectangular";
150
+ else type = "path";
151
+ }
152
+ const stops = [];
153
+ const stopList = findChildByLocalName(gradientFill, "gsLst");
154
+ if (stopList) for (const stop of findChildrenByLocalName(stopList, "gs")) {
155
+ const authoredPosition = getAttribute(stop, null, "pos");
156
+ const parsedPosition = authoredPosition ? Number.parseInt(authoredPosition, 10) : 0;
157
+ const color = parseColorElement(stop);
158
+ if (color) stops.push({
159
+ position: Number.isNaN(parsedPosition) ? 0 : parsedPosition,
160
+ color
161
+ });
162
+ }
163
+ return {
164
+ type: "gradient",
165
+ rawXml: elementToXml(gradientFill),
166
+ gradient: {
167
+ type,
168
+ ...angle !== void 0 ? { angle } : {},
169
+ stops
170
+ }
171
+ };
133
172
  }
134
173
  /**
135
174
  * Parse outline from shape properties (a:ln).
136
175
  */
137
176
  function parseOutline(spPr) {
138
- const ln = spPr ? findByFullName(spPr, "a:ln") : null;
177
+ const ln = spPr ? findChildByLocalName(spPr, "ln") : null;
139
178
  if (!ln) return;
140
- const children = getChildElements(ln);
141
- if (children.some((el) => el.name === "a:noFill")) return;
142
- const outline = {};
179
+ if (findChildByLocalName(ln, "noFill")) return;
180
+ const outline = { rawXml: elementToXml(ln) };
143
181
  const w = getAttribute(ln, null, "w");
144
- if (w) outline.width = Number.parseInt(w, 10);
145
- const solidFill = children.find((el) => el.name === "a:solidFill");
182
+ if (w) {
183
+ const parsed = Number.parseInt(w, 10);
184
+ if (!Number.isNaN(parsed)) outline.width = parsed;
185
+ }
186
+ const cap = getAttribute(ln, null, "cap");
187
+ if (cap === "flat") outline.cap = "flat";
188
+ else if (cap === "rnd") outline.cap = "round";
189
+ else if (cap === "sq") outline.cap = "square";
190
+ if (findChildByLocalName(ln, "bevel")) outline.join = "bevel";
191
+ else if (findChildByLocalName(ln, "round")) outline.join = "round";
192
+ else if (findChildByLocalName(ln, "miter")) outline.join = "miter";
193
+ const solidFill = findChildByLocalName(ln, "solidFill");
146
194
  if (solidFill) {
147
195
  const color = parseColorElement(solidFill);
148
196
  if (color !== void 0) outline.color = color;
149
197
  }
150
- const prstDash = children.find((el) => el.name === "a:prstDash");
198
+ const prstDash = findChildByLocalName(ln, "prstDash");
151
199
  if (prstDash) {
152
200
  const val = narrowEnum(getAttribute(prstDash, null, "val"), ShapeOutlineStyleSchema);
153
201
  if (val) outline.style = val;
154
202
  }
203
+ const headEnd = findChildByLocalName(ln, "headEnd");
204
+ if (headEnd) outline.headEnd = parseLineEnd(headEnd);
205
+ const tailEnd = findChildByLocalName(ln, "tailEnd");
206
+ if (tailEnd) outline.tailEnd = parseLineEnd(tailEnd);
155
207
  return outline;
156
208
  }
209
+ const LINE_END_TYPES = [
210
+ "none",
211
+ "triangle",
212
+ "stealth",
213
+ "diamond",
214
+ "oval",
215
+ "arrow"
216
+ ];
217
+ function parseLineEnd(element) {
218
+ const authoredType = getAttribute(element, null, "type");
219
+ const type = LINE_END_TYPES.find((allowed) => allowed === authoredType) ?? "none";
220
+ const authoredWidth = getAttribute(element, null, "w");
221
+ const authoredLength = getAttribute(element, null, "len");
222
+ const width = authoredWidth === "sm" || authoredWidth === "med" || authoredWidth === "lg" ? authoredWidth : void 0;
223
+ const length = authoredLength === "sm" || authoredLength === "med" || authoredLength === "lg" ? authoredLength : void 0;
224
+ return {
225
+ type,
226
+ ...width !== void 0 ? { width } : {},
227
+ ...length !== void 0 ? { length } : {}
228
+ };
229
+ }
157
230
  /**
158
231
  * Parse horizontal position from wp:positionH element.
159
232
  */
@@ -162,11 +235,11 @@ function parsePositionH(posH) {
162
235
  const relativeTo = narrowEnum(getAttribute(posH, null, "relativeFrom"), ImageHorizontalRelativeToSchema) ?? "column";
163
236
  const alignEl = findByFullName(posH, "wp:align");
164
237
  if (alignEl) {
165
- const text = getTextContent(alignEl);
166
- const result = { relativeTo };
167
- const alignment = narrowEnum(text, ImageHorizontalAlignmentSchema);
168
- if (alignment) result.alignment = alignment;
169
- return result;
238
+ const alignment = narrowEnum(getTextContent(alignEl), ImageHorizontalAlignmentSchema);
239
+ if (alignment) return {
240
+ relativeTo,
241
+ alignment
242
+ };
170
243
  }
171
244
  const posOffsetEl = findByFullName(posH, "wp:posOffset");
172
245
  if (posOffsetEl) {
@@ -177,7 +250,10 @@ function parsePositionH(posH) {
177
250
  posOffset: Number.isNaN(posOffset) ? 0 : posOffset
178
251
  };
179
252
  }
180
- return { relativeTo };
253
+ return {
254
+ relativeTo,
255
+ posOffset: 0
256
+ };
181
257
  }
182
258
  /**
183
259
  * Parse vertical position from wp:positionV element.
@@ -187,11 +263,11 @@ function parsePositionV(posV) {
187
263
  const relativeTo = narrowEnum(getAttribute(posV, null, "relativeFrom"), ImageVerticalRelativeToSchema) ?? "paragraph";
188
264
  const alignEl = findByFullName(posV, "wp:align");
189
265
  if (alignEl) {
190
- const text = getTextContent(alignEl);
191
- const result = { relativeTo };
192
- const alignment = narrowEnum(text, ImageVerticalAlignmentSchema);
193
- if (alignment) result.alignment = alignment;
194
- return result;
266
+ const alignment = narrowEnum(getTextContent(alignEl), ImageVerticalAlignmentSchema);
267
+ if (alignment) return {
268
+ relativeTo,
269
+ alignment
270
+ };
195
271
  }
196
272
  const posOffsetEl = findByFullName(posV, "wp:posOffset");
197
273
  if (posOffsetEl) {
@@ -202,7 +278,10 @@ function parsePositionV(posV) {
202
278
  posOffset: Number.isNaN(posOffset) ? 0 : posOffset
203
279
  };
204
280
  }
205
- return { relativeTo };
281
+ return {
282
+ relativeTo,
283
+ posOffset: 0
284
+ };
206
285
  }
207
286
  /**
208
287
  * Parse position for anchored drawings (combines positionH + positionV).
@@ -210,10 +289,15 @@ function parsePositionV(posV) {
210
289
  function parseAnchorPosition(anchor) {
211
290
  const positionH = findByFullName(anchor, "wp:positionH");
212
291
  const positionV = findByFullName(anchor, "wp:positionV");
213
- if (!positionH && !positionV) return;
214
292
  return {
215
- horizontal: parsePositionH(positionH) ?? { relativeTo: "column" },
216
- vertical: parsePositionV(positionV) ?? { relativeTo: "paragraph" }
293
+ horizontal: parsePositionH(positionH) ?? {
294
+ relativeTo: "column",
295
+ posOffset: 0
296
+ },
297
+ vertical: parsePositionV(positionV) ?? {
298
+ relativeTo: "paragraph",
299
+ posOffset: 0
300
+ }
217
301
  };
218
302
  }
219
303
  /** Known wrap element names */
@@ -1,6 +1,6 @@
1
- import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
2
1
  import { bytesEqual, joinBytes, padToBlock, passwordToUtf16Le, toArrayBuffer, writeUint32Le } from "./cryptoBytes.js";
3
2
  import { MAX_SPIN_COUNT } from "./encryptionInfo.js";
3
+ import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
4
4
  //#region src/docx/encryption/agileDecryption.ts
5
5
  /**
6
6
  * Agile Encryption decryption (Office 2010+) using Web Crypto.
@@ -1,5 +1,5 @@
1
- import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
2
1
  import { decodeBase64 } from "./cryptoBytes.js";
2
+ import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
3
3
  //#region src/docx/encryption/encryptionInfo.ts
4
4
  /**
5
5
  * Parse the EncryptionInfo stream for Agile Encryption (Office 2010+).
@@ -1,4 +1,4 @@
1
- import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, isDocxEncryptionError } from "./errors.js";
2
1
  import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "./containerFormat.js";
2
+ import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, isDocxEncryptionError } from "./errors.js";
3
3
  import { decryptDocxIfNeeded, openDocxBuffer } from "./openEncryptedDocx.js";
4
4
  export { DOCX_CONTAINER_TYPES, DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, decryptDocxIfNeeded, detectDocxContainerType, isDocxEncryptionError, openDocxBuffer };
@@ -1,9 +1,9 @@
1
- import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
2
- import { toArrayBuffer } from "./cryptoBytes.js";
3
- import { parseAgileEncryptionInfo } from "./encryptionInfo.js";
4
1
  import { decryptAgileEncryptedPackage } from "./agileDecryption.js";
5
2
  import { readEncryptedPackageStreams } from "./compoundFile.js";
6
3
  import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "./containerFormat.js";
4
+ import { toArrayBuffer } from "./cryptoBytes.js";
5
+ import { parseAgileEncryptionInfo } from "./encryptionInfo.js";
6
+ import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
7
7
  //#region src/docx/encryption/openEncryptedDocx.ts
8
8
  /**
9
9
  * Decrypt password-protected OOXML before ZIP extraction.
@@ -1,6 +1,6 @@
1
1
  import { FieldTypeSchema, narrowEnum } from "./parserEnums.js";
2
- import { findChildren, getAttribute } from "./xmlParser.js";
3
2
  import { parseRun } from "./runParser.js";
3
+ import { findChildren, getAttribute } from "./xmlParser.js";
4
4
  //#region src/docx/fieldParser.ts
5
5
  /**
6
6
  * All known field types from OOXML specification
@@ -1,8 +1,8 @@
1
- import { findChild, findChildren, getAttributes, getChildElements, getLocalName, parseXml } from "./xmlParser.js";
2
- import { parseSdtProperties } from "./sdtProperties.js";
3
1
  import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
4
2
  import { parseParagraph } from "./paragraphParser.js";
3
+ import { parseSdtProperties } from "./sdtProperties.js";
5
4
  import { parseTable } from "./tableParser.js";
5
+ import { findChild, findChildren, getAttributes, getChildElements, getLocalName, parseXml } from "./xmlParser.js";
6
6
  //#region src/docx/footnoteParser.ts
7
7
  /**
8
8
  * Parse note type attribute
@@ -1,6 +1,6 @@
1
- import { findAllDeep, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, getLocalName, getTextContent, parseNumericAttribute } from "./xmlParser.js";
2
1
  import { emuToPixels } from "../utils/units.js";
3
2
  import { parseImage, resolveImageData } from "./imageParser.js";
3
+ import { findAllDeep, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, getLocalName, getTextContent, parseNumericAttribute } from "./xmlParser.js";
4
4
  //#region src/docx/groupDrawingParser.ts
5
5
  const HEX_COLOR = /^[0-9A-Fa-f]{6}$/u;
6
6
  const DEFAULT_TEXT_COLOR = "000000";
@@ -1,8 +1,8 @@
1
- import { collectXmlnsDeclarations, parseXml } from "./xmlParser.js";
2
- import { parseWatermark } from "./watermarkParser.js";
3
- import { parseFooterReference, parseFooterReferences, parseHeaderReference, parseHeaderReferences } from "./headerFooterRefParser.js";
4
1
  import { parseBlockContent } from "./blockContentParser.js";
2
+ import { parseFooterReference, parseFooterReferences, parseHeaderReference, parseHeaderReferences } from "./headerFooterRefParser.js";
5
3
  import { assignHeaderFooterVerbatimXml } from "./headerFooterVerbatim.js";
4
+ import { parseWatermark } from "./watermarkParser.js";
5
+ import { collectXmlnsDeclarations, parseXml } from "./xmlParser.js";
6
6
  //#region src/docx/headerFooterParser.ts
7
7
  /**
8
8
  * Parse a header XML file (word/header*.xml)
@@ -14,6 +14,7 @@ type HeaderFooterWithVerbatim = document_d_exports.HeaderFooter & {
14
14
  declare const getHeaderFooterVerbatimXml: (hf: document_d_exports.HeaderFooter) => string | undefined;
15
15
  declare const canReplayHeaderFooterVerbatim: (hf: document_d_exports.HeaderFooter) => boolean;
16
16
  declare const assignHeaderFooterVerbatimXml: (hf: document_d_exports.HeaderFooter, xml: string) => void;
17
+ declare const refreshHeaderFooterVerbatimFingerprint: (hf: document_d_exports.HeaderFooter) => void;
17
18
  declare const clearHeaderFooterVerbatimXml: (hf: document_d_exports.HeaderFooter) => void;
18
19
  //#endregion
19
- export { HeaderFooterWithVerbatim, assignHeaderFooterVerbatimXml, canReplayHeaderFooterVerbatim, clearHeaderFooterVerbatimXml, getHeaderFooterVerbatimXml };
20
+ export { HeaderFooterWithVerbatim, assignHeaderFooterVerbatimXml, canReplayHeaderFooterVerbatim, clearHeaderFooterVerbatimXml, getHeaderFooterVerbatimXml, refreshHeaderFooterVerbatimFingerprint };
@@ -16,10 +16,15 @@ const assignHeaderFooterVerbatimXml = (hf, xml) => {
16
16
  ext.verbatimXml = xml;
17
17
  ext.verbatimFingerprint = headerFooterSerializationFingerprint(hf);
18
18
  };
19
+ const refreshHeaderFooterVerbatimFingerprint = (hf) => {
20
+ const ext = hf;
21
+ if (!ext.verbatimXml) return;
22
+ ext.verbatimFingerprint = headerFooterSerializationFingerprint(hf);
23
+ };
19
24
  const clearHeaderFooterVerbatimXml = (hf) => {
20
25
  const ext = hf;
21
26
  delete ext.verbatimXml;
22
27
  delete ext.verbatimFingerprint;
23
28
  };
24
29
  //#endregion
25
- export { assignHeaderFooterVerbatimXml, canReplayHeaderFooterVerbatim, clearHeaderFooterVerbatimXml, getHeaderFooterVerbatimXml };
30
+ export { assignHeaderFooterVerbatimXml, canReplayHeaderFooterVerbatim, clearHeaderFooterVerbatimXml, getHeaderFooterVerbatimXml, refreshHeaderFooterVerbatimFingerprint };
@@ -1,6 +1,6 @@
1
- import { getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseNumericAttribute } from "./xmlParser.js";
2
1
  import { sanitizeExternalUrl, sanitizeLinkTarget } from "../utils/urlSecurity.js";
3
2
  import { parseRun } from "./runParser.js";
3
+ import { getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseNumericAttribute } from "./xmlParser.js";
4
4
  //#region src/docx/hyperlinkParser.ts
5
5
  /**
6
6
  * Parse bookmark start (w:bookmarkStart)
@@ -1,10 +1,10 @@
1
- import { findByFullName, findChild, getAttribute, getChildElements, parseNumericAttribute } from "./xmlParser.js";
1
+ import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
2
2
  import { emuToPixels } from "../utils/units.js";
3
- import { WRAP_ELEMENT_NAMES, parsePositionH, parsePositionV, parseWrapElement } from "./drawingUtils.js";
4
3
  import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
5
- import { sanitizeImageSrc } from "../utils/sanitizeImageSrc.js";
4
+ import { WRAP_ELEMENT_NAMES, parsePositionH, parsePositionV, parseWrapElement } from "./drawingUtils.js";
6
5
  import { resolveTarget } from "./relsParser.js";
7
6
  import { isTextBoxDrawing } from "./textBoxParser.js";
7
+ import { findByFullName, findChild, getAttribute, getChildElements, parseNumericAttribute } from "./xmlParser.js";
8
8
  //#region src/docx/imageParser.ts
9
9
  /**
10
10
  * Convert rotation value (1/60000 of a degree) to degrees
@@ -1,5 +1,5 @@
1
- import { getCachedNumberingMap } from "./numberingParser.js";
2
1
  import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, isDocxEncryptionError } from "./encryption/errors.js";
3
2
  import { decryptDocxIfNeeded, openDocxBuffer } from "./encryption/openEncryptedDocx.js";
4
3
  import { FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentPrivacyArchiveError, InvalidFolioDocumentPrivacyOptionsError, isFolioDocumentPrivacyTransform, rewriteDocxMetadataPrivacy } from "./metadataPrivacy.js";
4
+ import { getCachedNumberingMap } from "./numberingParser.js";
5
5
  export { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FolioDocumentPrivacyArchiveError, InvalidFolioDocumentPrivacyOptionsError, decryptDocxIfNeeded, getCachedNumberingMap, isDocxEncryptionError, isFolioDocumentPrivacyTransform, openDocxBuffer, rewriteDocxMetadataPrivacy };
@@ -1,13 +1,13 @@
1
- import { BorderStyleSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, TabLeaderSchema, TabStopAlignmentSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
2
- import { elementToXml, findChild, findChildren, getAttribute, getChildElements, getLocalName, mergeXmlnsDeclarations, parseBooleanElement, parseNumberingLevelAttribute, parseNumericAttribute } from "./xmlParser.js";
3
- import { parseRun, parseRunProperties } from "./runParser.js";
4
- import { parseFieldType } from "./fieldParser.js";
5
1
  import { isValidHexId } from "../utils/hexId.js";
6
2
  import { parseBookmarkEnd as parseBookmarkEnd$1, parseBookmarkStart as parseBookmarkStart$1 } from "./bookmarkParser.js";
3
+ import { parseFieldType } from "./fieldParser.js";
7
4
  import { parseHyperlink as parseHyperlink$1 } from "./hyperlinkParser.js";
5
+ import { BorderStyleSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, LineSpacingRuleSchema, ParagraphAlignmentSchema, ShadingPatternSchema, TabLeaderSchema, TabStopAlignmentSchema, ThemeColorSlotSchema, narrowEnum } from "./parserEnums.js";
8
6
  import { consolidateParagraphContent } from "./runConsolidator.js";
7
+ import { parseRun, parseRunProperties } from "./runParser.js";
9
8
  import { parseSdtProperties } from "./sdtProperties.js";
10
9
  import { parseSectionProperties } from "./sectionParser.js";
10
+ import { elementToXml, findChild, findChildren, getAttribute, getChildElements, getLocalName, matchesName, mergeXmlnsDeclarations, parseBooleanElement, parseNumberingLevelAttribute, parseNumericAttribute } from "./xmlParser.js";
11
11
  import { normalizeRevisionId } from "@stll/docx-core/model";
12
12
  //#region src/docx/paragraphParser.ts
13
13
  /**
@@ -684,6 +684,9 @@ function parseSimpleField(node, styles, theme, rels, media, rootXmlns = {}) {
684
684
  }
685
685
  return field;
686
686
  }
687
+ function hasRunPayloadElement(runElement) {
688
+ return getChildElements(runElement).some((child) => !matchesName(child, "w", "rPr"));
689
+ }
687
690
  /**
688
691
  * Parse all content within a paragraph
689
692
  *
@@ -789,7 +792,7 @@ function parseParagraphContents(paraElement, styles, theme, _numbering, rels, me
789
792
  type: "commentReference",
790
793
  id: commentReferenceId
791
794
  });
792
- } else contents.push(run);
795
+ } else if (run.content.length > 0 || hasRunPayloadElement(runElement)) contents.push(run);
793
796
  break;
794
797
  }
795
798
  case "hyperlink":
@@ -1,7 +1,7 @@
1
- import { findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
2
1
  import { pixelsToEmu } from "../utils/units.js";
3
- import { getTextBoxContentElement, isTextBoxDrawing, parseTextBox, parseTextBoxContent } from "./textBoxParser.js";
4
2
  import { parseParagraph } from "./paragraphParser.js";
3
+ import { getTextBoxContentElement, isTextBoxDrawing, parseTextBox, parseTextBoxContent } from "./textBoxParser.js";
4
+ import { findDeep, getAttribute, getChildElements, getLocalName } from "./xmlParser.js";
5
5
  //#region src/docx/paragraphTextBoxEnrichment.ts
6
6
  const VML_HORIZONTAL_RELATIVES = /* @__PURE__ */ new Set([
7
7
  "character",
@@ -285,11 +285,11 @@ const parseVmlTextBoxShape = (pictEl, styles, theme, numbering, rels, media, par
285
285
  if (positioned) shape.position = {
286
286
  horizontal: {
287
287
  relativeTo: horizontalRelativeTo(style["mso-position-horizontal-relative"]),
288
- ...left === void 0 ? {} : { posOffset: pixelsToEmu(left) }
288
+ posOffset: pixelsToEmu(left ?? 0)
289
289
  },
290
290
  vertical: {
291
291
  relativeTo: verticalRelativeTo(style["mso-position-vertical-relative"]),
292
- ...top === void 0 ? {} : { posOffset: pixelsToEmu(top) }
292
+ posOffset: pixelsToEmu(top ?? 0)
293
293
  }
294
294
  };
295
295
  return shape;
@@ -1,12 +1,14 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  //#region src/docx/paragraphTraversal.d.ts
3
- type VisitDocxParagraphsInput = {
3
+ type DocxParagraphSurfaces = {
4
4
  documentBody: document_d_exports.DocumentBody;
5
5
  headers?: Map<string, document_d_exports.HeaderFooter> | undefined;
6
6
  footers?: Map<string, document_d_exports.HeaderFooter> | undefined;
7
7
  footnotes?: readonly document_d_exports.Footnote[] | undefined;
8
8
  endnotes?: readonly document_d_exports.Endnote[] | undefined;
9
9
  };
10
- declare const visitDocxParagraphs: ({ documentBody, headers, footers, footnotes, endnotes }: VisitDocxParagraphsInput, visit: (paragraph: document_d_exports.Paragraph) => void) => void;
10
+ /** Visit every run directly owned by a paragraph's inline-content tree. */
11
+ declare const visitParagraphRuns: (paragraph: document_d_exports.Paragraph, visit: (run: document_d_exports.Run) => void) => void;
12
+ declare const visitDocxParagraphs: ({ documentBody, headers, footers, footnotes, endnotes }: DocxParagraphSurfaces, visit: (paragraph: document_d_exports.Paragraph) => void) => void;
11
13
  //#endregion
12
- export { visitDocxParagraphs };
14
+ export { DocxParagraphSurfaces, visitDocxParagraphs, visitParagraphRuns };
@@ -1,17 +1,8 @@
1
1
  //#region src/docx/paragraphTraversal.ts
2
- const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnotes }, visit) => {
3
- const seenParagraphs = /* @__PURE__ */ new WeakSet();
4
- const visitParagraph = (paragraph) => {
5
- if (seenParagraphs.has(paragraph)) return;
6
- seenParagraphs.add(paragraph);
7
- visit(paragraph);
8
- for (const content of paragraph.content) visitParagraphContent(content);
9
- };
2
+ /** Visit every run directly owned by a paragraph's inline-content tree. */
3
+ const visitParagraphRuns = (paragraph, visit) => {
10
4
  const visitRun = (run) => {
11
- for (const content of run.content) {
12
- if (content.type !== "shape" || !content.shape.textBody) continue;
13
- for (const block of content.shape.textBody.content) visitBlock(block);
14
- }
5
+ visit(run);
15
6
  };
16
7
  const visitHyperlink = (hyperlink) => {
17
8
  for (const child of hyperlink.children) if (child.type === "run") visitRun(child);
@@ -47,6 +38,22 @@ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnot
47
38
  for (const run of content.fieldResult) visitRun(run);
48
39
  }
49
40
  };
41
+ for (const content of paragraph.content) visitParagraphContent(content);
42
+ };
43
+ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnotes }, visit) => {
44
+ const seenParagraphs = /* @__PURE__ */ new WeakSet();
45
+ const visitParagraph = (paragraph) => {
46
+ if (seenParagraphs.has(paragraph)) return;
47
+ seenParagraphs.add(paragraph);
48
+ visit(paragraph);
49
+ visitParagraphRuns(paragraph, visitRun);
50
+ };
51
+ const visitRun = (run) => {
52
+ for (const content of run.content) {
53
+ if (content.type !== "shape" || !content.shape.textBody) continue;
54
+ for (const block of content.shape.textBody.content) visitBlock(block);
55
+ }
56
+ };
50
57
  const visitTable = (table) => {
51
58
  for (const row of table.rows) for (const cell of row.cells) visitBlocks(cell.content);
52
59
  };
@@ -73,4 +80,4 @@ const visitDocxParagraphs = ({ documentBody, headers, footers, footnotes, endnot
73
80
  for (const comment of documentBody.comments ?? []) for (const paragraph of comment.content) visitParagraph(paragraph);
74
81
  };
75
82
  //#endregion
76
- export { visitDocxParagraphs };
83
+ export { visitDocxParagraphs, visitParagraphRuns };
@@ -1,6 +1,3 @@
1
- import { parseNumbering } from "./numberingParser.js";
2
- import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
3
- import { applyThemeFontLang, parseTheme } from "./themeParser.js";
4
1
  import { toArrayBuffer } from "../utils/docxInput.js";
5
2
  import { loadFontsWithMapping } from "../utils/fontLoader.js";
6
3
  import { convertTiffToPngDataUrl, isTiffMimeType } from "../utils/tiffConverter.js";
@@ -9,19 +6,23 @@ import { normalizeCommentReferences } from "./commentReferenceNormalization.js";
9
6
  import { detectDocxConformanceClass } from "./conformance.js";
10
7
  import { parseCoreProperties } from "./corePropertiesParser.js";
11
8
  import { extractAllTemplateVariables, parseDocumentBody } from "./documentParser.js";
9
+ import { normalizeDrawingIds } from "./drawingIdNormalization.js";
10
+ import { DocxEncryptionError } from "./encryption/errors.js";
11
+ import { parseFontTable } from "./fontTableParser.js";
12
12
  import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
13
- import { assignHeaderFooterVerbatimXml } from "./headerFooterVerbatim.js";
14
13
  import { parseFooter, parseHeader } from "./headerFooterParser.js";
15
14
  import { normalizeHeaderFooterReferences } from "./headerFooterReferenceNormalization.js";
16
- import { DocxModelValidationError, formatDocumentModelIssues, validateFolioDocumentModel } from "./modelValidation.js";
15
+ import { assignHeaderFooterVerbatimXml, refreshHeaderFooterVerbatimFingerprint } from "./headerFooterVerbatim.js";
17
16
  import { extractMetafileRaster, isMetafileMimeType } from "./metafileRaster.js";
18
- import { parseFontTable } from "./fontTableParser.js";
17
+ import { DocxModelValidationError, formatDocumentModelIssues, validateFolioDocumentModel } from "./modelValidation.js";
18
+ import { parseNumbering } from "./numberingParser.js";
19
19
  import { normalizeNumberingReferences } from "./numberingReferenceNormalization.js";
20
+ import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
20
21
  import { normalizeRenderedPageBreakHints } from "./renderedPageBreakNormalization.js";
21
22
  import { parseSettings } from "./settingsParser.js";
22
23
  import { parseStylesPackage } from "./styleParser.js";
24
+ import { applyThemeFontLang, parseTheme } from "./themeParser.js";
23
25
  import { normalizeTrackedMoveRanges } from "./trackedMoveRangeNormalization.js";
24
- import { DocxEncryptionError } from "./encryption/errors.js";
25
26
  import { getMediaMimeType, mediaToDataUrl, unzipDocx } from "./unzip.js";
26
27
  import { TaggedError } from "better-result";
27
28
  //#region src/docx/parser.ts
@@ -123,6 +124,15 @@ async function parseDocx(input, options = {}) {
123
124
  onProgress("Parsing comments...", 75);
124
125
  const comments = timeStage("comments", () => parseComments(raw.commentsXml, styles, theme, rels, media, raw.commentsExtensibleXml, raw.commentsExtendedXml));
125
126
  if (comments.length > 0) documentBody.comments = comments;
127
+ normalizeDrawingIds({
128
+ documentBody,
129
+ ...headers !== void 0 ? { headers } : {},
130
+ ...footers !== void 0 ? { footers } : {},
131
+ ...footnotes !== void 0 ? { footnotes } : {},
132
+ ...endnotes !== void 0 ? { endnotes } : {}
133
+ });
134
+ for (const header of headers?.values() ?? []) refreshHeaderFooterVerbatimFingerprint(header);
135
+ for (const footer of footers?.values() ?? []) refreshHeaderFooterVerbatimFingerprint(footer);
126
136
  normalizeRenderedPageBreakHints({
127
137
  documentBody,
128
138
  ...headers !== void 0 ? { headers } : {},
@@ -19,6 +19,9 @@ declare const ParagraphAlignmentSchema: v.PicklistSchema<readonly ["left", "cent
19
19
  declare const LineSpacingRuleSchema: v.PicklistSchema<readonly ["auto", "exact", "atLeast"], undefined>;
20
20
  declare const TabStopAlignmentSchema: v.PicklistSchema<readonly ["left", "center", "right", "decimal", "bar", "clear", "num"], undefined>;
21
21
  declare const TabLeaderSchema: v.PicklistSchema<readonly ["none", "dot", "hyphen", "underscore", "heavy", "middleDot"], undefined>;
22
+ declare const PositionalTabRelativeToSchema: v.PicklistSchema<readonly ["margin", "indent"], undefined>;
23
+ declare const PositionalTabAlignmentSchema: v.PicklistSchema<readonly ["left", "center", "right"], undefined>;
24
+ declare const PositionalTabLeaderSchema: v.PicklistSchema<readonly ["none", "dot", "hyphen", "underscore", "middleDot"], undefined>;
22
25
  declare const FrameXAlignSchema: v.PicklistSchema<readonly ["left", "center", "right", "inside", "outside"], undefined>;
23
26
  declare const FrameYAlignSchema: v.PicklistSchema<readonly ["top", "center", "bottom", "inside", "outside", "inline"], undefined>;
24
27
  declare const FrameWrapSchema: v.PicklistSchema<readonly ["around", "auto", "none", "notBeside", "through", "tight"], undefined>;
@@ -42,4 +45,4 @@ declare const ShapeTypeSchema: v.PicklistSchema<readonly ["rect", "roundRect", "
42
45
  declare const NumberFormatSchema: v.PicklistSchema<readonly ["decimal", "upperRoman", "lowerRoman", "upperLetter", "lowerLetter", "ordinal", "cardinalText", "ordinalText", "hex", "chicago", "ideographDigital", "japaneseCounting", "aiueo", "iroha", "decimalFullWidth", "decimalHalfWidth", "japaneseLegal", "japaneseDigitalTenThousand", "decimalEnclosedCircle", "decimalFullWidth2", "aiueoFullWidth", "irohaFullWidth", "decimalZero", "decimalZero3", "decimalZero4", "decimalZero5", "bullet", "ganada", "chosung", "decimalEnclosedFullstop", "decimalEnclosedParen", "decimalEnclosedCircleChinese", "ideographEnclosedCircle", "ideographTraditional", "ideographZodiac", "ideographZodiacTraditional", "taiwaneseCounting", "ideographLegalTraditional", "taiwaneseCountingThousand", "taiwaneseDigital", "chineseCounting", "chineseLegalSimplified", "chineseCountingThousand", "koreanDigital", "koreanCounting", "koreanLegal", "koreanDigital2", "vietnameseCounting", "russianLower", "russianUpper", "none", "numberInDash", "hebrew1", "hebrew2", "arabicAlpha", "arabicAbjad", "hindiVowels", "hindiConsonants", "hindiNumbers", "hindiCounting", "thaiLetters", "thaiNumbers", "thaiCounting"], undefined>;
43
46
  declare const LevelSuffixSchema: v.PicklistSchema<readonly ["tab", "space", "nothing"], undefined>;
44
47
  //#endregion
45
- export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
48
+ export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, PositionalTabAlignmentSchema, PositionalTabLeaderSchema, PositionalTabRelativeToSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
@@ -1,4 +1,4 @@
1
- import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
1
+ import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, PARAGRAPH_ALIGNMENT_VALUES, POSITIONAL_TAB_ALIGNMENT_VALUES, POSITIONAL_TAB_LEADER_VALUES, POSITIONAL_TAB_RELATIVE_TO_VALUES, SDT_LOCK_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
2
2
  import * as v from "valibot";
3
3
  //#region src/docx/parserEnums.ts
4
4
  /**
@@ -45,6 +45,9 @@ const ParagraphAlignmentSchema = v.picklist(PARAGRAPH_ALIGNMENT_VALUES);
45
45
  const LineSpacingRuleSchema = v.picklist(LINE_SPACING_RULE_VALUES);
46
46
  const TabStopAlignmentSchema = v.picklist(TAB_STOP_ALIGNMENT_VALUES);
47
47
  const TabLeaderSchema = v.picklist(TAB_LEADER_VALUES);
48
+ const PositionalTabRelativeToSchema = v.picklist(POSITIONAL_TAB_RELATIVE_TO_VALUES);
49
+ const PositionalTabAlignmentSchema = v.picklist(POSITIONAL_TAB_ALIGNMENT_VALUES);
50
+ const PositionalTabLeaderSchema = v.picklist(POSITIONAL_TAB_LEADER_VALUES);
48
51
  const FrameXAlignSchema = v.picklist(FRAME_X_ALIGN_VALUES);
49
52
  const FrameYAlignSchema = v.picklist(FRAME_Y_ALIGN_VALUES);
50
53
  const FrameWrapSchema = v.picklist(FRAME_WRAP_VALUES);
@@ -68,4 +71,4 @@ const ShapeTypeSchema = v.picklist(SHAPE_TYPE_VALUES);
68
71
  const NumberFormatSchema = v.picklist(NUMBER_FORMAT_VALUES);
69
72
  const LevelSuffixSchema = v.picklist(LEVEL_SUFFIX_VALUES);
70
73
  //#endregion
71
- export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
74
+ export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, PositionalTabAlignmentSchema, PositionalTabLeaderSchema, PositionalTabRelativeToSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
@@ -1,24 +1,24 @@
1
- import { findChild, getChildElements, matchesName, parseXml } from "./xmlParser.js";
2
- import { parseNumbering } from "./numberingParser.js";
3
- import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
1
+ import { isAllowedExternalWatermarkImageUrl } from "../watermark/index.js";
2
+ import { withoutOrphanCommentRanges } from "./commentRangeIntegrity.js";
3
+ import { applyReplyThreadMarkers } from "./commentReplyMarkers.js";
4
4
  import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
5
5
  import { assertValidFolioDocumentModel } from "./modelValidation.js";
6
- import { isPreservableDocxEntry } from "./unzip.js";
7
- import { applyReplyThreadMarkers } from "./commentReplyMarkers.js";
8
- import { withoutOrphanCommentRanges } from "./commentRangeIntegrity.js";
9
6
  import { isNewDataUrlDrawing } from "./newImage.js";
7
+ import { parseNumbering } from "./numberingParser.js";
8
+ import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
10
9
  import { buildParagraphOffsetIndex, buildPatchedNoteXml, buildPatchedNumberingXml, collectChangedNumberingDefs, collectParaIds } from "./selectiveXmlPatch.js";
11
- import { escapeXml } from "./serializer/xmlUtils.js";
12
10
  import { ensureThreadedCommentParaIds, serializeComments, serializeCommentsExtended } from "./serializer/commentSerializer.js";
13
11
  import { serializeDocument } from "./serializer/documentSerializer.js";
12
+ import { serializeFontTableXml } from "./serializer/fontTableSerializer.js";
14
13
  import { serializeHeaderFooter } from "./serializer/headerFooterSerializer.js";
15
14
  import { serializeEndnotes, serializeFootnotes } from "./serializer/noteSerializer.js";
16
15
  import { serializeNumberingXml } from "./serializer/numberingSerializer.js";
17
- import { serializeFontTableXml } from "./serializer/fontTableSerializer.js";
18
16
  import { serializeSettingsXml } from "./serializer/settingsSerializer.js";
19
17
  import { serializeStylesXml } from "./serializer/stylesSerializer.js";
20
18
  import { serializeThemeXml } from "./serializer/themeSerializer.js";
21
- import { isAllowedExternalWatermarkImageUrl } from "../watermark/index.js";
19
+ import { escapeXml } from "./serializer/xmlUtils.js";
20
+ import { isPreservableDocxEntry } from "./unzip.js";
21
+ import { findChild, getChildElements, matchesName, parseXml } from "./xmlParser.js";
22
22
  import { panic } from "better-result";
23
23
  import JSZip from "jszip";
24
24
  //#region src/docx/rezip.ts
@@ -161,7 +161,6 @@ function consolidateRuns(runs) {
161
161
  return result;
162
162
  }
163
163
  function consolidateParagraphContent(content) {
164
- if (content.length <= 1) return content;
165
164
  const result = [];
166
165
  const pendingRuns = [];
167
166
  function flushRuns() {