@stll/folio-core 0.54.2 → 0.56.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 (267) hide show
  1. package/dist/ai-edits/apply.js +185 -33
  2. package/dist/ai-edits/headless.js +3 -2
  3. package/dist/ai-edits/types.d.ts +7 -1
  4. package/dist/compare/compare.js +1 -0
  5. package/dist/compare/content-types.d.ts +3 -15
  6. package/dist/compare/reproducible-package.d.ts +0 -17
  7. package/dist/compare/reproducible-package.js +12 -18
  8. package/dist/controller/canonicalClipboard.d.ts +23 -0
  9. package/dist/controller/canonicalClipboard.js +476 -0
  10. package/dist/controller/canonicalClipboardResources.d.ts +21 -0
  11. package/dist/controller/canonicalClipboardResources.js +382 -0
  12. package/dist/controller/canonicalComposition.d.ts +53 -0
  13. package/dist/controller/canonicalComposition.js +296 -0
  14. package/dist/controller/canonicalInlineProjection.d.ts +113 -0
  15. package/dist/controller/canonicalInlineProjection.js +393 -0
  16. package/dist/controller/canonicalInput.d.ts +54 -0
  17. package/dist/controller/canonicalInput.js +377 -0
  18. package/dist/controller/canonicalInputTimer.d.ts +7 -0
  19. package/dist/controller/canonicalInputTimer.js +11 -0
  20. package/dist/controller/canonicalOperations.d.ts +22 -0
  21. package/dist/controller/canonicalOperations.js +85 -0
  22. package/dist/controller/canonicalPublicOperations.d.ts +48 -0
  23. package/dist/controller/canonicalPublicOperations.js +556 -0
  24. package/dist/controller/canonicalReview.d.ts +12 -0
  25. package/dist/controller/canonicalReview.js +19 -0
  26. package/dist/controller/canonicalSession.d.ts +167 -0
  27. package/dist/controller/canonicalSession.js +1186 -0
  28. package/dist/controller/canonicalStoryEditor.d.ts +36 -0
  29. package/dist/controller/canonicalStoryEditor.js +87 -0
  30. package/dist/controller/canonicalStructure.d.ts +16 -0
  31. package/dist/controller/canonicalStructure.js +322 -0
  32. package/dist/controller/canonicalTocSelection.d.ts +11 -0
  33. package/dist/controller/canonicalTocSelection.js +43 -0
  34. package/dist/controller/folioEditor.d.ts +3 -10
  35. package/dist/controller/folioEditor.js +14 -4
  36. package/dist/controller/headerFooterEditorManager.d.ts +5 -0
  37. package/dist/controller/headerFooterEditorManager.js +72 -3
  38. package/dist/controller/hiddenEditorApi.d.ts +45 -0
  39. package/dist/controller/hiddenEditorApi.js +29 -8
  40. package/dist/controller/hiddenEditorManager.d.ts +13 -2
  41. package/dist/controller/hiddenEditorManager.js +639 -31
  42. package/dist/controller/layoutPipeline.d.ts +1 -1
  43. package/dist/controller/layoutPipeline.js +2 -0
  44. package/dist/controller/noteEditorManager.d.ts +5 -0
  45. package/dist/controller/noteEditorManager.js +114 -15
  46. package/dist/document-operations.d.ts +8 -1
  47. package/dist/document-operations.js +6 -4
  48. package/dist/docx/attributeRemainder.js +1 -0
  49. package/dist/docx/blockPlainText.d.ts +1 -1
  50. package/dist/docx/blockPlainText.js +11 -3
  51. package/dist/docx/canonicalResourceSave.d.ts +16 -0
  52. package/dist/docx/canonicalResourceSave.js +27 -0
  53. package/dist/docx/canonicalSave.d.ts +29 -0
  54. package/dist/docx/canonicalSave.js +101 -0
  55. package/dist/docx/canonicalSessionInput.d.ts +11 -0
  56. package/dist/docx/canonicalSessionInput.js +27 -0
  57. package/dist/docx/canonicalStoryRepack.d.ts +10 -0
  58. package/dist/docx/canonicalStoryRepack.js +74 -0
  59. package/dist/docx/contentTypeRegistry.d.ts +8 -0
  60. package/dist/docx/contentTypeRegistry.js +64 -0
  61. package/dist/docx/documentParser.d.ts +1 -13
  62. package/dist/docx/documentParser.js +1 -47
  63. package/dist/docx/ensureParaIds.d.ts +7 -1
  64. package/dist/docx/ensureParaIds.js +173 -215
  65. package/dist/docx/foldedListNumberFields.d.ts +85 -0
  66. package/dist/docx/foldedListNumberFields.js +267 -0
  67. package/dist/docx/footnoteParser.d.ts +1 -11
  68. package/dist/docx/footnoteParser.js +1 -16
  69. package/dist/docx/headerFooterParser.d.ts +1 -9
  70. package/dist/docx/headerFooterParser.js +1 -12
  71. package/dist/docx/headerFooterVerbatim.d.ts +39 -1
  72. package/dist/docx/headerFooterVerbatim.js +173 -2
  73. package/dist/docx/imageParser.d.ts +13 -1
  74. package/dist/docx/imageParser.js +20 -11
  75. package/dist/docx/metadataPrivacy.js +6 -1
  76. package/dist/docx/noteIds.d.ts +5 -0
  77. package/dist/docx/noteIds.js +6 -2
  78. package/dist/docx/noteReferenceMark.d.ts +3 -1
  79. package/dist/docx/noteReferenceMark.js +15 -14
  80. package/dist/docx/numberingParser.d.ts +3 -1
  81. package/dist/docx/numberingParser.js +17 -3
  82. package/dist/docx/packageParts.d.ts +3 -1
  83. package/dist/docx/packageParts.js +74 -19
  84. package/dist/docx/paragraphMarkPropertyPresence.d.ts +9 -0
  85. package/dist/docx/paragraphMarkPropertyPresence.js +21 -0
  86. package/dist/docx/paragraphParser.js +101 -53
  87. package/dist/docx/paragraphPropertySource.d.ts +15 -1
  88. package/dist/docx/paragraphPropertySource.js +77 -22
  89. package/dist/docx/parser.js +3 -1
  90. package/dist/docx/removeHeaderFooterParts.js +17 -6
  91. package/dist/docx/reviewHistoryNamespace.d.ts +4 -0
  92. package/dist/docx/reviewHistoryNamespace.js +4 -0
  93. package/dist/docx/reviewResolutionProvenance.d.ts +25 -0
  94. package/dist/docx/reviewResolutionProvenance.js +153 -0
  95. package/dist/docx/rezip.d.ts +54 -6
  96. package/dist/docx/rezip.js +835 -257
  97. package/dist/docx/runConsolidator.d.ts +2 -58
  98. package/dist/docx/runConsolidator.js +3 -175
  99. package/dist/docx/runParser.d.ts +2 -1
  100. package/dist/docx/runParser.js +156 -116
  101. package/dist/docx/saveDiagnostics.d.ts +22 -0
  102. package/dist/docx/saveDiagnostics.js +0 -0
  103. package/dist/docx/selectiveSave.d.ts +3 -1
  104. package/dist/docx/selectiveSave.js +36 -4
  105. package/dist/docx/selectiveXmlPatch.d.ts +16 -8
  106. package/dist/docx/selectiveXmlPatch.js +81 -7
  107. package/dist/docx/serializer/documentSerializer.d.ts +9 -2
  108. package/dist/docx/serializer/documentSerializer.js +29 -10
  109. package/dist/docx/serializer/headerFooterSerializer.d.ts +5 -1
  110. package/dist/docx/serializer/headerFooterSerializer.js +19 -11
  111. package/dist/docx/serializer/noteSerializer.d.ts +2 -2
  112. package/dist/docx/serializer/noteSerializer.js +24 -8
  113. package/dist/docx/serializer/paragraphSerializer.js +41 -4
  114. package/dist/docx/serializer/partNamespaces.js +2 -1
  115. package/dist/docx/serializer/runSerializer.js +3 -1
  116. package/dist/docx/server/applyDocxXmlPatchProposal.js +14 -9
  117. package/dist/docx/settingsHeaderFooterUpdate.d.ts +5 -0
  118. package/dist/docx/settingsHeaderFooterUpdate.js +90 -0
  119. package/dist/docx/settingsParser.d.ts +1 -2
  120. package/dist/docx/settingsParser.js +5 -6
  121. package/dist/docx/storyBlockReplay.d.ts +31 -0
  122. package/dist/docx/storyBlockReplay.js +471 -0
  123. package/dist/docx/storyPlainText.d.ts +20 -0
  124. package/dist/docx/storyPlainText.js +23 -0
  125. package/dist/docx/streamingXmlParser.d.ts +22 -1
  126. package/dist/docx/streamingXmlParser.js +49 -3
  127. package/dist/docx/structuralXmlPatch.js +18 -23
  128. package/dist/docx/styleParser.d.ts +5 -1
  129. package/dist/docx/styleParser.js +1 -1
  130. package/dist/docx/tableParser.d.ts +1 -8
  131. package/dist/docx/tableParser.js +1 -28
  132. package/dist/docx/textBoxParser.d.ts +1 -5
  133. package/dist/docx/textBoxParser.js +1 -20
  134. package/dist/docx/unzip.js +6 -1
  135. package/dist/docx/verbatimCapture.d.ts +3 -1
  136. package/dist/docx/verbatimCapture.js +49 -6
  137. package/dist/i18n/messages/ar.gen.d.ts +5 -0
  138. package/dist/i18n/messages/ar.gen.js +656 -0
  139. package/dist/i18n/messages/cs.gen.d.ts +5 -0
  140. package/dist/i18n/messages/cs.gen.js +656 -0
  141. package/dist/i18n/messages/de.gen.d.ts +5 -0
  142. package/dist/i18n/messages/de.gen.js +656 -0
  143. package/dist/i18n/messages/en.gen.d.ts +5 -0
  144. package/dist/i18n/messages/en.gen.js +656 -0
  145. package/dist/i18n/messages/es.gen.d.ts +5 -0
  146. package/dist/i18n/messages/es.gen.js +656 -0
  147. package/dist/i18n/messages/et.gen.d.ts +5 -0
  148. package/dist/i18n/messages/et.gen.js +656 -0
  149. package/dist/i18n/messages/fr.gen.d.ts +5 -0
  150. package/dist/i18n/messages/fr.gen.js +656 -0
  151. package/dist/i18n/messages/he.gen.d.ts +5 -0
  152. package/dist/i18n/messages/he.gen.js +656 -0
  153. package/dist/i18n/messages/hi.gen.d.ts +5 -0
  154. package/dist/i18n/messages/hi.gen.js +656 -0
  155. package/dist/i18n/messages/hu.gen.d.ts +5 -0
  156. package/dist/i18n/messages/hu.gen.js +656 -0
  157. package/dist/i18n/messages/locales.d.ts +5 -0
  158. package/dist/i18n/messages/locales.js +22 -0
  159. package/dist/i18n/messages/lt.gen.d.ts +5 -0
  160. package/dist/i18n/messages/lt.gen.js +656 -0
  161. package/dist/i18n/messages/lv.gen.d.ts +5 -0
  162. package/dist/i18n/messages/lv.gen.js +656 -0
  163. package/dist/i18n/messages/pl.gen.d.ts +5 -0
  164. package/dist/i18n/messages/pl.gen.js +656 -0
  165. package/dist/i18n/messages/pt-BR.gen.d.ts +5 -0
  166. package/dist/i18n/messages/pt-BR.gen.js +656 -0
  167. package/dist/i18n/messages/sk.gen.d.ts +5 -0
  168. package/dist/i18n/messages/sk.gen.js +656 -0
  169. package/dist/i18n/messages/tr.gen.d.ts +5 -0
  170. package/dist/i18n/messages/tr.gen.js +656 -0
  171. package/dist/i18n/messages/zh-CN.gen.d.ts +5 -0
  172. package/dist/i18n/messages/zh-CN.gen.js +656 -0
  173. package/dist/i18n/messages.d.ts +2 -3
  174. package/dist/i18n/messages.js +1 -19
  175. package/dist/internal/acceptedBlockProjection.d.ts +12 -0
  176. package/dist/internal/acceptedBlockProjection.js +45 -0
  177. package/dist/internal/noteMarkerAttrs.d.ts +8 -0
  178. package/dist/internal/noteMarkerAttrs.js +16 -0
  179. package/dist/internal/pageBreakRunSourceDescendantIndex.js +1 -0
  180. package/dist/internal/prosemirrorAttrBoundary.d.ts +21 -0
  181. package/dist/internal/prosemirrorAttrBoundary.js +50 -0
  182. package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
  183. package/dist/layout-bridge/convert/footnoteLayout.js +3 -3
  184. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
  185. package/dist/layout-bridge/convert/headerFooterLayout.js +1 -0
  186. package/dist/layout-bridge/convert/noteReferences.d.ts +1 -3
  187. package/dist/layout-bridge/convert/noteReferences.js +1 -6
  188. package/dist/layout-bridge/convert/paragraphRuns.js +2 -4
  189. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -2
  190. package/dist/layout-bridge/convert/toFlowBlocks.js +2 -2
  191. package/dist/managers/DocumentLoaderManager.d.ts +1 -0
  192. package/dist/managers/DocumentLoaderManager.js +9 -1
  193. package/dist/markdown/escape.d.ts +3 -1
  194. package/dist/markdown/escape.js +9 -2
  195. package/dist/markdown/renderBlock.js +20 -121
  196. package/dist/markdown/renderParagraph.js +13 -15
  197. package/dist/markdown/renderRuns.d.ts +7 -1
  198. package/dist/markdown/renderRuns.js +35 -15
  199. package/dist/markdown/renderTable.js +2 -0
  200. package/dist/markdown/types.d.ts +3 -9
  201. package/dist/prosemirror/attrs/index.d.ts +2 -12
  202. package/dist/prosemirror/attrs/index.js +22 -48
  203. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -1
  204. package/dist/prosemirror/canonicalCommands.d.ts +121 -0
  205. package/dist/prosemirror/canonicalCommands.js +35 -0
  206. package/dist/prosemirror/canonicalSelectionRange.d.ts +9 -0
  207. package/dist/prosemirror/canonicalSelectionRange.js +15 -0
  208. package/dist/prosemirror/clipboardIntent.d.ts +7 -0
  209. package/dist/prosemirror/clipboardIntent.js +9 -0
  210. package/dist/prosemirror/commands/pageBreak.js +15 -1
  211. package/dist/prosemirror/commands/pastePlainText.js +2 -1
  212. package/dist/prosemirror/commentReferenceAttrs.d.ts +2 -1
  213. package/dist/prosemirror/conversion/fromProseDoc.js +91 -19
  214. package/dist/prosemirror/conversion/hyphenTextCarriers.d.ts +8 -0
  215. package/dist/prosemirror/conversion/hyphenTextCarriers.js +8 -0
  216. package/dist/prosemirror/conversion/listRenderingDefinition.d.ts +6 -0
  217. package/dist/prosemirror/conversion/listRenderingDefinition.js +97 -0
  218. package/dist/prosemirror/conversion/toProseDoc.d.ts +11 -4
  219. package/dist/prosemirror/conversion/toProseDoc.js +55 -14
  220. package/dist/prosemirror/executeEditorCommand.d.ts +11 -0
  221. package/dist/prosemirror/executeEditorCommand.js +26 -0
  222. package/dist/prosemirror/extensions/StarterKit.js +2 -0
  223. package/dist/prosemirror/extensions/core/ParagraphExtension.js +88 -48
  224. package/dist/prosemirror/extensions/features/ListExtension.js +18 -5
  225. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +5 -2
  226. package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +13 -1
  227. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +56 -28
  228. package/dist/prosemirror/extensions/marks/TextColorExtension.js +3 -2
  229. package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
  230. package/dist/prosemirror/extensions/marks/markUtils.js +72 -8
  231. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.d.ts +6 -0
  232. package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +36 -0
  233. package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +4 -2
  234. package/dist/prosemirror/insertOperations.js +2 -1
  235. package/dist/prosemirror/listMarker.d.ts +1 -0
  236. package/dist/prosemirror/listMarker.js +16 -7
  237. package/dist/prosemirror/listNumbering.js +26 -5
  238. package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
  239. package/dist/prosemirror/listRenderingAttrs.js +3 -0
  240. package/dist/prosemirror/markupViewNotes.js +3 -2
  241. package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +2 -1
  242. package/dist/prosemirror/noteReferenceReview.js +5 -3
  243. package/dist/prosemirror/paragraphPropertyCarry.d.ts +7 -1
  244. package/dist/prosemirror/paragraphPropertyCarry.js +8 -3
  245. package/dist/prosemirror/plugins/suggestionMode.js +57 -7
  246. package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -1
  247. package/dist/prosemirror/runFormattingFromMarks.d.ts +4 -1
  248. package/dist/prosemirror/runFormattingFromMarks.js +15 -1
  249. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -1
  250. package/dist/prosemirror/runFormattingInlineCarriers.js +4 -1
  251. package/dist/prosemirror/schema/marks.d.ts +2 -0
  252. package/dist/prosemirror/schema/nodes.d.ts +10 -2
  253. package/dist/prosemirror/textBoxAnchorAttrs.d.ts +2 -1
  254. package/dist/prosemirror/textInput.js +5 -1
  255. package/dist/prosemirror/trackedRevisionPath.js +2 -1
  256. package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -0
  257. package/dist/prosemirror/trackedRunInlineAtoms.js +1 -0
  258. package/dist/prosemirror/validation.js +4 -0
  259. package/dist/types/canonicalCapabilities.d.ts +215 -0
  260. package/dist/types/canonicalCapabilities.js +212 -0
  261. package/dist/types/canonicalSave.d.ts +11 -0
  262. package/dist/types/canonicalSave.js +0 -0
  263. package/dist/types/content.d.ts +2 -2
  264. package/dist/types/docxSerialization.d.ts +14 -0
  265. package/dist/types/docxSerialization.js +7 -0
  266. package/dist/utils/createDocument.js +2 -2
  267. package/package.json +16 -4
