@stll/folio-core 0.52.0 → 0.54.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 (389) hide show
  1. package/README.md +23 -0
  2. package/dist/ai-edits/apply.d.ts +26 -1
  3. package/dist/ai-edits/apply.js +1779 -141
  4. package/dist/ai-edits/batch-claims.d.ts +145 -0
  5. package/dist/ai-edits/batch-claims.js +275 -0
  6. package/dist/ai-edits/blockRange.js +9 -3
  7. package/dist/ai-edits/character-boundaries.d.ts +43 -0
  8. package/dist/ai-edits/character-boundaries.js +95 -0
  9. package/dist/ai-edits/clean-text.d.ts +33 -3
  10. package/dist/ai-edits/clean-text.js +52 -6
  11. package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
  12. package/dist/ai-edits/comment-lifecycle.js +52 -0
  13. package/dist/ai-edits/headless.d.ts +91 -7
  14. package/dist/ai-edits/headless.js +520 -51
  15. package/dist/ai-edits/index.d.ts +2 -1
  16. package/dist/ai-edits/index.js +2 -1
  17. package/dist/ai-edits/minimal-replacement.d.ts +21 -6
  18. package/dist/ai-edits/minimal-replacement.js +134 -15
  19. package/dist/ai-edits/newListNumbering.d.ts +23 -0
  20. package/dist/ai-edits/newListNumbering.js +94 -0
  21. package/dist/ai-edits/note-references.d.ts +96 -0
  22. package/dist/ai-edits/note-references.js +139 -0
  23. package/dist/ai-edits/pending-suggestions.d.ts +79 -0
  24. package/dist/ai-edits/pending-suggestions.js +306 -0
  25. package/dist/ai-edits/read.d.ts +6 -4
  26. package/dist/ai-edits/read.js +113 -50
  27. package/dist/ai-edits/result-validation.d.ts +29 -0
  28. package/dist/ai-edits/result-validation.js +164 -0
  29. package/dist/ai-edits/revisionStretches.d.ts +17 -0
  30. package/dist/ai-edits/revisionStretches.js +80 -0
  31. package/dist/ai-edits/snapshot.d.ts +36 -3
  32. package/dist/ai-edits/snapshot.js +180 -25
  33. package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
  34. package/dist/ai-edits/table-cell-mutations.js +6 -2
  35. package/dist/ai-edits/table-geometry.d.ts +1 -1
  36. package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
  37. package/dist/ai-edits/table-row-column-mutations.js +86 -34
  38. package/dist/ai-edits/types.d.ts +155 -16
  39. package/dist/compare/compare.d.ts +1 -1
  40. package/dist/compare/compare.js +65 -16
  41. package/dist/compare/content-alignment.d.ts +5 -1
  42. package/dist/compare/content-alignment.js +52 -34
  43. package/dist/compare/content-types.d.ts +7 -0
  44. package/dist/compare/content.d.ts +4 -1
  45. package/dist/compare/content.js +6 -1
  46. package/dist/compare/formatting.js +2 -1
  47. package/dist/compare/inline-atoms.d.ts +21 -4
  48. package/dist/compare/inline-atoms.js +138 -16
  49. package/dist/compare/inline-provenance.js +1 -1
  50. package/dist/compare/plan.js +10 -5
  51. package/dist/compare/scenario.js +14 -3
  52. package/dist/compare/section-boundary-properties.js +1 -1
  53. package/dist/compare/types.d.ts +4 -2
  54. package/dist/compare/types.js +2 -1
  55. package/dist/compare/verification.d.ts +1 -1
  56. package/dist/compare/verification.js +15 -3
  57. package/dist/controller/committedLayoutDiff.d.ts +25 -0
  58. package/dist/controller/committedLayoutDiff.js +71 -0
  59. package/dist/controller/contentControlWidgetController.d.ts +1 -1
  60. package/dist/controller/folioEditor.d.ts +1 -1
  61. package/dist/controller/fontReadiness.d.ts +70 -3
  62. package/dist/controller/fontReadiness.js +100 -10
  63. package/dist/controller/headerFooterEditorManager.js +6 -1
  64. package/dist/controller/layoutPipeline.d.ts +12 -10
  65. package/dist/controller/layoutPipeline.js +65 -11
  66. package/dist/controller/layoutRunOptions.d.ts +24 -0
  67. package/dist/controller/layoutRunOptions.js +17 -0
  68. package/dist/controller/layoutScheduler.d.ts +19 -14
  69. package/dist/controller/layoutScheduler.js +15 -12
  70. package/dist/controller/layoutSession.d.ts +26 -2
  71. package/dist/controller/layoutSession.js +1 -1
  72. package/dist/controller/noteEditorManager.js +8 -3
  73. package/dist/document-operations.d.ts +11 -2
  74. package/dist/document-operations.js +230 -21
  75. package/dist/docx/altChunk.d.ts +8 -0
  76. package/dist/docx/altChunk.js +17 -0
  77. package/dist/docx/archiveInflation.d.ts +127 -0
  78. package/dist/docx/archiveInflation.js +181 -0
  79. package/dist/docx/attributeRemainder.d.ts +1 -1
  80. package/dist/docx/blockContentParser.d.ts +64 -1
  81. package/dist/docx/blockContentParser.js +17 -4
  82. package/dist/docx/blockCustomXmlShell.d.ts +7 -0
  83. package/dist/docx/blockCustomXmlShell.js +14 -0
  84. package/dist/docx/blockPlainText.js +7 -0
  85. package/dist/docx/commentAnchorIndex.js +1 -1
  86. package/dist/docx/commentRangeIntegrity.js +8 -3
  87. package/dist/docx/commentReferenceNormalization.js +1 -1
  88. package/dist/docx/commentReplyMarkers.js +20 -1
  89. package/dist/docx/compatibility.d.ts +1 -1
  90. package/dist/docx/compatibility.js +34 -13
  91. package/dist/docx/containerChildren.gen.d.ts +1 -1
  92. package/dist/docx/containerChildren.gen.js +1 -0
  93. package/dist/docx/documentParser.js +12 -12
  94. package/dist/docx/drawingIdNormalization.d.ts +3 -1
  95. package/dist/docx/drawingIdNormalization.js +6 -1
  96. package/dist/docx/ensureParaIds.js +119 -97
  97. package/dist/docx/footnoteParser.js +8 -4
  98. package/dist/docx/headerFooterParser.js +3 -3
  99. package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
  100. package/dist/docx/headerFooterReferenceNormalization.js +52 -27
  101. package/dist/docx/hyperlinkParser.d.ts +1 -1
  102. package/dist/docx/index.d.ts +1 -1
  103. package/dist/docx/listNumberingInstances.d.ts +59 -0
  104. package/dist/docx/listNumberingInstances.js +249 -0
  105. package/dist/docx/metadataPrivacy.js +24 -1
  106. package/dist/docx/normalizeBaseDirection.js +2 -1
  107. package/dist/docx/noteReferenceMark.d.ts +15 -0
  108. package/dist/docx/noteReferenceMark.js +48 -0
  109. package/dist/docx/opaqueCarrier.d.ts +7 -0
  110. package/dist/docx/opaqueCarrier.js +38 -0
  111. package/dist/docx/packageParts.js +4 -1
  112. package/dist/docx/paragraphParser.js +96 -27
  113. package/dist/docx/paragraphPropertySource.d.ts +4 -2
  114. package/dist/docx/paragraphPropertySource.js +10 -2
  115. package/dist/docx/paragraphTraversal.js +1 -0
  116. package/dist/docx/parseWarningMessage.js +4 -1
  117. package/dist/docx/parser.js +175 -22
  118. package/dist/docx/rezip.js +31 -7
  119. package/dist/docx/sdtProperties.js +1 -1
  120. package/dist/docx/sdtPropertiesPatch.js +3 -0
  121. package/dist/docx/selectiveSave.js +16 -9
  122. package/dist/docx/selectiveXmlPatch.d.ts +3 -1
  123. package/dist/docx/selectiveXmlPatch.js +186 -39
  124. package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
  125. package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
  126. package/dist/docx/serializer/documentSerializer.js +2 -0
  127. package/dist/docx/serializer/headerFooterSerializer.js +2 -0
  128. package/dist/docx/serializer/noteSerializer.js +3 -1
  129. package/dist/docx/serializer/paragraphSerializer.js +33 -9
  130. package/dist/docx/serializer/tableSerializer.js +25 -38
  131. package/dist/docx/server/boundedArchive.d.ts +8 -13
  132. package/dist/docx/server/boundedArchive.js +70 -59
  133. package/dist/docx/server/createBilingualDocument.js +3 -3
  134. package/dist/docx/server/extractDocxText.d.ts +8 -2
  135. package/dist/docx/server/extractDocxText.js +2 -2
  136. package/dist/docx/server/validateDocxConformance.d.ts +1 -1
  137. package/dist/docx/server/validateDocxConformance.js +1 -0
  138. package/dist/docx/tableParser.d.ts +157 -1
  139. package/dist/docx/tableParser.js +89 -10
  140. package/dist/docx/textBoxParser.js +1 -1
  141. package/dist/docx/unzip.d.ts +20 -2
  142. package/dist/docx/unzip.js +136 -25
  143. package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
  144. package/dist/docx/wordprocessingPrefixes.js +286 -0
  145. package/dist/fonts/embeddedFonts.js +1 -1
  146. package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
  147. package/dist/i18n/messages/catalogs.gen.js +187 -51
  148. package/dist/i18n/messages/messages.gen.d.ts +10 -2
  149. package/dist/internal/compare/inline-presentation.d.ts +2 -1
  150. package/dist/internal/compare/inline-presentation.js +11 -10
  151. package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
  152. package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
  153. package/dist/internal/indexedPositionMap.d.ts +11 -0
  154. package/dist/internal/indexedPositionMap.js +42 -0
  155. package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
  156. package/dist/internal/revisionResolutionEdits.d.ts +13 -0
  157. package/dist/internal/revisionResolutionEdits.js +19 -0
  158. package/dist/internal/revisionResolutionInline.d.ts +24 -0
  159. package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
  160. package/dist/internal/revisionResolutionStep.d.ts +34 -0
  161. package/dist/internal/revisionResolutionStep.js +282 -0
  162. package/dist/internal/revisionResolutionTracking.d.ts +11 -0
  163. package/dist/internal/revisionResolutionTracking.js +124 -0
  164. package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
  165. package/dist/internal/wholeStoryRevisionResolution.js +600 -0
  166. package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
  167. package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
  168. package/dist/layout-bridge/convert/tableConversion.js +1 -1
  169. package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
  170. package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
  171. package/dist/layout-engine/layoutInstrumentation.js +4 -1
  172. package/dist/layout-engine/measure/cache.d.ts +18 -1
  173. package/dist/layout-engine/measure/cache.js +31 -1
  174. package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
  175. package/dist/layout-engine/measure/measureContainer.js +7 -47
  176. package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
  177. package/dist/layout-engine/measure/measureHelpers.js +22 -2
  178. package/dist/layout-engine/measure/measureParagraph.js +2 -2
  179. package/dist/layout-engine/measure/measureWorker.js +2 -3
  180. package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
  181. package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
  182. package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
  183. package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
  184. package/dist/layout-engine/types.d.ts +6 -0
  185. package/dist/layout-painter/renderPage.js +1 -0
  186. package/dist/layout-painter/renderParagraph.js +1 -1
  187. package/dist/managers/ContextMenuManager.js +5 -2
  188. package/dist/managers/types.d.ts +3 -0
  189. package/dist/markdown/escape.d.ts +2 -2
  190. package/dist/markdown/escape.js +4 -5
  191. package/dist/markdown/fromMarkdown.js +2 -1
  192. package/dist/markdown/internals.d.ts +11 -1
  193. package/dist/markdown/internals.js +24 -3
  194. package/dist/markdown/renderBlock.js +121 -25
  195. package/dist/markdown/renderParagraph.d.ts +13 -1
  196. package/dist/markdown/renderParagraph.js +85 -38
  197. package/dist/markdown/renderRuns.d.ts +10 -1
  198. package/dist/markdown/renderRuns.js +323 -69
  199. package/dist/markdown/renderTable.js +24 -12
  200. package/dist/markdown/trailers.js +2 -2
  201. package/dist/markdown/types.d.ts +29 -7
  202. package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
  203. package/dist/paged-layout/incrementalMeasure.js +1 -9
  204. package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
  205. package/dist/paged-layout/transactionDirtyRange.js +29 -41
  206. package/dist/panel-layout.d.ts +83 -0
  207. package/dist/panel-layout.js +96 -0
  208. package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
  209. package/dist/prosemirror/anchoredTextBoxes.js +156 -0
  210. package/dist/prosemirror/attrs/index.d.ts +6 -2
  211. package/dist/prosemirror/attrs/index.js +172 -1
  212. package/dist/prosemirror/clearRunColor.d.ts +6 -0
  213. package/dist/prosemirror/clearRunColor.js +46 -0
  214. package/dist/prosemirror/commands/comments.d.ts +7 -8
  215. package/dist/prosemirror/commands/comments.js +281 -212
  216. package/dist/prosemirror/commands/contentControls.d.ts +1 -1
  217. package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
  218. package/dist/prosemirror/commands/formatPainter.js +1 -1
  219. package/dist/prosemirror/commands/formatting.d.ts +1 -1
  220. package/dist/prosemirror/commands/hyperlink.js +2 -1
  221. package/dist/prosemirror/commands/index.d.ts +2 -2
  222. package/dist/prosemirror/commands/index.js +2 -2
  223. package/dist/prosemirror/commands/paragraph.d.ts +7 -1
  224. package/dist/prosemirror/commands/paragraph.js +9 -1
  225. package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
  226. package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
  227. package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
  228. package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
  229. package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
  230. package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
  231. package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
  232. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
  233. package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
  234. package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
  235. package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
  236. package/dist/prosemirror/commands/sectionBreak.js +2 -1
  237. package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
  238. package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
  239. package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
  240. package/dist/prosemirror/containerFinalParagraph.js +7 -6
  241. package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
  242. package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
  243. package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
  244. package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
  245. package/dist/prosemirror/conversion/toProseDoc.js +70 -154
  246. package/dist/prosemirror/documentSchema.d.ts +8 -0
  247. package/dist/prosemirror/documentSchema.js +18 -0
  248. package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
  249. package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
  250. package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
  251. package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
  252. package/dist/prosemirror/extensions/StarterKit.js +5 -1
  253. package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
  254. package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
  255. package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
  256. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
  257. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
  258. package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
  259. package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
  260. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
  261. package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
  262. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
  263. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
  264. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
  265. package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
  266. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
  267. package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
  268. package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
  269. package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
  270. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
  271. package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
  272. package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
  273. package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
  274. package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
  275. package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
  276. package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
  277. package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
  278. package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
  279. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
  280. package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
  281. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
  282. package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
  283. package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
  284. package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
  285. package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
  286. package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
  287. package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
  288. package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
  289. package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
  290. package/dist/prosemirror/extensions/types.d.ts +11 -1
  291. package/dist/prosemirror/findReplaceSelection.js +1 -1
  292. package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
  293. package/dist/prosemirror/hyperlinkRemoval.js +129 -0
  294. package/dist/prosemirror/index.d.ts +5 -3
  295. package/dist/prosemirror/index.js +5 -3
  296. package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
  297. package/dist/prosemirror/indexedNodeLookup.js +103 -0
  298. package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
  299. package/dist/prosemirror/listAutoformatMarkers.js +98 -0
  300. package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
  301. package/dist/prosemirror/listInstanceReferences.js +72 -0
  302. package/dist/prosemirror/listLabels.d.ts +24 -0
  303. package/dist/prosemirror/listLabels.js +111 -0
  304. package/dist/prosemirror/listNumbering.d.ts +92 -0
  305. package/dist/prosemirror/listNumbering.js +330 -0
  306. package/dist/prosemirror/listRendering.d.ts +27 -0
  307. package/dist/prosemirror/listRendering.js +27 -0
  308. package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
  309. package/dist/prosemirror/listRenderingAttrs.js +8 -1
  310. package/dist/prosemirror/markupViewNotes.d.ts +8 -0
  311. package/dist/prosemirror/markupViewNotes.js +49 -0
  312. package/dist/prosemirror/markupViewProjection.d.ts +97 -0
  313. package/dist/prosemirror/markupViewProjection.js +88 -0
  314. package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
  315. package/dist/prosemirror/noteReferenceReview.js +332 -0
  316. package/dist/prosemirror/numberingAttr.d.ts +9 -1
  317. package/dist/prosemirror/numberingAttr.js +9 -1
  318. package/dist/prosemirror/outlineLevelAttr.js +1 -1
  319. package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
  320. package/dist/prosemirror/paragraphIndentation.js +32 -7
  321. package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
  322. package/dist/prosemirror/paragraphMarkJoin.js +26 -0
  323. package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
  324. package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
  325. package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
  326. package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
  327. package/dist/prosemirror/plugins/documentNumbering.js +97 -11
  328. package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
  329. package/dist/prosemirror/plugins/documentStyleState.js +32 -0
  330. package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
  331. package/dist/prosemirror/plugins/documentStyles.js +67 -17
  332. package/dist/prosemirror/plugins/index.d.ts +2 -1
  333. package/dist/prosemirror/plugins/index.js +2 -1
  334. package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
  335. package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
  336. package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
  337. package/dist/prosemirror/plugins/suggestionMode.js +490 -63
  338. package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
  339. package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
  340. package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
  341. package/dist/prosemirror/positionSweep.d.ts +24 -0
  342. package/dist/prosemirror/positionSweep.js +222 -0
  343. package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
  344. package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
  345. package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
  346. package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
  347. package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
  348. package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
  349. package/dist/prosemirror/replacedAnnotations.js +170 -1
  350. package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
  351. package/dist/prosemirror/runFormattingFromMarks.js +567 -0
  352. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
  353. package/dist/prosemirror/runFormattingReconciliation.js +10 -9
  354. package/dist/prosemirror/schema/index.d.ts +2 -2
  355. package/dist/prosemirror/schema/index.js +3 -0
  356. package/dist/prosemirror/schema/nodes.d.ts +44 -11
  357. package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
  358. package/dist/prosemirror/sectionMarkEdits.js +59 -0
  359. package/dist/prosemirror/storyListNumbering.d.ts +17 -0
  360. package/dist/prosemirror/storyListNumbering.js +102 -0
  361. package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
  362. package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
  363. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
  364. package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
  365. package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
  366. package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
  367. package/dist/prosemirror/tableCellPaste.d.ts +74 -0
  368. package/dist/prosemirror/tableCellPaste.js +525 -0
  369. package/dist/prosemirror/tableGridMutation.d.ts +87 -2
  370. package/dist/prosemirror/tableGridMutation.js +255 -2
  371. package/dist/prosemirror/tableRunIn.d.ts +51 -0
  372. package/dist/prosemirror/tableRunIn.js +165 -0
  373. package/dist/prosemirror/textInput.js +11 -2
  374. package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
  375. package/dist/prosemirror/trackedRevisionPath.js +32 -0
  376. package/dist/prosemirror/validation.js +5 -1
  377. package/dist/redline.js +93 -9
  378. package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
  379. package/dist/render-dom/BodySelectionOverlay.js +3 -2
  380. package/dist/server.d.ts +2 -2
  381. package/dist/utils/findReplace.js +2 -2
  382. package/dist/utils/mergeDocumentContent.js +1 -1
  383. package/dist/utils/noteReferenceLabels.d.ts +36 -0
  384. package/dist/utils/noteReferenceLabels.js +32 -0
  385. package/dist/utils/replaceText.js +1 -1
  386. package/dist/version-comparison.d.ts +1 -0
  387. package/dist/version-comparison.js +1 -0
  388. package/package.json +6 -5
  389. package/dist/internal/headlessRevisionResolution.d.ts +0 -23
