@stll/folio-core 0.43.0 → 0.45.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 (237) hide show
  1. package/dist/ai-edits/__fixtures__/paragraphs.js +2 -2
  2. package/dist/ai-edits/headless.js +7 -5
  3. package/dist/ai-edits/index.d.ts +2 -2
  4. package/dist/ai-edits/index.js +2 -2
  5. package/dist/ai-edits/snapshot.js +13 -9
  6. package/dist/compare/content-alignment.js +94 -54
  7. package/dist/compare/inline-atoms.js +34 -20
  8. package/dist/compare/style-resources.js +6 -0
  9. package/dist/content-controls/mutateContentControls.js +4 -2
  10. package/dist/display-list/dom/renderDisplayListToDom.js +8 -8
  11. package/dist/document-operations.js +14 -3
  12. package/dist/docx/appVersionNormalization.d.ts +0 -18
  13. package/dist/docx/blockContentParser.js +8 -0
  14. package/dist/docx/blockRangeMarkers.d.ts +36 -0
  15. package/dist/docx/blockRangeMarkers.js +59 -0
  16. package/dist/docx/bookmarkParser.d.ts +2 -20
  17. package/dist/docx/bookmarkParser.js +6 -30
  18. package/dist/docx/borderParser.d.ts +13 -0
  19. package/dist/docx/borderParser.js +71 -0
  20. package/dist/docx/builtInStyles.d.ts +165 -0
  21. package/dist/docx/builtInStyles.js +239 -0
  22. package/dist/docx/commentIdNormalization.d.ts +3 -1
  23. package/dist/docx/commentIdNormalization.js +18 -1
  24. package/dist/docx/commentParser.d.ts +2 -1
  25. package/dist/docx/commentParser.js +80 -42
  26. package/dist/docx/commentReferenceNormalization.d.ts +4 -1
  27. package/dist/docx/commentReferenceNormalization.js +23 -14
  28. package/dist/docx/commentThreadKey.d.ts +18 -0
  29. package/dist/docx/commentThreadKey.js +22 -0
  30. package/dist/docx/danglingRelationshipReferences.d.ts +15 -0
  31. package/dist/docx/danglingRelationshipReferences.js +30 -0
  32. package/dist/docx/defaultParagraphStyle.d.ts +18 -1
  33. package/dist/docx/defaultParagraphStyle.js +23 -1
  34. package/dist/docx/diagramPreview.js +87 -27
  35. package/dist/docx/documentParser.d.ts +2 -1
  36. package/dist/docx/documentParser.js +2 -2
  37. package/dist/docx/drawingUtils.d.ts +8 -1
  38. package/dist/docx/drawingUtils.js +12 -3
  39. package/dist/docx/fieldParser.js +3 -5
  40. package/dist/docx/footnoteParser.d.ts +3 -2
  41. package/dist/docx/footnoteParser.js +19 -4
  42. package/dist/docx/groupDrawingParser.js +4 -4
  43. package/dist/docx/headerFooterRefParser.d.ts +4 -3
  44. package/dist/docx/headerFooterRefParser.js +42 -12
  45. package/dist/docx/headerFooterReferenceNormalization.d.ts +4 -1
  46. package/dist/docx/headerFooterReferenceNormalization.js +5 -1
  47. package/dist/docx/hyperlinkParser.js +13 -17
  48. package/dist/docx/imageParser.d.ts +10 -2
  49. package/dist/docx/imageParser.js +80 -30
  50. package/dist/docx/imageRawXml.d.ts +14 -1
  51. package/dist/docx/imageRawXml.js +35 -11
  52. package/dist/docx/markupRangeMarker.d.ts +15 -0
  53. package/dist/docx/markupRangeMarker.js +44 -0
  54. package/dist/docx/mathToMathml.js +12 -14
  55. package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
  56. package/dist/docx/nonVisualDrawingProps.js +46 -0
  57. package/dist/docx/noteReferenceStyles.d.ts +29 -0
  58. package/dist/docx/noteReferenceStyles.js +70 -0
  59. package/dist/docx/numberingReferenceNormalization.d.ts +4 -1
  60. package/dist/docx/numberingReferenceNormalization.js +20 -1
  61. package/dist/docx/paraIdRangeNormalization.d.ts +0 -19
  62. package/dist/docx/paragraphParser.js +66 -99
  63. package/dist/docx/paragraphPropertySource.js +1 -0
  64. package/dist/docx/paragraphTextBoxEnrichment.js +3 -0
  65. package/dist/docx/paragraphTraversal.d.ts +37 -1
  66. package/dist/docx/paragraphTraversal.js +84 -1
  67. package/dist/docx/parseContext.d.ts +37 -0
  68. package/dist/docx/parseContext.js +67 -0
  69. package/dist/docx/parseWarningMessage.d.ts +6 -0
  70. package/dist/docx/parseWarningMessage.js +44 -0
  71. package/dist/docx/parser.js +83 -29
  72. package/dist/docx/previewBudget.d.ts +64 -0
  73. package/dist/docx/previewBudget.js +88 -0
  74. package/dist/docx/relsParser.d.ts +28 -11
  75. package/dist/docx/relsParser.js +26 -13
  76. package/dist/docx/revisionIdNormalization.js +96 -10
  77. package/dist/docx/rezip.js +80 -40
  78. package/dist/docx/runConsolidator.js +1 -2
  79. package/dist/docx/runParser.d.ts +8 -1
  80. package/dist/docx/runParser.js +30 -48
  81. package/dist/docx/sdtPropertiesPatch.js +24 -18
  82. package/dist/docx/sectionParser.d.ts +2 -1
  83. package/dist/docx/sectionParser.js +21 -65
  84. package/dist/docx/sectionReferenceHistory.js +2 -2
  85. package/dist/docx/selectiveSave.js +6 -6
  86. package/dist/docx/serializer/blockSdtSerializer.js +38 -26
  87. package/dist/docx/serializer/borderSerializer.d.ts +2 -3
  88. package/dist/docx/serializer/borderSerializer.js +13 -12
  89. package/dist/docx/serializer/commentSerializer.d.ts +41 -16
  90. package/dist/docx/serializer/commentSerializer.js +82 -72
  91. package/dist/docx/serializer/documentSerializer.d.ts +1 -5
  92. package/dist/docx/serializer/documentSerializer.js +6 -16
  93. package/dist/docx/serializer/fontTableSerializer.js +6 -6
  94. package/dist/docx/serializer/headerFooterSerializer.js +10 -5
  95. package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
  96. package/dist/docx/serializer/markupRangeAttributes.js +24 -0
  97. package/dist/docx/serializer/noteSerializer.js +5 -0
  98. package/dist/docx/serializer/numberingSerializer.js +7 -6
  99. package/dist/docx/serializer/paragraphSerializer.d.ts +1 -5
  100. package/dist/docx/serializer/paragraphSerializer.js +47 -52
  101. package/dist/docx/serializer/partNamespaces.js +2 -2
  102. package/dist/docx/serializer/runSerializer.js +57 -31
  103. package/dist/docx/serializer/sectionPropertiesSerializer.js +11 -10
  104. package/dist/docx/serializer/settingsSerializer.js +4 -3
  105. package/dist/docx/serializer/stylesSerializer.js +6 -6
  106. package/dist/docx/serializer/tableSerializer.js +37 -21
  107. package/dist/docx/serializer/textFormattingSerializer.d.ts +2 -3
  108. package/dist/docx/serializer/textFormattingSerializer.js +29 -28
  109. package/dist/docx/serializer/themeSerializer.js +6 -6
  110. package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
  111. package/dist/docx/serializer/xmlUtils.d.ts +1 -2
  112. package/dist/docx/serializer/xmlUtils.js +1 -13
  113. package/dist/docx/server/boundedArchive.d.ts +12 -0
  114. package/dist/docx/server/boundedArchive.js +20 -1
  115. package/dist/docx/server/build.js +8 -1
  116. package/dist/docx/server/createBilingualDocument.js +10 -18
  117. package/dist/docx/server/extractDocxText.js +3 -4
  118. package/dist/docx/server/validateDocxConformance.js +22 -1
  119. package/dist/docx/shadingParser.d.ts +6 -0
  120. package/dist/docx/shadingParser.js +32 -0
  121. package/dist/docx/shapeParser.js +10 -8
  122. package/dist/docx/styleParser.js +13 -87
  123. package/dist/docx/styleReferenceResolution.d.ts +36 -0
  124. package/dist/docx/styleReferenceResolution.js +51 -0
  125. package/dist/docx/tableLook.d.ts +57 -0
  126. package/dist/docx/tableLook.js +63 -0
  127. package/dist/docx/tableParser.d.ts +7 -9
  128. package/dist/docx/tableParser.js +64 -110
  129. package/dist/docx/textBoxParser.js +11 -6
  130. package/dist/docx/trackedMoveRangeNormalization.d.ts +3 -1
  131. package/dist/docx/trackedMoveRangeNormalization.js +11 -21
  132. package/dist/docx/transitionalSpelling.d.ts +13 -2
  133. package/dist/docx/transitionalSpelling.js +23 -1
  134. package/dist/docx/unzip.d.ts +23 -0
  135. package/dist/docx/unzip.js +32 -22
  136. package/dist/docx/verbatimCapture.js +5 -12
  137. package/dist/docx/vmlImageParser.js +5 -4
  138. package/dist/docx/vmlPreview.d.ts +1 -3
  139. package/dist/docx/vmlPreview.js +2 -30
  140. package/dist/docx/watermarkParser.js +2 -2
  141. package/dist/docx/xmlParser.d.ts +38 -33
  142. package/dist/docx/xmlParser.js +92 -47
  143. package/dist/docx/xmlResourceLimits.d.ts +89 -9
  144. package/dist/docx/xmlResourceLimits.js +105 -24
  145. package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
  146. package/dist/internal/paragraphFormattingSerialization.d.ts +2 -3
  147. package/dist/internal/paragraphFormattingSerialization.js +29 -8
  148. package/dist/layout-bridge/convert/footnoteLayout.js +2 -7
  149. package/dist/layout-engine/index.d.ts +2 -2
  150. package/dist/layout-engine/index.js +2 -2
  151. package/dist/layout-engine/measure/measureBlocks.js +1 -6
  152. package/dist/layout-engine/types.d.ts +8 -2
  153. package/dist/layout-engine/types.js +35 -2
  154. package/dist/layout-painter/renderImage.js +4 -3
  155. package/dist/layout-painter/renderParagraph.js +4 -3
  156. package/dist/managers/autoSaveCodec.js +2 -8
  157. package/dist/markdown/images.js +1 -4
  158. package/dist/markdown/index.js +1 -1
  159. package/dist/markdown/internals.d.ts +6 -1
  160. package/dist/markdown/internals.js +14 -1
  161. package/dist/markdown/renderBlock.js +35 -21
  162. package/dist/markdown/renderParagraph.js +14 -5
  163. package/dist/markdown/renderRuns.js +4 -3
  164. package/dist/markdown/renderTable.js +4 -3
  165. package/dist/markdown/trailers.js +41 -7
  166. package/dist/markdown/types.d.ts +3 -7
  167. package/dist/prosemirror/attrs/index.js +71 -5
  168. package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +11 -1
  169. package/dist/prosemirror/bookmarkBoundaryAttrs.js +18 -3
  170. package/dist/prosemirror/commands/image.js +1 -0
  171. package/dist/prosemirror/commands/index.d.ts +3 -3
  172. package/dist/prosemirror/commands/index.js +2 -2
  173. package/dist/prosemirror/commands/paragraph.d.ts +3 -3
  174. package/dist/prosemirror/commands/paragraph.js +2 -2
  175. package/dist/prosemirror/commentIdAllocator.js +2 -7
  176. package/dist/prosemirror/conversion/fromProseDoc.js +197 -68
  177. package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -14
  178. package/dist/prosemirror/conversion/toProseDoc.js +458 -335
  179. package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +14 -1
  180. package/dist/prosemirror/extensions/core/ParagraphExtension.js +11 -6
  181. package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -3
  182. package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
  183. package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +6 -2
  184. package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +7 -0
  185. package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +74 -0
  186. package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
  187. package/dist/prosemirror/extensions/marks/markUtils.d.ts +11 -3
  188. package/dist/prosemirror/extensions/marks/markUtils.js +98 -19
  189. package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +7 -3
  190. package/dist/prosemirror/extensions/nodes/ImageExtension.js +6 -1
  191. package/dist/prosemirror/extensions/nodes/ShapeExtension.js +8 -2
  192. package/dist/prosemirror/extensions/nodes/TableExtension.js +15 -1
  193. package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +8 -4
  194. package/dist/prosemirror/extensions/types.d.ts +2 -2
  195. package/dist/prosemirror/index.d.ts +3 -3
  196. package/dist/prosemirror/index.js +3 -3
  197. package/dist/prosemirror/insertOperations.d.ts +9 -2
  198. package/dist/prosemirror/insertOperations.js +9 -4
  199. package/dist/prosemirror/paragraphFormattingProvenance.d.ts +162 -0
  200. package/dist/prosemirror/paragraphFormattingProvenance.js +115 -0
  201. package/dist/prosemirror/plugins/documentStyles.d.ts +9 -1
  202. package/dist/prosemirror/plugins/documentStyles.js +11 -1
  203. package/dist/prosemirror/plugins/index.d.ts +2 -2
  204. package/dist/prosemirror/plugins/index.js +2 -2
  205. package/dist/prosemirror/plugins/revisionIds.d.ts +11 -2
  206. package/dist/prosemirror/plugins/revisionIds.js +21 -6
  207. package/dist/prosemirror/runFormattingReconciliation.js +3 -2
  208. package/dist/prosemirror/runStyleFormatting.d.ts +1 -1
  209. package/dist/prosemirror/schema/nodes.d.ts +81 -1
  210. package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -0
  211. package/dist/prosemirror/styles/styleResolver.d.ts +9 -0
  212. package/dist/prosemirror/styles/styleResolver.js +12 -0
  213. package/dist/style-engine/styleEngine.d.ts +3 -0
  214. package/dist/style-engine/styleEngine.js +3 -0
  215. package/dist/style-sets/extract.js +1 -23
  216. package/dist/style-sets/stellaStyle.js +46 -39
  217. package/dist/style-sets/styleSetNormalization.d.ts +19 -0
  218. package/dist/style-sets/styleSetNormalization.js +99 -0
  219. package/dist/types/content.d.ts +2 -2
  220. package/dist/utils/base64.d.ts +36 -0
  221. package/dist/utils/base64.js +40 -0
  222. package/dist/utils/clipboard.js +2 -1
  223. package/dist/utils/createDocument.js +145 -20
  224. package/dist/utils/headingCollector.d.ts +8 -5
  225. package/dist/utils/headingCollector.js +23 -25
  226. package/dist/utils/tableOfContentsStyle.js +9 -2
  227. package/dist/utils/units.d.ts +10 -1
  228. package/dist/utils/units.js +12 -1
  229. package/dist/utils/urlSecurity.d.ts +8 -2
  230. package/dist/utils/urlSecurity.js +21 -3
  231. package/package.json +2 -2
  232. package/dist/docx/textWhitespace.d.ts +0 -4
  233. package/dist/docx/textWhitespace.js +0 -4
  234. package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -6
  235. package/dist/layout-bridge/engine/tableWidthUtils.js +0 -25
  236. package/dist/markdown/headings.d.ts +0 -13
  237. package/dist/markdown/headings.js +0 -20
