@stll/folio-core 0.33.0 → 0.33.2
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 +15 -0
- package/dist/ai-edits/apply.js +135 -24
- package/dist/ai-edits/headless.d.ts +47 -3
- package/dist/ai-edits/headless.js +53 -3
- package/dist/ai-edits/index.d.ts +1 -1
- package/dist/ai-edits/snapshot.d.ts +19 -1
- package/dist/ai-edits/snapshot.js +25 -3
- package/dist/ai-edits/table-geometry.d.ts +56 -0
- package/dist/ai-edits/table-geometry.js +217 -0
- package/dist/ai-edits/table-row-column-mutations.d.ts +34 -16
- package/dist/ai-edits/table-row-column-mutations.js +12 -4
- package/dist/ai-edits/table-template.d.ts +60 -0
- package/dist/ai-edits/table-template.js +176 -0
- package/dist/ai-edits/types.d.ts +7 -0
- package/dist/compare/__fixtures__/body-sequence.d.ts +86 -4
- package/dist/compare/__fixtures__/body-sequence.js +169 -12
- package/dist/compare/compare.d.ts +15 -8
- package/dist/compare/compare.js +138 -34
- package/dist/compare/plan.d.ts +31 -1
- package/dist/compare/plan.js +277 -28
- package/dist/compare/reproducible-package.d.ts +7 -3
- package/dist/compare/reproducible-package.js +20 -3
- package/dist/compare/types.d.ts +20 -3
- package/dist/compare/types.js +13 -1
- package/dist/compare/verification.d.ts +49 -2
- package/dist/compare/verification.js +115 -1
- package/dist/compat/eigenpal.d.ts +5 -5
- package/dist/compat/eigenpal.js +3 -3
- package/dist/document-operations.d.ts +10 -1
- package/dist/document-operations.js +3 -2
- package/dist/docx/appVersionNormalization.d.ts +49 -0
- package/dist/docx/appVersionNormalization.js +74 -0
- package/dist/docx/blockContentParser.js +3 -2
- package/dist/docx/drawingUtils.js +4 -3
- package/dist/docx/hyperlinkParser.d.ts +9 -1
- package/dist/docx/hyperlinkParser.js +19 -13
- package/dist/docx/paraIdRangeNormalization.d.ts +40 -0
- package/dist/docx/paraIdRangeNormalization.js +64 -0
- package/dist/docx/paragraphParser.js +82 -6
- package/dist/docx/revisionIdNormalization.d.ts +15 -1
- package/dist/docx/revisionIdNormalization.js +22 -4
- package/dist/docx/rezip.d.ts +13 -1
- package/dist/docx/rezip.js +80 -21
- package/dist/docx/runParser.js +9 -8
- package/dist/docx/sdtProperties.js +4 -3
- package/dist/docx/selectiveSave.js +7 -6
- package/dist/docx/serializer/commentSerializer.d.ts +1 -1
- package/dist/docx/serializer/commentSerializer.js +43 -19
- package/dist/docx/serializer/documentSerializer.d.ts +3 -1
- package/dist/docx/serializer/documentSerializer.js +42 -78
- package/dist/docx/serializer/fontTableSerializer.js +8 -5
- package/dist/docx/serializer/headerFooterSerializer.d.ts +4 -1
- package/dist/docx/serializer/headerFooterSerializer.js +34 -29
- package/dist/docx/serializer/noteSerializer.js +34 -30
- package/dist/docx/serializer/numberingSerializer.js +8 -4
- package/dist/docx/serializer/paragraphSerializer.js +45 -21
- package/dist/docx/serializer/partNamespaces.d.ts +78 -0
- package/dist/docx/serializer/partNamespaces.js +324 -0
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/settingsSerializer.js +8 -2
- package/dist/docx/serializer/stylesSerializer.js +8 -5
- package/dist/docx/serializer/tableSerializer.js +107 -27
- package/dist/docx/serializer/themeSerializer.js +10 -2
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/strictValueEncodings.gen.d.ts +15 -0
- package/dist/docx/strictValueEncodings.gen.js +275 -0
- package/dist/docx/tableParser.d.ts +0 -6
- package/dist/docx/tableParser.js +52 -7
- package/dist/docx/transitionalSpelling.d.ts +23 -0
- package/dist/docx/transitionalSpelling.js +36 -0
- package/dist/docx/universalMeasure.d.ts +20 -0
- package/dist/docx/universalMeasure.js +32 -0
- package/dist/docx/verbatimCapture.d.ts +20 -0
- package/dist/docx/verbatimCapture.js +131 -0
- package/dist/docx/vmlImageParser.js +4 -3
- package/dist/docx/watermarkParser.js +4 -3
- package/dist/docx/xmlParser.d.ts +23 -2
- package/dist/docx/xmlParser.js +43 -11
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/prosemirror/commands/comments.js +8 -2
- package/dist/prosemirror/containerFinalParagraph.d.ts +47 -0
- package/dist/prosemirror/containerFinalParagraph.js +92 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +8 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +15 -4
- package/dist/prosemirror/conversion/toProseDoc.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +5 -0
- package/dist/prosemirror/schema/marks.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +22 -0
- package/dist/server.d.ts +1 -1
- package/dist/types/block-id.d.ts +12 -1
- package/dist/types/block-id.js +17 -1
- package/dist/utils/canonicalJson.d.ts +14 -0
- package/dist/utils/canonicalJson.js +19 -0
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { TableAttrs, TableCellAttrs, TableRowAttrs } from "../schema/nodes.js";
|
|
2
3
|
import { Mark, Node } from "prosemirror-model";
|
|
3
4
|
//#region src/prosemirror/conversion/fromProseDoc.d.ts
|
|
4
5
|
/**
|
|
@@ -12,7 +13,13 @@ type MarksToTextFormattingOptions = {
|
|
|
12
13
|
inheritedFormatting: document_d_exports.TextFormatting | undefined;
|
|
13
14
|
};
|
|
14
15
|
declare function marksToTextFormatting(marks: readonly Mark[], options?: MarksToTextFormattingOptions): document_d_exports.TextFormatting;
|
|
16
|
+
declare function tableAttrsToFormatting(attrs: TableAttrs): document_d_exports.TableFormatting | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Convert ProseMirror table row attrs to TableRowFormatting
|
|
19
|
+
*/
|
|
20
|
+
declare function tableRowAttrsToFormatting(attrs: TableRowAttrs): document_d_exports.TableRowFormatting | undefined;
|
|
15
21
|
declare const standaloneTableCellFromProseMirror: (node: Node) => document_d_exports.TableCell;
|
|
22
|
+
declare function tableCellAttrsToFormatting(attrs: TableCellAttrs): document_d_exports.TableCellFormatting | undefined;
|
|
16
23
|
/**
|
|
17
24
|
* Update a Document with content from a ProseMirror document
|
|
18
25
|
* Preserves all non-content parts of the original document
|
|
@@ -27,4 +34,4 @@ declare function updateDocumentContent(originalDocument: document_d_exports.Docu
|
|
|
27
34
|
*/
|
|
28
35
|
declare function proseDocToBlocks(pmDoc: Node): document_d_exports.BlockContent[];
|
|
29
36
|
//#endregion
|
|
30
|
-
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, updateDocumentContent };
|
|
37
|
+
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { numPrEqual } from "../../docx/numberingParser.js";
|
|
2
2
|
import { ShapeOutlineStyleSchema, narrowEnum } from "../../docx/parserEnums.js";
|
|
3
3
|
import { OUTLINE_STYLE_CSS_ALIASES, normalizeShapeTextAnchor } from "../../types/documentEnumValues.js";
|
|
4
|
+
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
4
5
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
5
6
|
import { pixelsToEmu } from "../../utils/units.js";
|
|
6
7
|
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
@@ -1801,6 +1802,16 @@ function buildCellMarginsFromAttrs(m) {
|
|
|
1801
1802
|
/**
|
|
1802
1803
|
* Convert ProseMirror table attrs to TableFormatting
|
|
1803
1804
|
*/
|
|
1805
|
+
/**
|
|
1806
|
+
* Whether a live attr still holds what the style cascade resolved to.
|
|
1807
|
+
*
|
|
1808
|
+
* `toProseDoc` seeds an attr with the EFFECTIVE value — a border a table
|
|
1809
|
+
* style supplied, a margin a table declared — because that is what the editor
|
|
1810
|
+
* renders with. A save must write only what the node itself states, or the
|
|
1811
|
+
* inherited value becomes a direct override that outranks the style it came
|
|
1812
|
+
* from on reload. The resolved companion is what tells the two apart.
|
|
1813
|
+
*/
|
|
1814
|
+
const sameResolvedValue = (live, resolved) => resolved !== void 0 && resolved !== null && canonicalJson(live) === canonicalJson(resolved);
|
|
1804
1815
|
function tableAttrsToFormatting(attrs) {
|
|
1805
1816
|
if (attrs._originalFormatting) {
|
|
1806
1817
|
const orig = attrs._originalFormatting;
|
|
@@ -1824,7 +1835,7 @@ function tableAttrsToFormatting(attrs) {
|
|
|
1824
1835
|
type: tableWidthType ?? "dxa"
|
|
1825
1836
|
};
|
|
1826
1837
|
else delete result.width;
|
|
1827
|
-
if (attrs.cellMargins) result.cellMargins = buildCellMarginsFromAttrs(attrs.cellMargins);
|
|
1838
|
+
if (attrs.cellMargins && !sameResolvedValue(attrs.cellMargins, attrs._resolvedCellMargins)) result.cellMargins = buildCellMarginsFromAttrs(attrs.cellMargins);
|
|
1828
1839
|
return result;
|
|
1829
1840
|
}
|
|
1830
1841
|
const tableWidth = attrs.width;
|
|
@@ -2022,8 +2033,8 @@ function tableCellAttrsToFormatting(attrs) {
|
|
|
2022
2033
|
if (attrs.verticalAlign !== (orig.verticalAlign ?? void 0)) if (attrs.verticalAlign) result.verticalAlign = attrs.verticalAlign;
|
|
2023
2034
|
else delete result.verticalAlign;
|
|
2024
2035
|
if (backgroundChanged) result.shading = cellShadingFromAttrs(attrs);
|
|
2025
|
-
if (attrs.borders) result.borders = attrs.borders;
|
|
2026
|
-
if (attrs.margins) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
2036
|
+
if (attrs.borders && !sameResolvedValue(attrs.borders, attrs._resolvedBorders)) result.borders = attrs.borders;
|
|
2037
|
+
if (attrs.margins && !sameResolvedValue(attrs.margins, attrs._resolvedMargins)) result.margins = buildCellMarginsFromAttrs(attrs.margins);
|
|
2027
2038
|
if (attrs.textDirection !== (orig.textDirection ?? void 0)) if (attrs.textDirection) result.textDirection = attrs.textDirection;
|
|
2028
2039
|
else delete result.textDirection;
|
|
2029
2040
|
return result;
|
|
@@ -2154,4 +2165,4 @@ function proseDocToBlocks(pmDoc) {
|
|
|
2154
2165
|
return extractBlocks(pmDoc);
|
|
2155
2166
|
}
|
|
2156
2167
|
//#endregion
|
|
2157
|
-
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, updateDocumentContent };
|
|
2168
|
+
export { fromProseDoc, marksToTextFormatting, proseDocToBlocks, standaloneTableCellFromProseMirror, tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting, updateDocumentContent };
|
|
@@ -850,7 +850,10 @@ function convertTable(table, styleResolver, context) {
|
|
|
850
850
|
if (table.formatting?.justification) attrs.justification = table.formatting.justification;
|
|
851
851
|
if (columnWidths) attrs.columnWidths = columnWidths;
|
|
852
852
|
if (table.formatting?.floating) attrs.floating = table.formatting.floating;
|
|
853
|
-
if (cellMarginsAttr)
|
|
853
|
+
if (cellMarginsAttr) {
|
|
854
|
+
attrs.cellMargins = cellMarginsAttr;
|
|
855
|
+
attrs._resolvedCellMargins = cellMarginsAttr;
|
|
856
|
+
}
|
|
854
857
|
if (table.formatting?.look) attrs.look = table.formatting.look;
|
|
855
858
|
if (table.formatting?.borders) attrs.borders = table.formatting.borders;
|
|
856
859
|
if (resolvedTableIndent) attrs._resolvedIndent = resolvedTableIndent;
|
|
@@ -1059,8 +1062,14 @@ function convertTableCell({ cell, styleResolver, context, isHeader, gridWidthPer
|
|
|
1059
1062
|
if (formatting?.noWrap !== void 0) attrs.noWrap = formatting.noWrap;
|
|
1060
1063
|
const hideMark = formatting?.hideMark ?? conditionalStyle?.tcPr?.hideMark;
|
|
1061
1064
|
if (hideMark !== void 0) attrs.hideMark = hideMark;
|
|
1062
|
-
if (effectiveFormatting.borders)
|
|
1063
|
-
|
|
1065
|
+
if (effectiveFormatting.borders) {
|
|
1066
|
+
attrs.borders = effectiveFormatting.borders;
|
|
1067
|
+
attrs._resolvedBorders = effectiveFormatting.borders;
|
|
1068
|
+
}
|
|
1069
|
+
if (effectiveFormatting.margins) {
|
|
1070
|
+
attrs.margins = effectiveFormatting.margins;
|
|
1071
|
+
attrs._resolvedMargins = effectiveFormatting.margins;
|
|
1072
|
+
}
|
|
1064
1073
|
if (formatting) attrs._originalFormatting = formatting;
|
|
1065
1074
|
if (cell.propertyChanges && cell.propertyChanges.length > 0) attrs.tcPrChange = [...cell.propertyChanges];
|
|
1066
1075
|
if (cell.structuralChange?.type === "tableCellInsertion") attrs.cellMarker = {
|
|
@@ -151,6 +151,7 @@ const tableSpec = {
|
|
|
151
151
|
columnWidths: { default: null },
|
|
152
152
|
floating: { default: null },
|
|
153
153
|
cellMargins: { default: null },
|
|
154
|
+
_resolvedCellMargins: { default: null },
|
|
154
155
|
look: { default: null },
|
|
155
156
|
borders: { default: null },
|
|
156
157
|
_resolvedIndent: { default: null },
|
|
@@ -319,7 +320,9 @@ const tableCellSpec = {
|
|
|
319
320
|
backgroundColor: { default: null },
|
|
320
321
|
_resolvedBackgroundColor: { default: null },
|
|
321
322
|
borders: { default: null },
|
|
323
|
+
_resolvedBorders: { default: null },
|
|
322
324
|
margins: { default: null },
|
|
325
|
+
_resolvedMargins: { default: null },
|
|
323
326
|
textDirection: { default: null },
|
|
324
327
|
noWrap: { default: false },
|
|
325
328
|
hideMark: { default: false },
|
|
@@ -375,7 +378,9 @@ const tableHeaderSpec = {
|
|
|
375
378
|
backgroundColor: { default: null },
|
|
376
379
|
_resolvedBackgroundColor: { default: null },
|
|
377
380
|
borders: { default: null },
|
|
381
|
+
_resolvedBorders: { default: null },
|
|
378
382
|
margins: { default: null },
|
|
383
|
+
_resolvedMargins: { default: null },
|
|
379
384
|
textDirection: { default: null },
|
|
380
385
|
noWrap: { default: false },
|
|
381
386
|
hideMark: { default: false },
|
|
@@ -569,6 +569,13 @@ type TableAttrs = {
|
|
|
569
569
|
look?: document_d_exports.TableLook;
|
|
570
570
|
/** Table-level borders (w:tblBorders) — full BorderSpec per side */
|
|
571
571
|
borders?: document_d_exports.TableBorders;
|
|
572
|
+
/**
|
|
573
|
+
* Effective default cell margins after the table-style cascade. PM-only;
|
|
574
|
+
* never serialized. What `cellMargins` resolves to when the table declares
|
|
575
|
+
* none of its own, so a save can tell a value a style supplied from one the
|
|
576
|
+
* table states — and stop writing the style's into the table's `w:tblPr`.
|
|
577
|
+
*/
|
|
578
|
+
_resolvedCellMargins?: TableAttrs["cellMargins"];
|
|
572
579
|
/** Effective table indent after style resolution. PM-only; never serialized. */
|
|
573
580
|
_resolvedIndent?: NonNullable<document_d_exports.TableFormatting["indent"]>;
|
|
574
581
|
/** Style-derived table justification fallback. PM-only; never serialized. */
|
|
@@ -677,6 +684,14 @@ type TableCellAttrs = {
|
|
|
677
684
|
hideMark?: boolean;
|
|
678
685
|
/** Cell borders — full BorderSpec per side (style, color, size) */
|
|
679
686
|
borders?: document_d_exports.TableCellBorders;
|
|
687
|
+
/**
|
|
688
|
+
* Effective borders after the table and table-style cascade. PM-only; never
|
|
689
|
+
* serialized. The companion to `borders` that `_resolvedBackgroundColor` is
|
|
690
|
+
* to `backgroundColor`: what the cell renders with when it declares none of
|
|
691
|
+
* its own, so a save can tell a border a style supplied from one the cell
|
|
692
|
+
* states.
|
|
693
|
+
*/
|
|
694
|
+
_resolvedBorders?: document_d_exports.TableCellBorders;
|
|
680
695
|
/** Cell margins/padding in twips per side */
|
|
681
696
|
margins?: {
|
|
682
697
|
top?: number;
|
|
@@ -684,6 +699,13 @@ type TableCellAttrs = {
|
|
|
684
699
|
left?: number;
|
|
685
700
|
right?: number;
|
|
686
701
|
};
|
|
702
|
+
/** Effective margins after the cascade. PM-only; never serialized. */
|
|
703
|
+
_resolvedMargins?: {
|
|
704
|
+
top?: number;
|
|
705
|
+
bottom?: number;
|
|
706
|
+
left?: number;
|
|
707
|
+
right?: number;
|
|
708
|
+
};
|
|
687
709
|
/** Original cell formatting from DOCX for lossless round-trip serialization */
|
|
688
710
|
_originalFormatting?: document_d_exports.TableCellFormatting;
|
|
689
711
|
/** Tracked cell property changes (w:tcPrChange) for round-trip + accept/reject */
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineFormatting, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./ai-edits/types.js";
|
|
2
2
|
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationBatchPrecondition, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationQueuedOperation, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "./document-operations.js";
|
|
3
3
|
import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
|
|
4
|
-
import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, FolioReviewedStory, FolioReviewedView, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, isFolioResolvedReviewedView, isFolioReviewedView } from "./ai-edits/headless.js";
|
|
5
4
|
import { createFolioAITextRangeHandle, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./ai-edits/snapshot.js";
|
|
5
|
+
import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsOptions, FolioApplyDocumentOperationsToStoryOptions, FolioApplyOperationsOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioDocxReviewer, FolioDocxReviewerOptions, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewChangeFilter, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, FolioReviewedStory, FolioReviewedView, UnsupportedFolioReviewedViewError, applyFolioAIEditsToBuffer, isFolioResolvedReviewedView, isFolioReviewedView } from "./ai-edits/headless.js";
|
|
6
6
|
import { getFolioDocumentOutline, readFolioDocumentSection } from "./ai-edits/scoped-reading.js";
|
|
7
7
|
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
8
8
|
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocumentPreset, DocumentStyleSet } from "./style-sets/types.js";
|
package/dist/types/block-id.d.ts
CHANGED
|
@@ -61,6 +61,17 @@ declare const isBlankFolioBlockId: (id: string) => boolean;
|
|
|
61
61
|
* without an upfront brand check.
|
|
62
62
|
*/
|
|
63
63
|
declare const getFolioParaIdFromBlockId: (id: string) => string | null;
|
|
64
|
+
/**
|
|
65
|
+
* The id a block recorded earlier answers to in the document as parsed now.
|
|
66
|
+
*
|
|
67
|
+
* A paragraph id above the 31-bit bound the schema sets is brought into range
|
|
68
|
+
* on parse, so an id recorded from such a paragraph before that no longer
|
|
69
|
+
* names it. The mapping is a pure function of the id alone, so the recorded id
|
|
70
|
+
* resolves to the current one with no document in hand. Sequential and blank
|
|
71
|
+
* ids carry no paragraph id, and an id the parser would not have mapped is
|
|
72
|
+
* returned as it is.
|
|
73
|
+
*/
|
|
74
|
+
declare const currentFolioBlockId: (id: string) => string;
|
|
64
75
|
/**
|
|
65
76
|
* The 1-based document position encoded in a sequential fallback id
|
|
66
77
|
* (`seq-0011` -> 11), or `null` for paraId-backed ids. The number is
|
|
@@ -76,4 +87,4 @@ declare const getSequentialFolioBlockIdIndex: (id: string) => number | null;
|
|
|
76
87
|
*/
|
|
77
88
|
declare const isFolioBlockId: (value: unknown) => value is FolioBlockId;
|
|
78
89
|
//#endregion
|
|
79
|
-
export { DeriveBlockIdInput, FolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId };
|
|
90
|
+
export { DeriveBlockIdInput, FolioBlockId, currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId };
|
package/dist/types/block-id.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { paraIdInRange } from "../docx/paraIdRangeNormalization.js";
|
|
2
|
+
import { isValidHexId } from "../utils/hexId.js";
|
|
1
3
|
//#region src/types/block-id.ts
|
|
2
4
|
/**
|
|
3
5
|
* Single source of truth for folio block ids.
|
|
@@ -91,6 +93,20 @@ const isBlankFolioBlockId = (id) => BLANK_BLOCK_ID_PATTERN.test(id);
|
|
|
91
93
|
*/
|
|
92
94
|
const getFolioParaIdFromBlockId = (id) => isSequentialFolioBlockId(id) || isBlankFolioBlockId(id) ? null : id;
|
|
93
95
|
/**
|
|
96
|
+
* The id a block recorded earlier answers to in the document as parsed now.
|
|
97
|
+
*
|
|
98
|
+
* A paragraph id above the 31-bit bound the schema sets is brought into range
|
|
99
|
+
* on parse, so an id recorded from such a paragraph before that no longer
|
|
100
|
+
* names it. The mapping is a pure function of the id alone, so the recorded id
|
|
101
|
+
* resolves to the current one with no document in hand. Sequential and blank
|
|
102
|
+
* ids carry no paragraph id, and an id the parser would not have mapped is
|
|
103
|
+
* returned as it is.
|
|
104
|
+
*/
|
|
105
|
+
const currentFolioBlockId = (id) => {
|
|
106
|
+
const paraId = getFolioParaIdFromBlockId(id);
|
|
107
|
+
return paraId !== null && isValidHexId(paraId) ? paraIdInRange(paraId) : id;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
94
110
|
* The 1-based document position encoded in a sequential fallback id
|
|
95
111
|
* (`seq-0011` -> 11), or `null` for paraId-backed ids. The number is
|
|
96
112
|
* the block's position in the same non-empty-block walk both the
|
|
@@ -114,4 +130,4 @@ const isFolioBlockId = (value) => {
|
|
|
114
130
|
return true;
|
|
115
131
|
};
|
|
116
132
|
//#endregion
|
|
117
|
-
export { deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId };
|
|
133
|
+
export { currentFolioBlockId, deriveBlankBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isBlankFolioBlockId, isFolioBlockId, isSequentialFolioBlockId };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/utils/canonicalJson.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* JSON with object keys in a fixed order, for comparing two values that were
|
|
4
|
+
* built by different code paths.
|
|
5
|
+
*
|
|
6
|
+
* `JSON.stringify` writes keys in insertion order, so two objects holding the
|
|
7
|
+
* same properties compare unequal whenever one was assembled in a different
|
|
8
|
+
* sequence — which is what happens whenever a parsed record is compared with a
|
|
9
|
+
* rebuilt one. `undefined` members are omitted, so an absent property and one
|
|
10
|
+
* explicitly set to `undefined` read alike.
|
|
11
|
+
*/
|
|
12
|
+
declare const canonicalJson: (value: unknown) => string;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { canonicalJson };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/utils/canonicalJson.ts
|
|
2
|
+
/**
|
|
3
|
+
* JSON with object keys in a fixed order, for comparing two values that were
|
|
4
|
+
* built by different code paths.
|
|
5
|
+
*
|
|
6
|
+
* `JSON.stringify` writes keys in insertion order, so two objects holding the
|
|
7
|
+
* same properties compare unequal whenever one was assembled in a different
|
|
8
|
+
* sequence — which is what happens whenever a parsed record is compared with a
|
|
9
|
+
* rebuilt one. `undefined` members are omitted, so an absent property and one
|
|
10
|
+
* explicitly set to `undefined` read alike.
|
|
11
|
+
*/
|
|
12
|
+
const canonicalJson = (value) => {
|
|
13
|
+
if (value === null || value === void 0) return "null";
|
|
14
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
15
|
+
if (typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
16
|
+
return `{${Object.entries(value).filter(([, entry]) => entry !== void 0).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(",")}}`;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { canonicalJson };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { document_d_exports } from "../types/document.js";
|
|
2
1
|
import { ColorValue } from "../types/colors.js";
|
|
2
|
+
import { document_d_exports } from "../types/document.js";
|
|
3
3
|
import { Properties } from "csstype";
|
|
4
4
|
//#region src/utils/formatToStyle.d.ts
|
|
5
5
|
type CSSProperties = Properties<string | number>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"perf": "bun scripts/profile-editor.ts"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@stll/docx-core": "^0.19.
|
|
118
|
+
"@stll/docx-core": "^0.19.1",
|
|
119
119
|
"@stll/docx-utils": "^0.1.0",
|
|
120
120
|
"@stll/template-conditions": "^0.1.0",
|
|
121
121
|
"better-result": "3.0.1",
|