@stll/folio-core 0.66.2 → 0.68.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 (323) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +138 -17
  3. package/dist/ai-edits/batch-claims.js +5 -3
  4. package/dist/ai-edits/clean-text.js +4 -1
  5. package/dist/ai-edits/headless.d.ts +36 -21
  6. package/dist/ai-edits/headless.js +104 -34
  7. package/dist/ai-edits/index.d.ts +2 -2
  8. package/dist/ai-edits/note-references.d.ts +6 -0
  9. package/dist/ai-edits/note-references.js +7 -1
  10. package/dist/ai-edits/read.d.ts +19 -0
  11. package/dist/ai-edits/read.js +6 -4
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +32 -17
  14. package/dist/ai-edits/table-cell-mutations.js +3 -2
  15. package/dist/ai-edits/table-row-column-mutations.js +20 -6
  16. package/dist/ai-edits/types.d.ts +9 -1
  17. package/dist/ai-suggestions/apply.js +13 -4
  18. package/dist/compare/compare.js +2 -1
  19. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  20. package/dist/compare/inserted-resource-snapshot.js +7 -3
  21. package/dist/controller/canonicalClipboard.js +29 -12
  22. package/dist/controller/canonicalComposition.d.ts +1 -1
  23. package/dist/controller/canonicalComposition.js +77 -19
  24. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  25. package/dist/controller/canonicalInlineProjection.js +192 -28
  26. package/dist/controller/canonicalInput.d.ts +2 -2
  27. package/dist/controller/canonicalInput.js +47 -2
  28. package/dist/controller/canonicalListRendering.d.ts +2 -1
  29. package/dist/controller/canonicalListRendering.js +1 -1
  30. package/dist/controller/canonicalLockGuard.d.ts +8 -0
  31. package/dist/controller/canonicalLockGuard.js +88 -0
  32. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  33. package/dist/controller/canonicalPublicOperations.js +274 -20
  34. package/dist/controller/canonicalSession.d.ts +87 -7
  35. package/dist/controller/canonicalSession.js +328 -75
  36. package/dist/controller/canonicalStoryEditor.d.ts +3 -2
  37. package/dist/controller/canonicalStoryEditor.js +4 -3
  38. package/dist/controller/canonicalStructure.d.ts +2 -1
  39. package/dist/controller/canonicalStructure.js +129 -7
  40. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  41. package/dist/controller/contentControlWidgetController.js +13 -1
  42. package/dist/controller/folioEditor.js +1 -0
  43. package/dist/controller/headerFooterEditorManager.d.ts +2 -2
  44. package/dist/controller/headerFooterEditorManager.js +5 -5
  45. package/dist/controller/hiddenEditorApi.d.ts +6 -0
  46. package/dist/controller/hiddenEditorApi.js +1 -0
  47. package/dist/controller/hiddenEditorManager.d.ts +10 -3
  48. package/dist/controller/hiddenEditorManager.js +94 -38
  49. package/dist/controller/layoutPipeline.d.ts +2 -0
  50. package/dist/controller/layoutPipeline.js +55 -18
  51. package/dist/controller/layoutSession.d.ts +1 -0
  52. package/dist/controller/noteEditorManager.d.ts +2 -2
  53. package/dist/controller/noteEditorManager.js +5 -5
  54. package/dist/display-list/build/pageFurniture.js +41 -19
  55. package/dist/display-list/build/tablePrimitives.d.ts +3 -1
  56. package/dist/display-list/build/tablePrimitives.js +49 -14
  57. package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
  58. package/dist/document-operations.d.ts +8 -0
  59. package/dist/document-operations.js +4 -3
  60. package/dist/docx/blockContentParser.d.ts +7 -3
  61. package/dist/docx/blockContentParser.js +2 -3
  62. package/dist/docx/blockPlainText.js +2 -0
  63. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  64. package/dist/docx/bookmarkRangeJoin.js +43 -0
  65. package/dist/docx/canonicalSave.js +5 -1
  66. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  67. package/dist/docx/canonicalSessionInput.js +7 -2
  68. package/dist/docx/chartPreview.d.ts +4 -1
  69. package/dist/docx/chartPreview.js +26 -15
  70. package/dist/docx/commentAnchorIndex.d.ts +21 -5
  71. package/dist/docx/commentAnchorIndex.js +39 -11
  72. package/dist/docx/commentRangeIntegrity.js +30 -24
  73. package/dist/docx/commentRangeJoin.d.ts +4 -0
  74. package/dist/docx/commentRangeJoin.js +26 -12
  75. package/dist/docx/commentReferenceCompletion.js +5 -4
  76. package/dist/docx/commentReferenceNormalization.js +40 -18
  77. package/dist/docx/compatibility.js +9 -2
  78. package/dist/docx/containerChildren.js +22 -1
  79. package/dist/docx/encryption/compoundFile.js +9 -1
  80. package/dist/docx/encryption/encryptionInfo.js +16 -2
  81. package/dist/docx/ensureParaIds.js +46 -7
  82. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  83. package/dist/docx/ensureUniqueControlIds.js +110 -0
  84. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  85. package/dist/docx/headerFooterVerbatim.js +13 -2
  86. package/dist/docx/hostCommentThreads.d.ts +17 -0
  87. package/dist/docx/hostCommentThreads.js +49 -0
  88. package/dist/docx/hyperlinkParser.js +9 -2
  89. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  90. package/dist/docx/inlineWrapperContent.js +9 -2
  91. package/dist/docx/listMarkerComputation.d.ts +35 -1
  92. package/dist/docx/listMarkerComputation.js +39 -1
  93. package/dist/docx/listModelNormalization.d.ts +44 -1
  94. package/dist/docx/listModelNormalization.js +227 -96
  95. package/dist/docx/mainDocumentPart.d.ts +6 -0
  96. package/dist/docx/mainDocumentPart.js +65 -0
  97. package/dist/docx/markupRangeMarker.d.ts +14 -0
  98. package/dist/docx/markupRangeMarker.js +15 -1
  99. package/dist/docx/metadataPrivacy.js +43 -22
  100. package/dist/docx/normalizeBaseDirection.js +3 -1
  101. package/dist/docx/packageParts.d.ts +1 -1
  102. package/dist/docx/packageParts.js +10 -4
  103. package/dist/docx/paragraphParser.js +159 -48
  104. package/dist/docx/paragraphPropertySource.d.ts +7 -0
  105. package/dist/docx/paragraphPropertySource.js +22 -1
  106. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  107. package/dist/docx/paragraphTraversal.js +2 -0
  108. package/dist/docx/parseWarningMessage.js +2 -1
  109. package/dist/docx/parser.js +6 -0
  110. package/dist/docx/previewBudget.d.ts +6 -0
  111. package/dist/docx/previewBudget.js +7 -1
  112. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  113. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  114. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  115. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  116. package/dist/docx/reviewResolutionProvenance.js +110 -25
  117. package/dist/docx/rezip.d.ts +6 -0
  118. package/dist/docx/rezip.js +42 -25
  119. package/dist/docx/selectiveSave.js +6 -10
  120. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  121. package/dist/docx/selectiveXmlPatch.js +11 -7
  122. package/dist/docx/serializer/documentSerializer.js +3 -1
  123. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  124. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  125. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  126. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  127. package/dist/docx/serializer/noteSerializer.js +23 -16
  128. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  129. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  130. package/dist/docx/serializer/runSerializer.js +2 -2
  131. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  132. package/dist/docx/serializer/tableSerializer.js +4 -2
  133. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  134. package/dist/docx/server/createBilingualDocument.js +27 -5
  135. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  136. package/dist/docx/sessionListPruning.d.ts +2 -0
  137. package/dist/docx/sessionListPruning.js +50 -0
  138. package/dist/docx/shapeAlternateContent.js +19 -0
  139. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  140. package/dist/docx/splitRevisionPieces.js +14 -0
  141. package/dist/docx/storyBlockReplay.js +4 -0
  142. package/dist/docx/structuralXmlPatch.js +19 -7
  143. package/dist/docx/tableParser.d.ts +6 -2
  144. package/dist/docx/tableParser.js +2 -3
  145. package/dist/docx/textBoxContentParser.d.ts +11 -0
  146. package/dist/docx/textBoxContentParser.js +51 -0
  147. package/dist/docx/textBoxParser.d.ts +0 -5
  148. package/dist/docx/textBoxParser.js +1 -23
  149. package/dist/docx/unzip.js +2 -0
  150. package/dist/docx/verticalMergeProjection.js +1 -1
  151. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  152. package/dist/fonts/fontsourceFaces.js +1 -7
  153. package/dist/i18n/messages/ar.gen.js +3 -0
  154. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  155. package/dist/i18n/messages/catalogs.gen.js +51 -0
  156. package/dist/i18n/messages/cs.gen.js +3 -0
  157. package/dist/i18n/messages/de.gen.js +3 -0
  158. package/dist/i18n/messages/en.gen.js +3 -0
  159. package/dist/i18n/messages/es.gen.js +3 -0
  160. package/dist/i18n/messages/et.gen.js +3 -0
  161. package/dist/i18n/messages/fr.gen.js +3 -0
  162. package/dist/i18n/messages/he.gen.js +3 -0
  163. package/dist/i18n/messages/hi.gen.js +3 -0
  164. package/dist/i18n/messages/hu.gen.js +3 -0
  165. package/dist/i18n/messages/lt.gen.js +3 -0
  166. package/dist/i18n/messages/lv.gen.js +3 -0
  167. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  168. package/dist/i18n/messages/pl.gen.js +3 -0
  169. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  170. package/dist/i18n/messages/sk.gen.js +3 -0
  171. package/dist/i18n/messages/tr.gen.js +3 -0
  172. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  173. package/dist/internal/acceptedBlockProjection.js +2 -0
  174. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  175. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  176. package/dist/internal/revisionResolutionInline.js +1 -2
  177. package/dist/internal/wholeStoryRevisionResolution.js +57 -12
  178. package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
  179. package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
  180. package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
  181. package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
  182. package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
  183. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  184. package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
  185. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  186. package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
  187. package/dist/layout-bridge/convert/tableConversion.js +25 -10
  188. package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
  189. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  190. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  191. package/dist/layout-bridge/engine/clickToPosition.js +5 -1
  192. package/dist/layout-bridge/engine/hitTest.js +9 -10
  193. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  194. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  195. package/dist/layout-engine/footnoteContinuation.js +210 -0
  196. package/dist/layout-engine/index.d.ts +2 -2
  197. package/dist/layout-engine/index.js +7 -2
  198. package/dist/layout-engine/measure/cache.js +10 -5
  199. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  200. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  201. package/dist/layout-engine/measure/tableCellFloating.js +1 -0
  202. package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
  203. package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
  204. package/dist/layout-engine/tableLayout.js +34 -7
  205. package/dist/layout-engine/tableRowBreak.d.ts +46 -0
  206. package/dist/layout-engine/tableRowBreak.js +193 -36
  207. package/dist/layout-engine/types.d.ts +43 -3
  208. package/dist/layout-painter/previewSvg.d.ts +8 -0
  209. package/dist/layout-painter/previewSvg.js +47 -0
  210. package/dist/layout-painter/renderImage.js +2 -1
  211. package/dist/layout-painter/renderPage.d.ts +5 -4
  212. package/dist/layout-painter/renderPage.js +52 -20
  213. package/dist/layout-painter/renderParagraph.js +3 -2
  214. package/dist/layout-painter/renderTable.d.ts +5 -2
  215. package/dist/layout-painter/renderTable.js +39 -22
  216. package/dist/managers/AutoSaveManager.d.ts +5 -1
  217. package/dist/managers/FindReplaceManager.js +3 -10
  218. package/dist/markdown/escape.d.ts +20 -1
  219. package/dist/markdown/escape.js +43 -1
  220. package/dist/markdown/renderBlock.js +4 -1
  221. package/dist/markdown/renderParagraph.js +13 -27
  222. package/dist/markdown/renderTable.js +6 -2
  223. package/dist/markdown/trailers.js +1 -0
  224. package/dist/pdf/images.d.ts +17 -1
  225. package/dist/pdf/images.js +22 -4
  226. package/dist/pdf/writePdf.js +4 -2
  227. package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
  228. package/dist/prosemirror/attrs/index.js +1 -0
  229. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  230. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  231. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  232. package/dist/prosemirror/commands/comments.d.ts +25 -0
  233. package/dist/prosemirror/commands/comments.js +122 -18
  234. package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
  235. package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
  236. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  237. package/dist/prosemirror/commands/index.d.ts +1 -1
  238. package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
  239. package/dist/prosemirror/commands/pastePlainText.js +13 -3
  240. package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
  241. package/dist/prosemirror/commentIdAllocator.js +2 -2
  242. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  243. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  244. package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
  245. package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
  246. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  247. package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
  248. package/dist/prosemirror/conversion/index.d.ts +1 -1
  249. package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
  250. package/dist/prosemirror/conversion/toProseDoc.js +325 -55
  251. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  252. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  253. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
  255. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  256. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
  257. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
  258. package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
  259. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  260. package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
  263. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  264. package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
  265. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
  266. package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
  267. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
  268. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  269. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  270. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
  271. package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
  272. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
  273. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  274. package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
  275. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
  276. package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
  277. package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
  278. package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
  279. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  280. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
  281. package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
  282. package/dist/prosemirror/index.d.ts +2 -2
  283. package/dist/prosemirror/listLabels.js +3 -2
  284. package/dist/prosemirror/listNumbering.d.ts +6 -0
  285. package/dist/prosemirror/listNumbering.js +12 -9
  286. package/dist/prosemirror/lockedControls.d.ts +13 -0
  287. package/dist/prosemirror/lockedControls.js +106 -0
  288. package/dist/prosemirror/markupViewProjection.js +1 -1
  289. package/dist/prosemirror/noteReferenceReview.js +2 -2
  290. package/dist/prosemirror/plugins/documentNumbering.js +4 -1
  291. package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
  292. package/dist/prosemirror/plugins/suggestionMode.js +195 -30
  293. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  294. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  295. package/dist/prosemirror/replacedAnnotations.js +1 -0
  296. package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
  297. package/dist/prosemirror/rowGridOmissions.js +21 -0
  298. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  299. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  300. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  301. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  302. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  303. package/dist/prosemirror/runStyleFormatting.js +16 -13
  304. package/dist/prosemirror/schema/marks.d.ts +6 -0
  305. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  306. package/dist/prosemirror/tableGridMutation.d.ts +19 -2
  307. package/dist/prosemirror/tableGridMutation.js +118 -15
  308. package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
  309. package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
  310. package/dist/prosemirror/validation.js +2 -1
  311. package/dist/redline.js +23 -9
  312. package/dist/server.d.ts +2 -2
  313. package/dist/style-sets/extract.js +2 -2
  314. package/dist/types/canonicalCapabilities.d.ts +29 -8
  315. package/dist/types/canonicalCapabilities.js +13 -9
  316. package/dist/utils/cssString.d.ts +7 -0
  317. package/dist/utils/cssString.js +9 -0
  318. package/dist/utils/fontResolver.js +4 -1
  319. package/dist/utils/replaceText.d.ts +11 -0
  320. package/dist/utils/replaceText.js +39 -7
  321. package/dist/version-comparison.d.ts +9 -1
  322. package/dist/version-comparison.js +11 -5
  323. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { joinBookmarkRangesAcrossParagraphs } from "../../docx/bookmarkRangeJoin.js";
