@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
@@ -21,6 +21,19 @@ declare function getParagraphAlignment(state: EditorState): document_d_exports.P
21
21
  declare function getParagraphTabs(state: EditorState): document_d_exports.TabStop[] | null;
22
22
  declare function getStyleId(state: EditorState): string | null;
23
23
  declare function getParagraphBidi(state: EditorState): boolean;
24
+ /**
25
+ * What a generated table of contents needs from its caller.
26
+ *
27
+ * The title is the caller's because this layer has no locale: a command in
28
+ * `@stll/folio-core` cannot know whether the document should read "Table of
29
+ * Contents", "Obsah" or "Inhaltsverzeichnis", and a hardcoded English string
30
+ * is wrong in every document that is not in English. The host passes the
31
+ * string it already renders its own UI with.
32
+ */
33
+ type GenerateTableOfContentsOptions = {
34
+ /** Heading text for the table, in the document's language. */
35
+ title: string;
36
+ };
24
37
  declare const ParagraphExtension: (options?: Partial<Record<string, unknown>> | undefined) => NodeExtension;
25
38
  //#endregion
26
- export { ParagraphExtension, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId };
39
+ export { GenerateTableOfContentsOptions, ParagraphExtension, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getParagraphTabs, getStyleId };
@@ -1,3 +1,4 @@
1
+ import { BUILT_IN_STYLE_NAME } from "../../../docx/builtInStyles.js";
1
2
  import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR } from "../../../docx/paragraphPropertySource.js";
2
3
  import { PARAGRAPH_ALIGNMENT_VALUES } from "../../../types/documentEnumValues.js";
3
4
  import { paragraphToStyle } from "../../../utils/formatToStyle.js";
@@ -8,6 +9,7 @@ import { autospacingMatchesBase } from "../../autospacingBase.js";
8
9
  import { directParagraphAlignment } from "../../paragraphAlignment.js";
9
10
  import { directionIsRtl } from "../../paragraphDirection.js";
10
11
  import { withDirectParagraphSpacing } from "../../paragraphSpacing.js";
12
+ import { getDocumentBuiltInStyles } from "../../plugins/documentStyles.js";
11
13
  import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
12
14
  import { createNodeExtension } from "../create.js";
13
15
  import { Fragment } from "prosemirror-model";
@@ -248,6 +250,7 @@ const paragraphNodeSpec = {
248
250
  bookmarks: { default: null },
249
251
  _emptyHyperlinks: { default: null },
250
252
  _originalFormatting: { default: null },
253
+ _resolvedFormatting: { default: void 0 },
251
254
  _autospacingBase: { default: null },
252
255
  _sectionProperties: { default: null },
253
256
  _propertyChanges: { default: null },
@@ -602,8 +605,9 @@ const ParagraphExtension = createNodeExtension({
602
605
  }),
603
606
  insertSectionBreak: (breakType) => setParagraphAttr("sectionBreakType", breakType),
604
607
  removeSectionBreak: () => setParagraphAttr("sectionBreakType", null),
605
- generateTOC: () => (state, dispatch) => {
606
- const headings = collectHeadings(state.doc);
608
+ generateTOC: ({ title }) => (state, dispatch) => {
609
+ const builtInStyles = getDocumentBuiltInStyles(state);
610
+ const headings = collectHeadings(state.doc, builtInStyles);
607
611
  if (headings.length === 0) return false;
608
612
  if (!dispatch) return true;
609
613
  const { schema: s } = state;
@@ -630,10 +634,11 @@ const ParagraphExtension = createNodeExtension({
630
634
  }
631
635
  }
632
636
  const tocNodes = [];
637
+ const tocHeadingStyleId = builtInStyles.styleIdForBuiltInName(BUILT_IN_STYLE_NAME.tocHeading);
633
638
  tocNodes.push(s.node("paragraph", {
634
- styleId: "TOCHeading",
639
+ ...tocHeadingStyleId === void 0 ? {} : { styleId: tocHeadingStyleId },
635
640
  alignment: "center"
636
- }, [s.text("Table of Contents", s.marks["bold"] ? [s.marks["bold"].create()] : [])]));
641
+ }, [s.text(title, s.marks["bold"] ? [s.marks["bold"].create()] : [])]));
637
642
  const DEFAULT_MARGIN_TWIPS = 1440;
638
643
  let tocTabStopTwips = 12240 - 2 * DEFAULT_MARGIN_TWIPS;
639
644
  let tabStopResolved = false;
