@stll/folio-core 0.52.0 → 0.53.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 +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1519 -105
- package/dist/ai-edits/batch-claims.d.ts +130 -0
- package/dist/ai-edits/batch-claims.js +244 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +71 -7
- package/dist/ai-edits/headless.js +381 -41
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +1 -1
- package/dist/ai-edits/read.js +56 -43
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +177 -23
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +4 -1
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +38 -16
- package/dist/ai-edits/table-row-column-mutations.js +61 -26
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.js +13 -2
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +62 -9
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +91 -24
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +173 -20
- package/dist/docx/rezip.js +27 -5
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.js +106 -37
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +2 -1
- package/dist/docx/unzip.js +1 -1
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +136 -0
- package/dist/i18n/messages/catalogs.gen.js +153 -17
- package/dist/i18n/messages/messages.gen.d.ts +8 -0
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +530 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +39 -9
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.js +3 -10
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +241 -207
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +615 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +59 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +181 -31
- package/dist/prosemirror/conversion/toProseDoc.js +39 -4
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +3 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +161 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +126 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +21 -5
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +7 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +8 -2
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +35 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +19 -18
- package/dist/prosemirror/extensions/types.d.ts +4 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -2
- package/dist/prosemirror/index.js +3 -2
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +110 -0
- package/dist/prosemirror/listNumbering.js +345 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewProjection.d.ts +95 -0
- package/dist/prosemirror/markupViewProjection.js +83 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +29 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +19 -0
- package/dist/prosemirror/paragraphMarkJoin.js +24 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyles.d.ts +10 -1
- package/dist/prosemirror/plugins/documentStyles.js +14 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +16 -2
- package/dist/prosemirror/plugins/suggestionMode.js +116 -52
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +42 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/tableGridMutation.d.ts +48 -2
- package/dist/prosemirror/tableGridMutation.js +106 -1
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -43,7 +43,7 @@ const CANONICAL_INLINE_PRESENTATION_PROPERTIES = Object.freeze([
|
|
|
43
43
|
...INLINE_PRESENTATION_GRAMMAR.color
|
|
44
44
|
]);
|
|
45
45
|
const canonicalColor = (value) => value === null || value === void 0 ? value : normalizeInlinePresentationColor(value);
|
|
46
|
-
const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
46
|
+
const writeCanonicalInlinePresentationDifferences = (base, revised, patch, presentationBasis = "full") => {
|
|
47
47
|
let changed = false;
|
|
48
48
|
const baseDirect = base?.directFormatting ?? {};
|
|
49
49
|
const revisedDirect = revised?.directFormatting ?? {};
|
|
@@ -54,7 +54,7 @@ const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
|
54
54
|
const revisedEffective = revised?.[property] === true;
|
|
55
55
|
let value;
|
|
56
56
|
if (baseAuthored !== revisedAuthored) value = revisedAuthored ?? null;
|
|
57
|
-
else if (baseEffective === revisedEffective) value = NO_PRESENTATION_DIFFERENCE;
|
|
57
|
+
else if (presentationBasis === "authored" || baseEffective === revisedEffective) value = NO_PRESENTATION_DIFFERENCE;
|
|
58
58
|
else value = revisedEffective;
|
|
59
59
|
if (value !== NO_PRESENTATION_DIFFERENCE) {
|
|
60
60
|
changed = true;
|
|
@@ -64,7 +64,7 @@ const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
|
64
64
|
const stringProperty = INLINE_PRESENTATION_HOT_PATH_GRAMMAR.string[0];
|
|
65
65
|
let stringValue;
|
|
66
66
|
if (baseDirect[stringProperty] !== revisedDirect[stringProperty]) stringValue = revisedDirect[stringProperty] ?? null;
|
|
67
|
-
else if (base?.[stringProperty] === revised?.[stringProperty]) stringValue = NO_PRESENTATION_DIFFERENCE;
|
|
67
|
+
else if (presentationBasis === "authored" || base?.[stringProperty] === revised?.[stringProperty]) stringValue = NO_PRESENTATION_DIFFERENCE;
|
|
68
68
|
else stringValue = revised?.[stringProperty] ?? null;
|
|
69
69
|
if (stringValue !== NO_PRESENTATION_DIFFERENCE) {
|
|
70
70
|
changed = true;
|
|
@@ -73,7 +73,7 @@ const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
|
73
73
|
const numberProperty = INLINE_PRESENTATION_HOT_PATH_GRAMMAR.number[0];
|
|
74
74
|
let numberValue;
|
|
75
75
|
if (baseDirect[numberProperty] !== revisedDirect[numberProperty]) numberValue = revisedDirect[numberProperty] ?? null;
|
|
76
|
-
else if (base?.[numberProperty] === revised?.[numberProperty]) numberValue = NO_PRESENTATION_DIFFERENCE;
|
|
76
|
+
else if (presentationBasis === "authored" || base?.[numberProperty] === revised?.[numberProperty]) numberValue = NO_PRESENTATION_DIFFERENCE;
|
|
77
77
|
else numberValue = revised?.[numberProperty] ?? null;
|
|
78
78
|
if (numberValue !== NO_PRESENTATION_DIFFERENCE) {
|
|
79
79
|
changed = true;
|
|
@@ -86,7 +86,7 @@ const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
|
86
86
|
const revisedEffectiveColor = canonicalColor(revised?.[colorProperty]);
|
|
87
87
|
let color;
|
|
88
88
|
if (baseAuthoredColor !== revisedAuthoredColor) color = revisedAuthoredColor ?? null;
|
|
89
|
-
else if (baseEffectiveColor === revisedEffectiveColor) color = NO_PRESENTATION_DIFFERENCE;
|
|
89
|
+
else if (presentationBasis === "authored" || baseEffectiveColor === revisedEffectiveColor) color = NO_PRESENTATION_DIFFERENCE;
|
|
90
90
|
else color = revisedEffectiveColor ?? null;
|
|
91
91
|
if (color !== NO_PRESENTATION_DIFFERENCE) {
|
|
92
92
|
changed = true;
|
|
@@ -95,9 +95,9 @@ const writeCanonicalInlinePresentationDifferences = (base, revised, patch) => {
|
|
|
95
95
|
return changed;
|
|
96
96
|
};
|
|
97
97
|
const canonicalInlinePresentationsEqual = (base, revised) => !writeCanonicalInlinePresentationDifferences(base, revised, null);
|
|
98
|
-
const changedCanonicalInlinePresentation = (base, revised) => {
|
|
98
|
+
const changedCanonicalInlinePresentation = (base, revised, presentationBasis) => {
|
|
99
99
|
const patch = {};
|
|
100
|
-
return writeCanonicalInlinePresentationDifferences(base, revised, patch) ? patch : null;
|
|
100
|
+
return writeCanonicalInlinePresentationDifferences(base, revised, patch, presentationBasis) ? patch : null;
|
|
101
101
|
};
|
|
102
102
|
const sameCanonicalInlinePresentationPatch = (left, right) => {
|
|
103
103
|
for (const property of INLINE_PRESENTATION_GRAMMAR.boolean) if (left[property] !== right[property]) return false;
|
|
@@ -148,7 +148,7 @@ const visitAlignedRunRanges = (options) => {
|
|
|
148
148
|
if (options.type === "equivalence") {
|
|
149
149
|
if (!canonicalInlinePresentationsEqual(baseRun, revisedRun)) return "stopped";
|
|
150
150
|
} else if (!exceededBudget) {
|
|
151
|
-
const formatting = changedCanonicalInlinePresentation(baseRun, revisedRun);
|
|
151
|
+
const formatting = changedCanonicalInlinePresentation(baseRun, revisedRun, options.presentationBasis);
|
|
152
152
|
if (formatting !== null) {
|
|
153
153
|
const previous = options.segments.at(-1);
|
|
154
154
|
if (previous && previous.endOffset === baseBlockOffset && sameCanonicalInlinePresentationPatch(previous.formatting, formatting)) previous.endOffset += length;
|
|
@@ -180,14 +180,15 @@ const hasAlignedRunStream = (block) => {
|
|
|
180
180
|
* Invalid run streams take precedence over the segment budget, so malformed
|
|
181
181
|
* content cannot change meaning as the caller's remaining budget changes.
|
|
182
182
|
*/
|
|
183
|
-
const canonicalInlinePresentationSegments = ({ baseBlock, revisedBlock, maxSegments }) => {
|
|
183
|
+
const canonicalInlinePresentationSegments = ({ baseBlock, revisedBlock, maxSegments, presentationBasis = "full" }) => {
|
|
184
184
|
const segments = [];
|
|
185
185
|
const result = visitAlignedRunRanges({
|
|
186
186
|
type: "segments",
|
|
187
187
|
baseBlock,
|
|
188
188
|
revisedBlock,
|
|
189
189
|
maxSegments,
|
|
190
|
-
segments
|
|
190
|
+
segments,
|
|
191
|
+
presentationBasis
|
|
191
192
|
});
|
|
192
193
|
switch (result) {
|
|
193
194
|
case "complete": return {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
2
2
|
//#region src/internal/headlessRevisionResolutionGuard.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Whether a state can consume an unmapped replacement before it returns.
|
|
5
|
-
* Only the internal headless plugin set opts in; history and collaboration
|
|
6
|
-
* plugins always keep the state on the legacy editor-command path.
|
|
7
|
-
*/
|
|
8
|
-
declare const stateAllowsHeadlessRevisionResolution: (state: EditorState) => boolean;
|
|
9
3
|
/** Build the private plugin set for synchronous headless review states. */
|
|
10
4
|
declare const pluginsForHeadlessRevisionResolution: (plugins: readonly Plugin[]) => readonly Plugin[];
|
|
11
5
|
//#endregion
|
|
12
|
-
export { pluginsForHeadlessRevisionResolution
|
|
6
|
+
export { pluginsForHeadlessRevisionResolution };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
1
|
//#region src/internal/headlessRevisionResolutionGuard.ts
|
|
3
2
|
const UNSAFE_PLUGIN_KEY_PREFIXES = [
|
|
4
3
|
"collab$",
|
|
@@ -6,8 +5,6 @@ const UNSAFE_PLUGIN_KEY_PREFIXES = [
|
|
|
6
5
|
"y-sync$",
|
|
7
6
|
"y-undo$"
|
|
8
7
|
];
|
|
9
|
-
const headlessRevisionResolutionKey = new PluginKey("folioHeadlessRevisionResolution");
|
|
10
|
-
const headlessRevisionResolutionPlugin = new Plugin({ key: headlessRevisionResolutionKey });
|
|
11
8
|
const pluginRuntimeKey = (plugin) => {
|
|
12
9
|
const key = Reflect.get(plugin, "key");
|
|
13
10
|
return typeof key === "string" ? key : null;
|
|
@@ -16,13 +13,7 @@ const retainsOrTransportsSteps = (plugin) => {
|
|
|
16
13
|
const key = pluginRuntimeKey(plugin);
|
|
17
14
|
return key !== null && UNSAFE_PLUGIN_KEY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
18
15
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Whether a state can consume an unmapped replacement before it returns.
|
|
21
|
-
* Only the internal headless plugin set opts in; history and collaboration
|
|
22
|
-
* plugins always keep the state on the legacy editor-command path.
|
|
23
|
-
*/
|
|
24
|
-
const stateAllowsHeadlessRevisionResolution = (state) => headlessRevisionResolutionKey.get(state) === headlessRevisionResolutionPlugin && !state.plugins.some(retainsOrTransportsSteps);
|
|
25
16
|
/** Build the private plugin set for synchronous headless review states. */
|
|
26
|
-
const pluginsForHeadlessRevisionResolution = (plugins) =>
|
|
17
|
+
const pluginsForHeadlessRevisionResolution = (plugins) => plugins.filter((plugin) => !retainsOrTransportsSteps(plugin));
|
|
27
18
|
//#endregion
|
|
28
|
-
export { pluginsForHeadlessRevisionResolution
|
|
19
|
+
export { pluginsForHeadlessRevisionResolution };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StepMap } from "prosemirror-transform";
|
|
2
|
+
//#region src/internal/indexedPositionMap.d.ts
|
|
3
|
+
/** StepMap.map scans its ranges; index them once for many paragraph lookups. */
|
|
4
|
+
declare const indexedPositionMap: (map: StepMap) => ((position: number, assoc: 1 | -1) => number) & {
|
|
5
|
+
mapResult: (position: number, assoc: 1 | -1) => {
|
|
6
|
+
pos: number;
|
|
7
|
+
deletedAcross: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { indexedPositionMap };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/internal/indexedPositionMap.ts
|
|
2
|
+
/** StepMap.map scans its ranges; index them once for many paragraph lookups. */
|
|
3
|
+
const indexedPositionMap = (map) => {
|
|
4
|
+
const changes = [];
|
|
5
|
+
map.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
6
|
+
changes.push({
|
|
7
|
+
oldStart,
|
|
8
|
+
oldEnd,
|
|
9
|
+
newStart,
|
|
10
|
+
newEnd
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
const mapResult = (position, assoc) => {
|
|
14
|
+
let low = 0;
|
|
15
|
+
let high = changes.length;
|
|
16
|
+
while (low < high) {
|
|
17
|
+
const middle = Math.floor((low + high) / 2);
|
|
18
|
+
const candidate = changes.at(middle);
|
|
19
|
+
if (candidate && candidate.oldEnd < position) low = middle + 1;
|
|
20
|
+
else high = middle;
|
|
21
|
+
}
|
|
22
|
+
const change = changes.at(low);
|
|
23
|
+
if (change && change.oldStart <= position) {
|
|
24
|
+
const oldSize = change.oldEnd - change.oldStart;
|
|
25
|
+
let side = assoc;
|
|
26
|
+
if (oldSize > 0 && position === change.oldStart) side = -1;
|
|
27
|
+
else if (oldSize > 0 && position === change.oldEnd) side = 1;
|
|
28
|
+
return {
|
|
29
|
+
pos: side < 0 ? change.newStart : change.newEnd,
|
|
30
|
+
deletedAcross: position > change.oldStart && position < change.oldEnd
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const previous = low === 0 ? void 0 : changes.at(low - 1);
|
|
34
|
+
return {
|
|
35
|
+
pos: position + (previous ? previous.newEnd - previous.oldEnd : 0),
|
|
36
|
+
deletedAcross: false
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
return Object.assign((position, assoc) => mapResult(position, assoc).pos, { mapResult });
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { indexedPositionMap };
|
|
@@ -95,7 +95,8 @@ const buildPageBreakRunSourceDescendantIndex = (rootContent) => {
|
|
|
95
95
|
switch (block.type) {
|
|
96
96
|
case "paragraph": return inspectMany(block.content, inspectParagraphContent);
|
|
97
97
|
case "table": return inspectMany(block.rows, inspectTableRow);
|
|
98
|
-
case "blockSdt":
|
|
98
|
+
case "blockSdt":
|
|
99
|
+
case "blockCustomXml": return inspectBlocks(block.content);
|
|
99
100
|
case "preservedBlock":
|
|
100
101
|
case "bookmarkStart":
|
|
101
102
|
case "bookmarkEnd": return 0;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Step } from "prosemirror-transform";
|
|
3
|
+
//#region src/internal/revisionResolutionEdits.d.ts
|
|
4
|
+
type RecordNodeResolutionOptions = {
|
|
5
|
+
before: Node;
|
|
6
|
+
after: Node;
|
|
7
|
+
position: number;
|
|
8
|
+
steps: Step[];
|
|
9
|
+
};
|
|
10
|
+
/** Record only carrier edits; content replacements are recorded by their owning walk. */
|
|
11
|
+
declare const recordNodeResolution: ({ before, after, position, steps }: RecordNodeResolutionOptions) => void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { recordNodeResolution };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddMarkStep, AddNodeMarkStep, AttrStep, RemoveMarkStep, RemoveNodeMarkStep } from "prosemirror-transform";
|
|
2
|
+
//#region src/internal/revisionResolutionEdits.ts
|
|
3
|
+
/** Record only carrier edits; content replacements are recorded by their owning walk. */
|
|
4
|
+
const recordNodeResolution = ({ before, after, position, steps }) => {
|
|
5
|
+
if (before === after) return;
|
|
6
|
+
if (!before.isText) {
|
|
7
|
+
for (const name of Object.keys(after.attrs)) if (before.attrs[name] !== after.attrs[name]) steps.push(new AttrStep(position, name, after.attrs[name]));
|
|
8
|
+
}
|
|
9
|
+
for (const mark of before.marks) {
|
|
10
|
+
if (mark.isInSet(after.marks)) continue;
|
|
11
|
+
steps.push(before.isText ? new RemoveMarkStep(position, position + before.nodeSize, mark) : new RemoveNodeMarkStep(position, mark));
|
|
12
|
+
}
|
|
13
|
+
for (const mark of after.marks) {
|
|
14
|
+
if (mark.isInSet(before.marks)) continue;
|
|
15
|
+
steps.push(before.isText ? new AddMarkStep(position, position + before.nodeSize, mark) : new AddNodeMarkStep(position, mark));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { recordNodeResolution };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RunStyleResolver } from "../prosemirror/runStyleFormatting.js";
|
|
2
|
+
import { MarkType, Node } from "prosemirror-model";
|
|
3
|
+
import { Step, StepMap } from "prosemirror-transform";
|
|
4
|
+
//#region src/internal/revisionResolutionInline.d.ts
|
|
5
|
+
type RevisionResolutionMode = "accept" | "reject";
|
|
6
|
+
type RevisionRange = {
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
};
|
|
10
|
+
type ResolveInlineRevisionsOptions = {
|
|
11
|
+
doc: Node;
|
|
12
|
+
mode: RevisionResolutionMode;
|
|
13
|
+
keepType: MarkType | undefined;
|
|
14
|
+
removeType: MarkType | undefined;
|
|
15
|
+
styleResolver: RunStyleResolver | null;
|
|
16
|
+
};
|
|
17
|
+
declare const resolveInlineRevisions: ({ doc, mode, keepType, removeType, styleResolver }: ResolveInlineRevisionsOptions) => {
|
|
18
|
+
resolved: Node;
|
|
19
|
+
positionMap: StepMap;
|
|
20
|
+
ranges: RevisionRange[];
|
|
21
|
+
steps: Step[];
|
|
22
|
+
} | null;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RevisionResolutionMode, resolveInlineRevisions };
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { recreateProseNodeWithParagraphPropertySource } from "../docx/paragraphPropertySource.js";
|
|
2
|
-
import { expectRunPropertyChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
2
|
+
import { expectFieldAttrs, expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
3
3
|
import { resolutionRemovesControl, withoutResolvedEnclosures } from "../prosemirror/contentControlRevisions.js";
|
|
4
|
+
import { resolveEmptyFieldResultRuns } from "../prosemirror/emptyFieldResultRuns.js";
|
|
4
5
|
import "../prosemirror/extensions/nodes/SdtExtension.js";
|
|
5
6
|
import { continuedRunMarks } from "../prosemirror/rejoinRunCarriers.js";
|
|
6
7
|
import { RUN_FORMATTING_MARK_NAMES } from "../prosemirror/runFormattingMarkNames.js";
|
|
7
8
|
import { reconstructRejectedRunFormattingMarks } from "../prosemirror/runPropertyChangeResolution.js";
|
|
8
9
|
import { paragraphRunStyleContext } from "../prosemirror/runStyleFormatting.js";
|
|
10
|
+
import { recordNodeResolution } from "./revisionResolutionEdits.js";
|
|
9
11
|
import { panic } from "better-result";
|
|
10
12
|
import { Fragment, Slice } from "prosemirror-model";
|
|
11
13
|
import { ReplaceStep, StepMap } from "prosemirror-transform";
|
|
12
|
-
//#region src/internal/
|
|
14
|
+
//#region src/internal/revisionResolutionInline.ts
|
|
13
15
|
const EMPTY_PARAGRAPH_RUN_STYLE_CONTEXT = {
|
|
14
16
|
baseParagraphFormatting: void 0,
|
|
15
17
|
paragraphFormatting: void 0,
|
|
@@ -21,30 +23,6 @@ const resolveParagraphRunStyleScope = (scope, styleResolver) => {
|
|
|
21
23
|
scope.resolved ??= paragraphRunStyleContext(scope.paragraph, styleResolver);
|
|
22
24
|
return scope.resolved;
|
|
23
25
|
};
|
|
24
|
-
/**
|
|
25
|
-
* A synchronous headless replacement with the granular position map of the
|
|
26
|
-
* inline deletions it applies. It must never enter history or collaboration;
|
|
27
|
-
* map and serialization fail loudly if that invariant is broken.
|
|
28
|
-
*/
|
|
29
|
-
var HeadlessInlineResolutionStep = class HeadlessInlineResolutionStep extends ReplaceStep {
|
|
30
|
-
positionMap;
|
|
31
|
-
constructor(from, to, slice, positionMap) {
|
|
32
|
-
super(from, to, slice);
|
|
33
|
-
this.positionMap = positionMap;
|
|
34
|
-
}
|
|
35
|
-
getMap() {
|
|
36
|
-
return this.positionMap;
|
|
37
|
-
}
|
|
38
|
-
invert(doc) {
|
|
39
|
-
return new HeadlessInlineResolutionStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to), this.positionMap.invert());
|
|
40
|
-
}
|
|
41
|
-
map(_mapping) {
|
|
42
|
-
return panic("A headless revision-resolution step cannot be mapped");
|
|
43
|
-
}
|
|
44
|
-
toJSON() {
|
|
45
|
-
return panic("A headless revision-resolution step cannot be serialized");
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
26
|
const marksEqual = (left, right) => left.length === right.length && left.every((mark, index) => {
|
|
49
27
|
const candidate = right[index];
|
|
50
28
|
return candidate !== void 0 && mark.eq(candidate);
|
|
@@ -56,14 +34,25 @@ const rebuildNode = (source, attrs, content, marks = source.marks) => recreatePr
|
|
|
56
34
|
});
|
|
57
35
|
const resolveInlineNode = ({ node, context, paragraphScope }) => {
|
|
58
36
|
let marks = node.marks;
|
|
37
|
+
let attrs = node.attrs;
|
|
59
38
|
const runPropertyChangeMark = marks.find((mark) => mark.type.name === "runPropertyChange");
|
|
60
39
|
if (runPropertyChangeMark) {
|
|
61
40
|
const { changes } = expectRunPropertyChangeMarkAttrs(runPropertyChangeMark);
|
|
62
41
|
if (changes.length > 0) {
|
|
63
42
|
marks = marks.filter((mark) => mark !== runPropertyChangeMark);
|
|
64
|
-
|
|
43
|
+
const emptyRuns = node.type.name === "field" || node.type.name === "structuredField" ? expectFieldAttrs(node)._docxEmptyResultRuns : void 0;
|
|
44
|
+
const resolvedRuns = emptyRuns ? resolveEmptyFieldResultRuns({
|
|
45
|
+
runs: emptyRuns,
|
|
46
|
+
mode: context.mode,
|
|
47
|
+
revisionIds: null
|
|
48
|
+
}) : null;
|
|
49
|
+
if (resolvedRuns) attrs = {
|
|
50
|
+
...attrs,
|
|
51
|
+
_docxEmptyResultRuns: resolvedRuns.runs
|
|
52
|
+
};
|
|
53
|
+
if (context.mode === "reject" && (!resolvedRuns || resolvedRuns.visibleFormattingChanged)) {
|
|
65
54
|
marks = marks.filter((mark) => !RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
|
|
66
|
-
const previousFormatting = changes.at(0)?.previousFormatting;
|
|
55
|
+
const previousFormatting = resolvedRuns ? resolvedRuns.visibleFormatting : changes.at(0)?.previousFormatting;
|
|
67
56
|
for (const previousMark of reconstructRejectedRunFormattingMarks({
|
|
68
57
|
node,
|
|
69
58
|
paragraphContext: resolveParagraphRunStyleScope(paragraphScope, context.styleResolver),
|
|
@@ -73,16 +62,17 @@ const resolveInlineNode = ({ node, context, paragraphScope }) => {
|
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
|
-
if (context.removeType && node.marks.some((mark) => mark.type === context.removeType)) return null;
|
|
65
|
+
if (node.marks.some((mark) => (mark.type.name === "insertion" || mark.type.name === "deletion") && expectTrackedChangeMarkAttrs(mark)._docxRevisionAncestors?.some((layer) => context.mode === "accept" ? layer.type === "deletion" || layer.type === "moveFrom" : layer.type === "insertion" || layer.type === "moveTo")) || context.removeType && node.marks.some((mark) => mark.type === context.removeType)) return null;
|
|
77
66
|
if (context.keepType) marks = marks.filter((mark) => mark.type !== context.keepType);
|
|
67
|
+
if (attrs !== node.attrs) return rebuildNode(node, attrs, node.content, marks);
|
|
78
68
|
return marksEqual(marks, node.marks) ? node : node.mark(marks);
|
|
79
69
|
};
|
|
80
70
|
/**
|
|
81
|
-
* The pieces a revision split off its run, one run again: the
|
|
71
|
+
* The pieces a revision split off its run, one run again: the tree-walk counterpart of
|
|
82
72
|
* `rejoinRunsAt`, over the children of one inline container.
|
|
83
73
|
*/
|
|
84
|
-
const rejoinResolvedRuns = ({ children, resolvedBoundaries, paragraphScope, context }) => {
|
|
85
|
-
for (const index of
|
|
74
|
+
const rejoinResolvedRuns = ({ children, positions, resolvedBoundaries, paragraphScope, context }) => {
|
|
75
|
+
for (const index of resolvedBoundaries) {
|
|
86
76
|
const left = children[index - 1];
|
|
87
77
|
const right = children[index];
|
|
88
78
|
if (!left || !right) continue;
|
|
@@ -92,7 +82,16 @@ const rejoinResolvedRuns = ({ children, resolvedBoundaries, paragraphScope, cont
|
|
|
92
82
|
context: () => resolveParagraphRunStyleScope(paragraphScope, context.styleResolver),
|
|
93
83
|
styleResolver: context.styleResolver
|
|
94
84
|
});
|
|
95
|
-
if (marks !== null)
|
|
85
|
+
if (marks !== null) {
|
|
86
|
+
const joined = right.mark(marks);
|
|
87
|
+
recordNodeResolution({
|
|
88
|
+
before: right,
|
|
89
|
+
after: joined,
|
|
90
|
+
position: positions[index] ?? 0,
|
|
91
|
+
steps: context.steps
|
|
92
|
+
});
|
|
93
|
+
children[index] = joined;
|
|
94
|
+
}
|
|
96
95
|
}
|
|
97
96
|
};
|
|
98
97
|
const resolveInlineContent = ({ node, position, context, inheritedParagraphScope }) => {
|
|
@@ -114,6 +113,12 @@ const resolveInlineContent = ({ node, position, context, inheritedParagraphScope
|
|
|
114
113
|
return null;
|
|
115
114
|
}
|
|
116
115
|
resolvedNode = resolved;
|
|
116
|
+
recordNodeResolution({
|
|
117
|
+
before: node,
|
|
118
|
+
after: resolvedNode,
|
|
119
|
+
position,
|
|
120
|
+
steps: context.steps
|
|
121
|
+
});
|
|
117
122
|
if (resolvedNode.isLeaf) return resolvedNode;
|
|
118
123
|
}
|
|
119
124
|
if (resolutionRemovesControl({
|
|
@@ -129,6 +134,7 @@ const resolveInlineContent = ({ node, position, context, inheritedParagraphScope
|
|
|
129
134
|
return null;
|
|
130
135
|
}
|
|
131
136
|
const children = [];
|
|
137
|
+
const positions = [];
|
|
132
138
|
/** Indices into `children` where resolved content began or ended. */
|
|
133
139
|
const resolvedBoundaries = /* @__PURE__ */ new Set();
|
|
134
140
|
const contentStart = resolvedNode.type.name === "doc" ? 0 : position + 1;
|
|
@@ -146,13 +152,21 @@ const resolveInlineContent = ({ node, position, context, inheritedParagraphScope
|
|
|
146
152
|
}
|
|
147
153
|
if (resolved) {
|
|
148
154
|
children.push(resolved);
|
|
155
|
+
positions.push(contentStart + offset);
|
|
149
156
|
if (resolved !== child) resolvedBoundaries.add(children.length);
|
|
150
157
|
}
|
|
151
158
|
});
|
|
152
159
|
const resolvedAttrs = resolvedNode.type.name === "sdt" ? withoutResolvedEnclosures(resolvedNode, () => true) ?? resolvedNode.attrs : resolvedNode.attrs;
|
|
160
|
+
if (resolvedAttrs !== resolvedNode.attrs) recordNodeResolution({
|
|
161
|
+
before: resolvedNode,
|
|
162
|
+
after: rebuildNode(resolvedNode, resolvedAttrs, resolvedNode.content),
|
|
163
|
+
position,
|
|
164
|
+
steps: context.steps
|
|
165
|
+
});
|
|
153
166
|
if (!contentChanged && resolvedAttrs === resolvedNode.attrs) return resolvedNode;
|
|
154
167
|
if (contentChanged && resolvedNode.inlineContent) rejoinResolvedRuns({
|
|
155
168
|
children,
|
|
169
|
+
positions,
|
|
156
170
|
resolvedBoundaries,
|
|
157
171
|
paragraphScope,
|
|
158
172
|
context
|
|
@@ -161,7 +175,7 @@ const resolveInlineContent = ({ node, position, context, inheritedParagraphScope
|
|
|
161
175
|
if (!resolvedNode.type.validContent(resolvedContent)) {
|
|
162
176
|
const fitted = resolvedNode.type.createAndFill(resolvedNode.attrs, resolvedContent, resolvedNode.marks);
|
|
163
177
|
if (!fitted || !resolvedNode.type.validContent(fitted.content)) {
|
|
164
|
-
if (!resolvedNode.isInline) return panic(`
|
|
178
|
+
if (!resolvedNode.isInline) return panic(`Revision inline resolution invalidated ${resolvedNode.type.name} content`);
|
|
165
179
|
context.replacementRanges.splice(replacementRangeStart, context.replacementRanges.length - replacementRangeStart, {
|
|
166
180
|
from: position,
|
|
167
181
|
to: position + node.nodeSize,
|
|
@@ -172,7 +186,8 @@ const resolveInlineContent = ({ node, position, context, inheritedParagraphScope
|
|
|
172
186
|
context.replacementRanges.splice(replacementRangeStart, context.replacementRanges.length - replacementRangeStart, {
|
|
173
187
|
from: contentStart,
|
|
174
188
|
to: contentStart + node.content.size,
|
|
175
|
-
newSize: fitted.content.size
|
|
189
|
+
newSize: fitted.content.size,
|
|
190
|
+
slice: new Slice(fitted.content, 0, 0)
|
|
176
191
|
});
|
|
177
192
|
resolvedContent = fitted.content;
|
|
178
193
|
}
|
|
@@ -191,32 +206,35 @@ const coalesceReplacementRanges = (replacementRanges) => {
|
|
|
191
206
|
}
|
|
192
207
|
return coalesced;
|
|
193
208
|
};
|
|
194
|
-
const
|
|
209
|
+
const resolveInlineRevisions = ({ doc, mode, keepType, removeType, styleResolver }) => {
|
|
195
210
|
const context = {
|
|
196
211
|
mode,
|
|
197
212
|
keepType,
|
|
198
213
|
removeType,
|
|
199
214
|
replacementRanges: [],
|
|
215
|
+
steps: [],
|
|
200
216
|
changedParagraphRanges: [],
|
|
201
217
|
styleResolver
|
|
202
218
|
};
|
|
203
219
|
const resolved = resolveInlineContent({
|
|
204
|
-
node:
|
|
220
|
+
node: doc,
|
|
205
221
|
position: -1,
|
|
206
222
|
context
|
|
207
223
|
});
|
|
208
|
-
if (!resolved || resolved.eq(
|
|
209
|
-
const
|
|
224
|
+
if (!resolved || resolved.eq(doc)) return null;
|
|
225
|
+
const replacementRanges = coalesceReplacementRanges(context.replacementRanges);
|
|
226
|
+
const positionMap = new StepMap(replacementRanges.flatMap(({ from, to, newSize }) => [
|
|
210
227
|
from,
|
|
211
228
|
to - from,
|
|
212
229
|
newSize
|
|
213
230
|
]));
|
|
214
|
-
const
|
|
215
|
-
tr.step(new HeadlessInlineResolutionStep(0, tr.doc.content.size, new Slice(resolved.content, 0, 0), positionMap));
|
|
231
|
+
for (const { from, to, slice } of replacementRanges.toReversed()) context.steps.push(new ReplaceStep(from, to, slice ?? Slice.empty));
|
|
216
232
|
return {
|
|
233
|
+
resolved,
|
|
234
|
+
positionMap,
|
|
217
235
|
ranges: context.changedParagraphRanges,
|
|
218
|
-
|
|
236
|
+
steps: context.steps
|
|
219
237
|
};
|
|
220
238
|
};
|
|
221
239
|
//#endregion
|
|
222
|
-
export {
|
|
240
|
+
export { resolveInlineRevisions };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Node, Schema } from "prosemirror-model";
|
|
2
|
+
import { Mappable, Step, StepMap, StepResult } from "prosemirror-transform";
|
|
3
|
+
//#region src/internal/revisionResolutionStep.d.ts
|
|
4
|
+
type DeferredInverse = {
|
|
5
|
+
doc: Node;
|
|
6
|
+
steps: readonly Step[];
|
|
7
|
+
};
|
|
8
|
+
type RevisionResolutionStepOptions = {
|
|
9
|
+
beforeDoc: Node | null;
|
|
10
|
+
afterDoc: Node | null;
|
|
11
|
+
steps: readonly Step[];
|
|
12
|
+
positionMap: StepMap;
|
|
13
|
+
deferredInverse?: DeferredInverse;
|
|
14
|
+
};
|
|
15
|
+
/** Compose by retaining precisely the source positions that survive both maps. */
|
|
16
|
+
declare const composeRevisionResolutionMaps: (first: StepMap, second: StepMap) => StepMap;
|
|
17
|
+
/** One transaction step for a bulk resolution, with a granular position map. */
|
|
18
|
+
declare class RevisionResolutionStep extends Step {
|
|
19
|
+
private materializedSteps;
|
|
20
|
+
private readonly beforeDoc;
|
|
21
|
+
private readonly afterDoc;
|
|
22
|
+
private readonly positionMap;
|
|
23
|
+
private readonly deferredInverse;
|
|
24
|
+
constructor({ beforeDoc, afterDoc, steps, positionMap, deferredInverse }: RevisionResolutionStepOptions);
|
|
25
|
+
private steps;
|
|
26
|
+
apply(doc: Node): StepResult;
|
|
27
|
+
getMap(): StepMap;
|
|
28
|
+
invert(doc: Node): RevisionResolutionStep;
|
|
29
|
+
map(mapping: Mappable): RevisionResolutionStep | null;
|
|
30
|
+
toJSON(): unknown;
|
|
31
|
+
static fromJSON(schema: Schema, json: unknown): RevisionResolutionStep;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { RevisionResolutionStep, composeRevisionResolutionMaps };
|