1
2
  import { removeCommentMarkers } from "../../docx/commentAnchorIndex.js";
2
3
  import { joinCommentRangesAcrossParagraphs } from "../../docx/commentRangeJoin.js";
3
4
  import { completeCommentReferences } from "../../docx/commentReferenceCompletion.js";
@@ -49,6 +50,7 @@ import { directionToAuthoredBidi } from "../paragraphDirection.js";
49
50
  import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
50
51
  import { directParagraphSpacing } from "../paragraphSpacing.js";
51
52
  import { expectRangeAnchorAttrs } from "../rangeAnchorAttrs.js";
53
+ import { rowGridOmissions } from "../rowGridOmissions.js";
52
54
  import { marksToTextFormatting, sameFormattingValue } from "../runFormattingFromMarks.js";
53
55
  import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
54
56
  import { RUN_IDENTITY_MARK_NAME } from "../runIdentity.js";
@@ -401,6 +403,7 @@ function fromProseDoc(pmDoc, baseDocument, { stylesheetSource, reuse = "none" })
401
403
  });
402
404
  const blocks = extractBlocks(pmDoc, "resolve", createStyleEngine(styles));
403
405
  joinCommentRangesAcrossParagraphs(blocks);
406
+ joinBookmarkRangesAcrossParagraphs(blocks);
404
407
  completeCommentReferences(blocks);
