@stll/folio-core 0.47.7 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +565 -121
- package/dist/ai-edits/minimal-replacement.d.ts +64 -0
- package/dist/ai-edits/minimal-replacement.js +282 -0
- package/dist/controller/fontReadiness.js +3 -3
- package/dist/controller/hyphenationReadiness.d.ts +19 -0
- package/dist/controller/hyphenationReadiness.js +47 -0
- package/dist/controller/layoutPipeline.d.ts +3 -0
- package/dist/controller/layoutPipeline.js +70 -18
- package/dist/display-list/build/buildDisplayList.js +39 -12
- package/dist/display-list/build/pageFurniture.d.ts +7 -1
- package/dist/display-list/build/pageFurniture.js +21 -8
- package/dist/display-list/build/paragraphPrimitives.js +68 -11
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/display-list/build/textBoxPrimitives.js +1 -1
- package/dist/display-list/build/unsupported.d.ts +2 -2
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +79 -64
- package/dist/docx/bulletMarkers.d.ts +18 -2
- package/dist/docx/bulletMarkers.js +27 -2
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +57 -45
- package/dist/docx/containerChildren.d.ts +21 -8
- package/dist/docx/containerChildren.js +39 -9
- package/dist/docx/documentParser.d.ts +5 -1
- package/dist/docx/documentParser.js +8 -5
- package/dist/docx/documentSectionFacts.d.ts +22 -0
- package/dist/docx/documentSectionFacts.js +43 -0
- package/dist/docx/drawingGroupChildren.d.ts +60 -0
- package/dist/docx/drawingGroupChildren.js +176 -0
- package/dist/docx/drawingUtils.js +3 -0
- package/dist/docx/fieldParser.d.ts +8 -1
- package/dist/docx/fieldParser.js +47 -3
- package/dist/docx/fontTableParser.js +34 -27
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +15 -12
- package/dist/docx/groupDrawingParser.d.ts +9 -2
- package/dist/docx/groupDrawingParser.js +125 -37
- package/dist/docx/headerFooterParser.d.ts +7 -2
- package/dist/docx/headerFooterParser.js +15 -5
- package/dist/docx/hyperlinkParser.d.ts +48 -36
- package/dist/docx/hyperlinkParser.js +97 -82
- package/dist/docx/numberingParser.js +108 -84
- package/dist/docx/packageParts.d.ts +45 -1
- package/dist/docx/packageParts.js +93 -2
- package/dist/docx/paraIdAttribute.d.ts +3 -2
- package/dist/docx/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +468 -365
- package/dist/docx/paragraphProperties.js +123 -109
- package/dist/docx/paragraphPropertySource.d.ts +6 -1
- package/dist/docx/paragraphPropertySource.js +9 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
- package/dist/docx/parser.d.ts +7 -1
- package/dist/docx/parser.js +33 -16
- package/dist/docx/previewBudget.d.ts +55 -33
- package/dist/docx/previewBudget.js +59 -65
- package/dist/docx/rezip.js +41 -58
- package/dist/docx/runParser.d.ts +4 -1
- package/dist/docx/runParser.js +182 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/selectiveSaveFlags.d.ts +10 -3
- package/dist/docx/selectiveSaveFlags.js +1 -1
- package/dist/docx/selectiveXmlPatch.d.ts +56 -34
- package/dist/docx/selectiveXmlPatch.js +222 -115
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
- package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
- package/dist/docx/serializer/paragraphSerializer.js +47 -42
- package/dist/docx/serializer/runSerializer.d.ts +5 -1
- package/dist/docx/serializer/runSerializer.js +4 -3
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -0
- package/dist/docx/shapeAlternateContent.d.ts +25 -0
- package/dist/docx/shapeAlternateContent.js +52 -0
- package/dist/docx/streamingXmlParser.d.ts +6 -2
- package/dist/docx/streamingXmlParser.js +12 -7
- package/dist/docx/styleParser.js +34 -8
- package/dist/docx/tableParser.d.ts +21 -12
- package/dist/docx/tableParser.js +518 -441
- package/dist/docx/textBoxParser.d.ts +18 -5
- package/dist/docx/textBoxParser.js +12 -6
- package/dist/docx/verbatimCapture.d.ts +10 -8
- package/dist/docx/verbatimCapture.js +45 -2
- package/dist/docx/vmlImageParser.d.ts +15 -13
- package/dist/docx/vmlImageParser.js +75 -60
- package/dist/docx/vmlPreview.d.ts +3 -3
- package/dist/docx/vmlPreview.js +3 -4
- package/dist/docx/xmlNamespaceContext.d.ts +9 -0
- package/dist/docx/xmlNamespaceContext.js +54 -0
- package/dist/docx/xmlParser.d.ts +6 -3
- package/dist/docx/xmlParser.js +11 -41
- package/dist/docx/xmlResourceLimits.d.ts +2 -1
- package/dist/docx/xmlResourceLimits.js +4 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.d.ts +11 -2
- package/dist/headless-layout.js +153 -107
- package/dist/internal/headlessRevisionResolution.js +50 -13
- package/dist/internal/paragraphFormattingSerialization.js +3 -3
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
- package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
- package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
- package/dist/layout-bridge/engine/hitTest.js +5 -3
- package/dist/layout-bridge/engine/selectionRects.js +5 -3
- package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
- package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +102 -14
- package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
- package/dist/layout-engine/justificationCompatibility.js +9 -5
- package/dist/layout-engine/keep-together.d.ts +15 -6
- package/dist/layout-engine/keep-together.js +43 -16
- package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
- package/dist/layout-engine/layoutInstrumentation.js +8 -1
- package/dist/layout-engine/measure/advanceComposition.js +50 -7
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
- package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
- package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
- package/dist/layout-engine/measure/lineBreaks.js +10 -3
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
- package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
- package/dist/layout-engine/measure/measureBlocks.js +46 -10
- package/dist/layout-engine/measure/measureContainer.js +51 -8
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +34 -8
- package/dist/layout-engine/measure/measureParagraph.js +143 -101
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
- package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
- package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
- package/dist/layout-engine/measure/tabCalculator.js +2 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +51 -19
- package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
- package/dist/layout-engine/measure/tableCellGrid.js +45 -5
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
- package/dist/layout-engine/noteAreaFlow.js +83 -0
- package/dist/layout-engine/paginator.d.ts +12 -1
- package/dist/layout-engine/paginator.js +18 -2
- package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
- package/dist/layout-engine/paragraphSpacing.js +2 -1
- package/dist/layout-engine/tableRowBreak.d.ts +8 -1
- package/dist/layout-engine/tableRowBreak.js +25 -2
- package/dist/layout-engine/types.d.ts +108 -3
- package/dist/layout-engine/types.js +96 -1
- package/dist/layout-painter/index.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +32 -83
- package/dist/layout-painter/renderParagraph.d.ts +6 -1
- package/dist/layout-painter/renderParagraph.js +75 -26
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/layout-painter/renderTextBox.d.ts +12 -2
- package/dist/layout-painter/renderTextBox.js +26 -2
- package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
- package/dist/prosemirror/alternateContentAttrs.js +35 -0
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +133 -11
- package/dist/prosemirror/commands/comments.js +51 -41
- package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
- package/dist/prosemirror/contentControlRevisions.js +84 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +117 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +4 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/paragraphDirection.d.ts +29 -2
- package/dist/prosemirror/paragraphDirection.js +21 -2
- package/dist/prosemirror/plugins/suggestionMode.js +37 -8
- package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
- package/dist/prosemirror/rejoinRunCarriers.js +66 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
- package/dist/prosemirror/schema/nodes.d.ts +50 -6
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +10 -1
- package/dist/utils/scriptSegments.d.ts +33 -4
- package/dist/utils/scriptSegments.js +39 -6
- package/dist/utils/textFormattingMerge.d.ts +17 -3
- package/dist/utils/textFormattingMerge.js +18 -12
- package/dist/utils/trailingText.d.ts +22 -0
- package/dist/utils/trailingText.js +32 -0
- package/package.json +2 -2
- package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
- package/dist/layout-engine/justifiedLineFit.js +0 -6
|
@@ -5,6 +5,7 @@ import { isInlineSdtContent, isSimpleFieldContent } from "../../docx/inlineWrapp
|
|
|
5
5
|
import { paragraphNumberingReferenceId as paragraphNumberingReferenceId$1, sameStatedParagraphNumbering as sameStatedParagraphNumbering$1 } from "../../docx/numberingReference.js";
|
|
6
6
|
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";
|
|
7
7
|
import { BLOCK_TREE_DESCENT, visitBlockTreeRecords, visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
|
|
8
|
+
import { refingerprintShapeAlternateContent } from "../../docx/shapeAlternateContent.js";
|
|
8
9
|
import { DATE_UTC_ATTRIBUTE } from "../../docx/trackedChangeInfo.js";
|
|
9
10
|
import { copiedWrapPolygon } from "../../docx/wrapPolygon.js";
|
|
10
11
|
import { isStyleSourcedParagraphNumbering, modelParagraphFormattingEmission } from "../../internal/paragraphFormattingSerialization.js";
|
|
@@ -15,12 +16,14 @@ import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
|
15
16
|
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
16
17
|
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
17
18
|
import { emuToPixels, emuToStrokePixels, pixelsToEmu } from "../../utils/units.js";
|
|
19
|
+
import { unchangedAlternateContentXml } from "../alternateContentAttrs.js";
|
|
18
20
|
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
19
21
|
import { readAuthoredTransform } from "../authoredTransformAttrs.js";
|
|
20
22
|
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
21
23
|
import { bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
|
|
22
24
|
import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges } from "../commands/propertyChangeScope.js";
|
|
23
25
|
import { expectCommentReferenceAttrs } from "../commentReferenceAttrs.js";
|
|
26
|
+
import { enclosingRevisionIds } from "../contentControlRevisions.js";
|
|
24
27
|
import { INLINE_WRAPPER_MARK_NAME } from "../extensions/marks/InlineWrapperExtension.js";
|
|
25
28
|
import { applyRunFormattingOverrideAttrs, buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
|
|
26
29
|
import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
@@ -31,7 +34,7 @@ import { listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRende
|
|
|
31
34
|
import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
|
|
32
35
|
import { resolveNumberedRefFields } from "../numberedRefFields.js";
|
|
33
36
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
34
|
-
import {
|
|
37
|
+
import { directionToAuthoredBidi } from "../paragraphDirection.js";
|
|
35
38
|
import { directParagraphSpacing } from "../paragraphSpacing.js";
|
|
36
39
|
import { expectRangeAnchorAttrs } from "../rangeAnchorAttrs.js";
|
|
37
40
|
import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
@@ -42,6 +45,7 @@ import { schema } from "../schema/index.js";
|
|
|
42
45
|
import { PRESERVED_XML_LEVELS } from "../schema/nodes.js";
|
|
43
46
|
import { parseShapeGeometryAdjustments } from "../shapeGeometryAdjustments.js";
|
|
44
47
|
import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
|
|
48
|
+
import { textBoxHostParagraph } from "../textBoxHostParagraph.js";
|
|
45
49
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
46
50
|
import { hasSinkChildren } from "./preservedSinkCarriers.js";
|
|
47
51
|
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "./runShadingMark.js";
|
|
@@ -678,7 +682,7 @@ function isStillSyntheticFiller(blocks) {
|
|
|
678
682
|
}
|
|
679
683
|
function appendTextBoxBlock(blocks, node, options) {
|
|
680
684
|
const attrs = expectTextBoxAttrs(node);
|
|
681
|
-
|
|
685
|
+
let paragraph = convertPMTextBox(node, options.styleResolver);
|
|
682
686
|
const previousBlock = blocks.at(-1);
|
|
683
687
|
if (attrs._docxPlacement === "inlineWithPrevious" && previousBlock?.type === "paragraph") {
|
|
684
688
|
appendPageBreaks(previousBlock, options.pendingPageBreaks);
|
|
@@ -696,6 +700,12 @@ function appendTextBoxBlock(blocks, node, options) {
|
|
|
696
700
|
if (!mergeTextBoxIntoTrailingInlineSdts(options.previousStandaloneTextBox.paragraph, paragraph, attrs._docxInlineSdts ?? [])) options.previousStandaloneTextBox.paragraph.content.push(...paragraph.content);
|
|
697
701
|
return options.previousStandaloneTextBox;
|
|
698
702
|
}
|
|
703
|
+
const host = attrs._docxPlacement === "standalone" ? textBoxHostParagraph(node) : void 0;
|
|
704
|
+
if (host) {
|
|
705
|
+
const hostParagraph = convertPMParagraph(host, void 0, void 0, options.styleResolver);
|
|
706
|
+
hostParagraph.content = paragraph.content;
|
|
707
|
+
paragraph = hostParagraph;
|
|
708
|
+
}
|
|
699
709
|
if (attrs._docxPlacement === "standalone" && attrs._preservedAttributes?.length) paragraph.preservedAttributes = attrs._preservedAttributes;
|
|
700
710
|
prependPageBreaks(paragraph, options.pendingPageBreaks);
|
|
701
711
|
blocks.push(paragraph);
|
|
@@ -1043,7 +1053,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1043
1053
|
assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
|
|
1044
1054
|
if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
|
|
1045
1055
|
else delete result.spacingExplicit;
|
|
1046
|
-
const bidi = authoredParagraphValue("bidi",
|
|
1056
|
+
const bidi = authoredParagraphValue("bidi", directionToAuthoredBidi(attrs.direction), orig, attrs._resolvedFormatting);
|
|
1047
1057
|
if (bidi !== (orig.bidi ?? void 0)) if (bidi === void 0) delete result.bidi;
|
|
1048
1058
|
else result.bidi = bidi;
|
|
1049
1059
|
return result;
|
|
@@ -1051,7 +1061,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1051
1061
|
const resolved = attrs._resolvedFormatting;
|
|
1052
1062
|
const authored = (field, value) => authoredParagraphValue(field, value ?? void 0, void 0, resolved);
|
|
1053
1063
|
const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
|
|
1054
|
-
const bidi = authored("bidi",
|
|
1064
|
+
const bidi = authored("bidi", directionToAuthoredBidi(attrs.direction));
|
|
1055
1065
|
const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
|
|
1056
1066
|
const indentLeft = authored("indentLeft", attrs.indentLeft);
|
|
1057
1067
|
const indentRight = authored("indentRight", attrs.indentRight);
|
|
@@ -1343,6 +1353,7 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1343
1353
|
}
|
|
1344
1354
|
};
|
|
1345
1355
|
const appendDirectRun = (node, run, coalescePlainText = false) => {
|
|
1356
|
+
if (currentHyperlink) flushCurrentInline();
|
|
1346
1357
|
const marksKey = getMarksKey(node.marks);
|
|
1347
1358
|
const ownerId = runIdentityId(node);
|
|
1348
1359
|
const currentOwnerId = currentRun ? sourceRunOwners.get(currentRun) : void 0;
|
|
@@ -2255,6 +2266,7 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
|
|
|
2255
2266
|
};
|
|
2256
2267
|
if (attrs.fldLock !== void 0) complex.fldLock = attrs.fldLock;
|
|
2257
2268
|
if (attrs.dirty !== void 0) complex.dirty = attrs.dirty;
|
|
2269
|
+
if (attrs.fieldResultIsFallback !== void 0) complex.fieldResultIsFallback = attrs.fieldResultIsFallback;
|
|
2258
2270
|
return complex;
|
|
2259
2271
|
}
|
|
2260
2272
|
const simple = {
|
|
@@ -2317,21 +2329,21 @@ function createMathFromNode(node) {
|
|
|
2317
2329
|
return math;
|
|
2318
2330
|
}
|
|
2319
2331
|
/**
|
|
2320
|
-
* A revision
|
|
2332
|
+
* A revision that encloses a control, written around the control.
|
|
2321
2333
|
*
|
|
2322
2334
|
* `w:ins > w:sdt` and `w:sdt > w:ins` reach the editor as the same revision
|
|
2323
|
-
* mark on the same leaves
|
|
2324
|
-
*
|
|
2325
|
-
*
|
|
2326
|
-
*
|
|
2327
|
-
*
|
|
2335
|
+
* mark on the same leaves; the control's enclosing-revision record says which
|
|
2336
|
+
* one it was (`contentControlRevisions.ts`). A revision it names that still
|
|
2337
|
+
* covers every child goes outermost, the only form in which accepting or
|
|
2338
|
+
* rejecting the change is an operation over the whole control: the reader who
|
|
2339
|
+
* inserted a bound field inserted the field, not its text.
|
|
2328
2340
|
*
|
|
2329
|
-
*
|
|
2330
|
-
* where the editor holds it, per child.
|
|
2341
|
+
* Any other revision, including one over all of the content, revises the
|
|
2342
|
+
* content and stays where the editor holds it, per child.
|
|
2331
2343
|
*/
|
|
2332
|
-
const hoistUniformRevision = (sdt) => {
|
|
2344
|
+
const hoistUniformRevision = (sdt, enclosingIds) => {
|
|
2333
2345
|
const only = sdt.content.length === 1 ? sdt.content.at(0) : void 0;
|
|
2334
|
-
if (only === void 0 || !isRevisionWrapper(only)) return sdt;
|
|
2346
|
+
if (only === void 0 || !isRevisionWrapper(only) || !enclosingIds.includes(only.info.id)) return sdt;
|
|
2335
2347
|
const admitted = only.content.filter(isInlineSdtContent);
|
|
2336
2348
|
if (admitted.length !== only.content.length) return sdt;
|
|
2337
2349
|
return {
|
|
@@ -2352,7 +2364,7 @@ function createInlineSdtFromNode(node, textBoxAnchorMarkers, formattingContext)
|
|
|
2352
2364
|
type: "inlineSdt",
|
|
2353
2365
|
properties,
|
|
2354
2366
|
content
|
|
2355
|
-
});
|
|
2367
|
+
}, enclosingRevisionIds(node));
|
|
2356
2368
|
}
|
|
2357
2369
|
/**
|
|
2358
2370
|
* Create a Run containing an image
|
|
@@ -2481,6 +2493,17 @@ const drawingFromImageAttrs = (image, attrs) => {
|
|
|
2481
2493
|
default: return mode;
|
|
2482
2494
|
}
|
|
2483
2495
|
};
|
|
2496
|
+
const shapeContentFromNode = ({ node, shape, captured }) => {
|
|
2497
|
+
const xml = unchangedAlternateContentXml(node, captured);
|
|
2498
|
+
return xml === void 0 ? {
|
|
2499
|
+
type: "shape",
|
|
2500
|
+
shape
|
|
2501
|
+
} : {
|
|
2502
|
+
type: "shape",
|
|
2503
|
+
shape,
|
|
2504
|
+
alternateContent: refingerprintShapeAlternateContent(shape, xml)
|
|
2505
|
+
};
|
|
2506
|
+
};
|
|
2484
2507
|
/**
|
|
2485
2508
|
* Create a Run from a ProseMirror shape node
|
|
2486
2509
|
*/
|
|
@@ -2550,10 +2573,11 @@ function createShapeRun(node) {
|
|
|
2550
2573
|
if (attrs.outlineColor) shapeOutline.color = attrs.outlineColorValue ?? { rgb: attrs.outlineColor.replace("#", "") };
|
|
2551
2574
|
shape.outline = shapeOutline;
|
|
2552
2575
|
}
|
|
2553
|
-
const shapeContent = {
|
|
2554
|
-
|
|
2555
|
-
shape
|
|
2556
|
-
|
|
2576
|
+
const shapeContent = shapeContentFromNode({
|
|
2577
|
+
node,
|
|
2578
|
+
shape,
|
|
2579
|
+
captured: attrs._docxAlternateContent
|
|
2580
|
+
});
|
|
2557
2581
|
const run = {
|
|
2558
2582
|
type: "run",
|
|
2559
2583
|
...carriedRunFormatting(attrs._docxRunFormatting),
|
|
@@ -3576,6 +3600,7 @@ function convertPMTextBox(node, styleResolver = null) {
|
|
|
3576
3600
|
type: "solid",
|
|
3577
3601
|
color: { rgb: attrs.fillColor.replace("#", "") }
|
|
3578
3602
|
};
|
|
3603
|
+
else if (attrs.gradientFill?.gradient) shape.fill = structuredClone(attrs.gradientFill);
|
|
3579
3604
|
if (attrs.outlineStyle !== "none" && attrs.outlineWidth && attrs.outlineWidth > 0) {
|
|
3580
3605
|
const tbOutline = {
|
|
3581
3606
|
width: emuFromPixels(attrs.outlineWidth, "outlineWidth", authoredEmu, emuToStrokePixels),
|
|
@@ -3590,12 +3615,18 @@ function convertPMTextBox(node, styleResolver = null) {
|
|
|
3590
3615
|
if (position) shape.position = position;
|
|
3591
3616
|
const anchor = restoredDrawingAnchor(attrs.anchor);
|
|
3592
3617
|
if (anchor) shape.anchor = anchor;
|
|
3618
|
+
if (attrs._docxGroupChild) shape.groupChild = {
|
|
3619
|
+
path: [...attrs._docxGroupChild.path],
|
|
3620
|
+
group: attrs._docxGroupChild.group,
|
|
3621
|
+
content: attrs._docxGroupChild.content
|
|
3622
|
+
};
|
|
3593
3623
|
const run = {
|
|
3594
3624
|
type: "run",
|
|
3595
|
-
content: [{
|
|
3596
|
-
|
|
3597
|
-
shape
|
|
3598
|
-
|
|
3625
|
+
content: [shapeContentFromNode({
|
|
3626
|
+
node,
|
|
3627
|
+
shape,
|
|
3628
|
+
captured: attrs._docxAlternateContent
|
|
3629
|
+
})]
|
|
3599
3630
|
};
|
|
3600
3631
|
const trackedChange = attrs._docxTrackedChange;
|
|
3601
3632
|
const inlineSdts = attrs._docxInlineSdts ?? [];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MarkFactory } from "../extensions/marks/markUtils.js";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
//#region src/prosemirror/conversion/markInterner.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build marks that share one instance per distinct (type, attrs) value.
|
|
6
|
+
*
|
|
7
|
+
* A document repeats a small set of run formattings across thousands of runs,
|
|
8
|
+
* so one conversion builds each distinct mark once. Marks are immutable, and
|
|
9
|
+
* ProseMirror compares them by value, so sharing an instance changes nothing a
|
|
10
|
+
* caller can observe except the saved allocation. Create one interner per
|
|
11
|
+
* conversion; it holds every mark it built until it is dropped.
|
|
12
|
+
*
|
|
13
|
+
* The native JSON serialization is only a lookup key: it collapses values the
|
|
14
|
+
* mark would keep apart (`-0`, `NaN`, nested `undefined`), so a hit is shared
|
|
15
|
+
* only after an exact comparison, and a mismatch builds an unshared mark. A
|
|
16
|
+
* mark holding `NaN` is never shared: ProseMirror does not find two of them
|
|
17
|
+
* equal, and a shared instance would.
|
|
18
|
+
*/
|
|
19
|
+
declare const createMarkInterner: (schema: Schema) => MarkFactory;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { createMarkInterner };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
//#region src/prosemirror/conversion/markInterner.ts
|
|
3
|
+
/**
|
|
4
|
+
* Leaves ProseMirror compares with `===`, minus `-0`/`0`: sharing a mark makes
|
|
5
|
+
* `Mark.eq` take its identity shortcut, so two leaves may share only when
|
|
6
|
+
* ProseMirror would call them equal anyway. `NaN` never equals itself there.
|
|
7
|
+
*/
|
|
8
|
+
const sameLeaf = (left, right) => left === right && Object.is(left, right);
|
|
9
|
+
/**
|
|
10
|
+
* Whether two attr values are interchangeable: `sameLeaf` on leaves, and the
|
|
11
|
+
* same own keys in the same order, so `-0`/`0`, `NaN` and `undefined`/absent
|
|
12
|
+
* stay apart. Output follows the shared value's key order, which is why order
|
|
13
|
+
* counts.
|
|
14
|
+
*/
|
|
15
|
+
const sameAttrValue = (left, right) => {
|
|
16
|
+
if (sameLeaf(left, right)) return true;
|
|
17
|
+
if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
|
|
18
|
+
if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right)) return false;
|
|
19
|
+
if (Array.isArray(left)) {
|
|
20
|
+
if (!Array.isArray(right) || left.length !== right.length) return false;
|
|
21
|
+
for (let index = 0; index < left.length; index += 1) if (index in left !== index in right || !sameAttrValue(left[index], right[index])) return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const leftKeys = Object.keys(left);
|
|
25
|
+
const rightKeys = Object.keys(right);
|
|
26
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && sameAttrValue(Reflect.get(left, key), Reflect.get(right, key)));
|
|
27
|
+
};
|
|
28
|
+
const internedMark = (type, attrs) => {
|
|
29
|
+
const mark = type.create(attrs);
|
|
30
|
+
const nonDefault = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const [name, spec] of Object.entries(type.spec.attrs ?? {})) if (!sameLeaf(mark.attrs[name], spec.default)) nonDefault.add(name);
|
|
32
|
+
return {
|
|
33
|
+
mark,
|
|
34
|
+
nonDefault
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Whether `create(attrs)` would compute attrs interchangeable with the
|
|
39
|
+
* interned mark's. `create` fills every declared attr `attrs` leaves
|
|
40
|
+
* `undefined` from its default, so the given attrs must match each value they
|
|
41
|
+
* set and set every attr where the mark holds something else.
|
|
42
|
+
*/
|
|
43
|
+
const matchesInterned = (type, attrs, { mark, nonDefault }) => {
|
|
44
|
+
const specs = type.spec.attrs ?? {};
|
|
45
|
+
let covered = 0;
|
|
46
|
+
for (const name in attrs) {
|
|
47
|
+
const given = attrs[name];
|
|
48
|
+
if (given === void 0 || !Object.hasOwn(specs, name)) continue;
|
|
49
|
+
if (!sameAttrValue(given, mark.attrs[name])) return false;
|
|
50
|
+
if (nonDefault.has(name)) covered += 1;
|
|
51
|
+
}
|
|
52
|
+
return covered === nonDefault.size;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Build marks that share one instance per distinct (type, attrs) value.
|
|
56
|
+
*
|
|
57
|
+
* A document repeats a small set of run formattings across thousands of runs,
|
|
58
|
+
* so one conversion builds each distinct mark once. Marks are immutable, and
|
|
59
|
+
* ProseMirror compares them by value, so sharing an instance changes nothing a
|
|
60
|
+
* caller can observe except the saved allocation. Create one interner per
|
|
61
|
+
* conversion; it holds every mark it built until it is dropped.
|
|
62
|
+
*
|
|
63
|
+
* The native JSON serialization is only a lookup key: it collapses values the
|
|
64
|
+
* mark would keep apart (`-0`, `NaN`, nested `undefined`), so a hit is shared
|
|
65
|
+
* only after an exact comparison, and a mismatch builds an unshared mark. A
|
|
66
|
+
* mark holding `NaN` is never shared: ProseMirror does not find two of them
|
|
67
|
+
* equal, and a shared instance would.
|
|
68
|
+
*/
|
|
69
|
+
const createMarkInterner = (schema) => {
|
|
70
|
+
const marksByType = /* @__PURE__ */ new Map();
|
|
71
|
+
return (typeName, attrs) => {
|
|
72
|
+
const type = schema.marks[typeName];
|
|
73
|
+
if (type === void 0) panic(`Unknown mark type ${typeName}.`);
|
|
74
|
+
let marks = marksByType.get(type);
|
|
75
|
+
if (marks === void 0) {
|
|
76
|
+
marks = /* @__PURE__ */ new Map();
|
|
77
|
+
marksByType.set(type, marks);
|
|
78
|
+
}
|
|
79
|
+
const key = JSON.stringify(attrs ?? null);
|
|
80
|
+
const cached = marks.get(key);
|
|
81
|
+
if (cached === void 0) {
|
|
82
|
+
const interned = internedMark(type, attrs);
|
|
83
|
+
marks.set(key, interned);
|
|
84
|
+
return interned.mark;
|
|
85
|
+
}
|
|
86
|
+
return matchesInterned(type, attrs, cached) ? cached.mark : type.create(attrs);
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { createMarkInterner };
|