@stll/folio-core 0.58.4 → 0.59.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 (101) hide show
  1. package/dist/ai-edits/apply.d.ts +11 -12
  2. package/dist/ai-edits/apply.js +179 -168
  3. package/dist/ai-edits/headless.d.ts +15 -13
  4. package/dist/ai-edits/headless.js +40 -13
  5. package/dist/ai-edits/index.d.ts +3 -3
  6. package/dist/ai-edits/newListNumbering.d.ts +3 -9
  7. package/dist/ai-edits/newListNumbering.js +36 -41
  8. package/dist/ai-edits/referenceClassification.d.ts +22 -0
  9. package/dist/ai-edits/referenceClassification.js +21 -0
  10. package/dist/ai-edits/snapshot.js +39 -40
  11. package/dist/ai-edits/types.d.ts +24 -32
  12. package/dist/compare/column-alignment.d.ts +4 -4
  13. package/dist/compare/compare.d.ts +3 -7
  14. package/dist/compare/compare.js +25 -27
  15. package/dist/compare/content-alignment.d.ts +9 -9
  16. package/dist/compare/content-types.d.ts +23 -10
  17. package/dist/compare/content-types.js +14 -0
  18. package/dist/compare/content.d.ts +16 -17
  19. package/dist/compare/content.js +30 -7
  20. package/dist/compare/formatting.d.ts +3 -3
  21. package/dist/compare/import-style-closure.d.ts +22 -0
  22. package/dist/compare/import-style-closure.js +33 -0
  23. package/dist/compare/inserted-resource-snapshot.d.ts +15 -0
  24. package/dist/compare/inserted-resource-snapshot.js +63 -0
  25. package/dist/compare/plan.js +20 -13
  26. package/dist/compare/scenario.js +12 -2
  27. package/dist/compare/style-resources.d.ts +8 -2
  28. package/dist/compare/style-resources.js +63 -14
  29. package/dist/compare/verification.d.ts +15 -3
  30. package/dist/compare/verification.js +47 -8
  31. package/dist/compat/eigenpal.d.ts +4 -4
  32. package/dist/controller/canonicalListRendering.js +13 -22
  33. package/dist/controller/canonicalPublicOperations.js +1 -1
  34. package/dist/controller/canonicalStructure.js +45 -21
  35. package/dist/document-operations.d.ts +4 -9
  36. package/dist/document-operations.js +45 -41
  37. package/dist/docx/attributeRemainder.d.ts +1 -1
  38. package/dist/docx/index.d.ts +1 -1
  39. package/dist/docx/listMarkerComputation.js +9 -14
  40. package/dist/docx/listTemplate.d.ts +22 -0
  41. package/dist/docx/listTemplate.js +40 -0
  42. package/dist/docx/numberingParser.js +2 -2
  43. package/dist/docx/numberingReferenceNormalization.js +3 -3
  44. package/dist/docx/paragraphParser.js +3 -4
  45. package/dist/docx/rezip.js +2 -2
  46. package/dist/docx/server/materializeYjsDocx.js +2 -2
  47. package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
  48. package/dist/generated/text_shaper.js +8 -4
  49. package/dist/generated/text_shaper_bg.wasm +0 -0
  50. package/dist/index.d.ts +4 -4
  51. package/dist/internal/paragraphFormattingSerialization.d.ts +1 -8
  52. package/dist/internal/paragraphFormattingSerialization.js +6 -20
  53. package/dist/layout-bridge/convert/flowConversionShared.d.ts +1 -1
  54. package/dist/layout-bridge/convert/listMarkers.d.ts +1 -2
  55. package/dist/layout-bridge/convert/listMarkers.js +3 -11
  56. package/dist/layout-bridge/convert/paragraphAttrs.d.ts +1 -1
  57. package/dist/layout-bridge/convert/paragraphAttrs.js +8 -4
  58. package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -1
  59. package/dist/layout-bridge/convert/toFlowBlocks.js +2 -1
  60. package/dist/markdown/renderParagraph.js +29 -3
  61. package/dist/prosemirror/commands/comments.js +5 -32
  62. package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +7 -1
  63. package/dist/prosemirror/commands/paragraphBookmarkJoin.js +35 -1
  64. package/dist/prosemirror/commands/propertyChangeScope.js +6 -0
  65. package/dist/prosemirror/commands/resolveParagraphProperties.js +10 -5
  66. package/dist/prosemirror/conversion/fromProseDoc.js +23 -9
  67. package/dist/prosemirror/conversion/toProseDoc.js +31 -7
  68. package/dist/prosemirror/extensions/core/ParagraphExtension.js +29 -14
  69. package/dist/prosemirror/extensions/features/ListExtension.js +51 -21
  70. package/dist/prosemirror/listInstanceReferences.js +21 -15
  71. package/dist/prosemirror/listLabels.d.ts +4 -3
  72. package/dist/prosemirror/listLabels.js +18 -51
  73. package/dist/prosemirror/listMarker.d.ts +2 -19
  74. package/dist/prosemirror/listMarker.js +28 -57
  75. package/dist/prosemirror/listNumbering.js +16 -6
  76. package/dist/prosemirror/listRendering.d.ts +4 -3
  77. package/dist/prosemirror/listRendering.js +22 -3
  78. package/dist/prosemirror/listRenderingAttrs.d.ts +2 -1
  79. package/dist/prosemirror/listRenderingAttrs.js +6 -11
  80. package/dist/prosemirror/numberedRefFields.js +9 -5
  81. package/dist/prosemirror/numberingAttr.d.ts +19 -1
  82. package/dist/prosemirror/numberingAttr.js +16 -2
  83. package/dist/prosemirror/paragraphIndentation.js +5 -2
  84. package/dist/prosemirror/paragraphMarkJoin.js +17 -3
  85. package/dist/prosemirror/paragraphPropertyCarry.js +5 -6
  86. package/dist/prosemirror/plugins/transactionInvariants.js +6 -2
  87. package/dist/prosemirror/schema/nodes.d.ts +2 -1
  88. package/dist/prosemirror/selectionState.js +5 -1
  89. package/dist/prosemirror/storyListNumbering.js +11 -12
  90. package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -6
  91. package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +11 -4
  92. package/dist/prosemirror/styles/resolvedStyleAttrs.js +28 -18
  93. package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
  94. package/dist/prosemirror/yjsDocumentMetadata.js +42 -10
  95. package/dist/redline.d.ts +17 -1
  96. package/dist/redline.js +118 -57
  97. package/dist/server.d.ts +3 -3
  98. package/dist/server.js +2 -2
  99. package/dist/version-comparison.d.ts +1 -2
  100. package/dist/version-comparison.js +1 -2
  101. package/package.json +4 -3
