docxmlater 10.1.4 → 10.1.6

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 (372) hide show
  1. package/README.md +759 -754
  2. package/dist/constants/legacyCompatFlags.js +1 -1
  3. package/dist/constants/legacyCompatFlags.js.map +1 -1
  4. package/dist/constants/limits.js.map +1 -1
  5. package/dist/core/Document.d.ts +51 -50
  6. package/dist/core/Document.d.ts.map +1 -1
  7. package/dist/core/Document.js +486 -471
  8. package/dist/core/Document.js.map +1 -1
  9. package/dist/core/DocumentContent.d.ts +9 -9
  10. package/dist/core/DocumentContent.d.ts.map +1 -1
  11. package/dist/core/DocumentContent.js +1 -1
  12. package/dist/core/DocumentContent.js.map +1 -1
  13. package/dist/core/DocumentGenerator.d.ts +11 -11
  14. package/dist/core/DocumentGenerator.d.ts.map +1 -1
  15. package/dist/core/DocumentGenerator.js +251 -251
  16. package/dist/core/DocumentGenerator.js.map +1 -1
  17. package/dist/core/DocumentIdManager.js.map +1 -1
  18. package/dist/core/DocumentParser.d.ts +15 -15
  19. package/dist/core/DocumentParser.d.ts.map +1 -1
  20. package/dist/core/DocumentParser.js +2123 -2155
  21. package/dist/core/DocumentParser.js.map +1 -1
  22. package/dist/core/DocumentValidator.d.ts.map +1 -1
  23. package/dist/core/DocumentValidator.js +2 -5
  24. package/dist/core/DocumentValidator.js.map +1 -1
  25. package/dist/core/Relationship.js.map +1 -1
  26. package/dist/core/RelationshipManager.d.ts.map +1 -1
  27. package/dist/core/RelationshipManager.js +3 -3
  28. package/dist/core/RelationshipManager.js.map +1 -1
  29. package/dist/elements/AlternateContent.js.map +1 -1
  30. package/dist/elements/Bookmark.d.ts.map +1 -1
  31. package/dist/elements/Bookmark.js +3 -1
  32. package/dist/elements/Bookmark.js.map +1 -1
  33. package/dist/elements/BookmarkManager.d.ts.map +1 -1
  34. package/dist/elements/BookmarkManager.js.map +1 -1
  35. package/dist/elements/Comment.d.ts.map +1 -1
  36. package/dist/elements/Comment.js +9 -6
  37. package/dist/elements/Comment.js.map +1 -1
  38. package/dist/elements/CommentManager.d.ts.map +1 -1
  39. package/dist/elements/CommentManager.js +18 -17
  40. package/dist/elements/CommentManager.js.map +1 -1
  41. package/dist/elements/CommonTypes.d.ts +21 -21
  42. package/dist/elements/CommonTypes.d.ts.map +1 -1
  43. package/dist/elements/CommonTypes.js +56 -56
  44. package/dist/elements/CommonTypes.js.map +1 -1
  45. package/dist/elements/CustomXml.js.map +1 -1
  46. package/dist/elements/Endnote.d.ts.map +1 -1
  47. package/dist/elements/Endnote.js +6 -6
  48. package/dist/elements/Endnote.js.map +1 -1
  49. package/dist/elements/EndnoteManager.d.ts.map +1 -1
  50. package/dist/elements/EndnoteManager.js +6 -7
  51. package/dist/elements/EndnoteManager.js.map +1 -1
  52. package/dist/elements/Field.d.ts.map +1 -1
  53. package/dist/elements/Field.js +82 -25
  54. package/dist/elements/Field.js.map +1 -1
  55. package/dist/elements/FieldHelpers.d.ts.map +1 -1
  56. package/dist/elements/FieldHelpers.js.map +1 -1
  57. package/dist/elements/FontManager.d.ts.map +1 -1
  58. package/dist/elements/FontManager.js +1 -1
  59. package/dist/elements/FontManager.js.map +1 -1
  60. package/dist/elements/Footer.js +2 -2
  61. package/dist/elements/Footer.js.map +1 -1
  62. package/dist/elements/Footnote.d.ts.map +1 -1
  63. package/dist/elements/Footnote.js +6 -6
  64. package/dist/elements/Footnote.js.map +1 -1
  65. package/dist/elements/FootnoteManager.d.ts.map +1 -1
  66. package/dist/elements/FootnoteManager.js +6 -7
  67. package/dist/elements/FootnoteManager.js.map +1 -1
  68. package/dist/elements/Header.js +2 -2
  69. package/dist/elements/Header.js.map +1 -1
  70. package/dist/elements/HeaderFooterManager.js.map +1 -1
  71. package/dist/elements/Hyperlink.d.ts +5 -3
  72. package/dist/elements/Hyperlink.d.ts.map +1 -1
  73. package/dist/elements/Hyperlink.js +134 -76
  74. package/dist/elements/Hyperlink.js.map +1 -1
  75. package/dist/elements/Image.d.ts.map +1 -1
  76. package/dist/elements/Image.js +238 -106
  77. package/dist/elements/Image.js.map +1 -1
  78. package/dist/elements/ImageManager.d.ts.map +1 -1
  79. package/dist/elements/ImageManager.js +1 -1
  80. package/dist/elements/ImageManager.js.map +1 -1
  81. package/dist/elements/ImageRun.js +1 -1
  82. package/dist/elements/ImageRun.js.map +1 -1
  83. package/dist/elements/MathElement.js.map +1 -1
  84. package/dist/elements/Paragraph.d.ts +24 -24
  85. package/dist/elements/Paragraph.d.ts.map +1 -1
  86. package/dist/elements/Paragraph.js +181 -188
  87. package/dist/elements/Paragraph.js.map +1 -1
  88. package/dist/elements/PreservedElement.js.map +1 -1
  89. package/dist/elements/PropertyChangeTypes.d.ts.map +1 -1
  90. package/dist/elements/PropertyChangeTypes.js +6 -6
  91. package/dist/elements/PropertyChangeTypes.js.map +1 -1
  92. package/dist/elements/RangeMarker.d.ts.map +1 -1
  93. package/dist/elements/RangeMarker.js.map +1 -1
  94. package/dist/elements/Revision.d.ts.map +1 -1
  95. package/dist/elements/Revision.js +4 -5
  96. package/dist/elements/Revision.js.map +1 -1
  97. package/dist/elements/RevisionContent.js.map +1 -1
  98. package/dist/elements/RevisionManager.d.ts.map +1 -1
  99. package/dist/elements/RevisionManager.js +40 -48
  100. package/dist/elements/RevisionManager.js.map +1 -1
  101. package/dist/elements/Run.d.ts +16 -16
  102. package/dist/elements/Run.d.ts.map +1 -1
  103. package/dist/elements/Run.js +256 -238
  104. package/dist/elements/Run.js.map +1 -1
  105. package/dist/elements/Section.d.ts.map +1 -1
  106. package/dist/elements/Section.js +36 -11
  107. package/dist/elements/Section.js.map +1 -1
  108. package/dist/elements/Shape.d.ts.map +1 -1
  109. package/dist/elements/Shape.js.map +1 -1
  110. package/dist/elements/StructuredDocumentTag.d.ts +6 -6
  111. package/dist/elements/StructuredDocumentTag.d.ts.map +1 -1
  112. package/dist/elements/StructuredDocumentTag.js +99 -104
  113. package/dist/elements/StructuredDocumentTag.js.map +1 -1
  114. package/dist/elements/Table.d.ts +11 -11
  115. package/dist/elements/Table.d.ts.map +1 -1
  116. package/dist/elements/Table.js +102 -107
  117. package/dist/elements/Table.js.map +1 -1
  118. package/dist/elements/TableCell.d.ts +10 -10
  119. package/dist/elements/TableCell.d.ts.map +1 -1
  120. package/dist/elements/TableCell.js +105 -106
  121. package/dist/elements/TableCell.js.map +1 -1
  122. package/dist/elements/TableGridChange.d.ts.map +1 -1
  123. package/dist/elements/TableGridChange.js.map +1 -1
  124. package/dist/elements/TableOfContents.d.ts.map +1 -1
  125. package/dist/elements/TableOfContents.js +4 -4
  126. package/dist/elements/TableOfContents.js.map +1 -1
  127. package/dist/elements/TableOfContentsElement.js.map +1 -1
  128. package/dist/elements/TableRow.d.ts.map +1 -1
  129. package/dist/elements/TableRow.js +13 -6
  130. package/dist/elements/TableRow.js.map +1 -1
  131. package/dist/elements/TextBox.d.ts.map +1 -1
  132. package/dist/elements/TextBox.js +3 -5
  133. package/dist/elements/TextBox.js.map +1 -1
  134. package/dist/formatting/AbstractNumbering.d.ts +4 -4
  135. package/dist/formatting/AbstractNumbering.d.ts.map +1 -1
  136. package/dist/formatting/AbstractNumbering.js +54 -49
  137. package/dist/formatting/AbstractNumbering.js.map +1 -1
  138. package/dist/formatting/NumberingInstance.d.ts.map +1 -1
  139. package/dist/formatting/NumberingInstance.js +1 -3
  140. package/dist/formatting/NumberingInstance.js.map +1 -1
  141. package/dist/formatting/NumberingLevel.d.ts +5 -5
  142. package/dist/formatting/NumberingLevel.d.ts.map +1 -1
  143. package/dist/formatting/NumberingLevel.js +119 -125
  144. package/dist/formatting/NumberingLevel.js.map +1 -1
  145. package/dist/formatting/NumberingManager.d.ts +1 -0
  146. package/dist/formatting/NumberingManager.d.ts.map +1 -1
  147. package/dist/formatting/NumberingManager.js +27 -9
  148. package/dist/formatting/NumberingManager.js.map +1 -1
  149. package/dist/formatting/Style.d.ts +11 -11
  150. package/dist/formatting/Style.d.ts.map +1 -1
  151. package/dist/formatting/Style.js +219 -247
  152. package/dist/formatting/Style.js.map +1 -1
  153. package/dist/formatting/StylesManager.d.ts +2 -2
  154. package/dist/formatting/StylesManager.d.ts.map +1 -1
  155. package/dist/formatting/StylesManager.js +96 -102
  156. package/dist/formatting/StylesManager.js.map +1 -1
  157. package/dist/helpers/CleanupHelper.d.ts +1 -1
  158. package/dist/helpers/CleanupHelper.d.ts.map +1 -1
  159. package/dist/helpers/CleanupHelper.js +6 -6
  160. package/dist/helpers/CleanupHelper.js.map +1 -1
  161. package/dist/images/ImageOptimizer.js +7 -7
  162. package/dist/images/ImageOptimizer.js.map +1 -1
  163. package/dist/index.d.ts +9 -9
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js.map +1 -1
  166. package/dist/managers/DrawingManager.js.map +1 -1
  167. package/dist/tracking/DocumentTrackingContext.d.ts.map +1 -1
  168. package/dist/tracking/DocumentTrackingContext.js +23 -7
  169. package/dist/tracking/DocumentTrackingContext.js.map +1 -1
  170. package/dist/tracking/TrackingContext.d.ts.map +1 -1
  171. package/dist/tracking/TrackingContext.js.map +1 -1
  172. package/dist/types/compatibility-types.js.map +1 -1
  173. package/dist/types/formatting.js.map +1 -1
  174. package/dist/types/list-types.d.ts +6 -6
  175. package/dist/types/list-types.js.map +1 -1
  176. package/dist/types/settings-types.js.map +1 -1
  177. package/dist/types/styleConfig.d.ts +2 -2
  178. package/dist/types/styleConfig.js.map +1 -1
  179. package/dist/utils/ChangelogGenerator.d.ts.map +1 -1
  180. package/dist/utils/ChangelogGenerator.js +97 -101
  181. package/dist/utils/ChangelogGenerator.js.map +1 -1
  182. package/dist/utils/CompatibilityUpgrader.d.ts.map +1 -1
  183. package/dist/utils/CompatibilityUpgrader.js +1 -1
  184. package/dist/utils/CompatibilityUpgrader.js.map +1 -1
  185. package/dist/utils/InMemoryRevisionAcceptor.d.ts.map +1 -1
  186. package/dist/utils/InMemoryRevisionAcceptor.js +1 -6
  187. package/dist/utils/InMemoryRevisionAcceptor.js.map +1 -1
  188. package/dist/utils/MoveOperationHelper.d.ts.map +1 -1
  189. package/dist/utils/MoveOperationHelper.js +1 -1
  190. package/dist/utils/MoveOperationHelper.js.map +1 -1
  191. package/dist/utils/RevisionAwareProcessor.d.ts.map +1 -1
  192. package/dist/utils/RevisionAwareProcessor.js +2 -4
  193. package/dist/utils/RevisionAwareProcessor.js.map +1 -1
  194. package/dist/utils/RevisionWalker.d.ts.map +1 -1
  195. package/dist/utils/RevisionWalker.js +4 -12
  196. package/dist/utils/RevisionWalker.js.map +1 -1
  197. package/dist/utils/SelectiveRevisionAcceptor.d.ts.map +1 -1
  198. package/dist/utils/SelectiveRevisionAcceptor.js +2 -6
  199. package/dist/utils/SelectiveRevisionAcceptor.js.map +1 -1
  200. package/dist/utils/ShadingResolver.d.ts.map +1 -1
  201. package/dist/utils/ShadingResolver.js +1 -1
  202. package/dist/utils/ShadingResolver.js.map +1 -1
  203. package/dist/utils/acceptRevisions.d.ts.map +1 -1
  204. package/dist/utils/acceptRevisions.js +23 -12
  205. package/dist/utils/acceptRevisions.js.map +1 -1
  206. package/dist/utils/cnfStyleDecoder.d.ts +1 -1
  207. package/dist/utils/cnfStyleDecoder.d.ts.map +1 -1
  208. package/dist/utils/cnfStyleDecoder.js +40 -40
  209. package/dist/utils/cnfStyleDecoder.js.map +1 -1
  210. package/dist/utils/corruptionDetection.d.ts.map +1 -1
  211. package/dist/utils/corruptionDetection.js.map +1 -1
  212. package/dist/utils/dateFormatting.js.map +1 -1
  213. package/dist/utils/deepClone.js +1 -1
  214. package/dist/utils/deepClone.js.map +1 -1
  215. package/dist/utils/diagnostics.d.ts.map +1 -1
  216. package/dist/utils/diagnostics.js +1 -1
  217. package/dist/utils/diagnostics.js.map +1 -1
  218. package/dist/utils/errorHandling.js.map +1 -1
  219. package/dist/utils/formatting.d.ts.map +1 -1
  220. package/dist/utils/formatting.js +10 -2
  221. package/dist/utils/formatting.js.map +1 -1
  222. package/dist/utils/list-detection.d.ts +2 -2
  223. package/dist/utils/list-detection.d.ts.map +1 -1
  224. package/dist/utils/list-detection.js +21 -23
  225. package/dist/utils/list-detection.js.map +1 -1
  226. package/dist/utils/logger.d.ts.map +1 -1
  227. package/dist/utils/logger.js +12 -7
  228. package/dist/utils/logger.js.map +1 -1
  229. package/dist/utils/parsingHelpers.js.map +1 -1
  230. package/dist/utils/stripTrackedChanges.d.ts.map +1 -1
  231. package/dist/utils/stripTrackedChanges.js +3 -3
  232. package/dist/utils/stripTrackedChanges.js.map +1 -1
  233. package/dist/utils/textDiff.d.ts +1 -1
  234. package/dist/utils/textDiff.js +8 -8
  235. package/dist/utils/textDiff.js.map +1 -1
  236. package/dist/utils/units.js.map +1 -1
  237. package/dist/utils/validation.d.ts.map +1 -1
  238. package/dist/utils/validation.js +24 -7
  239. package/dist/utils/validation.js.map +1 -1
  240. package/dist/utils/xmlSanitization.d.ts.map +1 -1
  241. package/dist/utils/xmlSanitization.js +3 -3
  242. package/dist/utils/xmlSanitization.js.map +1 -1
  243. package/dist/validation/RevisionAutoFixer.d.ts.map +1 -1
  244. package/dist/validation/RevisionAutoFixer.js +5 -5
  245. package/dist/validation/RevisionAutoFixer.js.map +1 -1
  246. package/dist/validation/RevisionValidator.d.ts.map +1 -1
  247. package/dist/validation/RevisionValidator.js +7 -9
  248. package/dist/validation/RevisionValidator.js.map +1 -1
  249. package/dist/validation/ValidationRules.js +3 -3
  250. package/dist/validation/ValidationRules.js.map +1 -1
  251. package/dist/validation/index.js.map +1 -1
  252. package/dist/xml/XMLBuilder.d.ts +1 -1
  253. package/dist/xml/XMLBuilder.d.ts.map +1 -1
  254. package/dist/xml/XMLBuilder.js +98 -100
  255. package/dist/xml/XMLBuilder.js.map +1 -1
  256. package/dist/xml/XMLParser.d.ts.map +1 -1
  257. package/dist/xml/XMLParser.js +61 -66
  258. package/dist/xml/XMLParser.js.map +1 -1
  259. package/dist/zip/ZipHandler.d.ts.map +1 -1
  260. package/dist/zip/ZipHandler.js.map +1 -1
  261. package/dist/zip/ZipReader.d.ts.map +1 -1
  262. package/dist/zip/ZipReader.js +1 -3
  263. package/dist/zip/ZipReader.js.map +1 -1
  264. package/dist/zip/ZipWriter.d.ts +1 -1
  265. package/dist/zip/ZipWriter.d.ts.map +1 -1
  266. package/dist/zip/ZipWriter.js +28 -36
  267. package/dist/zip/ZipWriter.js.map +1 -1
  268. package/dist/zip/types.js +1 -1
  269. package/dist/zip/types.js.map +1 -1
  270. package/package.json +92 -92
  271. package/src/__tests__/helper-methods.test.ts +512 -512
  272. package/src/constants/legacyCompatFlags.ts +138 -138
  273. package/src/constants/limits.ts +50 -50
  274. package/src/core/Document.ts +1010 -1145
  275. package/src/core/DocumentContent.ts +461 -467
  276. package/src/core/DocumentGenerator.ts +1133 -1104
  277. package/src/core/DocumentIdManager.ts +158 -158
  278. package/src/core/DocumentParser.ts +2347 -2716
  279. package/src/core/DocumentValidator.ts +363 -372
  280. package/src/core/Relationship.ts +367 -367
  281. package/src/core/RelationshipManager.ts +429 -428
  282. package/src/elements/AlternateContent.ts +42 -42
  283. package/src/elements/Bookmark.ts +212 -210
  284. package/src/elements/BookmarkManager.ts +247 -250
  285. package/src/elements/Comment.ts +356 -359
  286. package/src/elements/CommentManager.ts +499 -502
  287. package/src/elements/CommonTypes.ts +524 -549
  288. package/src/elements/CustomXml.ts +36 -36
  289. package/src/elements/Endnote.ts +221 -217
  290. package/src/elements/EndnoteManager.ts +246 -249
  291. package/src/elements/Field.ts +1292 -1233
  292. package/src/elements/FieldHelpers.ts +329 -333
  293. package/src/elements/FontManager.ts +336 -339
  294. package/src/elements/Footer.ts +269 -269
  295. package/src/elements/Footnote.ts +221 -217
  296. package/src/elements/FootnoteManager.ts +246 -249
  297. package/src/elements/Header.ts +269 -269
  298. package/src/elements/HeaderFooterManager.ts +219 -219
  299. package/src/elements/Hyperlink.ts +1288 -1193
  300. package/src/elements/Image.ts +1982 -1756
  301. package/src/elements/ImageManager.ts +437 -432
  302. package/src/elements/ImageRun.ts +59 -59
  303. package/src/elements/MathElement.ts +65 -65
  304. package/src/elements/Paragraph.ts +4347 -4287
  305. package/src/elements/PreservedElement.ts +53 -53
  306. package/src/elements/PropertyChangeTypes.ts +458 -442
  307. package/src/elements/RangeMarker.ts +382 -400
  308. package/src/elements/Revision.ts +1198 -1217
  309. package/src/elements/RevisionContent.ts +73 -73
  310. package/src/elements/RevisionManager.ts +1070 -1070
  311. package/src/elements/Run.ts +3103 -3073
  312. package/src/elements/Section.ts +1521 -1421
  313. package/src/elements/Shape.ts +884 -873
  314. package/src/elements/StructuredDocumentTag.ts +1176 -1207
  315. package/src/elements/Table.ts +2468 -2524
  316. package/src/elements/TableCell.ts +1617 -1621
  317. package/src/elements/TableGridChange.ts +149 -151
  318. package/src/elements/TableOfContents.ts +701 -691
  319. package/src/elements/TableOfContentsElement.ts +89 -89
  320. package/src/elements/TableRow.ts +960 -929
  321. package/src/elements/TextBox.ts +766 -768
  322. package/src/formatting/AbstractNumbering.ts +580 -579
  323. package/src/formatting/NumberingInstance.ts +295 -299
  324. package/src/formatting/NumberingLevel.ts +981 -1040
  325. package/src/formatting/NumberingManager.ts +875 -827
  326. package/src/formatting/Style.ts +1785 -1879
  327. package/src/formatting/StylesManager.ts +1090 -1130
  328. package/src/helpers/CleanupHelper.ts +524 -524
  329. package/src/images/ImageOptimizer.ts +274 -274
  330. package/src/index.ts +559 -554
  331. package/src/managers/DrawingManager.ts +319 -319
  332. package/src/tracking/DocumentTrackingContext.ts +687 -674
  333. package/src/tracking/TrackingContext.ts +175 -173
  334. package/src/types/compatibility-types.ts +49 -49
  335. package/src/types/formatting.ts +210 -210
  336. package/src/types/list-types.ts +14 -14
  337. package/src/types/settings-types.ts +59 -59
  338. package/src/types/styleConfig.ts +189 -189
  339. package/src/utils/ChangelogGenerator.ts +1583 -1581
  340. package/src/utils/CompatibilityUpgrader.ts +235 -237
  341. package/src/utils/InMemoryRevisionAcceptor.ts +691 -696
  342. package/src/utils/MoveOperationHelper.ts +233 -238
  343. package/src/utils/RevisionAwareProcessor.ts +518 -526
  344. package/src/utils/RevisionWalker.ts +427 -457
  345. package/src/utils/SelectiveRevisionAcceptor.ts +662 -683
  346. package/src/utils/ShadingResolver.ts +105 -107
  347. package/src/utils/acceptRevisions.ts +723 -714
  348. package/src/utils/cnfStyleDecoder.ts +212 -217
  349. package/src/utils/corruptionDetection.ts +346 -345
  350. package/src/utils/dateFormatting.ts +20 -20
  351. package/src/utils/deepClone.ts +77 -78
  352. package/src/utils/diagnostics.ts +125 -129
  353. package/src/utils/errorHandling.ts +80 -80
  354. package/src/utils/formatting.ts +220 -213
  355. package/src/utils/list-detection.ts +32 -42
  356. package/src/utils/logger.ts +412 -404
  357. package/src/utils/parsingHelpers.ts +190 -190
  358. package/src/utils/stripTrackedChanges.ts +356 -353
  359. package/src/utils/textDiff.ts +100 -100
  360. package/src/utils/units.ts +421 -421
  361. package/src/utils/validation.ts +553 -542
  362. package/src/utils/xmlSanitization.ts +179 -182
  363. package/src/validation/RevisionAutoFixer.ts +541 -542
  364. package/src/validation/RevisionValidator.ts +470 -460
  365. package/src/validation/ValidationRules.ts +338 -338
  366. package/src/validation/index.ts +30 -30
  367. package/src/xml/XMLBuilder.ts +857 -871
  368. package/src/xml/XMLParser.ts +877 -919
  369. package/src/zip/ZipHandler.ts +629 -637
  370. package/src/zip/ZipReader.ts +295 -299
  371. package/src/zip/ZipWriter.ts +374 -390
  372. package/src/zip/types.ts +116 -116