@@ -0,0 +1,111 @@
1
+ import { bulletMarkerFontName, convertBulletToUnicode } from "../docx/bulletMarkers.js";
2
+ import { paragraphNumberingReference, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
3
+ import { advanceListMarker, advanceVisibleListMarker, cloneListCounterState, createListCounterState } from "./listMarker.js";
4
+ import { hasListRendering } from "./listRenderingAttrs.js";
5
+ import { paragraphNumberingAttr } from "./numberingAttr.js";
6
+ //#region src/prosemirror/listLabels.ts
7
+ /**
8
+ * The number or bullet a paragraph shows beside its text, as a reader reports
9
+ * it: counted in document order by the counter the page paints its markers
10
+ * with (`advanceVisibleListMarker`), so a reader's labels follow every edit.
11
+ * The `listMarker` attr is the marker the parser resolved when the document
12
+ * was opened; an item inserted, deleted, moved or restarted since leaves it
13
+ * stale for that item and every item after it.
14
+ *
15
+ * A reader counts inside the walk it already makes over the document (the AI
16
+ * snapshot's, Markdown's), one step per paragraph, so an edit costs nothing
17
+ * until something reads the document.
18
+ */
19
+ /**
20
+ * The cached text of a `LISTNUM` field the parser folded into the marker
21
+ * (`7.1\t(a)`). The level's template does not carry it, so it is kept as read.
22
+ */
23
+ const foldedFieldSuffix = (attrs) => {
24
+ const marker = attrs.listMarker;
25
+ const template = attrs.listMarkerTemplate;
26
+ if (!marker || !template || template.includes(" ")) return "";
27
+ const tab = marker.indexOf(" ");
28
+ return tab === -1 ? "" : marker.slice(tab);
29
+ };
30
+ const withoutNumbering = (attrs) => {
31
+ const unnumbered = { ...attrs };
32
+ Reflect.deleteProperty(unnumbered, "numPr");
33
+ return unnumbered;
34
+ };
35
+ const staticMarker = (attrs) => {
36
+ const marker = attrs.listMarker;
37
+ if (!marker) return;
38
+ return (attrs.listIsBullet ? convertBulletToUnicode(marker, bulletMarkerFontName(attrs.listMarkerFormatting)) : marker).trim() || void 0;
39
+ };
40
+ /** Most paragraphs: nothing to count and no marker to show. */
41
+ const isPlainParagraph = (attrs) => attrs.numPr == null && attrs.listMarker == null && attrs.listMarkerTemplate == null && (attrs._propertyChanges == null || attrs._propertyChanges.length === 0);
42
+ const NO_PREVIOUS_LIST = {
43
+ abstractNumId: null,
44
+ fromStyle: false,
45
+ numId: null
46
+ };
47
+ /**
48
+ * The attrs the counter reads for a paragraph of the document model, as
49
+ * `toProseDoc` projects them (`listRenderingAttrPatch`), without the layout
50
+ * attrs no label depends on: a reader that walks the model (Markdown) counts
51
+ * every list paragraph through here.
52
+ */
53
+ const listLabelAttrsFromRendering = (rendering, numPrFromStyle) => {
54
+ const attrs = { numPr: paragraphNumberingAttr(paragraphNumberingReference({
55
+ numId: rendering.numId,
56
+ ilvl: rendering.level
57
+ })) };
58
+ if (numPrFromStyle) attrs.numPrFromStyle = paragraphNumberingAttr(numPrFromStyle);
59
+ if (rendering.marker) attrs.listMarker = rendering.marker;
60
+ if (rendering.markerTemplate) attrs.listMarkerTemplate = rendering.markerTemplate;
61
+ if (rendering.isBullet) attrs.listIsBullet = true;
62
+ if (rendering.isLegal) attrs.listIsLegal = true;
63
+ if (rendering.numFmt) attrs.listNumFmt = rendering.numFmt;
64
+ if (rendering.markerHidden) attrs.listMarkerHidden = true;
65
+ if (rendering.markerFormatting) attrs.listMarkerFormatting = rendering.markerFormatting;
66
+ if (rendering.levelNumFmts) attrs.listLevelNumFmts = rendering.levelNumFmts;
67
+ if (rendering.levelStarts) attrs.listLevelStarts = rendering.levelStarts;
68
+ if (rendering.abstractNumId !== void 0) attrs.listAbstractNumId = rendering.abstractNumId;
69
+ if (rendering.startOverride !== void 0) attrs.listStartOverride = rendering.startOverride;
70
+ if (rendering.implicitChildLevelAdvances !== void 0) attrs.listImplicitChildLevelAdvances = rendering.implicitChildLevelAdvances;
71
+ return attrs;
72
+ };
73
+ /**
74
+ * A counter over paragraph attrs in document order. Call it for every
75
+ * paragraph, numbered or not: whether a list continues depends on what stands
76
+ * between its items.
77
+ */
78
+ const createListLabelCounter = () => {
79
+ const final = createListCounterState();
80
+ let streams = null;
81
+ let originalPreviousList = NO_PREVIOUS_LIST;
82
+ const advance = (counted) => {
83
+ const tracked = counted.pPrMark != null || counted._propertyChanges != null && counted._propertyChanges.length > 0;
84
+ if (streams === null && tracked) {
85
+ const original = cloneListCounterState(final);
86
+ original.previousList = { ...originalPreviousList };
87
+ streams = {
88
+ final,
89
+ original
90
+ };
91
+ }
92
+ if (streams !== null) return advanceVisibleListMarker(counted, streams).marker;
93
+ const marker = advanceListMarker(counted, final);
94
+ if (counted.numPr) originalPreviousList = final.previousList ?? NO_PREVIOUS_LIST;
95
+ return marker;
96
+ };
97
+ return (attrs) => {
98
+ if (isPlainParagraph(attrs)) {
99
+ final.previousList = NO_PREVIOUS_LIST;
100
+ return;
101
+ }
102
+ const rendered = hasListRendering(attrs);
103
+ const marker = advance(rendered ? attrs : withoutNumbering(attrs));
104
+ if (attrs.listMarkerHidden === true || !rendered) return;
105
+ const counted = paragraphNumberingReferenceId(attrs.numPr) === void 0 ? null : marker?.trim();
106
+ if (counted) return `${counted}${foldedFieldSuffix(attrs)}`;
107
+ return staticMarker(attrs);
108
+ };
109
+ };
110
+ //#endregion
111
+ export { createListLabelCounter, listLabelAttrsFromRendering };
@@ -0,0 +1,92 @@
1
+ import { ListKind, ListLevelFormat } from "../docx/listNumberingInstances.js";
2
+ import { ParagraphAttrs } from "./schema/nodes.js";
3
+ import { NumberingMap } from "../docx/numberingParser.js";
4
+ import { Node, ResolvedPos } from "prosemirror-model";
5
+ import { Command, EditorState, Transaction } from "prosemirror-state";
6
+ //#region src/prosemirror/listNumbering.d.ts
7
+ /** What a list command or typed marker asks for. */
8
+ type ListRequest = {
9
+ kind: ListKind;
10
+ /**
11
+ * The first level's format. A neighbouring list is continued only when its
12
+ * level has this format; a new list is defined with it.
13
+ */
14
+ format?: ListLevelFormat | undefined;
15
+ /** The value a new list's first item shows. */
16
+ start?: number | undefined;
17
+ };
18
+ /** Where the paragraphs a command numbers go. */
19
+ type ListTarget = {
20
+ numId: number;
21
+ /** The level a paragraph that is not yet a list item takes. */
22
+ ilvl: number;
23
+ /** Definitions the target is resolved in, including one minted for it. */
24
+ numbering: NumberingMap;
25
+ };
26
+ type ResolveListTargetOptions = {
27
+ numbering: NumberingMap | null;
28
+ $from: ResolvedPos;
29
+ $to: ResolvedPos;
30
+ /** Candidate requests, most likely first (see `listRequestsForMarker`). */
31
+ requests: readonly ListRequest[];
32
+ };
33
+ /**
34
+ * The list a paragraph range joins: the list directly above it, else the one
35
+ * directly below it, when it matches one of `requests`; otherwise a new list:
36
+ * an unused instance the package already defines for the first request, or
37
+ * one defined for it.
38
+ */
39
+ declare const resolveListTarget: ({ numbering, $from, $to, requests }: ResolveListTargetOptions) => ListTarget | null;
40
+ /** A paragraph's attrs as an item of `numId` at `ilvl`, resolved in `numbering`. */
41
+ declare const listItemAttrs: (attrs: Readonly<ParagraphAttrs>, { numId, ilvl }: {
42
+ numId: number;
43
+ ilvl: number;
44
+ }, numbering: NumberingMap) => Record<string, unknown>;
45
+ type ParagraphUpdate = {
46
+ pos: number;
47
+ node: Node;
48
+ next: Record<string, unknown>;
49
+ };
50
+ type ApplyParagraphUpdatesOptions = {
51
+ tr: Transaction;
52
+ state: EditorState;
53
+ updates: readonly ParagraphUpdate[];
54
+ };
55
+ /**
56
+ * Write `updates` into `tr`, each recorded as a tracked change while the
57
+ * editor is suggesting. `pos` is a position in `tr.doc`.
58
+ */
59
+ declare const applyParagraphUpdates: ({ tr, state, updates }: ApplyParagraphUpdatesOptions) => void;
60
+ /**
61
+ * Start the list over at `value` from the selected item: *Set Numbering
62
+ * Value* with *Start new list*. The item and every later item of
63
+ * its list move to a new instance of the same definition, whose
64
+ * `w:startOverride` at the item's level is `value`.
65
+ */
66
+ declare const setNumberingValue: (value: number) => Command;
67
+ /** *Restart at 1*: the selected item starts its list over at one. */
68
+ declare const restartNumbering: Command;
69
+ /**
70
+ * *Continue Numbering*: the selected item and the rest of its list
71
+ * join the nearest earlier list of the same kind, so their numbers carry on
72
+ * from it. Not applicable when no such list precedes the item.
73
+ */
74
+ declare const continueNumbering: Command;
75
+ /** What a context menu offers for the item the selection is in. */
76
+ type ListNumberingMenuState = {
77
+ readonly type: "none";
78
+ } | {
79
+ readonly type: "listItem";
80
+ readonly canContinue: boolean;
81
+ };
82
+ declare const NO_LIST_NUMBERING_MENU: {
83
+ readonly type: "none";
84
+ };
85
+ /**
86
+ * Whether the selection is in a list item whose numbering can be restarted
87
+ * or set, and whether an earlier list lets it continue: the enabled state of
88
+ * those menu entries.
89
+ */
90
+ declare const listNumberingMenuState: (state: EditorState) => ListNumberingMenuState;
91
+ //#endregion
92
+ export { ListNumberingMenuState, ListRequest, NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue };
@@ -0,0 +1,330 @@
1
+ import { mintListInstance, restartListInstance } from "../docx/listNumberingInstances.js";
2
+ import { createNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
3
+ import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
4
+ import { expectParagraphAttrs } from "./attrs/index.js";
5
+ import { paragraphPropertiesSnapshot } from "./commands/propertyChangeScope.js";
6
+ import { listRenderingFor, recordsListRendering } from "./listRendering.js";
7
+ import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
8
+ import { directParagraphIndentation } from "./paragraphIndentation.js";
9
+ import { getDocumentNumbering } from "./plugins/documentNumbering.js";
10
+ import { SUGGESTION_META, makeRevisionInfo } from "./plugins/suggestionMode.js";
11
+ import { listAttrsFromNumbering, listLevelIndentAttrPatch } from "./styles/resolvedStyleAttrs.js";
12
+ //#region src/prosemirror/listNumbering.ts
13
+ const PARAGRAPH_NODE = "paragraph";
14
+ /**
15
+ * The paragraph's properties as a `w:pPrChange` records them before a list
16
+ * change: every non-null in-scope attr (a reject restores the scope
17
+ * wholesale, so an unrecorded one would be wiped), plus the numbering and the
18
+ * list-rendering bookkeeping with explicit nulls (those sit outside the
19
+ * wholesale scope, so only recorded keys restore).
20
+ */
21
+ const listChangeSnapshot = (node, attrs) => {
22
+ const previousFormatting = paragraphPropertiesSnapshot(node.type.create(attrs, node.content, node.marks));
23
+ previousFormatting["numPr"] = attrs["numPr"] ?? null;
24
+ for (const key of LIST_RENDERING_ATTR_KEYS) previousFormatting[key] = attrs[key] ?? null;
25
+ return previousFormatting;
26
+ };
27
+ /**
28
+ * The original state a pending record describes, completed with the list
29
+ * attrs it may not state. A record written by a list command states them all.
30
+ * One written for another property (or read from a file) states the scope
31
+ * only: its numbering is the original's, and an absent one means the original
32
+ * had none, so the rendering is recomputed from it rather than copied from
33
+ * the live paragraph, whose list may since have changed.
34
+ */
35
+ const originalListFormatting = (record, numbering) => {
36
+ const original = { ...record };
37
+ if (recordsListRendering(record)) return original;
38
+ Object.assign(original, listRenderingFor(record.numPr, numbering));
39
+ original["numPr"] = record.numPr ?? null;
40
+ return original;
41
+ };
42
+ const canonicalJson = (value) => JSON.stringify(value, (_key, nested) => nested !== null && typeof nested === "object" && !Array.isArray(nested) ? Object.fromEntries(Object.entries(nested).filter(([, entry]) => entry !== null && entry !== void 0).toSorted(([left], [right]) => left.localeCompare(right))) : nested);
43
+ /**
44
+ * `next` with the list change recorded as a tracked paragraph-property change.
45
+ *
46
+ * A paragraph holds at most one serializable `w:pPrChange`. When it already
47
+ * has one, the record is replaced by one that keeps the original previous
48
+ * state: a second change under tracking is a further change to the same
49
+ * paragraph, and rejecting it must restore the paragraph as it was before
50
+ * either. When the change brings the paragraph back to that original, there
51
+ * is nothing left to track and the author's own record is dropped.
52
+ *
53
+ * A pending record by another author (another reviewer's, or one read from
54
+ * the file) keeps its author, id and date: the change joins that revision
55
+ * rather than re-attributing it, and it is never dropped.
56
+ */
57
+ const trackListChange = ({ current, next, rev, numbering }) => {
58
+ const currentAttrs = expectParagraphAttrs(current);
59
+ const existing = currentAttrs._propertyChanges ?? [];
60
+ const pending = existing.find(({ info }) => info.provenance !== "suggested");
61
+ const retained = existing.filter((change) => change !== pending);
62
+ const previousFormatting = pending?.previousFormatting ? originalListFormatting(pending.previousFormatting, numbering) : listChangeSnapshot(current, currentAttrs);
63
+ const ownPending = pending !== void 0 && pending.info.author === rev.author;
64
+ if (ownPending && canonicalJson(previousFormatting) === canonicalJson(listChangeSnapshot(current, next))) return {
65
+ ...next,
66
+ _propertyChanges: retained.length > 0 ? retained : null
67
+ };
68
+ const record = pending && !ownPending ? {
69
+ ...pending,
70
+ previousFormatting
71
+ } : {
72
+ type: "paragraphPropertyChange",
73
+ info: {
74
+ id: rev.id,
75
+ author: rev.author,
76
+ date: rev.date
77
+ },
78
+ previousFormatting
79
+ };
80
+ return {
81
+ ...next,
82
+ _propertyChanges: [...retained, record]
83
+ };
84
+ };
85
+ const levelKind = (level) => isBulletLevel(level) ? "bullet" : "numbered";
86
+ /** A level's text with its placeholders blanked: `%1.` and `%3.` read alike. */
87
+ const levelTextShape = (lvlText) => lvlText.replaceAll(/%\d/gu, "%");
88
+ const levelMatches = (level, request) => {
89
+ if (levelKind(level) !== request.kind) return false;
90
+ const { format } = request;
91
+ return format === void 0 || level.numFmt === format.numFmt && levelTextShape(level.lvlText) === levelTextShape(format.lvlText);
92
+ };
93
+ /**
94
+ * The list `node` is an item of, when the paragraph states it directly. A
95
+ * numbering its style supplies is the style's, and is not offered to the
96
+ * paragraphs around it.
97
+ */
98
+ const directListMembership = (node, numbering) => {
99
+ if (!node || node.type.name !== PARAGRAPH_NODE) return null;
100
+ const attrs = expectParagraphAttrs(node);
101
+ const numId = paragraphNumberingReferenceId(attrs.numPr);
102
+ if (numId === void 0 || numId === paragraphNumberingReferenceId(attrs.numPrFromStyle)) return null;
103
+ const ilvl = paragraphNumberingLevel(attrs.numPr) ?? 0;
104
+ const level = numbering?.getLevel(numId, ilvl) ?? null;
105
+ return level ? {
106
+ numId,
107
+ ilvl,
108
+ level
109
+ } : null;
110
+ };
111
+ /** The block directly before or after the paragraph `$pos` sits in. */
112
+ const siblingOf = ($pos, direction) => {
113
+ const depth = $pos.depth;
114
+ if (depth === 0) return null;
115
+ const index = $pos.index(depth - 1);
116
+ return $pos.node(depth - 1).maybeChild(direction === "before" ? index - 1 : index + 1);
117
+ };
118
+ /** Every instance a paragraph of `doc` names: directly, through its style, or as a tracked change's previous state. */
119
+ const referencedNumIds = (doc) => {
120
+ const referenced = /* @__PURE__ */ new Set();
121
+ const add = (numPr) => {
122
+ const numId = paragraphNumberingReferenceId(numPr ?? void 0);
123
+ if (numId !== void 0) referenced.add(numId);
124
+ };
125
+ doc.descendants((node) => {
126
+ if (node.type.name !== PARAGRAPH_NODE) return true;
127
+ const attrs = expectParagraphAttrs(node);
128
+ add(attrs.numPr);
129
+ add(attrs.numPrFromStyle);
130
+ for (const change of attrs._propertyChanges ?? []) add(change.previousFormatting?.numPr);
131
+ return false;
132
+ });
133
+ return referenced;
134
+ };
135
+ /**
136
+ * An instance the package defines for `request` that nothing uses yet: a host
137
+ * that prepares a document with an empty list of each kind means the first
138
+ * list of that kind to be it. An instance tied to a paragraph style (a level
139
+ * naming a `w:pStyle`, or a style link) belongs to that style and is never
140
+ * offered.
141
+ */
142
+ const unusedInstanceFor = (numbering, doc, request) => {
143
+ const referenced = referencedNumIds(doc);
144
+ return numbering.definitions.nums.find(({ numId, abstractNumId }) => {
145
+ const abstract = numbering.getAbstract(abstractNumId);
146
+ const level = numbering.getLevel(numId, 0);
147
+ return !referenced.has(numId) && abstract !== null && abstract.styleLink === void 0 && abstract.numStyleLink === void 0 && abstract.levels.every(({ pStyle }) => pStyle === void 0) && level !== null && levelMatches(level, request) && (level.start ?? 1) === (request.start ?? level.start ?? 1);
148
+ })?.numId;
149
+ };
150
+ /**
151
+ * The list a paragraph range joins: the list directly above it, else the one
152
+ * directly below it, when it matches one of `requests`; otherwise a new list:
153
+ * an unused instance the package already defines for the first request, or
154
+ * one defined for it.
155
+ */
156
+ const resolveListTarget = ({ numbering, $from, $to, requests }) => {
157
+ const [first] = requests;
158
+ if (!first) return null;
159
+ for (const neighbour of [siblingOf($from, "before"), siblingOf($to, "after")]) {
160
+ const membership = directListMembership(neighbour, numbering);
161
+ if (numbering && membership && requests.some((request) => levelMatches(membership.level, request))) return {
162
+ numId: membership.numId,
163
+ ilvl: membership.ilvl,
164
+ numbering
165
+ };
166
+ }
167
+ const unused = numbering ? unusedInstanceFor(numbering, $from.doc, first) : void 0;
168
+ if (numbering && unused !== void 0) return {
169
+ numId: unused,
170
+ ilvl: 0,
171
+ numbering
172
+ };
173
+ const minted = mintListInstance(numbering?.definitions, first);
174
+ return {
175
+ numId: minted.numId,
176
+ ilvl: 0,
177
+ numbering: createNumberingMap(minted.definitions)
178
+ };
179
+ };
180
+ /** A paragraph's attrs as an item of `numId` at `ilvl`, resolved in `numbering`. */
181
+ const listItemAttrs = (attrs, { numId, ilvl }, numbering) => ({
182
+ ...attrs,
183
+ ...listAttrsFromNumbering({
184
+ numId,
185
+ ilvl
186
+ }, numbering),
187
+ ...listLevelIndentAttrPatch(directParagraphIndentation(attrs), {
188
+ numId,
189
+ ilvl
190
+ }, numbering),
191
+ listImplicitChildLevelAdvances: attrs["listImplicitChildLevelAdvances"] ?? null,
192
+ listMarkerSecondSlotOffsetTwips: attrs["listMarkerSecondSlotOffsetTwips"] ?? null
193
+ });
194
+ /**
195
+ * Write `updates` into `tr`, each recorded as a tracked change while the
196
+ * editor is suggesting. `pos` is a position in `tr.doc`.
197
+ */
198
+ const applyParagraphUpdates = ({ tr, state, updates }) => {
199
+ const rev = makeRevisionInfo(state);
200
+ const numbering = getDocumentNumbering(state);
201
+ for (const { pos, node, next } of updates) {
202
+ const attrs = rev ? trackListChange({
203
+ current: node,
204
+ next,
205
+ rev,
206
+ numbering
207
+ }) : next;
208
+ tr.setNodeMarkup(pos, void 0, attrs);
209
+ }
210
+ if (rev) tr.setMeta(SUGGESTION_META, true);
211
+ };
212
+ /** The paragraph the selection starts in, when it is a direct list item. */
213
+ const selectedListParagraph = (state) => {
214
+ const { $from } = state.selection;
215
+ if ($from.parent.type.name !== PARAGRAPH_NODE || $from.depth === 0) return null;
216
+ const membership = directListMembership($from.parent, getDocumentNumbering(state));
217
+ return membership ? {
218
+ pos: $from.before(),
219
+ node: $from.parent,
220
+ membership
221
+ } : null;
222
+ };
223
+ /** Every direct item of `numId` from `fromPos` to the end of the document. */
224
+ const itemsFrom = (state, numId, fromPos) => {
225
+ const numbering = getDocumentNumbering(state);
226
+ const items = [];
227
+ state.doc.descendants((node, pos) => {
228
+ if (node.type.name !== PARAGRAPH_NODE) return true;
229
+ if (pos >= fromPos) {
230
+ const membership = directListMembership(node, numbering);
231
+ if (membership?.numId === numId) items.push({
232
+ pos,
233
+ node,
234
+ membership
235
+ });
236
+ }
237
+ return false;
238
+ });
239
+ return items;
240
+ };
241
+ const moveItems = ({ state, items, numId, numbering }) => {
242
+ const tr = state.tr;
243
+ applyParagraphUpdates({
244
+ tr,
245
+ state,
246
+ updates: items.map(({ pos, node, membership }) => ({
247
+ pos,
248
+ node,
249
+ next: listItemAttrs(expectParagraphAttrs(node), {
250
+ numId,
251
+ ilvl: membership.ilvl
252
+ }, numbering)
253
+ }))
254
+ });
255
+ return tr.scrollIntoView();
256
+ };
257
+ /**
258
+ * Start the list over at `value` from the selected item: *Set Numbering
259
+ * Value* with *Start new list*. The item and every later item of
260
+ * its list move to a new instance of the same definition, whose
261
+ * `w:startOverride` at the item's level is `value`.
262
+ */
263
+ const setNumberingValue = (value) => (state, dispatch) => {
264
+ if (!Number.isSafeInteger(value) || value < 0) return false;
265
+ const selected = selectedListParagraph(state);
266
+ const numbering = getDocumentNumbering(state);
267
+ const abstractNumId = selected ? numbering?.getAbstractNumId(selected.membership.numId) : null;
268
+ if (!selected || !numbering || abstractNumId === null || abstractNumId === void 0) return false;
269
+ if (!dispatch) return true;
270
+ const restarted = restartListInstance(numbering.definitions, {
271
+ abstractNumId,
272
+ ilvl: selected.membership.ilvl,
273
+ start: value
274
+ });
275
+ dispatch(moveItems({
276
+ state,
277
+ items: itemsFrom(state, selected.membership.numId, selected.pos),
278
+ numId: restarted.numId,
279
+ numbering: createNumberingMap(restarted.definitions)
280
+ }));
281
+ return true;
282
+ };
283
+ /** *Restart at 1*: the selected item starts its list over at one. */
284
+ const restartNumbering = (state, dispatch) => setNumberingValue(1)(state, dispatch);
285
+ /** The nearest list before `beforePos` of the kind `membership` has, other than its own. */
286
+ const previousListOfKind = (state, beforePos, membership) => {
287
+ const numbering = getDocumentNumbering(state);
288
+ const kind = levelKind(membership.level);
289
+ let found = null;
290
+ state.doc.descendants((node, pos) => {
291
+ if (pos >= beforePos) return false;
292
+ if (node.type.name !== PARAGRAPH_NODE) return true;
293
+ const candidate = directListMembership(node, numbering);
294
+ if (candidate && candidate.numId !== membership.numId && levelKind(candidate.level) === kind) found = candidate.numId;
295
+ return false;
296
+ });
297
+ return found;
298
+ };
299
+ /**
300
+ * *Continue Numbering*: the selected item and the rest of its list
301
+ * join the nearest earlier list of the same kind, so their numbers carry on
302
+ * from it. Not applicable when no such list precedes the item.
303
+ */
304
+ const continueNumbering = (state, dispatch) => {
305
+ const selected = selectedListParagraph(state);
306
+ const numbering = getDocumentNumbering(state);
307
+ if (!selected || !numbering) return false;
308
+ const previous = previousListOfKind(state, selected.pos, selected.membership);
309
+ if (previous === null) return false;
310
+ if (!dispatch) return true;
311
+ dispatch(moveItems({
312
+ state,
313
+ items: itemsFrom(state, selected.membership.numId, selected.pos),
314
+ numId: previous,
315
+ numbering
316
+ }));
317
+ return true;
318
+ };
319
+ const NO_LIST_NUMBERING_MENU = { type: "none" };
320
+ /**
321
+ * Whether the selection is in a list item whose numbering can be restarted
322
+ * or set, and whether an earlier list lets it continue: the enabled state of
323
+ * those menu entries.
324
+ */
325
+ const listNumberingMenuState = (state) => restartNumbering(state) ? {
326
+ type: "listItem",
327
+ canContinue: continueNumbering(state)
328
+ } : NO_LIST_NUMBERING_MENU;
329
+ //#endregion
330
+ export { NO_LIST_NUMBERING_MENU, applyParagraphUpdates, continueNumbering, listItemAttrs, listNumberingMenuState, resolveListTarget, restartNumbering, setNumberingValue };
@@ -0,0 +1,27 @@
1
+ import { ParagraphAttrs, ParagraphPropertyChangeAttrs } from "./schema/nodes.js";
2
+ import { NumberingMap } from "../docx/numberingParser.js";
3
+ //#region src/prosemirror/listRendering.d.ts
4
+ type PreviousFormatting = NonNullable<ParagraphPropertyChangeAttrs["previousFormatting"]>;
5
+ /** Whether a `w:pPrChange` record states the list rendering it had (a list command's does). */
6
+ declare const recordsListRendering: (record: PreviousFormatting) => boolean;
7
+ /** Every list-rendering attr for `numPr`: its level's, or all cleared when it numbers nothing. */
8
+ declare const listRenderingFor: (numPr: PreviousFormatting["numPr"], numbering: NumberingMap | null) => Record<string, unknown>;
9
+ /**
10
+ * The list rendering a paragraph takes when a `w:pPrChange` is rejected. A
11
+ * reject restores the recorded numbering, but the rendering attrs sit outside
12
+ * the scope it restores wholesale, so a record that does not state them (one
13
+ * written by an operation, or read from a file) would leave the rendering of
14
+ * the numbering it undoes: a paragraph restored to no numbering still showed
15
+ * the marker it was given. When the reject changes the numbering, the
16
+ * rendering is recomputed from the restored numbering; otherwise it stays.
17
+ */
18
+ type RejectedListRenderingOptions = {
19
+ /** The paragraph's attrs before the reject. */
20
+ current: Pick<ParagraphAttrs, "numPr">;
21
+ /** The previous state the rejected record restores. */
22
+ previousFormatting: PreviousFormatting | null | undefined;
23
+ numbering: NumberingMap | null;
24
+ };
25
+ declare const rejectedListRenderingPatch: ({ current, previousFormatting, numbering }: RejectedListRenderingOptions) => Record<string, unknown>;
26
+ //#endregion
27
+ export { RejectedListRenderingOptions, listRenderingFor, recordsListRendering, rejectedListRenderingPatch };
@@ -0,0 +1,27 @@
1
+ import { paragraphNumberingLevel, paragraphNumberingReferenceId, sameStatedParagraphNumbering } from "../docx/numberingReference.js";
2
+ import { CLEARED_LIST_RENDERING_ATTRS } from "./listMarker.js";
3
+ import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
4
+ import { listAttrsFromNumbering } from "./styles/resolvedStyleAttrs.js";
5
+ //#region src/prosemirror/listRendering.ts
6
+ /** Whether a `w:pPrChange` record states the list rendering it had (a list command's does). */
7
+ const recordsListRendering = (record) => LIST_RENDERING_ATTR_KEYS.some((key) => Object.hasOwn(record, key));
8
+ /** Every list-rendering attr for `numPr`: its level's, or all cleared when it numbers nothing. */
9
+ const listRenderingFor = (numPr, numbering) => {
10
+ const numId = paragraphNumberingReferenceId(numPr ?? void 0);
11
+ const rendering = numId === void 0 ? CLEARED_LIST_RENDERING_ATTRS : listAttrsFromNumbering({
12
+ numId,
13
+ ilvl: paragraphNumberingLevel(numPr ?? void 0) ?? 0
14
+ }, numbering);
15
+ const attrs = {};
16
+ for (const key of LIST_RENDERING_ATTR_KEYS) attrs[key] = rendering[key] ?? null;
17
+ return attrs;
18
+ };
19
+ const rejectedListRenderingPatch = ({ current, previousFormatting, numbering }) => {
20
+ const record = previousFormatting ?? {};
21
+ if (recordsListRendering(record)) return {};
22
+ const restored = record.numPr ?? void 0;
23
+ if (sameStatedParagraphNumbering(restored, current.numPr ?? void 0)) return {};
24
+ return listRenderingFor(restored, numbering);
25
+ };
26
+ //#endregion
27
+ export { listRenderingFor, recordsListRendering, rejectedListRenderingPatch };
@@ -30,8 +30,17 @@ declare const LIST_RENDERING_ATTR_KEYS: readonly ListRenderingAttrKey[];
30
30
  * never authors them as `false` or `""` deliberately.
31
31
  */
32
32
  declare const listRenderingAttrPatch: (rendering: document_d_exports.ListRendering) => Partial<ParagraphAttrs>;
33
+ /**
34
+ * Whether `attrs` carry what their numbering level renders as. Only a level
35
+ * the numbering defines gets a rendering (`toProseDoc` projects the parser's,
36
+ * a list command or operation writes the level's), so a reference without one
37
+ * names a level nothing defines: Word paints no marker for it.
38
+ */
39
+ declare const hasListRendering: (attrs: Pick<ParagraphAttrs, "listMarker" | "listIsBullet" | "listNumFmt">) => boolean;
40
+ /** The attrs a rendering is read back from: a paragraph's, or a recorded previous state's. */
41
+ type ListRenderingSourceAttrs = Pick<ParagraphAttrs, ListRenderingAttrKey | "numPr">;
33
42
  type ListRenderingFromAttrsOptions = {
34
- attrs: ParagraphAttrs;
43
+ attrs: ListRenderingSourceAttrs;
35
44
  numId: number;
36
45
  };
37
46
  /**
@@ -40,4 +49,4 @@ type ListRenderingFromAttrsOptions = {
40
49
  */
41
50
  declare const listRenderingFromAttrs: ({ attrs, numId }: ListRenderingFromAttrsOptions) => document_d_exports.ListRendering;
42
51
  //#endregion
43
- export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, ListRenderingAttrField, ListRenderingAttrKey, listRenderingAttrPatch, listRenderingFromAttrs };
52
+ export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, ListRenderingAttrField, ListRenderingAttrKey, ListRenderingSourceAttrs, hasListRendering, listRenderingAttrPatch, listRenderingFromAttrs };
@@ -60,6 +60,13 @@ const listRenderingAttrPatch = (rendering) => {
60
60
  return definedAttrs(patch);
61
61
  };