@@ -10,12 +10,13 @@ import { OUTLINE_STYLE_CSS_ALIASES, normalizeShapeTextAnchor } from "../../types
10
10
  import { canonicalJson } from "../../utils/canonicalJson.js";
11
11
  import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
12
12
  import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
13
- import { pixelsToEmu } from "../../utils/units.js";
13
+ import { emuToPixels, emuToStrokePixels, pixelsToEmu } from "../../utils/units.js";
14
14
  import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
15
15
  import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
16
- import { expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
16
+ import { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
17
17
  import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges } from "../commands/propertyChangeScope.js";
18
18
  import { applyRunFormattingOverrideAttrs, buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
19
+ import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
19
20
  import { listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
20
21
  import { resolveNumberedRefFields } from "../numberedRefFields.js";
21
22
  import { directParagraphAlignment } from "../paragraphAlignment.js";
@@ -24,12 +25,12 @@ import { directParagraphSpacing } from "../paragraphSpacing.js";
24
25
  import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
25
26
  import { authoredRunFormattingFromAttrs, hasAuthoredRunFormattingProvenance } from "../runFormattingProvenance.js";
26
27
  import { paragraphFormattingForRun, paragraphRunStyleContext, resolveEffectiveRunStyleFormatting, suppressParagraphMarkFormatting } from "../runStyleFormatting.js";
28
+ import { schema } from "../schema/index.js";
27
29
  import { parseShapeGeometryAdjustments } from "../shapeGeometryAdjustments.js";
28
30
  import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
29
31
  import { assertValidProseMirrorDocument } from "../validation.js";
30
32
  import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "./runShadingMark.js";
31
33
  import { decodeSdtListItems, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs } from "./sdtAttrs.js";
32
- import { textFormattingToMarks } from "./toProseDoc.js";
33
34
  import { panic } from "better-result";
34
35
  import { Fragment } from "prosemirror-model";
35
36
  import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
@@ -78,14 +79,35 @@ function imagePositionFromAttrs(attrs) {
78
79
  vertical
79
80
  };
80
81
  }
82
+ /**
83
+ * The EMUs behind one pixel attribute of a drawing.
84
+ *
85
+ * `toProseDoc` carries the authored EMU beside every pixel value it derived,
86
+ * because EMU → px → EMU does not land back on the same number. While the
87
+ * pixel attribute still projects from the authored EMU nothing has moved it,
88
+ * so the document gets its own value back; once an editor command has, the
89
+ * pixel attribute is the truth and converts.
90
+ */
91
+ const emuFromPixels = (px, key, authored, project) => {
92
+ const emu = authored?.[key];
93
+ return emu !== void 0 && project(emu) === px ? emu : pixelsToEmu(px);
94
+ };
95
+ /**
96
+ * Copy the wrap insets onto a wrap. Shared by the image, shape and text-box
97
+ * paths so one rule decides when an inset keeps its authored EMU.
98
+ */
99
+ const assignWrapDistances = (wrap, attrs) => {
100
+ const authored = attrs._docxAuthoredEmu;
101
+ if (attrs.distTop !== void 0) wrap.distT = emuFromPixels(attrs.distTop, "distTop", authored, emuToPixels);
102
+ if (attrs.distBottom !== void 0) wrap.distB = emuFromPixels(attrs.distBottom, "distBottom", authored, emuToPixels);
103
+ if (attrs.distLeft !== void 0) wrap.distL = emuFromPixels(attrs.distLeft, "distLeft", authored, emuToPixels);
104
+ if (attrs.distRight !== void 0) wrap.distR = emuFromPixels(attrs.distRight, "distRight", authored, emuToPixels);
105
+ };
81
106
  function textBoxWrapFromAttrs(attrs) {
82
107
  if (!(attrs.wrapType !== void 0 && attrs.wrapType !== "inline" || attrs.wrapText !== void 0 || attrs.distTop !== void 0 || attrs.distBottom !== void 0 || attrs.distLeft !== void 0 || attrs.distRight !== void 0)) return;
83
108
  const wrap = { type: attrs.wrapType ?? "inline" };
84
109
  if (attrs.wrapText !== void 0) wrap.wrapText = attrs.wrapText;
85
- if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
86
- if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
87
- if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
88
- if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
110
+ assignWrapDistances(wrap, attrs);
89
111
  return wrap;
90
112
  }
91
113
  const assignUniqueParagraph = (paragraphs, paraId, paragraph) => {
@@ -271,7 +293,7 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
271
293
  styleResolver
272
294
  }) : paragraphFormatting, previousFormatting);
