@stll/folio-core 0.32.1 → 0.33.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/__fixtures__/paragraphs.d.ts +17 -0
- package/dist/ai-edits/__fixtures__/paragraphs.js +33 -0
- package/dist/ai-edits/apply.d.ts +49 -3
- package/dist/ai-edits/apply.js +692 -75
- package/dist/ai-edits/blockRange.d.ts +7 -3
- package/dist/ai-edits/blockRange.js +14 -6
- package/dist/ai-edits/headless.d.ts +39 -5
- package/dist/ai-edits/headless.js +76 -17
- package/dist/ai-edits/index.d.ts +6 -6
- package/dist/ai-edits/index.js +3 -3
- package/dist/ai-edits/read.d.ts +4 -0
- package/dist/ai-edits/read.js +30 -6
- package/dist/ai-edits/scoped-reading.js +4 -3
- package/dist/ai-edits/snapshot.d.ts +42 -2
- package/dist/ai-edits/snapshot.js +127 -62
- package/dist/ai-edits/table-row-column-mutations.d.ts +24 -1
- package/dist/ai-edits/table-row-column-mutations.js +98 -6
- package/dist/ai-edits/table-targets.d.ts +12 -3
- package/dist/ai-edits/table-targets.js +15 -5
- package/dist/ai-edits/types.d.ts +235 -7
- package/dist/ai-edits/word-diff.d.ts +54 -11
- package/dist/ai-edits/word-diff.js +221 -61
- package/dist/compare/__fixtures__/body-sequence.d.ts +33 -0
- package/dist/compare/__fixtures__/body-sequence.js +67 -0
- package/dist/compare/__fixtures__/nested-table.d.ts +16 -0
- package/dist/compare/__fixtures__/nested-table.js +50 -0
- package/dist/compare/__fixtures__/numbered-list.d.ts +34 -0
- package/dist/compare/__fixtures__/numbered-list.js +85 -0
- package/dist/compare/column-alignment.d.ts +27 -0
- package/dist/compare/column-alignment.js +162 -0
- package/dist/compare/compare.d.ts +107 -0
- package/dist/compare/compare.js +406 -0
- package/dist/compare/formatting.d.ts +29 -0
- package/dist/compare/formatting.js +84 -0
- package/dist/compare/plan.d.ts +22 -0
- package/dist/compare/plan.js +1059 -0
- package/dist/compare/reproducible-package.d.ts +17 -0
- package/dist/compare/reproducible-package.js +30 -0
- package/dist/compare/scenario.d.ts +77 -0
- package/dist/compare/scenario.js +263 -0
- package/dist/compare/types.d.ts +282 -0
- package/dist/compare/types.js +32 -0
- package/dist/compare/verification.d.ts +55 -0
- package/dist/compare/verification.js +146 -0
- package/dist/compat/eigenpal.d.ts +9 -6
- package/dist/compat/eigenpal.js +6 -3
- package/dist/controller/layoutPipeline.d.ts +13 -0
- package/dist/controller/layoutPipeline.js +15 -1
- package/dist/display-list/build/buildContext.d.ts +39 -0
- package/dist/display-list/build/buildContext.js +31 -0
- package/dist/display-list/build/buildDisplayList.d.ts +79 -0
- package/dist/display-list/build/buildDisplayList.js +283 -0
- package/dist/display-list/build/colors.d.ts +20 -0
- package/dist/display-list/build/colors.js +136 -0
- package/dist/display-list/build/floatingImages.d.ts +24 -0
- package/dist/display-list/build/floatingImages.js +41 -0
- package/dist/display-list/build/fontTable.d.ts +31 -0
- package/dist/display-list/build/fontTable.js +97 -0
- package/dist/display-list/build/furniture.d.ts +86 -0
- package/dist/display-list/build/furniture.js +98 -0
- package/dist/display-list/build/glyphs.d.ts +55 -0
- package/dist/display-list/build/glyphs.js +103 -0
- package/dist/display-list/build/headerFooterPrimitives.d.ts +17 -0
- package/dist/display-list/build/headerFooterPrimitives.js +40 -0
- package/dist/display-list/build/imagePrimitives.d.ts +35 -0
- package/dist/display-list/build/imagePrimitives.js +264 -0
- package/dist/display-list/build/pageBorderPrimitives.d.ts +23 -0
- package/dist/display-list/build/pageBorderPrimitives.js +111 -0
- package/dist/display-list/build/pageFurniture.d.ts +35 -0
- package/dist/display-list/build/pageFurniture.js +141 -0
- package/dist/display-list/build/paragraphPrimitives.d.ts +19 -0
- package/dist/display-list/build/paragraphPrimitives.js +819 -0
- package/dist/display-list/build/regions.d.ts +46 -0
- package/dist/display-list/build/regions.js +56 -0
- package/dist/display-list/build/storyPrimitives.d.ts +29 -0
- package/dist/display-list/build/storyPrimitives.js +279 -0
- package/dist/display-list/build/strokes.d.ts +19 -0
- package/dist/display-list/build/strokes.js +78 -0
- package/dist/display-list/build/tablePrimitives.d.ts +38 -0
- package/dist/display-list/build/tablePrimitives.js +409 -0
- package/dist/display-list/build/textBoxPrimitives.d.ts +14 -0
- package/dist/display-list/build/textBoxPrimitives.js +129 -0
- package/dist/display-list/build/textDecorations.d.ts +29 -0
- package/dist/display-list/build/textDecorations.js +29 -0
- package/dist/display-list/build/unsupported.d.ts +57 -0
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/build/watermarkPrimitives.d.ts +15 -0
- package/dist/display-list/build/watermarkPrimitives.js +128 -0
- package/dist/display-list/dom/renderDisplayListToDom.d.ts +26 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +620 -0
- package/dist/display-list/editor/displayListPagePainter.d.ts +22 -0
- package/dist/display-list/editor/displayListPagePainter.js +63 -0
- package/dist/display-list/editor/pageRenderer.d.ts +24 -0
- package/dist/display-list/editor/pageRenderer.js +36 -0
- package/dist/display-list/primitives.d.ts +95 -0
- package/dist/display-list/primitives.js +127 -0
- package/dist/display-list/types.d.ts +472 -0
- package/dist/display-list/types.js +0 -0
- package/dist/document-operations.d.ts +42 -9
- package/dist/document-operations.js +171 -16
- package/dist/document-stories.d.ts +16 -0
- package/dist/document-stories.js +48 -4
- package/dist/docx/packageParts.d.ts +35 -0
- package/dist/docx/packageParts.js +120 -0
- package/dist/docx/paragraphParser.js +22 -22
- package/dist/docx/paragraphTraversal.js +1 -1
- package/dist/docx/renderedPageBreakNormalization.js +3 -1
- package/dist/docx/revisionIdNormalization.d.ts +13 -0
- package/dist/docx/revisionIdNormalization.js +103 -0
- package/dist/docx/rezip.js +26 -17
- package/dist/docx/selectiveSave.js +2 -2
- package/dist/docx/serializer/commentSerializer.js +6 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -4
- package/dist/docx/serializer/runSerializer.js +11 -10
- package/dist/docx/serializer/tableSerializer.js +2 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.js +1 -1
- package/dist/docx/server/createBilingualDocx.js +3 -2
- package/dist/docx/streamingXmlParser.d.ts +13 -1
- package/dist/docx/streamingXmlParser.js +49 -11
- package/dist/docx/unzip.d.ts +1 -2
- package/dist/docx/unzip.js +25 -6
- package/dist/docx/xmlParser.d.ts +3 -1
- package/dist/docx/xmlParser.js +33 -27
- package/dist/export-pdf.d.ts +43 -0
- package/dist/export-pdf.js +98 -0
- package/dist/fonts/headlessMeasure.d.ts +76 -0
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/fonts/sfnt/parse.d.ts +51 -0
- package/dist/fonts/sfnt/parse.js +525 -0
- package/dist/fonts/sfnt/subset.d.ts +20 -0
- package/dist/fonts/sfnt/subset.js +350 -0
- package/dist/fonts/sfnt/tables.d.ts +88 -0
- package/dist/fonts/sfnt/tables.js +131 -0
- package/dist/fonts/sfnt/woff.d.ts +14 -0
- package/dist/fonts/sfnt/woff.js +163 -0
- package/dist/generated/text_shaper.js +324 -0
- package/dist/generated/text_shaper_bg.wasm +0 -0
- package/dist/headless-layout.d.ts +75 -0
- package/dist/headless-layout.js +350 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.js +6 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +3 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +2 -0
- package/dist/layout-engine/measure/advanceComposition.d.ts +62 -0
- package/dist/layout-engine/measure/advanceComposition.js +148 -0
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/measureContainer.js +13 -0
- package/dist/layout-engine/measure/measureParagraph.js +1 -2
- package/dist/layout-engine/measure/measureTypes.d.ts +12 -0
- package/dist/layout-engine/measure/tableInlinePlacement.d.ts +3 -2
- package/dist/layout-engine/measure/tableInlinePlacement.js +14 -1
- package/dist/layout-engine/tableIndentCompatibility.d.ts +5 -0
- package/dist/layout-engine/tableIndentCompatibility.js +15 -0
- package/dist/layout-engine/types.d.ts +8 -0
- package/dist/layout-painter/renderPage.d.ts +29 -1
- package/dist/layout-painter/renderPage.js +47 -19
- package/dist/layout-painter/renderParagraph.d.ts +21 -2
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/layout-painter/renderTable.js +37 -4
- package/dist/managers/editorShortcuts.d.ts +33 -1
- package/dist/managers/editorShortcuts.js +20 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +5 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/pdf/contentStream.d.ts +73 -0
- package/dist/pdf/contentStream.js +143 -0
- package/dist/pdf/fonts.d.ts +96 -0
- package/dist/pdf/fonts.js +593 -0
- package/dist/pdf/images.d.ts +28 -0
- package/dist/pdf/images.js +439 -0
- package/dist/pdf/objects.d.ts +93 -0
- package/dist/pdf/objects.js +237 -0
- package/dist/pdf/pageSpace.d.ts +43 -0
- package/dist/pdf/pageSpace.js +57 -0
- package/dist/pdf/paint.d.ts +32 -0
- package/dist/pdf/paint.js +442 -0
- package/dist/pdf/writePdf.d.ts +56 -0
- package/dist/pdf/writePdf.js +345 -0
- package/dist/prosemirror/commands/comments.js +91 -6
- package/dist/prosemirror/conversion/fromProseDoc.js +41 -7
- package/dist/prosemirror/conversion/toProseDoc.js +41 -4
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +15 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +35 -6
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +2 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +4 -3
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +7 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +9 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +56 -39
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.js +5 -3
- package/dist/prosemirror/plugins/suggestionMode.js +1 -0
- package/dist/prosemirror/revisionCarriers.js +19 -2
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +2 -2
- package/dist/prosemirror/utils/extractTrackedChanges.js +59 -23
- package/dist/prosemirror/validation.js +55 -27
- package/dist/prosemirror/zeroWidthAnchors.d.ts +10 -0
- package/dist/prosemirror/zeroWidthAnchors.js +23 -0
- package/dist/redline.js +12 -79
- package/dist/server.d.ts +4 -4
- package/dist/server.js +2 -2
- package/dist/shaping/placeRun.d.ts +51 -0
- package/dist/shaping/placeRun.js +84 -0
- package/dist/shaping/shaper.d.ts +92 -0
- package/dist/shaping/shaper.js +102 -0
- package/dist/types/block-id.d.ts +18 -2
- package/dist/types/block-id.js +49 -5
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/clipboard.js +4 -3
- package/dist/utils/fontResolver.js +183 -0
- package/dist/utils/htmlComments.d.ts +17 -0
- package/dist/utils/htmlComments.js +22 -0
- package/dist/utils/scriptSegments.d.ts +12 -1
- package/dist/utils/scriptSegments.js +17 -1
- package/dist/version-comparison.d.ts +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FolioAIBlock, FolioAIInlineFormatting } from "../ai-edits/types.js";
|
|
2
|
+
//#region src/compare/formatting.d.ts
|
|
3
|
+
/** One run of characters whose supported inline formatting differs. */
|
|
4
|
+
type InlineFormattingSegment = {
|
|
5
|
+
/** Zero-based UTF-16 offset into the block's visible text. */
|
|
6
|
+
startOffset: number;
|
|
7
|
+
endOffset: number;
|
|
8
|
+
/** Only the properties that differ, set to the target document's value. */
|
|
9
|
+
formatting: FolioAIInlineFormatting;
|
|
10
|
+
};
|
|
11
|
+
type InlineFormattingSegmentsOptions = {
|
|
12
|
+
baseBlock: FolioAIBlock;
|
|
13
|
+
targetBlock: FolioAIBlock;
|
|
14
|
+
/** Refuse (return `null`) rather than build more segments than this. */
|
|
15
|
+
maxSegments: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Segments where `targetBlock`'s bold / italic / underline / strike differs from
|
|
19
|
+
* `baseBlock`'s, for two blocks that carry the same text. Returns `null` only
|
|
20
|
+
* when the diff would exceed `maxSegments`.
|
|
21
|
+
*
|
|
22
|
+
* A block whose runs cannot be aligned to its text reports no segments rather
|
|
23
|
+
* than guessing: attributing formatting to the wrong characters is worse than
|
|
24
|
+
* missing a formatting-only change, and the caller has no offset it could
|
|
25
|
+
* trust instead.
|
|
26
|
+
*/
|
|
27
|
+
declare const inlineFormattingSegments: ({ baseBlock, targetBlock, maxSegments }: InlineFormattingSegmentsOptions) => InlineFormattingSegment[] | null;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { InlineFormattingSegment, inlineFormattingSegments };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/compare/formatting.ts
|
|
2
|
+
const changedSupportedFormatting = (base, target) => ({
|
|
3
|
+
...Boolean(base.bold) !== Boolean(target.bold) && { bold: Boolean(target.bold) },
|
|
4
|
+
...Boolean(base.italic) !== Boolean(target.italic) && { italic: Boolean(target.italic) },
|
|
5
|
+
...Boolean(base.underline) !== Boolean(target.underline) && { underline: Boolean(target.underline) },
|
|
6
|
+
...Boolean(base.strike) !== Boolean(target.strike) && { strike: Boolean(target.strike) }
|
|
7
|
+
});
|
|
8
|
+
const sameInlineFormatting = (left, right) => left.bold === right.bold && left.italic === right.italic && left.underline === right.underline && left.strike === right.strike;
|
|
9
|
+
const hasInlineFormatting = (formatting) => formatting.bold !== void 0 || formatting.italic !== void 0 || formatting.underline !== void 0 || formatting.strike !== void 0;
|
|
10
|
+
/**
|
|
11
|
+
* A block's runs, or `null` when they cannot describe the block's text.
|
|
12
|
+
* Non-text inline content (a field, an image) leaves the concatenated run text
|
|
13
|
+
* shorter than the block text; attributing formatting by offset would then
|
|
14
|
+
* point at the wrong characters, so the caller must back off instead.
|
|
15
|
+
*/
|
|
16
|
+
const previewRunsForBlock = (block) => {
|
|
17
|
+
const runs = block.previewRuns ?? [{ text: block.text }];
|
|
18
|
+
return runs.map(({ text }) => text).join("") === block.text ? runs : null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Segments where `targetBlock`'s bold / italic / underline / strike differs from
|
|
22
|
+
* `baseBlock`'s, for two blocks that carry the same text. Returns `null` only
|
|
23
|
+
* when the diff would exceed `maxSegments`.
|
|
24
|
+
*
|
|
25
|
+
* A block whose runs cannot be aligned to its text reports no segments rather
|
|
26
|
+
* than guessing: attributing formatting to the wrong characters is worse than
|
|
27
|
+
* missing a formatting-only change, and the caller has no offset it could
|
|
28
|
+
* trust instead.
|
|
29
|
+
*/
|
|
30
|
+
const inlineFormattingSegments = ({ baseBlock, targetBlock, maxSegments }) => {
|
|
31
|
+
const baseRuns = previewRunsForBlock(baseBlock);
|
|
32
|
+
const targetRuns = previewRunsForBlock(targetBlock);
|
|
33
|
+
if (!baseRuns || !targetRuns || baseBlock.text.length === 0) return [];
|
|
34
|
+
const segments = [];
|
|
35
|
+
let baseRunIndex = 0;
|
|
36
|
+
let targetRunIndex = 0;
|
|
37
|
+
let baseRunOffset = 0;
|
|
38
|
+
let targetRunOffset = 0;
|
|
39
|
+
let textOffset = 0;
|
|
40
|
+
while (baseRunIndex < baseRuns.length && targetRunIndex < targetRuns.length) {
|
|
41
|
+
const baseRun = baseRuns[baseRunIndex];
|
|
42
|
+
const targetRun = targetRuns[targetRunIndex];
|
|
43
|
+
if (!baseRun || !targetRun) break;
|
|
44
|
+
const length = Math.min(baseRun.text.length - baseRunOffset, targetRun.text.length - targetRunOffset);
|
|
45
|
+
if (length <= 0) {
|
|
46
|
+
if (baseRunOffset >= baseRun.text.length) {
|
|
47
|
+
baseRunIndex++;
|
|
48
|
+
baseRunOffset = 0;
|
|
49
|
+
}
|
|
50
|
+
if (targetRunOffset >= targetRun.text.length) {
|
|
51
|
+
targetRunIndex++;
|
|
52
|
+
targetRunOffset = 0;
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const formatting = changedSupportedFormatting(baseRun, targetRun);
|
|
57
|
+
if (hasInlineFormatting(formatting)) {
|
|
58
|
+
const previous = segments.at(-1);
|
|
59
|
+
if (previous && previous.endOffset === textOffset && sameInlineFormatting(previous.formatting, formatting)) previous.endOffset += length;
|
|
60
|
+
else {
|
|
61
|
+
if (segments.length >= maxSegments) return null;
|
|
62
|
+
segments.push({
|
|
63
|
+
startOffset: textOffset,
|
|
64
|
+
endOffset: textOffset + length,
|
|
65
|
+
formatting
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
textOffset += length;
|
|
70
|
+
baseRunOffset += length;
|
|
71
|
+
targetRunOffset += length;
|
|
72
|
+
if (baseRunOffset >= baseRun.text.length) {
|
|
73
|
+
baseRunIndex++;
|
|
74
|
+
baseRunOffset = 0;
|
|
75
|
+
}
|
|
76
|
+
if (targetRunOffset >= targetRun.text.length) {
|
|
77
|
+
targetRunIndex++;
|
|
78
|
+
targetRunOffset = 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return segments;
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { inlineFormattingSegments };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FolioAIEditOperation, FolioAIEditSnapshot } from "../ai-edits/types.js";
|
|
2
|
+
import { FolioDocumentStoryHandle } from "../ai-edits/headless.js";
|
|
3
|
+
import { CompareChange } from "./types.js";
|
|
4
|
+
//#region src/compare/plan.d.ts
|
|
5
|
+
type CompareStoryPlan = {
|
|
6
|
+
changes: CompareChange[];
|
|
7
|
+
operations: FolioAIEditOperation[];
|
|
8
|
+
};
|
|
9
|
+
type PlanStoryCompareOptions = {
|
|
10
|
+
story: FolioDocumentStoryHandle;
|
|
11
|
+
baseSnapshot: FolioAIEditSnapshot;
|
|
12
|
+
targetSnapshot: FolioAIEditSnapshot;
|
|
13
|
+
/** Cap on generated operations; the caller turns `null` into its own error. */
|
|
14
|
+
maxOperations: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Plan one story's comparison, or `null` when it needs more operations than
|
|
18
|
+
* `maxOperations`.
|
|
19
|
+
*/
|
|
20
|
+
declare const planStoryCompare: ({ story, baseSnapshot, targetSnapshot, maxOperations }: PlanStoryCompareOptions) => CompareStoryPlan | null;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CompareStoryPlan, PlanStoryCompareOptions, planStoryCompare };
|