@stll/folio-core 0.58.5 → 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.
- package/dist/ai-edits/apply.d.ts +11 -12
- package/dist/ai-edits/apply.js +179 -168
- package/dist/ai-edits/headless.d.ts +15 -13
- package/dist/ai-edits/headless.js +40 -13
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/newListNumbering.d.ts +3 -9
- package/dist/ai-edits/newListNumbering.js +36 -41
- package/dist/ai-edits/referenceClassification.d.ts +22 -0
- package/dist/ai-edits/referenceClassification.js +21 -0
- package/dist/ai-edits/snapshot.js +39 -40
- package/dist/ai-edits/types.d.ts +24 -32
- package/dist/compare/column-alignment.d.ts +4 -4
- package/dist/compare/compare.d.ts +3 -7
- package/dist/compare/compare.js +25 -27
- package/dist/compare/content-alignment.d.ts +9 -9
- package/dist/compare/content-types.d.ts +23 -10
- package/dist/compare/content-types.js +14 -0
- package/dist/compare/content.d.ts +16 -17
- package/dist/compare/content.js +30 -7
- package/dist/compare/formatting.d.ts +3 -3
- package/dist/compare/import-style-closure.d.ts +22 -0
- package/dist/compare/import-style-closure.js +33 -0
- package/dist/compare/inserted-resource-snapshot.d.ts +15 -0
- package/dist/compare/inserted-resource-snapshot.js +63 -0
- package/dist/compare/plan.js +20 -13
- package/dist/compare/scenario.js +12 -2
- package/dist/compare/style-resources.d.ts +8 -2
- package/dist/compare/style-resources.js +63 -14
- package/dist/compare/verification.d.ts +15 -3
- package/dist/compare/verification.js +47 -8
- package/dist/compat/eigenpal.d.ts +4 -4
- package/dist/controller/canonicalListRendering.js +13 -22
- package/dist/controller/canonicalPublicOperations.js +1 -1
- package/dist/controller/canonicalStructure.js +45 -21
- package/dist/document-operations.d.ts +4 -9
- package/dist/document-operations.js +45 -41
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listMarkerComputation.js +9 -14
- package/dist/docx/listTemplate.d.ts +22 -0
- package/dist/docx/listTemplate.js +40 -0
- package/dist/docx/numberingParser.js +2 -2
- package/dist/docx/numberingReferenceNormalization.js +3 -3
- package/dist/docx/paragraphParser.js +3 -4
- package/dist/docx/rezip.js +2 -2
- package/dist/docx/server/materializeYjsDocx.js +2 -2
- package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
- package/dist/generated/text_shaper.js +8 -4
- package/dist/generated/text_shaper_bg.wasm +0 -0
- package/dist/index.d.ts +4 -4
- package/dist/internal/paragraphFormattingSerialization.d.ts +1 -8
- package/dist/internal/paragraphFormattingSerialization.js +6 -20
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +1 -1
- package/dist/layout-bridge/convert/listMarkers.d.ts +1 -2
- package/dist/layout-bridge/convert/listMarkers.js +3 -11
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +1 -1
- package/dist/layout-bridge/convert/paragraphAttrs.js +8 -4
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +2 -1
- package/dist/markdown/renderParagraph.js +29 -3
- package/dist/prosemirror/commands/comments.js +5 -32
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +7 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +35 -1
- package/dist/prosemirror/commands/propertyChangeScope.js +6 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +10 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +23 -9
- package/dist/prosemirror/conversion/toProseDoc.js +31 -7
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +29 -14
- package/dist/prosemirror/extensions/features/ListExtension.js +51 -21
- package/dist/prosemirror/listInstanceReferences.js +21 -15
- package/dist/prosemirror/listLabels.d.ts +4 -3
- package/dist/prosemirror/listLabels.js +18 -51
- package/dist/prosemirror/listMarker.d.ts +2 -19
- package/dist/prosemirror/listMarker.js +28 -57
- package/dist/prosemirror/listNumbering.js +16 -6
- package/dist/prosemirror/listRendering.d.ts +4 -3
- package/dist/prosemirror/listRendering.js +22 -3
- package/dist/prosemirror/listRenderingAttrs.d.ts +2 -1
- package/dist/prosemirror/listRenderingAttrs.js +6 -11
- package/dist/prosemirror/numberedRefFields.js +9 -5
- package/dist/prosemirror/numberingAttr.d.ts +19 -1
- package/dist/prosemirror/numberingAttr.js +16 -2
- package/dist/prosemirror/paragraphIndentation.js +5 -2
- package/dist/prosemirror/paragraphMarkJoin.js +17 -3
- package/dist/prosemirror/paragraphPropertyCarry.js +5 -6
- package/dist/prosemirror/plugins/transactionInvariants.js +6 -2
- package/dist/prosemirror/schema/nodes.d.ts +2 -1
- package/dist/prosemirror/selectionState.js +5 -1
- package/dist/prosemirror/storyListNumbering.js +11 -12
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -6
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +11 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +28 -18
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
- package/dist/prosemirror/yjsDocumentMetadata.js +42 -10
- package/dist/redline.d.ts +17 -1
- package/dist/redline.js +118 -57
- package/dist/server.d.ts +3 -3
- package/dist/server.js +2 -2
- package/dist/version-comparison.d.ts +1 -2
- package/dist/version-comparison.js +1 -2
- 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
|
|
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
|
|
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:
|
|
64
|
-
numPrFromStyle:
|
|
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
|
|
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 (
|
|
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
|
|
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 (
|
|
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:
|
|
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
|
|
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
|
|
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 =
|
|
433
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
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(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
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 =
|
|
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
|
|
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 (
|
|
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:
|
|
596
|
-
ilvl:
|
|
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 ||
|
|
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
|
-
|
|
40
|
-
|
|
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(
|
|
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,
|
|
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 (
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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:
|
|
188
|
-
ilvl:
|
|
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
|
-
|
|
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 ((
|
|
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, (
|
|
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 =
|
|
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(
|
|
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
|
|
14
|
-
|
|
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:
|
|
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
|
|
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 = (
|
|
56
|
-
const
|
|
57
|
-
|
|
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
|
|
60
|
-
for (const change of attrs._propertyChanges ?? [])
|
|
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 {
|
|
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:
|
|
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 };
|