@@ -1,3 +1,5 @@
1
+ import { withCanonicalCommand } from "../canonicalCommands.js";
2
+ import { canonicalSelectionRange } from "../canonicalSelectionRange.js";
1
3
  import { pageBreakRunParagraphProjectionDisposition } from "../pageBreakRunProjection.js";
2
4
  //#region src/prosemirror/commands/pageBreak.ts
3
5
  const UNSUPPORTED_PAGE_BREAK_RUN_ANCESTORS = /* @__PURE__ */ new Set([
@@ -23,7 +25,7 @@ const hasTextBoxAnchorAtOrAfter = (paragraph, contentStart, position) => {
23
25
  * position among neighbouring run content. Block-level `pageBreak` remains a
24
26
  * legacy input boundary and is never emitted by this command.
25
27
  */
26
- const insertPageBreak = (state, dispatch) => {
28
+ const insertPageBreakCommand = (state, dispatch) => {
27
29
  const { schema } = state;
28
30
  const pageBreakRunType = schema.nodes["pageBreakRun"];
29
31
  const { $from } = state.selection;
@@ -36,5 +38,17 @@ const insertPageBreak = (state, dispatch) => {
36
38
  }
37
39
  return true;
38
40
  };
41
+ /**
42
+ * Insert a page-break run at the current text cursor.
43
+ *
44
+ * Keeping the atom inline preserves its authored run, revision marks, and exact
45
+ * position among neighbouring run content. Block-level `pageBreak` remains a
46
+ * legacy input boundary and is never emitted by this command.
47
+ */
48
+ const insertPageBreak = withCanonicalCommand(insertPageBreakCommand, (state) => insertPageBreakCommand(state) ? [{
49
+ type: "insertBreak",
50
+ ...canonicalSelectionRange(state),
51
+ breakType: "page"
52
+ }] : []);
39
53
  //#endregion
40
54
  export { insertPageBreak };
@@ -1,3 +1,4 @@
1
+ import { dispatchClipboardIntent } from "../clipboardIntent.js";
1
2
  import { Fragment, Slice } from "prosemirror-model";
2
3
  //#region src/prosemirror/commands/pastePlainText.ts
3
4
  /**
@@ -54,7 +55,7 @@ const pasteWithoutFormatting = (state, dispatch, view) => {
54
55
  navigator.clipboard.readText().then((text) => {
55
56
  if (!text || view.isDestroyed) return;
56
57
  const slice = buildPlainTextSlice(text, schema);
57
- view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
58
+ if (dispatchClipboardIntent(view, slice) === void 0) view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
58
59
  }).catch((error) => {
59
60
  if (typeof CustomEvent === "function" && !view.isDestroyed) view.dom.dispatchEvent(new CustomEvent(CLIPBOARD_READ_ERROR_EVENT, {
60
61
  detail: { error },
@@ -1,5 +1,6 @@
1
1
  import { CommentReferenceAttrs } from "./schema/nodes.js";
2
- import { ReadProseMirrorAttrsResult } from "./attrs/index.js";
2
+ import { ReadProseMirrorAttrsResult } from "../internal/prosemirrorAttrBoundary.js";
3
+ import "./attrs/index.js";
3
4
  import { Node } from "prosemirror-model";
4
5
  //#region src/prosemirror/commentReferenceAttrs.d.ts
5
6
  declare const readCommentReferenceAttrs: (node: Node) => ReadProseMirrorAttrsResult<CommentReferenceAttrs>;
@@ -1,13 +1,15 @@
1
1
  import { joinCommentRangesAcrossParagraphs } from "../../docx/commentRangeJoin.js";
2
2
  import { completeCommentReferences } from "../../docx/commentReferenceCompletion.js";
3
+ import { normalizeFoldedListNumbers } from "../../docx/foldedListNumberFields.js";
3
4
  import { EDITED_PREVIEW_FINGERPRINT, imageRawXmlFingerprint } from "../../docx/imageRawXml.js";
4
5
  import { isInlineSdtContent, isSimpleFieldContent } from "../../docx/inlineWrapperContent.js";
5
6
  import { paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
6
- import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphPropertySourceBelongsToDocument, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
7
+ import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, inspectParagraphSourceIdentity, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
7
8
  import { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
8
9
  import { refingerprintShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
9
10
  import { DATE_UTC_ATTRIBUTE } from "../../docx/trackedChangeInfo.js";
10
11
  import { copiedWrapPolygon } from "../../docx/wrapPolygon.js";
12
+ import { expectNoteMarkerAttrs } from "../../internal/noteMarkerAttrs.js";
11
13
  import { isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission } from "../../internal/paragraphFormattingSerialization.js";
12
14
  import { createStyleEngine } from "../../style-engine/styleEngine.js";
13
15
  import { normalizeShapeTextAnchor, presetDashForOutlineAttr } from "../../types/documentEnumValues.js";
@@ -185,11 +187,16 @@ const validateParagraphPropertySourceTokens = (pmDoc, baseDocument, contract) =>
185
187
  if (!sourceParagraphs) panic("A paragraph-property source contract lost its source registry");
186
188
  const currentTokens = /* @__PURE__ */ new Set();
187
189
  visitDocumentStoryParagraphs(baseDocument.package.document.content, (paragraph) => {
188
- const token = getParagraphPropertySourceToken(paragraph);
189
- if (!token) {
190
- if (paragraphPropertySourceBelongsToDocument(paragraph, baseDocument)) throw sourceValidationError("invalid_token", "A source-bound paragraph is missing its paragraph-property token.");
191
- return;
190
+ const identity = inspectParagraphSourceIdentity(paragraph, baseDocument);
191
+ switch (identity.type) {
192
+ case "authored":
193
+ case "capture-only": return;
194
+ case "missing-token": throw sourceValidationError("invalid_token", "A source-bound paragraph is missing its paragraph-property token.");
195
+ case "invalid": throw sourceValidationError("invalid_token", "The source paragraph identity is invalid.");
196
+ case "durable": break;
197
+ default: panic(`Unhandled paragraph source identity: ${String(identity)}`);
192
198
  }
199
+ const { token } = identity;
193
200
  if (!paragraphPropertySourceTokenMatchesContract(token, contract)) throw sourceValidationError("invalid_token", "The source document contains an invalid paragraph-property token.");
194
201
  if (!sourceParagraphs.has(token)) throw sourceValidationError("unknown_token", "The source document contains an unknown paragraph-property token.");
195
202
  if (currentTokens.has(token)) throw sourceValidationError("duplicate_token", "The source document contains a duplicate paragraph-property token.");
@@ -965,6 +972,7 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers, styleRes
965
972
  if (pFormatting) paragraph.formatting = pFormatting;
966
973
  const listRendering = listRenderingFromAttrs(attrs);
967
974
  if (listRendering) paragraph.listRendering = listRendering;
975
+ normalizeFoldedListNumbers(paragraph);
968
976
  if (attrs.renderedPageBreakBefore) paragraph.renderedPageBreakBefore = true;
969
977
  if (attrs._sectionProperties) paragraph.sectionProperties = attrs._sectionProperties;
970
978
  if (attrs._propertyChanges && attrs._propertyChanges.length > 0) paragraph.propertyChanges = attrs._propertyChanges.map(propertyChangeFromAttrs);
@@ -1172,27 +1180,32 @@ function paragraphAttrsToFormatting(attrs) {
1172
1180
  if (suppressAutoHyphens != null) f.suppressAutoHyphens = suppressAutoHyphens;
1173
1181
  return f;
1174
1182
  }
1175
- function createTrackedRunWrapper(type, info, child) {
1183
+ function createTrackedRunWrapper({ type, info, child, resolutionJoins }) {
1176
1184
  const content = child ? [child] : [];
1185
+ const provenance = resolutionJoins === void 0 ? {} : { resolutionJoins: structuredClone(resolutionJoins) };
1177
1186
  if (type === "insertion") return {
1178
1187
  type,
1179
1188
  info,
1180
- content
1189
+ content,
1190
+ ...provenance
1181
1191
  };
1182
1192
  if (type === "deletion") return {
1183
1193
  type,
1184
1194
  info,
1185
- content
1195
+ content,
1196
+ ...provenance
1186
1197
  };
1187
1198
  if (type === "moveFrom") return {
1188
1199
  type,
1189
1200
  info,
1190
- content
1201
+ content,
1202
+ ...provenance
1191
1203
  };
1192
1204
  return {
1193
1205
  type,
1194
1206
  info,
1195
- content
1207
+ content,
1208
+ ...provenance
1196
1209
  };
1197
1210
  }
1198
1211
  /**
@@ -1272,7 +1285,7 @@ const nestRevisionAwareInlineWrappers = (items, stack, revisionOuterWrapperCount
1272
1285
  closeLayer();
1273
1286
  return nested;
1274
1287
  };
1275
- const sameRevisionLayer = (left, right) => left.type === right.type && left.revisionId === right.revisionId && left.author === right.author && left.date === right.date && left.utcDate === right.utcDate && left.initials === right.initials && left.outerWrapperCount === right.outerWrapperCount;
1288
+ const sameRevisionLayer = (left, right) => left.type === right.type && left.revisionId === right.revisionId && left.author === right.author && left.date === right.date && left.utcDate === right.utcDate && left.initials === right.initials && left.outerWrapperCount === right.outerWrapperCount && JSON.stringify(left.resolutionJoins) === JSON.stringify(right.resolutionJoins);
1276
1289
  const revisionInfoFromLayer = (layer) => ({
1277
1290
  id: layer.revisionId,
1278
1291
  author: layer.author,
@@ -1299,14 +1312,19 @@ const nestRevisionAncestors = (items, ancestorsByWrapper, revisionOuterWrapperCo
1299
1312
  ...item.info.date ? { date: item.info.date } : {},
1300
1313
  ...item.info.utcDate ? { utcDate: item.info.utcDate.value } : {},
1301
1314
  ...item.info.initials ? { initials: item.info.initials } : {},
1302
- outerWrapperCount: revisionOuterWrapperCounts.get(item) ?? 0
1315
+ outerWrapperCount: revisionOuterWrapperCounts.get(item) ?? 0,
1316
+ ...item.resolutionJoins === void 0 ? {} : { resolutionJoins: item.resolutionJoins }
1303
1317
  };
1304
1318
  const path = [...ancestorsByWrapper.get(item) ?? [], ownLayer];
1305
1319
  let shared = 0;
1306
1320
  while (shared < open.length && path[shared] && sameRevisionLayer(open[shared].layer, path[shared])) shared += 1;
1307
1321
  open.length = shared;
1308
1322
  for (const layer of path.slice(shared)) {
1309
- const wrapper = createTrackedRunWrapper(layer.type, revisionInfoFromLayer(layer));
1323
+ const wrapper = createTrackedRunWrapper({
1324
+ type: layer.type,
1325
+ info: revisionInfoFromLayer(layer),
1326
+ resolutionJoins: layer.resolutionJoins
1327
+ });
1310
1328
  revisionOuterWrapperCounts.set(wrapper, layer.outerWrapperCount);
1311
1329
  const parent = open.at(-1)?.wrapper;
1312
1330
  if (parent) parent.content.push(wrapper);
@@ -1553,7 +1571,12 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1553
1571
  let type;
1554
1572
  if (insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
1555
1573
  else type = changeAttrs.moveKind === "moveFrom" ? "moveFrom" : "deletion";
1556
- const wrapper = createTrackedRunWrapper(type, info, anchoredContent);
1574
+ const wrapper = createTrackedRunWrapper({
1575
+ type,
1576
+ info,
1577
+ child: anchoredContent,
1578
+ resolutionJoins: changeAttrs._docxResolutionJoins ?? void 0
1579
+ });
1557
1580
  revisionOuterWrapperCounts.set(wrapper, changeAttrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length);
1558
1581
  revisionAncestorsByWrapper.set(wrapper, changeAttrs._docxRevisionAncestors ?? []);
1559
1582
  content.push(wrapper);
@@ -1584,12 +1607,17 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1584
1607
  if (changeMark === insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
1585
1608
  else type = changeAttrs.moveKind === "moveFrom" ? "moveFrom" : "deletion";
1586
1609
  const outerWrapperCount = changeAttrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length;
1587
- const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(revisionAncestors)}`;
1610
+ const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(revisionAncestors)}:${JSON.stringify(changeAttrs._docxResolutionJoins ?? void 0)}`;
1588
1611
  if (linkMark) {
1589
1612
  const linkKey = getLinkKey(linkMark);
1590
1613
  if (!currentTrackedChange || currentTrackedChange.type !== "hyperlink" || currentTrackedChange.key !== trackedChangeKey || currentTrackedChange.hyperlinkKey !== linkKey) {
1591
1614
  const hyperlink = createIndexedHyperlink(linkMark);
1592
- const wrapper = createTrackedRunWrapper(type, info, hyperlink);
1615
+ const wrapper = createTrackedRunWrapper({
1616
+ type,
1617
+ info,
1618
+ child: hyperlink,
1619
+ resolutionJoins: changeAttrs._docxResolutionJoins ?? void 0
1620
+ });
1593
1621
  revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
1594
1622
  revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
1595
1623
  content.push(wrapper);
@@ -1624,7 +1652,11 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1624
1652
  return;
1625
1653
  }
1626
1654
  if (!currentTrackedChange || currentTrackedChange.type !== "direct" || currentTrackedChange.key !== trackedChangeKey) {
1627
- const wrapper = createTrackedRunWrapper(type, info);
1655
+ const wrapper = createTrackedRunWrapper({
1656
+ type,
1657
+ info,
1658
+ resolutionJoins: changeAttrs._docxResolutionJoins ?? void 0
1659
+ });
1628
1660
  revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
1629
1661
  revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
1630
1662
  content.push(wrapper);
@@ -1717,6 +1749,13 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1717
1749
  clear,
1718
1750
  marks: node.marks
1719
1751
  }));
1752
+ } else if (node.type.name === "noteMarker") {
1753
+ flushCurrentInline();
1754
+ appendDirectRun(node, createNoteMarkerRun({
1755
+ node,
1756
+ marks: node.marks,
1757
+ formattingContext
1758
+ }));
1720
1759
  } else if (node.type.name === "symbol") {
1721
1760
  flushCurrentInline();
1722
1761
  content.push(createSymbolRun(node, node.marks, formattingContext));
@@ -1806,6 +1845,11 @@ function createTrackedChangeRun({ baseParagraphFormatting, inheritedFormatting,
1806
1845
  };
1807
1846
  restoreRunRecord(run, marks);
1808
1847
  } else if (node.type.name === "symbol") run = createSymbolRun(node, marks, formattingContext);
1848
+ else if (node.type.name === "noteMarker") run = createNoteMarkerRun({
1849
+ node,
1850
+ marks,
1851
+ formattingContext
1852
+ });
1809
1853
  else if (node.type.name === "preservedXml") run = createPreservedXmlRun(node, marks, formattingContext);
1810
1854
  else if (node.type.name === "hardBreak") run = createBreakRun(expectHardBreakAttrs(node), marks, formattingContext);
1811
1855
  else if (node.type.name === "pageBreakRun") {
@@ -1968,6 +2012,14 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
1968
2012
  hyperlink.children.push(run);
1969
2013
  return;
1970
2014
  }
2015
+ if (node.type.name === "noteMarker") {
2016
+ hyperlink.children.push(createNoteMarkerRun({
2017
+ node,
2018
+ marks: nonLinkMarks,
2019
+ formattingContext
2020
+ }));
2021
+ return;
2022
+ }
1971
2023
  if (node.type.name === "symbol") {
1972
2024
  hyperlink.children.push(createSymbolRun(node, nonLinkMarks, {
1973
2025
  baseParagraphFormatting,
@@ -2098,13 +2150,33 @@ function createSymbolRun(node, marks, formattingContext) {
2098
2150
  const isInlineLevelPreservedXml = (node) => node.type.name === "preservedXml" && expectPreservedXmlAttrs(node).level === PRESERVED_XML_LEVELS.inline;
2099
2151
  /** The paragraph-level capture an inline-level atom writes back. */
2100
2152
  const createPreservedInline = (node) => {
2101
- const { xml, text } = expectPreservedXmlAttrs(node);
2102
- return {
2153
+ const { xml, text, foldedListNumber } = expectPreservedXmlAttrs(node);
2154
+ return foldedListNumber ? {
2155
+ type: "preservedInline",
2156
+ xml,
2157
+ text,
2158
+ foldedListNumber
2159
+ } : {
2103
2160
  type: "preservedInline",
2104
2161
  xml,
2105
2162
  text
2106
2163
  };
2107
2164
  };
2165
+ /** Rebuild the authored automatic mark and its run properties from the atom. */
2166
+ const createNoteMarkerRun = ({ node, marks, formattingContext }) => {
2167
+ const { kind } = expectNoteMarkerAttrs(node);
2168
+ const run = {
2169
+ type: "run",
2170
+ content: [{
2171
+ type: "noteMarker",
2172
+ kind
2173
+ }]
2174
+ };
2175
+ const formatting = getAtomRunFormattingFromMarks(marks, formattingContext);
2176
+ if (formatting) run.formatting = formatting;
2177
+ restoreRunRecord(run, marks);
2178
+ return run;
2179
+ };
2108
2180
  /**
2109
2181
  * Rebuild the run around a preserved child. The markup is opaque and comes
2110
2182
  * back byte for byte; only the run properties around it are rebuilt from the
@@ -0,0 +1,8 @@
1
+ //#region src/prosemirror/conversion/hyphenTextCarriers.d.ts
2
+ /** These source units render as native text while keeping one logical atom each. */
3
+ declare const HYPHEN_TEXT_CARRIERS: {
4
+ readonly softHyphen: "­";
5
+ readonly noBreakHyphen: "‑";
6
+ };
7
+ //#endregion
8
+ export { HYPHEN_TEXT_CARRIERS };
@@ -0,0 +1,8 @@
1
+ //#region src/prosemirror/conversion/hyphenTextCarriers.ts
2
+ /** These source units render as native text while keeping one logical atom each. */
3
+ const HYPHEN_TEXT_CARRIERS = {
4
+ softHyphen: "­",
5
+ noBreakHyphen: "‑"
6
+ };
7
+ //#endregion
8
+ export { HYPHEN_TEXT_CARRIERS };
@@ -0,0 +1,6 @@
1
+ import { document_d_exports } from "../../types/document.js";
2
+ //#region src/prosemirror/conversion/listRenderingDefinition.d.ts
3
+ /** Compare scalar fields directly; only nested records need canonical ordering. */
4
+ declare const listRenderingDefinitionsMatch: (left: document_d_exports.ListRendering, right: document_d_exports.ListRendering) => boolean;
5
+ //#endregion
6
+ export { listRenderingDefinitionsMatch };
@@ -0,0 +1,97 @@
1
+ import { canonicalJson } from "../../utils/canonicalJson.js";
2
+ //#region src/prosemirror/conversion/listRenderingDefinition.ts
3
+ const DEFINITION_FIELDS = Object.values({
4
+ marker: {
5
+ key: "marker",
6
+ source: "paragraph"
7
+ },
8
+ foldedMarkerSuffix: {
9
+ key: "foldedMarkerSuffix",
10
+ source: "paragraph"
11
+ },
12
+ implicitChildLevelAdvances: {
13
+ key: "implicitChildLevelAdvances",
14
+ source: "paragraph"
15
+ },
16
+ markerSecondSlotOffsetTwips: {
17
+ key: "markerSecondSlotOffsetTwips",
18
+ source: "paragraph"
19
+ },
20
+ markerTemplate: {
21
+ key: "markerTemplate",
22
+ source: "definition"
23
+ },
24
+ level: {
25
+ key: "level",
26
+ source: "definition"
27
+ },
28
+ numId: {
29
+ key: "numId",
30
+ source: "definition"
31
+ },
32
+ isBullet: {
33
+ key: "isBullet",
34
+ source: "definition"
35
+ },
36
+ isLegal: {
37
+ key: "isLegal",
38
+ source: "definition"
39
+ },
40
+ numFmt: {
41
+ key: "numFmt",
42
+ source: "definition"
43
+ },
44
+ markerHidden: {
45
+ key: "markerHidden",
46
+ source: "definition"
47
+ },
48
+ markerFormatting: {
49
+ key: "markerFormatting",
50
+ source: "definition"
51
+ },
52
+ markerAlignment: {
53
+ key: "markerAlignment",
54
+ source: "definition"
55
+ },
56
+ markerAllCaps: {
57
+ key: "markerAllCaps",
58
+ source: "definition"
59
+ },
60
+ markerSuffix: {
61
+ key: "markerSuffix",
62
+ source: "definition"
63
+ },
64
+ levelTabs: {
65
+ key: "levelTabs",
66
+ source: "definition"
67
+ },
68
+ levelNumFmts: {
69
+ key: "levelNumFmts",
70
+ source: "definition"
71
+ },
72
+ levelStarts: {
73
+ key: "levelStarts",
74
+ source: "definition"
75
+ },
76
+ abstractNumId: {
77
+ key: "abstractNumId",
78
+ source: "definition"
79
+ },
80
+ startOverride: {
81
+ key: "startOverride",
82
+ source: "definition"
83
+ }
84
+ }).filter((field) => field.source === "definition");
85
+ /** Compare scalar fields directly; only nested records need canonical ordering. */
86
+ const listRenderingDefinitionsMatch = (left, right) => {
87
+ for (const { key } of DEFINITION_FIELDS) {
88
+ const before = left[key];
89
+ const after = right[key];
90
+ if (before === after) continue;
91
+ if (typeof before !== "object" || typeof after !== "object") return false;
92
+ if (canonicalJson(before) !== canonicalJson(after)) return false;
93
+ }
94
+ return true;
95
+ };
96
+ //#endregion
97
+ export { listRenderingDefinitionsMatch };
@@ -8,6 +8,8 @@ import { Node } from "prosemirror-model";
8
8
  type ToProseDocOptions = {
9
9
  /** Style definitions for resolving paragraph styles */
10
10
  styles?: document_d_exports.StyleDefinitions;
11
+ /** Package definitions used to recompute secondary-story list rendering. */
12
+ numbering?: document_d_exports.NumberingDefinitions;
11
13
  /** Theme used when converting themed table/cell values in nested content. */
12
14
  theme?: document_d_exports.Theme | null;
13
15
  /**
@@ -16,6 +18,12 @@ type ToProseDocOptions = {
16
18
  */
17
19
  warn?: ParseContext["warn"];
18
20
  };
21
+ /**
22
+ * Find bookmark pairs across every editable inline wrapper in a document story.
23
+ * Each endpoint is converted at its own structural position, so a range may
24
+ * start outside a hyperlink and end inside it (or the inverse).
25
+ */
26
+ declare const collectPairedBookmarkIds: (blocks: readonly document_d_exports.BlockContent[]) => ReadonlySet<number>;
19
27
  /**
20
28
  * Convert a Document to a ProseMirror document
21
29
  *
@@ -28,9 +36,8 @@ declare function standaloneTableCellToProseMirror(cell: document_d_exports.Table
28
36
  * Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document.
29
37
  * Used for editing headers/footers in their own ProseMirror editor and for
30
38
  * the unified header/footer render pipeline (see
31
- * `core/layout-bridge/headerFooterLayout.ts`). `theme` lives in
32
- * `ToProseDocOptions` for future themeColor cell-shading resolution; folio's
33
- * `convertTable` does not yet thread it (orthogonal upstream divergence).
39
+ * `core/layout-bridge/headerFooterLayout.ts`). Package numbering definitions
40
+ * recompute list rendering for direct paragraphs and nested table content.
34
41
  */
35
42
  declare function headerFooterToProseDoc(content: document_d_exports.BlockContent[], options?: ToProseDocOptions): Node;
36
43
  declare function footnoteToProseDoc(content: document_d_exports.BlockContent[], options?: ToProseDocOptions): Node;
@@ -39,4 +46,4 @@ declare function footnoteToProseDoc(content: document_d_exports.BlockContent[],
39
46
  */
40
47
  declare function createEmptyDoc(): Node;
41
48
  //#endregion
42
- export { ToProseDocOptions, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };
49
+ export { ToProseDocOptions, collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };
@@ -1,6 +1,7 @@
1
1
  import { rangedCommentIds } from "../../docx/commentAnchorIndex.js";
2
2
  import { resolveColorValueToHex } from "../../docx/drawingUtils.js";
3
3
  import { isInlineSdtContent, isTrackedChangeWrapperChild } from "../../docx/inlineWrapperContent.js";
4
+ import { computeListRendering, getCachedNumberingMap } from "../../docx/numberingParser.js";
4
5
  import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, createProseParagraphWithPropertySource, getDocumentParagraphPropertySourceContract, proseParagraphAttrsWithoutPropertySource, recreateProseNodeWithParagraphPropertySource, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
5
6
  import { isBaselineVertAlign } from "../../docx/runParser.js";
6
7
  import { replayableShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
@@ -30,6 +31,7 @@ import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "../extensions/nodes/MoveRangeBoun
30
31
  import { RANGE_ANCHOR_NODE_NAME } from "../extensions/nodes/RangeAnchorExtension.js";
31
32
  import "../extensions/nodes/SdtExtension.js";
32
33
  import { inlineWrapperLayer } from "../inlineWrapperStack.js";
34
+ import { CLEARED_LIST_RENDERING_ATTRS } from "../listMarker.js";
33
35
  import { listRenderingAttrPatch } from "../listRenderingAttrs.js";
34
36
  import { stampNumberedRefFieldBaselines } from "../numberedRefFields.js";
35
37
  import { paragraphNumberingAttr } from "../numberingAttr.js";
@@ -47,11 +49,13 @@ import { tableCellStyleRegions, tableRowBand } from "../styles/tableStyleRegions
47
49
  import { canCarryTrackedRunMark, trackedRunInlineAtomDisposition } from "../trackedRunInlineAtoms.js";
48
50
  import { assertValidProseMirrorDocument } from "../validation.js";
49
51
  import { resolveEffectiveTableCellFormatting } from "./effectiveTableCellFormatting.js";
52
+ import { HYPHEN_TEXT_CARRIERS } from "./hyphenTextCarriers.js";
53
+ import { listRenderingDefinitionsMatch } from "./listRenderingDefinition.js";
50
54
  import { createMarkInterner } from "./markInterner.js";
51
55
  import { hasSinkChildren } from "./preservedSinkCarriers.js";
52
56
  import { sdtAttrsFromProperties } from "./sdtAttrs.js";
53
57
  import { panic } from "better-result";
54
- import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES } from "@stll/docx-core/model";
58
+ import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES, mergeParagraphNumbering } from "@stll/docx-core/model";
55
59
  //#region src/prosemirror/conversion/toProseDoc.ts
56
60
  const DETACHED_WATERMARK_HOST = Symbol.for("stll.detachedWatermarkHost");
57
61
  const noPageBreakProjectionWarning = () => {};
@@ -227,11 +231,15 @@ function toProseDoc(document, options) {
227
231
  const styleResolver = createStyleEngine(options?.styles ?? document.package.styles);
228
232
  const theme = options?.theme ?? document.package.theme ?? null;
229
233
  const nextTextBoxGroupId = createTextBoxGroupIdFactory();
234
+ const nextHyperlinkInstanceIndex = createHyperlinkInstanceIndexAllocator();
235
+ const pairedBookmarkIds = collectPairedBookmarkIds(paragraphs);
230
236
  const conversionContext = {
237
+ listRenderings: /* @__PURE__ */ new Map(),
238
+ numbering: document.package.numbering === void 0 ? void 0 : getCachedNumberingMap(document.package.numbering),
231
239
  theme,
232
240
  nextTextBoxGroupId,
233
- nextHyperlinkInstanceIndex: createHyperlinkInstanceIndexAllocator(),
234
- pairedBookmarkIds: collectPairedBookmarkIds(paragraphs),
241
+ nextHyperlinkInstanceIndex,
242
+ pairedBookmarkIds,
235
243
  pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex(paragraphs),
236
244
  storyRangedCommentIds: rangedCommentIds(paragraphs),
237
245
  openCommentIds: /* @__PURE__ */ new Set(),
@@ -328,7 +336,8 @@ function preservedInlineNode(content) {
328
336
  return schema.node("preservedXml", {
329
337
  xml: content.xml,
330
338
  text: content.text,
331
- level: PRESERVED_XML_LEVELS.inline
339
+ level: PRESERVED_XML_LEVELS.inline,
340
+ ...content.foldedListNumber ? { foldedListNumber: content.foldedListNumber } : {}
332
341
  });
333
342
  }
334
343
  /**
@@ -372,6 +381,20 @@ function convertBlockCustomXml(block, convertBlocks) {
372
381
  _originallyEmpty: block.content.length === 0
373
382
  }, children);
374
383
  }
384
+ const resolveListRendering = (numPr, context) => {
385
+ const key = `${numPr.numId}:${numPr.ilvl ?? 0}`;
386
+ const cached = context.listRenderings.get(key);
387
+ if (cached !== void 0) return cached;
388
+ const numbering = context.numbering;
389
+ const rendering = numbering === void 0 ? null : computeListRendering(numPr, numbering);
390
+ const nextLevel = numbering?.getLevel(numPr.numId, (numPr.ilvl ?? 0) + 1);
391
+ const resolved = {
392
+ rendering,
393
+ nextSlotOffset: nextLevel?.pPr?.hangingIndent === true && nextLevel.pPr.indentFirstLine !== void 0 && nextLevel.pPr.indentFirstLine < 0 ? -nextLevel.pPr.indentFirstLine : void 0
394
+ };
395
+ context.listRenderings.set(key, resolved);
396
+ return resolved;
397
+ };
375
398
  /**
376
399
  * Convert a Paragraph to a ProseMirror paragraph node
377
400
  *
@@ -386,6 +409,15 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
386
409
  createMark: context.createMark
387
410
  };
388
411
  const { attrs, effectiveFrame } = paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOverlay);
412
+ const numPr = mergeParagraphNumbering(attrs.numPrFromStyle ?? void 0, attrs.numPr ?? void 0);
413
+ if (numPr?.kind === "none") Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
414
+ else if (context.numbering !== void 0 && numPr?.kind === "reference") {
415
+ const { rendering, nextSlotOffset } = resolveListRendering(numPr, context);
416
+ if (rendering !== null) {
417
+ const cached = paragraph.listRendering;
418
+ if (!(cached !== void 0 && listRenderingDefinitionsMatch(cached, rendering) && (cached.markerSecondSlotOffsetTwips === void 0 || cached.markerSecondSlotOffsetTwips === nextSlotOffset))) Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS, listRenderingAttrPatch(rendering));
419
+ } else Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
420
+ }
389
421
  reportParagraphPageBreakProjection({
390
422
  paragraph,
391
423
  attrs,
@@ -724,6 +756,7 @@ function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runS
724
756
  initials: change.info.initials ?? null,
725
757
  moveKind,
726
758
  _docxOuterWrapperCount: wrappedBy.length,
759
+ _docxResolutionJoins: change.resolutionJoins ?? null,
727
760
  ...markType === "deletion" ? { _historicalFormatting: true } : {}
728
761
  });
729
762
  const ancestor = {
@@ -733,7 +766,8 @@ function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runS
733
766
  ...change.info.date ? { date: change.info.date } : {},
734
767
  ...change.info.utcDate ? { utcDate: change.info.utcDate.value } : {},
735
768
  ...change.info.initials ? { initials: change.info.initials } : {},
736
- outerWrapperCount: wrappedBy.length
769
+ outerWrapperCount: wrappedBy.length,
770
+ ...change.resolutionJoins === void 0 ? {} : { resolutionJoins: change.resolutionJoins }
737
771
  };
738
772
  return nodes.map((node) => withTrackedRunMark(node, mark, ancestor));
739
773
  }
@@ -753,7 +787,7 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
753
787
  if (tableOfContentsLevel !== void 0) attrs._tableOfContentsLevel = tableOfContentsLevel;
754
788
  if (formatting?.numPr) attrs.numPr = paragraphNumberingAttr(formatting.numPr);
755
789
  if (formatting?.numPrFromStyle) attrs.numPrFromStyle = paragraphNumberingAttr(formatting.numPrFromStyle);
756
- if (paragraph.listRendering) Object.assign(attrs, listRenderingAttrPatch(paragraph.listRendering));
790
+ if (paragraph.listRendering && formatting?.numPr?.kind !== "none") Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS, listRenderingAttrPatch(paragraph.listRendering));
757
791
  if (formatting) attrs._originalFormatting = formatting;
758
792
  if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...change }) => {
759
793
  if (previousFormatting === void 0) return change;
@@ -1262,7 +1296,9 @@ function standaloneTableCellToProseMirror(cell, nodeType) {
1262
1296
  cell,
1263
1297
  styleResolver: null,
1264
1298
  context: {
1299
+ listRenderings: /* @__PURE__ */ new Map(),
1265
1300
  theme: null,
1301
+ numbering: void 0,
1266
1302
  nextTextBoxGroupId,
1267
1303
  nextHyperlinkInstanceIndex,
1268
1304
  pairedBookmarkIds: collectPairedBookmarkIds(cell.content),
@@ -1725,6 +1761,7 @@ function reportRunContentBesidePageBreak(run, owner, warn) {
1725
1761
  case "drawing":
1726
1762
  case "endnoteRef":
1727
1763
  case "footnoteRef":
1764
+ case "noteMarker":
1728
1765
  case "preservedXml":
1729
1766
  case "renderedPageBreak":
1730
1767
  case "symbol":
@@ -1938,6 +1975,7 @@ const carriedRunFormatting = (formatting) => formatting && Object.keys(formattin
1938
1975
  */
1939
1976
  function convertRunContent(content, marks, formatting, textBoxAnchors, authoredFormatting) {
1940
1977
  switch (content.type) {
1978
+ case "noteMarker": return [schema.node("noteMarker", { kind: content.kind }).mark(marks)];
1941
1979
  case "text":
1942
1980
  if (content.text) return [schema.text(content.text, marks)];
1943
1981
  return [];
@@ -1997,8 +2035,8 @@ function convertRunContent(content, marks, formatting, textBoxAnchors, authoredF
1997
2035
  text: content.text,
1998
2036
  level: PRESERVED_XML_LEVELS.run
1999
2037
  }).mark(marks)];
2000
- case "noBreakHyphen": return [schema.text("‑", marks)];
2001
- case "softHyphen": return [schema.text("­", marks)];
2038
+ case "noBreakHyphen": return [schema.text(HYPHEN_TEXT_CARRIERS.noBreakHyphen, marks)];
2039
+ case "softHyphen": return [schema.text(HYPHEN_TEXT_CARRIERS.softHyphen, marks)];
2002
2040
  case "symbol": return [schema.node("symbol", {
2003
2041
  font: content.font,
2004
2042
  char: content.char
@@ -2648,20 +2686,23 @@ function convertTextBox(textBox, styleResolver, options) {
2648
2686
  * Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document.
2649
2687
  * Used for editing headers/footers in their own ProseMirror editor and for
2650
2688
  * the unified header/footer render pipeline (see
2651
- * `core/layout-bridge/headerFooterLayout.ts`). `theme` lives in
2652
- * `ToProseDocOptions` for future themeColor cell-shading resolution; folio's
2653
- * `convertTable` does not yet thread it (orthogonal upstream divergence).
2689
+ * `core/layout-bridge/headerFooterLayout.ts`). Package numbering definitions
2690
+ * recompute list rendering for direct paragraphs and nested table content.
2654
2691
  */
2655
2692
  function headerFooterToProseDoc(content, options) {
2656
2693
  const nodes = [];
2657
2694
  const styleResolver = options?.styles ? createStyleEngine(options.styles) : null;
2658
2695
  const theme = options?.theme ?? null;
2659
2696
  const nextTextBoxGroupId = createTextBoxGroupIdFactory();
2697
+ const nextHyperlinkInstanceIndex = createHyperlinkInstanceIndexAllocator();
2698
+ const pairedBookmarkIds = collectPairedBookmarkIds(content);
2660
2699
  const conversionContext = {
2700
+ listRenderings: /* @__PURE__ */ new Map(),
2661
2701
  theme,
2702
+ numbering: options?.numbering === void 0 ? void 0 : getCachedNumberingMap(options.numbering),
2662
2703
  nextTextBoxGroupId,
2663
- nextHyperlinkInstanceIndex: createHyperlinkInstanceIndexAllocator(),
2664
- pairedBookmarkIds: collectPairedBookmarkIds(content),
2704
+ nextHyperlinkInstanceIndex,
2705
+ pairedBookmarkIds,
2665
2706
  pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex(content),
2666
2707
  storyRangedCommentIds: rangedCommentIds(content),
2667
2708
  openCommentIds: /* @__PURE__ */ new Set(),
@@ -2725,4 +2766,4 @@ function createEmptyDoc() {
2725
2766
  return schema.node("doc", null, [schema.node("paragraph", {}, [])]);
2726
2767
  }
2727
2768
  //#endregion
2728
- export { createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };
2769
+ export { collectPairedBookmarkIds, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, standaloneTableCellToProseMirror, toProseDoc };