273
295
  next = next.filter((mark) => !RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
274
- for (const restored of textFormattingToMarks(effectivePreviousFormatting, {
296
+ for (const restored of textFormattingToMarks(effectivePreviousFormatting, schema, {
275
297
  overrideFormatting: previousFormatting,
276
298
  directFormatting: previousFormatting
277
299
  })) next = restored.addToSet(next);
@@ -645,17 +667,47 @@ function replaceTextBoxAnchorInBlocks(blocks, marker, textBoxRun) {
645
667
  }
646
668
  return false;
647
669
  }
670
+ /**
671
+ * The inline list a text-box anchor run can be spliced out of, or nothing when
672
+ * the item holds no such list.
673
+ *
674
+ * A complex field keeps its runs in `fieldCode`/`fieldResult`, two arrays
675
+ * rather than one, and an anchor has never been placed in either; splicing one
676
+ * would have to pick a side. The marker stays where it is and
677
+ * `removeUnresolvedTextBoxAnchors` leaves it, as before.
678
+ */
679
+ const textBoxAnchorHost = (item) => {
680
+ switch (item.type) {
681
+ case "hyperlink": return item.children;
682
+ case "simpleField": return item.content;
683
+ case "inlineSdt":
684
+ case "insertion":
685
+ case "deletion":
686
+ case "moveFrom":
687
+ case "moveTo":
688
+ case "bidiWrapper": return item.content;
689
+ case "run":
690
+ case "complexField":
691
+ case "bookmarkStart":
692
+ case "bookmarkEnd":
693
+ case "commentRangeStart":
694
+ case "commentRangeEnd":
695
+ case "commentReference":
696
+ case "moveFromRangeStart":
697
+ case "moveFromRangeEnd":
698
+ case "moveToRangeStart":
699
+ case "moveToRangeEnd":
700
+ case "mathEquation": return;
701
+ default: panic(`Unsupported paragraph content: ${JSON.stringify(item)}`);
702
+ }
703
+ };
648
704
  function editTextBoxAnchorInContent(content, marker, replacement) {
649
- for (let index = 0; index < content.length; index += 1) {
650
- const item = content[index];
705
+ for (const [index, item] of content.entries()) {
651
706
  if (item === marker) {
652
707
  content.splice(index, 1, ...replacement ? [replacement] : []);
653
708
  return true;
654
709
  }
655
- let nestedContent;
656
- if (item?.type === "hyperlink") nestedContent = item.children;
657
- else if (item?.type === "simpleField") nestedContent = item.content;
658
- else if (item?.type === "inlineSdt" || item?.type === "insertion" || item?.type === "deletion" || item?.type === "moveFrom" || item?.type === "moveTo") nestedContent = item.content;
710
+ const nestedContent = textBoxAnchorHost(item);
659
711
  if (!nestedContent) continue;
660
712
  const hadContent = nestedContent.length > 0;
661
713
  if (editTextBoxAnchorInContent(nestedContent, marker, replacement)) {
@@ -800,8 +852,23 @@ const propertyChangeFromAttrs = (change) => {
800
852
  ...currentFormatting !== void 0 && { currentFormatting }
801
853
  };
802
854
  };
855
+ /**
856
+ * What the paragraph states itself for one `w:pPr` field, as opposed to what
857
+ * the style cascade resolved into the same attr.
858
+ *
859
+ * `undefined` means the paragraph states nothing and the field must stay
860
+ * absent: a materialised value is a direct override that outranks the style it
861
+ * was read from, and a later edit to that style no longer reaches the
862
+ * paragraph. A value the source stated directly is always authored, even when
863
+ * it happens to equal the style's.
864
+ */
865
+ const authoredParagraphValue = (field, value, orig, resolved) => {
866
+ if (value === void 0) return;
867
+ if (orig?.[field] !== void 0) return value;
868
+ return sameResolvedValue(value, resolved?.[field]) ? void 0 : value;
869
+ };
803
870
  function assignBooleanToggle(result, attrs, orig, key) {
804
- const value = attrs[key] ?? void 0;
871
+ const value = authoredParagraphValue(key, attrs[key] ?? void 0, orig, attrs._resolvedFormatting);
805
872
  if (value === (orig[key] ?? void 0)) return;
806
873
  if (value === void 0) Reflect.deleteProperty(result, key);
807
874
  else result[key] = value;
@@ -860,20 +927,41 @@ function paragraphAttrsToFormatting(attrs) {
860
927
  else delete result.styleId;
861
928
  assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
862
929
  assignBooleanToggle(result, attrs, orig, "widowControl");
930
+ assignBooleanToggle(result, attrs, orig, "keepNext");
931
+ assignBooleanToggle(result, attrs, orig, "keepLines");
932
+ assignBooleanToggle(result, attrs, orig, "runInWithNext");
863
933
  assignBooleanToggle(result, attrs, orig, "snapToGrid");
864
934
  assignBooleanToggle(result, attrs, orig, "kinsoku");
865
935
  assignBooleanToggle(result, attrs, orig, "overflowPunctuation");
866
936
  assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
867
937
  if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
868
938
  else delete result.spacingExplicit;
869
- const bidi = directionToBidi(attrs.direction);
939
+ const bidi = authoredParagraphValue("bidi", directionToBidi(attrs.direction), orig, attrs._resolvedFormatting);
870
940
  if (bidi !== (orig.bidi ?? void 0)) if (bidi === void 0) delete result.bidi;
871
941
  else result.bidi = bidi;
872
942
  return result;
873
943
  }
874
- const outlineLevel = Reflect.get(attrs, "outlineLevel");
875
- const bidi = directionToBidi(attrs.direction);
876
- if (!(directAlignment !== void 0 || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || hasDirectLineSpacing || hasDirectLineSpacingRule || attrs.snapToGrid != null || attrs.indentLeft || attrs.indentRight || attrs.indentFirstLine || attrs.numPr || attrs.styleId || attrs.borders || attrs.shading || attrs.tabs || typeof outlineLevel === "number" || attrs.contextualSpacing || attrs.spacingExplicit || bidi != null || attrs.pageBreakBefore != null || attrs.widowControl != null || attrs.kinsoku != null || attrs.overflowPunctuation != null || attrs.suppressAutoHyphens != null)) return;
944
+ const resolved = attrs._resolvedFormatting;
945
+ const authored = (field, value) => authoredParagraphValue(field, value ?? void 0, void 0, resolved);
946
+ const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
947
+ const bidi = authored("bidi", directionToBidi(attrs.direction));
948
+ const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
949
+ const indentLeft = authored("indentLeft", attrs.indentLeft);
950
+ const indentRight = authored("indentRight", attrs.indentRight);
951
+ const indentFirstLine = authored("indentFirstLine", attrs.indentFirstLine);
952
+ const borders = authored("borders", attrs.borders);
953
+ const shading = authored("shading", attrs.shading);
954
+ const tabs = authored("tabs", attrs.tabs);
955
+ const contextualSpacing = authored("contextualSpacing", attrs.contextualSpacing);
956
+ const pageBreakBefore = authored("pageBreakBefore", attrs.pageBreakBefore);
957
+ const widowControl = authored("widowControl", attrs.widowControl);
958
+ const keepNext = authored("keepNext", attrs.keepNext);
959
+ const keepLines = authored("keepLines", attrs.keepLines);
960
+ const runInWithNext = authored("runInWithNext", attrs.runInWithNext);
961
+ const kinsoku = authored("kinsoku", attrs.kinsoku);
962
+ const overflowPunctuation = authored("overflowPunctuation", attrs.overflowPunctuation);
963
+ const suppressAutoHyphens = authored("suppressAutoHyphens", attrs.suppressAutoHyphens);
964
+ if (!(directAlignment !== void 0 || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || hasDirectLineSpacing || hasDirectLineSpacingRule || snapToGrid != null || indentLeft || indentRight || indentFirstLine || attrs.numPr || attrs.styleId || borders || shading || tabs || typeof outlineLevel === "number" || contextualSpacing || attrs.spacingExplicit || bidi != null || pageBreakBefore != null || widowControl != null || keepNext != null || keepLines != null || runInWithNext != null || kinsoku != null || overflowPunctuation != null || suppressAutoHyphens != null)) return;
877
965
  const f = {};
878
966
  if (directAlignment !== void 0) f.alignment = directAlignment;
879
967
  if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
@@ -882,25 +970,28 @@ function paragraphAttrsToFormatting(attrs) {
882
970
  if (afterAutospacingEdited) f.afterAutospacing = false;
883
971
  if (hasDirectLineSpacing && typeof attrs.lineSpacing === "number") f.lineSpacing = attrs.lineSpacing;
884
972
  if (hasDirectLineSpacingRule && attrs.lineSpacingRule) f.lineSpacingRule = attrs.lineSpacingRule;
885
- if (attrs.snapToGrid != null) f.snapToGrid = attrs.snapToGrid;
973
+ if (snapToGrid != null) f.snapToGrid = snapToGrid;
886
974
  if (attrs.spacingExplicit) f.spacingExplicit = attrs.spacingExplicit;
887
- if (attrs.indentLeft) f.indentLeft = attrs.indentLeft;
888
- if (attrs.indentRight) f.indentRight = attrs.indentRight;
889
- if (attrs.indentFirstLine) f.indentFirstLine = attrs.indentFirstLine;
890
- if (attrs.hangingIndent) f.hangingIndent = attrs.hangingIndent;
975
+ if (indentLeft) f.indentLeft = indentLeft;
976
+ if (indentRight) f.indentRight = indentRight;
977
+ if (indentFirstLine) f.indentFirstLine = indentFirstLine;
978
+ if (attrs.hangingIndent && indentFirstLine) f.hangingIndent = attrs.hangingIndent;
891
979
  if (attrs.numPr && !isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) f.numPr = attrs.numPr;
892
980
  if (attrs.styleId) f.styleId = attrs.styleId;
893
- if (attrs.borders) f.borders = attrs.borders;
894
- if (attrs.shading) f.shading = attrs.shading;
895
- if (attrs.tabs) f.tabs = attrs.tabs;
981
+ if (borders) f.borders = borders;
982
+ if (shading) f.shading = shading;
983
+ if (tabs) f.tabs = tabs;
896
984
  if (typeof outlineLevel === "number") f.outlineLevel = outlineLevel;
897
- if (attrs.contextualSpacing) f.contextualSpacing = attrs.contextualSpacing;
985
+ if (contextualSpacing) f.contextualSpacing = contextualSpacing;
898
986
  if (bidi != null) f.bidi = bidi;
899
- if (attrs.pageBreakBefore != null) f.pageBreakBefore = attrs.pageBreakBefore;
900
- if (attrs.widowControl != null) f.widowControl = attrs.widowControl;
901
- if (attrs.kinsoku != null) f.kinsoku = attrs.kinsoku;
902
- if (attrs.overflowPunctuation != null) f.overflowPunctuation = attrs.overflowPunctuation;
903
- if (attrs.suppressAutoHyphens != null) f.suppressAutoHyphens = attrs.suppressAutoHyphens;
987
+ if (pageBreakBefore != null) f.pageBreakBefore = pageBreakBefore;
988
+ if (widowControl != null) f.widowControl = widowControl;
989
+ if (keepNext != null) f.keepNext = keepNext;
990
+ if (keepLines != null) f.keepLines = keepLines;
991
+ if (runInWithNext != null) f.runInWithNext = runInWithNext;
992
+ if (kinsoku != null) f.kinsoku = kinsoku;
993
+ if (overflowPunctuation != null) f.overflowPunctuation = overflowPunctuation;
994
+ if (suppressAutoHyphens != null) f.suppressAutoHyphens = suppressAutoHyphens;
904
995
  return f;
905
996
  }
906
997
  function createTrackedRunWrapper(type, info, child) {
@@ -1143,10 +1234,12 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1143
1234
  id: attrs.id,
1144
1235
  name: attrs.name,
1145
1236
  ...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
1146
- ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
1237
+ ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
1238
+ ...bookmarkBoundaryDisplacement(attrs)
1147
1239
  } : {
1148
1240
  type: "bookmarkEnd",
1149
- id: attrs.id
1241
+ id: attrs.id,
1242
+ ...bookmarkBoundaryDisplacement(attrs)
1150
1243
  };
1151
1244
  currentTrackedChange.wrapper.content.push(boundary);
1152
1245
  return;
@@ -1209,11 +1302,13 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
1209
1302
  id: attrs.id,
1210
1303
  name: attrs.name,
1211
1304
  ...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
1212
- ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
1305
+ ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
1306
+ ...bookmarkBoundaryDisplacement(attrs)
1213
1307
  });
1214
1308
  else content.push({
1215
1309
  type: "bookmarkEnd",
1216
- id: attrs.id
1310
+ id: attrs.id,
1311
+ ...bookmarkBoundaryDisplacement(attrs)
1217
1312
  });
1218
1313
  } else if (node.isText) appendDirectRun(node, createRunFromText({
1219
1314
  ...formattingContext,
@@ -1426,11 +1521,13 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
1426
1521
  id: attrs.id,
1427
1522
  name: attrs.name,
1428
1523
  ...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
1429
- ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
1524
+ ...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
1525
+ ...bookmarkBoundaryDisplacement(attrs)
1430
1526
  });
1431
1527
  else hyperlink.children.push({
1432
1528
  type: "bookmarkEnd",
1433
- id: attrs.id
1529
+ id: attrs.id,
1530
+ ...bookmarkBoundaryDisplacement(attrs)
1434
1531
  });
1435
1532
  return;
1436
1533
  }
@@ -1818,21 +1915,27 @@ function createInlineSdtFromNode(node, textBoxAnchorMarkers, formattingContext)
1818
1915
  /**
1819
1916
  * Create a Run containing an image
1820
1917
  */
1918
+ /**
1919
+ * Restore the `w:rPr` an inline atom carried from its source run.
1920
+ *
1921
+ * Image and shape nodes do not hold the run's formatting marks
1922
+ * (`withRunBoundaryMarks` in toProseDoc keeps them off), so the run rebuilt
1923
+ * around one has no other record of the properties it was authored with.
1924
+ */
1925
+ const carriedRunFormatting = (formatting) => formatting && Object.keys(formatting).length > 0 ? { formatting } : {};
1821
1926
  function createImageRun(node) {
1822
1927
  const attrs = expectImageAttrs(node);
1823
1928
  const wrap = { type: attrs.wrapType || "inline" };
1824
- if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
1825
- if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
1826
- if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
1827
- if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
1929
+ assignWrapDistances(wrap, attrs);
1828
1930
  if (attrs.wrapText) wrap.wrapText = attrs.wrapText;
1931
+ const authoredEmu = attrs._docxAuthoredEmu;
1829
1932
  const image = {
1830
1933
  type: "image",
1831
1934
  rId: attrs.rId || "",
1832
1935
  src: attrs.src,
1833
1936
  size: {
1834
- width: pixelsToEmu(attrs.width || 0),
1835
- height: pixelsToEmu(attrs.height || 0)
1937
+ width: emuFromPixels(attrs.width || 0, "width", authoredEmu, emuToPixels),
1938
+ height: emuFromPixels(attrs.height || 0, "height", authoredEmu, emuToPixels)
1836
1939
  },
1837
1940
  wrap
1838
1941
  };
@@ -1845,10 +1948,13 @@ function createImageRun(node) {
1845
1948
  const imagePosition = imagePositionFromAttrs(attrs.position);
1846
1949
  if (imagePosition) image.position = imagePosition;
1847
1950
  if (attrs.layoutInCell !== void 0) image.layoutInCell = attrs.layoutInCell;
1951
+ if (attrs.decorative !== void 0) image.decorative = attrs.decorative;
1952
+ if (attrs.hidden !== void 0) image.hidden = attrs.hidden;
1953
+ if (attrs.docPrExtensions !== void 0) image.docPrExtensions = [...attrs.docPrExtensions];
1848
1954
  if (attrs.frameLocks !== void 0) image.frameLocks = { ...attrs.frameLocks };
1849
1955
  if (attrs.borderWidth && attrs.borderWidth > 0) {
1850
1956
  const outline = {
1851
- width: pixelsToEmu(attrs.borderWidth),
1957
+ width: emuFromPixels(attrs.borderWidth, "borderWidth", authoredEmu, emuToStrokePixels),
1852
1958
  style: attrs.borderStyle ? {
1853
1959
  solid: "solid",
1854
1960
  dotted: "dot",
@@ -1888,6 +1994,7 @@ function createImageRun(node) {
1888
1994
  }
1889
1995
  return {
1890
1996
  type: "run",
1997
+ ...carriedRunFormatting(attrs._docxRunFormatting),
1891
1998
  content: [drawingFromImageAttrs(image, attrs)]
1892
1999
  };
1893
2000
  }
@@ -1927,24 +2034,25 @@ const drawingFromImageAttrs = (image, attrs) => {
1927
2034
  */
1928
2035
  function createShapeRun(node) {
1929
2036
  const attrs = expectShapeAttrs(node);
2037
+ const authoredEmu = attrs._docxAuthoredEmu;
1930
2038
  const shape = {
1931
2039
  type: "shape",
1932
2040
  shapeType: attrs.shapeType || "rect",
1933
2041
  size: {
1934
- width: attrs.width ? pixelsToEmu(attrs.width) : 0,
1935
- height: attrs.height ? pixelsToEmu(attrs.height) : 0
2042
+ width: attrs.width ? emuFromPixels(attrs.width, "width", authoredEmu, emuToPixels) : 0,
2043
+ height: attrs.height ? emuFromPixels(attrs.height, "height", authoredEmu, emuToPixels) : 0
1936
2044
  }
1937
2045
  };
1938
2046
  if (attrs.shapeId) shape.id = attrs.shapeId;
2047
+ if (attrs.shapeName !== void 0) shape.name = attrs.shapeName;
2048
+ if (attrs.alt !== void 0) shape.alt = attrs.alt;
2049
+ if (attrs.title !== void 0) shape.title = attrs.title;
1939
2050
  const geometryAdjustments = parseShapeGeometryAdjustments(attrs.geometryAdjustments);
1940
2051
  if (geometryAdjustments !== void 0) shape.geometryAdjustments = geometryAdjustments;
1941
2052
  const shapeTransform = parseTransformAttr(attrs.transform);
1942
2053
  if (shapeTransform) shape.transform = shapeTransform;
1943
2054
  const wrap = { type: attrs.wrapType || "inline" };
1944
- if (attrs.distTop !== void 0) wrap.distT = pixelsToEmu(attrs.distTop);
1945
- if (attrs.distBottom !== void 0) wrap.distB = pixelsToEmu(attrs.distBottom);
1946
- if (attrs.distLeft !== void 0) wrap.distL = pixelsToEmu(attrs.distLeft);
1947
- if (attrs.distRight !== void 0) wrap.distR = pixelsToEmu(attrs.distRight);
2055
+ assignWrapDistances(wrap, attrs);
1948
2056
  if (attrs.wrapText) wrap.wrapText = attrs.wrapText;
1949
2057
  shape.wrap = wrap;
1950
2058
  const shapePosition = imagePositionFromAttrs(attrs.position);
@@ -1974,22 +2082,28 @@ function createShapeRun(node) {
1974
2082
  color: attrs.fillColorValue ?? { rgb: attrs.fillColor.replace("#", "") }
1975
2083
  };
1976
2084
  else if (attrs.fillType === "none") shape.fill = { type: "none" };
1977
- if (attrs.outlineStyle !== "none" && (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0 || attrs.outlineColor || attrs.outlineStyle || attrs.outlineCap || attrs.outlineHeadEnd || attrs.outlineTailEnd)) {
2085
+ if (attrs.outlineStyle !== "none" && (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0 || attrs.outlineColor || attrs.outlineStyle || attrs.outlineCap || attrs.outlineJoin || attrs.outlineHeadEnd || attrs.outlineTailEnd)) {
1978
2086
  const shapeOutline = {};
1979
- if (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0) shapeOutline.width = pixelsToEmu(attrs.outlineWidth);
1980
- if (attrs.outlineStyle) shapeOutline.style = normalizeShapeOutlineStyle(attrs.outlineStyle) ?? "solid";
2087
+ if (attrs.outlineWidth !== void 0 && attrs.outlineWidth > 0) shapeOutline.width = emuFromPixels(attrs.outlineWidth, "outlineWidth", authoredEmu, emuToStrokePixels);
2088
+ if (attrs.outlineStyle) {
2089
+ const style = normalizeShapeOutlineStyle(attrs.outlineStyle);
2090
+ if (style !== void 0) shapeOutline.style = style;
2091
+ }
1981
2092
  if (attrs.outlineCap) shapeOutline.cap = attrs.outlineCap;
2093
+ if (attrs.outlineJoin) shapeOutline.join = attrs.outlineJoin;
1982
2094
  if (attrs.outlineHeadEnd) shapeOutline.headEnd = attrs.outlineHeadEnd;
1983
2095
  if (attrs.outlineTailEnd) shapeOutline.tailEnd = attrs.outlineTailEnd;
1984
2096
  if (attrs.outlineColor) shapeOutline.color = attrs.outlineColorValue ?? { rgb: attrs.outlineColor.replace("#", "") };
1985
2097
  shape.outline = shapeOutline;
1986
2098
  }
2099
+ const shapeContent = {
2100
+ type: "shape",
2101
+ shape
2102
+ };
1987
2103
  return {
1988
2104
  type: "run",
1989
- content: [{
1990
- type: "shape",
1991
- shape
1992
- }]
2105
+ ...carriedRunFormatting(attrs._docxRunFormatting),
2106
+ content: [shapeContent]
1993
2107
  };
1994
2108
  }
1995
2109
  const RUN_FORMATTING_VISUAL_GROUPS = {
@@ -2550,6 +2664,17 @@ function marksToTextFormatting(marks, options) {
2550
2664
  /**
2551
2665
  * Convert a ProseMirror table node to our Table type
2552
2666
  */
2667
+ /**
2668
+ * A table the editor created carries no `w:tblPr`, so the borders its cells
2669
+ * were built with are the only record of what the table looks like. Lift the
2670
+ * first bordered cell's set to the table.
2671
+ *
2672
+ * Only for such a table: a table read from a package states its own
2673
+ * `w:tblBorders` or deliberately states none, and its cells' borders may be
2674
+ * the table style's rather than their own. Inferring there invents a
2675
+ * `w:tblBorders` the source never had, and it outranks the table style on
2676
+ * reload (`formatting.borders: absent became object` in the corpus census).
2677
+ */
2553
2678
  function inferTableBorders(rows) {
2554
2679
  for (const row of rows) for (const cell of row.cells) {
2555
2680
  const borders = cell.formatting?.borders;
@@ -2571,7 +2696,7 @@ function convertPMTable(node, documentCounts, styleResolver = null) {
2571
2696
  const attrs = expectTableAttrs(node);
2572
2697
  const rows = convertPMTableRows(node, documentCounts, styleResolver);
2573
2698
  const formatting = tableAttrsToFormatting(attrs) || void 0;
2574
- if (!formatting?.borders) {
2699
+ if (!formatting?.borders && !attrs._originalFormatting) {
2575
2700
  const inferredBorders = inferTableBorders(rows);
2576
2701
  if (inferredBorders) if (formatting) formatting.borders = inferredBorders;
2577
2702
  else {
@@ -2590,7 +2715,7 @@ function convertPMTable(node, documentCounts, styleResolver = null) {
2590
2715
  rows
2591
2716
  };
2592
2717
  if (attrs.columnWidths) table.columnWidths = attrs.columnWidths;
2593
- if (formatting) table.formatting = formatting;
2718
+ if (formatting && Object.keys(formatting).length > 0) table.formatting = formatting;
2594
2719
  restoreTablePropertyChanges(table, attrs);
2595
2720
  return table;
2596
2721
  }
@@ -2926,6 +3051,7 @@ const projectTextBoxBodyContent = (state, blocks) => {
2926
3051
  */
2927
3052
  function convertPMTextBox(node, styleResolver = null) {
2928
3053
  const attrs = expectTextBoxAttrs(node);
3054
+ const authoredEmu = attrs._docxAuthoredEmu;
2929
3055
  const verticalAlign = normalizeShapeTextAnchor(attrs.verticalAlign);
2930
3056
  const childBlocks = [];
2931
3057
  node.forEach((child) => {
@@ -2937,8 +3063,8 @@ function convertPMTextBox(node, styleResolver = null) {
2937
3063
  type: "shape",
2938
3064
  shapeType: "textBox",
2939
3065
  size: {
2940
- width: attrs.width ? pixelsToEmu(attrs.width) : 0,
2941
- height: attrs.height ? pixelsToEmu(attrs.height) : 0
3066
+ width: attrs.width ? emuFromPixels(attrs.width, "width", authoredEmu, emuToPixels) : 0,
3067
+ height: attrs.height ? emuFromPixels(attrs.height, "height", authoredEmu, emuToPixels) : 0
2942
3068
  },
2943
3069
  textBody: {
2944
3070
  content: textBodyContent.type === "source-empty" ? [] : textBodyContent.content,
@@ -2948,15 +3074,18 @@ function convertPMTextBox(node, styleResolver = null) {
2948
3074
  ...verticalAlign !== void 0 ? { anchor: verticalAlign } : {},
2949
3075
  margins: (() => {
2950
3076
  const m = {};
2951
- if (typeof attrs.marginTop === "number") m.top = pixelsToEmu(attrs.marginTop);
2952
- if (typeof attrs.marginBottom === "number") m.bottom = pixelsToEmu(attrs.marginBottom);
2953
- if (typeof attrs.marginLeft === "number") m.left = pixelsToEmu(attrs.marginLeft);
2954
- if (typeof attrs.marginRight === "number") m.right = pixelsToEmu(attrs.marginRight);
3077
+ if (typeof attrs.marginTop === "number") m.top = emuFromPixels(attrs.marginTop, "marginTop", authoredEmu, emuToPixels);
3078
+ if (typeof attrs.marginBottom === "number") m.bottom = emuFromPixels(attrs.marginBottom, "marginBottom", authoredEmu, emuToPixels);
3079
+ if (typeof attrs.marginLeft === "number") m.left = emuFromPixels(attrs.marginLeft, "marginLeft", authoredEmu, emuToPixels);
3080
+ if (typeof attrs.marginRight === "number") m.right = emuFromPixels(attrs.marginRight, "marginRight", authoredEmu, emuToPixels);
2955
3081
  return m;
2956
3082
  })()
2957
3083
  }
2958
3084
  };
2959
3085
  if (attrs.textBoxId) shape.id = attrs.textBoxId;
3086
+ if (attrs.textBoxName !== void 0) shape.name = attrs.textBoxName;
3087
+ if (attrs.alt !== void 0) shape.alt = attrs.alt;
3088
+ if (attrs.title !== void 0) shape.title = attrs.title;
2960
3089
  const transform = parseTransformAttr(attrs.transform);
2961
3090
  if (transform) shape.transform = transform;
2962
3091
  if (attrs.fillColor) shape.fill = {
@@ -2965,7 +3094,7 @@ function convertPMTextBox(node, styleResolver = null) {
2965
3094
  };
2966
3095
  if (attrs.outlineStyle !== "none" && attrs.outlineWidth && attrs.outlineWidth > 0) {
2967
3096
  const tbOutline = {
2968
- width: pixelsToEmu(attrs.outlineWidth),
3097
+ width: emuFromPixels(attrs.outlineWidth, "outlineWidth", authoredEmu, emuToStrokePixels),
2969
3098
  style: normalizeShapeOutlineStyle(attrs.outlineStyle) ?? "solid"
2970
3099
  };
2971
3100
  if (attrs.outlineColor) tbOutline.color = { rgb: attrs.outlineColor.replace("#", "") };
@@ -1,7 +1,6 @@
1
1
  import { document_d_exports } from "../../types/document.js";
2
2
  import { StyleEngine } from "../../style-engine/styleEngine.js";
3
3
  import "../../style-engine/index.js";
4
- import { schema } from "../schema/index.js";
5
4
  import { Node } from "prosemirror-model";
6
5
  //#region src/prosemirror/conversion/toProseDoc.d.ts
7
6
  type UnsupportedDocxToProseMirrorOwner = "complex-field-instruction" | "field-result" | "page-break-bearing-run" | "paragraph-borders" | "paragraph-frame" | "paragraph-outline" | "paragraph-text-box-anchor" | "table-cell" | "text-box";
@@ -39,18 +38,6 @@ declare function resolveParagraphDefaultTextFormatting(styleId: string | undefin
39
38
  includeParagraphMarkRunProperties?: boolean;
40
39
  }): document_d_exports.TextFormatting | undefined;
41
40
  declare function standaloneTableCellToProseMirror(cell: document_d_exports.TableCell, nodeType: "tableCell" | "tableHeader"): Node;
42
- type AuthoredRunFormattingCarrier = "preserve" | "reconstruct";
43
- /**
44
- * Convert TextFormatting to ProseMirror marks
45
- */
46
- type TextFormattingToMarksOptions = {
47
- overrideFormatting: document_d_exports.TextFormatting | undefined;
48
- /** Direct standard font properties whose authored provenance must survive. */
49
- directFormatting?: document_d_exports.TextFormatting | undefined;
50
- /** Whether direct authorship is reconstructible from structural marks and the style context. */
51
- authoredCarrier?: AuthoredRunFormattingCarrier;
52
- };
53
- declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting | undefined, options?: TextFormattingToMarksOptions): ReturnType<typeof schema.mark>[];
54
41
  /**
55
42
  * Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document.
56
43
  * Used for editing headers/footers in their own ProseMirror editor and for
@@ -66,4 +53,4 @@ declare function footnoteToProseDoc(content: document_d_exports.BlockContent[],
66
53
  */
67
54
  declare function createEmptyDoc(): Node;
68
55
  //#endregion
69
- export { ToProseDocOptions, UnsupportedDocxToProseMirrorConversionError, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, resolveParagraphDefaultTextFormatting, standaloneTableCellToProseMirror, textFormattingToMarks, toProseDoc };
56
+ export { ToProseDocOptions, UnsupportedDocxToProseMirrorConversionError, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, resolveParagraphDefaultTextFormatting, standaloneTableCellToProseMirror, toProseDoc };