@@ -1,4 +1,5 @@
1
1
  import { Fragment } from "prosemirror-model";
2
+ import { canJoin } from "prosemirror-transform";
2
3
  //#region src/prosemirror/commands/paragraphBookmarkJoin.ts
3
4
  /** The inline form of boundaries whose enclosing paragraph break was removed. */
4
5
  const inlineBookmarksOf = (boundaries) => {
@@ -18,5 +19,38 @@ const inlineBookmarksForParagraphJoin = ({ first, boundaries, second }) => {
18
19
  ]);
19
20
  return first.type.validContent(content) ? inline : null;
20
21
  };
22
+ /** Paragraph siblings separated only by typed bookmark boundaries. */
23
+ const paragraphJoinAfter = (doc, position) => {
24
+ const at = doc.resolve(position);
25
+ const first = at.nodeBefore;
26
+ if (first?.type.name !== "paragraph") return null;
27
+ const boundaries = [];
28
+ let nextPosition = position;
29
+ let index = at.index();
30
+ while (index < at.parent.childCount) {
31
+ const boundary = at.parent.child(index);
32
+ if (boundary.type.name !== "blockBookmarkBoundary") break;
33
+ boundaries.push(boundary);
34
+ nextPosition += boundary.nodeSize;
35
+ index++;
36
+ }
37
+ const next = index < at.parent.childCount ? at.parent.child(index) : null;
38
+ if (!next || next.type !== first.type) return null;
39
+ if (boundaries.length === 0) return canJoin(doc, position) ? {
40
+ next,
41
+ nextPosition,
42
+ inlineBookmarks: []
43
+ } : null;
44
+ const inlineBookmarks = inlineBookmarksForParagraphJoin({
45
+ first,
46
+ boundaries,
47
+ second: next
48
+ });
49
+ return inlineBookmarks ? {
50
+ next,
51
+ nextPosition,
52
+ inlineBookmarks
53
+ } : null;
54
+ };
21
55
  //#endregion
22
- export { inlineBookmarksForParagraphJoin, inlineBookmarksOf };
56
+ export { inlineBookmarksForParagraphJoin, inlineBookmarksOf, paragraphJoinAfter };
@@ -1,5 +1,6 @@
1
1
  import { isStyleSourcedParagraphNumbering } from "../../internal/paragraphFormattingSerialization.js";
2
2
  import { expectParagraphAttrs } from "../attrs/index.js";
3
+ import { LIST_RENDERING_ATTR_KEYS, hasListRendering } from "../listRenderingAttrs.js";
3
4
  import { readParagraphNumberingAttr } from "../numberingAttr.js";
4
5
  import { directParagraphAlignment } from "../paragraphAlignment.js";
5
6
  import { directionFromBidi } from "../paragraphDirection.js";
@@ -135,6 +136,11 @@ const paragraphPropertiesSnapshot = (node) => {
135
136
  }
136
137
  const directAlignment = directParagraphAlignment(attrs);
137
138
  if (directAlignment !== void 0) snapshot["alignment"] = directAlignment;
139
+ snapshot["numPrFromStyle"] = attrs.numPrFromStyle ?? null;
140
+ if (hasListRendering(attrs)) for (const key of LIST_RENDERING_ATTR_KEYS) {
141
+ const value = attrs[key];
142
+ if (value != null) snapshot[key] = value;
143
+ }
138
144
  Object.assign(snapshot, directParagraphSpacing(attrs), directParagraphIndentation(attrs));
139
145
  return snapshot;
140
146
  };
@@ -1,7 +1,7 @@
1
1
  import { resolveParagraphNumbering } from "../../docx/numberingReference.js";
2
2
  import { expectParagraphAttrs } from "../attrs/index.js";
3
3
  import { rejectedListRenderingPatch } from "../listRendering.js";
4
- import { paragraphNumberingAttr } from "../numberingAttr.js";
4
+ import { effectiveParagraphNumbering, paragraphNumberingAttr, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
5
5
  import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
6
6
  import { resolveParagraphDefaultTextFormatting } from "../styles/paragraphStyleCascade.js";
7
7
  import { listIndentationProvenancePatch } from "../styles/resolvedStyleAttrs.js";
@@ -38,12 +38,17 @@ const resolveParagraphChangeAttrs = ({ node, boundaryCovered, mode, revisionSet,
38
38
  if (!styleResolver && sameStyle) styleNumbering = currentAttrs.numPrFromStyle ?? void 0;
39
39
  const inheritedNumbering = styleNumbering == null ? null : paragraphNumberingAttr(resolveParagraphNumbering(styleNumbering));
40
40
  const recordedNumbering = rejection.previousFormatting?.numPr;
41
- const restoredNumbering = recordedNumbering ?? inheritedNumbering;
41
+ const restoredNumPrFromStyle = recordedNumbering?.kind === "reference" || recordedNumbering?.kind === "none" ? null : inheritedNumbering;
42
+ const effectiveNumbering = effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
43
+ numPr: recordedNumbering,
44
+ numPrFromStyle: restoredNumPrFromStyle
45
+ }));
46
+ const restoredNumbering = effectiveNumbering === void 0 ? null : paragraphNumberingAttr(effectiveNumbering);
42
47
  const restoredFormatting = paragraphRejectOriginalFormatting(rejection.previousFormatting, node.attrs["_originalFormatting"]);
