@stll/folio-core 0.67.0 → 0.69.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 (350) hide show
  1. package/dist/ai-edits/apply.d.ts +9 -1
  2. package/dist/ai-edits/apply.js +94 -8
  3. package/dist/ai-edits/headless.d.ts +36 -21
  4. package/dist/ai-edits/headless.js +106 -36
  5. package/dist/ai-edits/index.d.ts +2 -2
  6. package/dist/ai-edits/newListNumbering.d.ts +14 -1
  7. package/dist/ai-edits/newListNumbering.js +24 -1
  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/pending-suggestions.js +2 -2
  11. package/dist/ai-edits/read.d.ts +19 -0
  12. package/dist/ai-edits/snapshot.d.ts +6 -0
  13. package/dist/ai-edits/snapshot.js +8 -3
  14. package/dist/ai-edits/types.d.ts +9 -1
  15. package/dist/ai-suggestions/apply.js +13 -4
  16. package/dist/compare/compare.js +2 -1
  17. package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
  18. package/dist/compare/inserted-resource-snapshot.js +7 -3
  19. package/dist/controller/canonicalClipboard.js +31 -14
  20. package/dist/controller/canonicalComposition.js +35 -6
  21. package/dist/controller/canonicalInlineProjection.d.ts +35 -10
  22. package/dist/controller/canonicalInlineProjection.js +192 -28
  23. package/dist/controller/canonicalInput.d.ts +2 -1
  24. package/dist/controller/canonicalInput.js +32 -7
  25. package/dist/controller/canonicalListRendering.d.ts +2 -1
  26. package/dist/controller/canonicalListRendering.js +1 -1
  27. package/dist/controller/canonicalLockGuard.d.ts +23 -0
  28. package/dist/controller/canonicalLockGuard.js +133 -0
  29. package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
  30. package/dist/controller/canonicalProjectionBlocks.js +75 -0
  31. package/dist/controller/canonicalPublicOperations.d.ts +12 -4
  32. package/dist/controller/canonicalPublicOperations.js +676 -46
  33. package/dist/controller/canonicalSeedContent.d.ts +12 -0
  34. package/dist/controller/canonicalSeedContent.js +131 -0
  35. package/dist/controller/canonicalSession.d.ts +133 -21
  36. package/dist/controller/canonicalSession.js +738 -205
  37. package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
  38. package/dist/controller/canonicalSourceNormalization.js +148 -0
  39. package/dist/controller/canonicalStoryEditor.d.ts +4 -3
  40. package/dist/controller/canonicalStoryEditor.js +20 -15
  41. package/dist/controller/canonicalStructure.d.ts +2 -1
  42. package/dist/controller/canonicalStructure.js +129 -7
  43. package/dist/controller/contentControlWidgetController.d.ts +5 -0
  44. package/dist/controller/contentControlWidgetController.js +13 -1
  45. package/dist/controller/folioEditor.js +4 -0
  46. package/dist/controller/headerFooterEditorManager.d.ts +7 -2
  47. package/dist/controller/headerFooterEditorManager.js +11 -6
  48. package/dist/controller/hiddenEditorApi.d.ts +17 -2
  49. package/dist/controller/hiddenEditorApi.js +4 -0
  50. package/dist/controller/hiddenEditorManager.d.ts +11 -3
  51. package/dist/controller/hiddenEditorManager.js +157 -48
  52. package/dist/controller/layoutPipeline.js +50 -16
  53. package/dist/controller/layoutSession.d.ts +3 -0
  54. package/dist/controller/layoutSession.js +3 -1
  55. package/dist/controller/noteEditorManager.d.ts +7 -2
  56. package/dist/controller/noteEditorManager.js +11 -6
  57. package/dist/display-list/build/pageFurniture.js +41 -19
  58. package/dist/display-list/build/tablePrimitives.js +23 -4
  59. package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
  60. package/dist/document-operations.d.ts +9 -1
  61. package/dist/document-operations.js +4 -3
  62. package/dist/docx/blockContentParser.d.ts +7 -3
  63. package/dist/docx/blockContentParser.js +2 -3
  64. package/dist/docx/blockPlainText.js +2 -0
  65. package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
  66. package/dist/docx/bookmarkRangeJoin.js +43 -0
  67. package/dist/docx/canonicalSave.js +11 -2
  68. package/dist/docx/canonicalSessionInput.d.ts +5 -1
  69. package/dist/docx/canonicalSessionInput.js +7 -2
  70. package/dist/docx/commentAnchorIndex.d.ts +40 -5
  71. package/dist/docx/commentAnchorIndex.js +94 -12
  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/contentTypeRegistry.js +1 -1
  80. package/dist/docx/encryption/compoundFile.js +9 -1
  81. package/dist/docx/encryption/encryptionInfo.js +16 -2
  82. package/dist/docx/ensureParaIds.js +46 -7
  83. package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
  84. package/dist/docx/ensureUniqueControlIds.js +110 -0
  85. package/dist/docx/headerFooterVerbatim.d.ts +7 -0
  86. package/dist/docx/headerFooterVerbatim.js +13 -2
  87. package/dist/docx/hostCommentThreads.d.ts +27 -0
  88. package/dist/docx/hostCommentThreads.js +72 -0
  89. package/dist/docx/hyperlinkParser.js +9 -2
  90. package/dist/docx/inlineWrapperContent.d.ts +8 -1
  91. package/dist/docx/inlineWrapperContent.js +9 -2
  92. package/dist/docx/listMarkerComputation.d.ts +35 -1
  93. package/dist/docx/listMarkerComputation.js +39 -1
  94. package/dist/docx/listModelNormalization.d.ts +44 -1
  95. package/dist/docx/listModelNormalization.js +226 -96
  96. package/dist/docx/listNumberingInstances.d.ts +1 -1
  97. package/dist/docx/listNumberingInstances.js +2 -2
  98. package/dist/docx/markupRangeMarker.d.ts +14 -0
  99. package/dist/docx/markupRangeMarker.js +15 -1
  100. package/dist/docx/metadataPrivacy.js +43 -22
  101. package/dist/docx/normalizeBaseDirection.js +3 -1
  102. package/dist/docx/numberingIds.d.ts +6 -0
  103. package/dist/docx/numberingIds.js +6 -1
  104. package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
  105. package/dist/docx/numberingReferenceNormalization.js +12 -2
  106. package/dist/docx/paragraphParser.js +159 -48
  107. package/dist/docx/paragraphPropertySource.d.ts +29 -0
  108. package/dist/docx/paragraphPropertySource.js +106 -16
  109. package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
  110. package/dist/docx/paragraphTraversal.js +2 -0
  111. package/dist/docx/parseWarningMessage.js +2 -1
  112. package/dist/docx/parser.js +8 -0
  113. package/dist/docx/removeHeaderFooterParts.js +1 -1
  114. package/dist/docx/renderedPageBreakNormalization.js +1 -1
  115. package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
  116. package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
  117. package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
  118. package/dist/docx/reviewResolutionProvenance.js +171 -33
  119. package/dist/docx/rezip.d.ts +6 -0
  120. package/dist/docx/rezip.js +38 -21
  121. package/dist/docx/selectiveSave.js +6 -10
  122. package/dist/docx/selectiveXmlPatch.d.ts +5 -4
  123. package/dist/docx/selectiveXmlPatch.js +11 -7
  124. package/dist/docx/serializer/documentSerializer.js +5 -2
  125. package/dist/docx/serializer/headerFooterSerializer.js +3 -1
  126. package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
  127. package/dist/docx/serializer/markupRangeAttributes.js +6 -1
  128. package/dist/docx/serializer/noteSerializer.d.ts +17 -4
  129. package/dist/docx/serializer/noteSerializer.js +23 -16
  130. package/dist/docx/serializer/paragraphSerializer.js +56 -12
  131. package/dist/docx/serializer/partNamespaces.d.ts +1 -1
  132. package/dist/docx/serializer/partNamespaces.js +1 -1
  133. package/dist/docx/serializer/runSerializer.d.ts +1 -3
  134. package/dist/docx/serializer/runSerializer.js +2 -2
  135. package/dist/docx/serializer/tableSerializer.d.ts +4 -0
  136. package/dist/docx/serializer/tableSerializer.js +4 -2
  137. package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
  138. package/dist/docx/server/build.d.ts +1 -1
  139. package/dist/docx/server/createBilingualDocument.js +27 -5
  140. package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
  141. package/dist/docx/sessionListPruning.d.ts +2 -0
  142. package/dist/docx/sessionListPruning.js +50 -0
  143. package/dist/docx/splitRevisionPieces.d.ts +10 -0
  144. package/dist/docx/splitRevisionPieces.js +14 -0
  145. package/dist/docx/storyBlockReplay.js +19 -2
  146. package/dist/docx/structuralXmlPatch.js +44 -11
  147. package/dist/docx/tableParser.d.ts +6 -2
  148. package/dist/docx/tableParser.js +2 -3
  149. package/dist/docx/textBoxContentParser.d.ts +11 -0
  150. package/dist/docx/textBoxContentParser.js +51 -0
  151. package/dist/docx/textBoxParser.d.ts +0 -5
  152. package/dist/docx/textBoxParser.js +1 -23
  153. package/dist/docx/verticalMergeProjection.js +1 -1
  154. package/dist/docx/xmlParser.d.ts +1 -1
  155. package/dist/docx/xmlParser.js +2 -3
  156. package/dist/fonts/fontsourceFaces.d.ts +2 -8
  157. package/dist/fonts/fontsourceFaces.js +1 -7
  158. package/dist/i18n/messages/ar.gen.js +3 -0
  159. package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
  160. package/dist/i18n/messages/catalogs.gen.js +51 -0
  161. package/dist/i18n/messages/cs.gen.js +3 -0
  162. package/dist/i18n/messages/de.gen.js +3 -0
  163. package/dist/i18n/messages/en.gen.js +3 -0
  164. package/dist/i18n/messages/es.gen.js +3 -0
  165. package/dist/i18n/messages/et.gen.js +3 -0
  166. package/dist/i18n/messages/fr.gen.js +3 -0
  167. package/dist/i18n/messages/he.gen.js +3 -0
  168. package/dist/i18n/messages/hi.gen.js +3 -0
  169. package/dist/i18n/messages/hu.gen.js +3 -0
  170. package/dist/i18n/messages/lt.gen.js +3 -0
  171. package/dist/i18n/messages/lv.gen.js +3 -0
  172. package/dist/i18n/messages/messages.gen.d.ts +3 -0
  173. package/dist/i18n/messages/pl.gen.js +3 -0
  174. package/dist/i18n/messages/pt-BR.gen.js +3 -0
  175. package/dist/i18n/messages/sk.gen.js +3 -0
  176. package/dist/i18n/messages/tr.gen.js +3 -0
  177. package/dist/i18n/messages/zh-CN.gen.js +3 -0
  178. package/dist/internal/acceptedBlockProjection.js +2 -0
  179. package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
  180. package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
  181. package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
  182. package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
  183. package/dist/internal/revisionResolutionInline.js +1 -2
  184. package/dist/internal/subtreeHolds.d.ts +12 -0
  185. package/dist/internal/subtreeHolds.js +25 -0
  186. package/dist/internal/wholeStoryRevisionResolution.js +1 -1
  187. package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
  188. package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
  189. package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
  190. package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
  191. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
  192. package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
  193. package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
  194. package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
  195. package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
  196. package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
  197. package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
  198. package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
  199. package/dist/layout-bridge/convert/tableConversion.js +19 -8
  200. package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
  201. package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
  202. package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
  203. package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
  204. package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
  205. package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
  206. package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
  207. package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
  208. package/dist/layout-bridge/dom/textStreamDom.js +3 -2
  209. package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
  210. package/dist/layout-bridge/engine/blockIndex.js +12 -0
  211. package/dist/layout-bridge/engine/hitTest.js +9 -10
  212. package/dist/layout-bridge/engine/selectionRects.js +6 -6
  213. package/dist/layout-bridge/headerFooterLayout.js +12 -11
  214. package/dist/layout-bridge/tableInsertHover.js +2 -1
  215. package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
  216. package/dist/layout-engine/footnoteContinuation.js +210 -0
  217. package/dist/layout-engine/index.d.ts +2 -2
  218. package/dist/layout-engine/index.js +7 -2
  219. package/dist/layout-engine/measure/cache.d.ts +2 -0
  220. package/dist/layout-engine/measure/cache.js +16 -6
  221. package/dist/layout-engine/measure/measureParagraph.js +1 -1
  222. package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
  223. package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
  224. package/dist/layout-engine/tableLayout.js +29 -5
  225. package/dist/layout-engine/tableRowBreak.d.ts +36 -0
  226. package/dist/layout-engine/tableRowBreak.js +43 -1
  227. package/dist/layout-engine/types.d.ts +42 -1
  228. package/dist/layout-painter/imageLayout.js +2 -1
  229. package/dist/layout-painter/pageShellStyles.d.ts +10 -0
  230. package/dist/layout-painter/pageShellStyles.js +32 -0
  231. package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
  232. package/dist/layout-painter/reconcileRenderedContent.js +117 -0
  233. package/dist/layout-painter/renderFragment.js +4 -6
  234. package/dist/layout-painter/renderImage.js +2 -2
  235. package/dist/layout-painter/renderPage.d.ts +4 -4
  236. package/dist/layout-painter/renderPage.js +54 -46
  237. package/dist/layout-painter/renderParagraph.js +3 -3
  238. package/dist/layout-painter/renderTable.js +16 -16
  239. package/dist/layout-painter/renderTextBox.js +2 -2
  240. package/dist/layout-painter/sdtBoundary.js +3 -2
  241. package/dist/managers/AutoSaveManager.d.ts +5 -1
  242. package/dist/managers/FindReplaceManager.js +3 -10
  243. package/dist/markdown/escape.d.ts +20 -1
  244. package/dist/markdown/escape.js +43 -1
  245. package/dist/markdown/renderBlock.js +4 -1
  246. package/dist/markdown/renderParagraph.js +13 -27
  247. package/dist/markdown/renderTable.js +6 -2
  248. package/dist/markdown/trailers.js +1 -0
  249. package/dist/paged-layout/blockGeometry.js +3 -2
  250. package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
  251. package/dist/paged-layout/editorScrollRoot.js +10 -1
  252. package/dist/paged-layout/rangeProjection.js +5 -4
  253. package/dist/paged-layout/scrollToPmPosition.js +3 -3
  254. package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
  255. package/dist/paged-layout/selectionViewportRect.js +8 -2
  256. package/dist/pdf/images.d.ts +17 -1
  257. package/dist/pdf/images.js +22 -4
  258. package/dist/pdf/writePdf.js +4 -2
  259. package/dist/prosemirror/attrs/index.js +2 -0
  260. package/dist/prosemirror/canonicalCommands.d.ts +39 -1
  261. package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
  262. package/dist/prosemirror/canonicalTableCommands.js +362 -0
  263. package/dist/prosemirror/commands/comments.d.ts +30 -2
  264. package/dist/prosemirror/commands/comments.js +189 -18
  265. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  266. package/dist/prosemirror/commands/index.d.ts +1 -1
  267. package/dist/prosemirror/commentIdAllocator.js +2 -2
  268. package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
  269. package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
  270. package/dist/prosemirror/commentRecords.d.ts +137 -0
  271. package/dist/prosemirror/commentRecords.js +400 -0
  272. package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
  273. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
  274. package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
  275. package/dist/prosemirror/conversion/index.d.ts +2 -2
  276. package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
  277. package/dist/prosemirror/conversion/toProseDoc.js +432 -76
  278. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  279. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  280. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
  281. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
  282. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
  283. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
  284. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
  285. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
  286. package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
  287. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
  288. package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
  289. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
  290. package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
  291. package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
  292. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
  293. package/dist/prosemirror/index.d.ts +3 -3
  294. package/dist/prosemirror/listLabels.js +3 -2
  295. package/dist/prosemirror/listNumbering.d.ts +6 -0
  296. package/dist/prosemirror/listNumbering.js +12 -9
  297. package/dist/prosemirror/lockedControls.d.ts +13 -0
  298. package/dist/prosemirror/lockedControls.js +106 -0
  299. package/dist/prosemirror/markupViewProjection.js +1 -1
  300. package/dist/prosemirror/nativeSelection.d.ts +33 -0
  301. package/dist/prosemirror/nativeSelection.js +74 -0
  302. package/dist/prosemirror/noteReferenceReview.js +2 -2
  303. package/dist/prosemirror/numberedRefFields.d.ts +2 -0
  304. package/dist/prosemirror/numberedRefFields.js +16 -5
  305. package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
  306. package/dist/prosemirror/paragraphMarkJoin.js +155 -16
  307. package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
  308. package/dist/prosemirror/plugins/documentNumbering.js +37 -15
  309. package/dist/prosemirror/plugins/suggestionMode.js +33 -10
  310. package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
  311. package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
  312. package/dist/prosemirror/replacedAnnotations.js +1 -0
  313. package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
  314. package/dist/prosemirror/runFormattingFromMarks.js +2 -4
  315. package/dist/prosemirror/runFormattingReconciliation.js +2 -2
  316. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
  317. package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
  318. package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
  319. package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
  320. package/dist/prosemirror/runStyleFormatting.js +16 -13
  321. package/dist/prosemirror/schema/marks.d.ts +13 -1
  322. package/dist/prosemirror/storyListNumbering.js +7 -2
  323. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
  324. package/dist/prosemirror/tableResize.d.ts +10 -9
  325. package/dist/prosemirror/tableResize.js +60 -49
  326. package/dist/prosemirror/textInput.d.ts +30 -1
  327. package/dist/prosemirror/textInput.js +144 -17
  328. package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
  329. package/dist/prosemirror/validation.d.ts +19 -0
  330. package/dist/prosemirror/validation.js +79 -5
  331. package/dist/redline.js +23 -9
  332. package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
  333. package/dist/render-dom/RenderedDomContext.js +7 -6
  334. package/dist/server.d.ts +2 -2
  335. package/dist/style-sets/extract.js +2 -2
  336. package/dist/types/canonicalCapabilities.d.ts +38 -16
  337. package/dist/types/canonicalCapabilities.js +21 -18
  338. package/dist/utils/cssString.d.ts +7 -0
  339. package/dist/utils/cssString.js +9 -0
  340. package/dist/utils/findMatchView.js +4 -3
  341. package/dist/utils/fontResolver.js +4 -1
  342. package/dist/utils/formatToStyle.d.ts +1 -1
  343. package/dist/utils/mergeDocumentContent.js +2 -2
  344. package/dist/utils/paintedPositions.d.ts +60 -0
  345. package/dist/utils/paintedPositions.js +101 -0
  346. package/dist/utils/replaceText.d.ts +11 -0
  347. package/dist/utils/replaceText.js +39 -7
  348. package/dist/version-comparison.d.ts +9 -1
  349. package/dist/version-comparison.js +11 -5
  350. package/package.json +2 -3
