@stll/folio-core 0.37.4 → 0.37.5

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.
@@ -0,0 +1,142 @@
1
+ import { HIGHLIGHT_COLOR_VALUES } from "../../types/documentEnumValues.js";
2
+ import { isValidHexColor } from "../../utils/colorResolver.js";
3
+ import { roundHorizontalScalePercentForSerialization } from "../../utils/horizontalScale.js";
4
+ import { escapeXml, intAttr } from "./xmlUtils.js";
5
+ //#region src/docx/serializer/textFormattingSerializer.ts
6
+ const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
7
+ /**
8
+ * Serialize a color element (w:color)
9
+ */
10
+ function serializeColorElement(color) {
11
+ if (!color) return "";
12
+ const { auto, rgb, themeColor, themeTint, themeShade } = color;
13
+ const attrs = [];
14
+ if (auto) attrs.push("w:val=\"auto\"");
15
+ else if (rgb && isValidHexColor(rgb)) attrs.push(`w:val="${escapeXml(rgb)}"`);
16
+ if (themeColor) attrs.push(`w:themeColor="${escapeXml(themeColor)}"`);
17
+ if (themeTint) attrs.push(`w:themeTint="${escapeXml(themeTint)}"`);
18
+ if (themeShade) attrs.push(`w:themeShade="${escapeXml(themeShade)}"`);
19
+ return attrs.length === 0 ? "" : `<w:color ${attrs.join(" ")}/>`;
20
+ }
21
+ /**
22
+ * Serialize shading properties (w:shd)
23
+ */
24
+ function serializeShading(shading) {
25
+ if (!shading) return "";
26
+ const { pattern, color, fill } = shading;
27
+ const attrs = [];
28
+ if (pattern) attrs.push(`w:val="${escapeXml(pattern)}"`);
29
+ else attrs.push("w:val=\"clear\"");
30
+ if (color) {
31
+ const { rgb, auto, themeColor: _themeColor, themeTint: _themeTint, themeShade: _themeShade } = color;
32
+ if (rgb && isValidHexColor(rgb)) attrs.push(`w:color="${escapeXml(rgb)}"`);
33
+ else if (auto) attrs.push("w:color=\"auto\"");
34
+ }
35
+ if (fill) {
36
+ const { rgb, auto, themeColor, themeTint, themeShade } = fill;
37
+ if (rgb && isValidHexColor(rgb)) attrs.push(`w:fill="${escapeXml(rgb)}"`);
38
+ else if (auto) attrs.push("w:fill=\"auto\"");
39
+ if (themeColor) attrs.push(`w:themeFill="${escapeXml(themeColor)}"`);
40
+ if (themeTint) attrs.push(`w:themeFillTint="${escapeXml(themeTint)}"`);
41
+ if (themeShade) attrs.push(`w:themeFillShade="${escapeXml(themeShade)}"`);
42
+ }
43
+ return attrs.length === 0 ? "" : `<w:shd ${attrs.join(" ")}/>`;
44
+ }
45
+ /**
46
+ * Serialize text formatting properties to w:rPr XML
47
+ */
48
+ function serializeTextFormatting(input) {
49
+ if (!input) return "";
50
+ const { bold, boldCs, italic, italicCs, underline, strike, doubleStrike, vertAlign, smallCaps, allCaps, hidden, color, highlight, shading, fontSize, fontSizeCs, fontFamily, language, spacing, position, scale, kerning, effect, emphasisMark, emboss, imprint, outline, shadow, rtl, cs, styleId } = input;
51
+ const parts = [];
52
+ if (styleId) parts.push(`<w:rStyle w:val="${escapeXml(styleId)}"/>`);
53
+ if (fontFamily) {
54
+ const { ascii, hAnsi, eastAsia, cs: complexScript, hint, asciiTheme, hAnsiTheme, eastAsiaTheme, csTheme } = fontFamily;
55
+ const fontAttrs = [];
56
+ if (ascii) fontAttrs.push(`w:ascii="${escapeXml(ascii)}"`);
57
+ if (hAnsi) fontAttrs.push(`w:hAnsi="${escapeXml(hAnsi)}"`);
58
+ if (eastAsia) fontAttrs.push(`w:eastAsia="${escapeXml(eastAsia)}"`);
59
+ if (complexScript) fontAttrs.push(`w:cs="${escapeXml(complexScript)}"`);
60
+ if (hint) fontAttrs.push(`w:hint="${escapeXml(hint)}"`);
61
+ if (asciiTheme) fontAttrs.push(`w:asciiTheme="${escapeXml(asciiTheme)}"`);
62
+ if (hAnsiTheme) fontAttrs.push(`w:hAnsiTheme="${escapeXml(hAnsiTheme)}"`);
63
+ if (eastAsiaTheme) fontAttrs.push(`w:eastAsiaTheme="${escapeXml(eastAsiaTheme)}"`);
64
+ if (csTheme) fontAttrs.push(`w:cstheme="${escapeXml(csTheme)}"`);
65
+ if (fontAttrs.length > 0) parts.push(`<w:rFonts ${fontAttrs.join(" ")}/>`);
66
+ }
67
+ if (bold === true) parts.push("<w:b/>");
68
+ else if (bold === false) parts.push("<w:b w:val=\"0\"/>");
69
+ if (boldCs === true) parts.push("<w:bCs/>");
70
+ else if (boldCs === false) parts.push("<w:bCs w:val=\"0\"/>");
71
+ if (italic === true) parts.push("<w:i/>");
72
+ else if (italic === false) parts.push("<w:i w:val=\"0\"/>");
73
+ if (italicCs === true) parts.push("<w:iCs/>");
74
+ else if (italicCs === false) parts.push("<w:iCs w:val=\"0\"/>");
75
+ if (allCaps === true) parts.push("<w:caps/>");
76
+ else if (allCaps === false) parts.push("<w:caps w:val=\"0\"/>");
77
+ if (smallCaps === true) parts.push("<w:smallCaps/>");
78
+ else if (smallCaps === false) parts.push("<w:smallCaps w:val=\"0\"/>");
79
+ if (strike === true) parts.push("<w:strike/>");
80
+ else if (strike === false) parts.push("<w:strike w:val=\"0\"/>");
81
+ if (doubleStrike === true) parts.push("<w:dstrike/>");
82
+ else if (doubleStrike === false) parts.push("<w:dstrike w:val=\"0\"/>");
83
+ if (outline === true) parts.push("<w:outline/>");
84
+ else if (outline === false) parts.push("<w:outline w:val=\"0\"/>");
85
+ if (shadow === true) parts.push("<w:shadow/>");
86
+ else if (shadow === false) parts.push("<w:shadow w:val=\"0\"/>");
87
+ if (emboss === true) parts.push("<w:emboss/>");
88
+ else if (emboss === false) parts.push("<w:emboss w:val=\"0\"/>");
89
+ if (imprint === true) parts.push("<w:imprint/>");
90
+ else if (imprint === false) parts.push("<w:imprint w:val=\"0\"/>");
91
+ if (hidden === true) parts.push("<w:vanish/>");
92
+ else if (hidden === false) parts.push("<w:vanish w:val=\"0\"/>");
93
+ const colorXml = serializeColorElement(color);
94
+ if (colorXml) parts.push(colorXml);
95
+ if (spacing !== void 0) parts.push(`<w:spacing w:val="${intAttr(spacing)}"/>`);
96
+ const horizontalScale = roundHorizontalScalePercentForSerialization(scale);
97
+ if (horizontalScale !== void 0) parts.push(`<w:w w:val="${intAttr(horizontalScale)}"/>`);
98
+ if (kerning !== void 0) parts.push(`<w:kern w:val="${intAttr(kerning)}"/>`);
99
+ if (position !== void 0) parts.push(`<w:position w:val="${intAttr(position)}"/>`);
100
+ if (fontSize !== void 0) parts.push(`<w:sz w:val="${intAttr(fontSize)}"/>`);
101
+ if (fontSizeCs !== void 0) parts.push(`<w:szCs w:val="${intAttr(fontSizeCs)}"/>`);
102
+ let customHighlightShadingXml = "";
103
+ if (highlight) {
104
+ if (VALID_HIGHLIGHT_COLORS.has(highlight)) parts.push(`<w:highlight w:val="${highlight}"/>`);
105
+ else if (!shading) {
106
+ const hex = highlight.replace(/^#/u, "");
107
+ if (/^[0-9a-fA-F]{6}$/u.test(hex)) customHighlightShadingXml = `<w:shd w:val="clear" w:color="auto" w:fill="${hex}"/>`;
108
+ }
109
+ }
110
+ if (underline) {
111
+ const { style, color: underlineColor } = underline;
112
+ const uAttrs = [`w:val="${style}"`];
113
+ if (underlineColor) {
114
+ const { rgb, themeColor, themeTint, themeShade, auto: _auto } = underlineColor;
115
+ if (rgb && isValidHexColor(rgb)) uAttrs.push(`w:color="${escapeXml(rgb)}"`);
116
+ if (themeColor) uAttrs.push(`w:themeColor="${escapeXml(themeColor)}"`);
117
+ if (themeTint) uAttrs.push(`w:themeTint="${escapeXml(themeTint)}"`);
118
+ if (themeShade) uAttrs.push(`w:themeShade="${escapeXml(themeShade)}"`);
119
+ }
120
+ parts.push(`<w:u ${uAttrs.join(" ")}/>`);
121
+ }
122
+ if (effect) parts.push(`<w:effect w:val="${effect}"/>`);
123
+ const shadingXml = serializeShading(shading) || customHighlightShadingXml;
124
+ if (shadingXml) parts.push(shadingXml);
125
+ if (vertAlign) parts.push(`<w:vertAlign w:val="${vertAlign}"/>`);
126
+ if (rtl === true) parts.push("<w:rtl/>");
127
+ else if (rtl === false) parts.push("<w:rtl w:val=\"0\"/>");
128
+ if (cs === true) parts.push("<w:cs/>");
129
+ else if (cs === false) parts.push("<w:cs w:val=\"0\"/>");
130
+ if (emphasisMark) parts.push(`<w:em w:val="${emphasisMark}"/>`);
131
+ if (language) {
132
+ const { val, eastAsia, bidi } = language;
133
+ const languageAttrs = [];
134
+ if (val) languageAttrs.push(`w:val="${escapeXml(val)}"`);
135
+ if (eastAsia) languageAttrs.push(`w:eastAsia="${escapeXml(eastAsia)}"`);
136
+ if (bidi) languageAttrs.push(`w:bidi="${escapeXml(bidi)}"`);
137
+ if (languageAttrs.length > 0) parts.push(`<w:lang ${languageAttrs.join(" ")}/>`);
138
+ }
139
+ return parts.length === 0 ? "" : `<w:rPr>${parts.join("")}</w:rPr>`;
140
+ }
141
+ //#endregion
142
+ export { serializeShading, serializeTextFormatting };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { document_d_exports } from "./types/document.js";
2
- import { FolioContentBlock, FolioContentContainerPathEntry, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentParagraphAlignment, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "./compare/content-types.js";
2
+ import { FolioContentBlock, FolioContentContainerPathEntry, FolioContentIdStability, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentLineSpacingRule, FolioContentParagraphAlignment, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentTableLocation } from "./compare/content-types.js";
3
3
  import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphSpacing, FolioAISignatureParty } from "./ai-edits/types.js";
4
4
  import { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, diffWordSegments } from "./ai-edits/word-diff.js";
5
5
  import { FolioAIEditApplyOutcome, FolioRevisionStamp, FolioWordDiffOptions, applyFolioAIEditOperations } from "./ai-edits/apply.js";
@@ -40,4 +40,4 @@ import { getGoogleFontsEnabled, setEmbeddedFontFamilyMap, setGoogleFontsEnabled
40
40
  import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
41
41
  type Document = document_d_exports.Document;
42
42
  type DocxConformanceClass = document_d_exports.DocxConformanceClass;
43
- export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFormatRange, type CompareResult, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
43
+ export { type AIBarStatus, type AIChatMode, type AICitation, type AICitationRange, type AICitationSource, type AIGenerateInput, type AISuggestion, type AISuggestionApplyMode, type AISuggestionPreset, type AISuggestionSeverity, type AISuggestionStatus, type AcceptAutocompleteResult, type AnonymizationMatch, type AnonymizationTerm, type ApplyFolioDocumentOperationsOptions, type ApplyResult, type AutocompleteSuggestionPluginOptions, type AutocompleteSuggestionState, type AutocompleteSuggestionStatus, type AutocompleteTriggerCheck, type AutocompleteTriggerOptions, type AutocompleteTriggerSkipReason, type BlockRect, COMPARE_UNSUPPORTED_REASONS, COMPARE_VERIFICATION_CAUSES, COMPARE_VERIFICATION_INVARIANTS, type CompareChange, type CompareChangeLocation, type CompareContentOptions, CompareDocxApplyError, type CompareDocxError, CompareDocxFinalParagraphMarkError, CompareDocxOperationLimitError, type CompareDocxOptions, CompareDocxParseError, CompareDocxRoundTripError, CompareDocxSerializeError, type CompareFormatRange, type CompareResult, type CompareUnsupportedPart, type CompareUnsupportedReason, type CompareVerification, type CompareVerificationCause, type CompareVerificationFailure, type CompareVerificationInvariant, type CreateEmptyDocumentOptions, DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, type DeriveBlockIdInput, type DirectiveKind, type DirectiveRange, type Document, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, type DocxCompatibility, type DocxCompatibilityContext, type DocxCompatibilityIssue, type DocxCompatibilityLocation, type DocxCompatibilityPart, type DocxConformanceClass, type EmbeddedFont, type EmbeddedFontParts, type ExtractDocumentStyleSetOptions, FOLIO_CONTENT_COMPARISON_LIMITS, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, type FinalParagraphMarkRevision, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioBlockId, type FolioContentBlock, type FolioContentBlockProperty, type FolioContentComparison, type FolioContentComparisonError, type FolioContentComparisonEvent, type FolioContentComparisonLimit, FolioContentComparisonLimitError, type FolioContentContainerPathEntry, type FolioContentFormatRange, type FolioContentFormattingChange, type FolioContentIdStability, type FolioContentInlineBooleanProperty, type FolioContentInlineFormatting, type FolioContentInlineFormattingPatch, type FolioContentLineSpacingRule, type FolioContentParagraphAlignment, type FolioContentParagraphFormattingPatch, type FolioContentParagraphKind, type FolioContentParagraphSpacing, type FolioContentRun, type FolioContentSnapshot, type FolioContentStructuralChange, type FolioContentTableLocation, type FolioContentTextSegment, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocxCompatibilityHost, type FolioDocxCompatibilityProfile, type FolioRevisionStamp, type FolioWordDiffOptions, type ImageMeta, type ImageRef, type InspectDocxCompatibilityOptions, InvalidCompareDocxOptionsError, InvalidFolioContentComparisonError, InvalidFolioDocumentOperationBatchError, MAX_COMPARE_OPERATIONS, type MarkdownOptions, type MarkdownResult, type PositionalText, type ResolvedAnchor, STELLA_STYLE_SET_NAME, type TemplatePreviewSpan, type TemplatePreviewValue, type TemplatePreviewValues, type TemplateSlashMenuKeyAction, type TemplateSlashMenuState, UnsupportedFolioDocumentOperationVersionError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildEmbeddedFontFamilyMap, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, compareContent, compareDocx, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, currentFolioBlockId, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, mergeDocumentContent, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scopeEmbeddedFontFamily, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setEmbeddedFontFamilyMap, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
@@ -0,0 +1,23 @@
1
+ import { document_d_exports } from "../types/document.js";
2
+ //#region src/internal/paragraphFormattingSerialization.d.ts
3
+ type ExhaustiveFields<Source, Classified extends keyof Source> = Exclude<keyof Source, Classified> extends never ? Source : never;
4
+ type ParagraphNumberingReference = document_d_exports.ParagraphFormatting["numPr"] | null;
5
+ type ClassifiedParagraphFormattingField = "alignment" | "bidi" | "kinsoku" | "overflowPunctuation" | "spaceBefore" | "spaceAfter" | "lineSpacing" | "lineSpacingRule" | "snapToGrid" | "beforeAutospacing" | "afterAutospacing" | "spacingExplicit" | "indentLeft" | "indentRight" | "indentFirstLine" | "hangingIndent" | "borders" | "shading" | "tabs" | "keepNext" | "keepLines" | "widowControl" | "pageBreakBefore" | "contextualSpacing" | "numPr" | "numPrFromStyle" | "outlineLevel" | "styleId" | "frame" | "suppressLineNumbers" | "suppressAutoHyphens" | "runProperties" | "runInWithNext";
6
+ type ExhaustiveParagraphFormatting = ExhaustiveFields<document_d_exports.ParagraphFormatting, ClassifiedParagraphFormattingField>;
7
+ /** Compare numbering references by their emitted id and effective level. */
8
+ declare const paragraphNumberingReferencesEqual: (left: ParagraphNumberingReference, right: ParagraphNumberingReference) => boolean;
9
+ /** Whether resolved numbering still belongs to the paragraph's style tier. */
10
+ declare const isStyleSourcedParagraphNumbering: (numPr: ParagraphNumberingReference, numPrFromStyle: ParagraphNumberingReference) => boolean;
11
+ /** Exact fallback-emission instructions for the modeled part of `w:pPr`. */
12
+ type ModeledParagraphFormattingEmission = Readonly<{
13
+ propertiesXml?: string;
14
+ paragraphMarkPropertiesInnerXml?: string;
15
+ }>;
16
+ /**
17
+ * Resolve paragraph formatting into its exact fallback `w:pPr` instructions.
18
+ * Every input field is classified here so parser capture fingerprints and the
19
+ * serializer cannot drift apart when paragraph formatting grows.
20
+ */
21
+ declare const modelParagraphFormattingEmission: (input: ExhaustiveParagraphFormatting | undefined) => ModeledParagraphFormattingEmission;
22
+ //#endregion
23
+ export { ModeledParagraphFormattingEmission, isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission, paragraphNumberingReferencesEqual };
@@ -0,0 +1,157 @@
1
+ import { serializeBorder } from "../docx/serializer/borderSerializer.js";
2
+ import { serializeShading, serializeTextFormatting } from "../docx/serializer/textFormattingSerializer.js";
3
+ import { escapeXml, intAttr } from "../docx/serializer/xmlUtils.js";
4
+ //#region src/internal/paragraphFormattingSerialization.ts
5
+ const modelParagraphNumberingReference = (reference) => {
6
+ if (!reference) return null;
7
+ const { numId, ilvl } = reference;
8
+ return {
9
+ ...numId !== void 0 ? { numId } : {},
10
+ ...ilvl !== void 0 ? { ilvl } : {}
11
+ };
12
+ };
13
+ /** Compare numbering references by their emitted id and effective level. */
14
+ const paragraphNumberingReferencesEqual = (left, right) => {
15
+ const modeledLeft = modelParagraphNumberingReference(left);
16
+ const modeledRight = modelParagraphNumberingReference(right);
17
+ if (modeledLeft === null || modeledRight === null) return modeledLeft === null && modeledRight === null;
18
+ return modeledLeft.numId === modeledRight.numId && (modeledLeft.ilvl ?? 0) === (modeledRight.ilvl ?? 0);
19
+ };
20
+ /** Whether resolved numbering still belongs to the paragraph's style tier. */
21
+ const isStyleSourcedParagraphNumbering = (numPr, numPrFromStyle) => numPr != null && numPrFromStyle != null && paragraphNumberingReferencesEqual(numPr, numPrFromStyle);
22
+ const serializeToggle = (name, value) => {
23
+ if (value === true) return `<w:${name}/>`;
24
+ if (value === false) return `<w:${name} w:val="0"/>`;
25
+ return "";
26
+ };
27
+ const serializeParagraphBorders = (borders) => {
28
+ if (!borders) return "";
29
+ const { top, left, bottom, right, between, bar } = borders;
30
+ const parts = [
31
+ serializeBorder(top, "top"),
32
+ serializeBorder(left, "left"),
33
+ serializeBorder(bottom, "bottom"),
34
+ serializeBorder(right, "right"),
35
+ serializeBorder(between, "between"),
36
+ serializeBorder(bar, "bar")
37
+ ].filter(Boolean);
38
+ return parts.length === 0 ? "" : `<w:pBdr>${parts.join("")}</w:pBdr>`;
39
+ };
40
+ const serializeTabStops = (tabs) => {
41
+ if (!tabs || tabs.length === 0) return "";
42
+ return `<w:tabs>${tabs.map((tab) => {
43
+ const { alignment, position, leader } = tab;
44
+ const attrs = [`w:val="${alignment}"`, `w:pos="${intAttr(position)}"`];
45
+ if (leader && leader !== "none") attrs.push(`w:leader="${leader}"`);
46
+ return `<w:tab ${attrs.join(" ")}/>`;
47
+ }).join("")}</w:tabs>`;
48
+ };
49
+ const serializeSpacing = (formatting) => {
50
+ const attrs = [];
51
+ if (formatting.spaceBefore !== void 0) attrs.push(`w:before="${intAttr(formatting.spaceBefore)}"`);
52
+ if (formatting.spaceAfter !== void 0) attrs.push(`w:after="${intAttr(formatting.spaceAfter)}"`);
53
+ if (formatting.lineSpacing !== void 0) attrs.push(`w:line="${intAttr(formatting.lineSpacing)}"`);
54
+ if (formatting.lineSpacingRule) attrs.push(`w:lineRule="${formatting.lineSpacingRule}"`);
55
+ if (formatting.beforeAutospacing !== void 0) attrs.push(`w:beforeAutospacing="${formatting.beforeAutospacing ? "1" : "0"}"`);
56
+ if (formatting.afterAutospacing !== void 0) attrs.push(`w:afterAutospacing="${formatting.afterAutospacing ? "1" : "0"}"`);
57
+ return attrs.length === 0 ? "" : `<w:spacing ${attrs.join(" ")}/>`;
58
+ };
59
+ const serializeIndentation = (formatting) => {
60
+ const attrs = [];
61
+ if (formatting.indentLeft !== void 0) attrs.push(`w:left="${intAttr(formatting.indentLeft)}"`);
62
+ if (formatting.indentRight !== void 0) attrs.push(`w:right="${intAttr(formatting.indentRight)}"`);
63
+ if (formatting.indentFirstLine !== void 0) {
64
+ const attribute = formatting.hangingIndent ? "hanging" : "firstLine";
65
+ const value = formatting.hangingIndent ? Math.abs(formatting.indentFirstLine) : formatting.indentFirstLine;
66
+ attrs.push(`w:${attribute}="${intAttr(value)}"`);
67
+ }
68
+ return attrs.length === 0 ? "" : `<w:ind ${attrs.join(" ")}/>`;
69
+ };
70
+ const serializeNumbering = (numPr) => {
71
+ const modeled = modelParagraphNumberingReference(numPr ?? null);
72
+ if (!modeled) return "";
73
+ const parts = [];
74
+ if (modeled.ilvl !== void 0) parts.push(`<w:ilvl w:val="${intAttr(modeled.ilvl)}"/>`);
75
+ if (modeled.numId !== void 0) parts.push(`<w:numId w:val="${intAttr(modeled.numId)}"/>`);
76
+ return parts.length === 0 ? "" : `<w:numPr>${parts.join("")}</w:numPr>`;
77
+ };
78
+ const serializeFrameProperties = (frame) => {
79
+ if (!frame) return "";
80
+ const { dropCap, lines, width, height, hSpace, vSpace, hAnchor, vAnchor, x, y, xAlign, yAlign, wrap } = frame;
81
+ const attrs = [];
82
+ if (dropCap) attrs.push(`w:dropCap="${dropCap}"`);
83
+ if (lines !== void 0) attrs.push(`w:lines="${intAttr(lines)}"`);
84
+ if (width !== void 0) attrs.push(`w:w="${intAttr(width)}"`);
85
+ if (height !== void 0) attrs.push(`w:h="${intAttr(height)}"`);
86
+ if (hSpace !== void 0) attrs.push(`w:hSpace="${intAttr(hSpace)}"`);
87
+ if (vSpace !== void 0) attrs.push(`w:vSpace="${intAttr(vSpace)}"`);
88
+ if (hAnchor) attrs.push(`w:hAnchor="${hAnchor}"`);
89
+ if (vAnchor) attrs.push(`w:vAnchor="${vAnchor}"`);
90
+ if (x !== void 0) attrs.push(`w:x="${x}"`);
91
+ if (y !== void 0) attrs.push(`w:y="${y}"`);
92
+ if (xAlign) attrs.push(`w:xAlign="${xAlign}"`);
93
+ if (yAlign) attrs.push(`w:yAlign="${yAlign}"`);
94
+ if (wrap) attrs.push(`w:wrap="${wrap}"`);
95
+ return attrs.length === 0 ? "" : `<w:framePr ${attrs.join(" ")}/>`;
96
+ };
97
+ const modelSpacingProvenance = (spacingExplicit) => {
98
+ if (spacingExplicit) {
99
+ const { before: _before, after: _after } = spacingExplicit;
100
+ }
101
+ };
102
+ const extractRunPropertiesInnerXml = (runPropertiesXml) => {
103
+ if (!runPropertiesXml.startsWith("<w:rPr>") || !runPropertiesXml.endsWith("</w:rPr>")) return "";
104
+ return runPropertiesXml.slice(7, -8);
105
+ };
106
+ /**
107
+ * Resolve paragraph formatting into its exact fallback `w:pPr` instructions.
108
+ * Every input field is classified here so parser capture fingerprints and the
109
+ * serializer cannot drift apart when paragraph formatting grows.
110
+ */
111
+ const modelParagraphFormattingEmission = (input) => {
112
+ if (!input) return {};
113
+ const { alignment, bidi, kinsoku, overflowPunctuation, spaceBefore, spaceAfter, lineSpacing, lineSpacingRule, snapToGrid, beforeAutospacing, afterAutospacing, spacingExplicit, indentLeft, indentRight, indentFirstLine, hangingIndent, borders, shading, tabs, keepNext, keepLines, widowControl, pageBreakBefore, contextualSpacing, numPr, numPrFromStyle, outlineLevel, styleId, frame, suppressLineNumbers, suppressAutoHyphens, runProperties, runInWithNext } = input;
114
+ modelSpacingProvenance(spacingExplicit);
115
+ const propertiesXml = [
116
+ styleId ? `<w:pStyle w:val="${escapeXml(styleId)}"/>` : "",
117
+ serializeToggle("keepNext", keepNext),
118
+ serializeToggle("keepLines", keepLines),
119
+ serializeToggle("pageBreakBefore", pageBreakBefore),
120
+ serializeFrameProperties(frame),
121
+ serializeToggle("widowControl", widowControl),
122
+ isStyleSourcedParagraphNumbering(numPr, numPrFromStyle) ? "" : serializeNumbering(numPr),
123
+ serializeToggle("suppressLineNumbers", suppressLineNumbers),
124
+ serializeParagraphBorders(borders),
125
+ serializeShading(shading),
126
+ serializeTabStops(tabs),
127
+ serializeToggle("suppressAutoHyphens", suppressAutoHyphens),
128
+ serializeToggle("kinsoku", kinsoku),
129
+ serializeToggle("overflowPunct", overflowPunctuation),
130
+ serializeToggle("bidi", bidi),
131
+ serializeToggle("snapToGrid", snapToGrid),
132
+ serializeSpacing({
133
+ spaceBefore,
134
+ spaceAfter,
135
+ lineSpacing,
136
+ lineSpacingRule,
137
+ beforeAutospacing,
138
+ afterAutospacing
139
+ }),
140
+ serializeIndentation({
141
+ indentLeft,
142
+ indentRight,
143
+ indentFirstLine,
144
+ hangingIndent
145
+ }),
146
+ serializeToggle("contextualSpacing", contextualSpacing),
147
+ alignment ? `<w:jc w:val="${alignment}"/>` : "",
148
+ outlineLevel !== void 0 ? `<w:outlineLvl w:val="${outlineLevel}"/>` : ""
149
+ ].join("");
150
+ const paragraphMarkPropertiesInnerXml = `${extractRunPropertiesInnerXml(serializeTextFormatting(runProperties))}${runInWithNext === true ? "<w:specVanish/>" : ""}`;
151
+ const emission = {};
152
+ if (propertiesXml) emission.propertiesXml = propertiesXml;
153
+ if (paragraphMarkPropertiesInnerXml) emission.paragraphMarkPropertiesInnerXml = paragraphMarkPropertiesInnerXml;
154
+ return emission;
155
+ };
156
+ //#endregion
157
+ export { isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission, paragraphNumberingReferencesEqual };
@@ -1,8 +1,8 @@
1
- import { numPrEqual } from "../../docx/numberingParser.js";
2
1
  import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphPropertySourceBelongsToDocument, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
3
2
  import { visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
4
3
  import { ShapeOutlineStyleSchema, narrowEnum } from "../../docx/parserEnums.js";
5
4
  import { DATE_UTC_ATTRIBUTE } from "../../docx/trackedChangeInfo.js";
5
+ import { isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission, paragraphNumberingReferencesEqual } from "../../internal/paragraphFormattingSerialization.js";
6
6
  import { createStyleEngine } from "../../style-engine/styleEngine.js";
7
7
  import { OUTLINE_STYLE_CSS_ALIASES, normalizeShapeTextAnchor } from "../../types/documentEnumValues.js";
8
8
  import { canonicalJson } from "../../utils/canonicalJson.js";
@@ -106,9 +106,10 @@ const uniqueParagraphsById = (content, includeTransferIds = false) => {
106
106
  const restoreParagraphPropertySource = (paragraph, baseParagraph) => {
107
107
  copyParagraphPropertySource(paragraph, baseParagraph);
108
108
  const baseFormatting = baseParagraph.formatting;
109
- if (!baseFormatting?.numPr || !baseFormatting.numPrFromStyle || !numPrEqual(baseFormatting.numPr, baseFormatting.numPrFromStyle)) return;
110
- const { numPr, numPrFromStyle, ...authoredFormatting } = baseFormatting;
111
- if (canonicalJson(paragraph.formatting ?? {}) !== canonicalJson(authoredFormatting)) return;
109
+ if (!baseFormatting) return;
110
+ const { numPr, numPrFromStyle } = baseFormatting;
111
+ if (!numPr || !numPrFromStyle || !isStyleSourcedParagraphNumbering(numPr, numPrFromStyle)) return;
112
+ if (canonicalJson(modelParagraphFormattingEmission(paragraph.formatting)) !== canonicalJson(modelParagraphFormattingEmission(baseFormatting))) return;
112
113
  paragraph.formatting = {
113
114
  ...paragraph.formatting,
114
115
  numPr,
@@ -777,15 +778,6 @@ const propertyChangeFromAttrs = (change) => {
777
778
  ...currentFormatting !== void 0 && { currentFormatting }
778
779
  };
779
780
  };
780
- /**
781
- * Whether the paragraph's numbering still comes verbatim from its style —
782
- * serialize no direct `<w:numPr>` then. The moment a list command changes
783
- * `numPr` the values diverge and the numbering serializes as direct
784
- * formatting, so a stale provenance value can never swallow a user edit.
785
- */
786
- function isStyleSourcedNumPr(attrs) {
787
- return attrs.numPrFromStyle != null && attrs.numPr != null && numPrEqual(attrs.numPr, attrs.numPrFromStyle);
788
- }
789
781
  function assignBooleanToggle(result, attrs, orig, key) {
790
782
  const value = attrs[key] ?? void 0;
791
783
  if (value === (orig[key] ?? void 0)) return;
@@ -834,10 +826,10 @@ function paragraphAttrsToFormatting(attrs) {
834
826
  else Reflect.deleteProperty(result, "lineSpacingRule");
835
827
  if (directAlignment === void 0) Reflect.deleteProperty(result, "alignment");
836
828
  else result.alignment = directAlignment;
837
- if (isStyleSourcedNumPr(attrs)) {
829
+ if (isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) {
838
830
  delete result.numPr;
839
831
  delete result.numPrFromStyle;
840
- } else if (attrs.numPr !== orig.numPr && !numPrEqual(attrs.numPr, orig.numPr)) {
832
+ } else if (attrs.numPr !== orig.numPr && !paragraphNumberingReferencesEqual(attrs.numPr, orig.numPr)) {
841
833
  if (attrs.numPr) result.numPr = attrs.numPr;
842
834
  else delete result.numPr;
843
835
  delete result.numPrFromStyle;
@@ -874,7 +866,7 @@ function paragraphAttrsToFormatting(attrs) {
874
866
  if (attrs.indentRight) f.indentRight = attrs.indentRight;
875
867
  if (attrs.indentFirstLine) f.indentFirstLine = attrs.indentFirstLine;
876
868
  if (attrs.hangingIndent) f.hangingIndent = attrs.hangingIndent;
877
- if (attrs.numPr && !isStyleSourcedNumPr(attrs)) f.numPr = attrs.numPr;
869
+ if (attrs.numPr && !isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) f.numPr = attrs.numPr;
878
870
  if (attrs.styleId) f.styleId = attrs.styleId;
879
871
  if (attrs.borders) f.borders = attrs.borders;
880
872
  if (attrs.shading) f.shading = attrs.shading;
package/dist/server.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FolioContentParagraphKind } from "./compare/content-types.js";
1
2
  import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIParagraphSpacing, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./ai-edits/types.js";
2
3
  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, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, 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
4
  import { FolioReviewChange, FolioReviewChangeKind } from "./ai-edits/read.js";
@@ -27,4 +28,4 @@ import { FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_E
27
28
  import { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioYjsDocxMaterializationError, FolioYjsDocxMaterializationErrorCode, MaterializeYjsDocxOptions, materializeYjsDocx } from "./docx/server/materializeYjsDocx.js";
28
29
  import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
29
30
  import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioBlockDiff, FolioBlockProperty, FolioCompareDocxVersionsOptions, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionChangeProperty, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
30
- export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, 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, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, FolioYjsDocxMaterializationError, type FolioYjsDocxMaterializationErrorCode, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type MaterializeYjsDocxOptions, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
31
+ export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, 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, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioContentParagraphKind, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, FolioYjsDocxMaterializationError, type FolioYjsDocxMaterializationErrorCode, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type MaterializeYjsDocxOptions, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
@@ -21,39 +21,35 @@ import { TaggedError, panic } from "better-result";
21
21
  * ## Alignment
22
22
  *
23
23
  * Compatible body and table/container segments are aligned by the neutral
24
- * comparison core. Within each compatible segment, blocks are paired in
25
- * three passes, each only considering blocks the previous pass left unpaired:
24
+ * comparison core. Quadratic structural candidate alignment shares bounded
25
+ * cell and token budgets across the comparison. Within each compatible
26
+ * segment, blocks are paired in four confidence-ordered passes:
26
27
  *
27
28
  * 1. **Stable-id pairing.** Blocks whose ids are equal and whose snapshot
28
- * provenance marks those ids stable are paired directly. A source
29
- * `w14:paraId` is stable identity independent of text, so an equal-id pair
30
- * with different text is a genuine edit (`modified`). Deterministically
31
- * synthesized ids and `seq-NNNN` fallbacks are positional instead: the
32
- * adapter preserves that provenance so an ordinal shift falls through to
33
- * exact-text alignment rather than becoming a false identity match.
34
- * 2. **Exact-text pairing.** An order-preserving LCS over remaining blocks,
35
- * matched by exact text equality. This is what recovers same-text blocks
36
- * that pass 1 missed because a fallback id shifted with the ordinal. Its
37
- * O(m·n) table is skipped ({@link exceedsLcsBudget}) once the unpaired
38
- * counts on both sides would exceed a fixed cell budget, so a document
39
- * with few/no stable ids can't force a quadratic-sized allocation; those
40
- * blocks fall through to pass 3 instead.
41
- * 3. **Positional fallback.** Whatever a monotonicity filter leaves
42
- * unpaired is split into the gaps between anchored pairs (pass 1 + 2,
43
- * time-ordered); within each gap the shorter side is zipped positionally
44
- * against the longer one (`modified`), and any excess on either side is
45
- * reported as `added` / `deleted`.
46
- *
47
- * The combined anchor set from passes 1 and 2 is re-filtered to the longest
48
- * increasing subsequence by revised-side index before pass 3 runs, so a
49
- * pathological crossing match (content reordered across versions) can't
50
- * produce an out-of-order gap — the alignment always walks both documents
51
- * forward.
29
+ * provenance marks those ids stable become the highest-confidence
30
+ * monotone anchor candidates. A source `w14:paraId` is stable identity
31
+ * independent of text, so an equal-id pair with different text is a genuine
32
+ * edit (`modified`). Deterministically synthesized ids and `seq-NNNN`
33
+ * fallbacks are positional instead: the adapter preserves that provenance
34
+ * so an ordinal shift falls through to exact-text alignment rather than
35
+ * becoming a false identity match.
36
+ * 2. **Exact-text pairing.** Within each stable-id gap, nonblank text that is
37
+ * unique on both sides becomes an exact anchor. An O(n log n) increasing-
38
+ * subsequence selection keeps those anchors ordered; repeated or blank
39
+ * text is deliberately not treated as identity evidence.
40
+ * 3. **Residual-id continuity.** Within the stable-plus-exact gaps, a unique
41
+ * id whose provenance changed between positional and stable may pair. This
42
+ * preserves identity across serialize-and-reopen boundaries without
43
+ * letting weaker evidence cross an established correspondence.
44
+ * 4. **Positional fallback.** Whatever remains is split into the gaps between
45
+ * the confidence-ordered anchors; within each gap the shorter side is
46
+ * zipped positionally against the longer one (`modified`), and any excess
47
+ * on either side is reported as `added` / `deleted`.
52
48
  *
53
49
  * ## Move detection
54
50
  *
55
51
  * Relocated content would otherwise report as an unrelated `deleted` +
56
- * `added` pair (both order-preserving passes drop crossing matches by
52
+ * `added` pair (the monotone alignment passes drop crossing matches by
57
53
  * design). The neutral comparison core re-classifies eligible exact and
58
54
  * closely edited pairs as `movedFrom` / `movedTo` entries sharing a
59
55
  * `moveGroupId`. Candidate counts and similarity work share bounded budgets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-core",
3
- "version": "0.37.4",
3
+ "version": "0.37.5",
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",