43
48
  const indentation = listIndentationProvenancePatch({
44
49
  direct: paragraphIndentationFromFormatting(restoredFormatting ?? void 0),
45
50
  styleFormatting: previousFormattingFromStyle,
46
- numberingSource: recordedNumbering == null ? "style" : "paragraph",
51
+ numberingSource: recordedNumbering?.kind === "reference" ? "paragraph" : "style",
47
52
  numPr: restoredNumbering?.kind === "reference" ? {
48
53
  numId: restoredNumbering.numId,
49
54
  ilvl: restoredNumbering.ilvl ?? 0
@@ -60,8 +65,8 @@ const resolveParagraphChangeAttrs = ({ node, boundaryCovered, mode, revisionSet,
60
65
  numbering,
61
66
  restoredNumbering
62
67
  }), {
63
- numPr: restoredNumbering,
64
- numPrFromStyle: recordedNumbering == null ? inheritedNumbering : null
68
+ numPr: recordedNumbering ?? null,
69
+ numPrFromStyle: restoredNumPrFromStyle
65
70
  });
66
71
  Object.assign(nextAttrs, indentation);
67
72
  nextAttrs["_originalFormatting"] = restoredFormatting;
@@ -4,7 +4,7 @@ import { normalizeFoldedListNumbers } from "../../docx/foldedListNumberFields.js
4
4
  import { getDocumentSourceStyles } from "../../docx/headerFooterVerbatim.js";
5
5
  import { EDITED_PREVIEW_FINGERPRINT, imageRawXmlFingerprint } from "../../docx/imageRawXml.js";
6
6
  import { isInlineSdtContent, isSimpleFieldContent } from "../../docx/inlineWrapperContent.js";
7
- import { paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
7
+ import { paragraphNumberingReferenceId, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
8
8
  import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, assignParagraphIndentationProjection, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, inspectParagraphSourceIdentity, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
9
9
  import { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
10
10
  import { refingerprintShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
@@ -32,10 +32,11 @@ import "../extensions/nodes/MoveRangeBoundaryExtension.js";
32
32
  import "../extensions/nodes/RangeAnchorExtension.js";
33
33
  import { inlineWrapperMember, inlineWrapperStackKey } from "../inlineWrapperStack.js";
34
34
  import { completeNumberingForDoc } from "../listInstanceReferences.js";
35
- import { hasListRendering, listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
35
+ import { LIST_RENDERING_ATTR_KEYS, hasListRendering, listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
36
36
  import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
37
37
  import { assertNoteReferenceOccurrences, coalesceNoteReferenceOccurrences } from "../noteReferenceOccurrences.js";
38
38
  import { resolveNumberedRefFields } from "../numberedRefFields.js";
39
+ import { effectiveParagraphNumbering, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
39
40
  import { directParagraphAlignment } from "../paragraphAlignment.js";
40
41
  import { directionToAuthoredBidi } from "../paragraphDirection.js";
41
42
  import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
@@ -172,11 +173,11 @@ const restoreParagraphPropertySource = (paragraph, baseParagraph) => {
172
173
  }
173
174
  }
174
175
  const { numPr, numPrFromStyle } = baseFormatting;
175
- if (!numPr || !numPrFromStyle || !isStyleSourcedParagraphNumbering(numPr, numPrFromStyle)) return;
176
+ if (numPrFromStyle == null || numPr != null && numPr.kind !== "levelOnly") return;
176
177
  if (canonicalJson(modelParagraphFormattingEmission(paragraph.formatting)) !== canonicalJson(modelParagraphFormattingEmission(baseFormatting))) return;
177
178
  paragraph.formatting = {
178
179
  ...paragraph.formatting,
179
- numPr,
180
+ ...numPr === void 0 ? {} : { numPr },
180
181
  numPrFromStyle
181
182
  };
182
183
  };
@@ -1024,7 +1025,10 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
1024
1025
  * list markers on the way out of the editor.
1025
1026
  */
1026
1027
  function listRenderingFromAttrs(attrs) {
1027
- const numId = paragraphNumberingReferenceId$1(attrs.numPr);
1028
+ const numId = paragraphNumberingReferenceId(effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
1029
+ numPr: attrs.numPr,
1030
+ numPrFromStyle: attrs.numPrFromStyle
1031
+ })));
1028
1032
  if (numId === void 0) return;
1029
1033
  if (!hasListRendering(attrs)) return;
1030
1034
  return listRenderingFromAttrs$1({
@@ -1101,7 +1105,10 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers, styleRes
1101
1105
  if (attrs.reviewCarrier) paragraph.reviewCarrier = attrs.reviewCarrier;
1102
1106
  const pFormatting = paragraphAttrsToFormatting(attrs);
1103
1107
  if (pFormatting) paragraph.formatting = pFormatting;
1104
- if (attrs.numPr?.kind === "reference") {
1108
+ if (effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
1109
+ numPr: attrs.numPr,
1110
+ numPrFromStyle: attrs.numPrFromStyle
1111
+ }))?.kind === "reference") {
1105
1112
  const inheritedIndentation = paragraphIndentationFromFormatting(attrs._resolvedFormatting);
1106
1113
  if (inheritedIndentation) assignParagraphIndentationProjection({
1107
1114
  paragraph,
@@ -1133,14 +1140,18 @@ const propertyChangeFromAttrs = (change) => {
1133
1140
  ...normalizedChangeInfo,
1134
1141
  currentFormatting
1135
1142
  };
1136
- const { numPr, ...previousWithoutNumPr } = previousFormatting;
1143
+ const { numPr, numPrFromStyle, ...previousWithoutNumPr } = previousFormatting;
1137
1144
  const normalizedPrevious = numPr == null ? previousWithoutNumPr : {
1138
1145
  ...previousWithoutNumPr,
1139
1146
  numPr
1140
1147
  };
1148
+ for (const key of LIST_RENDERING_ATTR_KEYS) if (normalizedPrevious[key] == null) Reflect.deleteProperty(normalizedPrevious, key);
1141
1149
  return {
1142
1150
  ...normalizedChangeInfo,
1143
- previousFormatting: normalizedPrevious,
1151
+ previousFormatting: {
1152
+ ...normalizedPrevious,
1153
+ ...numPrFromStyle == null ? {} : { numPrFromStyle }
1154
+ },
1144
1155
  ...currentFormatting !== void 0 && { currentFormatting }
1145
1156
  };
1146
1157
  };
@@ -1269,7 +1280,10 @@ function paragraphAttrsToFormatting(attrs) {
1269
1280
  const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
1270
1281
  const bidi = authored("bidi", directionToAuthoredBidi(attrs.direction));
1271
1282
  const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
1272
- const numbered = paragraphNumberingReferenceId$1(attrs.numPr ?? void 0) !== void 0;
1283
+ const numbered = paragraphNumberingReferenceId(effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
1284
+ numPr: attrs.numPr,
1285
+ numPrFromStyle: attrs.numPrFromStyle
1286
+ }))) !== void 0;
1273
1287
  const statedIndent = (value) => value === 0 && !numbered ? void 0 : value;
1274
1288
  const indentLeft = statedIndent(authored("indentLeft", attrs.indentLeft));
1275
1289
  const indentRight = authored("indentRight", attrs.indentRight);
@@ -33,9 +33,10 @@ import "../extensions/nodes/SdtExtension.js";
33
33
  import { fieldRequiresStructuredContent } from "../fieldRepresentation.js";
34
34
  import { inlineWrapperLayer } from "../inlineWrapperStack.js";
35
35
  import { CLEARED_LIST_RENDERING_ATTRS } from "../listMarker.js";
36
+ import { listRenderingFor } from "../listRendering.js";
36
37
  import { listRenderingAttrPatch } from "../listRenderingAttrs.js";
37
38
  import { stampNumberedRefFieldBaselines } from "../numberedRefFields.js";
38
- import { paragraphNumberingAttr } from "../numberingAttr.js";
39
+ import { effectiveParagraphNumbering, paragraphNumberingAttr, paragraphNumberingSourcesFromBoundary } from "../numberingAttr.js";
39
40
  import { pageBreakRunParagraphProjectionDispositionForFeatures } from "../pageBreakRunProjection.js";
40
41
  import { directionFromBidi } from "../paragraphDirection.js";
41
42
  import { paragraphIndentationFromFormatting } from "../paragraphIndentation.js";
@@ -57,7 +58,7 @@ import { createMarkInterner } from "./markInterner.js";
57
58
  import { hasSinkChildren } from "./preservedSinkCarriers.js";
58
59
  import { sdtAttrsFromProperties } from "./sdtAttrs.js";
59
60
  import { panic } from "better-result";
60
- import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES, mergeParagraphNumbering } from "@stll/docx-core/model";
61
+ import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES } from "@stll/docx-core/model";
61
62
  //#region src/prosemirror/conversion/toProseDoc.ts
62
63
  /**
63
64
  * Document to ProseMirror Conversion
@@ -429,8 +430,11 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
429
430
  const { attrs, effectiveFrame } = paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOverlay);
430
431
  if (directFormatting === void 0) Reflect.deleteProperty(attrs, "_originalFormatting");
431
432
  else attrs._originalFormatting = directFormatting;
432
- const numPr = mergeParagraphNumbering(attrs.numPrFromStyle ?? void 0, attrs.numPr ?? void 0);
433
- if (numPr?.kind === "none" || paragraph.listRendering !== void 0 && context.numbering !== void 0 && numPr === void 0) Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
433
+ const numPr = effectiveParagraphNumbering(paragraphNumberingSourcesFromBoundary({
434
+ numPr: attrs.numPr,
435
+ numPrFromStyle: attrs.numPrFromStyle
436
+ }));
437
+ if (numPr.kind === "none" && (paragraph.formatting?.numPr?.kind === "none" || paragraph.listRendering !== void 0 && context.numbering !== void 0)) Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
434
438
  else if (context.numbering !== void 0 && numPr?.kind === "reference") {
435
439
  Object.assign(attrs, listIndentationProvenancePatch({
436
440
  direct: paragraphIndentationFromFormatting(directFormatting),
@@ -448,6 +452,25 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
448
452
  if (!(cached !== void 0 && listRenderingDefinitionsMatch(cached, rendering) && (cached.markerSecondSlotOffsetTwips === void 0 || cached.markerSecondSlotOffsetTwips === nextSlotOffset))) Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS, listRenderingAttrPatch(rendering));
449
453
  } else Object.assign(attrs, CLEARED_LIST_RENDERING_ATTRS);
450
454
  }
455
+ if (attrs._propertyChanges) attrs._propertyChanges = attrs._propertyChanges.map((change) => {
456
+ const previous = change.previousFormatting;
457
+ if (!previous) return change;
458
+ const inherited = styleResolver?.resolveParagraphStyle(previous.styleId ?? void 0).paragraphFormatting?.numPr;
459
+ const sources = paragraphNumberingSourcesFromBoundary({
460
+ numPr: previous.numPr,
461
+ numPrFromStyle: inherited ?? previous.numPrFromStyle
462
+ });
463
+ const originalNumbering = effectiveParagraphNumbering(sources);
464
+ const originalRendering = originalNumbering.kind === "reference" ? listRenderingFor(originalNumbering, context.numbering ?? null) : {};
465
+ return {
466
+ ...change,
467
+ previousFormatting: {
468
+ ...originalRendering,
469
+ ...previous,
470
+ numPrFromStyle: sources.numPrFromStyle === void 0 ? null : paragraphNumberingAttr(sources.numPrFromStyle)
471
+ }
472
+ };
473
+ });
451
474
  reportParagraphPageBreakProjection({
452
475
  paragraph,
453
476
  attrs,
@@ -813,12 +836,13 @@ function paragraphFormattingToAttrs(paragraph, styleResolver, tableParagraphOver
813
836
  if (formatting) attrs._originalFormatting = formatting;
814
837
  if (paragraph.propertyChanges && paragraph.propertyChanges.length > 0) attrs._propertyChanges = paragraph.propertyChanges.map(({ previousFormatting, ...change }) => {
815
838
  if (previousFormatting === void 0) return change;
816
- const { numPr, ...rest } = previousFormatting;
839
+ const { numPr, numPrFromStyle, ...rest } = previousFormatting;
817
840
  return {
818
841
  ...change,
819
- previousFormatting: numPr === void 0 ? rest : {
842
+ previousFormatting: {
820
843
  ...rest,
821
- numPr: paragraphNumberingAttr(numPr)
844
+ ...numPr === void 0 ? {} : { numPr: paragraphNumberingAttr(numPr) },
845
+ ...numPrFromStyle === void 0 ? {} : { numPrFromStyle: paragraphNumberingAttr(numPrFromStyle) }
822
846
  }
823
847
  };
824
848
  });
@@ -11,6 +11,7 @@ import { autospacingMatchesBase } from "../../autospacingBase.js";
11
11
  import { withCanonicalCommand, withCanonicalParagraphFormatting, withCanonicalStartParagraphFormatting } from "../../canonicalCommands.js";
12
12
  import { removeSectionBreakAtSelection, setSectionBreakType } from "../../commands/sectionBreak.js";
13
13
  import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
14
+ import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "../../numberingAttr.js";
14
15
  import { directParagraphAlignment } from "../../paragraphAlignment.js";
15
16
  import { directionIsRtl } from "../../paragraphDirection.js";
16
17
  import { directParagraphIndentation } from "../../paragraphIndentation.js";
@@ -23,7 +24,7 @@ import { rebaseParagraphRuns } from "../../rebaseParagraphRuns.js";
23
24
  import { mintSectionProperties, parseSectionBreakType, sectionBreakTypeOf } from "../../sectionCarrier.js";
24
25
  import { listAttrsFromResolvedStyle, listIndentationProvenancePatch, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
25
26
  import { createNodeExtension } from "../create.js";
26
- import { headingOutlineLevel, paragraphNumberingLevel, paragraphNumberingReferenceId } from "@stll/docx-core/model";
27
+ import { headingOutlineLevel } from "@stll/docx-core/model";
27
28
  import { Fragment } from "prosemirror-model";
28
29
  //#region src/prosemirror/extensions/core/ParagraphExtension.ts
29
30
  /**
@@ -36,7 +37,11 @@ import { Fragment } from "prosemirror-model";
36
37
  function paragraphAttrsToDOMStyle(attrs) {
37
38
  const rawIndentLeft = Reflect.get(attrs, "indentLeft");
38
39
  let indentLeft = typeof rawIndentLeft === "number" ? rawIndentLeft : void 0;
39
- if (paragraphNumberingReferenceId(attrs.numPr) !== void 0 && (rawIndentLeft === null || rawIndentLeft === void 0)) indentLeft = ((paragraphNumberingLevel(attrs.numPr) ?? 0) + 1) * 720;
40
+ const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
41
+ numPr: attrs.numPr,
42
+ numPrFromStyle: attrs.numPrFromStyle
43
+ }));
44
+ if (numbering !== void 0 && (rawIndentLeft === null || rawIndentLeft === void 0)) indentLeft = (numbering.ilvl + 1) * 720;
40
45
  const style = paragraphToStyle({
41
46
  ...attrs.alignment !== void 0 ? { alignment: attrs.alignment } : {},
42
47
  ...attrs.spaceBefore !== void 0 ? { spaceBefore: attrs.spaceBefore } : {},
@@ -71,11 +76,15 @@ function numFmtToClass(numFmt) {
71
76
  default: return "docx-list-decimal";
72
77
  }
73
78
  }
74
- function getListClass(numPr, listIsBullet, listNumFmt) {
75
- if (paragraphNumberingReferenceId(numPr) === void 0) return "";
76
- const level = paragraphNumberingLevel(numPr) ?? 0;
77
- if (listIsBullet) return `docx-list-bullet docx-list-level-${level}`;
78
- return `docx-list-numbered ${numFmtToClass(listNumFmt)} docx-list-level-${level}`;
79
+ function getListClass(attrs) {
80
+ const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
81
+ numPr: attrs.numPr,
82
+ numPrFromStyle: attrs.numPrFromStyle
83
+ }));
84
+ if (numbering === void 0) return "";
85
+ const level = numbering.ilvl;
86
+ if (attrs.listIsBullet) return `docx-list-bullet docx-list-level-${level}`;
87
+ return `docx-list-numbered ${numFmtToClass(attrs.listNumFmt)} docx-list-level-${level}`;
79
88
  }
80
89
  /**
81
90
  * Parse a CSS length value to twips.
@@ -342,7 +351,7 @@ const paragraphNodeSpec = {
342
351
  toDOM(node) {
343
352
  const attrs = expectParagraphAttrs(node);
344
353
  const style = paragraphAttrsToDOMStyle(attrs);
345
- const listClass = getListClass(attrs.numPr, attrs.listIsBullet, attrs.listNumFmt);
354
+ const listClass = getListClass(attrs);
346
355
  const domAttrs = {};
347
356
  if (style) domAttrs["style"] = style;
348
357
  if (listClass) domAttrs["class"] = listClass;
@@ -535,7 +544,10 @@ function makeDecreaseIndent(amount = 720) {
535
544
  seen.add(pos);
536
545
  const currentIndent = node.attrs["indentLeft"] || 0;
537
546
  const newIndent = Math.max(0, currentIndent - amount);
538
- const numbered = paragraphNumberingReferenceId(expectParagraphAttrs(node).numPr ?? void 0) !== void 0;
547
+ const numbered = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
548
+ numPr: expectParagraphAttrs(node).numPr,
549
+ numPrFromStyle: expectParagraphAttrs(node).numPrFromStyle
550
+ })) !== void 0;
539
551
  tr = tr.setNodeMarkup(pos, void 0, {
540
552
  ...node.attrs,
541
553
  indentLeft: newIndent > 0 || numbered ? newIndent : null
@@ -581,19 +593,19 @@ function makeApplyStyle() {
581
593
  } else Object.assign(newAttrs, directParagraphAttrs(current));
582
594
  newAttrs["_originalFormatting"] = restyledOriginal ?? null;
583
595
  const listAttrs = listAttrsFromResolvedStyle(resolvedAttrs, resolvedAttrs.numbering);
584
- const directNumId = current.numPrFromStyle == null ? paragraphNumberingReferenceId(current.numPr ?? void 0) : void 0;
596
+ const directNumbering = current.numPrFromStyle == null && current.numPr?.kind === "reference" ? current.numPr : void 0;
585
597
  if (listAttrs) Object.assign(newAttrs, listAttrs);
586
598
  else if (isStyleSourcedParagraphNumbering(current.numPr, current.numPrFromStyle)) Object.assign(newAttrs, CLEARED_LIST_RENDERING_ATTRS, {
587
599
  numPr: null,
588
600
  numPrFromStyle: null
589
601
  });
590
- else if (directNumId !== void 0) Object.assign(newAttrs, listIndentationProvenancePatch({
602
+ else if (directNumbering !== void 0) Object.assign(newAttrs, listIndentationProvenancePatch({
591
603
  direct: restyledIndentation(styleAttrs, restyledOriginal),
592
604
  styleFormatting: resolvedAttrs.paragraphFormatting,
593
605
  numberingSource: "paragraph",
594
606
  numPr: {
595
- numId: directNumId,
596
- ilvl: paragraphNumberingLevel(current.numPr ?? void 0) ?? 0
607
+ numId: directNumbering.numId,
608
+ ilvl: directNumbering.ilvl ?? 0
597
609
  },
598
610
  numbering: resolvedAttrs.numbering ?? getDocumentNumbering(state)
599
611
  }));
@@ -677,7 +689,10 @@ const ParagraphExtension = createNodeExtension({
677
689
  decreaseIndent: (amount) => withCanonicalParagraphFormatting(makeDecreaseIndent(amount), (node) => {
678
690
  const attrs = expectParagraphAttrs(node);
679
691
  const indentLeft = Math.max(0, (attrs.indentLeft ?? 0) - (amount ?? 720));
680
- return { indentLeft: indentLeft > 0 || paragraphNumberingReferenceId(attrs.numPr ?? void 0) !== void 0 ? indentLeft : null };
692
+ return { indentLeft: indentLeft > 0 || effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
693
+ numPr: attrs.numPr,
694
+ numPrFromStyle: attrs.numPrFromStyle
695
+ })) !== void 0 ? indentLeft : null };
681
696
  }),
682
697
  setIndentLeft: (twips) => withCanonicalParagraphFormatting(setParagraphAttr("indentLeft", twips > 0 ? twips : null), { indentLeft: twips > 0 ? twips : null }),
683
698
  setIndentRight: (twips) => withCanonicalParagraphFormatting(setParagraphAttr("indentRight", twips > 0 ? twips : null), { indentRight: twips > 0 ? twips : null }),
@@ -5,7 +5,7 @@ import { LIST_MARKER_PATTERN, listRequestsForMarker } from "../../listAutoformat
5
5
  import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
6
6
  import { applyParagraphUpdates, continueNumbering, listItemAttrs, resolveListTarget, restartNumbering, setNumberingValue } from "../../listNumbering.js";
7
7
  import { resolveListState } from "../../listState.js";
8
- import { removedNumberingAttr } from "../../numberingAttr.js";
8
+ import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary, removedNumberingAttr } from "../../numberingAttr.js";
9
9
  import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
10
10
  import { SUGGESTION_META, makeRevisionInfo, suggestRangeDeletion } from "../../plugins/suggestionMode.js";
11
11
  import { listLevelAttrPatch, listLevelIndentRemovalPatch } from "../../styles/resolvedStyleAttrs.js";
@@ -36,9 +36,10 @@ function clearListAttrs(attrs, numbering) {
36
36
  ...CLEARED_LIST_RENDERING_ATTRS
37
37
  };
38
38
  }
39
- function hasActiveListNumbering(attrs) {
40
- return attrs.numPr?.kind === "reference";
41
- }
39
+ const hasActiveListNumbering = (attrs) => effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
40
+ numPr: attrs.numPr,
41
+ numPrFromStyle: attrs.numPrFromStyle
42
+ })) !== void 0;
42
43
  const paragraphsBetween = (doc, from, to) => {
43
44
  const paragraphs = [];
44
45
  doc.nodesBetween(from, to, (node, pos) => {
@@ -73,7 +74,10 @@ const numberParagraphs = ({ state, tr, from, to, requests }) => {
73
74
  node,
74
75
  next: listItemAttrs(expectParagraphAttrs(node), {
75
76
  numId: target.numId,
76
- ilvl: paragraphNumberingLevel(expectParagraphAttrs(node).numPr) ?? target.ilvl
77
+ ilvl: paragraphNumberingLevel(effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
78
+ numPr: expectParagraphAttrs(node).numPr,
79
+ numPrFromStyle: expectParagraphAttrs(node).numPrFromStyle
80
+ }))) ?? target.ilvl
77
81
  }, target.numbering)
78
82
  }))
79
83
  });
@@ -86,7 +90,10 @@ function toggleList(intent) {
86
90
  if (paragraph.type.name !== "paragraph") return false;
87
91
  if (!dispatch) return true;
88
92
  const numbering = getDocumentNumbering(state);
89
- const isItemOfKind = (node) => resolveListState(numbering, expectParagraphAttrs(node).numPr).type === intent;
93
+ const isItemOfKind = (node) => resolveListState(numbering, effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
94
+ numPr: expectParagraphAttrs(node).numPr,
95
+ numPrFromStyle: expectParagraphAttrs(node).numPrFromStyle
96
+ }))).type === intent;
90
97
  const tr = state.tr;
91
98
  if (isItemOfKind(paragraph)) applyParagraphUpdates({
92
99
  tr,
@@ -117,13 +124,13 @@ const toggleNumberedList = withCanonicalCommand((state, dispatch) => toggleList(
117
124
  kind: "decimal"
118
125
  }]);
119
126
  const attrsForListLevel = (state, attrs, level) => {
120
- if (!hasActiveListNumbering(attrs)) panic("Cannot change the level of a list without a numbering id");
127
+ if (effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
128
+ numPr: attrs.numPr,
129
+ numPrFromStyle: attrs.numPrFromStyle
130
+ })) === void 0) panic("Cannot change the level of a list without a numbering id");
121
131
  return {
122
132
  ...attrs,
123
- ...listLevelAttrPatch(attrs, {
124
- numId: attrs.numPr.numId,
125
- ilvl: level
126
- }, getDocumentNumbering(state))
133
+ ...listLevelAttrPatch(attrs, level, getDocumentNumbering(state))
127
134
  };
128
135
  };
129
136
  const increaseListLevel = (state, dispatch) => {
@@ -132,7 +139,10 @@ const increaseListLevel = (state, dispatch) => {
132
139
  if (paragraph.type.name !== "paragraph") return false;
133
140
  const attrs = expectParagraphAttrs(paragraph);
134
141
  if (!hasActiveListNumbering(attrs)) return false;
135
- const currentLevel = attrs.numPr.ilvl ?? 0;
142
+ const currentLevel = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
143
+ numPr: attrs.numPr,
144
+ numPrFromStyle: attrs.numPrFromStyle
145
+ }))?.ilvl ?? 0;
136
146
  if (currentLevel >= 8) return false;
137
147
  if (!dispatch) return true;
138
148
  const paragraphPos = $from.before($from.depth);
@@ -145,7 +155,10 @@ const decreaseListLevel = (state, dispatch) => {
145
155
  if (paragraph.type.name !== "paragraph") return false;
146
156
  const attrs = expectParagraphAttrs(paragraph);
147
157
  if (!hasActiveListNumbering(attrs)) return false;
148
- const currentLevel = attrs.numPr.ilvl ?? 0;
158
+ const currentLevel = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
159
+ numPr: attrs.numPr,
160
+ numPrFromStyle: attrs.numPrFromStyle
161
+ }))?.ilvl ?? 0;
149
162
  if (!dispatch) return true;
150
163
  const paragraphPos = $from.before($from.depth);
151
164
  if (currentLevel <= 0) dispatch(state.tr.setNodeMarkup(paragraphPos, void 0, {
@@ -182,10 +195,14 @@ function getListInfo(state) {
182
195
  const paragraph = $from.parent;
183
196
  if (paragraph.type.name !== "paragraph") return null;
184
197
  const attrs = expectParagraphAttrs(paragraph);
185
- if (!hasActiveListNumbering(attrs)) return null;
198
+ const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
199
+ numPr: attrs.numPr,
200
+ numPrFromStyle: attrs.numPrFromStyle
201
+ }));
202
+ if (numbering === void 0) return null;
186
203
  return {
187
- numId: attrs.numPr.numId,
188
- ilvl: attrs.numPr.ilvl ?? 0
204
+ numId: numbering.numId,
205
+ ilvl: numbering.ilvl ?? 0
189
206
  };
190
207
  }
191
208
  function exitListOnEmptyEnter() {
@@ -219,7 +236,8 @@ function splitListItem() {
219
236
  if (!empty) return false;
220
237
  const paragraph = $from.parent;
221
238
  if (paragraph.type.name !== "paragraph") return false;
222
- if (!hasActiveListNumbering(expectParagraphAttrs(paragraph))) return false;
239
+ const attrs = expectParagraphAttrs(paragraph);
240
+ if (!hasActiveListNumbering(attrs)) return false;
223
241
  if (dispatch) {
224
242
  const { tr } = state;
225
243
  const pos = $from.pos;
@@ -274,7 +292,10 @@ function increaseListIndent() {
274
292
  if (node.type.name === "paragraph") {
275
293
  const attrs = expectParagraphAttrs(node);
276
294
  if (!hasActiveListNumbering(attrs)) return;
277
- if ((attrs.numPr.ilvl ?? 0) < 8) positions.push({
295
+ if ((effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
296
+ numPr: attrs.numPr,
297
+ numPrFromStyle: attrs.numPrFromStyle
298
+ }))?.ilvl ?? 0) < 8) positions.push({
278
299
  pos,
279
300
  attrs
280
301
  });
@@ -283,7 +304,10 @@ function increaseListIndent() {
283
304
  if (positions.length === 0) return false;
284
305
  if (dispatch) {
285
306
  let tr = state.tr;
286
- for (const { pos, attrs } of positions) tr = tr.setNodeMarkup(pos, void 0, attrsForListLevel(state, attrs, (attrs.numPr.ilvl ?? 0) + 1));
307
+ for (const { pos, attrs } of positions) tr = tr.setNodeMarkup(pos, void 0, attrsForListLevel(state, attrs, (effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
308
+ numPr: attrs.numPr,
309
+ numPrFromStyle: attrs.numPrFromStyle
310
+ }))?.ilvl ?? 0) + 1));
287
311
  dispatch(tr);
288
312
  }
289
313
  return true;
@@ -306,7 +330,10 @@ function decreaseListIndent() {
306
330
  if (dispatch) {
307
331
  let tr = state.tr;
308
332
  for (const { pos, attrs } of positions) {
309
- const currentLevel = attrs.numPr.ilvl ?? 0;
333
+ const currentLevel = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
334
+ numPr: attrs.numPr,
335
+ numPrFromStyle: attrs.numPrFromStyle
336
+ }))?.ilvl ?? 0;
310
337
  if (currentLevel <= 0) tr = tr.setNodeMarkup(pos, void 0, {
311
338
  ...clearListAttrs(attrs, getDocumentNumbering(state)),
312
339
  indentLeft: null,
@@ -330,7 +357,10 @@ function insertTab() {
330
357
  };
331
358
  }
332
359
  /** Whether a typed marker may become a list here at all. */
333
- const acceptsListMarker = (paragraph) => paragraph.type.name === "paragraph" && paragraphNumberingReferenceId(expectParagraphAttrs(paragraph).numPr) === void 0;
360
+ const acceptsListMarker = (paragraph) => paragraph.type.name === "paragraph" && paragraphNumberingReferenceId(effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
361
+ numPr: expectParagraphAttrs(paragraph).numPr,
362
+ numPrFromStyle: expectParagraphAttrs(paragraph).numPrFromStyle
363
+ }))) === void 0;
334
364
  /**
335
365
  * Replace a typed marker with the list the toolbar button produces: the same
336
366
  * target resolution and the same attrs, so an autoformatted list saves exactly
@@ -1,7 +1,7 @@
1
1
  import { completeListNumbering } from "../docx/listNumberingInstances.js";
2
- import { paragraphNumberingLevel, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
3
2
  import { expectParagraphAttrs } from "./attrs/index.js";
4
3
  import { hasListRendering, listRenderingFromAttrs } from "./listRenderingAttrs.js";
4
+ import { effectiveParagraphNumberingReference, paragraphNumberingSourcesFromBoundary } from "./numberingAttr.js";
5
5
  //#region src/prosemirror/listInstanceReferences.ts
6
6
  const PARAGRAPH_NODE = "paragraph";
7
7
  /**
@@ -10,15 +10,18 @@ const PARAGRAPH_NODE = "paragraph";
10
10
  * define an instance from.
11
11
  */