@@ -650,7 +655,7 @@ const ParagraphExtension = createNodeExtension({
650
655
  const canPageNumber = Boolean(s.nodes["field"] && s.nodes["tab"]);
651
656
  for (const entry of bookmarkEntries) {
652
657
  const indent = entry.level * 720;
653
- const tocStyleId = `TOC${entry.level + 1}`;
658
+ const tocStyleId = builtInStyles.styleIdForTableOfContentsLevel(entry.level + 1);
654
659
  if (!s.marks["hyperlink"]) continue;
655
660
  const linkMark = s.marks["hyperlink"].create({ href: `#${entry.name}` });
656
661
  const content = [s.text(entry.text, [linkMark])];
@@ -663,7 +668,7 @@ const ParagraphExtension = createNodeExtension({
663
668
  dirty: true
664
669
  }));
665
670
  tocNodes.push(s.node("paragraph", {
666
- styleId: tocStyleId,
671
+ ...tocStyleId === void 0 ? {} : { styleId: tocStyleId },
667
672
  indentLeft: indent > 0 ? indent : null,
668
673
  ...canPageNumber ? { tabs: [{
669
674
  position: tocTabStopTwips,
@@ -7,9 +7,9 @@ const emptyParagraphFormatKey = new PluginKey("emptyParagraphFormat");
7
7
  * Run-formatting properties the painter does NOT reproduce from
8
8
  * `defaultTextFormatting` on its own (it forwards only font family + size).
9
9
  * When an empty paragraph's defaults carry any of these, typed text must
10
- * acquire real marks or it would render unstyled. Kept in sync with the
11
- * properties `textFormattingToMarks` can turn into marks — listing one it
12
- * can't (e.g. allCaps) would gate work that produces nothing.
10
+ * acquire real marks or it would render unstyled. Every property listed here
11
+ * must be one `textFormattingToMarks` can turn into a mark, or the gate would
12
+ * open for work that produces nothing.
13
13
  */
14
14
  function hasNonFontDefaults(dtf) {
15
15
  return !!(dtf.bold || dtf.italic || dtf.underline || dtf.strike || dtf.doubleStrike || dtf.color || dtf.highlight || dtf.vertAlign || dtf.rtl);
@@ -11,7 +11,10 @@ import { Extension } from "../types.js";
11
11
  * default clipboard parser; ProseMirror chains every plugin's
12
12
  * `transformPastedHTML`, so this cooperates with the inliner rather than
13
13
  * replacing it, and `<style>` blocks are left intact for it to resolve.
14
- * 2. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
14
+ * 2. `transformPasted` — drops unpaired bookmark boundaries, then points
15
+ * pasted headings at the open document's own heading style (see
16
+ * {@link retargetPastedHeadingStyles}).
17
+ * 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
15
18
  * the source formatting stripped (see {@link pasteWithoutFormatting}).
16
19
  */
17
20
  type PasteCleanupOptions = {
@@ -2,6 +2,7 @@ import { pasteWithoutFormatting } from "../../commands/pastePlainText.js";
2
2
  import { createExtension } from "../create.js";
3
3
  import { Priority } from "../types.js";
4
4
  import { cleanPastedHtml, removeUnpairedBookmarkBoundaries } from "./pasteCleanup.js";
5
+ import { retargetPastedHeadingStyles } from "./pastedHeadingStyles.js";
5
6
  import { Plugin } from "prosemirror-state";
6
7
  //#region src/prosemirror/extensions/features/PasteCleanupExtension.ts
7
8
  /**
@@ -15,7 +16,10 @@ import { Plugin } from "prosemirror-state";
15
16
  * default clipboard parser; ProseMirror chains every plugin's
16
17
  * `transformPastedHTML`, so this cooperates with the inliner rather than
17
18
  * replacing it, and `<style>` blocks are left intact for it to resolve.
18
- * 2. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
19
+ * 2. `transformPasted` — drops unpaired bookmark boundaries, then points
20
+ * pasted headings at the open document's own heading style (see
21
+ * {@link retargetPastedHeadingStyles}).
22
+ * 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
19
23
  * the source formatting stripped (see {@link pasteWithoutFormatting}).
20
24
  */
21
25
  const PasteCleanupExtension = createExtension({
@@ -28,7 +32,7 @@ const PasteCleanupExtension = createExtension({
28
32
  const internalClipboardToken = options.getInternalClipboardToken?.();
29
33
  return cleanPastedHtml(html, { ...internalClipboardToken ? { internalClipboardToken } : {} });
30
34
  },
31
- transformPasted: removeUnpairedBookmarkBoundaries
35
+ transformPasted: (slice, view) => retargetPastedHeadingStyles(removeUnpairedBookmarkBoundaries(slice), view)
32
36
  } })],
33
37
  keyboardShortcuts: { "Mod-Alt-v": pasteWithoutFormatting }
34
38
  };
@@ -0,0 +1,7 @@
1
+ import { Slice } from "prosemirror-model";
2
+ import { EditorView } from "prosemirror-view";
3
+ //#region src/prosemirror/extensions/features/pastedHeadingStyles.d.ts
4
+ /** A `transformPasted` hook; returns the slice unchanged when nothing matches. */
5
+ declare const retargetPastedHeadingStyles: (slice: Slice, view: EditorView) => Slice;
6
+ //#endregion
7
+ export { retargetPastedHeadingStyles };
@@ -0,0 +1,74 @@
1
+ import { isHeadingOutlineLevel } from "../../../docx/builtInStyles.js";
2
+ import { getDocumentBuiltInStyles, getDocumentStyleResolver } from "../../plugins/documentStyles.js";
3
+ import { Fragment, Slice } from "prosemirror-model";
4
+ //#region src/prosemirror/extensions/features/pastedHeadingStyles.ts
5
+ /**
6
+ * Retarget pasted heading paragraphs at the open document's own heading style.
7
+ *
8
+ * The schema's `h1`–`h6` paste rule runs inside `parseDOM`, which sees no
9
+ * document, so it can only write the English built-in id `Heading1`…`Heading6`.
10
+ * In a document written by a localized Word the heading style is `Nadpis1` or
11
+ * `berschrift2`, and in one folio generated from a style set the deeper levels
12
+ * may not exist at all, so that id resolves to nothing and the pasted heading
13
+ * loses the document's heading formatting.
14
+ *
15
+ * The paragraph still classifies as a heading either way — `parseDOM` also sets
16
+ * `outlineLevel`, which is what `docx/builtInStyles.ts` reads first. This is
17
+ * about which style the text picks up.
18
+ *
19
+ * Deliberately narrow: a paragraph is retargeted only when the document defines
20
+ * no style under the id it carries. Pasting between two folio documents, or
21
+ * within one, never reaches it. Creating a style stays an explicit command —
22
+ * minting one here would edit `styles.xml` as a side effect of a clipboard
23
+ * action — so a level the document does not define falls back to the deepest
24
+ * heading it does. An `<h5>` pasted into a set that stops at `heading 4` lands
25
+ * on that one rather than keeping an id nothing resolves.
26
+ */
27
+ /**
28
+ * The document's style for this heading level, else its deepest shallower one.
29
+ * Never deeper: promoting an `<h5>` to `heading 1` would restructure the
30
+ * document's outline, while demoting it to the deepest level it has preserves
31
+ * the ordering of everything around it.
32
+ */
33
+ const nearestHeadingStyleId = (outlineLevel, styles) => {
34
+ for (let level = outlineLevel; level >= 0; level -= 1) {
35
+ const styleId = styles.styleIdForHeadingLevel(level);
36
+ if (styleId !== void 0) return styleId;
37
+ }
38
+ };
39
+ const retargetedStyleId = (node, view) => {
40
+ const styleId = node.attrs["styleId"];
41
+ if (typeof styleId !== "string") return;
42
+ const outlineLevel = node.attrs["outlineLevel"];
43
+ if (typeof outlineLevel !== "number" || !isHeadingOutlineLevel(outlineLevel)) return;
44
+ const resolver = getDocumentStyleResolver(view.state);
45
+ if (resolver === null || resolver.getStyle(styleId) !== void 0) return;
46
+ const target = nearestHeadingStyleId(outlineLevel, getDocumentBuiltInStyles(view.state));
47
+ return target === styleId ? void 0 : target;
48
+ };
49
+ const retargetFragment = (fragment, view) => {
50
+ const children = [];
51
+ let changed = false;
52
+ fragment.forEach((node) => {
53
+ const content = retargetFragment(node.content, view);
54
+ const styleId = node.type.name === "paragraph" ? retargetedStyleId(node, view) : void 0;
55
+ if (styleId === void 0 && content === node.content) {
56
+ children.push(node);
57
+ return;
58
+ }
59
+ changed = true;
60
+ const retargeted = styleId === void 0 ? node : node.type.create({
61
+ ...node.attrs,
62
+ styleId
63
+ }, content, node.marks);
64
+ children.push(styleId === void 0 ? node.copy(content) : retargeted);
65
+ });
66
+ return changed ? Fragment.fromArray(children) : fragment;
67
+ };
68
+ /** A `transformPasted` hook; returns the slice unchanged when nothing matches. */
69
+ const retargetPastedHeadingStyles = (slice, view) => {
70
+ const content = retargetFragment(slice.content, view);
71
+ return content === slice.content ? slice : new Slice(content, slice.openStart, slice.openEnd);
72
+ };
73
+ //#endregion
74
+ export { retargetPastedHeadingStyles };
@@ -1,4 +1,4 @@
1
- import { normalizeUserUrl, sanitizeExternalUrl } from "../../../utils/urlSecurity.js";
1
+ import { anchorTargetAttrs, normalizeUserUrl, sanitizeExternalUrl } from "../../../utils/urlSecurity.js";
2
2
  import { expectHyperlinkMarkAttrs } from "../../attrs/index.js";
3
3
  import { createMarkExtension } from "../create.js";
4
4
  import { isMarkActive } from "./markUtils.js";
@@ -96,8 +96,7 @@ const HyperlinkExtension = createMarkExtension({
96
96
  const { href, tooltip } = expectHyperlinkMarkAttrs(mark);
97
97
  const domAttrs = {
98
98
  href: sanitizeStoredHref(href),
99
- target: "_blank",
100
- rel: "noopener noreferrer"
99
+ ...anchorTargetAttrs(void 0)
101
100
  };
102
101
  if (tooltip) domAttrs["title"] = tooltip;
103
102
  return [
@@ -21,10 +21,18 @@ declare function isMarkActive(state: EditorState, markType: MarkType, attrs?: Re
21
21
  * Get the current value of a mark attribute
22
22
  */
23
23
  declare function getMarkAttr(state: EditorState, markType: MarkType, attr: string): unknown;
24
+ type AuthoredRunFormattingCarrier = "preserve" | "reconstruct";
24
25
  /**
25
- * Convert TextFormatting to marks array (used to restore formatting on empty paragraphs)
26
+ * Convert TextFormatting to ProseMirror marks
26
27
  */
27
- declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting, schema: Schema): Mark[];
28
+ type TextFormattingToMarksOptions = {
29
+ overrideFormatting: document_d_exports.TextFormatting | undefined;
30
+ /** Direct standard font properties whose authored provenance must survive. */
31
+ directFormatting?: document_d_exports.TextFormatting | undefined;
32
+ /** Whether direct authorship is reconstructible from structural marks and the style context. */
33
+ authoredCarrier?: AuthoredRunFormattingCarrier;
34
+ };
35
+ declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting | undefined, schema: Schema, options?: TextFormattingToMarksOptions): Mark[];
28
36
  /**
29
37
  * Clear all text formatting (remove all marks)
30
38
  */
@@ -38,4 +46,4 @@ declare function createSetMarkCommand(markType: MarkType, attrs?: Record<string,
38
46
  */
39
47
  declare function createRemoveMarkCommand(markType: MarkType): Command;
40
48
  //#endregion
41
- export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
49
+ export { AuthoredRunFormattingCarrier, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
@@ -1,8 +1,11 @@
1
1
  import { FONT_THEME_VALUES } from "../../../types/documentEnumValues.js";
2
2
  import { mergeFontFamily } from "../../../utils/fontFamilyMerge.js";
3
+ import { normalizeHorizontalScalePercent } from "../../../utils/horizontalScale.js";
3
4
  import { expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
5
+ import { shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
4
6
  import { selectRunFormattingCarrierRepresentations } from "../../runFormattingInlineCarriers.js";
5
7
  import { hasRunFormattingOverrideAttrs } from "../../runFormattingProvenance.js";
8
+ import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS } from "../../schema/marks.js";
6
9
  import { applyRunFormattingOverrideMark, buildRunFormattingOverrideAttrs } from "./RunFormattingOverrideExtension.js";
7
10
  import { toggleMark } from "prosemirror-commands";
8
11
  //#region src/prosemirror/extensions/marks/markUtils.ts
@@ -328,30 +331,85 @@ function getMarkAttr(state, markType, attr) {
328
331
  });
329
332
  return value;
330
333
  }
331
- /**
332
- * Convert TextFormatting to marks array (used to restore formatting on empty paragraphs)
333
- */
334
- function textFormattingToMarks(formatting, schema) {
334
+ const addDirectFontProvenance = (marks, schema, directFormatting) => {
335
+ const directFontProperties = [];
336
+ if (directFormatting?.fontFamily !== void 0) directFontProperties.push("fontFamily");
337
+ if (directFormatting?.fontSize !== void 0) directFontProperties.push("fontSize");
338
+ if (directFormatting?.color !== void 0) directFontProperties.push("color");
339
+ if (directFontProperties.length === 0) return;
340
+ const index = marks.findIndex(({ type }) => type.name === "runFormattingOverride");
341
+ const existing = index >= 0 ? marks.at(index) : void 0;
342
+ const override = schema.mark("runFormattingOverride", {
343
+ ...existing?.attrs,
344
+ directFontProperties
345
+ });
346
+ if (index >= 0) {
347
+ marks[index] = override;
348
+ return;
349
+ }
350
+ marks.push(override);
351
+ };
352
+ const COMPLEX_SCRIPT_MIRRORS = [
353
+ {
354
+ ordinary: "bold",
355
+ complex: "boldCs"
356
+ },
357
+ {
358
+ ordinary: "italic",
359
+ complex: "italicCs"
360
+ },
361
+ {
362
+ ordinary: "fontSize",
363
+ complex: "fontSizeCs"
364
+ }
365
+ ];
366
+ const addComplexScriptAbsenceProvenance = (marks, schema, directFormatting) => {
367
+ const absent = COMPLEX_SCRIPT_MIRRORS.filter(({ ordinary, complex }) => directFormatting?.[ordinary] !== void 0 && directFormatting[complex] === void 0).map(({ complex }) => complex);
368
+ if (absent.length === 0) return;
369
+ const index = marks.findIndex(({ type }) => type.name === "runFormattingOverride");
370
+ const existing = index >= 0 ? marks.at(index) : void 0;
371
+ const existingAbsences = new Set(existing?.attrs["complexScriptPropertyAbsences"] ?? []);
372
+ for (const property of absent) existingAbsences.add(property);
373
+ const override = schema.mark("runFormattingOverride", {
374
+ ...existing?.attrs,
375
+ complexScriptPropertyAbsences: COMPLEX_SCRIPT_RUN_PROPERTY_KEYS.filter((property) => existingAbsences.has(property))
376
+ });
377
+ if (index >= 0) {
378
+ marks[index] = override;
379
+ return;
380
+ }
381
+ marks.push(override);
382
+ };
383
+ function textFormattingToMarks(formatting, schema, options) {
384
+ if (!formatting) return [];
335
385
  const marks = [];
336
- const overrideAttrs = buildRunFormattingOverrideAttrs(formatting);
337
- if (overrideAttrs && schema.marks["runFormattingOverride"]) marks.push(schema.marks["runFormattingOverride"].create(overrideAttrs));
338
- if (formatting.bold && schema.marks["bold"]) marks.push(schema.marks["bold"].create());
339
- if (formatting.italic && schema.marks["italic"]) marks.push(schema.marks["italic"].create());
340
- if (formatting.underline && schema.marks["underline"]) marks.push(schema.marks["underline"].create({
386
+ const overrideFormatting = options ? options.overrideFormatting : formatting;
387
+ let overrideAttrs;
388
+ if (options?.authoredCarrier === "reconstruct") overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting, { type: "structural-only" });
389
+ else if (options) overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting, {
390
+ type: "authored-baseline",
391
+ formatting: options.directFormatting
392
+ });
393
+ else overrideAttrs = buildRunFormattingOverrideAttrs(overrideFormatting);
394
+ if (overrideAttrs) marks.push(schema.mark("runFormattingOverride", overrideAttrs));
395
+ if (formatting.bold) marks.push(schema.mark("bold"));
396
+ if (formatting.italic) marks.push(schema.mark("italic"));
397
+ if (formatting.underline && formatting.underline.style !== "none") marks.push(schema.mark("underline", {
341
398
  style: formatting.underline.style,
342
399
  color: formatting.underline.color
343
400
  }));
344
- if (formatting.strike && schema.marks["strike"]) marks.push(schema.marks["strike"].create());
345
- if (formatting.doubleStrike && schema.marks["strike"]) marks.push(schema.marks["strike"].create({ double: true }));
346
- if (formatting.color && schema.marks["textColor"]) marks.push(schema.marks["textColor"].create({
401
+ if (formatting.strike || formatting.doubleStrike) marks.push(schema.mark("strike", { double: formatting.doubleStrike || false }));
402
+ if (formatting.color && !formatting.color.auto) marks.push(schema.mark("textColor", {
347
403
  rgb: formatting.color.rgb,
348
404
  themeColor: formatting.color.themeColor,
349
405
  themeTint: formatting.color.themeTint,
350
406
  themeShade: formatting.color.themeShade
351
407
  }));
352
- if (formatting.highlight && schema.marks["highlight"]) marks.push(schema.marks["highlight"].create({ color: formatting.highlight }));
353
- if (formatting.fontSize !== void 0 && schema.marks["fontSize"]) marks.push(schema.marks["fontSize"].create({ size: formatting.fontSize }));
354
- if (formatting.fontFamily && schema.marks["fontFamily"]) marks.push(schema.marks["fontFamily"].create({
408
+ if (formatting.highlight && formatting.highlight !== "none") marks.push(schema.mark("highlight", { color: formatting.highlight }));
409
+ const runShadingMarkAttrs = shadingToRunShadingAttrs(formatting.shading);
410
+ if (runShadingMarkAttrs) marks.push(schema.mark("runShading", runShadingMarkAttrs));
411
+ if (formatting.fontSize) marks.push(schema.mark("fontSize", { size: formatting.fontSize }));
412
+ if (formatting.fontFamily) marks.push(schema.mark("fontFamily", {
355
413
  ascii: formatting.fontFamily.ascii,
356
414
  hAnsi: formatting.fontFamily.hAnsi,
357
415
  eastAsia: formatting.fontFamily.eastAsia,
@@ -362,10 +420,31 @@ function textFormattingToMarks(formatting, schema) {
362
420
  eastAsiaTheme: formatting.fontFamily.eastAsiaTheme,
363
421
  csTheme: formatting.fontFamily.csTheme
364
422
  }));
365
- if (formatting.language && schema.marks["language"]) marks.push(schema.marks["language"].create(formatting.language));
366
- if (formatting.vertAlign === "superscript" && schema.marks["superscript"]) marks.push(schema.marks["superscript"].create());
367
- if (formatting.vertAlign === "subscript" && schema.marks["subscript"]) marks.push(schema.marks["subscript"].create());
368
- if (formatting.rtl && schema.marks["rtl"]) marks.push(schema.marks["rtl"].create());
423
+ if (formatting.language) marks.push(schema.mark("language", formatting.language));
424
+ if (formatting.vertAlign === "superscript") marks.push(schema.mark("superscript"));
425
+ else if (formatting.vertAlign === "subscript") marks.push(schema.mark("subscript"));
426
+ if (formatting.allCaps) marks.push(schema.mark("allCaps"));
427
+ if (formatting.smallCaps) marks.push(schema.mark("smallCaps"));
428
+ const spacing = typeof formatting.spacing === "number" ? formatting.spacing : null;
429
+ const position = typeof formatting.position === "number" ? formatting.position : null;
430
+ const scale = normalizeHorizontalScalePercent(formatting.scale) ?? null;
431
+ const kerning = typeof formatting.kerning === "number" ? formatting.kerning : null;
432
+ if (spacing !== null || position !== null || scale !== null || kerning !== null) marks.push(schema.mark("characterSpacing", {
433
+ spacing,
434
+ position,
435
+ scale,
436
+ kerning
437
+ }));
438
+ if (formatting.hidden === true) marks.push(schema.mark("hidden"));
439
+ if (formatting.emboss) marks.push(schema.mark("emboss"));
440
+ if (formatting.imprint) marks.push(schema.mark("imprint"));
441
+ if (formatting.shadow) marks.push(schema.mark("textShadow"));
442
+ if (formatting.emphasisMark && formatting.emphasisMark !== "none") marks.push(schema.mark("emphasisMark", { type: formatting.emphasisMark }));
443
+ if (formatting.outline) marks.push(schema.mark("textOutline"));
444
+ if (formatting.rtl) marks.push(schema.mark("rtl"));
445
+ if (formatting.effect && formatting.effect !== "none") marks.push(schema.mark("textEffect", { effect: formatting.effect }));
446
+ addDirectFontProvenance(marks, schema, options?.directFormatting);
447
+ if (options?.authoredCarrier === "preserve") addComplexScriptAbsenceProvenance(marks, schema, options.directFormatting);
369
448
  return marks;
370
449
  }
371
450
  /**
@@ -1,5 +1,5 @@
1
1
  import { readParagraphAttrs } from "../../attrs/index.js";
2
- import { expectBookmarkBoundaryAttrs, readBookmarkBoundaryAttrs } from "../../bookmarkBoundaryAttrs.js";
2
+ import { expectBookmarkBoundaryAttrs, isDisplacedByCustomXml, readBookmarkBoundaryAttrs } from "../../bookmarkBoundaryAttrs.js";
3
3
  import { findInvalidBookmarkBoundaryIds } from "../../bookmarkBoundaryIntegrity.js";
4
4
  import { createNodeExtension } from "../create.js";
5
5
  import { Plugin } from "prosemirror-state";
@@ -60,7 +60,8 @@ const BookmarkBoundaryExtension = createNodeExtension({
60
60
  id: {},
61
61
  name: { default: null },
62
62
  colFirst: { default: null },
63
- colLast: { default: null }
63
+ colLast: { default: null },
64
+ displacedByCustomXml: { default: null }
64
65
  },
65
66
  parseDOM: [{
66
67
  tag: "span[data-docx-bookmark-boundary]",
@@ -73,12 +74,14 @@ const BookmarkBoundaryExtension = createNodeExtension({
73
74
  const colFirst = readOptionalColumn(dom, "data-docx-bookmark-col-first");
74
75
  const colLast = readOptionalColumn(dom, "data-docx-bookmark-col-last");
75
76
  if (colFirst === false || colLast === false) return false;
77
+ const displaced = dom.getAttribute("data-docx-bookmark-displaced");
76
78
  return {
77
79
  type,
78
80
  id,
79
81
  ...name ? { name } : {},
80
82
  ...colFirst !== void 0 ? { colFirst } : {},
81
- ...colLast !== void 0 ? { colLast } : {}
83
+ ...colLast !== void 0 ? { colLast } : {},
84
+ ...isDisplacedByCustomXml(displaced) ? { displacedByCustomXml: displaced } : {}
82
85
  };
83
86
  }
84
87
  }],
@@ -90,6 +93,7 @@ const BookmarkBoundaryExtension = createNodeExtension({
90
93
  ...attrs.type === "start" ? { "data-docx-bookmark-name": attrs.name } : {},
91
94
  ...attrs.type === "start" && attrs.colFirst !== void 0 ? { "data-docx-bookmark-col-first": String(attrs.colFirst) } : {},
92
95
  ...attrs.type === "start" && attrs.colLast !== void 0 ? { "data-docx-bookmark-col-last": String(attrs.colLast) } : {},
96
+ ...attrs.displacedByCustomXml !== void 0 ? { "data-docx-bookmark-displaced": attrs.displacedByCustomXml } : {},
93
97
  "aria-hidden": "true",
94
98
  contenteditable: "false",
95
99
  style: "display: none;",
@@ -39,8 +39,12 @@ const ImageExtension = createNodeExtension({
39
39
  paddingLeft: { default: null },
40
40
  position: { default: null },
41
41
  layoutInCell: { default: null },
42
+ decorative: { default: null },
43
+ hidden: { default: null },
44
+ docPrExtensions: { default: null },
42
45
  frameLocks: { default: null },
43
46
  borderWidth: { default: null },
47
+ _docxAuthoredEmu: { default: null },
44
48
  borderColor: { default: null },
45
49
  borderStyle: { default: null },
46
50
  wrapText: { default: null },
@@ -49,7 +53,8 @@ const ImageExtension = createNodeExtension({
49
53
  _docxRawXml: { default: null },
50
54
  _docxRawXmlMode: { default: null },
51
55
  _docxRawImageFingerprint: { default: null },
52
- _docxObjectPreview: { default: null }
56
+ _docxObjectPreview: { default: null },
57
+ _docxRunFormatting: { default: null }
53
58
  },
54
59
  parseDOM: [{
55
60
  tag: "img[src]",
@@ -369,20 +369,26 @@ const ShapeExtension = createNodeExtension({
369
369
  attrs: {
370
370
  shapeType: { default: "rect" },
371
371
  geometryAdjustments: { default: null },
372
+ _docxRunFormatting: { default: null },
372
373
  shapeId: { default: null },
374
+ shapeName: { default: null },
375
+ alt: { default: null },
376
+ title: { default: null },
373
377
  width: { default: 100 },
374
378
  height: { default: 80 },
379
+ _docxAuthoredEmu: { default: null },
375
380
  fillColor: { default: null },
376
381
  fillColorValue: { default: null },
377
382
  fillType: { default: "solid" },
378
383
  gradientType: { default: null },
379
384
  gradientAngle: { default: null },
380
385
  gradientStops: { default: null },
381
- outlineWidth: { default: 1 },
386
+ outlineWidth: { default: null },
382
387
  outlineColor: { default: "var(--doc-shape-outline, #000000)" },
383
388
  outlineColorValue: { default: null },
384
- outlineStyle: { default: "solid" },
389
+ outlineStyle: { default: null },
385
390
  outlineCap: { default: null },
391
+ outlineJoin: { default: null },
386
392
  outlineHeadEnd: { default: null },
387
393
  outlineTailEnd: { default: null },
388
394
  transform: { default: null },
@@ -1,3 +1,4 @@
1
+ import { setTableLookFlags } from "../../../docx/tableLook.js";
1
2
  import { TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_WIDTH_TYPE_VALUES } from "../../../types/documentEnumValues.js";
2
3
  import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
3
4
  import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
@@ -1618,7 +1619,20 @@ const TablePluginExtension = createExtension({
1618
1619
  };
1619
1620
  const conditionals = styleData.conditionals ?? {};
1620
1621
  const tableBorders = styleData.tableBorders;
1621
- tr = tr.setNodeMarkup(tablePos, void 0, mergeTableAttrs(table, { styleId: styleData.styleId }));
1622
+ tr = tr.setNodeMarkup(tablePos, void 0, mergeTableAttrs(table, {
1623
+ styleId: styleData.styleId,
1624
+ look: setTableLookFlags({
1625
+ look: expectTableAttrs(table).look,
1626
+ flags: {
1627
+ firstRow: look.firstRow === true,
1628
+ lastRow: look.lastRow === true,
1629
+ firstColumn: look.firstCol === true,
1630
+ lastColumn: look.lastCol === true,
1631
+ noHBand: look.noHBand === true,
1632
+ noVBand: look.noVBand === true
1633
+ }
1634
+ })
1635
+ }));
1622
1636
  let dataRowIndex = 0;
1623
1637
  let rowOffset = tablePos + 1;
1624
1638
  for (let rowIdx = 0; rowIdx < totalRows; rowIdx++) {
@@ -77,19 +77,23 @@ const TextBoxExtension = createNodeExtension({
77
77
  attrs: {
78
78
  width: { default: 200 },
79
79
  height: { default: null },
80
+ _docxAuthoredEmu: { default: null },
80
81
  autoFit: { default: null },
81
82
  wordArt: { default: null },
82
83
  textWrap: { default: null },
83
84
  textBoxId: { default: null },
85
+ textBoxName: { default: null },
86
+ alt: { default: null },
87
+ title: { default: null },
84
88
  fillColor: { default: null },
85
89
  outlineWidth: { default: null },
86
90
  outlineColor: { default: null },
87
91
  outlineStyle: { default: null },
88
92
  transform: { default: null },
89
- marginTop: { default: 4 },
90
- marginBottom: { default: 4 },
91
- marginLeft: { default: 7 },
92
- marginRight: { default: 7 },
93
+ marginTop: { default: null },
94
+ marginBottom: { default: null },
95
+ marginLeft: { default: null },
96
+ marginRight: { default: null },
93
97
  verticalAlign: { default: null },
94
98
  displayMode: { default: "inline" },
95
99
  cssFloat: { default: null },
@@ -2,7 +2,7 @@ import { document_d_exports } from "../../types/document.js";
2
2
  import { TextColorAttrs } from "../schema/marks.js";
3
3
  import "../schema/index.js";
4
4
  import { TablePropertiesCommand } from "../../utils/tableOperations.js";
5
- import { ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
5
+ import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
6
6
  import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
7
7
  import { Command, Plugin } from "prosemirror-state";
8
8
  import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
@@ -106,7 +106,7 @@ type FolioCommandArguments = {
106
106
  setRtl: [];
107
107
  setLtr: [];
108
108
  setTabs: [tabs: document_d_exports.TabStop[]];
109
- generateTOC: [];
109
+ generateTOC: [options: GenerateTableOfContentsOptions];
110
110
  insertTable: [rows: number, cols: number];
111
111
  addRowAbove: [];
112
112
  addRowBelow: [];
@@ -10,7 +10,7 @@ import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensi
10
10
  import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
11
11
  import { insertImageFromFile } from "./commands/image.js";
12
12
  import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
13
- import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTOC, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
13
+ import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTableOfContents, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
14
14
  import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
15
15
  import { insertPageBreak } from "./commands/pageBreak.js";
16
16
  import "./commands/index.js";
@@ -22,8 +22,8 @@ import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin
22
22
  import { ensureParaIdsInState } from "./extensions/features/ParaIdAllocatorExtension.js";
23
23
  import "./styles/index.js";
24
24
  import { SelectionState, extractSelectionState } from "./selectionState.js";
25
- import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./plugins/documentStyles.js";
25
+ import { createDocumentStylesPlugin, documentStylesKey, getDocumentBuiltInStyles, getDocumentStyleResolver } from "./plugins/documentStyles.js";
26
26
  import "./plugins/index.js";
27
27
  import { insertPageBreakInView, insertTableInView, insertTableOfContentsInView } from "./insertOperations.js";
28
28
  import { TextSelection } from "prosemirror-state";
29
- export { type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type HyperlinkAttrs, type ImageAttrs, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderPreset, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTOC, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };
29
+ export { type BorderPreset, type CapturedTextFormatting, type FontFamilyAttrs, type FontSizeAttrs, type HyperlinkAttrs, type ImageAttrs, PAINTABLE_MARK_NAMES, type ParagraphAttrs, type ProseMirrorDocumentValidationIssue, type ResolvedParagraphStyle, type SelectionChangeCallback, type SelectionContext, type SelectionState, StyleResolver, type TableBorderPreset, type TableContextInfo, type TextColorAttrs, TextSelection, type ToProseDocOptions, type UnderlineAttrs, type ValidateProseMirrorDocumentResult, addColumnLeft, addColumnRight, addRowAbove, addRowBelow, addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyFormatMarks, applyStyle, applyTableStyle, assertValidProseMirrorDocument, autoFitContents, captureFormatMarks, clearFontFamily, clearFontSize, clearFormatting, clearHighlight, clearStyle, clearTextColor, createDocumentStylesPlugin, createEmptyDoc, createSelectionTrackerPlugin, createStyleResolver, decreaseIndent, decreaseListLevel, deleteColumn, deleteRow, deleteTable, distributeColumns, documentStylesKey, ensureParaIdsInState, extractSelectionContext, extractSelectionState, formatProseMirrorDocumentIssues, fromProseDoc, generateTableOfContents, getDocumentBuiltInStyles, getDocumentStyleResolver, getHyperlinkAttrs, getListInfo, getMarkAttr, getParagraphAlignment, getParagraphBidi, getSelectedText, getSelectionContext, getStyleId, getTableContext, increaseIndent, increaseListLevel, insertHyperlink, insertImageFromFile, insertPageBreak, insertPageBreakInView, insertTable, insertTableInView, insertTableOfContentsInView, isHyperlinkActive, isInList, isInTableCell as isInTable, isMarkActive, mergeCells, removeHyperlink, removeList, removeTabStop, removeTableBorders, schema, selectColumn, selectRow, selectTable, selectionTrackerKey, setAlignment, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setFontFamily, setFontSize, setHighlight, setHyperlink, setIndentFirstLine, setIndentLeft, setIndentRight, setInsideTableBorders, setLineSpacing, setLtr, setOutsideTableBorders, setRowHeight, setRtl, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, setTextColor, singletonManager, splitCell, toProseDoc, toggleBidi, toggleBold, toggleBulletList, toggleHeaderRow, toggleItalic, toggleNoWrap, toggleNumberedList, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, updateDocumentContent, validateProseMirrorDocument };