@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
package/dist/ai-edits/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { CanonicalGap } from "../types/canonicalCapabilities.js";
|
|
3
|
-
import { FolioContentBlock, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentListReference, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "../compare/content-types.js";
|
|
3
|
+
import { FolioContentBlock, FolioContentBlockIdentity, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentListReference, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentStatedNumbering, FolioContentTableLocation } from "../compare/content-types.js";
|
|
4
4
|
import { ListKind } from "../docx/listNumberingInstances.js";
|
|
5
5
|
//#region src/ai-edits/types.d.ts
|
|
6
6
|
type FolioAIBlockKind = FolioContentParagraphKind | "diagnostic";
|
|
@@ -46,14 +46,17 @@ type FolioAIBlockStructuralBoundary = {
|
|
|
46
46
|
* own blocks. Absent on a block that is not inside a table.
|
|
47
47
|
*/
|
|
48
48
|
type FolioAIBlockTableLocation = FolioContentTableLocation;
|
|
49
|
-
type
|
|
49
|
+
type FolioAIParagraphBlock = FolioContentBlock<FolioContentParagraphKind> & {
|
|
50
50
|
structuralBoundaries?: readonly FolioAIBlockStructuralBoundary[];
|
|
51
|
+
};
|
|
52
|
+
type FolioAIDiagnosticBlock = FolioContentBlockIdentity<"diagnostic"> & {
|
|
51
53
|
/** Present on a read-only block that reports preserved content Folio cannot interpret. */
|
|
52
|
-
diagnostic
|
|
54
|
+
diagnostic: {
|
|
53
55
|
type: "opaqueCarrier";
|
|
54
56
|
carrier: string;
|
|
55
57
|
};
|
|
56
58
|
};
|
|
59
|
+
type FolioAIBlock = FolioAIParagraphBlock | FolioAIDiagnosticBlock;
|
|
57
60
|
/**
|
|
58
61
|
* The complete modeled attribute set of one direct `w:pPr/w:spacing` child.
|
|
59
62
|
* Optional fields preserve the distinction between an absent attribute and
|
|
@@ -66,19 +69,19 @@ type FolioAIListReference = FolioContentListReference;
|
|
|
66
69
|
/** The kinds of list an operation can start. */
|
|
67
70
|
type FolioAIListKind = ListKind;
|
|
68
71
|
/**
|
|
69
|
-
* Start a new list: a numbering instance of `
|
|
72
|
+
* Start a new list: a numbering instance of `format`, defined for the
|
|
70
73
|
* operation, with its paragraphs at `level` (zero-based, default 0). Every
|
|
71
74
|
* paragraph one operation numbers this way joins the same new list; separate
|
|
72
75
|
* operations start separate lists. A package without a numbering part gets
|
|
73
76
|
* one.
|
|
74
77
|
*/
|
|
75
78
|
type FolioAINewListReference = {
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
kind: "newList";
|
|
80
|
+
format: FolioAIListKind;
|
|
78
81
|
level?: number;
|
|
79
82
|
};
|
|
80
83
|
/** An existing numbering instance and level, or a new list. */
|
|
81
|
-
type FolioAIListNumbering =
|
|
84
|
+
type FolioAIListNumbering = FolioContentStatedNumbering | FolioAINewListReference;
|
|
82
85
|
/** Which paragraphs split from one insertion's `text` receive its paragraph formatting. */
|
|
83
86
|
type FolioAIInsertFormattingScope = "firstParagraph" | "allParagraphs";
|
|
84
87
|
/**
|
|
@@ -86,18 +89,13 @@ type FolioAIInsertFormattingScope = "firstParagraph" | "allParagraphs";
|
|
|
86
89
|
* scope: properties a comparison can see in a block projection and an agent
|
|
87
90
|
* has a reason to change.
|
|
88
91
|
*/
|
|
89
|
-
type FolioAIBlockParagraphProperties = {
|
|
92
|
+
type FolioAIBlockParagraphProperties<Numbering = FolioAIListNumbering> = {
|
|
90
93
|
/** `w:pStyle`. `null` clears the style back to the default. */
|
|
91
94
|
styleId?: string | null;
|
|
92
95
|
/** Direct `w:outlineLvl`. `null` restores style inheritance. */
|
|
93
96
|
outlineLevel?: document_d_exports.OutlineLevel | null;
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
* supplies a concrete instance; together they retain that instance without
|
|
97
|
-
* an authored level.
|
|
98
|
-
*/
|
|
99
|
-
listLevel?: number | null;
|
|
100
|
-
numbering?: FolioAIListNumbering | null;
|
|
97
|
+
/** Exact stated numbering: inherit, cancellation, level-only, or an authored reference. */
|
|
98
|
+
numbering?: Numbering;
|
|
101
99
|
/** Direct `w:jc`. `null` clears the override and restores style inheritance. */
|
|
102
100
|
alignment?: document_d_exports.ParagraphAlignment | null;
|
|
103
101
|
/** Direct `w:spacing` attributes. `null` removes the whole direct child. */
|
|
@@ -213,7 +211,7 @@ type FolioAISignatureParty = {
|
|
|
213
211
|
signatory?: string;
|
|
214
212
|
title?: string;
|
|
215
213
|
};
|
|
216
|
-
type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
214
|
+
type FolioAIEditOperation<Numbering = FolioAIListNumbering> = FolioAIEditReviewMeta & {
|
|
217
215
|
precondition?: FolioAIEditPrecondition;
|
|
218
216
|
/**
|
|
219
217
|
* Groups this operation's produced marks under one logical suggestion so the
|
|
@@ -272,7 +270,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
272
270
|
/**
|
|
273
271
|
* Which paragraphs split from `text` receive the operation's
|
|
274
272
|
* paragraph formatting: the inherited anchor formatting plus
|
|
275
|
-
* `styleId`, `outlineLevel`, `
|
|
273
|
+
* `styleId`, `outlineLevel`, `numbering`, `alignment`,
|
|
276
274
|
* `spacing` and `indentation`. `"firstParagraph"` (the default) formats the first
|
|
277
275
|
* and leaves the rest as body paragraphs, for a heading followed by
|
|
278
276
|
* its body. `"allParagraphs"` formats every paragraph alike, for
|
|
@@ -315,16 +313,8 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
315
313
|
* becomes a heading. `null` clears it and lets the style decide.
|
|
316
314
|
*/
|
|
317
315
|
outlineLevel?: document_d_exports.OutlineLevel | null;
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
* anchor's `w:numId`. Without it the inserted paragraph takes the
|
|
321
|
-
* anchor's level, which is the wrong one whenever the new item sits
|
|
322
|
-
* beside a list item at a different depth. `null` gives it no
|
|
323
|
-
* numbering unless `numbering` supplies a concrete instance; together
|
|
324
|
-
* they retain that instance without an authored level.
|
|
325
|
-
*/
|
|
326
|
-
listLevel?: number | null;
|
|
327
|
-
numbering?: FolioAIListNumbering | null;
|
|
316
|
+
/** Exact stated numbering for the inserted paragraph; omission copies the anchor. */
|
|
317
|
+
numbering?: Numbering;
|
|
328
318
|
/**
|
|
329
319
|
* Direct `w:jc` for the inserted block. `null` clears alignment copied
|
|
330
320
|
* from the anchor and lets the inserted paragraph's style decide.
|
|
@@ -397,12 +387,12 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
397
387
|
* Paragraph properties for the first result. Omitted properties keep
|
|
398
388
|
* the source paragraph's value.
|
|
399
389
|
*/
|
|
400
|
-
firstParagraphProperties?: FolioAIBlockParagraphProperties
|
|
390
|
+
firstParagraphProperties?: FolioAIBlockParagraphProperties<Numbering>;
|
|
401
391
|
/**
|
|
402
392
|
* Paragraph properties for the second result. Omitted properties keep
|
|
403
393
|
* the source paragraph's value.
|
|
404
394
|
*/
|
|
405
|
-
secondParagraphProperties?: FolioAIBlockParagraphProperties
|
|
395
|
+
secondParagraphProperties?: FolioAIBlockParagraphProperties<Numbering>;
|
|
406
396
|
} |
|
|
407
397
|
/**
|
|
408
398
|
* Add a whole table next to the anchor block, its rows marked inserted in
|
|
@@ -446,7 +436,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
446
436
|
id: string;
|
|
447
437
|
type: "setBlockParagraphProperties";
|
|
448
438
|
blockId: string;
|
|
449
|
-
properties: FolioAIBlockParagraphProperties
|
|
439
|
+
properties: FolioAIBlockParagraphProperties<Numbering>;
|
|
450
440
|
} |
|
|
451
441
|
/**
|
|
452
442
|
* Join the block with the one after it, the mirror of `splitBlock`: in
|
|
@@ -472,7 +462,7 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
472
462
|
* Paragraph properties for the joined result. Omitted properties keep
|
|
473
463
|
* the first paragraph's value.
|
|
474
464
|
*/
|
|
475
|
-
mergedParagraphProperties?: FolioAIBlockParagraphProperties
|
|
465
|
+
mergedParagraphProperties?: FolioAIBlockParagraphProperties<Numbering>;
|
|
476
466
|
} | {
|
|
477
467
|
id: string;
|
|
478
468
|
type: "commentOnBlock";
|
|
@@ -553,6 +543,8 @@ type FolioAIEditOperation = FolioAIEditReviewMeta & {
|
|
|
553
543
|
/** Stable paragraph anchor inside the cell to split. */
|
|
554
544
|
blockId: string;
|
|
555
545
|
});
|
|
546
|
+
/** Operations after the numbering allocator has resolved every request. */
|
|
547
|
+
type FolioAIResolvedEditOperation = FolioAIEditOperation<FolioContentStatedNumbering>;
|
|
556
548
|
/**
|
|
557
549
|
* How AI-authored operations are applied:
|
|
558
550
|
* - `"direct"` — edits are written straight into the document.
|
|
@@ -754,4 +746,4 @@ type FolioAIEditApplyResult = {
|
|
|
754
746
|
normalizations?: FolioAIEditNormalization[];
|
|
755
747
|
};
|
|
756
748
|
//#endregion
|
|
757
|
-
export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIInsertFormattingScope, FolioAIListKind, FolioAIListNumbering, FolioAIListReference, FolioAINewListReference, FolioAIParagraphIndentation, FolioAIParagraphSpacing, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
|
|
749
|
+
export { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockParagraphProperties, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIDiagnosticBlock, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIInsertFormattingScope, FolioAIListKind, FolioAIListNumbering, FolioAIListReference, FolioAINewListReference, FolioAIParagraphBlock, FolioAIParagraphIndentation, FolioAIParagraphSpacing, FolioAIResolvedEditOperation, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FolioContentBlock, FolioContentTableLocation } from "./content-types.js";
|
|
1
|
+
import { FolioContentBlock, FolioContentBlockIdentity, FolioContentTableLocation } from "./content-types.js";
|
|
2
2
|
//#region src/compare/column-alignment.d.ts
|
|
3
|
-
type TableColumnAlignmentStep<Block extends
|
|
3
|
+
type TableColumnAlignmentStep<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
4
4
|
type: "baseColumn";
|
|
5
5
|
blocks: readonly Block[];
|
|
6
6
|
location: FolioContentTableLocation;
|
|
@@ -15,13 +15,13 @@ type TableColumnAlignmentStep<Block extends FolioContentBlock = FolioContentBloc
|
|
|
15
15
|
position: "after" | "before";
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
type TableColumnAlignment<Block extends
|
|
18
|
+
type TableColumnAlignment<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
19
19
|
steps: TableColumnAlignmentStep<Block>[];
|
|
20
20
|
baseBlocks: Block[];
|
|
21
21
|
revisedBlocks: Block[];
|
|
22
22
|
baseColumnKeys: ReadonlyMap<number, number>;
|
|
23
23
|
revisedColumnKeys: ReadonlyMap<number, number>;
|
|
24
24
|
};
|
|
25
|
-
declare const alignTableColumns: <Block extends
|
|
25
|
+
declare const alignTableColumns: <Block extends FolioContentBlockIdentity>(baseBlocks: readonly Block[], revisedBlocks: readonly Block[]) => TableColumnAlignment<Block> | null;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { TableColumnAlignment, TableColumnAlignmentStep, alignTableColumns };
|
|
@@ -5,6 +5,7 @@ import { FolioRevisionStamp } from "../ai-edits/apply.js";
|
|
|
5
5
|
import { FolioDocumentStoryHandle, FolioDocxReviewer } from "../ai-edits/headless.js";
|
|
6
6
|
import { CompareVerification } from "./verification.js";
|
|
7
7
|
import { CompareChange, CompareCompatibility, CompareDocxApplyError, CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxOptions, CompareDocxParseError, CompareDocxSerializeError, CompareResult, CompareUnsupportedPart, InvalidCompareDocxOptionsError } from "./types.js";
|
|
8
|
+
import { importStyleClosureWithNumbering } from "./import-style-closure.js";
|
|
8
9
|
import { CompareStoryPlan } from "./plan.js";
|
|
9
10
|
import { Result } from "better-result";
|
|
10
11
|
//#region src/compare/compare.d.ts
|
|
@@ -51,12 +52,7 @@ type ParsedComparison = {
|
|
|
51
52
|
pairs: readonly ComparedStoryPair[];
|
|
52
53
|
/** Package-level numbering differences, which belong to no story. */
|
|
53
54
|
numberingChanges: readonly CompareChange[];
|
|
54
|
-
|
|
55
|
-
targetNumberingReferences: readonly {
|
|
56
|
-
numId: number;
|
|
57
|
-
level: number;
|
|
58
|
-
}[];
|
|
59
|
-
targetNumberingReferenceMap: ReadonlyMap<number, number>;
|
|
55
|
+
numberingStage: ReturnType<typeof importStyleClosureWithNumbering>["numberingStage"];
|
|
60
56
|
finalSectionComparison: FinalSectionComparison;
|
|
61
57
|
styleImportFailure: string | undefined;
|
|
62
58
|
unsupported: readonly CompareUnsupportedPart[];
|
|
@@ -100,7 +96,7 @@ type AppliedComparison = {
|
|
|
100
96
|
* what you could not represent" and "give me nothing unless you can prove it"
|
|
101
97
|
* are both legitimate asks and only the caller knows which one it is making.
|
|
102
98
|
*/
|
|
103
|
-
declare const applyComparison: ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges,
|
|
99
|
+
declare const applyComparison: ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges, numberingStage, finalSectionComparison, styleImportFailure, pairs, unsupported }: ParsedComparison, planned: readonly PlannedStoryComparison[]) => Result<AppliedComparison, CompareDocxApplyError | CompareDocxOperationLimitError>;
|
|
104
100
|
/**
|
|
105
101
|
* Stage 4: the result package, with every ZIP entry date pinned.
|
|
106
102
|
*
|
package/dist/compare/compare.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FolioDocxReviewer, getFolioDocxComparisonAccess } from "../ai-edits/headless.js";
|
|
2
2
|
import { withComparisonNoteReferenceEdits } from "../ai-edits/note-references.js";
|
|
3
|
-
import { alignedNoteReferenceLabels, detachFolioAIEditSnapshotExternalHyperlinks, numberingReferenceKeysOf, relabelFolioAIEditSnapshotNoteReferences,
|
|
3
|
+
import { alignedNoteReferenceLabels, detachFolioAIEditSnapshotExternalHyperlinks, numberingReferenceKeysOf, relabelFolioAIEditSnapshotNoteReferences, sourceDocumentOf, storyTablesOf } from "../ai-edits/snapshot.js";
|
|
4
4
|
import { projectTableGeometry } from "../ai-edits/table-geometry.js";
|
|
5
5
|
import { tableTemplateCanCrossPackageLosslessly } from "../ai-edits/table-template.js";
|
|
6
6
|
import { createScopedWordDiffOptions } from "../ai-edits/word-diff.js";
|
|
@@ -11,9 +11,9 @@ import { isOpaqueNestedRowMarkup, opaqueRevisionCarrierName } from "../docx/opaq
|
|
|
11
11
|
import { sectionReferenceHistory } from "../docx/sectionReferenceHistory.js";
|
|
12
12
|
import { sameCanonicalInlinePresentation } from "../internal/compare/inline-presentation.js";
|
|
13
13
|
import { revisionIdSeedAbove } from "../prosemirror/plugins/revisionIds.js";
|
|
14
|
-
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
15
14
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
16
15
|
import { createContentComparisonWorkSession } from "./content.js";
|
|
16
|
+
import { importStyleClosureWithNumbering } from "./import-style-closure.js";
|
|
17
17
|
import { MISSING_NOTE_DETAIL, sameInlineAtoms } from "./inline-atoms.js";
|
|
18
18
|
import { sameAuthoredInlineProvenance } from "./inline-provenance.js";
|
|
19
19
|
import { planStoryCompare } from "./plan.js";
|
|
@@ -348,29 +348,30 @@ const parseComparison = async (base, target, options) => {
|
|
|
348
348
|
targetSnapshot
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
styleIdMap: styleImport.styleIdMap,
|
|
360
|
-
defaultParagraphStyleId: styleImport.defaultParagraphStyleId,
|
|
361
|
-
importedStyleResolver: createStyleResolver(styleImport.styles),
|
|
362
|
-
reconcileAuthoredFormatting: true
|
|
363
|
-
})
|
|
351
|
+
const targetNumberingReferences = pairs.flatMap(({ targetSnapshot }) => targetSnapshot.blocks.flatMap((block) => {
|
|
352
|
+
switch (block.kind) {
|
|
353
|
+
case "diagnostic": return [];
|
|
354
|
+
case "paragraph":
|
|
355
|
+
case "heading":
|
|
356
|
+
case "listItem": return block.listReference ? [block.listReference] : [];
|
|
357
|
+
default: return panic("Unhandled comparison block kind", { block });
|
|
358
|
+
}
|
|
364
359
|
}));
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
360
|
+
const numberingChanges = compareNumbering(reviewer, targetReviewer, referencedNumberingLevels);
|
|
361
|
+
const resources = importStyleClosureWithNumbering({
|
|
362
|
+
destination: reviewer,
|
|
363
|
+
source: targetReviewer,
|
|
364
|
+
snapshots: pairs.map(({ targetSnapshot }) => targetSnapshot),
|
|
365
|
+
importedHeaderFooterSnapshots: [...importedHeaderFooterTargetSnapshots],
|
|
366
|
+
numberingReferences: targetNumberingReferences
|
|
367
|
+
});
|
|
368
|
+
const { styleImport, numberingStage } = resources;
|
|
369
|
+
const comparisonPairs = pairs.map(({ baseStory, targetStory, baseSnapshot, rawBaseSnapshot }, index) => ({
|
|
369
370
|
baseStory,
|
|
370
371
|
targetStory,
|
|
371
372
|
baseSnapshot,
|
|
372
373
|
rawBaseSnapshot: rawBaseSnapshot ?? baseSnapshot,
|
|
373
|
-
targetSnapshot:
|
|
374
|
+
targetSnapshot: resources.snapshots.at(index) ?? panic("A comparison resource import lost its snapshot")
|
|
374
375
|
}));
|
|
375
376
|
const finalSectionComparison = compareFinalSectionProperties({
|
|
376
377
|
base: getFolioDocxComparisonAccess(reviewer).finalSectionProperties(),
|
|
@@ -391,10 +392,8 @@ const parseComparison = async (base, target, options) => {
|
|
|
391
392
|
},
|
|
392
393
|
packageDate,
|
|
393
394
|
pairs: comparisonPairs,
|
|
394
|
-
numberingChanges
|
|
395
|
-
|
|
396
|
-
targetNumberingReferences,
|
|
397
|
-
targetNumberingReferenceMap: targetNumberingReferenceMap ?? /* @__PURE__ */ new Map(),
|
|
395
|
+
numberingChanges,
|
|
396
|
+
numberingStage,
|
|
398
397
|
finalSectionComparison,
|
|
399
398
|
styleImportFailure: styleImport.status === "unalignable" ? styleImport.detail : void 0,
|
|
400
399
|
unsupported
|
|
@@ -538,7 +537,7 @@ const resolveTableTemplates = (targetTables, requests) => {
|
|
|
538
537
|
* what you could not represent" and "give me nothing unless you can prove it"
|
|
539
538
|
* are both legitimate asks and only the caller knows which one it is making.
|
|
540
539
|
*/
|
|
541
|
-
const applyComparison = ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges,
|
|
540
|
+
const applyComparison = ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges, numberingStage, finalSectionComparison, styleImportFailure, pairs, unsupported }, planned) => {
|
|
542
541
|
const relationshipIds = sectionRelationshipMap(pairs);
|
|
543
542
|
const baseNotes = /* @__PURE__ */ new Set();
|
|
544
543
|
for (const { baseStory } of [...pairs, ...unsupported]) if (baseStory?.type === "footnote" || baseStory?.type === "endnote") baseNotes.add(`${baseStory.type}:${String(baseStory.noteId)}`);
|
|
@@ -549,7 +548,6 @@ const applyComparison = ({ reviewer, revisionStamp, granularity, revisionFormat,
|
|
|
549
548
|
limit: MAX_COMPARE_OPERATIONS
|
|
550
549
|
}));
|
|
551
550
|
const comparisonAccess = getFolioDocxComparisonAccess(reviewer);
|
|
552
|
-
const numberingStage = comparisonAccess.stageTargetNumbering(targetNumbering, targetNumberingReferences, targetNumberingReferenceMap);
|
|
553
551
|
const changes = [...numberingChanges];
|
|
554
552
|
const failures = [];
|
|
555
553
|
if (styleImportFailure !== void 0) failures.push({
|
|
@@ -622,7 +620,7 @@ const applyComparison = ({ reviewer, revisionStamp, granularity, revisionFormat,
|
|
|
622
620
|
},
|
|
623
621
|
tableTemplates: resolveTableTemplates(targetTables, plan.tableTemplates),
|
|
624
622
|
replacementBackground: "keep",
|
|
625
|
-
|
|
623
|
+
undefinedReferences: "keep"
|
|
626
624
|
}));
|
|
627
625
|
if (nextRevisionId === void 0) panic("The applier did not report where it left the revision-id counter", { story: pair.baseStory });
|
|
628
626
|
idSeed = nextRevisionId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FolioContentBlock, FolioContentIdStability, FolioContentTableLocation } from "./content-types.js";
|
|
1
|
+
import { FolioContentBlock, FolioContentBlockIdentity, FolioContentIdStability, FolioContentTableLocation } from "./content-types.js";
|
|
2
2
|
import { TableColumnAlignmentStep } from "./column-alignment.js";
|
|
3
3
|
//#region src/compare/content-alignment.d.ts
|
|
4
4
|
type FolioContentAlignmentWorkSession = {
|
|
@@ -29,7 +29,7 @@ type IncreasingPairOptions = {
|
|
|
29
29
|
* stable-anchor pass from quadratic to O(n log n).
|
|
30
30
|
*/
|
|
31
31
|
declare const longestIncreasingFolioContentPairs: (pairs: readonly FolioContentBlockPair[], options?: IncreasingPairOptions) => FolioContentBlockPair[];
|
|
32
|
-
type FolioContentAlignedBlockEvent<Block extends
|
|
32
|
+
type FolioContentAlignedBlockEvent<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
33
33
|
type: "pair";
|
|
34
34
|
baseBlock: Block;
|
|
35
35
|
revisedBlock: Block;
|
|
@@ -40,15 +40,15 @@ type FolioContentAlignedBlockEvent<Block extends FolioContentBlock = FolioConten
|
|
|
40
40
|
type: "revisedOnly";
|
|
41
41
|
block: Block;
|
|
42
42
|
};
|
|
43
|
-
type AlignFolioContentBlocksOptions<Block extends
|
|
43
|
+
type AlignFolioContentBlocksOptions<Block extends FolioContentBlockIdentity> = {
|
|
44
44
|
workSession?: FolioContentAlignmentWorkSession;
|
|
45
45
|
/** Let an already-aligned structural slot outrank differing authored IDs. */
|
|
46
46
|
stableIdMismatch?: "pair" | "separate";
|
|
47
47
|
/** @internal Compatibility hook for adapters whose source model predates `idStability`. */
|
|
48
48
|
idStability?: ((block: Block) => FolioContentIdStability) | undefined;
|
|
49
49
|
};
|
|
50
|
-
declare const alignFolioContentBlocks: <Block extends
|
|
51
|
-
type FolioContentAlignmentStep<Block extends
|
|
50
|
+
declare const alignFolioContentBlocks: <Block extends FolioContentBlockIdentity>(baseBlocks: readonly Block[], revisedBlocks: readonly Block[], options?: AlignFolioContentBlocksOptions<Block>) => FolioContentAlignedBlockEvent<Block>[];
|
|
51
|
+
type FolioContentAlignmentStep<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
52
52
|
type: "pair";
|
|
53
53
|
baseBlock: Block;
|
|
54
54
|
revisedBlock: Block;
|
|
@@ -82,8 +82,8 @@ type FolioContentMoveScope = {
|
|
|
82
82
|
readonly bucket: number;
|
|
83
83
|
readonly gap: number;
|
|
84
84
|
};
|
|
85
|
-
declare const groupFolioContentTableRows: <Block extends
|
|
86
|
-
type AlignFolioContentStructureOptions<Block extends
|
|
85
|
+
declare const groupFolioContentTableRows: <Block extends FolioContentBlockIdentity>(blocks: readonly Block[]) => Block[][];
|
|
86
|
+
type AlignFolioContentStructureOptions<Block extends FolioContentBlockIdentity> = {
|
|
87
87
|
baseBlocks: readonly Block[];
|
|
88
88
|
revisedBlocks: readonly Block[];
|
|
89
89
|
workSession?: FolioContentAlignmentWorkSession;
|
|
@@ -93,7 +93,7 @@ type AlignFolioContentStructureOptions<Block extends FolioContentBlock> = {
|
|
|
93
93
|
/** @internal Compatibility hook for adapters whose source model predates `idStability`. */
|
|
94
94
|
idStability?: ((block: Block) => FolioContentIdStability) | undefined;
|
|
95
95
|
};
|
|
96
|
-
declare const alignFolioContentStructure: <Block extends
|
|
97
|
-
declare const contentBlocksShareContainer: (left:
|
|
96
|
+
declare const alignFolioContentStructure: <Block extends FolioContentBlockIdentity>({ baseBlocks, revisedBlocks, workSession, wholeTableReplacement, stableIdMismatch, idStability }: AlignFolioContentStructureOptions<Block>) => FolioContentAlignmentStep<Block>[];
|
|
97
|
+
declare const contentBlocksShareContainer: (left: FolioContentBlockIdentity, right: FolioContentBlockIdentity) => boolean;
|
|
98
98
|
//#endregion
|
|
99
99
|
export { AlignFolioContentBlocksOptions, AlignFolioContentStructureOptions, CreateFolioContentAlignmentWorkSessionOptions, FolioContentAlignedBlockEvent, FolioContentAlignmentStep, FolioContentAlignmentWorkSession, FolioContentBlockPair, FolioContentMoveScope, alignFolioContentBlocks, alignFolioContentStructure, contentBlocksShareContainer, createFolioContentAlignmentWorkSession, exceedsFolioContentLcsBudget, groupFolioContentTableRows, longestIncreasingFolioContentPairs };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ParagraphNumberingOverride } from "@stll/docx-core/model";
|
|
2
3
|
//#region src/compare/content-types.d.ts
|
|
3
4
|
/** How callers expect a block identifier to behave across document revisions. */
|
|
4
5
|
type FolioContentIdStability = "stable" | "positional";
|
|
@@ -91,13 +92,21 @@ type FolioContentListReference = {
|
|
|
91
92
|
numId: number;
|
|
92
93
|
level: number;
|
|
93
94
|
};
|
|
95
|
+
/** Authored paragraph numbering state, separate from effective list membership. */
|
|
96
|
+
type FolioContentStatedNumbering = ParagraphNumberingOverride | {
|
|
97
|
+
readonly kind: "inherit";
|
|
98
|
+
};
|
|
99
|
+
declare const INHERITED_PARAGRAPH_NUMBERING: {
|
|
100
|
+
readonly kind: "inherit";
|
|
101
|
+
};
|
|
102
|
+
declare const sameFolioContentStatedNumbering: (left: FolioContentStatedNumbering, right: FolioContentStatedNumbering) => boolean;
|
|
94
103
|
/**
|
|
95
104
|
* The complete modeled attribute set of direct paragraph spacing. Optional
|
|
96
105
|
* fields distinguish an absent attribute from an explicit zero or false value.
|
|
97
106
|
*/
|
|
98
107
|
type FolioContentParagraphSpacing = Pick<document_d_exports.ParagraphFormatting, "spaceBefore" | "spaceAfter" | "lineSpacing" | "lineSpacingRule" | "beforeAutospacing" | "afterAutospacing">;
|
|
99
|
-
/**
|
|
100
|
-
type
|
|
108
|
+
/** Identity and shared projection fields for any block in one ordered story. */
|
|
109
|
+
type FolioContentBlockIdentity<Kind extends string = string> = {
|
|
101
110
|
id: string;
|
|
102
111
|
kind: Kind;
|
|
103
112
|
text: string;
|
|
@@ -111,6 +120,13 @@ type FolioContentBlock<Kind extends string = string> = {
|
|
|
111
120
|
*/
|
|
112
121
|
displayLabel?: string;
|
|
113
122
|
styleId?: string;
|
|
123
|
+
previewRuns?: readonly FolioContentRun[];
|
|
124
|
+
table?: FolioContentTableLocation;
|
|
125
|
+
/** Structural ancestry, ordered from the outermost to the innermost container. */
|
|
126
|
+
containerPath?: readonly FolioContentContainerPathEntry[];
|
|
127
|
+
};
|
|
128
|
+
/** A paragraph block with authored paragraph numbering state. */
|
|
129
|
+
type FolioContentBlock<Kind extends FolioContentParagraphKind = FolioContentParagraphKind> = FolioContentBlockIdentity<Kind> & {
|
|
114
130
|
/** Authored `w:outlineLvl`; absent when heading depth comes only from a style. */
|
|
115
131
|
directOutlineLevel?: document_d_exports.OutlineLevel;
|
|
116
132
|
/** Direct paragraph alignment; absent when alignment comes only from a style. */
|
|
@@ -119,17 +135,14 @@ type FolioContentBlock<Kind extends string = string> = {
|
|
|
119
135
|
directSpacing?: FolioContentParagraphSpacing;
|
|
120
136
|
/** Direct paragraph indentation; absent when every indentation value is inherited. */
|
|
121
137
|
directIndentation?: FolioContentParagraphIndentation;
|
|
122
|
-
/**
|
|
123
|
-
listLevel?: number;
|
|
138
|
+
/** Effective list membership resolved from authored and inherited numbering. */
|
|
124
139
|
listReference?: FolioContentListReference;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/** Structural ancestry, ordered from the outermost to the innermost container. */
|
|
128
|
-
containerPath?: readonly FolioContentContainerPathEntry[];
|
|
140
|
+
/** Authored paragraph numbering override; `inherit` means no direct override. */
|
|
141
|
+
statedNumbering: FolioContentStatedNumbering;
|
|
129
142
|
};
|
|
130
143
|
/** Every block of one story, in document order. */
|
|
131
|
-
type FolioContentSnapshot<Block extends
|
|
144
|
+
type FolioContentSnapshot<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
132
145
|
blocks: readonly Block[];
|
|
133
146
|
};
|
|
134
147
|
//#endregion
|
|
135
|
-
export { FolioContentBlock, FolioContentContainerPathEntry, FolioContentFormatRange, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineComparisonResult, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentListReference, FolioContentParagraphAlignment, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation };
|
|
148
|
+
export { FolioContentBlock, FolioContentBlockIdentity, FolioContentContainerPathEntry, FolioContentFormatRange, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineComparisonResult, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentListReference, FolioContentParagraphAlignment, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentStatedNumbering, FolioContentTableLocation, INHERITED_PARAGRAPH_NUMBERING, sameFolioContentStatedNumbering };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/compare/content-types.ts
|
|
2
|
+
const INHERITED_PARAGRAPH_NUMBERING = { kind: "inherit" };
|
|
3
|
+
const sameFolioContentStatedNumbering = (left, right) => {
|
|
4
|
+
if (left.kind !== right.kind) return false;
|
|
5
|
+
switch (left.kind) {
|
|
6
|
+
case "inherit":
|
|
7
|
+
case "none": return true;
|
|
8
|
+
case "levelOnly": return right.kind === "levelOnly" && left.ilvl === right.ilvl;
|
|
9
|
+
case "reference": return right.kind === "reference" && left.numId === right.numId && left.ilvl === right.ilvl;
|
|
10
|
+
default: return left;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { INHERITED_PARAGRAPH_NUMBERING, sameFolioContentStatedNumbering };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FolioContentBlock, FolioContentFormatRange, FolioContentIdStability,
|
|
1
|
+
import { FolioContentBlock, FolioContentBlockIdentity, FolioContentFormatRange, FolioContentIdStability, FolioContentParagraphIndentation, FolioContentParagraphSpacing, FolioContentSnapshot, FolioContentStatedNumbering } from "./content-types.js";
|
|
2
2
|
import { WordDiffGranularity, createWordDiffSession } from "../ai-edits/word-diff.js";
|
|
3
3
|
import { FolioContentAlignmentStep, FolioContentAlignmentWorkSession } from "./content-alignment.js";
|
|
4
4
|
import { Result } from "better-result";
|
|
@@ -56,8 +56,7 @@ type FolioContentTextSegment = {
|
|
|
56
56
|
type FolioContentParagraphFormattingPatch = {
|
|
57
57
|
styleId?: string | null;
|
|
58
58
|
outlineLevel?: FolioContentBlock["directOutlineLevel"] | null;
|
|
59
|
-
|
|
60
|
-
listReference?: FolioContentListReference | null;
|
|
59
|
+
numbering?: FolioContentStatedNumbering;
|
|
61
60
|
alignment?: FolioContentBlock["directAlignment"] | null;
|
|
62
61
|
spacing?: FolioContentParagraphSpacing | null;
|
|
63
62
|
indentation?: FolioContentParagraphIndentation | null;
|
|
@@ -71,15 +70,15 @@ type FolioContentFormattingChange = {
|
|
|
71
70
|
};
|
|
72
71
|
/** Non-presentation block fields that changed on a paired block. */
|
|
73
72
|
type FolioContentBlockProperty = "kind" | "headingLevel" | "displayLabel";
|
|
74
|
-
type PairedEvent<Block extends
|
|
73
|
+
type PairedEvent<Block extends FolioContentBlockIdentity> = {
|
|
75
74
|
baseBlocks: readonly [Block];
|
|
76
75
|
revisedBlocks: readonly [Block];
|
|
77
76
|
};
|
|
78
|
-
type BaseOnlyEvent<Block extends
|
|
77
|
+
type BaseOnlyEvent<Block extends FolioContentBlockIdentity> = {
|
|
79
78
|
baseBlocks: readonly [Block];
|
|
80
79
|
revisedBlocks: readonly [];
|
|
81
80
|
};
|
|
82
|
-
type RevisedOnlyEvent<Block extends
|
|
81
|
+
type RevisedOnlyEvent<Block extends FolioContentBlockIdentity> = {
|
|
83
82
|
baseBlocks: readonly [];
|
|
84
83
|
revisedBlocks: readonly [Block];
|
|
85
84
|
};
|
|
@@ -87,7 +86,7 @@ type RevisedOnlyEvent<Block extends FolioContentBlock> = {
|
|
|
87
86
|
* One item in the complete comparison stream. Tuple cardinality is fixed by
|
|
88
87
|
* the discriminator, making both document projections mechanically exact.
|
|
89
88
|
*/
|
|
90
|
-
type FolioContentComparisonEvent<Block extends
|
|
89
|
+
type FolioContentComparisonEvent<Block extends FolioContentBlockIdentity = FolioContentBlock> = ({
|
|
91
90
|
type: "unchanged";
|
|
92
91
|
} & PairedEvent<Block>) | ({
|
|
93
92
|
type: "modified";
|
|
@@ -158,12 +157,12 @@ type FolioContentStructuralChange = ({
|
|
|
158
157
|
columnIndex: number;
|
|
159
158
|
} & RevisedStructuralChange);
|
|
160
159
|
/** Result of one representation-neutral story comparison. */
|
|
161
|
-
type FolioContentComparison<Block extends
|
|
160
|
+
type FolioContentComparison<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
162
161
|
events: readonly FolioContentComparisonEvent<Block>[];
|
|
163
162
|
structuralChanges: readonly FolioContentStructuralChange[];
|
|
164
163
|
};
|
|
165
164
|
/** Inputs to {@link compareContent}. */
|
|
166
|
-
type CompareContentOptions<Block extends
|
|
165
|
+
type CompareContentOptions<Block extends FolioContentBlockIdentity = FolioContentBlock> = {
|
|
167
166
|
base: FolioContentSnapshot<Block>;
|
|
168
167
|
revised: FolioContentSnapshot<Block>;
|
|
169
168
|
/** Token size for modified-block segments; defaults to `"word"`. */
|
|
@@ -176,8 +175,8 @@ type FolioContentComparisonWorkSession = {
|
|
|
176
175
|
diffText: ReturnType<typeof createWordDiffSession>["diff"];
|
|
177
176
|
};
|
|
178
177
|
declare const createContentComparisonWorkSession: (granularity?: WordDiffGranularity) => FolioContentComparisonWorkSession;
|
|
179
|
-
declare const changedFolioContentParagraphFormatting: (base:
|
|
180
|
-
type ParagraphMarkPlan<Block extends
|
|
178
|
+
declare const changedFolioContentParagraphFormatting: (base: FolioContentBlockIdentity, revised: FolioContentBlockIdentity) => FolioContentParagraphFormattingPatch | null;
|
|
179
|
+
type ParagraphMarkPlan<Block extends FolioContentBlockIdentity> = {
|
|
181
180
|
type: "split";
|
|
182
181
|
baseBlock: Block;
|
|
183
182
|
revisedBlocks: readonly [Block, Block];
|
|
@@ -190,18 +189,18 @@ type ParagraphMarkPlan<Block extends FolioContentBlock> = {
|
|
|
190
189
|
separator: string;
|
|
191
190
|
};
|
|
192
191
|
/** Plans keyed by their first step; each consumes the step after it. */
|
|
193
|
-
declare const detectFolioContentParagraphMarkPlans: <Block extends
|
|
194
|
-
type MovePair<Block extends
|
|
192
|
+
declare const detectFolioContentParagraphMarkPlans: <Block extends FolioContentBlockIdentity>(steps: readonly FolioContentAlignmentStep<Block>[]) => ReadonlyMap<number, ParagraphMarkPlan<Block>>;
|
|
193
|
+
type MovePair<Block extends FolioContentBlockIdentity> = {
|
|
195
194
|
baseBlock: Block;
|
|
196
195
|
revisedBlock: Block;
|
|
197
196
|
};
|
|
198
|
-
declare const detectFolioContentMoves: <Block extends
|
|
197
|
+
declare const detectFolioContentMoves: <Block extends FolioContentBlockIdentity>({ steps, consumedStepIndexes, workSession, idStability }: {
|
|
199
198
|
steps: readonly FolioContentAlignmentStep<Block>[];
|
|
200
199
|
consumedStepIndexes: ReadonlySet<number>;
|
|
201
200
|
workSession: FolioContentComparisonWorkSession;
|
|
202
201
|
idStability?: (block: Block) => FolioContentIdStability;
|
|
203
202
|
}) => readonly MovePair<Block>[];
|
|
204
|
-
type CompareAlignedContentOptions<Block extends
|
|
203
|
+
type CompareAlignedContentOptions<Block extends FolioContentBlockIdentity> = {
|
|
205
204
|
baseBlocks: readonly Block[];
|
|
206
205
|
revisedBlocks: readonly Block[];
|
|
207
206
|
steps: readonly FolioContentAlignmentStep<Block>[];
|
|
@@ -209,8 +208,8 @@ type CompareAlignedContentOptions<Block extends FolioContentBlock> = {
|
|
|
209
208
|
maxChanges: number;
|
|
210
209
|
idStability?: (block: Block) => FolioContentIdStability;
|
|
211
210
|
};
|
|
212
|
-
declare const compareAlignedFolioContent: <Block extends
|
|
211
|
+
declare const compareAlignedFolioContent: <Block extends FolioContentBlockIdentity>({ baseBlocks, revisedBlocks, steps, workSession, maxChanges, idStability }: CompareAlignedContentOptions<Block>) => Result<FolioContentComparison<Block>, FolioContentComparisonLimitError | FolioContentInlinePresentationProjectionError>;
|
|
213
212
|
/** Compare two representation-neutral ordered content snapshots. */
|
|
214
|
-
declare const compareContent: <Block extends
|
|
213
|
+
declare const compareContent: <Block extends FolioContentBlockIdentity = FolioContentBlock>(options: CompareContentOptions<Block>) => Result<FolioContentComparison<Block>, FolioContentComparisonError>;
|
|
215
214
|
//#endregion
|
|
216
215
|
export { CompareContentOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FolioContentBlockProperty, FolioContentComparison, FolioContentComparisonError, FolioContentComparisonEvent, FolioContentComparisonLimit, FolioContentComparisonLimitError, FolioContentComparisonWorkSession, type FolioContentFormatRange, FolioContentFormattingChange, FolioContentInlinePresentationProjectionError, FolioContentParagraphFormattingPatch, FolioContentStructuralChange, FolioContentTextSegment, InvalidFolioContentComparisonError, changedFolioContentParagraphFormatting, compareAlignedFolioContent, compareContent, createContentComparisonWorkSession, detectFolioContentMoves, detectFolioContentParagraphMarkPlans, sameFolioContentOutlineLevel };
|