405
408
  const linkedSources = restoreLinkedParagraphPropertySources(blocks);
406
409
  if (tokenSources) restoreParagraphPropertySourcesByToken(blocks, tokenSources);
@@ -461,7 +464,7 @@ function stripSuggestedInlineMarks(marks, readFormattingContext) {
461
464
  if (!hasSuggestedDeletion && !suggestedRunPropertyChange) return marks;
462
465
  let next = marks.filter((mark) => !((mark.type.name === "deletion" || mark.type.name === "runPropertyChange") && isSuggestedMark(mark)));
463
466
  if (suggestedRunPropertyChange) {
464
- const { baseParagraphFormatting, inheritedFormatting, paragraphMarkFormatting, paragraphMarkPrecedesStyle, styleResolver } = readFormattingContext();
467
+ const { baseParagraphFormatting, inheritedFormatting, paragraphMarkFormatting, styleResolver } = readFormattingContext();
465
468
  const previousFormatting = expectRunPropertyChangeMarkAttrs(suggestedRunPropertyChange).changes.at(0)?.previousFormatting;
466
469
  const characterStyleMark = marks.find(({ type }) => type.name === "characterStyle");
467
470
  const characterStyleAttrs = characterStyleMark ? expectCharacterStyleMarkAttrs(characterStyleMark) : void 0;
@@ -471,8 +474,7 @@ function stripSuggestedInlineMarks(marks, readFormattingContext) {
471
474
  context: {
472
475
  baseParagraphFormatting,
473
476
  paragraphFormatting: inheritedFormatting,
474
- paragraphMarkFormatting,
475
- paragraphMarkPrecedesStyle
477
+ paragraphMarkFormatting
476
478
  },
477
479
  ...previousFormatting !== void 0 ? { directFormatting: previousFormatting } : {}
478
480
  });
@@ -609,7 +611,6 @@ function mapSuggestionStrippedNode(node, readFormattingContext) {
609
611
  baseParagraphFormatting: paragraphStyleContext.baseParagraphFormatting,
610
612
  inheritedFormatting: paragraphStyleContext.paragraphFormatting,
611
613
  paragraphMarkFormatting: paragraphStyleContext.paragraphMarkFormatting,
612
- paragraphMarkPrecedesStyle: paragraphStyleContext.paragraphMarkPrecedesStyle,
613
614
  styleResolver
614
615
  };
615
616
  return resolvedChildContext;
@@ -640,7 +641,6 @@ function stripSuggestedProvenance(doc, styleResolver) {
640
641
  baseParagraphFormatting: void 0,
641
642
  inheritedFormatting: void 0,
642
643
  paragraphMarkFormatting: void 0,
643
- paragraphMarkPrecedesStyle: false,
644
644
  styleResolver
645
645
  })) ?? doc;
