@stll/folio-core 0.39.1 → 0.41.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 (64) hide show
  1. package/dist/ai-edits/apply.js +6 -4
  2. package/dist/ai-edits/clean-text.d.ts +28 -6
  3. package/dist/ai-edits/clean-text.js +28 -13
  4. package/dist/ai-edits/headless.d.ts +12 -0
  5. package/dist/ai-edits/headless.js +26 -3
  6. package/dist/ai-edits/index.d.ts +2 -2
  7. package/dist/ai-edits/snapshot.d.ts +6 -1
  8. package/dist/ai-edits/snapshot.js +15 -10
  9. package/dist/ai-edits/types.d.ts +19 -6
  10. package/dist/ai-suggestions/text-positions.js +15 -3
  11. package/dist/compare/inline-atoms.js +2 -2
  12. package/dist/compat/eigenpal.d.ts +3 -2
  13. package/dist/compat/eigenpal.js +2 -1
  14. package/dist/display-list/primitives.d.ts +2 -1
  15. package/dist/document-operations.d.ts +24 -23
  16. package/dist/document-operations.js +163 -127
  17. package/dist/docx/blockPlainText.d.ts +8 -0
  18. package/dist/docx/blockPlainText.js +40 -0
  19. package/dist/docx/commentRangeIntegrity.js +0 -1
  20. package/dist/docx/compatibility.d.ts +16 -2
  21. package/dist/docx/compatibility.js +30 -9
  22. package/dist/docx/footnoteParser.js +4 -23
  23. package/dist/docx/graphicFrameLocks.d.ts +22 -0
  24. package/dist/docx/graphicFrameLocks.js +55 -0
  25. package/dist/docx/groupDrawingParser.d.ts +7 -1
  26. package/dist/docx/groupDrawingParser.js +11 -2
  27. package/dist/docx/headerFooterParser.d.ts +5 -1
  28. package/dist/docx/headerFooterParser.js +7 -21
  29. package/dist/docx/headerFooterVerbatim.d.ts +1 -12
  30. package/dist/docx/imageParser.js +5 -0
  31. package/dist/docx/imageRawXml.d.ts +33 -1
  32. package/dist/docx/imageRawXml.js +56 -1
  33. package/dist/docx/numberingParser.d.ts +1 -3
  34. package/dist/docx/runParser.js +43 -21
  35. package/dist/docx/serializer/runSerializer.js +4 -2
  36. package/dist/docx/server/createBilingualDocument.js +31 -5
  37. package/dist/docx/settingsParser.d.ts +2 -6
  38. package/dist/docx/shapeParser.js +32 -6
  39. package/dist/docx/vmlImageParser.d.ts +11 -1
  40. package/dist/docx/vmlImageParser.js +29 -2
  41. package/dist/headless-layout.js +1 -7
  42. package/dist/index.d.ts +3 -2
  43. package/dist/index.js +2 -1
  44. package/dist/internal/compare/inline-presentation.d.ts +11 -3
  45. package/dist/internal/compare/inline-presentation.js +8 -1
  46. package/dist/prosemirror/attrs/index.js +33 -3
  47. package/dist/prosemirror/conversion/fromProseDoc.d.ts +13 -2
  48. package/dist/prosemirror/conversion/fromProseDoc.js +85 -46
  49. package/dist/prosemirror/conversion/index.d.ts +2 -2
  50. package/dist/prosemirror/conversion/toProseDoc.js +12 -21
  51. package/dist/prosemirror/extensions/features/ListExtension.js +2 -1
  52. package/dist/prosemirror/extensions/nodes/ImageExtension.js +6 -0
  53. package/dist/prosemirror/imageCommit.js +7 -3
  54. package/dist/prosemirror/listMarker.d.ts +1 -1
  55. package/dist/prosemirror/listMarker.js +1 -18
  56. package/dist/prosemirror/listRenderingAttrs.d.ts +42 -0
  57. package/dist/prosemirror/listRenderingAttrs.js +80 -0
  58. package/dist/prosemirror/runFormattingInlineCarriers.d.ts +16 -1
  59. package/dist/prosemirror/runFormattingInlineCarriers.js +20 -1
  60. package/dist/prosemirror/schema/marks.d.ts +1 -1
  61. package/dist/prosemirror/schema/nodes.d.ts +20 -0
  62. package/dist/prosemirror/styles/resolvedStyleAttrs.js +2 -14
  63. package/dist/utils/mergeDocumentContent.js +1 -1
  64. package/package.json +2 -2