@@ -1,213 +1,220 @@
1
- /**
2
- * Formatting utilities for deep merging and cloning formatting objects
3
- * Used for style inheritance and applying formatting
4
- */
5
-
6
- /**
7
- * Deep merges two formatting objects, with override taking precedence
8
- * Used for style inheritance and applying formatting
9
- *
10
- * @param base - Base formatting object
11
- * @param override - Override formatting object (takes precedence)
12
- * @returns Merged formatting object
13
- *
14
- * @example
15
- * ```typescript
16
- * const baseFormat = { bold: true, fontSize: 24 };
17
- * const overrideFormat = { fontSize: 28, italic: true };
18
- * const result = mergeFormatting(baseFormat, overrideFormat);
19
- * // Result: { bold: true, fontSize: 28, italic: true }
20
- * ```
21
- */
22
- export function mergeFormatting<T extends Record<string, any>>(
23
- base: T,
24
- override: Partial<T>
25
- ): T {
26
- const result = { ...base };
27
-
28
- for (const [key, value] of Object.entries(override)) {
29
- if (value === undefined) continue;
30
-
31
- if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
32
- // Deep merge nested objects
33
- result[key as keyof T] = mergeFormatting(
34
- result[key as keyof T] || ({} as any),
35
- value
36
- );
37
- } else {
38
- // Direct assignment for primitives
39
- result[key as keyof T] = value;
40
- }
41
- }
42
-
43
- return result;
44
- }
45
-
46
- /**
47
- * Deep clones a formatting object
48
- * Creates a completely independent copy with no shared references
49
- *
50
- * @param formatting - Formatting object to clone
51
- * @returns Cloned formatting object
52
- *
53
- * @example
54
- * ```typescript
55
- * const original = { bold: true, indentation: { left: 100 } };
56
- * const cloned = cloneFormatting(original);
57
- * cloned.indentation.left = 200; // Doesn't affect original
58
- * ```
59
- */
60
- export function cloneFormatting<T>(formatting: T): T {
61
- return JSON.parse(JSON.stringify(formatting));
62
- }
63
-
64
- /**
65
- * Checks if a formatting object has any defined properties
66
- *
67
- * @param formatting - Formatting object to check
68
- * @returns True if the object has at least one defined property
69
- *
70
- * @example
71
- * ```typescript
72
- * hasFormatting({}) // false
73
- * hasFormatting({ bold: true }) // true
74
- * hasFormatting({ bold: undefined }) // false
75
- * ```
76
- */
77
- export function hasFormatting(formatting: Record<string, unknown>): boolean {
78
- for (const value of Object.values(formatting)) {
79
- if (value !== undefined && value !== null) {
80
- return true;
81
- }
82
- }
83
- return false;
84
- }
85
-
86
- /**
87
- * Removes undefined and null properties from a formatting object
88
- * Useful for cleaning up formatting before comparison or serialization
89
- *
90
- * @param formatting - Formatting object to clean
91
- * @returns Cleaned formatting object with no undefined/null values
92
- *
93
- * @example
94
- * ```typescript
95
- * const dirty = { bold: true, italic: undefined, fontSize: null, underline: false };
96
- * const clean = cleanFormatting(dirty);
97
- * // Result: { bold: true, underline: false }
98
- * ```
99
- */
100
- export function cleanFormatting<T extends Record<string, any>>(formatting: T): Partial<T> {
101
- const cleaned: Partial<T> = {};
102
-
103
- for (const [key, value] of Object.entries(formatting)) {
104
- if (value !== undefined && value !== null) {
105
- if (typeof value === 'object' && !Array.isArray(value)) {
106
- // Recursively clean nested objects
107
- const cleanedNested = cleanFormatting(value);
108
- if (Object.keys(cleanedNested).length > 0) {
109
- cleaned[key as keyof T] = cleanedNested as any;
110
- }
111
- } else {
112
- cleaned[key as keyof T] = value;
113
- }
114
- }
115
- }
116
-
117
- return cleaned;
118
- }
119
-
120
- /**
121
- * Compares two formatting objects for equality
122
- * Performs deep comparison of all properties
123
- *
124
- * @param format1 - First formatting object
125
- * @param format2 - Second formatting object
126
- * @returns True if the formatting objects are equal
127
- *
128
- * @example
129
- * ```typescript
130
- * const a = { bold: true, fontSize: 24 };
131
- * const b = { bold: true, fontSize: 24 };
132
- * const c = { bold: true, fontSize: 28 };
133
- * isEqualFormatting(a, b) // true
134
- * isEqualFormatting(a, c) // false
135
- * ```
136
- */
137
- export function isEqualFormatting(
138
- format1: Record<string, unknown>,
139
- format2: Record<string, unknown>
140
- ): boolean {
141
- // Quick reference check
142
- if (format1 === format2) return true;
143
-
144
- // Null/undefined checks
145
- if (!format1 || !format2) return false;
146
-
147
- // Get all keys from both objects
148
- const keys1 = Object.keys(format1);
149
- const keys2 = Object.keys(format2);
150
-
151
- // Check if they have the same number of properties
152
- if (keys1.length !== keys2.length) return false;
153
-
154
- // Check all properties
155
- for (const key of keys1) {
156
- const val1 = format1[key];
157
- const val2 = format2[key];
158
-
159
- // Both undefined/null - considered equal
160
- if ((val1 === undefined || val1 === null) && (val2 === undefined || val2 === null)) {
161
- continue;
162
- }
163
-
164
- // One is undefined/null and the other isn't
165
- if ((val1 === undefined || val1 === null) !== (val2 === undefined || val2 === null)) {
166
- return false;
167
- }
168
-
169
- // Check nested objects
170
- if (typeof val1 === 'object' && val1 !== null && typeof val2 === 'object' && val2 !== null && !Array.isArray(val1) && !Array.isArray(val2)) {
171
- if (!isEqualFormatting(val1 as Record<string, unknown>, val2 as Record<string, unknown>)) return false;
172
- } else if (val1 !== val2) {
173
- return false;
174
- }
175
- }
176
-
177
- return true;
178
- }
179
-
180
- /**
181
- * Applies default values to a formatting object for any undefined properties
182
- *
183
- * @param formatting - Formatting object to apply defaults to
184
- * @param defaults - Default values
185
- * @returns Formatting object with defaults applied
186
- *
187
- * @example
188
- * ```typescript
189
- * const format = { bold: true };
190
- * const defaults = { bold: false, italic: false, fontSize: 24 };
191
- * const result = applyDefaults(format, defaults);
192
- * // Result: { bold: true, italic: false, fontSize: 24 }
193
- * ```
194
- */
195
- export function applyDefaults<T extends Record<string, any>>(
196
- formatting: Partial<T>,
197
- defaults: T
198
- ): T {
199
- const result = { ...defaults };
200
-
201
- for (const [key, value] of Object.entries(formatting)) {
202
- if (value !== undefined) {
203
- if (typeof value === 'object' && !Array.isArray(value) && value !== null && typeof defaults[key] === 'object') {
204
- // Deep merge nested objects
205
- result[key as keyof T] = applyDefaults(value, defaults[key]);
206
- } else {
207
- result[key as keyof T] = value;
208
- }
209
- }
210
- }
211
-
212
- return result;
213
- }
1
+ /**
2
+ * Formatting utilities for deep merging and cloning formatting objects
3
+ * Used for style inheritance and applying formatting
4
+ */
5
+
6
+ /**
7
+ * Deep merges two formatting objects, with override taking precedence
8
+ * Used for style inheritance and applying formatting
9
+ *
10
+ * @param base - Base formatting object
11
+ * @param override - Override formatting object (takes precedence)
12
+ * @returns Merged formatting object
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const baseFormat = { bold: true, fontSize: 24 };
17
+ * const overrideFormat = { fontSize: 28, italic: true };
18
+ * const result = mergeFormatting(baseFormat, overrideFormat);
19
+ * // Result: { bold: true, fontSize: 28, italic: true }
20
+ * ```
21
+ */
22
+ export function mergeFormatting<T extends Record<string, any>>(base: T, override: Partial<T>): T {
23
+ const result = { ...base };
24
+
25
+ for (const [key, value] of Object.entries(override)) {
26
+ if (value === undefined) continue;
27
+
28
+ if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
29
+ // Deep merge nested objects
30
+ result[key as keyof T] = mergeFormatting(result[key as keyof T] || ({} as any), value);
31
+ } else {
32
+ // Direct assignment for primitives
33
+ result[key as keyof T] = value;
34
+ }
35
+ }
36
+
37
+ return result;
38
+ }
39
+
40
+ /**
41
+ * Deep clones a formatting object
42
+ * Creates a completely independent copy with no shared references
43
+ *
44
+ * @param formatting - Formatting object to clone
45
+ * @returns Cloned formatting object
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const original = { bold: true, indentation: { left: 100 } };
50
+ * const cloned = cloneFormatting(original);
51
+ * cloned.indentation.left = 200; // Doesn't affect original
52
+ * ```
53
+ */
54
+ export function cloneFormatting<T>(formatting: T): T {
55
+ return JSON.parse(JSON.stringify(formatting));
56
+ }
57
+
58
+ /**
59
+ * Checks if a formatting object has any defined properties
60
+ *
61
+ * @param formatting - Formatting object to check
62
+ * @returns True if the object has at least one defined property
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * hasFormatting({}) // false
67
+ * hasFormatting({ bold: true }) // true
68
+ * hasFormatting({ bold: undefined }) // false
69
+ * ```
70
+ */
71
+ export function hasFormatting(formatting: Record<string, unknown>): boolean {
72
+ for (const value of Object.values(formatting)) {
73
+ if (value !== undefined && value !== null) {
74
+ return true;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Removes undefined and null properties from a formatting object
82
+ * Useful for cleaning up formatting before comparison or serialization
83
+ *
84
+ * @param formatting - Formatting object to clean
85
+ * @returns Cleaned formatting object with no undefined/null values
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const dirty = { bold: true, italic: undefined, fontSize: null, underline: false };
90
+ * const clean = cleanFormatting(dirty);
91
+ * // Result: { bold: true, underline: false }
92
+ * ```
93
+ */
94
+ export function cleanFormatting<T extends Record<string, any>>(formatting: T): Partial<T> {
95
+ const cleaned: Partial<T> = {};
96
+
97
+ for (const [key, value] of Object.entries(formatting)) {
98
+ if (value !== undefined && value !== null) {
99
+ if (typeof value === 'object' && !Array.isArray(value)) {
100
+ // Recursively clean nested objects
101
+ const cleanedNested = cleanFormatting(value);
102
+ if (Object.keys(cleanedNested).length > 0) {
103
+ cleaned[key as keyof T] = cleanedNested as any;
104
+ }
105
+ } else {
106
+ cleaned[key as keyof T] = value;
107
+ }
108
+ }
109
+ }
110
+
111
+ return cleaned;
112
+ }
113
+
114
+ /**
115
+ * Compares two formatting objects for equality
116
+ * Performs deep comparison of all properties
117
+ *
118
+ * @param format1 - First formatting object
119
+ * @param format2 - Second formatting object
120
+ * @returns True if the formatting objects are equal
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const a = { bold: true, fontSize: 24 };
125
+ * const b = { bold: true, fontSize: 24 };
126
+ * const c = { bold: true, fontSize: 28 };
127
+ * isEqualFormatting(a, b) // true
128
+ * isEqualFormatting(a, c) // false
129
+ * ```
130
+ */
131
+ export function isEqualFormatting(
132
+ format1: Record<string, unknown>,
133
+ format2: Record<string, unknown>
134
+ ): boolean {
135
+ // Quick reference check
136
+ if (format1 === format2) return true;
137
+
138
+ // Null/undefined checks
139
+ if (!format1 || !format2) return false;
140
+
141
+ // Get all keys from both objects
142
+ const keys1 = Object.keys(format1);
143
+ const keys2 = Object.keys(format2);
144
+
145
+ // Check if they have the same number of properties
146
+ if (keys1.length !== keys2.length) return false;
147
+
148
+ // Check all properties
149
+ for (const key of keys1) {
150
+ const val1 = format1[key];
151
+ const val2 = format2[key];
152
+
153
+ // Both undefined/null - considered equal
154
+ if ((val1 === undefined || val1 === null) && (val2 === undefined || val2 === null)) {
155
+ continue;
156
+ }
157
+
158
+ // One is undefined/null and the other isn't
159
+ if ((val1 === undefined || val1 === null) !== (val2 === undefined || val2 === null)) {
160
+ return false;
161
+ }
162
+
163
+ // Check nested objects
164
+ if (
165
+ typeof val1 === 'object' &&
166
+ val1 !== null &&
167
+ typeof val2 === 'object' &&
168
+ val2 !== null &&
169
+ !Array.isArray(val1) &&
170
+ !Array.isArray(val2)
171
+ ) {
172
+ if (!isEqualFormatting(val1 as Record<string, unknown>, val2 as Record<string, unknown>))
173
+ return false;
174
+ } else if (val1 !== val2) {
175
+ return false;
176
+ }
177
+ }
178
+
179
+ return true;
180
+ }
181
+
182
+ /**
183
+ * Applies default values to a formatting object for any undefined properties
184
+ *
185
+ * @param formatting - Formatting object to apply defaults to
186
+ * @param defaults - Default values
187
+ * @returns Formatting object with defaults applied
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const format = { bold: true };
192
+ * const defaults = { bold: false, italic: false, fontSize: 24 };
193
+ * const result = applyDefaults(format, defaults);
194
+ * // Result: { bold: true, italic: false, fontSize: 24 }
195
+ * ```
196
+ */
197
+ export function applyDefaults<T extends Record<string, any>>(
198
+ formatting: Partial<T>,
199
+ defaults: T
200
+ ): T {
201
+ const result = { ...defaults };
202
+
203
+ for (const [key, value] of Object.entries(formatting)) {
204
+ if (value !== undefined) {
205
+ if (
206
+ typeof value === 'object' &&
207
+ !Array.isArray(value) &&
208
+ value !== null &&
209
+ typeof defaults[key] === 'object'
210
+ ) {
211
+ // Deep merge nested objects
212
+ result[key as keyof T] = applyDefaults(value, defaults[key]);
213
+ } else {
214
+ result[key as keyof T] = value;
215
+ }
216
+ }
217
+ }
218
+
219
+ return result;
220
+ }
@@ -5,13 +5,13 @@
5
5
  * paragraph list properties.
6
6
  */
7
7
 
8
- import type { Paragraph } from "../elements/Paragraph";
8
+ import type { Paragraph } from '../elements/Paragraph';
9
9
  import type {
10
10
  ListCategory,
11
11
  ListDetectionResult,
12
12
  NumberFormat,
13
13
  BulletFormat,
14
- } from "../types/list-types";
14
+ } from '../types/list-types';
15
15
 
16
16
  // =============================================================================
17
17
  // CONSTANTS
@@ -36,13 +36,13 @@ export const TYPED_LIST_PATTERNS: Record<string, RegExp> = {
36
36
 
37
37
  /** Map pattern names to categories */
38
38
  export const PATTERN_TO_CATEGORY: Record<string, ListCategory> = {
39
- decimal: "numbered",
40
- lowerLetter: "numbered",
41
- upperLetter: "numbered",
42
- lowerRoman: "numbered",
43
- bullet: "bullet",
44
- dash: "bullet",
45
- arrow: "bullet",
39
+ decimal: 'numbered',
40
+ lowerLetter: 'numbered',
41
+ upperLetter: 'numbered',
42
+ lowerRoman: 'numbered',
43
+ bullet: 'bullet',
44
+ dash: 'bullet',
45
+ arrow: 'bullet',
46
46
  };
47
47
 
48
48
  /**
@@ -53,14 +53,14 @@ export const PATTERN_TO_CATEGORY: Record<string, ListCategory> = {
53
53
  * Level 2: i., ii., iii. (lowerRoman)
54
54
  */
55
55
  export const FORMAT_TO_LEVEL: Record<string, number> = {
56
- decimal: 0, // 1., 2., 3.
57
- lowerLetter: 1, // a., b., c.
58
- upperLetter: 1, // A., B., C.
59
- lowerRoman: 2, // i., ii., iii.
60
- upperRoman: 2, // I., II., III.
61
- bullet: 0, // Top-level bullet (filled circle)
62
- dash: 0, // Top-level dash marker
63
- arrow: 0, // Top-level arrow marker
56
+ decimal: 0, // 1., 2., 3.
57
+ lowerLetter: 1, // a., b., c.
58
+ upperLetter: 1, // A., B., C.
59
+ lowerRoman: 2, // i., ii., iii.
60
+ upperRoman: 2, // I., II., III.
61
+ bullet: 0, // Top-level bullet (filled circle)
62
+ dash: 0, // Top-level dash marker
63
+ arrow: 0, // Top-level arrow marker
64
64
  };
65
65
 
66
66
  /**
@@ -124,7 +124,7 @@ export function detectTypedPrefix(text: string): {
124
124
  if (match) {
125
125
  // Special check for single-letter patterns (lowerLetter, upperLetter)
126
126
  // to avoid false positives on abbreviations like "P.O. Box", "U.S.", "A.M."
127
- if (format === "lowerLetter" || format === "upperLetter") {
127
+ if (format === 'lowerLetter' || format === 'upperLetter') {
128
128
  const remaining = text.substring(match[0].length);
129
129
  // If remaining text starts with another letter followed by period,
130
130
  // this is likely an abbreviation, not a list marker
@@ -136,12 +136,12 @@ export function detectTypedPrefix(text: string): {
136
136
  return {
137
137
  prefix: match[0],
138
138
  format: format as NumberFormat | BulletFormat,
139
- category: PATTERN_TO_CATEGORY[format] ?? "none",
139
+ category: PATTERN_TO_CATEGORY[format] ?? 'none',
140
140
  };
141
141
  }
142
142
  }
143
143
 
144
- return { prefix: null, format: null, category: "none" };
144
+ return { prefix: null, format: null, category: 'none' };
145
145
  }
146
146
 
147
147
  /**
@@ -163,7 +163,7 @@ export function detectListType(paragraph: Paragraph): ListDetectionResult {
163
163
  // Priority 1: Real Word list with <w:numPr>
164
164
  if (numbering?.numId !== undefined && numbering.numId !== 0) {
165
165
  return {
166
- category: "numbered", // Default, caller can refine with NumberingManager lookup
166
+ category: 'numbered', // Default, caller can refine with NumberingManager lookup
167
167
  isWordList: true,
168
168
  typedPrefix: null,
169
169
  inferredLevel: numbering.level ?? 0,
@@ -193,7 +193,7 @@ export function detectListType(paragraph: Paragraph): ListDetectionResult {
193
193
 
194
194
  // Priority 3: Not a list
195
195
  return {
196
- category: "none",
196
+ category: 'none',
197
197
  isWordList: false,
198
198
  typedPrefix: null,
199
199
  inferredLevel: 0,
@@ -213,10 +213,10 @@ export function validateListSequence(
213
213
  ): { valid: boolean; warnings: string[] } {
214
214
  const warnings: string[] = [];
215
215
  let lastDecimal = 0;
216
- let lastLetter = "";
216
+ let lastLetter = '';
217
217
 
218
218
  for (const { detection } of paragraphs) {
219
- if (!detection.typedPrefix || detection.category !== "numbered") continue;
219
+ if (!detection.typedPrefix || detection.category !== 'numbered') continue;
220
220
 
221
221
  const match = /^(\d+|[a-zA-Z]+)/.exec(detection.typedPrefix);
222
222
  if (!match?.[1]) continue;
@@ -235,11 +235,7 @@ export function validateListSequence(
235
235
  // Check letter sequence
236
236
  if (/^[a-z]$/i.test(marker)) {
237
237
  const letter = marker.toLowerCase();
238
- if (
239
- lastLetter &&
240
- letter.charCodeAt(0) !== lastLetter.charCodeAt(0) + 1 &&
241
- letter !== "a"
242
- ) {
238
+ if (lastLetter && letter.charCodeAt(0) !== lastLetter.charCodeAt(0) + 1 && letter !== 'a') {
243
239
  warnings.push(`Unexpected letter sequence: ${lastLetter} → ${letter}`);
244
240
  }
245
241
  lastLetter = letter;
@@ -253,22 +249,16 @@ export function validateListSequence(
253
249
  * Determine the list category for a given numId by checking the abstractNum.
254
250
  * This requires access to the NumberingManager.
255
251
  */
256
- export function getListCategoryFromFormat(
257
- format: string | undefined
258
- ): ListCategory {
259
- if (!format) return "none";
252
+ export function getListCategoryFromFormat(format: string | undefined): ListCategory {
253
+ if (!format) return 'none';
260
254
 
261
- if (["bullet", "dash", "arrow"].includes(format)) {
262
- return "bullet";
255
+ if (['bullet', 'dash', 'arrow'].includes(format)) {
256
+ return 'bullet';
263
257
  }
264
258
 
265
- if (
266
- ["decimal", "lowerLetter", "upperLetter", "lowerRoman", "upperRoman"].includes(
267
- format
268
- )
269
- ) {
270
- return "numbered";
259
+ if (['decimal', 'lowerLetter', 'upperLetter', 'lowerRoman', 'upperRoman'].includes(format)) {
260
+ return 'numbered';
271
261
  }
272
262
 
273
- return "none";
263
+ return 'none';
274
264
  }