@stll/folio-core 0.58.5 → 0.60.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/README.md +10 -1
- 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 +5 -5
- package/dist/compat/eigenpal.js +2 -2
- package/dist/controller/canonicalListRendering.js +13 -22
- package/dist/controller/canonicalPublicOperations.js +1 -1
- package/dist/controller/canonicalSession.js +3 -2
- package/dist/controller/canonicalStructure.js +55 -28
- package/dist/controller/fontReadiness.js +1 -1
- package/dist/controller/layoutPipeline.js +7 -1
- package/dist/controller/layoutSession.d.ts +2 -0
- package/dist/display-list/build/fontTable.js +7 -5
- package/dist/display-list/build/furniture.d.ts +1 -0
- package/dist/display-list/build/furniture.js +1 -0
- package/dist/display-list/build/watermarkPrimitives.d.ts +2 -1
- package/dist/display-list/build/watermarkPrimitives.js +9 -3
- package/dist/display-list/editor/pageRenderer.js +1 -0
- 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/bookmarkIdNormalization.d.ts +10 -0
- package/dist/docx/bookmarkIdNormalization.js +100 -0
- package/dist/docx/bookmarkParser.js +4 -2
- package/dist/docx/importedIdCollisions.d.ts +136 -0
- package/dist/docx/importedIdCollisions.js +215 -0
- 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 +4 -4
- package/dist/docx/numberingReferenceNormalization.js +3 -3
- package/dist/docx/paragraphParser.js +3 -4
- package/dist/docx/paragraphPropertySource.js +1 -2
- package/dist/docx/parseContext.d.ts +2 -1
- package/dist/docx/parseContext.js +1 -0
- package/dist/docx/parseWarningMessage.js +1 -0
- package/dist/docx/parser.js +5 -1
- package/dist/docx/relsParser.js +1 -1
- package/dist/docx/rezip.js +4 -3
- package/dist/docx/selectedXmlIdentityScan.d.ts +10 -0
- package/dist/docx/selectedXmlIdentityScan.js +36 -0
- package/dist/docx/selectiveSave.js +5 -4
- package/dist/docx/selectiveXmlPatch.js +44 -52
- package/dist/docx/serializer/commentSerializer.d.ts +3 -1
- package/dist/docx/serializer/commentSerializer.js +11 -2
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +1 -3
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -11
- package/dist/docx/server/materializeYjsDocx.js +2 -2
- package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
- package/dist/fonts/embeddedFontFingerprint.d.ts +5 -0
- package/dist/fonts/embeddedFontFingerprint.js +18 -0
- package/dist/fonts/embeddedFonts.d.ts +1 -1
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/generated/text_shaper.js +8 -4
- package/dist/generated/text_shaper_bg.wasm +0 -0
- package/dist/headless-layout.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +1 -8
- package/dist/internal/paragraphFormattingSerialization.js +6 -20
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +3 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- 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/paragraphConversion.js +8 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +27 -2
- package/dist/layout-engine/measure/cache.js +39 -7
- package/dist/layout-engine/measure/lineTypography.js +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +1 -0
- package/dist/layout-engine/measure/measureContainer.js +3 -4
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -9
- package/dist/layout-engine/measure/measureHelpers.js +21 -18
- package/dist/layout-engine/measure/measureParagraph.js +2 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -0
- package/dist/layout-engine/types.d.ts +4 -1
- package/dist/layout-painter/renderPage.d.ts +1 -0
- package/dist/layout-painter/renderPage.js +11 -3
- package/dist/layout-painter/renderParagraph.js +13 -3
- package/dist/layout-painter/renderWatermark.d.ts +1 -0
- package/dist/layout-painter/renderWatermark.js +7 -3
- package/dist/managers/editorShortcuts.d.ts +2 -1
- package/dist/managers/editorShortcuts.js +2 -1
- package/dist/markdown/renderParagraph.js +29 -3
- package/dist/prosemirror/canonicalSelectionRange.d.ts +4 -1
- package/dist/prosemirror/canonicalSelectionRange.js +9 -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/AutoBidiDetectionExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +39 -3
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +4 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +4 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +51 -21
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +6 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +11 -3
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +1 -1
- 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/pluginKeyOwner.d.ts +13 -0
- package/dist/prosemirror/pluginKeyOwner.js +35 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiCitationDecorations.js +16 -3
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +11 -4
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +18 -3
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +11 -11
- package/dist/prosemirror/plugins/anonymizationDecorations.js +23 -13
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +8 -2
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +27 -5
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +8 -2
- package/dist/prosemirror/plugins/contentControlWidgets.js +4 -3
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +6 -5
- package/dist/prosemirror/plugins/createDocScanPlugin.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +5 -3
- package/dist/prosemirror/plugins/documentStyleState.d.ts +8 -2
- package/dist/prosemirror/plugins/documentStyleState.js +2 -2
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +8 -2
- package/dist/prosemirror/plugins/selectionTracker.js +4 -3
- package/dist/prosemirror/plugins/suggestionMode.d.ts +8 -2
- package/dist/prosemirror/plugins/suggestionMode.js +4 -3
- package/dist/prosemirror/plugins/templateDirectives.d.ts +8 -2
- package/dist/prosemirror/plugins/templateDirectives.js +19 -4
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +8 -2
- package/dist/prosemirror/plugins/templatePreviewValues.js +27 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +8 -2
- package/dist/prosemirror/plugins/templateSlashMenu.js +23 -5
- package/dist/prosemirror/plugins/transactionInvariants.js +29 -5
- 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/utils/fontLoader.d.ts +2 -2
- package/dist/utils/fontLoader.js +2 -7
- package/dist/utils/fontResolver.d.ts +7 -3
- package/dist/utils/fontResolver.js +6 -8
- package/dist/version-comparison.d.ts +1 -2
- package/dist/version-comparison.js +1 -2
- package/package.json +26 -9
|
@@ -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,12 +1,18 @@
|
|
|
1
1
|
import { Extension } from "../types.js";
|
|
2
2
|
import { Node } from "prosemirror-model";
|
|
3
|
-
import { EditorState,
|
|
3
|
+
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts
|
|
5
5
|
type ParagraphPropertySourceSeed = {
|
|
6
6
|
contract: string | null;
|
|
7
7
|
tokens: ReadonlySet<string>;
|
|
8
8
|
};
|
|
9
|
-
declare const paraIdAllocatorKey:
|
|
9
|
+
declare const paraIdAllocatorKey: Readonly<{
|
|
10
|
+
key: string;
|
|
11
|
+
createKey: () => import("prosemirror-state").PluginKey<ParagraphPropertySourceSeed>;
|
|
12
|
+
owns: (plugin: Plugin<ParagraphPropertySourceSeed>) => boolean;
|
|
13
|
+
get: (state: EditorState) => Plugin<ParagraphPropertySourceSeed> | undefined;
|
|
14
|
+
getState: (state: EditorState) => ParagraphPropertySourceSeed | undefined;
|
|
15
|
+
}>;
|
|
10
16
|
/**
|
|
11
17
|
* Transaction meta asking this plugin to derive the ids it mints from a
|
|
12
18
|
* caller-supplied seed instead of `Math.random()`.
|
|
@@ -17,7 +23,7 @@ declare const paraIdAllocatorKey: PluginKey<ParagraphPropertySourceSeed>;
|
|
|
17
23
|
* be deterministic, so it says so on its own transaction rather than leaving
|
|
18
24
|
* the plugin to guess.
|
|
19
25
|
*/
|
|
20
|
-
declare const deterministicParaIdSeedKey
|
|
26
|
+
declare const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
|
|
21
27
|
/** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
|
|
22
28
|
declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
|
|
23
29
|
type ParagraphPropertySourceKeeper = {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR, getExplicitParagraphPropertySourceTransfers, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, setProseParagraphMarkupWithPropertySource, transferProseParagraphPropertySource } from "../../../docx/paragraphPropertySource.js";
|
|
2
2
|
import { deterministicHexId, generateHexId } from "../../../utils/hexId.js";
|
|
3
|
+
import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
|
|
3
4
|
import { sweepPositions } from "../../positionSweep.js";
|
|
4
5
|
import { createExtension } from "../create.js";
|
|
5
6
|
import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
|
|
6
7
|
import { panic } from "better-result";
|
|
7
8
|
import { Fragment } from "prosemirror-model";
|
|
8
|
-
import { Plugin
|
|
9
|
+
import { Plugin } from "prosemirror-state";
|
|
9
10
|
//#region src/prosemirror/extensions/features/ParaIdAllocatorExtension.ts
|
|
10
11
|
/**
|
|
11
12
|
* ParaIdAllocator — assigns a stable `w14:paraId` to every paragraph.
|
|
@@ -44,7 +45,7 @@ import { Plugin, PluginKey } from "prosemirror-state";
|
|
|
44
45
|
* split therefore restores the same allocated id instead of minting
|
|
45
46
|
* another one.
|
|
46
47
|
*/
|
|
47
|
-
const paraIdAllocatorKey =
|
|
48
|
+
const paraIdAllocatorKey = createPluginKeyOwner("paraIdAllocator");
|
|
48
49
|
/**
|
|
49
50
|
* Transaction meta asking this plugin to derive the ids it mints from a
|
|
50
51
|
* caller-supplied seed instead of `Math.random()`.
|
|
@@ -55,7 +56,7 @@ const paraIdAllocatorKey = new PluginKey("paraIdAllocator");
|
|
|
55
56
|
* be deterministic, so it says so on its own transaction rather than leaving
|
|
56
57
|
* the plugin to guess.
|
|
57
58
|
*/
|
|
58
|
-
const deterministicParaIdSeedKey =
|
|
59
|
+
const deterministicParaIdSeedKey = "stll.folio.meta.deterministicParaIdSeed";
|
|
59
60
|
/** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
|
|
60
61
|
const requestDeterministicParaIds = (tr, seed) => tr.setMeta(deterministicParaIdSeedKey, seed);
|
|
61
62
|
/**
|
|
@@ -297,7 +298,7 @@ const ensureParaIdsInState = (state) => {
|
|
|
297
298
|
return state.apply(tr);
|
|
298
299
|
};
|
|
299
300
|
const createParaIdAllocatorPlugin = () => new Plugin({
|
|
300
|
-
key: paraIdAllocatorKey,
|
|
301
|
+
key: paraIdAllocatorKey.createKey(),
|
|
301
302
|
state: {
|
|
302
303
|
init: (_config, state) => collectParagraphPropertySourceSeed(state.doc),
|
|
303
304
|
apply: (_transaction, seed) => seed
|
|
@@ -307,7 +308,7 @@ const createParaIdAllocatorPlugin = () => new Plugin({
|
|
|
307
308
|
const paragraphSourceSeed = paraIdAllocatorKey.getState(oldState);
|
|
308
309
|
if (!paragraphSourceSeed) panic("ParaId allocator lost its paragraph-property source seed");
|
|
309
310
|
const keeperPositions = mapParagraphKeepers(oldState.doc, transactions, paragraphSourceSeed);
|
|
310
|
-
const deterministicSeed = transactions.map((transaction) => transaction.getMeta(
|
|
311
|
+
const deterministicSeed = transactions.map((transaction) => transaction.getMeta("stll.folio.meta.deterministicParaIdSeed")).find((value) => typeof value === "string") ?? null;
|
|
311
312
|
const census = collectParagraphCensus(newState.doc, paragraphSourceSeed);
|
|
312
313
|
const updates = collectParaIdUpdatesFromCensus(census, keeperPositions.paraIds, deterministicSeed);
|
|
313
314
|
const paragraphSourceUpdates = collectParagraphPropertySourceUpdates(census, keeperPositions.sourceTokens, transactions);
|
|
@@ -2,9 +2,15 @@ import { document_d_exports } from "../../../types/document.js";
|
|
|
2
2
|
import { Extension } from "../types.js";
|
|
3
3
|
import { RemovedSectionReference, TrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
|
|
4
4
|
import { Node } from "prosemirror-model";
|
|
5
|
-
import { EditorState, Plugin,
|
|
5
|
+
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
6
6
|
//#region src/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts
|
|
7
|
-
declare const paragraphChangeTrackerKey:
|
|
7
|
+
declare const paragraphChangeTrackerKey: Readonly<{
|
|
8
|
+
key: string;
|
|
9
|
+
createKey: () => import("prosemirror-state").PluginKey<InternalParagraphChangeTrackerState>;
|
|
10
|
+
owns: (plugin: Plugin<InternalParagraphChangeTrackerState>) => boolean;
|
|
11
|
+
get: (state: EditorState) => Plugin<InternalParagraphChangeTrackerState> | undefined;
|
|
12
|
+
getState: (state: EditorState) => InternalParagraphChangeTrackerState | undefined;
|
|
13
|
+
}>;
|
|
8
14
|
type ParagraphChangeTrackerState = {
|
|
9
15
|
/** Set of paraIds that were modified since last clear */
|
|
10
16
|
changedParaIds: Set<string>;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { withTrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
|
|
2
2
|
import { canonicalJson } from "../../../utils/canonicalJson.js";
|
|
3
3
|
import { enclosingParagraphIndexed, nodeAtIndexed, nodesBetweenIndexed } from "../../indexedNodeLookup.js";
|
|
4
|
+
import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
|
|
4
5
|
import { sweepPositions } from "../../positionSweep.js";
|
|
5
6
|
import { sectionPropertiesOf } from "../../sectionCarrier.js";
|
|
6
7
|
import { sectionMarkEditsOf } from "../../sectionMarkEdits.js";
|
|
7
8
|
import { createExtension } from "../create.js";
|
|
8
9
|
import { AddMarkStep, AddNodeMarkStep, AttrStep, RemoveMarkStep, RemoveNodeMarkStep } from "prosemirror-transform";
|
|
9
|
-
import { Plugin
|
|
10
|
+
import { Plugin } from "prosemirror-state";
|
|
10
11
|
import { isHistoryTransaction } from "prosemirror-history";
|
|
11
12
|
//#region src/prosemirror/extensions/features/ParagraphChangeTrackerExtension.ts
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Paragraph Change Tracker Extension
|
|
15
|
+
*
|
|
16
|
+
* Watches ProseMirror transactions and records which paragraph IDs (paraId)
|
|
17
|
+
* were modified. Also detects paragraph and block-structure changes.
|
|
18
|
+
* Used by the selective save system to patch only changed paragraphs in document.xml.
|
|
19
|
+
*/
|
|
20
|
+
const paragraphChangeTrackerKey = createPluginKeyOwner("paragraphChangeTracker");
|
|
13
21
|
const CLEAR_META = "clear";
|
|
14
22
|
const IGNORE_META = "ignore";
|
|
15
23
|
const STRUCTURAL_META = "structural";
|
|
@@ -196,7 +204,7 @@ const mapStepTouches = (tr, batches) => {
|
|
|
196
204
|
};
|
|
197
205
|
function createParagraphChangeTrackerPlugin() {
|
|
198
206
|
return new Plugin({
|
|
199
|
-
key: paragraphChangeTrackerKey,
|
|
207
|
+
key: paragraphChangeTrackerKey.createKey(),
|
|
200
208
|
state: {
|
|
201
209
|
init(_config, state) {
|
|
202
210
|
const counts = countDocumentStructure(state.doc);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { expectRunIdentityMarkAttrs } from "../../attrs/index.js";
|
|
2
2
|
import { nodesBetweenIndexed } from "../../indexedNodeLookup.js";
|
|
3
|
+
import { createPluginKeyOwner } from "../../pluginKeyOwner.js";
|
|
3
4
|
import { sweepPositions } from "../../positionSweep.js";
|
|
4
5
|
import { RUN_IDENTITY_ATTRIBUTE, RUN_IDENTITY_MARK_NAME, runIdentityAttrs } from "../../runIdentity.js";
|
|
5
6
|
import { createMarkExtension } from "../create.js";
|
|
6
|
-
import { Plugin
|
|
7
|
+
import { Plugin } from "prosemirror-state";
|
|
7
8
|
import { isHistoryTransaction, undoDepth } from "prosemirror-history";
|
|
8
9
|
//#region src/prosemirror/extensions/marks/RunIdentityExtension.ts
|
|
9
10
|
/**
|
|
@@ -28,7 +29,7 @@ import { isHistoryTransaction, undoDepth } from "prosemirror-history";
|
|
|
28
29
|
* supplies the session the format itself says such a run belongs to.
|
|
29
30
|
*/
|
|
30
31
|
const CANONICAL_RUN_IDENTITY_ID = /^(?:0|[1-9]\d*)$/u;
|
|
31
|
-
const runIdentityStripKey =
|
|
32
|
+
const runIdentityStripKey = createPluginKeyOwner("runIdentityStrip");
|
|
32
33
|
/**
|
|
33
34
|
* Every range `transactions` inserted, in the document they produced.
|
|
34
35
|
*
|
|
@@ -87,7 +88,7 @@ const insertedRanges = (transactions, skip = () => false) => {
|
|
|
87
88
|
* collaborative apply all arrive here and nowhere else in common.
|
|
88
89
|
*/
|
|
89
90
|
const createRunIdentityStripPlugin = () => new Plugin({
|
|
90
|
-
key: runIdentityStripKey,
|
|
91
|
+
key: runIdentityStripKey.createKey(),
|
|
91
92
|
appendTransaction(transactions, oldState, newState) {
|
|
92
93
|
if (!transactions.some((transaction) => transaction.docChanged)) return null;
|
|
93
94
|
const markType = newState.schema.marks[RUN_IDENTITY_MARK_NAME];
|
|
@@ -409,7 +409,7 @@ function isMarkActive(state, type, attrs) {
|
|
|
409
409
|
});
|
|
410
410
|
let hasMark = false;
|
|
411
411
|
state.doc.nodesBetween(from, to, (node) => {
|
|
412
|
-
if (node.isText) {
|
|
412
|
+
if (node.isText && !(RUN_FORMATTING_MARK_NAMES.has(markType.name) && node.marks.some((mark) => mark.type.name === "footnoteRef"))) {
|
|
413
413
|
const mark = markType.isInSet(node.marks);
|
|
414
414
|
if (mark) {
|
|
415
415
|
if (!attrs) {
|
|
@@ -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 };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { bulletMarkerFontName, convertBulletToUnicode } from "../docx/bulletMarkers.js";
|
|
2
|
-
import {
|
|
3
|
-
import { advanceListMarker, advanceVisibleListMarker, cloneListCounterState, createListCounterState } from "./listMarker.js";
|
|
2
|
+
import { advanceVisibleListMarker, createListCounterState } from "./listMarker.js";
|
|
4
3
|
import { hasListRendering } from "./listRenderingAttrs.js";
|
|
5
4
|
import { paragraphNumberingAttr } from "./numberingAttr.js";
|
|
6
5
|
//#region src/prosemirror/listLabels.ts
|
|
@@ -27,35 +26,23 @@ const foldedFieldSuffix = (attrs) => {
|
|
|
27
26
|
const tab = marker.indexOf(" ");
|
|
28
27
|
return tab === -1 ? "" : marker.slice(tab);
|
|
29
28
|
};
|
|
30
|
-
const withoutNumbering = (attrs) => {
|
|
31
|
-
const unnumbered = { ...attrs };
|
|
32
|
-
Reflect.deleteProperty(unnumbered, "numPr");
|
|
33
|
-
return unnumbered;
|
|
34
|
-
};
|
|
35
29
|
const staticMarker = (attrs) => {
|
|
36
30
|
const marker = attrs.listMarker;
|
|
37
31
|
if (!marker) return;
|
|
38
32
|
return (attrs.listIsBullet ? convertBulletToUnicode(marker, bulletMarkerFontName(attrs.listMarkerFormatting)) : marker).trim() || void 0;
|
|
39
33
|
};
|
|
40
|
-
/** Most paragraphs: nothing to count and no marker to show. */
|
|
41
|
-
const isPlainParagraph = (attrs) => attrs.numPr == null && attrs.listMarker == null && attrs.listMarkerTemplate == null && (attrs._propertyChanges == null || attrs._propertyChanges.length === 0);
|
|
42
|
-
const NO_PREVIOUS_LIST = {
|
|
43
|
-
abstractNumId: null,
|
|
44
|
-
fromStyle: false,
|
|
45
|
-
numId: null
|
|
46
|
-
};
|
|
47
34
|
/**
|
|
48
35
|
* The attrs the counter reads for a paragraph of the document model, as
|
|
49
36
|
* `toProseDoc` projects them (`listRenderingAttrPatch`), without the layout
|
|
50
37
|
* attrs no label depends on: a reader that walks the model (Markdown) counts
|
|
51
38
|
* every list paragraph through here.
|
|
52
39
|
*/
|
|
53
|
-
const listLabelAttrsFromRendering = (rendering, numPrFromStyle) => {
|
|
54
|
-
const attrs = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (
|
|
40
|
+
const listLabelAttrsFromRendering = (rendering, { numPr, numPrFromStyle }) => {
|
|
41
|
+
const attrs = {
|
|
42
|
+
...numPr === void 0 ? {} : { numPr: paragraphNumberingAttr(numPr) },
|
|
43
|
+
...numPrFromStyle === void 0 ? {} : { numPrFromStyle: paragraphNumberingAttr(numPrFromStyle) }
|
|
44
|
+
};
|
|
45
|
+
if (rendering === void 0) return attrs;
|
|
59
46
|
if (rendering.marker) attrs.listMarker = rendering.marker;
|
|
60
47
|
if (rendering.markerTemplate) attrs.listMarkerTemplate = rendering.markerTemplate;
|
|
61
48
|
if (rendering.isBullet) attrs.listIsBullet = true;
|
|
@@ -75,37 +62,17 @@ const listLabelAttrsFromRendering = (rendering, numPrFromStyle) => {
|
|
|
75
62
|
* paragraph, numbered or not: whether a list continues depends on what stands
|
|
76
63
|
* between its items.
|
|
77
64
|
*/
|
|
78
|
-
const createListLabelCounter = (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
original
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
if (streams !== null) return advanceVisibleListMarker(counted, streams).marker;
|
|
93
|
-
const marker = advanceListMarker(counted, final);
|
|
94
|
-
if (counted.numPr) originalPreviousList = final.previousList ?? NO_PREVIOUS_LIST;
|
|
95
|
-
return marker;
|
|
96
|
-
};
|
|
97
|
-
return (attrs) => {
|
|
98
|
-
if (isPlainParagraph(attrs)) {
|
|
99
|
-
final.previousList = NO_PREVIOUS_LIST;
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const rendered = hasListRendering(attrs);
|
|
103
|
-
const marker = advance(rendered ? attrs : withoutNumbering(attrs));
|
|
104
|
-
if (attrs.listMarkerHidden === true || !rendered) return;
|
|
105
|
-
const counted = paragraphNumberingReferenceId(attrs.numPr) === void 0 ? null : marker?.trim();
|
|
106
|
-
if (counted) return `${counted}${foldedFieldSuffix(attrs)}`;
|
|
107
|
-
return staticMarker(attrs);
|
|
108
|
-
};
|
|
65
|
+
const createListLabelCounter = (streams = {
|
|
66
|
+
final: createListCounterState(),
|
|
67
|
+
original: createListCounterState()
|
|
68
|
+
}) => (attrs) => {
|
|
69
|
+
const visible = advanceVisibleListMarker(attrs, streams);
|
|
70
|
+
const rendered = hasListRendering(visible.counterAttrs);
|
|
71
|
+
const marker = visible.marker;
|
|
72
|
+
if (visible.counterAttrs.listMarkerHidden === true || !rendered) return void 0;
|
|
73
|
+
const counted = marker?.trim();
|
|
74
|
+
if (counted) return `${counted}${foldedFieldSuffix(visible.counterAttrs)}`;
|
|
75
|
+
return staticMarker(visible.counterAttrs);
|
|
109
76
|
};
|
|
110
77
|
//#endregion
|
|
111
78
|
export { createListLabelCounter, listLabelAttrsFromRendering };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { ParagraphAttrs } from "./schema/nodes.js";
|
|
3
|
+
import { ResolvedListComponent, ResolvedListTemplate, resolveListTemplate, resolveListTemplateWithComponents } from "../docx/listTemplate.js";
|
|
3
4
|
import { LIST_RENDERING_ATTR_KEYS } from "./listRenderingAttrs.js";
|
|
4
5
|
//#region src/prosemirror/listMarker.d.ts
|
|
5
6
|
type ListCounterState = {
|
|
@@ -32,16 +33,6 @@ type VisibleListMarker = {
|
|
|
32
33
|
stream: ListCounterStream;
|
|
33
34
|
advances: readonly AdvancedListMarker[];
|
|
34
35
|
};
|
|
35
|
-
type ResolvedListComponent = {
|
|
36
|
-
level: number;
|
|
37
|
-
relativeStart: number;
|
|
38
|
-
start: number;
|
|
39
|
-
end: number;
|
|
40
|
-
};
|
|
41
|
-
type ResolvedListTemplate = {
|
|
42
|
-
value: string;
|
|
43
|
-
components: readonly ResolvedListComponent[];
|
|
44
|
-
};
|
|
45
36
|
declare const MAX_LIST_LEVEL = 8;
|
|
46
37
|
declare const CLEARED_LIST_RENDERING_ATTRS: Readonly<{
|
|
47
38
|
listIsBullet: null;
|
|
@@ -72,14 +63,6 @@ declare function cloneListCounterState(state: ListCounterState): ListCounterStat
|
|
|
72
63
|
*/
|
|
73
64
|
declare function advanceVisibleListMarker(attrs: ParagraphAttrs, streams: ListCounterStreams): VisibleListMarker;
|
|
74
65
|
declare function formatCounter(value: number, format: document_d_exports.CounterFormat | undefined): string;
|
|
75
|
-
type ResolveListTemplateOptions = {
|
|
76
|
-
template: string;
|
|
77
|
-
counters: number[];
|
|
78
|
-
levelFormats?: document_d_exports.CounterFormat[] | undefined;
|
|
79
|
-
forceDecimal?: boolean | undefined;
|
|
80
|
-
};
|
|
81
|
-
declare function resolveListTemplate(options: ResolveListTemplateOptions): string;
|
|
82
|
-
declare function resolveListTemplateWithComponents({ template, counters, levelFormats, forceDecimal }: ResolveListTemplateOptions): ResolvedListTemplate;
|
|
83
66
|
declare function advanceListMarker(attrs: ParagraphAttrs, state: ListCounterState): string | null;
|
|
84
67
|
//#endregion
|
|
85
|
-
export { AdvancedListMarker, CLEARED_LIST_RENDERING_ATTRS, LIST_RENDERING_ATTR_KEYS, ListCounterState, ListCounterStream, ListCounterStreams, MAX_LIST_LEVEL, ResolvedListComponent, ResolvedListTemplate, VisibleListMarker, advanceListMarker, advanceVisibleListMarker, cloneListCounterState, createListCounterState, formatCounter, resolveListTemplate, resolveListTemplateWithComponents };
|
|
68
|
+
export { AdvancedListMarker, CLEARED_LIST_RENDERING_ATTRS, LIST_RENDERING_ATTR_KEYS, ListCounterState, ListCounterStream, ListCounterStreams, MAX_LIST_LEVEL, type ResolvedListComponent, type ResolvedListTemplate, VisibleListMarker, advanceListMarker, advanceVisibleListMarker, cloneListCounterState, createListCounterState, formatCounter, resolveListTemplate, resolveListTemplateWithComponents };
|