@@ -1,6 +1,6 @@
1
1
  import { isQuoteStyle, resolveHeadingLevel } from "../docx/builtInStyles.js";
2
2
  import { countParagraphList } from "./countParagraphList.js";
3
- import { inlineBreaksToHtml } from "./escape.js";
3
+ import { escapeLeadingBlockMarker, inlineBreaksToHtml, protectBreakBlanks } from "./escape.js";
4
4
  import { renderParagraphInline } from "./renderRuns.js";
5
5
  // src/markdown/renderParagraph.ts
6
6
  /**
@@ -33,12 +33,14 @@ function renderParagraph(ctx, pkg, para) {
33
33
  */
34
34
  function renderParagraphBlock(ctx, pkg, para) {
35
35
  const { visibleList, label } = countParagraphList(ctx, pkg, para);
36
- const inline = renderParagraphInline(ctx, pkg, para.content, para.paraId);
36
+ const written = renderParagraphInline(ctx, pkg, para.content, para.paraId);
37
+ const blank = written.trim().length === 0;
38
+ const inline = protectBreakBlanks(written);
37
39
  const styleId = para.formatting?.styleId;
38
40
  const headingLevel = markdownHeadingLevel(ctx, para);
39
41
  if (headingLevel !== void 0) {
40
42
  ctx.listIndentWidths = [];
41
- if (!inline || !inline.trim() && label === void 0) return {
43
+ if (!inline || blank && label === void 0) return {
42
44
  type: "paragraph",
43
45
  markdown: ""
44
46
  };
@@ -49,7 +51,12 @@ function renderParagraphBlock(ctx, pkg, para) {
49
51
  type: "paragraph"
50
52
  };
51
53
  }
52
- if (visibleList && label !== void 0) return renderListItem(ctx, visibleList, label, inline);
54
+ if (visibleList && label !== void 0) return renderListItem(ctx, {
55
+ list: visibleList,
56
+ label,
57
+ inline,
58
+ blank
59
+ });
53
60
  ctx.listIndentWidths = [];
54
61
  if (isQuoteStyle(styleId, ctx.builtInStyles)) return {
55
62
  markdown: inline.split("\n").map((line) => `> ${line}`).join("\n"),
@@ -68,15 +75,6 @@ function markdownHeadingLevel(ctx, para) {
68
75
  }, ctx.builtInStyles);
69
76
  }
70
77
  /**
71
- * A plain paragraph whose visible text begins with markdown block syntax (e.g.
72
- * `# Not a heading`, `- value`, `1. value`, `> quote`) would be reclassified as
73
- * a heading/list/blockquote on re-parse, even though Word carries no matching
74
- * style/list metadata. Escape the leading marker so literal text round-trips.
75
- */
76
- function escapeLeadingBlockMarker(text) {
77
- return text.replace(/^(?<ws>[ \t]*)(?<marker>[#>=])/gmu, "$<ws>\\$<marker>").replace(/^(?<ws>[ \t]*)(?<marker>[-+*])(?=[ \t]|$)/gmu, "$<ws>\\$<marker>").replace(/^(?<ws>[ \t]*)-(?=[- \t]*$)/gmu, "$<ws>\\-").replace(/^(?<ws>[ \t]*)(?<num>\d{1,9})(?<marker>[.)])(?<after>[ \t])/gmu, "$<ws>$<num>\\$<marker>$<after>");
78
- }
79
- /**
80
78
  * Only emitted Markdown ancestors contribute columns. OOXML levels may skip
81
79
  * ancestors or resume after prose; inventing those columns creates code blocks.
82
80
  */
@@ -85,19 +83,7 @@ function listIndentWidth(ctx, level) {
85
83
  for (let ancestor = 0; ancestor < level; ancestor++) width += ctx.listIndentWidths[ancestor] ?? 0;
86
84
  return width;
87
85
  }
88
- /**
89
- * A list item line with the label the page shows (`1.`, `a)`, `i.`), counted
90
- * in document order across the whole render, list items inside tables and
91
- * block SDTs included. A bullet is Markdown's `-`.
92
- *
93
- * The indent before the marker is not a fixed two spaces: CommonMark keeps a
94
- * child nested under its parent only when it starts at or past the column
95
- * where the parent item's content begins, which is the width of the parent's
96
- * marker plus its one trailing space (`1. ` is 3 columns, `10. ` is 4, `- ` is
97
- * 2). `ctx.listIndentWidths` is updated with this item's own marker width so
98
- * a following, deeper item can indent correctly under it.
99
- */
100
- function renderListItem(ctx, list, label, inline) {
86
+ function renderListItem(ctx, { list, label, inline, blank }) {
101
87
  if (!(list.isBullet || /^\d{1,9}[.)]$/u.test(label))) {
102
88
  ctx.listIndentWidths = [];
103
89
  return {
@@ -112,7 +98,7 @@ function renderListItem(ctx, list, label, inline) {
112
98
  return {
113
99
  type: "listItem",
114
100
  markdown: `${indent}${marker}${escapeLeadingBlockMarker(inline)}`.trimEnd(),
115
- separation: inline.trim().length === 0 ? "loose" : "tight"
101
+ separation: blank ? "loose" : "tight"
116
102
  };
117
103
  }
118
104
  export { renderParagraph, renderParagraphBlock };
@@ -3,7 +3,7 @@ import { getHyperlinkRuns } from "../docx/hyperlinkParser.js";
3
3
  import { OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC, isOpaqueNestedRowMarkup, opaqueRevisionCarrierName } from "../docx/opaqueCarrier.js";
4
4
  import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "../docx/relsParser.js";
5
5
  import { decodeOoxmlSymbolCharacter } from "../utils/ooxmlSymbol.js";
6
- import { escapeTableCell } from "./escape.js";
6
+ import { escapeTableCell, inlineBreaksToHtml } from "./escape.js";
7
7
  import { registerImage } from "./images.js";
8
8
  import { numberNoteReference, pushWarning } from "./internals.js";
9
9
  import { renderParagraph } from "./renderParagraph.js";
@@ -90,6 +90,8 @@ function renderGfmCell(ctx, pkg, cell) {
90
90
  break;
91
91
  case "bookmarkStart":
92
92
  case "bookmarkEnd":
93
+ case "commentRangeStart":
94
+ case "commentRangeEnd":
93
95
  case "moveFromRangeStart":
94
96
  case "moveFromRangeEnd":
95
97
  case "moveToRangeStart":
@@ -167,12 +169,14 @@ function renderHtmlCell(ctx, pkg, cell) {
167
169
  renderBlocks(item.content);
168
170
  break;
169
171
  case "preservedBlock":
170
- if (isAltChunkMarkup(item.xml)) parts.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC} ${item.readerText}`);
172
+ if (isAltChunkMarkup(item.xml)) parts.push(item.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC} ${inlineBreaksToHtml(escapeHtml(item.readerText))}`);
171
173
  else if (opaqueRevisionCarrierName(item.xml) !== void 0) parts.push(OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC);
172
174
  else if (isOpaqueNestedRowMarkup(item.xml)) parts.push("[Unsupported nested w:tr content]");
173
175
  break;
174
176
  case "bookmarkStart":
175
177
  case "bookmarkEnd":
178
+ case "commentRangeStart":
179
+ case "commentRangeEnd":
176
180
  case "moveFromRangeStart":
177
181
  case "moveFromRangeEnd":
178
182
  case "moveToRangeStart":
@@ -55,6 +55,7 @@ function inlineText(content) {
55
55
  break;
56
56
  case "hyperlink":
57
57
  for (const child of item.children) if (child.type === "run") out += runText(child);
58
+ else if (child.type === "complexField") out += inlineText(child.fieldResult);
58
59
  break;
59
60
  case "complexField":
60
61
  out += inlineText(item.fieldResult);
@@ -1,7 +1,8 @@
1
1
  import { resolveSequentialBlockAnchor } from "../ai-edits/blockRange.js";
2
2
  import { PAINTER_PAINTED_EVENT, findPageShellForPmPos } from "../layout-painter/renderPage.js";
3
+ import { PAINTED_START_SELECTOR, readPaintedStart } from "../utils/paintedPositions.js";
3
4
  // src/paged-layout/blockGeometry.ts
4
- const PAINTED_BLOCK_SELECTOR = "[data-block-id][data-pm-start]";
5
+ const PAINTED_BLOCK_SELECTOR = `[data-block-id]${PAINTED_START_SELECTOR}`;
5
6
  const PAGE_SELECTOR = "[data-page-number]";
6
7
  const pageNumberOf = (page) => {
7
8
  const raw = page.dataset["pageNumber"];
@@ -23,7 +24,7 @@ const requestedBlocks = (blockIds, snapshot) => {
23
24
  const paintedBlocksByPmStart = (page) => {
24
25
  const blocks = /* @__PURE__ */ new Map();
25
26
  for (const element of page.querySelectorAll(PAINTED_BLOCK_SELECTOR)) {
26
- const pmStart = Number(element.dataset["pmStart"]);
27
+ const pmStart = readPaintedStart(element) ?? NaN;
27
28
  if (Number.isFinite(pmStart) && !blocks.has(pmStart)) blocks.set(pmStart, element);
28
29
  }
29
30
  return blocks;
@@ -1,6 +1,15 @@
1
1
  export declare const getEditorScrollRoot: (element: HTMLElement | null) => HTMLElement | null;
2
2
  /** Resolve the root even when a caller holds a painted descendant or viewport. */
3
3
  export declare const scrollEditorTo: (element: HTMLElement | null, options: ScrollToOptions) => void;
4
+ /**
5
+ * Scroll a box that only clips (such as the hidden editor's wrapper) back to
6
+ * its origin. It is not the editor's scroll root; the browser scrolls it to
7
+ * reveal a caret, and nothing it shows may move with that scroll.
8
+ */
9
+ export declare const scrollClipBoxToOrigin: (box: {
10
+ scrollLeft: number;
11
+ scrollTop: number;
12
+ }) => void;
4
13
  export declare const scrollEditorBy: (element: HTMLElement | null, delta: number) => void;
5
14
  type ScrollEditorElementOptions = {
6
15
  block?: "start" | "center" | "end" | "nearest";
@@ -7,6 +7,15 @@ const getEditorScrollRoot = (element) => element?.closest(EDITOR_SCROLL_ROOT_SEL
7
7
  const scrollEditorTo = (element, options) => {
8
8
  getEditorScrollRoot(element)?.scrollTo(options);
9
9
  };
10
+ /**
11
+ * Scroll a box that only clips (such as the hidden editor's wrapper) back to
12
+ * its origin. It is not the editor's scroll root; the browser scrolls it to
13
+ * reveal a caret, and nothing it shows may move with that scroll.
14
+ */
15
+ const scrollClipBoxToOrigin = (box) => {
16
+ if (box.scrollLeft !== 0) box.scrollLeft = 0;
17
+ if (box.scrollTop !== 0) box.scrollTop = 0;
18
+ };
10
19
  const scrollEditorBy = (element, delta) => {
11
20
  const root = getEditorScrollRoot(element);
12
21
  if (root) scrollEditorTo(root, {
@@ -76,4 +85,4 @@ const scrollEditorElementIntoView = (element, { block = "center", behavior, marg
76
85
  behavior: behavior ?? navigationScrollBehavior(clampedTop - root.scrollTop, root.clientHeight)
77
86
  });
78
87
  };
79
- export { getEditorScrollRoot, scrollEditorBy, scrollEditorElementIntoView, scrollEditorTo };
88
+ export { getEditorScrollRoot, scrollClipBoxToOrigin, scrollEditorBy, scrollEditorElementIntoView, scrollEditorTo };
@@ -1,5 +1,6 @@
1
1
  import { findBodyPmSpans } from "../layout-bridge/dom/findBodyPmSpans.js";
2
2
  import { createTextStreamRange, descendantTextNodes, totalTextLength } from "../layout-bridge/dom/textStreamDom.js";
3
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
3
4
  // src/paged-layout/rangeProjection.ts
4
5
  /**
5
6
  * Shared range → paged-canvas rectangle projection.
@@ -22,8 +23,8 @@ const pageIndexOf = (el) => {
22
23
  const domRectsForRange = (pmSpans, overlayRect, zoom, from, to) => {
23
24
  const rects = [];
24
25
  for (const spanEl of pmSpans) {
25
- const pmStart = Number(spanEl.dataset["pmStart"]);
26
- if (!(Number(spanEl.dataset["pmEnd"]) > from && pmStart < to)) continue;
26
+ const pmStart = readPaintedStart(spanEl) ?? NaN;
27
+ if (!((readPaintedEnd(spanEl) ?? NaN) > from && pmStart < to)) continue;
27
28
  if (spanEl.classList.contains("layout-run-tab")) {
28
29
  const spanRect = spanEl.getBoundingClientRect();
29
30
  rects.push({
@@ -119,8 +120,8 @@ const collectRunFontsAtPmPositions = (pagesContainer, positions) => {
119
120
  const remaining = new Set(positions);
120
121
  for (const spanEl of findBodyPmSpans(pagesContainer)) {
121
122
  if (remaining.size === 0) break;
122
- const pmStart = Number(spanEl.dataset["pmStart"]);
123
- const pmEnd = Number(spanEl.dataset["pmEnd"]);
123
+ const pmStart = readPaintedStart(spanEl) ?? NaN;
124
+ const pmEnd = readPaintedEnd(spanEl) ?? NaN;
124
125
  if (Number.isNaN(pmStart) || Number.isNaN(pmEnd)) continue;
125
126
  for (const pos of remaining) {
126
127
  if (!(pmStart <= pos && pos < pmEnd)) continue;
@@ -1,5 +1,6 @@
1
1
  import { findBodyPmAnchor, findBodyPmAnchors } from "../layout-bridge/dom/findBodyPmSpans.js";
2
2
  import { findPageShellForPmPos, renderPagesAround } from "../layout-painter/renderPage.js";
3
+ import { readPaintedEnd, readPaintedStart } from "../utils/paintedPositions.js";
3
4
  import { getEditorScrollRoot, scrollEditorElementIntoView } from "./editorScrollRoot.js";
4
5
  import { isValidPmScrollPosition } from "./scrollNavigation.js";
5
6
  // src/paged-layout/scrollToPmPosition.ts
@@ -22,13 +23,12 @@ const scrollPagesToPmPosition = (pageContainer, pmPos) => {
22
23
  const anchorRanges = (root) => {
23
24
  const ranges = [];
24
25
  for (const element of findBodyPmAnchors(root)) {
25
- const start = Number(element.dataset["pmStart"]);
26
+ const start = readPaintedStart(element) ?? NaN;
26
27
  if (Number.isNaN(start)) continue;
27
- const endAttr = element.dataset["pmEnd"];
28
28
  ranges.push({
29
29
  element,
30
30
  start,
31
- end: endAttr === void 0 ? start : Number(endAttr)
31
+ end: readPaintedEnd(element) ?? start
32
32
  });
33
33
  }
34
34
  return ranges;
@@ -3,6 +3,12 @@ import { EditorView } from "prosemirror-view";
3
3
  export declare const FOLIO_SELECTION_RECT_ATTRIBUTE = "data-folio-selection-rect";
4
4
  /** Attribute SelectionOverlay stamps on the painted collapsed caret. */
5
5
  export declare const FOLIO_CARET_RECT_ATTRIBUTE = "data-folio-caret-rect";
6
+ /**
7
+ * Attribute the paged editor sets on its selection overlay while typed
8
+ * content lays out again: the caret the overlay still holds stands where the
9
+ * text was, so it is hidden, and it does not anchor anything.
10
+ */
11
+ export declare const FOLIO_INPUT_HIDDEN_ATTRIBUTE = "data-folio-input-hidden";
6
12
  /**
7
13
  * Union bounding rect (client coordinates) of the painted selection
8
14
  * highlights mirroring `view`'s selection. Returns null for a collapsed
@@ -4,6 +4,12 @@ const FOLIO_SELECTION_RECT_ATTRIBUTE = "data-folio-selection-rect";
4
4
  /** Attribute SelectionOverlay stamps on the painted collapsed caret. */
5
5
  const FOLIO_CARET_RECT_ATTRIBUTE = "data-folio-caret-rect";
6
6
  /**
7
+ * Attribute the paged editor sets on its selection overlay while typed
8
+ * content lays out again: the caret the overlay still holds stands where the
9
+ * text was, so it is hidden, and it does not anchor anything.
10
+ */
11
+ const FOLIO_INPUT_HIDDEN_ATTRIBUTE = "data-folio-input-hidden";
12
+ /**
7
13
  * Union bounding rect (client coordinates) of the painted selection
8
14
  * highlights mirroring `view`'s selection. Returns null for a collapsed
9
15
  * selection or while the overlay has not painted yet — the selection
@@ -46,9 +52,9 @@ const getFolioCaretViewportRect = (view) => {
46
52
  const scrollContainer = view.dom.closest("[data-folio-scroll]");
47
53
  if (!scrollContainer) return null;
48
54
  const caret = scrollContainer.querySelector(`[${FOLIO_CARET_RECT_ATTRIBUTE}]`);
49
- if (!caret) return null;
55
+ if (!caret || caret.closest(`[data-folio-input-hidden]`)) return null;
50
56
  const rect = caret.getBoundingClientRect();
51
57
  if (rect.height <= 0) return null;
52
58
  return rect;
53
59
  };
54
- export { FOLIO_CARET_RECT_ATTRIBUTE, FOLIO_SELECTION_RECT_ATTRIBUTE, getFolioCaretViewportRect, getFolioSelectionViewportRect };
60
+ export { FOLIO_CARET_RECT_ATTRIBUTE, FOLIO_INPUT_HIDDEN_ATTRIBUTE, FOLIO_SELECTION_RECT_ATTRIBUTE, getFolioCaretViewportRect, getFolioSelectionViewportRect };
@@ -22,5 +22,21 @@ export type PdfImageSamples = {
22
22
  readonly decode?: readonly number[];
23
23
  readonly alpha?: PdfImageAlpha;
24
24
  };
25
- export declare const decodeImage: (source: DisplayImageSource) => Result<PdfImageSamples, PdfImageError>;
25
+ /**
26
+ * Largest PNG raster decoded for one image. A PNG's IDAT can compress an
27
+ * empty raster about a thousandfold, so the encoded size says little about
28
+ * the decode: 64 MP of RGBA is 256 MB per raster copy before the alpha split
29
+ * and the re-deflate. Matches the per-image TIFF ceiling at import.
30
+ */
31
+ export declare const MAX_PDF_PNG_PIXELS = 64000000;
32
+ /**
33
+ * Pixels decoded across every PNG in one PDF. The per-image ceiling bounds a
34
+ * single decode; without a running total many large images still add up.
35
+ */
36
+ export declare const MAX_PDF_DOCUMENT_PNG_PIXELS = 256000000;
37
+ /**
38
+ * Decode one image for painting. `maxPngPixels` is what remains of the
39
+ * document's PNG pixel budget; JPEG passes through undecoded and spends none.
40
+ */
41
+ export declare const decodeImage: (source: DisplayImageSource, maxPngPixels?: number) => Result<PdfImageSamples, PdfImageError>;
26
42
  export {};
@@ -48,6 +48,18 @@ const FULLY_OPAQUE = 255;
48
48
  const EIGHT_BIT = 8;
49
49
  /** IHDR interlace method 1: the only one PNG defines besides "none". */
50
50
  const ADAM7_INTERLACE = 1;
51
+ /**
52
+ * Largest PNG raster decoded for one image. A PNG's IDAT can compress an
53
+ * empty raster about a thousandfold, so the encoded size says little about
54
+ * the decode: 64 MP of RGBA is 256 MB per raster copy before the alpha split
55
+ * and the re-deflate. Matches the per-image TIFF ceiling at import.
56
+ */
57
+ const MAX_PDF_PNG_PIXELS = 64e6;
58
+ /**
59
+ * Pixels decoded across every PNG in one PDF. The per-image ceiling bounds a
60
+ * single decode; without a running total many large images still add up.
61
+ */
62
+ const MAX_PDF_DOCUMENT_PNG_PIXELS = 256e6;
51
63
  const toHex = (bytes) => {
52
64
  let out = "";
53
65
  for (const byte of bytes) out += byte.toString(16).padStart(2, "0").toUpperCase();
@@ -281,7 +293,7 @@ const expandIndices = ({ rows, bytesPerRow, width, height, bitDepth }) => {
281
293
  }
282
294
  return out;
283
295
  };
284
- const decodePng = (bytes) => {
296
+ const decodePng = (bytes, maxPixels) => {
285
297
  const chunks = readPngChunks(bytes);
286
298
  if (chunks.isErr()) return Result.err(chunks.error);
287
299
  const { header, palette, transparency, pixels } = chunks.value;
@@ -292,6 +304,8 @@ const decodePng = (bytes) => {
292
304
  const colorType = header[9] ?? 0;
293
305
  const interlace = header[12] ?? 0;
294
306
  if (width === 0 || height === 0) return Result.err(new PdfImageError({ message: "PNG has a zero dimension" }));
307
+ const pixelLimit = Math.min(maxPixels, MAX_PDF_PNG_PIXELS);
308
+ if (width * height > pixelLimit) return Result.err(new PdfImageError({ message: `PNG is ${String(width)}x${String(height)} pixels, above the ${String(pixelLimit)} pixels allowed` }));
295
309
  if (interlace !== 0 && interlace !== ADAM7_INTERLACE) return Result.err(new PdfImageError({ message: `unknown PNG interlace method ${String(interlace)}` }));
296
310
  const channels = CHANNELS_PER_COLOR_TYPE[colorType];
297
311
  if (channels === void 0) return Result.err(new PdfImageError({ message: `unknown PNG colour type ${String(colorType)}` }));
@@ -566,9 +580,13 @@ const decodeJpeg = (bytes) => {
566
580
  }
567
581
  return Result.err(new PdfImageError({ message: "JPEG has no frame header" }));
568
582
  };
569
- const decodeImage = (source) => {
583
+ /**
584
+ * Decode one image for painting. `maxPngPixels` is what remains of the
585
+ * document's PNG pixel budget; JPEG passes through undecoded and spends none.
586
+ */
587
+ const decodeImage = (source, maxPngPixels = MAX_PDF_PNG_PIXELS) => {
570
588
  switch (source.format) {
571
- case "png": return decodePng(source.bytes);
589
+ case "png": return decodePng(source.bytes, maxPngPixels);
572
590
  case "jpeg": return decodeJpeg(source.bytes);
573
591
  case "svg": return Result.err(new PdfImageError({ message: "SVG images are not supported in PDF" }));
574
592
  default: {
@@ -577,4 +595,4 @@ const decodeImage = (source) => {
577
595
  }
578
596
  }
579
597
  };
580
- export { PdfImageError, decodeImage };
598
+ export { MAX_PDF_DOCUMENT_PNG_PIXELS, MAX_PDF_PNG_PIXELS, PdfImageError, decodeImage };
@@ -2,7 +2,7 @@ import { getShaper } from "../shaping/shaper.js";
2
2
  import { encodeUtf8 } from "../utils/textEncoding.js";
3
3
  import { collectResources, renderContentStream } from "./contentStream.js";
4
4
  import { prepareFonts } from "./fonts.js";
5
- import { decodeImage } from "./images.js";
5
+ import { MAX_PDF_DOCUMENT_PNG_PIXELS, decodeImage } from "./images.js";
6
6
  import { createPdfDocument, pdfArray, pdfAsciiString, pdfDict, pdfFlateStream, pdfName, pdfNull, pdfNumber, pdfNumberArray, pdfStream, pdfTextString } from "./objects.js";
7
7
  import { displayPointToPdf, pxToPt } from "./pageSpace.js";
8
8
  import { collectUsage, paintPage } from "./paint.js";
@@ -265,14 +265,16 @@ const writePdf = async (list, options) => {
265
265
  });
266
266
  if (options.strictGlyphCoverage === true && unencodable.length > 0) return Result.err(new WritePdfError({ message: describeUnencodable(unencodable) }));
267
267
  const imageRefs = /* @__PURE__ */ new Map();
268
+ let remainingPngPixels = MAX_PDF_DOCUMENT_PNG_PIXELS;
268
269
  for (const imageIndex of [...usage.value.imageIndices].sort((left, right) => left - right)) {
269
270
  const source = list.images[imageIndex];
270
271
  if (source === void 0) return Result.err(new WritePdfError({ message: `image ${String(imageIndex)} is outside the image table` }));
271
- const decoded = decodeImage(source);
272
+ const decoded = decodeImage(source, remainingPngPixels);
272
273
  if (decoded.isErr()) return Result.err(new WritePdfError({
273
274
  message: `image ${String(imageIndex)} could not be decoded: ${decoded.error.message}`,
274
275
  cause: decoded.error
275
276
  }));
277
+ if (source.format === "png") remainingPngPixels -= decoded.value.widthPx * decoded.value.heightPx;
276
278
  imageRefs.set(imageIndex, buildImageObject(document, decoded.value));
277
279
  }
278
280
  const outlineRoots = buildOutlineTree(list.outline, document);
@@ -978,6 +978,8 @@ const readCommentMarkAttrs = (mark) => {
978
978
  const issues = [];
979
979
  expectMarkType(mark, "comment", issues);
980
980
  requiredNumber(attrs, "commentId", "comment.attrs.commentId", issues);
981
+ optionalBoolean(attrs, "point", "comment.attrs.point", issues);
982
+ optionalString(attrs, "suggestionId", "comment.attrs.suggestionId", issues);
981
983
  return attrsResult(attrs, issues);
982
984
  };
983
985
  const expectCommentMarkAttrs = (mark) => expectCachedMarkAttrs(mark, commentAttrsCache, readCommentMarkAttrs, "comment attrs");
@@ -1,9 +1,47 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
+ import { TableCellFormatting, TableFormatting, TableRowFormatting } from "../types/formatting.js";
2
3
  import { Node } from "prosemirror-model";
3
4
  import { Command, EditorState } from "prosemirror-state";
4
- import { FormattingPatch, ParagraphPropsPatch, RunPropsPatch } from "@stll/docx-core/ops";
5
+ import { FormattingPatch, ParagraphPropsPatch, RunPropsPatch, TableBlockIntentOperation, TableIntentOperation, TableRowIntentOperation } from "@stll/docx-core/ops";
6
+ /** One table, row or cell, addressed by a position inside its first paragraph. */
7
+ export type CanonicalTableFormatTarget = {
8
+ scope: "table";
9
+ at: number;
10
+ patch: FormattingPatch<TableFormatting>;
11
+ } | {
12
+ scope: "row";
13
+ at: number;
14
+ patch: FormattingPatch<TableRowFormatting>;
15
+ } | {
16
+ scope: "cell";
17
+ at: number;
18
+ patch: FormattingPatch<TableCellFormatting>;
19
+ };
20
+ type WithoutTableTarget<Operation> = Operation extends unknown ? Omit<Operation, "story" | "blockId"> : never;
21
+ /**
22
+ * A change to a table's columns, cells or grid. The session addresses the
23
+ * table through a paragraph of its own; the engine derives fresh ids.
24
+ */
25
+ export type CanonicalTableEdit = WithoutTableTarget<Exclude<TableIntentOperation, {
26
+ type: "setCellProps" | "setRowProps" | "setTableProps";
27
+ }>>;
5
28
  /** Command meaning before canonical positions are resolved by the session. */
6
29
  export type CanonicalCommandIntent = {
30
+ type: "formatTable";
31
+ targets: readonly CanonicalTableFormatTarget[];
32
+ } | {
33
+ type: "editTable";
34
+ at: number;
35
+ edit: CanonicalTableEdit;
36
+ } | {
37
+ type: "editTableBlock";
38
+ at: number;
39
+ edit: WithoutTableTarget<TableBlockIntentOperation>;
40
+ } | {
41
+ type: "editTableRow";
42
+ at: number;
43
+ edit: WithoutTableTarget<TableRowIntentOperation>;
44
+ } | {
7
45
  type: "generateTOC";
8
46
  at: number;
9
47
  title: string;
@@ -0,0 +1,28 @@
1
+ import { CanonicalCommandIntent } from "./canonicalCommands.js";
2
+ import { Command, EditorState } from "prosemirror-state";
3
+ /**
4
+ * What an attribute-only table command does, as table formatting patches.
5
+ *
6
+ * The command runs against the state without dispatching to the view. Every
7
+ * table, row and cell whose attributes it changed lowers to a patch of the
8
+ * formatting the save would write for it, so the session applies exactly what
9
+ * the editor would have saved. A command that changes anything else (content,
10
+ * a node's type, a span) has no attribute lowering and stays refused.
11
+ */
12
+ export declare const lowerTableAttributeCommand: (command: Command, state: EditorState) => readonly CanonicalCommandIntent[] | undefined;
13
+ /** Register a command whose whole effect is table, row and cell attributes. */
14
+ export declare const withCanonicalTableAttributeCommand: (command: Command) => Command;
15
+ export declare const withCanonicalColumnInsertion: (command: Command, side: "left" | "right") => Command;
16
+ export declare const withCanonicalColumnDeletion: (command: Command) => Command;
17
+ export declare const withCanonicalCellMerge: (command: Command) => Command;
18
+ export declare const withCanonicalCellSplit: (command: Command) => Command;
19
+ export declare const withCanonicalRowInsertion: (command: Command, side: "above" | "below") => Command;
20
+ export declare const withCanonicalRowDeletion: (command: Command) => Command;
21
+ export declare const withCanonicalTableDeletion: (command: Command) => Command;
22
+ /**
23
+ * Register the insert table command, lowered to a table and an empty
24
+ * paragraph after the paragraph that holds the caret, as the command places
25
+ * them. The table is the one the command built, without the revision marks
26
+ * it put on its rows; in suggesting mode the engine records its own.
27
+ */
28
+ export declare const withCanonicalTableInsertion: (command: Command) => Command;