646
646
  }
@@ -732,6 +732,9 @@ function extractBlocks(inputDoc, refResolution = "resolve", styleResolver = null
732
732
  } else if (node.type.name === "blockMoveRangeBoundary") {
733
733
  blocks.push({ ...expectMoveRangeBoundaryAttrs(node) });
734
734
  previousStandaloneTextBox = null;
735
+ } else if (node.type.name === "blockCommentRangeBoundary") {
736
+ blocks.push({ ...expectCommentRangeBoundaryAttrs(node).marker });
737
+ previousStandaloneTextBox = null;
735
738
  }
736
739
  });
737
740
  if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
@@ -1109,7 +1112,6 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers, styleRes
1109
1112
  baseParagraphFormatting: paragraphStyleContext.baseParagraphFormatting,
1110
1113
  inheritedFormatting: paragraphStyleContext.paragraphFormatting,
1111
1114
  paragraphMarkFormatting: paragraphStyleContext.paragraphMarkFormatting,
1112
- paragraphMarkPrecedesStyle: paragraphStyleContext.paragraphMarkPrecedesStyle,
1113
1115
  styleResolver
1114
1116
  });
1115
1117
  const bookmarks = attrs.bookmarks;
@@ -1593,7 +1595,6 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
1593
1595
  baseParagraphFormatting: paragraphStyleContext?.baseParagraphFormatting,
1594
1596
  inheritedFormatting: paragraphStyleContext?.paragraphFormatting,
1595
1597
  paragraphMarkFormatting: paragraphStyleContext?.paragraphMarkFormatting,
1596
- paragraphMarkPrecedesStyle: paragraphStyleContext?.paragraphMarkPrecedesStyle ?? false,
1597
1598
  styleResolver: null
1598
1599
  };
