@stll/folio-core 0.47.7 → 0.49.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 (213) hide show
  1. package/dist/ai-edits/apply.js +565 -121
  2. package/dist/ai-edits/minimal-replacement.d.ts +64 -0
  3. package/dist/ai-edits/minimal-replacement.js +282 -0
  4. package/dist/controller/fontReadiness.js +3 -3
  5. package/dist/controller/hyphenationReadiness.d.ts +19 -0
  6. package/dist/controller/hyphenationReadiness.js +47 -0
  7. package/dist/controller/layoutPipeline.d.ts +3 -0
  8. package/dist/controller/layoutPipeline.js +70 -18
  9. package/dist/display-list/build/buildDisplayList.js +39 -12
  10. package/dist/display-list/build/pageFurniture.d.ts +7 -1
  11. package/dist/display-list/build/pageFurniture.js +21 -8
  12. package/dist/display-list/build/paragraphPrimitives.js +68 -11
  13. package/dist/display-list/build/tablePrimitives.js +10 -6
  14. package/dist/display-list/build/textBoxPrimitives.js +1 -1
  15. package/dist/display-list/build/unsupported.d.ts +2 -2
  16. package/dist/display-list/build/unsupported.js +0 -0
  17. package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
  18. package/dist/docx/attributeRemainder.js +10 -2
  19. package/dist/docx/blockContentParser.d.ts +2 -0
  20. package/dist/docx/blockContentParser.js +79 -64
  21. package/dist/docx/bulletMarkers.d.ts +18 -2
  22. package/dist/docx/bulletMarkers.js +27 -2
  23. package/dist/docx/commentParser.d.ts +2 -1
  24. package/dist/docx/commentParser.js +57 -45
  25. package/dist/docx/containerChildren.d.ts +21 -8
  26. package/dist/docx/containerChildren.js +39 -9
  27. package/dist/docx/documentParser.d.ts +5 -1
  28. package/dist/docx/documentParser.js +8 -5
  29. package/dist/docx/documentSectionFacts.d.ts +22 -0
  30. package/dist/docx/documentSectionFacts.js +43 -0
  31. package/dist/docx/drawingGroupChildren.d.ts +60 -0
  32. package/dist/docx/drawingGroupChildren.js +176 -0
  33. package/dist/docx/drawingUtils.js +3 -0
  34. package/dist/docx/fieldParser.d.ts +8 -1
  35. package/dist/docx/fieldParser.js +47 -3
  36. package/dist/docx/fontTableParser.js +34 -27
  37. package/dist/docx/footnoteParser.d.ts +3 -2
  38. package/dist/docx/footnoteParser.js +15 -12
  39. package/dist/docx/groupDrawingParser.d.ts +9 -2
  40. package/dist/docx/groupDrawingParser.js +125 -37
  41. package/dist/docx/headerFooterParser.d.ts +7 -2
  42. package/dist/docx/headerFooterParser.js +15 -5
  43. package/dist/docx/hyperlinkParser.d.ts +48 -36
  44. package/dist/docx/hyperlinkParser.js +97 -82
  45. package/dist/docx/numberingParser.js +108 -84
  46. package/dist/docx/packageParts.d.ts +45 -1
  47. package/dist/docx/packageParts.js +93 -2
  48. package/dist/docx/paraIdAttribute.d.ts +3 -2
  49. package/dist/docx/paragraphParser.d.ts +5 -1
  50. package/dist/docx/paragraphParser.js +468 -365
  51. package/dist/docx/paragraphProperties.js +123 -109
  52. package/dist/docx/paragraphPropertySource.d.ts +6 -1
  53. package/dist/docx/paragraphPropertySource.js +9 -1
  54. package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
  55. package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
  56. package/dist/docx/parser.d.ts +7 -1
  57. package/dist/docx/parser.js +33 -16
  58. package/dist/docx/previewBudget.d.ts +55 -33
  59. package/dist/docx/previewBudget.js +59 -65
  60. package/dist/docx/rezip.js +41 -58
  61. package/dist/docx/runParser.d.ts +4 -1
  62. package/dist/docx/runParser.js +182 -184
  63. package/dist/docx/sdtProperties.js +87 -84
  64. package/dist/docx/sectionParser.js +169 -160
  65. package/dist/docx/selectiveSaveFlags.d.ts +10 -3
  66. package/dist/docx/selectiveSaveFlags.js +1 -1
  67. package/dist/docx/selectiveXmlPatch.d.ts +56 -34
  68. package/dist/docx/selectiveXmlPatch.js +222 -115
  69. package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
  70. package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
  71. package/dist/docx/serializer/paragraphSerializer.js +47 -42
  72. package/dist/docx/serializer/runSerializer.d.ts +5 -1
  73. package/dist/docx/serializer/runSerializer.js +4 -3
  74. package/dist/docx/serializer/settingsSerializer.js +19 -1
  75. package/dist/docx/settingsParser.js +8 -0
  76. package/dist/docx/shapeAlternateContent.d.ts +25 -0
  77. package/dist/docx/shapeAlternateContent.js +52 -0
  78. package/dist/docx/streamingXmlParser.d.ts +6 -2
  79. package/dist/docx/streamingXmlParser.js +12 -7
  80. package/dist/docx/styleParser.js +34 -8
  81. package/dist/docx/tableParser.d.ts +21 -12
  82. package/dist/docx/tableParser.js +518 -441
  83. package/dist/docx/textBoxParser.d.ts +18 -5
  84. package/dist/docx/textBoxParser.js +12 -6
  85. package/dist/docx/verbatimCapture.d.ts +10 -8
  86. package/dist/docx/verbatimCapture.js +45 -2
  87. package/dist/docx/vmlImageParser.d.ts +15 -13
  88. package/dist/docx/vmlImageParser.js +75 -60
  89. package/dist/docx/vmlPreview.d.ts +3 -3
  90. package/dist/docx/vmlPreview.js +3 -4
  91. package/dist/docx/xmlNamespaceContext.d.ts +9 -0
  92. package/dist/docx/xmlNamespaceContext.js +54 -0
  93. package/dist/docx/xmlParser.d.ts +6 -3
  94. package/dist/docx/xmlParser.js +11 -41
  95. package/dist/docx/xmlResourceLimits.d.ts +2 -1
  96. package/dist/docx/xmlResourceLimits.js +4 -1
  97. package/dist/fonts/headlessMeasure.js +0 -0
  98. package/dist/headless-layout.d.ts +11 -2
  99. package/dist/headless-layout.js +153 -107
  100. package/dist/internal/headlessRevisionResolution.js +50 -13
  101. package/dist/internal/paragraphFormattingSerialization.js +3 -3
  102. package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
  103. package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
  104. package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
  105. package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
  106. package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
  107. package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
  108. package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
  109. package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
  110. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
  111. package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
  112. package/dist/layout-bridge/engine/hitTest.js +5 -3
  113. package/dist/layout-bridge/engine/selectionRects.js +5 -3
  114. package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
  115. package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
  116. package/dist/layout-engine/index.d.ts +2 -2
  117. package/dist/layout-engine/index.js +102 -14
  118. package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
  119. package/dist/layout-engine/justificationCompatibility.js +9 -5
  120. package/dist/layout-engine/keep-together.d.ts +15 -6
  121. package/dist/layout-engine/keep-together.js +43 -16
  122. package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
  123. package/dist/layout-engine/layoutInstrumentation.js +8 -1
  124. package/dist/layout-engine/measure/advanceComposition.js +50 -7
  125. package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
  126. package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
  127. package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
  128. package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
  129. package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
  130. package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
  131. package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
  132. package/dist/layout-engine/measure/lineBreaks.js +10 -3
  133. package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
  134. package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
  135. package/dist/layout-engine/measure/measureBlocks.js +46 -10
  136. package/dist/layout-engine/measure/measureContainer.js +51 -8
  137. package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
  138. package/dist/layout-engine/measure/measureHelpers.js +34 -8
  139. package/dist/layout-engine/measure/measureParagraph.js +143 -101
  140. package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
  141. package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
  142. package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
  143. package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
  144. package/dist/layout-engine/measure/tabCalculator.js +2 -1
  145. package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
  146. package/dist/layout-engine/measure/tableCellFloating.js +51 -19
  147. package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
  148. package/dist/layout-engine/measure/tableCellGrid.js +45 -5
  149. package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
  150. package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
  151. package/dist/layout-engine/noteAreaFlow.js +83 -0
  152. package/dist/layout-engine/paginator.d.ts +12 -1
  153. package/dist/layout-engine/paginator.js +18 -2
  154. package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
  155. package/dist/layout-engine/paragraphSpacing.js +2 -1
  156. package/dist/layout-engine/tableRowBreak.d.ts +8 -1
  157. package/dist/layout-engine/tableRowBreak.js +25 -2
  158. package/dist/layout-engine/types.d.ts +108 -3
  159. package/dist/layout-engine/types.js +96 -1
  160. package/dist/layout-painter/index.d.ts +3 -0
  161. package/dist/layout-painter/renderPage.js +32 -83
  162. package/dist/layout-painter/renderParagraph.d.ts +6 -1
  163. package/dist/layout-painter/renderParagraph.js +75 -26
  164. package/dist/layout-painter/renderTable.js +26 -13
  165. package/dist/layout-painter/renderTextBox.d.ts +12 -2
  166. package/dist/layout-painter/renderTextBox.js +26 -2
  167. package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
  168. package/dist/prosemirror/alternateContentAttrs.js +35 -0
  169. package/dist/prosemirror/attrs/index.d.ts +9 -9
  170. package/dist/prosemirror/attrs/index.js +133 -11
  171. package/dist/prosemirror/commands/comments.js +51 -41
  172. package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
  173. package/dist/prosemirror/contentControlRevisions.js +84 -0
  174. package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
  175. package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
  176. package/dist/prosemirror/conversion/markInterner.js +90 -0
  177. package/dist/prosemirror/conversion/toProseDoc.js +117 -58
  178. package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
  179. package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
  180. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
  181. package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
  182. package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
  183. package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
  184. package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
  185. package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
  186. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
  187. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
  188. package/dist/prosemirror/listMarker.d.ts +1 -0
  189. package/dist/prosemirror/listMarker.js +4 -2
  190. package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
  191. package/dist/prosemirror/listRenderingAttrs.js +3 -0
  192. package/dist/prosemirror/paragraphDirection.d.ts +29 -2
  193. package/dist/prosemirror/paragraphDirection.js +21 -2
  194. package/dist/prosemirror/plugins/suggestionMode.js +37 -8
  195. package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
  196. package/dist/prosemirror/rejoinRunCarriers.js +66 -0
  197. package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
  198. package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
  199. package/dist/prosemirror/schema/nodes.d.ts +50 -6
  200. package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
  201. package/dist/prosemirror/textBoxHostParagraph.js +21 -0
  202. package/dist/prosemirror/validation.js +91 -80
  203. package/dist/types/content.d.ts +2 -2
  204. package/dist/utils/createDocument.js +10 -1
  205. package/dist/utils/scriptSegments.d.ts +33 -4
  206. package/dist/utils/scriptSegments.js +39 -6
  207. package/dist/utils/textFormattingMerge.d.ts +17 -3
  208. package/dist/utils/textFormattingMerge.js +18 -12
  209. package/dist/utils/trailingText.d.ts +22 -0
  210. package/dist/utils/trailingText.js +32 -0
  211. package/package.json +2 -2
  212. package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
  213. package/dist/layout-engine/justifiedLineFit.js +0 -6
