@stll/folio-core 0.35.1 → 0.37.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 +59 -1
- package/dist/ai-edits/apply.js +878 -377
- package/dist/ai-edits/block-identity.d.ts +4 -1
- package/dist/ai-edits/block-identity.js +4 -1
- package/dist/ai-edits/blockRange.js +14 -14
- package/dist/ai-edits/clean-text.d.ts +40 -1
- package/dist/ai-edits/clean-text.js +52 -2
- package/dist/ai-edits/headless.d.ts +3 -1
- package/dist/ai-edits/headless.js +141 -73
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/read.js +38 -20
- package/dist/ai-edits/snapshot.d.ts +14 -6
- package/dist/ai-edits/snapshot.js +105 -20
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.js +7 -0
- package/dist/ai-edits/table-template.d.ts +11 -1
- package/dist/ai-edits/table-template.js +49 -17
- package/dist/ai-edits/types.d.ts +62 -61
- package/dist/ai-edits/word-diff.d.ts +18 -3
- package/dist/ai-edits/word-diff.js +556 -67
- package/dist/ai-suggestions/conflict.js +1 -4
- package/dist/ai-suggestions/text-positions.d.ts +8 -0
- package/dist/ai-suggestions/text-positions.js +27 -5
- package/dist/compare/__fixtures__/body-sequence.js +3 -4
- package/dist/compare/column-alignment.d.ts +13 -13
- package/dist/compare/column-alignment.js +78 -39
- package/dist/compare/compare.d.ts +4 -3
- package/dist/compare/compare.js +48 -21
- package/dist/compare/content-alignment.d.ts +95 -0
- package/dist/compare/content-alignment.js +1450 -0
- package/dist/compare/content-types.d.ts +100 -0
- package/dist/compare/content-types.js +0 -0
- package/dist/compare/content.d.ts +209 -0
- package/dist/compare/content.js +885 -0
- package/dist/compare/formatting.d.ts +5 -5
- package/dist/compare/formatting.js +6 -4
- package/dist/compare/plan.d.ts +6 -1
- package/dist/compare/plan.js +171 -566
- package/dist/compare/scenario.d.ts +2 -2
- package/dist/compare/types.d.ts +3 -3
- package/dist/compare/verification.d.ts +8 -9
- package/dist/compare/verification.js +72 -50
- package/dist/compat/eigenpal.d.ts +5 -3
- package/dist/compat/eigenpal.js +3 -2
- package/dist/controller/headerFooterEditorManager.js +18 -10
- package/dist/controller/hiddenEditorApi.js +1 -1
- package/dist/controller/hiddenEditorManager.d.ts +7 -2
- package/dist/controller/hiddenEditorManager.js +15 -6
- package/dist/controller/layoutPipeline.js +5 -3
- package/dist/controller/noteEditorManager.js +12 -7
- package/dist/display-list/build/headerFooterPrimitives.js +1 -0
- package/dist/display-list/build/storyPrimitives.d.ts +5 -2
- package/dist/display-list/build/storyPrimitives.js +60 -3
- package/dist/display-list/build/tablePrimitives.js +30 -0
- package/dist/display-list/primitives.d.ts +1 -1
- package/dist/document-operations.d.ts +8 -4
- package/dist/document-operations.js +104 -12
- package/dist/docx/blockContentParser.js +6 -27
- package/dist/docx/commentParser.js +2 -4
- package/dist/docx/commentRangeIntegrity.js +2 -4
- package/dist/docx/documentClone.d.ts +2 -0
- package/dist/docx/documentClone.js +2 -0
- package/dist/docx/ensureParaIds.js +9 -4
- package/dist/docx/headerFooterParser.js +2 -4
- package/dist/docx/normalizeBaseDirection.js +5 -7
- package/dist/docx/numberingParser.d.ts +3 -1
- package/dist/docx/numberingParser.js +4 -1
- package/dist/docx/paragraphParser.js +34 -35
- package/dist/docx/paragraphPropertySource.d.ts +49 -0
- package/dist/docx/paragraphPropertySource.js +113 -0
- package/dist/docx/paragraphTraversal.js +30 -34
- package/dist/docx/rezip.d.ts +0 -8
- package/dist/docx/rezip.js +41 -16
- package/dist/docx/runConsolidator.js +2 -4
- package/dist/docx/runParser.js +6 -17
- package/dist/docx/sectionParser.js +1 -15
- package/dist/docx/serializer/paragraphSerializer.js +289 -30
- package/dist/docx/serializer/runSerializer.js +6 -12
- package/dist/docx/serializer/sectionPropertiesSerializer.js +2 -10
- package/dist/docx/serializer/tableSerializer.js +4 -23
- package/dist/docx/serializer/trackedChangeAttributes.d.ts +11 -0
- package/dist/docx/serializer/trackedChangeAttributes.js +31 -0
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +8 -10
- package/dist/docx/server/evaluateDocxXmlPatchProposal.js +22 -13
- package/dist/docx/server/validateDocxConformance.js +17 -13
- package/dist/docx/tableParser.js +1 -37
- package/dist/docx/trackedChangeInfo.d.ts +11 -0
- package/dist/docx/trackedChangeInfo.js +38 -0
- package/dist/docx/verbatimCapture.d.ts +20 -9
- package/dist/docx/verbatimCapture.js +208 -8
- package/dist/docx/xmlParser.d.ts +3 -1
- package/dist/docx/xmlParser.js +6 -1
- package/dist/docx/xmlSafety.d.ts +1 -1
- package/dist/docx/xmlSafety.js +157 -0
- package/dist/headless-layout.js +5 -4
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +23 -0
- package/dist/internal/headlessRevisionResolution.js +155 -0
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +12 -0
- package/dist/internal/headlessRevisionResolutionGuard.js +28 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +9 -0
- package/dist/internal/pageBreakRunDescendantIndex.js +27 -0
- package/dist/internal/pageBreakRunPartition.d.ts +26 -0
- package/dist/internal/pageBreakRunPartition.js +35 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +15 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +126 -0
- package/dist/internal/sectionEndpointResolution.d.ts +32 -0
- package/dist/internal/sectionEndpointResolution.js +38 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +16 -4
- package/dist/layout-bridge/convert/headerFooterLayout.js +52 -9
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +4 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +391 -82
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +8 -1
- package/dist/layout-bridge/dom/clickToPositionDom.js +114 -40
- package/dist/layout-bridge/dom/textStreamDom.d.ts +24 -0
- package/dist/layout-bridge/dom/textStreamDom.js +75 -0
- package/dist/layout-bridge/headerFooterLayout.js +16 -30
- package/dist/layout-engine/index.js +12 -3
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.d.ts +17 -0
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.js +1 -1
- package/dist/layout-engine/types.d.ts +7 -0
- package/dist/layout-painter/imageLayout.d.ts +1 -1
- package/dist/layout-painter/renderTable.js +20 -0
- package/dist/markdown/renderBlock.js +7 -10
- package/dist/model.d.ts +1 -1
- package/dist/paged-layout/rangeProjection.js +6 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +3 -1
- package/dist/paged-layout/transactionDirtyRange.js +23 -1
- package/dist/prosemirror/attrs/index.d.ts +7 -3
- package/dist/prosemirror/attrs/index.js +128 -7
- package/dist/prosemirror/bookmarkBoundaryIntegrity.d.ts +9 -0
- package/dist/prosemirror/bookmarkBoundaryIntegrity.js +22 -0
- package/dist/prosemirror/commands/comments.d.ts +10 -1
- package/dist/prosemirror/commands/comments.js +551 -87
- package/dist/prosemirror/commands/formatPainter.d.ts +45 -10
- package/dist/prosemirror/commands/formatPainter.js +319 -63
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/pageBreak.d.ts +5 -2
- package/dist/prosemirror/commands/pageBreak.js +18 -36
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +27 -3
- package/dist/prosemirror/commands/propertyChangeScope.js +85 -14
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +935 -223
- package/dist/prosemirror/conversion/runShadingMark.js +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +26 -1
- package/dist/prosemirror/conversion/toProseDoc.js +439 -291
- package/dist/prosemirror/extensions/StarterKit.js +4 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +54 -6
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +95 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +19 -6
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +27 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +134 -30
- package/dist/prosemirror/extensions/features/pasteCleanup.js +9 -15
- package/dist/prosemirror/extensions/marks/BoldExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +4 -7
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +5 -11
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +3 -3
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +39 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +7 -1
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +67 -21
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +8 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +88 -2
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +44 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +15 -4
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.js +36 -0
- package/dist/prosemirror/findReplaceSelection.js +8 -3
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listMarker.d.ts +26 -1
- package/dist/prosemirror/listMarker.js +108 -14
- package/dist/prosemirror/pageBreakRunProjection.d.ts +28 -0
- package/dist/prosemirror/pageBreakRunProjection.js +47 -0
- package/dist/prosemirror/paraText.js +6 -0
- package/dist/prosemirror/paragraphAlignment.d.ts +12 -0
- package/dist/prosemirror/paragraphAlignment.js +13 -0
- package/dist/prosemirror/paragraphSpacing.d.ts +29 -0
- package/dist/prosemirror/paragraphSpacing.js +125 -0
- package/dist/prosemirror/plugins/documentNumbering.d.ts +8 -0
- package/dist/prosemirror/plugins/documentNumbering.js +18 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +3 -2
- package/dist/prosemirror/plugins/pmTextScan.js +14 -4
- package/dist/prosemirror/plugins/suggestionMode.js +9 -11
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +16 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +61 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +64 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +121 -0
- package/dist/prosemirror/runFormattingProvenance.d.ts +12 -0
- package/dist/prosemirror/runFormattingProvenance.js +48 -0
- package/dist/prosemirror/runFormattingReconciliation.d.ts +25 -0
- package/dist/prosemirror/runFormattingReconciliation.js +54 -0
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +18 -0
- package/dist/prosemirror/runPropertyChangeResolution.js +18 -0
- package/dist/prosemirror/runStyleFormatting.d.ts +50 -0
- package/dist/prosemirror/runStyleFormatting.js +105 -0
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +84 -9
- package/dist/prosemirror/schema/marks.js +73 -1
- package/dist/prosemirror/schema/nodes.d.ts +30 -6
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +14 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +45 -23
- package/dist/prosemirror/styles/styleResolver.d.ts +10 -13
- package/dist/prosemirror/styles/styleResolver.js +3 -3
- package/dist/prosemirror/styles/styleToggleCascade.d.ts +8 -1
- package/dist/prosemirror/styles/styleToggleCascade.js +24 -1
- package/dist/prosemirror/tableGridMutation.d.ts +20 -0
- package/dist/prosemirror/tableGridMutation.js +30 -0
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +31 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +39 -0
- package/dist/prosemirror/utils/visualLineNavigation.js +27 -31
- package/dist/prosemirror/validation.js +23 -4
- package/dist/redline.js +4 -1
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +20 -20
- package/dist/render-dom/RenderedDomContext.js +17 -34
- package/dist/server.d.ts +4 -4
- package/dist/server.js +2 -2
- package/dist/style-engine/styleEngine.d.ts +1 -1
- package/dist/utils/clipboard.js +1 -1
- package/dist/utils/findReplace.js +38 -21
- package/dist/utils/mergeDocumentContent.js +3 -3
- package/dist/utils/replaceText.js +2 -1
- package/dist/version-comparison.d.ts +38 -44
- package/dist/version-comparison.js +270 -399
- package/dist/watermark/index.js +2 -4
- package/package.json +8 -2
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//#region src/compare/content-types.d.ts
|
|
2
|
+
/** How callers expect a block identifier to behave across document revisions. */
|
|
3
|
+
type FolioContentIdStability = "stable" | "positional";
|
|
4
|
+
/** One enclosing structural container, ordered outermost to innermost in a block path. */
|
|
5
|
+
type FolioContentContainerPathEntry = {
|
|
6
|
+
kind: string;
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
/** Boolean inline properties represented by content snapshots. */
|
|
10
|
+
type FolioContentInlineBooleanProperty = "bold" | "italic" | "underline" | "strike";
|
|
11
|
+
type FolioContentInlineFormatting = Partial<Record<FolioContentInlineBooleanProperty, boolean>> & {
|
|
12
|
+
fontFamily?: string | null;
|
|
13
|
+
fontSizePt?: number | null;
|
|
14
|
+
color?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An inline-formatting mutation: `false` is an explicit off value, while
|
|
18
|
+
* `null` removes the direct property so its inherited value becomes effective.
|
|
19
|
+
*/
|
|
20
|
+
type FolioContentInlineFormattingPatch = Omit<FolioContentInlineFormatting, FolioContentInlineBooleanProperty> & Partial<Record<FolioContentInlineBooleanProperty, boolean | null>>;
|
|
21
|
+
type FolioContentRun = {
|
|
22
|
+
text: string;
|
|
23
|
+
bold?: boolean;
|
|
24
|
+
italic?: boolean;
|
|
25
|
+
underline?: boolean;
|
|
26
|
+
strike?: boolean;
|
|
27
|
+
fontFamily?: string;
|
|
28
|
+
fontSizePt?: number;
|
|
29
|
+
color?: string;
|
|
30
|
+
/** Authored run properties only; paragraph and named-style values stay inherited. */
|
|
31
|
+
directFormatting?: FolioContentInlineFormatting;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Where a block sits inside its innermost enclosing table. Every index is
|
|
35
|
+
* zero-based: `tableIndex` counts tables in document order across the story,
|
|
36
|
+
* `rowIndex` is the row's index in that table, `cellIndex` is the cell's
|
|
37
|
+
* physical index within the row (a merged cell occupies one slot, so this is
|
|
38
|
+
* not a grid column), and `paragraphIndex` orders the block among the cell's
|
|
39
|
+
* own blocks. Absent on a block that is not inside a table.
|
|
40
|
+
*/
|
|
41
|
+
type FolioContentTableLocation = {
|
|
42
|
+
/**
|
|
43
|
+
* Document-order index of the outermost table the block sits in. This equals
|
|
44
|
+
* `tableIndex` unless tables nest.
|
|
45
|
+
*/
|
|
46
|
+
outerTableIndex: number;
|
|
47
|
+
tableIndex: number;
|
|
48
|
+
rowIndex: number;
|
|
49
|
+
cellIndex: number;
|
|
50
|
+
/** Grid column occupied by the cell's left edge. */
|
|
51
|
+
gridColumnIndex: number;
|
|
52
|
+
/** Number of grid columns occupied by this physical cell. */
|
|
53
|
+
columnSpan: number;
|
|
54
|
+
/** Number of grid rows occupied by this physical cell. */
|
|
55
|
+
rowSpan: number;
|
|
56
|
+
paragraphIndex: number;
|
|
57
|
+
};
|
|
58
|
+
/** Direct paragraph alignment understood by the neutral comparison model. */
|
|
59
|
+
type FolioContentParagraphAlignment = "left" | "center" | "right" | "both" | "distribute" | "mediumKashida" | "highKashida" | "lowKashida" | "thaiDistribute";
|
|
60
|
+
/** Line-height interpretation understood by the neutral comparison model. */
|
|
61
|
+
type FolioContentLineSpacingRule = "auto" | "exact" | "atLeast";
|
|
62
|
+
/**
|
|
63
|
+
* The complete modeled attribute set of direct paragraph spacing. Optional
|
|
64
|
+
* fields distinguish an absent attribute from an explicit zero or false value.
|
|
65
|
+
*/
|
|
66
|
+
type FolioContentParagraphSpacing = {
|
|
67
|
+
spaceBefore?: number;
|
|
68
|
+
spaceAfter?: number;
|
|
69
|
+
lineSpacing?: number;
|
|
70
|
+
lineSpacingRule?: FolioContentLineSpacingRule;
|
|
71
|
+
beforeAutospacing?: boolean;
|
|
72
|
+
afterAutospacing?: boolean;
|
|
73
|
+
};
|
|
74
|
+
/** A representation-neutral block in one ordered document story. */
|
|
75
|
+
type FolioContentBlock<Kind extends string = string> = {
|
|
76
|
+
id: string;
|
|
77
|
+
kind: Kind;
|
|
78
|
+
text: string;
|
|
79
|
+
idStability?: FolioContentIdStability;
|
|
80
|
+
/** One-based heading depth when the block has outline semantics. */
|
|
81
|
+
headingLevel?: number;
|
|
82
|
+
displayLabel?: string;
|
|
83
|
+
styleId?: string;
|
|
84
|
+
/** Direct paragraph alignment; absent when alignment comes only from a style. */
|
|
85
|
+
directAlignment?: FolioContentParagraphAlignment;
|
|
86
|
+
/** Direct paragraph spacing; absent when every spacing value is inherited. */
|
|
87
|
+
directSpacing?: FolioContentParagraphSpacing;
|
|
88
|
+
/** Zero-based list indent level when the block carries numbering. */
|
|
89
|
+
listLevel?: number;
|
|
90
|
+
previewRuns?: readonly FolioContentRun[];
|
|
91
|
+
table?: FolioContentTableLocation;
|
|
92
|
+
/** Structural ancestry, ordered from the outermost to the innermost container. */
|
|
93
|
+
containerPath?: readonly FolioContentContainerPathEntry[];
|
|
94
|
+
};
|
|
95
|
+
/** Every block of one story, in document order. */
|
|
96
|
+
type FolioContentSnapshot<Block extends FolioContentBlock = FolioContentBlock> = {
|
|
97
|
+
blocks: readonly Block[];
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { FolioContentBlock, FolioContentContainerPathEntry, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentParagraphAlignment, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation };
|
|
File without changes
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { FolioContentBlock, FolioContentIdStability, FolioContentInlineFormattingPatch, FolioContentParagraphSpacing, FolioContentSnapshot } from "./content-types.js";
|
|
2
|
+
import { WordDiffGranularity, createWordDiffSession } from "../ai-edits/word-diff.js";
|
|
3
|
+
import { FolioContentAlignmentStep, FolioContentAlignmentWorkSession } from "./content-alignment.js";
|
|
4
|
+
import { Result } from "better-result";
|
|
5
|
+
//#region src/compare/content.d.ts
|
|
6
|
+
/** Hard resource ceilings for one representation-neutral comparison. */
|
|
7
|
+
declare const FOLIO_CONTENT_COMPARISON_LIMITS: Readonly<{
|
|
8
|
+
readonly blocksPerSnapshot: 100000;
|
|
9
|
+
readonly changes: 10000;
|
|
10
|
+
readonly blockCodeUnits: 1048576;
|
|
11
|
+
readonly textCodeUnitsPerSnapshot: 8000000;
|
|
12
|
+
readonly previewRunsPerBlock: 65536;
|
|
13
|
+
readonly previewRunsPerSnapshot: 1000000;
|
|
14
|
+
readonly containerDepth: 64;
|
|
15
|
+
readonly containerEntriesPerSnapshot: 1000000;
|
|
16
|
+
readonly attributeCodeUnits: 16384;
|
|
17
|
+
readonly attributeCodeUnitsPerSnapshot: 8000000;
|
|
18
|
+
}>;
|
|
19
|
+
type FolioContentComparisonLimit = keyof typeof FOLIO_CONTENT_COMPARISON_LIMITS;
|
|
20
|
+
declare const InvalidFolioContentComparisonError_base: import("better-result").TaggedErrorClass<"InvalidFolioContentComparisonError">;
|
|
21
|
+
declare class InvalidFolioContentComparisonError extends InvalidFolioContentComparisonError_base<{
|
|
22
|
+
message: string;
|
|
23
|
+
input: "options" | "base" | "revised";
|
|
24
|
+
blockIndex?: number;
|
|
25
|
+
field: string;
|
|
26
|
+
}> {}
|
|
27
|
+
declare const FolioContentComparisonLimitError_base: import("better-result").TaggedErrorClass<"FolioContentComparisonLimitError">;
|
|
28
|
+
declare class FolioContentComparisonLimitError extends FolioContentComparisonLimitError_base<{
|
|
29
|
+
message: string;
|
|
30
|
+
input: "base" | "revised" | "result";
|
|
31
|
+
limit: FolioContentComparisonLimit;
|
|
32
|
+
maximum: number;
|
|
33
|
+
actual: number;
|
|
34
|
+
blockIndex?: number;
|
|
35
|
+
field?: string;
|
|
36
|
+
}> {}
|
|
37
|
+
/** Errors returned by {@link compareContent}. */
|
|
38
|
+
type FolioContentComparisonError = InvalidFolioContentComparisonError | FolioContentComparisonLimitError;
|
|
39
|
+
/** One Folio word-diff segment with JavaScript-slice-compatible offsets. */
|
|
40
|
+
type FolioContentTextSegment = {
|
|
41
|
+
type: "equal" | "del" | "ins";
|
|
42
|
+
text: string;
|
|
43
|
+
baseStart: number;
|
|
44
|
+
baseEnd: number;
|
|
45
|
+
revisedStart: number;
|
|
46
|
+
revisedEnd: number;
|
|
47
|
+
};
|
|
48
|
+
/** Target-side paragraph properties that differ from the base block. */
|
|
49
|
+
type FolioContentParagraphFormattingPatch = {
|
|
50
|
+
styleId?: string | null;
|
|
51
|
+
listLevel?: number | null;
|
|
52
|
+
alignment?: FolioContentBlock["directAlignment"] | null;
|
|
53
|
+
spacing?: FolioContentParagraphSpacing | null;
|
|
54
|
+
};
|
|
55
|
+
/** Presentation differences for one text-aligned block pair. */
|
|
56
|
+
type FolioContentFormatRange = {
|
|
57
|
+
startOffset: number;
|
|
58
|
+
endOffset: number;
|
|
59
|
+
formatting: FolioContentInlineFormattingPatch;
|
|
60
|
+
};
|
|
61
|
+
/** Presentation differences for one text-aligned block pair. */
|
|
62
|
+
type FolioContentFormattingChange = {
|
|
63
|
+
paragraph?: FolioContentParagraphFormattingPatch;
|
|
64
|
+
ranges: readonly FolioContentFormatRange[];
|
|
65
|
+
};
|
|
66
|
+
/** Non-presentation block fields that changed on a paired block. */
|
|
67
|
+
type FolioContentBlockProperty = "kind" | "headingLevel" | "displayLabel";
|
|
68
|
+
type PairedEvent<Block extends FolioContentBlock> = {
|
|
69
|
+
baseBlocks: readonly [Block];
|
|
70
|
+
revisedBlocks: readonly [Block];
|
|
71
|
+
};
|
|
72
|
+
type BaseOnlyEvent<Block extends FolioContentBlock> = {
|
|
73
|
+
baseBlocks: readonly [Block];
|
|
74
|
+
revisedBlocks: readonly [];
|
|
75
|
+
};
|
|
76
|
+
type RevisedOnlyEvent<Block extends FolioContentBlock> = {
|
|
77
|
+
baseBlocks: readonly [];
|
|
78
|
+
revisedBlocks: readonly [Block];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* One item in the complete comparison stream. Tuple cardinality is fixed by
|
|
82
|
+
* the discriminator, making both document projections mechanically exact.
|
|
83
|
+
*/
|
|
84
|
+
type FolioContentComparisonEvent<Block extends FolioContentBlock = FolioContentBlock> = ({
|
|
85
|
+
type: "unchanged";
|
|
86
|
+
} & PairedEvent<Block>) | ({
|
|
87
|
+
type: "modified";
|
|
88
|
+
segments: readonly FolioContentTextSegment[];
|
|
89
|
+
changedProperties: readonly FolioContentBlockProperty[];
|
|
90
|
+
formatting?: FolioContentFormattingChange;
|
|
91
|
+
} & PairedEvent<Block>) | ({
|
|
92
|
+
type: "formatting";
|
|
93
|
+
formatting: FolioContentFormattingChange;
|
|
94
|
+
} & PairedEvent<Block>) | ({
|
|
95
|
+
type: "inserted";
|
|
96
|
+
structuralChangeId?: number;
|
|
97
|
+
} & RevisedOnlyEvent<Block>) | ({
|
|
98
|
+
type: "deleted";
|
|
99
|
+
structuralChangeId?: number;
|
|
100
|
+
} & BaseOnlyEvent<Block>) | ({
|
|
101
|
+
type: "movedFrom";
|
|
102
|
+
moveId: number;
|
|
103
|
+
} & BaseOnlyEvent<Block>) | ({
|
|
104
|
+
type: "movedTo";
|
|
105
|
+
moveId: number;
|
|
106
|
+
baseBlockId: string;
|
|
107
|
+
segments?: readonly FolioContentTextSegment[];
|
|
108
|
+
changedProperties?: readonly FolioContentBlockProperty[];
|
|
109
|
+
formatting?: FolioContentFormattingChange;
|
|
110
|
+
} & RevisedOnlyEvent<Block>) | {
|
|
111
|
+
type: "split";
|
|
112
|
+
baseBlocks: readonly [Block];
|
|
113
|
+
revisedBlocks: readonly [Block, Block];
|
|
114
|
+
offset: number;
|
|
115
|
+
separator: string;
|
|
116
|
+
} | {
|
|
117
|
+
type: "merge";
|
|
118
|
+
baseBlocks: readonly [Block, Block];
|
|
119
|
+
revisedBlocks: readonly [Block];
|
|
120
|
+
separator: string;
|
|
121
|
+
};
|
|
122
|
+
type BaseStructuralChange = {
|
|
123
|
+
id: number;
|
|
124
|
+
baseBlockIds: readonly string[];
|
|
125
|
+
};
|
|
126
|
+
type RevisedStructuralChange = {
|
|
127
|
+
id: number;
|
|
128
|
+
revisedBlockIds: readonly string[];
|
|
129
|
+
};
|
|
130
|
+
/** A grouped table operation referenced by its block-granular stream events. */
|
|
131
|
+
type FolioContentStructuralChange = ({
|
|
132
|
+
type: "table-delete";
|
|
133
|
+
tableIndex: number;
|
|
134
|
+
} & BaseStructuralChange) | ({
|
|
135
|
+
type: "table-insert";
|
|
136
|
+
tableIndex: number;
|
|
137
|
+
} & RevisedStructuralChange) | ({
|
|
138
|
+
type: "table-row-delete";
|
|
139
|
+
tableIndex: number;
|
|
140
|
+
rowIndex: number;
|
|
141
|
+
} & BaseStructuralChange) | ({
|
|
142
|
+
type: "table-row-insert";
|
|
143
|
+
tableIndex: number;
|
|
144
|
+
rowIndex: number;
|
|
145
|
+
} & RevisedStructuralChange) | ({
|
|
146
|
+
type: "table-column-delete";
|
|
147
|
+
tableIndex: number;
|
|
148
|
+
columnIndex: number;
|
|
149
|
+
} & BaseStructuralChange) | ({
|
|
150
|
+
type: "table-column-insert";
|
|
151
|
+
tableIndex: number;
|
|
152
|
+
columnIndex: number;
|
|
153
|
+
} & RevisedStructuralChange);
|
|
154
|
+
/** Result of one representation-neutral story comparison. */
|
|
155
|
+
type FolioContentComparison<Block extends FolioContentBlock = FolioContentBlock> = {
|
|
156
|
+
events: readonly FolioContentComparisonEvent<Block>[];
|
|
157
|
+
structuralChanges: readonly FolioContentStructuralChange[];
|
|
158
|
+
};
|
|
159
|
+
/** Inputs to {@link compareContent}. */
|
|
160
|
+
type CompareContentOptions<Block extends FolioContentBlock = FolioContentBlock> = {
|
|
161
|
+
base: FolioContentSnapshot<Block>;
|
|
162
|
+
revised: FolioContentSnapshot<Block>;
|
|
163
|
+
/** Token size for modified-block segments; defaults to `"word"`. */
|
|
164
|
+
granularity?: WordDiffGranularity;
|
|
165
|
+
};
|
|
166
|
+
type FolioContentComparisonWorkSession = {
|
|
167
|
+
alignment: FolioContentAlignmentWorkSession;
|
|
168
|
+
remainingMoveComparisons: number;
|
|
169
|
+
remainingMoveTokenLookups: number;
|
|
170
|
+
diffText: ReturnType<typeof createWordDiffSession>["diff"];
|
|
171
|
+
};
|
|
172
|
+
declare const createContentComparisonWorkSession: (granularity?: WordDiffGranularity) => FolioContentComparisonWorkSession;
|
|
173
|
+
declare const changedFolioContentParagraphFormatting: (base: FolioContentBlock, revised: FolioContentBlock) => FolioContentParagraphFormattingPatch | null;
|
|
174
|
+
type ParagraphMarkPlan<Block extends FolioContentBlock> = {
|
|
175
|
+
type: "split";
|
|
176
|
+
baseBlock: Block;
|
|
177
|
+
revisedBlocks: readonly [Block, Block];
|
|
178
|
+
offset: number;
|
|
179
|
+
separator: string;
|
|
180
|
+
} | {
|
|
181
|
+
type: "merge";
|
|
182
|
+
baseBlocks: readonly [Block, Block];
|
|
183
|
+
revisedBlock: Block;
|
|
184
|
+
separator: string;
|
|
185
|
+
};
|
|
186
|
+
declare const detectFolioContentParagraphMarkPlans: <Block extends FolioContentBlock>(steps: readonly FolioContentAlignmentStep<Block>[]) => ReadonlyMap<number, ParagraphMarkPlan<Block>>;
|
|
187
|
+
type MovePair<Block extends FolioContentBlock> = {
|
|
188
|
+
baseBlock: Block;
|
|
189
|
+
revisedBlock: Block;
|
|
190
|
+
};
|
|
191
|
+
declare const detectFolioContentMoves: <Block extends FolioContentBlock>({ steps, consumedStepIndexes, workSession, idStability }: {
|
|
192
|
+
steps: readonly FolioContentAlignmentStep<Block>[];
|
|
193
|
+
consumedStepIndexes: ReadonlySet<number>;
|
|
194
|
+
workSession: FolioContentComparisonWorkSession;
|
|
195
|
+
idStability?: (block: Block) => FolioContentIdStability;
|
|
196
|
+
}) => readonly MovePair<Block>[];
|
|
197
|
+
type CompareAlignedContentOptions<Block extends FolioContentBlock> = {
|
|
198
|
+
baseBlocks: readonly Block[];
|
|
199
|
+
revisedBlocks: readonly Block[];
|
|
200
|
+
steps: readonly FolioContentAlignmentStep<Block>[];
|
|
201
|
+
workSession: FolioContentComparisonWorkSession;
|
|
202
|
+
maxChanges: number;
|
|
203
|
+
idStability?: (block: Block) => FolioContentIdStability;
|
|
204
|
+
};
|
|
205
|
+
declare const compareAlignedFolioContent: <Block extends FolioContentBlock>({ baseBlocks, revisedBlocks, steps, workSession, maxChanges, idStability }: CompareAlignedContentOptions<Block>) => Result<FolioContentComparison<Block>, FolioContentComparisonLimitError>;
|
|
206
|
+
/** Compare two representation-neutral ordered content snapshots. */
|
|
207
|
+
declare const compareContent: <Block extends FolioContentBlock = FolioContentBlock>(options: CompareContentOptions<Block>) => Result<FolioContentComparison<Block>, FolioContentComparisonError>;
|
|
208
|
+
//#endregion
|
|
209
|
+
export { CompareContentOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FolioContentBlockProperty, FolioContentComparison, FolioContentComparisonError, FolioContentComparisonEvent, FolioContentComparisonLimit, FolioContentComparisonLimitError, FolioContentComparisonWorkSession, FolioContentFormatRange, FolioContentFormattingChange, FolioContentParagraphFormattingPatch, FolioContentStructuralChange, FolioContentTextSegment, InvalidFolioContentComparisonError, changedFolioContentParagraphFormatting, compareAlignedFolioContent, compareContent, createContentComparisonWorkSession, detectFolioContentMoves, detectFolioContentParagraphMarkPlans };
|