1599
1600
  const sortedEmptyHyperlinks = (emptyHyperlinks ?? []).map((attrs, order) => ({
@@ -2005,8 +2006,7 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
2005
2006
  const runFormattingContext = changeMark === deletionMark && changeAttrs._historicalFormatting ? {
2006
2007
  ...formattingContext,
2007
2008
  inheritedFormatting: formattingContext.baseParagraphFormatting ?? formattingContext.inheritedFormatting,
2008
- paragraphMarkFormatting: void 0,
2009
- paragraphMarkPrecedesStyle: false
2009
+ paragraphMarkFormatting: void 0
2010
2010
  } : formattingContext;
2011
2011
  const revisionAncestors = enclosingInsertionAncestors({
2012
2012
  insertionMark: changeMark === deletionMark ? insertionMark : void 0,
@@ -2129,7 +2129,26 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
2129
2129
  content.push(createNoteReferenceRun(noteRefMark, node.marks, formattingContext));
2130
2130
  return;
2131
2131
  }
2132
- if (linkMark) {
2132
+ const fieldUnderLink = node.type.name === "field" || node.type.name === "structuredField";
2133
+ if (linkMark && fieldUnderLink) {
2134
+ const field = createFieldFromNode(node, {
2135
+ ...formattingContext,
2136
+ marks: node.marks,
2137
+ textBoxAnchorMarkers
2138
+ });
2139
+ if (field.type === "complexField") {
2140
+ const linkKey = getLinkKey(linkMark);
2141
+ if (!currentHyperlink || currentHyperlinkKey !== linkKey) {
2142
+ flushCurrentInline();
2143
+ currentHyperlink = createIndexedHyperlink(linkMark);
2144
+ currentHyperlinkKey = linkKey;
2145
+ }
2146
+ currentHyperlink.children.push(field);
2147
+ syncStructuredCommentExit(node, offset);
2148
+ return;
2149
+ }
2150
+ }
2151
+ if (linkMark && !fieldUnderLink) {
2133
2152
  const linkKey = getLinkKey(linkMark);
2134
2153
  if (currentHyperlink && currentHyperlinkKey === linkKey) {} else {
2135
2154
  flushCurrentInline();
@@ -2252,12 +2271,11 @@ function extractParagraphContent(originalParagraph, _documentCounts, emptyHyperl
2252
2271
  }
2253
2272
  return nestInlineWrapperGroups(content, wrapperGroups, sourceHyperlinkIndices, revisionOuterWrapperCounts, revisionAncestorsByWrapper);
2254
2273
  }
2255
- function createTrackedChangeRun({ baseParagraphFormatting, inheritedFormatting, marks, node, paragraphMarkFormatting, paragraphMarkPrecedesStyle, styleResolver }) {
2274
+ function createTrackedChangeRun({ baseParagraphFormatting, inheritedFormatting, marks, node, paragraphMarkFormatting, styleResolver }) {
2256
2275
  const formattingContext = {
2257
2276
  baseParagraphFormatting,
2258
2277
  inheritedFormatting,
2259
2278
  paragraphMarkFormatting,
2260
- paragraphMarkPrecedesStyle,
2261
2279
  styleResolver
2262
2280
  };
2263
2281
  const noteRefMark = marks.find((mark) => mark.type.name === "footnoteRef");
@@ -2315,7 +2333,11 @@ function createEmptyHyperlink(attrs) {
2315
2333
  }
2316
2334
  function getCommentMarkIds(marks) {
2317
2335
  const commentIds = /* @__PURE__ */ new Set();
2318
- for (const mark of marks) if (mark.type.name === "comment") commentIds.add(expectCommentMarkAttrs(mark).commentId);
2336
+ for (const mark of marks) {
2337
+ if (mark.type.name !== "comment") continue;
2338
+ const attrs = expectCommentMarkAttrs(mark);
2339
+ if (attrs.point !== true) commentIds.add(attrs.commentId);
2340
+ }
2319
2341
  return commentIds;
2320
2342
  }
2321
2343
  /**
@@ -2385,7 +2407,7 @@ function createHyperlink(linkMark) {
2385
2407
  if (attrs.rId) hyperlink.rId = attrs.rId;
2386
2408
  return hyperlink;
2387
2409
  }
2388
- function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedFormatting, node, paragraphMarkFormatting, paragraphMarkPrecedesStyle, sourceRunOwners, styleResolver }) {
2410
+ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedFormatting, node, paragraphMarkFormatting, sourceRunOwners, styleResolver }) {
2389
2411
  if (node.type.name === "bookmarkBoundary") {
2390
2412
  hyperlink.children.push(bookmarkMarkerFromAttrs(expectBookmarkBoundaryAttrs(node)));
2391
2413
  return;
@@ -2394,7 +2416,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2394
2416
  baseParagraphFormatting,
2395
2417
  inheritedFormatting,
2396
2418
  paragraphMarkFormatting,
2397
- paragraphMarkPrecedesStyle,
2398
2419
  styleResolver
2399
2420
  };
2400
2421
  const nonLinkMarks = node.marks.filter((mark) => mark.type.name !== "hyperlink");
@@ -2413,7 +2434,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2413
2434
  baseParagraphFormatting,
2414
2435
  inheritedFormatting,
2415
2436
  paragraphMarkFormatting,
2416
- paragraphMarkPrecedesStyle,
2417
2437
  styleResolver
2418
2438
  }));
2419
2439
  return;
@@ -2424,7 +2444,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2424
2444
  inheritedFormatting,
2425
2445
  marks: nonLinkMarks,
2426
2446
  paragraphMarkFormatting,
2427
- paragraphMarkPrecedesStyle,
2428
2447
  styleResolver,
2429
2448
  text: node.text
2430
2449
  });
@@ -2444,7 +2463,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2444
2463
  baseParagraphFormatting,
2445
2464
  inheritedFormatting,
2446
2465
  paragraphMarkFormatting,
2447
- paragraphMarkPrecedesStyle,
2448
2466
  styleResolver
2449
2467
  }));
2450
2468
  return;
@@ -2454,7 +2472,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2454
2472
  baseParagraphFormatting,
2455
2473
  inheritedFormatting,
2456
2474
  paragraphMarkFormatting,
2457
- paragraphMarkPrecedesStyle,
2458
2475
  styleResolver
2459
2476
  }));
2460
2477
  return;
@@ -2464,7 +2481,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2464
2481
  baseParagraphFormatting,
2465
2482
  inheritedFormatting,
2466
2483
  paragraphMarkFormatting,
2467
- paragraphMarkPrecedesStyle,
2468
2484
  styleResolver
2469
2485
  }));
2470
2486
  return;
@@ -2483,7 +2499,6 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
2483
2499
  baseParagraphFormatting,
2484
2500
  inheritedFormatting,
2485
2501
  paragraphMarkFormatting,
2486
- paragraphMarkPrecedesStyle,
2487
2502
  styleResolver
2488
2503
  }));
2489
2504
  return;
@@ -2541,12 +2556,11 @@ function textLeafRunContent(text, marks) {
2541
2556
  function isTextLeafContent(content) {
2542
2557
  return content.type === "text" || content.type === "softHyphen" || content.type === "noBreakHyphen";
2543
2558
  }
2544
- function createRunFromText({ baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, paragraphMarkPrecedesStyle, styleResolver, text }) {
2559
+ function createRunFromText({ baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver, text }) {
2545
2560
  const formatting = getRunFormattingFromMarks(marks, {
2546
2561
  baseParagraphFormatting,
2547
2562
  inheritedFormatting,
2548
2563
  paragraphMarkFormatting,
2549
- paragraphMarkPrecedesStyle,
2550
2564
  styleResolver
2551
2565
  });
2552
2566
  const run = {
@@ -2730,7 +2744,7 @@ function appendRunToHyperlink(hyperlink, run, node, sourceRunOwners) {
2730
2744
  hyperlink.children.push(run);
2731
2745
  rememberSourceRunOwner(run, node, sourceRunOwners);
2732
2746
  }
2733
- function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFormatting, marks, paragraphMarkFormatting, paragraphMarkPrecedesStyle, styleResolver }) {
2747
+ function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver }) {
2734
2748
  const run = {
2735
2749
  type: "run",
2736
2750
  content: [{
@@ -2743,7 +2757,6 @@ function createPageBreakCarrierRun({ baseParagraphFormatting, clear, inheritedFo
2743
2757
  baseParagraphFormatting,
2744
2758
  inheritedFormatting,
2745
2759
  paragraphMarkFormatting,
2746
- paragraphMarkPrecedesStyle,
2747
2760
  styleResolver
2748
2761
  });
2749
2762
  if (formatting) run.formatting = formatting;
@@ -2794,22 +2807,40 @@ function createTabRun(node, marks, formattingContext) {
2794
2807
  if (marks) restoreRunRecord(run, marks);
2795
2808
  return run;
2796
2809
  }
2797
- function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, paragraphMarkPrecedesStyle, styleResolver, textBoxAnchorMarkers }) {
2810
+ const FIELD_WIDE_MARK_NAMES = /* @__PURE__ */ new Set([
2811
+ "comment",
2812
+ "deletion",
2813
+ "insertion",
2814
+ "moveFrom",
2815
+ "moveTo"
2816
+ ]);
2817
+ /**
2818
+ * A change or comment over a whole field marks its result as well; the field
2819
+ * as a whole is what writes them, so the result's runs do not repeat them.
2820
+ */
2821
+ const withoutTheFieldsOwnMarks = (node) => {
2822
+ if (node.marks.length === 0) return node;
2823
+ const children = [];
2824
+ node.forEach((child) => {
2825
+ children.push(child.mark(child.marks.filter((mark) => !FIELD_WIDE_MARK_NAMES.has(mark.type.name) || !mark.isInSet(node.marks))));
2826
+ });
2827
+ return recreateProseNodeWithParagraphPropertySource(node, { content: Fragment.fromArray(children) });
2828
+ };
2829
+ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormatting, marks, paragraphMarkFormatting, styleResolver, textBoxAnchorMarkers }) {
2798
2830
  const attrs = expectFieldAttrs(node);
2799
2831
  const formatting = marks && marks.length > 0 ? marksToTextFormatting(marks, {
2800
2832
  baseParagraphFormatting,
2801
2833
  inheritedFormatting,
2802
2834
  paragraphMarkFormatting,
2803
- paragraphMarkPrecedesStyle,
2804
2835
  styleResolver
2805
2836
  }) : void 0;
2806
- const extractedContent = extractParagraphContent(node, void 0, void 0, textBoxAnchorMarkers, false, {
2837
+ const fieldFormattingContext = {
2807
2838
  baseParagraphFormatting,
2808
2839
  inheritedFormatting,
2809
2840
  paragraphMarkFormatting,
2810
- paragraphMarkPrecedesStyle: paragraphMarkPrecedesStyle ?? false,
2811
2841
  styleResolver: styleResolver ?? null
2812
- }).filter(isSimpleFieldContent);
2842
+ };
2843
+ const extractedContent = extractParagraphContent(withoutTheFieldsOwnMarks(node), void 0, void 0, textBoxAnchorMarkers, false, fieldFormattingContext).filter(isSimpleFieldContent);
2813
2844
  const displayText = attrs.displayText ?? "";
2814
2845
  const displayRun = {
2815
2846
  type: "run",
@@ -3413,6 +3444,19 @@ function tableAttrsToFormatting(attrs) {
3413
3444
  /**
3414
3445
  * Convert a ProseMirror table row node to our TableRow type
3415
3446
  */
3447
+ /** What the row states it omits follows what column edits made of it. */
3448
+ const withOmittedGridSlots = (formatting, row) => {
3449
+ const statedBefore = formatting?.gridBefore ?? 0;
3450
+ const statedAfter = formatting?.gridAfter ?? 0;
3451
+ const { gridBefore, gridAfter } = rowGridOmissions(row, statedAfter);
3452
+ if (gridBefore === statedBefore && gridAfter === statedAfter) return formatting;
3453
+ const next = { ...formatting };
3454
+ if (gridBefore > 0) next.gridBefore = gridBefore;
3455
+ else delete next.gridBefore;
3456
+ if (gridAfter > 0) next.gridAfter = gridAfter;
3457
+ else delete next.gridAfter;
3458
+ return next;
3459
+ };
3416
3460
  function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleResolver = null) {
3417
3461
  const attrs = expectTableRowAttrs(node);
3418
3462
  const cells = [];
@@ -3456,7 +3500,7 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
3456
3500
  type: "tableRow",
3457
3501
  cells
3458
3502
  };
3459
- const rowFormatting = tableRowAttrsToFormatting(attrs);
3503
+ const rowFormatting = withOmittedGridSlots(tableRowAttrsToFormatting(attrs), node);
3460
3504
  if (rowFormatting) row.formatting = rowFormatting;
3461
3505
  if (attrs._tablePropertyExceptions) row.tablePropertyExceptions = attrs._tablePropertyExceptions;
3462
3506
  if (Array.isArray(attrs.tblPrExChange) && attrs.tblPrExChange.length > 0) row.tablePropertyExceptionChanges = [...attrs.tblPrExChange];
@@ -3603,6 +3647,9 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
3603
3647
  } else if (contentNode.type.name === "blockMoveRangeBoundary") {
3604
3648
  content.push({ ...expectMoveRangeBoundaryAttrs(contentNode) });
3605
3649
  previousStandaloneTextBox = null;
3650
+ } else if (contentNode.type.name === "blockCommentRangeBoundary") {
3651
+ content.push({ ...expectCommentRangeBoundaryAttrs(contentNode).marker });
3652
+ previousStandaloneTextBox = null;
3606
3653
  }
3607
3654
  });
3608
3655
  removeUnresolvedTextBoxAnchors(content, textBoxAnchorMarkers);
@@ -3641,6 +3688,8 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
3641
3688
  return cell;
3642
3689
  }
3643
3690
  const standaloneTableCellFromProseMirror = (node) => convertPMTableCell(node);
3691
+ /** A table node's rows as the save writes them, vertical merges included. */
3692
+ const standaloneTableRowsFromProseMirror = (node) => convertPMTableRows(node);
3644
3693
  const cellShadingFromAttrs = (attrs) => attrs.backgroundColor ? { fill: { rgb: attrs.backgroundColor } } : { pattern: "nil" };
3645
3694
  function tableCellAttrsToFormatting(attrs) {
3646
3695
  const backgroundChanged = attrs.backgroundColor !== attrs._resolvedBackgroundColor;
@@ -3665,16 +3714,21 @@ function tableCellAttrsToFormatting(attrs) {
3665
3714
  if (attrs.textDirection) result.textDirection = attrs.textDirection;
3666
3715
  else delete result.textDirection;
3667
3716
  }
3717
+ if (attrs.noWrap !== (orig.noWrap ?? void 0)) {
3718
+ if (attrs.noWrap === true) result.noWrap = true;
3719
+ else delete result.noWrap;
3720
+ }
3668
3721
  return Object.keys(result).length > 0 ? result : void 0;
3669
3722
  }
3670
3723
  const authoredWidth = attrs._authoredWidth;
3671
- if (!(attrs.colspan > 1 || attrs.rowspan > 1 || authoredWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection)) return;
3724
+ if (!(attrs.colspan > 1 || attrs.rowspan > 1 || authoredWidth !== void 0 || attrs.verticalAlign || backgroundChanged || attrs.borders || attrs.margins || attrs.textDirection || attrs.noWrap === true)) return;
3672
3725
  const f = {};
3673
3726
  if (attrs.colspan > 1) f.gridSpan = attrs.colspan;
3674
3727
  if (attrs.rowspan > 1) f.vMerge = "restart";
3675
3728
  if (authoredWidth) f.width = authoredWidth;
3676
3729
  if (attrs.verticalAlign) f.verticalAlign = attrs.verticalAlign;
3677
3730
  if (attrs.textDirection) f.textDirection = attrs.textDirection;
3731
+ if (attrs.noWrap === true) f.noWrap = true;
3678
3732
  if (backgroundChanged) f.shading = cellShadingFromAttrs(attrs);
3679
3733
  if (attrs.borders) f.borders = attrs.borders;
3680
3734
  if (attrs.margins) f.margins = buildCellMarginsFromAttrs(attrs.margins);
@@ -3708,8 +3762,33 @@ function convertPMTextBox(node, styleResolver = null) {
3708
3762
  const verticalAlign = normalizeShapeTextAnchor(attrs.verticalAlign);
3709
3763
  const childBlocks = [];
3710
3764
  node.forEach((child) => {
3711
- if (child.type.name === "paragraph") childBlocks.push(convertPMParagraph(child, void 0, void 0, styleResolver));
3712
- else if (child.type.name === "table") childBlocks.push(convertPMTable(child, void 0, styleResolver));
3765
+ switch (child.type.name) {
3766
+ case "paragraph":
3767
+ childBlocks.push(convertPMParagraph(child, void 0, void 0, styleResolver));
3768
+ break;
3769
+ case "table":
3770
+ childBlocks.push(convertPMTable(child, void 0, styleResolver));
3771
+ break;
3772
+ case "blockSdt":
3773
+ childBlocks.push(convertPMBlockSdt(child, styleResolver));
3774
+ break;
3775
+ case "blockCustomXml":
3776
+ childBlocks.push(convertPMBlockCustomXml(child, styleResolver));
3777
+ break;
3778
+ case "preservedBlock":
3779
+ childBlocks.push({
3780
+ type: "preservedBlock",
3781
+ xml: expectPreservedBlockAttrs(child).xml
3782
+ });
3783
+ break;
3784
+ case "blockBookmarkBoundary":
3785
+ childBlocks.push(blockBookmarkMarker(child));
3786
+ break;
3787
+ case "blockMoveRangeBoundary":
3788
+ childBlocks.push({ ...expectMoveRangeBoundaryAttrs(child) });
3789
+ break;
3790
+ case "blockCommentRangeBoundary": childBlocks.push({ ...expectCommentRangeBoundaryAttrs(child).marker });
3791
+ }
3713
3792
  });
3714
3793
  const textBodyContent = projectTextBoxBodyContent(attrs._docxTextBodyContentState, childBlocks);
3715
3794
  const margins = {};
@@ -3819,9 +3898,10 @@ function updateDocumentContent(originalDocument, pmDoc) {
3819
3898
  function proseDocToBlocks(pmDoc, baseContent, styles) {
3820
3899
  const blocks = extractBlocks(pmDoc, "resolve", styles ? createStyleEngine(styles) : null);
3821
3900
  joinCommentRangesAcrossParagraphs(blocks);
3901
+ joinBookmarkRangesAcrossParagraphs(blocks);
3822
3902
  completeCommentReferences(blocks);
3823
3903
  const linkedSources = restoreLinkedParagraphPropertySources(blocks);
3824
3904
  if (baseContent) restoreParagraphPropertySources(blocks, baseContent, linkedSources.targets, linkedSources.sources);
3825
3905
  return blocks;
3826
3906
  }
3827
- export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
3907
+ export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, standaloneTableRowsFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
@@ -1,4 +1,4 @@
1
- import { FromProseDocOptions, ProjectionReuse, fromProseDoc, proseDocToBlocks, updateDocumentContent } from "./fromProseDoc.js";
2
1
  import { ToProseDocOptions, createEmptyDoc, headerFooterToProseDoc, toProseDoc } from "./toProseDoc.js";
2
+ import { FromProseDocOptions, ProjectionReuse, fromProseDoc, proseDocToBlocks, updateDocumentContent } from "./fromProseDoc.js";
3
3
  import { ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument } from "../validation.js";
4
4
  export { type FromProseDocOptions, type ProjectionReuse, type ProseMirrorDocumentValidationIssue, type ToProseDocOptions, type ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, createEmptyDoc, formatProseMirrorDocumentIssues, fromProseDoc, headerFooterToProseDoc, proseDocToBlocks, toProseDoc, updateDocumentContent, validateProseMirrorDocument };
@@ -1,6 +1,12 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
2
  import { TextBoxAttrs } from "../schema/nodes.js";
3
+ import { NumberingMap } from "../../docx/numberingParser.js";
4
+ import { StyleEngine } from "../../style-engine/styleEngine.js";
5
+ import "../../style-engine/index.js";
6
+ import { ListRenderingDefinition } from "../../docx/listRendering.js";
3
7
  import { ParseContext } from "../../docx/parseContext.js";
8
+ import { PageBreakRunSourceDescendantIndex } from "../../internal/pageBreakRunSourceDescendantIndex.js";
9
+ import { MarkFactory } from "../extensions/marks/markUtils.js";
4
10
  import { Node } from "prosemirror-model";
5
11
  /**
6
12
  * Options for document conversion
@@ -17,13 +23,101 @@ export type ToProseDocOptions = {
17
23
  * already use. Absent means nobody is listening, not that nothing happened.
18
24
  */
19
25
  warn?: ParseContext["warn"];
26
+ /**
27
+ * Blocks converted by earlier projections of the same story, reused where
28
+ * nothing a block's conversion read has changed. See
29
+ * {@link createProjectionBlockCache}.
30
+ */
31
+ blockCache?: ProjectionBlockCache;
32
+ /**
33
+ * The salt of minted text-box anchor ids. Each conversion draws its own;
34
+ * a block cache keeps one for every projection it serves, and a caller
35
+ * comparing a cached projection with a fresh one gives the fresh one the
36
+ * cache's salt.
37
+ */
38
+ textBoxGroupSalt?: string;
20
39
  };
40
+ /** Records that a page break is projected less than exactly. */
41
+ type PageBreakProjectionWarn = (detail: string) => void;
42
+ type HyperlinkInstanceIndexAllocator = () => number;
21
43
  /**
22
44
  * Find bookmark pairs across every editable inline wrapper in a document story.
23
45
  * Each endpoint is converted at its own structural position, so a range may
24
46
  * start outside a hyperlink and end inside it (or the inverse).
25
47
  */
26
48
  export declare const collectPairedBookmarkIds: (blocks: readonly document_d_exports.BlockContent[]) => ReadonlySet<number>;
49
+ /**
50
+ * What each field of the conversion context depends on: the package alone,
51
+ * or the story before the block being converted. A block's conversion reads
52
+ * the package fields freely; it reads the story fields only through a
53
+ * recorder, so a converted block is reused only where every story fact it
54
+ * read still holds. Total over the context: a field added to it does not
55
+ * compile until it is placed in one half or the other.
56
+ */
57
+ declare const CONVERSION_CONTEXT_DEPENDENCY: {
58
+ readonly listRenderings: "package";
59
+ readonly numbering: "package";
60
+ readonly theme: "package";
61
+ readonly pageBreakRunSourceDescendants: "package";
62
+ readonly warnPageBreakProjection: "package";
63
+ readonly createMark: "package";
64
+ readonly nextTextBoxGroupId: "story";
65
+ readonly nextHyperlinkInstanceIndex: "story";
66
+ readonly nextNoteReferenceOccurrenceId: "story";
67
+ readonly pairedBookmarkIds: "story";
68
+ readonly storyRangedCommentIds: "story";
69
+ readonly openCommentIds: "story";
70
+ };
71
+ type ContextDependency = typeof CONVERSION_CONTEXT_DEPENDENCY;
72
+ type PackageContextField = { [K in keyof ContextDependency]: ContextDependency[K] extends "package" ? K : never; }[keyof ContextDependency];
73
+ /** The conversion context a block may read without recording. */
74
+ type PackageConversionContext = Pick<TableConversionContext, PackageContextField>;
75
+ /** Whether a story holds an id: all a block's conversion asks of a story id set. */
76
+ type IdMembership = Pick<ReadonlySet<number>, "has">;
77
+ /** One story counter, as the conversion advances it. */
78
+ type StoryCounter = {
79
+ value: number;
80
+ };
81
+ /** The story state a block conversion starts from and advances. */
82
+ type StoryState = {
83
+ textBoxGroups: StoryCounter;
84
+ hyperlinks: StoryCounter;
85
+ noteOccurrences: StoryCounter;
86
+ pairedBookmarkIds: IdMembership;
87
+ storyRangedCommentIds: IdMembership;
88
+ openCommentIds: Set<number>;
89
+ };
90
+ type ProjectionPackageInputs = {
91
+ styles: document_d_exports.StyleDefinitions | undefined;
92
+ theme: document_d_exports.Theme | null;
93
+ numbering: document_d_exports.NumberingDefinitions | undefined;
94
+ warn: ParseContext["warn"] | undefined;
95
+ };
96
+ /**
97
+ * Converted blocks kept across projections of one story.
98
+ *
99
+ * A block is the same object in the next document when an edit left it, so
100
+ * its nodes can be reused where the story facts its conversion read are the
101
+ * same: the counters it drew from, the comments open at its start, and the
102
+ * bookmark and comment ids it asked about. The package inputs (styles,
103
+ * theme, numbering) are part of the cache: a projection over other ones
104
+ * starts the cache over.
105
+ */
106
+ export declare class ProjectionBlockCache {
107
+ readonly salt: string;
108
+ private inputs;
109
+ private context;
110
+ private blocks;
111
+ /** The package context for these inputs, the cache started over if they changed. */
112
+ packageContext(inputs: ProjectionPackageInputs): PackageConversionContext & {
113
+ styleResolver: StyleEngine;
114
+ };
115
+ /**
116
+ * The nodes of `paragraph` from the story state it starts at, reused when
117
+ * every story fact its last conversion read still holds, else converted.
118
+ */
119
+ paragraph(paragraph: document_d_exports.Paragraph, state: StoryState, convert: (context: TableConversionContext, groupId: string) => Node[]): readonly Node[];
120
+ }
27
121
  /**
28
122
  * Convert a Document to a ProseMirror document
29
123
  *
@@ -31,6 +125,38 @@ export declare const collectPairedBookmarkIds: (blocks: readonly document_d_expo
31
125
  * @param options - Conversion options including style definitions
32
126
  */
33
127
  export declare function toProseDoc(document: document_d_exports.Document, options?: ToProseDocOptions): Node;
128
+ type ResolvedListRendering = ListRenderingDefinition;
129
+ /**
130
+ * Convert a Table to a ProseMirror table node
131
+ *
132
+ * Handles column widths from w:tblGrid - if cell widths aren't specified,
133
+ * we use the grid column widths to set cell widths. This ensures tables
134
+ * preserve their layout when opened from DOCX files.
135
+ */
136
+ type TableConversionContext = {
137
+ listRenderings: Map<string, ResolvedListRendering>;
138
+ numbering: NumberingMap | undefined;
139
+ theme: document_d_exports.Theme | null | undefined;
140
+ nextTextBoxGroupId: () => string;
141
+ nextHyperlinkInstanceIndex: HyperlinkInstanceIndexAllocator;
142
+ nextNoteReferenceOccurrenceId: () => string;
143
+ pairedBookmarkIds: IdMembership;
144
+ pageBreakRunSourceDescendants: PageBreakRunSourceDescendantIndex;
145
+ /** Comments the story opens a range for, for the point-comment question. */
146
+ storyRangedCommentIds: IdMembership;
147
+ warnPageBreakProjection: PageBreakProjectionWarn;
148
+ /** Shares one mark instance per distinct run formatting across the conversion. */
149
+ createMark: MarkFactory;
150
+ /**
151
+ * Comment ranges open at the walk's current position. A range is a story
152
+ * fact, not a paragraph one: it opens in one paragraph and closes in another,
153
+ * and every inline node between the two carries its mark. The walk visits the
154
+ * story in document order, so the set the block walker carries is exactly the
155
+ * set of ranges covering the node it is converting — the same way
156
+ * `pairedBookmarkIds` answers for a boundary whose partner is elsewhere.
157
+ */
158
+ openCommentIds: Set<number>;
159
+ };
34
160
  export declare function standaloneTableCellToProseMirror(cell: document_d_exports.TableCell, nodeType: "tableCell" | "tableHeader"): Node;
35
161
  /**
36
162
  * The host paragraph's attributes without its identity. The node may be
@@ -50,4 +176,5 @@ export declare function footnoteToProseDoc(content: document_d_exports.BlockCont
50
176
  /**
51
177
  * Create an empty ProseMirror document
52
178
  */
53
- export declare function createEmptyDoc(): Node;
179
+ export declare function createEmptyDoc(): Node;
180
+ export {};