@@ -5,6 +5,7 @@ import { isInlineSdtContent, isSimpleFieldContent } from "../../docx/inlineWrapp
5
5
  import { paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
6
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
7
  import { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
8
+ import { refingerprintShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
8
9
  import { DATE_UTC_ATTRIBUTE } from "../../docx/trackedChangeInfo.js";
9
10
  import { copiedWrapPolygon } from "../../docx/wrapPolygon.js";
10
11
  import { isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission } from "../../internal/paragraphFormattingSerialization.js";
@@ -15,12 +16,14 @@ import { canonicalJson } from "../../utils/canonicalJson.js";
15
16
  import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
16
17
  import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
17
18
  import { emuToPixels, emuToStrokePixels, pixelsToEmu } from "../../utils/units.js";
19
+ import { unchangedAlternateContentXml } from "../alternateContentAttrs.js";
18
20
  import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
19
21
  import { readAuthoredTransform } from "../authoredTransformAttrs.js";
20
22
  import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
21
23
  import { bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
22
24
  import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges } from "../commands/propertyChangeScope.js";
23
25
  import { expectCommentReferenceAttrs } from "../commentReferenceAttrs.js";
26
+ import { enclosingRevisionIds } from "../contentControlRevisions.js";
24
27
  import { INLINE_WRAPPER_MARK_NAME } from "../extensions/marks/InlineWrapperExtension.js";
25
28
  import { applyRunFormattingOverrideAttrs, buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
26
29
  import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
@@ -31,7 +34,7 @@ import { listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRende
31
34
  import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
32
35
  import { resolveNumberedRefFields } from "../numberedRefFields.js";
33
36
  import { directParagraphAlignment } from "../paragraphAlignment.js";
34
- import { directionToBidi } from "../paragraphDirection.js";
37
+ import { directionToAuthoredBidi } from "../paragraphDirection.js";
35
38
  import { directParagraphSpacing } from "../paragraphSpacing.js";
36
39
  import { expectRangeAnchorAttrs } from "../rangeAnchorAttrs.js";
37
40
  import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
@@ -42,6 +45,7 @@ import { schema } from "../schema/index.js";
42
45
  import { PRESERVED_XML_LEVELS } from "../schema/nodes.js";
43
46
  import { parseShapeGeometryAdjustments } from "../shapeGeometryAdjustments.js";
44
47
  import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
48
+ import { textBoxHostParagraph } from "../textBoxHostParagraph.js";
45
49
  import { assertValidProseMirrorDocument } from "../validation.js";
46
50
  import { hasSinkChildren } from "./preservedSinkCarriers.js";
47
51
  import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "./runShadingMark.js";
@@ -678,7 +682,7 @@ function isStillSyntheticFiller(blocks) {
678
682
  }
679
683
  function appendTextBoxBlock(blocks, node, options) {
680
684
  const attrs = expectTextBoxAttrs(node);
681
- const paragraph = convertPMTextBox(node, options.styleResolver);
685
+ let paragraph = convertPMTextBox(node, options.styleResolver);
682
686
  const previousBlock = blocks.at(-1);
683
687
  if (attrs._docxPlacement === "inlineWithPrevious" && previousBlock?.type === "paragraph") {
684
688
  appendPageBreaks(previousBlock, options.pendingPageBreaks);
@@ -696,6 +700,12 @@ function appendTextBoxBlock(blocks, node, options) {
696
700
  if (!mergeTextBoxIntoTrailingInlineSdts(options.previousStandaloneTextBox.paragraph, paragraph, attrs._docxInlineSdts ?? [])) options.previousStandaloneTextBox.paragraph.content.push(...paragraph.content);
697
701
  return options.previousStandaloneTextBox;
698
702
  }
703
+ const host = attrs._docxPlacement === "standalone" ? textBoxHostParagraph(node) : void 0;
704
+ if (host) {
705
+ const hostParagraph = convertPMParagraph(host, void 0, void 0, options.styleResolver);
706
+ hostParagraph.content = paragraph.content;
707
+ paragraph = hostParagraph;
708
+ }
699
709
  if (attrs._docxPlacement === "standalone" && attrs._preservedAttributes?.length) paragraph.preservedAttributes = attrs._preservedAttributes;
700
710
  prependPageBreaks(paragraph, options.pendingPageBreaks);
701
711
  blocks.push(paragraph);
@@ -1043,7 +1053,7 @@ function paragraphAttrsToFormatting(attrs) {
1043
1053
  assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
1044
1054
  if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
1045
1055
  else delete result.spacingExplicit;
1046
- const bidi = authoredParagraphValue("bidi", directionToBidi(attrs.direction), orig, attrs._resolvedFormatting);
1056
+ const bidi = authoredParagraphValue("bidi", directionToAuthoredBidi(attrs.direction), orig, attrs._resolvedFormatting);
1047
1057
  if (bidi !== (orig.bidi ?? void 0)) if (bidi === void 0) delete result.bidi;
1048
1058
  else result.bidi = bidi;
1049
1059
  return result;
@@ -1051,7 +1061,7 @@ function paragraphAttrsToFormatting(attrs) {
1051
1061
  const resolved = attrs._resolvedFormatting;
1052
1062
  const authored = (field, value) => authoredParagraphValue(field, value ?? void 0, void 0, resolved);
1053
1063
  const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
1054
- const bidi = authored("bidi", directionToBidi(attrs.direction));
1064
+ const bidi = authored("bidi", directionToAuthoredBidi(attrs.direction));
1055
1065
  const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
1056
1066
  const indentLeft = authored("indentLeft", attrs.indentLeft);
1057
1067
  const indentRight = authored("indentRight", attrs.indentRight);
@@ -1343,6 +1353,7 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1343
1353
  }
1344
1354
  };
1345
1355
  const appendDirectRun = (node, run, coalescePlainText = false) => {
1356
+ if (currentHyperlink) flushCurrentInline();
1346
1357
  const marksKey = getMarksKey(node.marks);
1347
1358
  const ownerId = runIdentityId(node);
1348
1359
  const currentOwnerId = currentRun ? sourceRunOwners.get(currentRun) : void 0;
@@ -2255,6 +2266,7 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
2255
2266
  };
2256
2267
  if (attrs.fldLock !== void 0) complex.fldLock = attrs.fldLock;
2257
2268
  if (attrs.dirty !== void 0) complex.dirty = attrs.dirty;
2269
+ if (attrs.fieldResultIsFallback !== void 0) complex.fieldResultIsFallback = attrs.fieldResultIsFallback;
2258
2270
  return complex;
2259
2271
  }
2260
2272
  const simple = {
@@ -2317,21 +2329,21 @@ function createMathFromNode(node) {
2317
2329
  return math;
2318
2330
  }
2319
2331
  /**
2320
- * A revision covering every child of a control, written around the control.
2332
+ * A revision that encloses a control, written around the control.
2321
2333
  *
2322
2334
  * `w:ins > w:sdt` and `w:sdt > w:ins` reach the editor as the same revision
2323
- * mark on the same leaves, so the save leg has to pick one and writes the
2324
- * canonical order: the revision outermost, as it already is around a hyperlink
2325
- * and around a transparent wrapper. Outermost is also the only form in which
2326
- * accepting or rejecting the change is an operation over the whole control —
2327
- * the reader who inserted a bound field inserted the field, not its text.
2335
+ * mark on the same leaves; the control's enclosing-revision record says which
2336
+ * one it was (`contentControlRevisions.ts`). A revision it names that still
2337
+ * covers every child goes outermost, the only form in which accepting or
2338
+ * rejecting the change is an operation over the whole control: the reader who
2339
+ * inserted a bound field inserted the field, not its text.
2328
2340
  *
2329
- * A revision that covers only part of the content has no such form and stays
2330
- * where the editor holds it, per child.
2341
+ * Any other revision, including one over all of the content, revises the
2342
+ * content and stays where the editor holds it, per child.
2331
2343
  */
2332
- const hoistUniformRevision = (sdt) => {
2344
+ const hoistUniformRevision = (sdt, enclosingIds) => {
2333
2345
  const only = sdt.content.length === 1 ? sdt.content.at(0) : void 0;
2334
- if (only === void 0 || !isRevisionWrapper(only)) return sdt;
2346
+ if (only === void 0 || !isRevisionWrapper(only) || !enclosingIds.includes(only.info.id)) return sdt;
2335
2347
  const admitted = only.content.filter(isInlineSdtContent);
2336
2348
  if (admitted.length !== only.content.length) return sdt;
2337
2349
  return {
@@ -2352,7 +2364,7 @@ function createInlineSdtFromNode(node, textBoxAnchorMarkers, formattingContext)
2352
2364
  type: "inlineSdt",
2353
2365
  properties,
2354
2366
  content
2355
- });
2367
+ }, enclosingRevisionIds(node));
2356
2368
  }
2357
2369
  /**
2358
2370
  * Create a Run containing an image
@@ -2481,6 +2493,17 @@ const drawingFromImageAttrs = (image, attrs) => {
2481
2493
  default: return mode;
2482
2494
  }
2483
2495
  };
2496
+ const shapeContentFromNode = ({ node, shape, captured }) => {
2497
+ const xml = unchangedAlternateContentXml(node, captured);
2498
+ return xml === void 0 ? {
2499
+ type: "shape",
2500
+ shape
2501
+ } : {
2502
+ type: "shape",
2503
+ shape,
2504
+ alternateContent: refingerprintShapeAlternateContent(shape, xml)
2505
+ };
2506
+ };
2484
2507
  /**
2485
2508
  * Create a Run from a ProseMirror shape node
2486
2509
  */
@@ -2550,10 +2573,11 @@ function createShapeRun(node) {
2550
2573
  if (attrs.outlineColor) shapeOutline.color = attrs.outlineColorValue ?? { rgb: attrs.outlineColor.replace("#", "") };
2551
2574
  shape.outline = shapeOutline;
2552
2575
  }
2553
- const shapeContent = {
2554
- type: "shape",
2555
- shape
2556
- };
2576
+ const shapeContent = shapeContentFromNode({
2577
+ node,
2578
+ shape,
2579
+ captured: attrs._docxAlternateContent
2580
+ });
2557
2581
  const run = {
2558
2582
  type: "run",
2559
2583
  ...carriedRunFormatting(attrs._docxRunFormatting),
@@ -3576,6 +3600,7 @@ function convertPMTextBox(node, styleResolver = null) {
3576
3600
  type: "solid",
3577
3601
  color: { rgb: attrs.fillColor.replace("#", "") }
3578
3602
  };
3603
+ else if (attrs.gradientFill?.gradient) shape.fill = structuredClone(attrs.gradientFill);
3579
3604
  if (attrs.outlineStyle !== "none" && attrs.outlineWidth && attrs.outlineWidth > 0) {
3580
3605
  const tbOutline = {
3581
3606
  width: emuFromPixels(attrs.outlineWidth, "outlineWidth", authoredEmu, emuToStrokePixels),
@@ -3590,12 +3615,18 @@ function convertPMTextBox(node, styleResolver = null) {
3590
3615
  if (position) shape.position = position;
3591
3616
  const anchor = restoredDrawingAnchor(attrs.anchor);
3592
3617
  if (anchor) shape.anchor = anchor;
3618
+ if (attrs._docxGroupChild) shape.groupChild = {
3619
+ path: [...attrs._docxGroupChild.path],
3620
+ group: attrs._docxGroupChild.group,
3621
+ content: attrs._docxGroupChild.content
3622
+ };
3593
3623
  const run = {
3594
3624
  type: "run",
3595
- content: [{
3596
- type: "shape",
3597
- shape
3598
- }]
3625
+ content: [shapeContentFromNode({
3626
+ node,
3627
+ shape,
3628
+ captured: attrs._docxAlternateContent
3629
+ })]
3599
3630
  };
3600
3631
  const trackedChange = attrs._docxTrackedChange;
3601
3632
  const inlineSdts = attrs._docxInlineSdts ?? [];
@@ -0,0 +1,21 @@
1
+ import { MarkFactory } from "../extensions/marks/markUtils.js";
2
+ import { Schema } from "prosemirror-model";
3
+ //#region src/prosemirror/conversion/markInterner.d.ts
4
+ /**
5
+ * Build marks that share one instance per distinct (type, attrs) value.
6
+ *
7
+ * A document repeats a small set of run formattings across thousands of runs,
8
+ * so one conversion builds each distinct mark once. Marks are immutable, and
9
+ * ProseMirror compares them by value, so sharing an instance changes nothing a
10
+ * caller can observe except the saved allocation. Create one interner per
11
+ * conversion; it holds every mark it built until it is dropped.
12
+ *
13
+ * The native JSON serialization is only a lookup key: it collapses values the
14
+ * mark would keep apart (`-0`, `NaN`, nested `undefined`), so a hit is shared
15
+ * only after an exact comparison, and a mismatch builds an unshared mark. A
16
+ * mark holding `NaN` is never shared: ProseMirror does not find two of them
17
+ * equal, and a shared instance would.
18
+ */
19
+ declare const createMarkInterner: (schema: Schema) => MarkFactory;
20
+ //#endregion
21
+ export { createMarkInterner };
@@ -0,0 +1,90 @@
1
+ import { panic } from "better-result";
2
+ //#region src/prosemirror/conversion/markInterner.ts
3
+ /**
4
+ * Leaves ProseMirror compares with `===`, minus `-0`/`0`: sharing a mark makes
5
+ * `Mark.eq` take its identity shortcut, so two leaves may share only when
6
+ * ProseMirror would call them equal anyway. `NaN` never equals itself there.
7
+ */
8
+ const sameLeaf = (left, right) => left === right && Object.is(left, right);
9
+ /**
10
+ * Whether two attr values are interchangeable: `sameLeaf` on leaves, and the
11
+ * same own keys in the same order, so `-0`/`0`, `NaN` and `undefined`/absent
12
+ * stay apart. Output follows the shared value's key order, which is why order
13
+ * counts.
14
+ */
15
+ const sameAttrValue = (left, right) => {
16
+ if (sameLeaf(left, right)) return true;
17
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
18
+ if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right)) return false;
19
+ if (Array.isArray(left)) {
20
+ if (!Array.isArray(right) || left.length !== right.length) return false;
21
+ for (let index = 0; index < left.length; index += 1) if (index in left !== index in right || !sameAttrValue(left[index], right[index])) return false;
22
+ return true;
23
+ }
24
+ const leftKeys = Object.keys(left);
25
+ const rightKeys = Object.keys(right);
26
+ return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && sameAttrValue(Reflect.get(left, key), Reflect.get(right, key)));
27
+ };
28
+ const internedMark = (type, attrs) => {
29
+ const mark = type.create(attrs);
30
+ const nonDefault = /* @__PURE__ */ new Set();
31
+ for (const [name, spec] of Object.entries(type.spec.attrs ?? {})) if (!sameLeaf(mark.attrs[name], spec.default)) nonDefault.add(name);
32
+ return {
33
+ mark,
34
+ nonDefault
35
+ };
36
+ };
37
+ /**
38
+ * Whether `create(attrs)` would compute attrs interchangeable with the
39
+ * interned mark's. `create` fills every declared attr `attrs` leaves
40
+ * `undefined` from its default, so the given attrs must match each value they
41
+ * set and set every attr where the mark holds something else.
42
+ */
43
+ const matchesInterned = (type, attrs, { mark, nonDefault }) => {
44
+ const specs = type.spec.attrs ?? {};
45
+ let covered = 0;
46
+ for (const name in attrs) {
47
+ const given = attrs[name];
48
+ if (given === void 0 || !Object.hasOwn(specs, name)) continue;
49
+ if (!sameAttrValue(given, mark.attrs[name])) return false;
50
+ if (nonDefault.has(name)) covered += 1;
51
+ }
52
+ return covered === nonDefault.size;
53
+ };
54
+ /**
55
+ * Build marks that share one instance per distinct (type, attrs) value.
56
+ *
57
+ * A document repeats a small set of run formattings across thousands of runs,
58
+ * so one conversion builds each distinct mark once. Marks are immutable, and
59
+ * ProseMirror compares them by value, so sharing an instance changes nothing a
60
+ * caller can observe except the saved allocation. Create one interner per
61
+ * conversion; it holds every mark it built until it is dropped.
62
+ *
63
+ * The native JSON serialization is only a lookup key: it collapses values the
64
+ * mark would keep apart (`-0`, `NaN`, nested `undefined`), so a hit is shared
65
+ * only after an exact comparison, and a mismatch builds an unshared mark. A
66
+ * mark holding `NaN` is never shared: ProseMirror does not find two of them
67
+ * equal, and a shared instance would.
68
+ */
69
+ const createMarkInterner = (schema) => {
70
+ const marksByType = /* @__PURE__ */ new Map();
71
+ return (typeName, attrs) => {
72
+ const type = schema.marks[typeName];
73
+ if (type === void 0) panic(`Unknown mark type ${typeName}.`);
74
+ let marks = marksByType.get(type);
75
+ if (marks === void 0) {
76
+ marks = /* @__PURE__ */ new Map();
77
+ marksByType.set(type, marks);
78
+ }
79
+ const key = JSON.stringify(attrs ?? null);
80
+ const cached = marks.get(key);
81
+ if (cached === void 0) {
82
+ const interned = internedMark(type, attrs);
83
+ marks.set(key, interned);
84
+ return interned.mark;
85
+ }
86
+ return matchesInterned(type, attrs, cached) ? cached.mark : type.create(attrs);
87
+ };
88
+ };
89
+ //#endregion
90
+ export { createMarkInterner };