12
12
  const collectReference = (attrs, sink) => {
13
- const numId = paragraphNumberingReferenceId(attrs.numPr);
14
- if (numId === void 0 || sink.isDefined(numId)) return;
13
+ const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
14
+ numPr: attrs.numPr,
15
+ numPrFromStyle: attrs.numPrFromStyle
16
+ }));
17
+ if (numbering === void 0 || sink.isDefined(numbering.numId)) return;
15
18
  if (!hasListRendering(attrs)) return;
16
19
  sink.references.push({
17
- numId,
18
- ilvl: paragraphNumberingLevel(attrs.numPr) ?? 0,
20
+ numId: numbering.numId,
21
+ ilvl: numbering.ilvl,
19
22
  rendering: listRenderingFromAttrs({
20
23
  attrs,
21
- numId
24
+ numId: numbering.numId
22
25
  })
23
26
  });
24
27
  };
@@ -38,10 +41,7 @@ const undefinedListInstanceReferences = (doc, isDefined) => {
38
41
  collectReference(attrs, sink);
39
42
  for (const change of attrs._propertyChanges ?? []) {
40
43
  const previous = change.previousFormatting;
41
- if (previous?.numPr) collectReference({
42
- ...previous,
43
- numPr: previous.numPr
44
- }, sink);
44
+ if (previous) collectReference(previous, sink);
45
45
  }
46
46
  return false;
47
47
  });