@@ -9,6 +9,7 @@ import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
9
9
  import { emuToPixels } from "../../utils/units.js";
10
10
  import { setAutospacingBaseValue } from "../autospacingBase.js";
11
11
  import { buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
12
+ import { listRenderingAttrPatch } from "../listRenderingAttrs.js";
12
13
  import { stampNumberedRefFieldBaselines } from "../numberedRefFields.js";
13
14
  import { pageBreakRunParagraphProjectionDispositionForFeatures } from "../pageBreakRunProjection.js";
14
15
  import { directionFromBidi } from "../paragraphDirection.js";
@@ -23,6 +24,7 @@ import { resolveEffectiveTableCellFormatting } from "./effectiveTableCellFormatt
23
24
  import { shadingToRunShadingAttrs } from "./runShadingMark.js";
24
25
  import { sdtAttrsFromProperties } from "./sdtAttrs.js";
25
26
  import { TaggedError, panic } from "better-result";
27
+ import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
26
28
  //#region src/prosemirror/conversion/toProseDoc.ts
27
29
  /** DOCX content that cannot be preserved by the editable ProseMirror model. */
28
30
  var UnsupportedDocxToProseMirrorConversionError = class extends TaggedError("UnsupportedDocxToProseMirrorConversionError") {};
@@ -422,25 +424,7 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
422
424
  if (tableOfContentsLevel !== void 0) attrs._tableOfContentsLevel = tableOfContentsLevel;
423
425
  if (formatting?.numPr) attrs.numPr = formatting.numPr;
424
426
  if (formatting?.numPrFromStyle) attrs.numPrFromStyle = formatting.numPrFromStyle;
425
- if (paragraph.listRendering?.numFmt) attrs.listNumFmt = paragraph.listRendering.numFmt;
426
- if (paragraph.listRendering?.isBullet) attrs.listIsBullet = paragraph.listRendering.isBullet;
427
- if (paragraph.listRendering?.isLegal) attrs.listIsLegal = paragraph.listRendering.isLegal;
428
- if (paragraph.listRendering?.marker) attrs.listMarker = paragraph.listRendering.marker;
429
- if (paragraph.listRendering?.markerTemplate) attrs.listMarkerTemplate = paragraph.listRendering.markerTemplate;
430
- if (paragraph.listRendering?.markerHidden) attrs.listMarkerHidden = paragraph.listRendering.markerHidden;
431
- if (paragraph.listRendering?.markerFormatting) attrs.listMarkerFormatting = paragraph.listRendering.markerFormatting;
432
- if (paragraph.listRendering?.markerAlignment) attrs.listMarkerAlignment = paragraph.listRendering.markerAlignment;
433
- if (paragraph.listRendering?.markerSuffix) attrs.listMarkerSuffix = paragraph.listRendering.markerSuffix;
434
- if (paragraph.listRendering?.markerAllCaps) attrs.listMarkerAllCaps = paragraph.listRendering.markerAllCaps;
435
- if (paragraph.listRendering?.implicitChildLevelAdvances !== void 0) attrs.listImplicitChildLevelAdvances = paragraph.listRendering.implicitChildLevelAdvances;
436
- if (paragraph.listRendering?.markerSecondSlotOffsetTwips !== void 0) attrs.listMarkerSecondSlotOffsetTwips = paragraph.listRendering.markerSecondSlotOffsetTwips;
437
- if (paragraph.listRendering?.levelNumFmts) attrs.listLevelNumFmts = paragraph.listRendering.levelNumFmts;
438
- if (paragraph.listRendering && "levelStarts" in paragraph.listRendering) {
439
- const { levelStarts } = paragraph.listRendering;
440
- if (Array.isArray(levelStarts) && levelStarts.every((value) => typeof value === "number")) attrs.listLevelStarts = levelStarts;
441
- }
442
- if (paragraph.listRendering?.abstractNumId !== void 0) attrs.listAbstractNumId = paragraph.listRendering.abstractNumId;
443
- if (paragraph.listRendering?.startOverride !== void 0) attrs.listStartOverride = paragraph.listRendering.startOverride;
427
+ if (paragraph.listRendering) Object.assign(attrs, listRenderingAttrPatch(paragraph.listRendering));
444
428
  if (formatting) attrs._originalFormatting = formatting;
445
429
  if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = [...paragraph.propertyChanges];
446
430
  if (paragraph.pPrMark) attrs.pPrMark = paragraph.pPrMark;
@@ -1605,7 +1589,8 @@ function convertRunContent(content, marks, formatting, textBoxAnchors) {
1605
1589
  case "drawing": return [withRunBoundaryMarks(convertImage({
1606
1590
  image: content.image,
1607
1591
  rawXml: content.rawXml,
1608
- rawXmlMode: content.rawXmlMode
1592
+ rawXmlMode: content.rawXmlMode,
1593
+ rawImageFingerprint: content.rawXmlMode === DRAWING_RAW_XML_MODES.PRESERVE_ONLY ? void 0 : content.rawImageFingerprint
1609
1594
  }), marks)];
1610
1595
  case "shape": {
1611
1596
  const shp = content.shape;
@@ -1645,7 +1630,7 @@ function withRunBoundaryMarks(node, marks) {
1645
1630
  if (!marks.some(({ type }) => type.name === "hyperlink" || type.name === "pageBreakRunOwner")) return node;
1646
1631
  return node.mark(marks);
1647
1632
  }
1648
- function convertImage({ image, rawXml, rawXmlMode }) {
1633
+ function convertImage({ image, rawXml, rawXmlMode, rawImageFingerprint }) {
1649
1634
  const imageSize = image.size;
1650
1635
  const widthPx = imageSize?.width ? emuToPixels(imageSize.width) : void 0;
1651
1636
  const heightPx = imageSize?.height ? emuToPixels(imageSize.height) : void 0;
@@ -1737,8 +1722,13 @@ function convertImage({ image, rawXml, rawXmlMode }) {
1737
1722
  cropRight: image.crop?.right,
1738
1723
  cropBottom: image.crop?.bottom,
1739
1724
  cropLeft: image.crop?.left,
1725
+ paddingTop: image.padding?.top,
1726
+ paddingRight: image.padding?.right,
1727
+ paddingBottom: image.padding?.bottom,
1728
+ paddingLeft: image.padding?.left,
1740
1729
  position,
1741
1730
  layoutInCell: image.layoutInCell,
1731
+ frameLocks: image.frameLocks ? { ...image.frameLocks } : void 0,
1742
1732
  borderWidth,
1743
1733
  borderColor,
1744
1734
  borderStyle,
@@ -1747,6 +1737,7 @@ function convertImage({ image, rawXml, rawXmlMode }) {
1747
1737
  hlinkRId: image.hlinkRId,
1748
1738
  _docxRawXml: rawXml,
1749
1739
  _docxRawXmlMode: rawXmlMode,
1740
+ _docxRawImageFingerprint: rawImageFingerprint,
1750
1741
  _docxObjectPreview: rawXml !== void 0 && /<(?:[A-Za-z_][\w.-]*:)?object(?:\s|>)/u.test(rawXml)
1751
1742
  });
1752
1743
  }
@@ -1,6 +1,7 @@
1
1
  import { expectParagraphAttrs } from "../../attrs/index.js";
2
2
  import { PPR_CHANGE_SCOPED_ATTR_KEYS, hasSerializableParagraphPropertyChange } from "../../commands/propertyChangeScope.js";
3
- import { CLEARED_LIST_RENDERING_ATTRS, LIST_RENDERING_ATTR_KEYS } from "../../listMarker.js";
3
+ import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
4
+ import { LIST_RENDERING_ATTR_KEYS } from "../../listRenderingAttrs.js";
4
5
  import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
5
6
  import { SUGGESTION_META, makeRevisionInfo } from "../../plugins/suggestionMode.js";
6
7
  import { listLevelAttrPatch } from "../../styles/resolvedStyleAttrs.js";
@@ -33,8 +33,13 @@ const ImageExtension = createNodeExtension({
33
33
  cropRight: { default: null },
34
34
  cropBottom: { default: null },
35
35
  cropLeft: { default: null },
36
+ paddingTop: { default: null },
37
+ paddingRight: { default: null },
38
+ paddingBottom: { default: null },
39
+ paddingLeft: { default: null },
36
40
  position: { default: null },
37
41
  layoutInCell: { default: null },
42
+ frameLocks: { default: null },
38
43
  borderWidth: { default: null },
39
44
  borderColor: { default: null },
40
45
  borderStyle: { default: null },
@@ -43,6 +48,7 @@ const ImageExtension = createNodeExtension({
43
48
  hlinkRId: { default: null },
44
49
  _docxRawXml: { default: null },
45
50
  _docxRawXmlMode: { default: null },
51
+ _docxRawImageFingerprint: { default: null },
46
52
  _docxObjectPreview: { default: null }
47
53
  },
48
54
  parseDOM: [{
@@ -1,5 +1,5 @@
1
+ import { allowsDirectDrawingEdit } from "../docx/imageRawXml.js";
1
2
  import { expectImageAttrs, mergeImageAttrs } from "./attrs/index.js";
2
- import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
3
3
  //#region src/prosemirror/imageCommit.ts
4
4
  const MIN_IMAGE_PX = 20;
5
5
  const MAX_IMAGE_PX = 2e3;
@@ -38,11 +38,15 @@ function isFloatingImage(node) {
38
38
  "through"
39
39
  ].includes(wrapType) : false);
40
40
  }
41
- /** Resolve the image node at `pmPos`, or null if it isn't an image. */
41
+ /**
42
+ * Resolve the image node at `pmPos`, or null if it isn't an image or is one
43
+ * whose raw XML says more than the model does. Refusing the node leaves the
44
+ * rest of the document editable.
45
+ */
42
46
  function imageNodeAt(view, pmPos) {
43
47
  const node = view.state.doc.nodeAt(pmPos);
44
48
  if (!node || node.type.name !== "image") return null;
45
- if (expectImageAttrs(node)._docxRawXmlMode === DRAWING_RAW_XML_MODES.PRESERVE_ONLY) return null;
49
+ if (!allowsDirectDrawingEdit(expectImageAttrs(node)._docxRawXmlMode)) return null;
46
50
  return node;
47
51
  }
48
52
  /**
@@ -1,5 +1,6 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
2
  import { ParagraphAttrs } from "./schema/nodes.js";
3
+ import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
3
4
  //#region src/prosemirror/listMarker.d.ts
4
5
  type ListCounterState = {
5
6
  counters: Map<number, number[]>;
@@ -42,7 +43,6 @@ type ResolvedListTemplate = {
42
43
  components: readonly ResolvedListComponent[];
43
44
  };
44
45
  declare const MAX_LIST_LEVEL = 8;
45
- declare const LIST_RENDERING_ATTR_KEYS: readonly ["listIsBullet", "listIsLegal", "listNumFmt", "listMarker", "listMarkerTemplate", "listMarkerHidden", "listMarkerFormatting", "listMarkerAlignment", "listMarkerSuffix", "listMarkerAllCaps", "listImplicitChildLevelAdvances", "listMarkerSecondSlotOffsetTwips", "listLevelNumFmts", "listLevelStarts", "listAbstractNumId", "listStartOverride"];
46
46
  declare const CLEARED_LIST_RENDERING_ATTRS: Readonly<{
47
47
  listIsBullet: null;
48
48
  listIsLegal: null;
@@ -1,25 +1,8 @@
1
1
  import { convertBulletToUnicode } from "../docx/bulletMarkers.js";
2
2
  import { formatOoxmlCounter } from "../docx/ooxmlCounterFormatter.js";
3
+ import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
3
4
  //#region src/prosemirror/listMarker.ts
4
5
  const MAX_LIST_LEVEL = 8;
5
- const LIST_RENDERING_ATTR_KEYS = [
6
- "listIsBullet",
7
- "listIsLegal",
8
- "listNumFmt",
9
- "listMarker",
10
- "listMarkerTemplate",
11
- "listMarkerHidden",
12
- "listMarkerFormatting",
13
- "listMarkerAlignment",
14
- "listMarkerSuffix",
15
- "listMarkerAllCaps",
16
- "listImplicitChildLevelAdvances",
17
- "listMarkerSecondSlotOffsetTwips",
18
- "listLevelNumFmts",
19
- "listLevelStarts",
20
- "listAbstractNumId",
21
- "listStartOverride"
22
- ];
23
6
  const CLEARED_LIST_RENDERING_ATTRS = Object.freeze({
24
7
  listIsBullet: null,
25
8
  listIsLegal: null,
@@ -0,0 +1,42 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ import { ParagraphAttrs } from "./schema/nodes.js";
3
+ //#region src/prosemirror/listRenderingAttrs.d.ts
4
+ /** `ListRendering` fields that have their own editor attr. */
5
+ type ListRenderingAttrField = Exclude<keyof document_d_exports.ListRendering, "level" | "numId">;
6
+ declare const LIST_RENDERING_ATTR_BY_FIELD: {
7
+ readonly marker: "listMarker";
8
+ readonly markerTemplate: "listMarkerTemplate";
9
+ readonly isBullet: "listIsBullet";
10
+ readonly isLegal: "listIsLegal";
11
+ readonly numFmt: "listNumFmt";
12
+ readonly markerHidden: "listMarkerHidden";
13
+ readonly markerFormatting: "listMarkerFormatting";
14
+ readonly markerAlignment: "listMarkerAlignment";
15
+ readonly markerAllCaps: "listMarkerAllCaps";
16
+ readonly markerSuffix: "listMarkerSuffix";
17
+ readonly levelNumFmts: "listLevelNumFmts";
18
+ readonly levelStarts: "listLevelStarts";
19
+ readonly abstractNumId: "listAbstractNumId";
20
+ readonly startOverride: "listStartOverride";
21
+ readonly implicitChildLevelAdvances: "listImplicitChildLevelAdvances";
22
+ readonly markerSecondSlotOffsetTwips: "listMarkerSecondSlotOffsetTwips";
23
+ };
24
+ type ListRenderingAttrKey = (typeof LIST_RENDERING_ATTR_BY_FIELD)[ListRenderingAttrField];
25
+ declare const LIST_RENDERING_ATTR_KEYS: readonly ListRenderingAttrKey[];
26
+ /**
27
+ * Editor attrs carrying `rendering`. A falsy marker, flag or format is left
28
+ * unset: the editor treats `null` and absent alike for those, and the parser
29
+ * never authors them as `false` or `""` deliberately.
30
+ */
31
+ declare const listRenderingAttrPatch: (rendering: document_d_exports.ListRendering) => Partial<ParagraphAttrs>;
32
+ type ListRenderingFromAttrsOptions = {
33
+ attrs: ParagraphAttrs;
34
+ numId: number;
35
+ };
36
+ /**
37
+ * Inverse of `listRenderingAttrPatch`. The caller decides whether the
38
+ * paragraph is a list item at all; this only reassembles the fields.
39
+ */
40
+ declare const listRenderingFromAttrs: ({ attrs, numId }: ListRenderingFromAttrsOptions) => document_d_exports.ListRendering;
41
+ //#endregion
42
+ export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, ListRenderingAttrField, ListRenderingAttrKey, listRenderingAttrPatch, listRenderingFromAttrs };
@@ -0,0 +1,80 @@
1
+ //#region src/prosemirror/listRenderingAttrs.ts
2
+ const LIST_RENDERING_ATTR_BY_FIELD = {
3
+ marker: "listMarker",
4
+ markerTemplate: "listMarkerTemplate",
5
+ isBullet: "listIsBullet",
6
+ isLegal: "listIsLegal",
7
+ numFmt: "listNumFmt",
8
+ markerHidden: "listMarkerHidden",
9
+ markerFormatting: "listMarkerFormatting",
10
+ markerAlignment: "listMarkerAlignment",
11
+ markerAllCaps: "listMarkerAllCaps",
12
+ markerSuffix: "listMarkerSuffix",
13
+ levelNumFmts: "listLevelNumFmts",
14
+ levelStarts: "listLevelStarts",
15
+ abstractNumId: "listAbstractNumId",
16
+ startOverride: "listStartOverride",
17
+ implicitChildLevelAdvances: "listImplicitChildLevelAdvances",
18
+ markerSecondSlotOffsetTwips: "listMarkerSecondSlotOffsetTwips"
19
+ };
20
+ const LIST_RENDERING_ATTR_KEYS = Object.values(LIST_RENDERING_ATTR_BY_FIELD);
21
+ const isDefinedEntry = ([, value]) => value !== void 0;
22
+ const definedAttrs = (patch) => Object.fromEntries(Object.entries(patch).filter(isDefinedEntry));
23
+ const definedFields = (fields) => Object.fromEntries(Object.entries(fields).filter(isDefinedEntry));
24
+ /**
25
+ * Editor attrs carrying `rendering`. A falsy marker, flag or format is left
26
+ * unset: the editor treats `null` and absent alike for those, and the parser
27
+ * never authors them as `false` or `""` deliberately.
28
+ */
29
+ const listRenderingAttrPatch = (rendering) => {
30
+ const patch = {
31
+ listMarker: rendering.marker || void 0,
32
+ listMarkerTemplate: rendering.markerTemplate || void 0,
33
+ listIsBullet: rendering.isBullet || void 0,
34
+ listIsLegal: rendering.isLegal || void 0,
35
+ listNumFmt: rendering.numFmt || void 0,
36
+ listMarkerHidden: rendering.markerHidden || void 0,
37
+ listMarkerFormatting: rendering.markerFormatting || void 0,
38
+ listMarkerAlignment: rendering.markerAlignment || void 0,
39
+ listMarkerAllCaps: rendering.markerAllCaps || void 0,
40
+ listMarkerSuffix: rendering.markerSuffix || void 0,
41
+ listLevelNumFmts: rendering.levelNumFmts || void 0,
42
+ listLevelStarts: rendering.levelStarts || void 0,
43
+ listAbstractNumId: rendering.abstractNumId,
44
+ listStartOverride: rendering.startOverride,
45
+ listImplicitChildLevelAdvances: rendering.implicitChildLevelAdvances,
46
+ listMarkerSecondSlotOffsetTwips: rendering.markerSecondSlotOffsetTwips
47
+ };
48
+ return definedAttrs(patch);
49
+ };
50
+ /**
51
+ * Inverse of `listRenderingAttrPatch`. The caller decides whether the
52
+ * paragraph is a list item at all; this only reassembles the fields.
53
+ */
54
+ const listRenderingFromAttrs = ({ attrs, numId }) => {
55
+ const optional = {
56
+ markerTemplate: attrs.listMarkerTemplate ?? void 0,
57
+ isLegal: attrs.listIsLegal ?? void 0,
58
+ numFmt: attrs.listNumFmt ?? void 0,
59
+ markerHidden: attrs.listMarkerHidden ?? void 0,
60
+ markerFormatting: attrs.listMarkerFormatting ?? void 0,
61
+ markerAlignment: attrs.listMarkerAlignment ?? void 0,
62
+ markerAllCaps: attrs.listMarkerAllCaps ?? void 0,
63
+ markerSuffix: attrs.listMarkerSuffix ?? void 0,
64
+ levelNumFmts: attrs.listLevelNumFmts ?? void 0,
65
+ levelStarts: attrs.listLevelStarts ?? void 0,
66
+ abstractNumId: attrs.listAbstractNumId ?? void 0,
67
+ startOverride: attrs.listStartOverride ?? void 0,
68
+ implicitChildLevelAdvances: attrs.listImplicitChildLevelAdvances ?? void 0,
69
+ markerSecondSlotOffsetTwips: attrs.listMarkerSecondSlotOffsetTwips ?? void 0
70
+ };
71
+ return {
72
+ marker: attrs.listMarker ?? "",
73
+ level: attrs.numPr?.ilvl ?? 0,
74
+ numId,
75
+ isBullet: attrs.listIsBullet ?? false,
76
+ ...definedFields(optional)
77
+ };
78
+ };
79
+ //#endregion
80
+ export { LIST_RENDERING_ATTR_BY_FIELD, LIST_RENDERING_ATTR_KEYS, listRenderingAttrPatch, listRenderingFromAttrs };
@@ -26,6 +26,21 @@ declare const RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS: Readonly<{
26
26
  readonly textBoxAnchor: "not-a-run";
27
27
  }>;
28
28
  declare const runFormattingInlineControlCharacter: (node: Node) => string | null;
29
+ /**
30
+ * Text an inline atom contributes to a flattened, reader-facing projection.
31
+ *
32
+ * A control-character carrier contributes its character; a field contributes its
33
+ * authored result, so a cross-reference reads as the text Word shows instead of
34
+ * vanishing. A field with no result contributes nothing: the placeholder
35
+ * `getFieldVisibleText` paints for the editor is a rendering decision, not
36
+ * document text, and one of its branches is the current date.
37
+ */
38
+ declare const runFormattingInlineAtomCleanText: (node: Node) => string | null;
39
+ /**
40
+ * Document text an inline atom contributes, as opposed to a control character:
41
+ * today a field's authored result.
42
+ */
43
+ declare const runFormattingInlineAtomResultText: (node: Node) => string | null;
29
44
  declare const runFormattingInlineControlNodeName: (character: string) => string | null;
30
45
  declare const runFormattingInlineAtomDisposition: (node: Node) => RunFormattingInlineAtomDisposition | null;
31
46
  type RunFormattingCarrierRepresentation = {
@@ -74,4 +89,4 @@ declare const selectRunFormattingCarrierRepresentations: ({ doc, from, to }: Sel
74
89
  /** Deterministic visible text for one logical formatting revision carrier. */
75
90
  declare const runFormattingCarrierReviewText: (carrier: RunFormattingCarrier) => string;
76
91
  //#endregion
77
- export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, RunFormattingCarrier, RunFormattingCarrierRepresentation, RunFormattingInlineAtomDisposition, SelectedRunFormattingCarrierRepresentation, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
92
+ export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, RunFormattingCarrier, RunFormattingCarrierRepresentation, RunFormattingInlineAtomDisposition, SelectedRunFormattingCarrierRepresentation, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomCleanText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
@@ -42,6 +42,25 @@ const runFormattingInlineControlCharacter = (node) => {
42
42
  if (disposition === null) return null;
43
43
  return CONTROL_CHARACTER_BY_DISPOSITION[disposition] ?? null;
44
44
  };
45
+ /**
46
+ * Text an inline atom contributes to a flattened, reader-facing projection.
47
+ *
48
+ * A control-character carrier contributes its character; a field contributes its
49
+ * authored result, so a cross-reference reads as the text Word shows instead of
50
+ * vanishing. A field with no result contributes nothing: the placeholder
51
+ * `getFieldVisibleText` paints for the editor is a rendering decision, not
52
+ * document text, and one of its branches is the current date.
53
+ */
54
+ const runFormattingInlineAtomCleanText = (node) => {
55
+ const disposition = runFormattingInlineAtomDisposition(node);
56
+ if (disposition === null) return null;
57
+ return runFormattingInlineAtomResultText(node) ?? CONTROL_CHARACTER_BY_DISPOSITION[disposition];
58
+ };
59
+ /**
60
+ * Document text an inline atom contributes, as opposed to a control character:
61
+ * today a field's authored result.
62
+ */
63
+ const runFormattingInlineAtomResultText = (node) => runFormattingInlineAtomDisposition(node) === "field-run" ? expectFieldAttrs(node).displayText ?? "" : null;
45
64
  const runFormattingInlineControlNodeName = (character) => {
46
65
  return Object.entries(RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS).find(([, disposition]) => CONTROL_CHARACTER_BY_DISPOSITION[disposition] === character)?.[0] ?? null;
47
66
  };
@@ -148,4 +167,4 @@ const runFormattingCarrierReviewText = (carrier) => {
148
167
  }
149
168
  };
150
169
  //#endregion
151
- export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomDisposition, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
170
+ export { RUN_FORMATTING_INLINE_ATOM_DISPOSITIONS, applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomCleanText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText, runFormattingInlineControlCharacter, runFormattingInlineControlNodeName, selectRunFormattingCarrierRepresentations };
@@ -201,7 +201,7 @@ type RunFormattingOverrideAttrs = {
201
201
  position?: 0;
202
202
  rtl?: false;
203
203
  scale?: 100;
204
- shading?: ShadingProperties & {
204
+ shading?: Omit<ShadingProperties, "pattern"> & {
205
205
  pattern: "nil";
206
206
  };
207
207
  spacing?: 0;
@@ -292,10 +292,25 @@ type ImageAttrs = {
292
292
  cropRight?: number;
293
293
  cropBottom?: number;
294
294
  cropLeft?: number;
295
+ /**
296
+ * `wp:effectExtent` reservation, in EMU — not pixels like `dist*` above.
297
+ * Nothing renders it, and `emuToPixels` rounds (12700 EMU would land back
298
+ * as 9525), so the editor carries the authored units untouched.
299
+ */
300
+ paddingTop?: number;
301
+ paddingRight?: number;
302
+ paddingBottom?: number;
303
+ paddingLeft?: number;
295
304
  /** Position for floating images (horizontal and vertical alignment) */
296
305
  position?: ImagePositionAttrs;
297
306
  /** Use the containing table cell as the anchor's positioning scope (the OOXML default). */
298
307
  layoutInCell?: boolean;
308
+ /**
309
+ * Authored `a:graphicFrameLocks`. Carried through the editor so a resize,
310
+ * which forces the serializer to regenerate DrawingML, cannot silently
311
+ * relax a lock the author set.
312
+ */
313
+ frameLocks?: document_d_exports.ImageFrameLocks;
299
314
  /** Border width in pixels */
300
315
  borderWidth?: number;
301
316
  /** Border color as CSS color string */
@@ -312,6 +327,11 @@ type ImageAttrs = {
312
327
  _docxRawXml?: string;
313
328
  /** Raw XML preserved without an editable image projection. */
314
329
  _docxRawXmlMode?: document_d_exports.DrawingRawXmlMode;
330
+ /**
331
+ * The fingerprint captured with `_docxRawXml`. A preview-only drawing must
332
+ * compare against this rather than re-baseline on its own edited projection.
333
+ */
334
+ _docxRawImageFingerprint?: string;
315
335
  /** Embedded-object previews use their authored box as the exact line height. */
316
336
  _docxObjectPreview?: boolean;
317
337
  };
@@ -2,6 +2,7 @@ import { computeListRendering, numberingLevelHasMarkerSlot } from "../../docx/nu
2
2
  import { tableOfContentsStyleLevel } from "../../utils/tableOfContentsStyle.js";
3
3
  import { setAutospacingBaseValue } from "../autospacingBase.js";
4
4
  import { CLEARED_LIST_RENDERING_ATTRS } from "../listMarker.js";
5
+ import { listRenderingAttrPatch } from "../listRenderingAttrs.js";
5
6
  //#region src/prosemirror/styles/resolvedStyleAttrs.ts
6
7
  /**
7
8
  * Shared helper for projecting a resolved paragraph style onto ProseMirror
@@ -103,20 +104,7 @@ function listAttrsFromNumbering(numPr, numbering) {
103
104
  return {
104
105
  ...CLEARED_LIST_RENDERING_ATTRS,
105
106
  numPr: targetNumPr,
106
- listNumFmt: rendering?.numFmt ?? null,
107
- listIsBullet: rendering?.isBullet ?? null,
108
- listIsLegal: rendering?.isLegal ?? null,
109
- listMarker: rendering?.marker ?? null,
110
- listMarkerTemplate: rendering?.markerTemplate ?? null,
111
- listMarkerHidden: rendering?.markerHidden ?? null,
112
- listMarkerFormatting: rendering?.markerFormatting ?? null,
113
- listMarkerAlignment: rendering?.markerAlignment ?? null,
114
- listMarkerSuffix: rendering?.markerSuffix ?? null,
115
- listMarkerAllCaps: rendering?.markerAllCaps ?? null,
116
- listLevelNumFmts: rendering?.levelNumFmts ?? null,
117
- listLevelStarts: rendering?.levelStarts ?? null,
118
- listAbstractNumId: rendering?.abstractNumId ?? null,
119
- listStartOverride: rendering?.startOverride ?? null
107
+ ...rendering && listRenderingAttrPatch(rendering)
120
108
  };
121
109
  }
122
110
  /** Recompute every level-dependent attr when a paragraph changes list level. */
@@ -85,7 +85,7 @@ function mergeDocumentContent(target, source) {
85
85
  function remapBlock(block, numIdRemap, abstractNumIdRemap) {
86
86
  if (block.type === "paragraph") return remapParagraph(block, numIdRemap, abstractNumIdRemap);
87
87
  if (block.type === "table") return remapTable(block, numIdRemap, abstractNumIdRemap);
88
- if ("content" in block && Array.isArray(block.content)) return {
88
+ if (block.type === "blockSdt" && Array.isArray(block.content)) return {
89
89
  ...block,
90
90
  content: block.content.map((child) => remapBlock(child, numIdRemap, abstractNumIdRemap))
91
91
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.39.1",
3
+ "version": "0.41.0",
4
4
  "description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
5
5
  "keywords": [
6
6
  "document-model",
@@ -121,7 +121,7 @@
121
121
  "perf": "bun scripts/profile-editor.ts"
122
122
  },
123
123
  "dependencies": {
124
- "@stll/docx-core": "^0.20.1",
124
+ "@stll/docx-core": "^0.21.0",
125
125
  "@stll/docx-utils": "^0.1.0",
126
126
  "@stll/template-conditions": ">=0.4.0 <1.0.0",
127
127
  "better-result": "3.0.1",