62
62
  /**
63
+ * Whether `attrs` carry what their numbering level renders as. Only a level
64
+ * the numbering defines gets a rendering (`toProseDoc` projects the parser's,
65
+ * a list command or operation writes the level's), so a reference without one
66
+ * names a level nothing defines: Word paints no marker for it.
67
+ */
68
+ const hasListRendering = (attrs) => attrs.listMarker != null || attrs.listIsBullet === true || attrs.listNumFmt != null;
69
+ /**
63
70
  * Inverse of `listRenderingAttrPatch`. The caller decides whether the
64
71
  * paragraph is a list item at all; this only reassembles the fields.
65
72
  */
@@ -90,4 +97,4 @@ const listRenderingFromAttrs = ({ attrs, numId }) => {
90
97
  };
91
98
  };
92
99
  //#endregion
93
- export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, listRenderingAttrPatch, listRenderingFromAttrs };
100
+ export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, hasListRendering, listRenderingAttrPatch, listRenderingFromAttrs };
@@ -0,0 +1,8 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { DisplayMode } from "../managers/EditorModeManager.js";
3
+ import { EditorState } from "prosemirror-state";
4
+ //#region src/prosemirror/markupViewNotes.d.ts
5
+ /** The footnotes or endnotes as `view` shows them. */
6
+ declare const markupViewNotes: <TNote extends document_d_exports.Footnote | document_d_exports.Endnote>(notes: TNote[] | undefined, view: DisplayMode, state: EditorState, document: document_d_exports.Document | null) => TNote[] | undefined;
7
+ //#endregion
8
+ export { markupViewNotes };