@@ -52,12 +52,18 @@ const paragraphListReferences = (node) => {
52
52
  if (node.type.name !== PARAGRAPH_NODE) return [];
53
53
  const attrs = expectParagraphAttrs(node);
54
54
  const numIds = [];
55
- const add = (numPr) => {
56
- const numId = paragraphNumberingReferenceId(numPr ?? void 0);
57
- if (numId !== void 0) numIds.push(numId);
55
+ const add = (source) => {
56
+ const numbering = effectiveParagraphNumberingReference(paragraphNumberingSourcesFromBoundary({
57
+ numPr: source.numPr,
58
+ numPrFromStyle: source.numPrFromStyle
59
+ }));
60
+ if (numbering !== void 0) numIds.push(numbering.numId);
58
61
  };
59
- add(attrs.numPr);
60
- for (const change of attrs._propertyChanges ?? []) add(change.previousFormatting?.numPr);
62
+ add(attrs);
63
+ for (const change of attrs._propertyChanges ?? []) {
64
+ const previous = change.previousFormatting;
65
+ if (previous) add(previous);
66
+ }
61
67
  return numIds;
62
68
  };
63
69
  /**
@@ -1,6 +1,7 @@
1
1
  import { document_d_exports } from "../types/document.js";
2
+ import { ParagraphNumberingSources } from "./numberingAttr.js";
2
3
  import { ParagraphAttrs } from "./schema/nodes.js";
3
- import { ParagraphNumberingOverride } from "../docx/numberingReference.js";
4
+ import { ListCounterStreams } from "./listMarker.js";
4
5
  //#region src/prosemirror/listLabels.d.ts
5
6
  /**
6
7
  * The attrs the counter reads for a paragraph of the document model, as
@@ -8,7 +9,7 @@ import { ParagraphNumberingOverride } from "../docx/numberingReference.js";
8
9
  * attrs no label depends on: a reader that walks the model (Markdown) counts
9
10
  * every list paragraph through here.
10
11
  */
11
- declare const listLabelAttrsFromRendering: (rendering: document_d_exports.ListRendering, numPrFromStyle: ParagraphNumberingOverride | undefined) => ParagraphAttrs;
12
+ declare const listLabelAttrsFromRendering: (rendering: document_d_exports.ListRendering | undefined, { numPr, numPrFromStyle }: ParagraphNumberingSources) => ParagraphAttrs;
12
13
  /**
13
14
  * Advances past one paragraph and answers the label it shows, or `undefined`
14
15
  * when it shows none.
@@ -19,6 +20,6 @@ type ListLabelCounter = (attrs: Readonly<ParagraphAttrs>) => string | undefined;
19
20
  * paragraph, numbered or not: whether a list continues depends on what stands
20
21
  * between its items.
21
22
  */
22
- declare const createListLabelCounter: () => ListLabelCounter;
23
+ declare const createListLabelCounter: (streams?: ListCounterStreams) => ListLabelCounter;
23
24
  //#endregion
24
25
  export { ListLabelCounter, createListLabelCounter, listLabelAttrsFromRendering };