@stll/folio-core 0.37.5 → 0.39.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.js +275 -88
- package/dist/ai-edits/clean-text.js +12 -1
- package/dist/ai-edits/headless.d.ts +110 -0
- package/dist/ai-edits/headless.js +569 -40
- package/dist/ai-edits/snapshot.d.ts +24 -1
- package/dist/ai-edits/snapshot.js +206 -9
- package/dist/ai-edits/table-geometry.d.ts +7 -7
- package/dist/ai-edits/table-geometry.js +43 -27
- package/dist/ai-edits/table-template.d.ts +2 -1
- package/dist/ai-edits/table-template.js +9 -3
- package/dist/ai-edits/types.d.ts +37 -15
- package/dist/compare/__fixtures__/body-sequence.d.ts +4 -0
- package/dist/compare/__fixtures__/body-sequence.js +5 -3
- package/dist/compare/compare.d.ts +26 -2
- package/dist/compare/compare.js +444 -16
- package/dist/compare/content-alignment.js +3 -2
- package/dist/compare/content-types.d.ts +34 -2
- package/dist/compare/content.d.ts +13 -10
- package/dist/compare/content.js +69 -23
- package/dist/compare/formatting.d.ts +4 -22
- package/dist/compare/formatting.js +8 -112
- package/dist/compare/inline-atom-resources.d.ts +6 -0
- package/dist/compare/inline-atom-resources.js +26 -0
- package/dist/compare/inline-atoms.d.ts +35 -0
- package/dist/compare/inline-atoms.js +383 -0
- package/dist/compare/inline-provenance.d.ts +36 -0
- package/dist/compare/inline-provenance.js +334 -0
- package/dist/compare/plan.d.ts +4 -1
- package/dist/compare/plan.js +32 -4
- package/dist/compare/scenario.d.ts +4 -6
- package/dist/compare/section-boundary-properties.d.ts +63 -0
- package/dist/compare/section-boundary-properties.js +235 -0
- package/dist/compare/style-resources.d.ts +30 -0
- package/dist/compare/style-resources.js +404 -0
- package/dist/compare/types.d.ts +50 -11
- package/dist/compare/types.js +3 -1
- package/dist/compare/verification.d.ts +3 -5
- package/dist/compare/verification.js +8 -39
- package/dist/compat/eigenpal.d.ts +4 -4
- package/dist/compat/eigenpal.js +3 -3
- package/dist/controller/layoutPipeline.js +4 -0
- package/dist/display-list/build/buildContext.d.ts +3 -1
- package/dist/display-list/build/buildDisplayList.d.ts +4 -1
- package/dist/display-list/build/buildDisplayList.js +38 -4
- package/dist/display-list/build/commentAnnotations.d.ts +10 -0
- package/dist/display-list/build/commentAnnotations.js +17 -0
- package/dist/display-list/build/paragraphPrimitives.js +39 -1
- package/dist/display-list/primitives.d.ts +1 -1
- package/dist/display-list/types.d.ts +16 -1
- package/dist/document-operations.d.ts +5 -3
- package/dist/document-operations.js +112 -5
- package/dist/docx/blockContentParser.js +14 -2
- package/dist/docx/diagramPreview.d.ts +7 -0
- package/dist/docx/diagramPreview.js +191 -0
- package/dist/docx/drawingIdNormalization.js +43 -2
- package/dist/docx/drawingRelationships.d.ts +10 -0
- package/dist/docx/drawingRelationships.js +28 -0
- package/dist/docx/fieldParser.js +1 -1
- package/dist/docx/hyperlinkParser.js +3 -5
- package/dist/docx/imageRawXml.d.ts +8 -0
- package/dist/docx/imageRawXml.js +13 -0
- package/dist/docx/newImage.d.ts +2 -2
- package/dist/docx/newImage.js +3 -3
- package/dist/docx/numberingParser.js +30 -27
- package/dist/docx/paragraphParser.js +11 -4
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/parser.js +13 -0
- package/dist/docx/removeHeaderFooterParts.d.ts +14 -0
- package/dist/docx/removeHeaderFooterParts.js +87 -0
- package/dist/docx/rezip.d.ts +3 -1
- package/dist/docx/rezip.js +143 -41
- package/dist/docx/runParser.js +24 -5
- package/dist/docx/sectionParser.js +3 -0
- package/dist/docx/sectionReferenceHistory.d.ts +17 -0
- package/dist/docx/sectionReferenceHistory.js +59 -0
- package/dist/docx/selectiveSave.js +11 -31
- package/dist/docx/selectiveXmlPatch.d.ts +8 -1
- package/dist/docx/selectiveXmlPatch.js +62 -2
- package/dist/docx/serializer/paragraphSerializer.js +2 -0
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +4 -0
- package/dist/docx/serializer/runSerializer.js +5 -2
- package/dist/docx/serializer/sectionPropertiesSerializer.js +5 -2
- package/dist/docx/serializer/textFormattingSerializer.d.ts +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +3 -1
- package/dist/docx/tableParser.js +21 -11
- package/dist/docx/textBoxParser.js +25 -5
- package/dist/docx/xmlParser.d.ts +10 -1
- package/dist/docx/xmlParser.js +23 -1
- package/dist/export-pdf.js +2 -0
- package/dist/headless-layout.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/internal/compare/inline-presentation.d.ts +20 -0
- package/dist/internal/compare/inline-presentation.js +222 -0
- package/dist/internal/paragraphFormattingSerialization.d.ts +3 -1
- package/dist/internal/paragraphFormattingSerialization.js +8 -1
- package/dist/internal/sectionReferenceResolution.d.ts +21 -0
- package/dist/internal/sectionReferenceResolution.js +72 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +1 -0
- package/dist/layout-engine/index.js +5 -5
- package/dist/layout-engine/sectionVerticalAlignment.d.ts +7 -0
- package/dist/layout-engine/sectionVerticalAlignment.js +52 -0
- package/dist/layout-engine/types.d.ts +3 -1
- package/dist/markdown/renderRuns.js +1 -0
- package/dist/markdown/renderTable.js +1 -0
- package/dist/pdf/writePdf.js +37 -2
- package/dist/prosemirror/attrs/index.js +55 -1
- package/dist/prosemirror/commands/comments.d.ts +11 -1
- package/dist/prosemirror/commands/comments.js +68 -6
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +9 -3
- package/dist/prosemirror/commands/propertyChangeScope.js +4 -10
- package/dist/prosemirror/conversion/fromProseDoc.js +17 -8
- package/dist/prosemirror/conversion/toProseDoc.js +18 -57
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +3 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +2 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +39 -1
- package/dist/prosemirror/imageCommit.js +7 -9
- package/dist/prosemirror/paragraphIndentation.d.ts +21 -0
- package/dist/prosemirror/paragraphIndentation.js +72 -0
- package/dist/prosemirror/plugins/documentNumbering.d.ts +3 -1
- package/dist/prosemirror/plugins/documentNumbering.js +7 -1
- package/dist/prosemirror/plugins/documentStyles.d.ts +3 -1
- package/dist/prosemirror/plugins/documentStyles.js +7 -1
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +3 -1
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +2 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +15 -2
- package/dist/prosemirror/runFormattingInlineCarriers.js +33 -3
- package/dist/prosemirror/runStyleFormatting.d.ts +15 -2
- package/dist/prosemirror/runStyleFormatting.js +76 -2
- package/dist/prosemirror/schema/marks.d.ts +3 -1
- package/dist/prosemirror/schema/marks.js +2 -0
- package/dist/prosemirror/schema/nodes.d.ts +5 -0
- package/dist/prosemirror/tableCellRevisionVisibility.d.ts +6 -0
- package/dist/prosemirror/tableCellRevisionVisibility.js +14 -0
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -1
- package/dist/prosemirror/trackedRunInlineAtoms.js +1 -1
- package/dist/redline.js +15 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/version-comparison.d.ts +2 -0
- package/dist/version-comparison.js +7 -2
- package/package.json +2 -2
|
@@ -53,10 +53,14 @@ type TableProperties = {
|
|
|
53
53
|
value: number;
|
|
54
54
|
type: "auto" | "dxa" | "pct";
|
|
55
55
|
};
|
|
56
|
+
/** `w:bidiVisual`. */
|
|
57
|
+
bidi?: boolean;
|
|
56
58
|
/** `w:jc` on the table. */
|
|
57
59
|
justification?: "left" | "center" | "right";
|
|
58
60
|
/** `w:tblInd` in twips. */
|
|
59
61
|
indent?: number;
|
|
62
|
+
/** `w:tblCellSpacing` in twips. */
|
|
63
|
+
cellSpacing?: number;
|
|
60
64
|
/** `w:tblBorders`, single style on every side, in eighths of a point. */
|
|
61
65
|
borderSize?: number;
|
|
62
66
|
/** `w:shd` fill colour on the table, as six hex digits. */
|
|
@@ -132,9 +132,9 @@ const MARGIN_SIDES = [
|
|
|
132
132
|
const borders = (element, sides, size) => `<w:${element}>${sides.map((side) => `<w:${side} w:val="single" w:sz="${String(size)}" w:space="0" w:color="000000"/>`).join("")}</w:${element}>`;
|
|
133
133
|
const margins = (element, value) => `<w:${element}>${MARGIN_SIDES.map((side) => `<w:${side} w:w="${String(value)}" w:type="dxa"/>`).join("")}</w:${element}>`;
|
|
134
134
|
/**
|
|
135
|
-
* `w:tblPr` children in the order CT_TblPrBase declares: tblStyle,
|
|
136
|
-
* tblInd, tblBorders, shd, tblLayout, tblCellMar,
|
|
137
|
-
* written.
|
|
135
|
+
* `w:tblPr` children in the order CT_TblPrBase declares: tblStyle, bidiVisual,
|
|
136
|
+
* tblW, jc, tblCellSpacing, tblInd, tblBorders, shd, tblLayout, tblCellMar,
|
|
137
|
+
* tblLook. `w:tblW` is always written.
|
|
138
138
|
*/
|
|
139
139
|
const tableProperties = ({ properties }) => {
|
|
140
140
|
const width = properties?.width ?? {
|
|
@@ -143,8 +143,10 @@ const tableProperties = ({ properties }) => {
|
|
|
143
143
|
};
|
|
144
144
|
return `<w:tblPr>${[
|
|
145
145
|
...properties?.styleId === void 0 ? [] : [`<w:tblStyle w:val="${properties.styleId}"/>`],
|
|
146
|
+
...properties?.bidi === void 0 ? [] : [properties.bidi ? "<w:bidiVisual/>" : "<w:bidiVisual w:val=\"0\"/>"],
|
|
146
147
|
`<w:tblW w:w="${String(width.value)}" w:type="${width.type}"/>`,
|
|
147
148
|
...properties?.justification === void 0 ? [] : [`<w:jc w:val="${properties.justification}"/>`],
|
|
149
|
+
...properties?.cellSpacing === void 0 ? [] : [`<w:tblCellSpacing w:w="${String(properties.cellSpacing)}" w:type="dxa"/>`],
|
|
148
150
|
...properties?.indent === void 0 ? [] : [`<w:tblInd w:w="${String(properties.indent)}" w:type="dxa"/>`],
|
|
149
151
|
...properties?.borderSize === void 0 ? [] : [borders("tblBorders", BORDER_SIDES, properties.borderSize)],
|
|
150
152
|
...properties?.shadingFill === void 0 ? [] : [`<w:shd w:val="clear" w:color="auto" w:fill="${properties.shadingFill}"/>`],
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
1
2
|
import { FolioAIEditSkipReason, FolioAIEditSnapshot } from "../ai-edits/types.js";
|
|
2
3
|
import { WordDiffGranularity } from "../ai-edits/word-diff.js";
|
|
3
4
|
import { FolioRevisionStamp } from "../ai-edits/apply.js";
|
|
4
5
|
import { FolioDocumentStoryHandle, FolioDocxReviewer } from "../ai-edits/headless.js";
|
|
5
6
|
import { CompareVerification } from "./verification.js";
|
|
6
|
-
import { CompareChange, CompareDocxApplyError, CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxOptions, CompareDocxParseError, CompareDocxSerializeError, CompareResult, CompareUnsupportedPart, InvalidCompareDocxOptionsError } from "./types.js";
|
|
7
|
+
import { CompareChange, CompareCompatibility, CompareDocxApplyError, CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, CompareDocxOptions, CompareDocxParseError, CompareDocxSerializeError, CompareResult, CompareUnsupportedPart, InvalidCompareDocxOptionsError } from "./types.js";
|
|
7
8
|
import { CompareStoryPlan } from "./plan.js";
|
|
8
9
|
import { Result } from "better-result";
|
|
9
10
|
//#region src/compare/compare.d.ts
|
|
@@ -17,12 +18,26 @@ type ComparedStoryPair = {
|
|
|
17
18
|
baseStory: FolioDocumentStoryHandle;
|
|
18
19
|
targetStory: FolioDocumentStoryHandle;
|
|
19
20
|
baseSnapshot: FolioAIEditSnapshot;
|
|
21
|
+
/** Raw base expectation when Folio-exact staging added an untracked carrier. */
|
|
22
|
+
rawBaseSnapshot?: FolioAIEditSnapshot;
|
|
20
23
|
targetSnapshot: FolioAIEditSnapshot;
|
|
21
24
|
};
|
|
25
|
+
type FinalSectionComparison = {
|
|
26
|
+
status: "same";
|
|
27
|
+
} | {
|
|
28
|
+
status: "stage";
|
|
29
|
+
previous: document_d_exports.SectionProperties;
|
|
30
|
+
target: document_d_exports.SectionProperties;
|
|
31
|
+
} | {
|
|
32
|
+
status: "unsupported";
|
|
33
|
+
detail: string;
|
|
34
|
+
};
|
|
22
35
|
/** Everything the later stages need, and nothing they have to re-derive. */
|
|
23
36
|
type ParsedComparison = {
|
|
24
37
|
/** Token size a changed paragraph's redline is cut at. */
|
|
25
38
|
granularity: WordDiffGranularity;
|
|
39
|
+
revisionFormat: "word" | "folio-exact";
|
|
40
|
+
terminalTableCarrierStaged: boolean;
|
|
26
41
|
/**
|
|
27
42
|
* The base package as it arrived. It is the result when nothing changed, but
|
|
28
43
|
* only when it carried no revisions of its own: otherwise the compared base
|
|
@@ -36,6 +51,14 @@ type ParsedComparison = {
|
|
|
36
51
|
pairs: readonly ComparedStoryPair[];
|
|
37
52
|
/** Package-level numbering differences, which belong to no story. */
|
|
38
53
|
numberingChanges: readonly CompareChange[];
|
|
54
|
+
targetNumbering: document_d_exports.NumberingDefinitions | null | undefined;
|
|
55
|
+
targetNumberingReferences: readonly {
|
|
56
|
+
numId: number;
|
|
57
|
+
level: number;
|
|
58
|
+
}[];
|
|
59
|
+
targetNumberingReferenceMap: ReadonlyMap<number, number>;
|
|
60
|
+
finalSectionComparison: FinalSectionComparison;
|
|
61
|
+
styleImportFailure: string | undefined;
|
|
39
62
|
unsupported: readonly CompareUnsupportedPart[];
|
|
40
63
|
};
|
|
41
64
|
/** Stage 1: both packages to editor models, paired story by story. */
|
|
@@ -53,6 +76,7 @@ declare const planComparison: ({ pairs }: ParsedComparison) => Result<readonly P
|
|
|
53
76
|
declare const getCompareSkipDisposition: (reason: FolioAIEditSkipReason) => "fatal" | "unwritable";
|
|
54
77
|
/** What stage 3 produced: the change list, whether it was proven, and whether it wrote anything. */
|
|
55
78
|
type AppliedComparison = {
|
|
79
|
+
compatibility: CompareCompatibility;
|
|
56
80
|
changes: readonly CompareChange[];
|
|
57
81
|
verification: CompareVerification;
|
|
58
82
|
/**
|
|
@@ -76,7 +100,7 @@ type AppliedComparison = {
|
|
|
76
100
|
* what you could not represent" and "give me nothing unless you can prove it"
|
|
77
101
|
* are both legitimate asks and only the caller knows which one it is making.
|
|
78
102
|
*/
|
|
79
|
-
declare const applyComparison: ({ reviewer, revisionStamp, granularity, numberingChanges }: ParsedComparison, planned: readonly PlannedStoryComparison[]) => Result<AppliedComparison, CompareDocxApplyError>;
|
|
103
|
+
declare const applyComparison: ({ reviewer, revisionStamp, granularity, revisionFormat, terminalTableCarrierStaged, numberingChanges, targetNumbering, targetNumberingReferences, targetNumberingReferenceMap, finalSectionComparison, styleImportFailure, pairs }: ParsedComparison, planned: readonly PlannedStoryComparison[]) => Result<AppliedComparison, CompareDocxApplyError | CompareDocxOperationLimitError>;
|
|
80
104
|
/**
|
|
81
105
|
* Stage 4: the result package, with every ZIP entry date pinned.
|
|
82
106
|
*
|