@stll/folio-core 0.52.0 → 0.54.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1779 -141
- package/dist/ai-edits/batch-claims.d.ts +145 -0
- package/dist/ai-edits/batch-claims.js +275 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +91 -7
- package/dist/ai-edits/headless.js +520 -51
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +6 -4
- package/dist/ai-edits/read.js +113 -50
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/revisionStretches.js +80 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +180 -25
- package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
- package/dist/ai-edits/table-cell-mutations.js +6 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
- package/dist/ai-edits/table-row-column-mutations.js +86 -34
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.d.ts +5 -1
- package/dist/compare/content-alignment.js +52 -34
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/inline-provenance.js +1 -1
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +65 -11
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/archiveInflation.d.ts +127 -0
- package/dist/docx/archiveInflation.js +181 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/metadataPrivacy.js +24 -1
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/noteReferenceMark.d.ts +15 -0
- package/dist/docx/noteReferenceMark.js +48 -0
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +96 -27
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +10 -2
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +175 -22
- package/dist/docx/rezip.js +31 -7
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.d.ts +3 -1
- package/dist/docx/selectiveXmlPatch.js +186 -39
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/boundedArchive.d.ts +8 -13
- package/dist/docx/server/boundedArchive.js +70 -59
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/server/extractDocxText.d.ts +8 -2
- package/dist/docx/server/extractDocxText.js +2 -2
- package/dist/docx/server/validateDocxConformance.d.ts +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -0
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +20 -2
- package/dist/docx/unzip.js +136 -25
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
- package/dist/i18n/messages/catalogs.gen.js +187 -51
- package/dist/i18n/messages/messages.gen.d.ts +10 -2
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +600 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureParagraph.js +2 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
- package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/escape.d.ts +2 -2
- package/dist/markdown/escape.js +4 -5
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +121 -25
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.d.ts +10 -1
- package/dist/markdown/renderRuns.js +323 -69
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/clearRunColor.d.ts +6 -0
- package/dist/prosemirror/clearRunColor.js +46 -0
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +281 -212
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.js +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/hyperlink.js +2 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
- package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
- package/dist/prosemirror/containerFinalParagraph.js +7 -6
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
- package/dist/prosemirror/conversion/toProseDoc.js +70 -154
- package/dist/prosemirror/documentSchema.d.ts +8 -0
- package/dist/prosemirror/documentSchema.js +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +5 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
- package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
- package/dist/prosemirror/extensions/types.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
- package/dist/prosemirror/hyperlinkRemoval.js +129 -0
- package/dist/prosemirror/index.d.ts +5 -3
- package/dist/prosemirror/index.js +5 -3
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +92 -0
- package/dist/prosemirror/listNumbering.js +330 -0
- package/dist/prosemirror/listRendering.d.ts +27 -0
- package/dist/prosemirror/listRendering.js +27 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewNotes.d.ts +8 -0
- package/dist/prosemirror/markupViewNotes.js +49 -0
- package/dist/prosemirror/markupViewProjection.d.ts +97 -0
- package/dist/prosemirror/markupViewProjection.js +88 -0
- package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
- package/dist/prosemirror/noteReferenceReview.js +332 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +32 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
- package/dist/prosemirror/paragraphMarkJoin.js +26 -0
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
- package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
- package/dist/prosemirror/plugins/documentStyleState.js +32 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
- package/dist/prosemirror/plugins/documentStyles.js +67 -17
- package/dist/prosemirror/plugins/index.d.ts +2 -1
- package/dist/prosemirror/plugins/index.js +2 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
- package/dist/prosemirror/plugins/suggestionMode.js +490 -63
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
- package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
- package/dist/prosemirror/runFormattingFromMarks.js +567 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -9
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +44 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
- package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
- package/dist/prosemirror/tableCellPaste.d.ts +74 -0
- package/dist/prosemirror/tableCellPaste.js +525 -0
- package/dist/prosemirror/tableGridMutation.d.ts +87 -2
- package/dist/prosemirror/tableGridMutation.js +255 -2
- package/dist/prosemirror/tableRunIn.d.ts +51 -0
- package/dist/prosemirror/tableRunIn.js +165 -0
- package/dist/prosemirror/textInput.js +11 -2
- package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
- package/dist/prosemirror/trackedRevisionPath.js +32 -0
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/server.d.ts +2 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +6 -5
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -13,11 +13,10 @@ import { createStyleEngine } from "../../style-engine/styleEngine.js";
|
|
|
13
13
|
import { normalizeShapeTextAnchor, presetDashForOutlineAttr } from "../../types/documentEnumValues.js";
|
|
14
14
|
import { presetDashForCssBorderStyle } from "../../utils/borderCss.js";
|
|
15
15
|
import { canonicalJson } from "../../utils/canonicalJson.js";
|
|
16
|
-
import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js";
|
|
17
16
|
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
18
17
|
import { emuToPixels, emuToStrokePixels, pixelsToEmu } from "../../utils/units.js";
|
|
19
18
|
import { unchangedAlternateContentXml } from "../alternateContentAttrs.js";
|
|
20
|
-
import {
|
|
19
|
+
import { expectBlockCustomXmlAttrs, expectBlockSdtAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectFieldAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTrackedChangeMarkAttrs } from "../attrs/index.js";
|
|
21
20
|
import { readAuthoredTransform } from "../authoredTransformAttrs.js";
|
|
22
21
|
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
23
22
|
import { bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
|
|
@@ -25,30 +24,29 @@ import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removePara
|
|
|
25
24
|
import { expectCommentReferenceAttrs } from "../commentReferenceAttrs.js";
|
|
26
25
|
import { enclosingRevisionIds } from "../contentControlRevisions.js";
|
|
27
26
|
import { INLINE_WRAPPER_MARK_NAME } from "../extensions/marks/InlineWrapperExtension.js";
|
|
28
|
-
import { applyRunFormattingOverrideAttrs, buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
|
|
29
27
|
import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
30
28
|
import "../extensions/nodes/MoveRangeBoundaryExtension.js";
|
|
31
29
|
import "../extensions/nodes/RangeAnchorExtension.js";
|
|
32
30
|
import { inlineWrapperMember, inlineWrapperStackKey } from "../inlineWrapperStack.js";
|
|
33
|
-
import {
|
|
31
|
+
import { completeNumberingForDoc } from "../listInstanceReferences.js";
|
|
32
|
+
import { hasListRendering, listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
|
|
34
33
|
import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
|
|
35
34
|
import { resolveNumberedRefFields } from "../numberedRefFields.js";
|
|
36
35
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
37
36
|
import { directionToAuthoredBidi } from "../paragraphDirection.js";
|
|
38
37
|
import { directParagraphSpacing } from "../paragraphSpacing.js";
|
|
39
38
|
import { expectRangeAnchorAttrs } from "../rangeAnchorAttrs.js";
|
|
39
|
+
import { marksToTextFormatting, sameFormattingValue } from "../runFormattingFromMarks.js";
|
|
40
40
|
import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
41
|
-
import { authoredRunFormattingFromAttrs, hasAuthoredRunFormattingProvenance } from "../runFormattingProvenance.js";
|
|
42
41
|
import { RUN_IDENTITY_MARK_NAME } from "../runIdentity.js";
|
|
43
|
-
import { paragraphFormattingForRun, paragraphRunStyleContext, resolveEffectiveRunStyleFormatting
|
|
44
|
-
import { schema } from "../schema/index.js";
|
|
42
|
+
import { paragraphFormattingForRun, paragraphRunStyleContext, resolveEffectiveRunStyleFormatting } from "../runStyleFormatting.js";
|
|
45
43
|
import { PRESERVED_XML_LEVELS } from "../schema/nodes.js";
|
|
46
44
|
import { parseShapeGeometryAdjustments } from "../shapeGeometryAdjustments.js";
|
|
47
45
|
import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
|
|
48
46
|
import { textBoxHostParagraph } from "../textBoxHostParagraph.js";
|
|
47
|
+
import { enclosingInsertionAncestors, inlineWrapperStackOf } from "../trackedRevisionPath.js";
|
|
49
48
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
50
49
|
import { hasSinkChildren } from "./preservedSinkCarriers.js";
|
|
51
|
-
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "./runShadingMark.js";
|
|
52
50
|
import { decodeSdtListItems, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs } from "./sdtAttrs.js";
|
|
53
51
|
import { panic } from "better-result";
|
|
54
52
|
import { DRAWING_RAW_XML_MODES, relationshipIdOf } from "@stll/docx-core/model";
|
|
@@ -280,18 +278,23 @@ function fromProseDoc(pmDoc, baseDocument, { reuse = "none" } = {}) {
|
|
|
280
278
|
if (baseDocument?.package.document.finalSectionProperties) documentBody.finalSectionProperties = baseDocument.package.document.finalSectionProperties;
|
|
281
279
|
if (baseDocument?.package.document.sections) documentBody.sections = baseDocument.package.document.sections;
|
|
282
280
|
if (baseDocument?.package.document.comments) documentBody.comments = baseDocument.package.document.comments;
|
|
281
|
+
const numbering = completeNumberingForDoc(baseDocument?.package.numbering, pmDoc);
|
|
283
282
|
if (baseDocument) {
|
|
284
283
|
const updatedDocument = {
|
|
285
284
|
...baseDocument,
|
|
286
285
|
package: {
|
|
287
286
|
...baseDocument.package,
|
|
288
|
-
document: documentBody
|
|
287
|
+
document: documentBody,
|
|
288
|
+
...numbering ? { numbering } : {}
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
copyDocumentParagraphPropertySourceContract(updatedDocument, baseDocument);
|
|
292
292
|
return updatedDocument;
|
|
293
293
|
}
|
|
294
|
-
return { package: {
|
|
294
|
+
return { package: {
|
|
295
|
+
document: documentBody,
|
|
296
|
+
...numbering ? { numbering } : {}
|
|
297
|
+
} };
|
|
295
298
|
}
|
|
296
299
|
const isSuggestedMark = (mark) => mark.attrs["provenance"] === "suggested";
|
|
297
300
|
const hasSuggestedInsertion = (marks) => marks.some((mark) => mark.type.name === "insertion" && isSuggestedMark(mark));
|
|
@@ -330,7 +333,7 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
330
333
|
styleResolver
|
|
331
334
|
}) : paragraphFormatting, previousFormatting);
|
|
332
335
|
next = next.filter((mark) => !RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
|
|
333
|
-
for (const restored of textFormattingToMarks(effectivePreviousFormatting, schema, {
|
|
336
|
+
for (const restored of textFormattingToMarks(effectivePreviousFormatting, suggestedRunPropertyChange.type.schema, {
|
|
334
337
|
overrideFormatting: previousFormatting,
|
|
335
338
|
directFormatting: previousFormatting
|
|
336
339
|
})) next = restored.addToSet(next);
|
|
@@ -341,12 +344,30 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
341
344
|
}
|
|
342
345
|
return next;
|
|
343
346
|
}
|
|
347
|
+
/** A paragraph's attrs without its suggested property changes, or `null` when it has none. */
|
|
348
|
+
function stripSuggestedParagraphPropertyChanges(node) {
|
|
349
|
+
const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
|
|
350
|
+
if (!Array.isArray(propertyChanges)) return null;
|
|
351
|
+
if (!propertyChanges.some(({ info }) => info.provenance === "suggested")) return null;
|
|
352
|
+
const removal = removeParagraphPropertyChanges(propertyChanges, ({ info }) => info.provenance === "suggested");
|
|
353
|
+
if (removal.type === "unchanged") return null;
|
|
354
|
+
const nextAttrs = {
|
|
355
|
+
...node.attrs,
|
|
356
|
+
_propertyChanges: removal.remaining.length > 0 ? removal.remaining : null
|
|
357
|
+
};
|
|
358
|
+
if (removal.type === "restore-previous") {
|
|
359
|
+
Object.assign(nextAttrs, paragraphRejectAttrPatch(removal.previousFormatting));
|
|
360
|
+
nextAttrs["_originalFormatting"] = paragraphRejectOriginalFormatting(removal.previousFormatting, nextAttrs["_originalFormatting"]);
|
|
361
|
+
}
|
|
362
|
+
return nextAttrs;
|
|
363
|
+
}
|
|
344
364
|
/**
|
|
345
365
|
* Compute the node attrs a block/structural node keeps once its suggested
|
|
346
366
|
* revision markers are neutralized. Returns `null` when nothing changes.
|
|
347
367
|
*
|
|
348
|
-
* - a suggested `trDel` / `cellMarker` (insertion or deletion)
|
|
349
|
-
* the
|
|
368
|
+
* - a suggested `trDel` / `cellMarker` (insertion or deletion) or paragraph
|
|
369
|
+
* mark revision (`pPrMark`) is cleared so the node serializes as though the
|
|
370
|
+
* proposed change never happened;
|
|
350
371
|
* merge markers never carry suggestion provenance (structurally excluded);
|
|
351
372
|
* - suggested INSERT markers are handled by the caller, which drops the whole
|
|
352
373
|
* node instead of clearing an attr.
|
|
@@ -356,20 +377,13 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
356
377
|
function stripSuggestedNodeAttrs(node) {
|
|
357
378
|
const name = node.type.name;
|
|
358
379
|
if (name === "paragraph") {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
if (!
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
...node.attrs,
|
|
366
|
-
_propertyChanges: removal.remaining.length > 0 ? removal.remaining : null
|
|
380
|
+
const stripped = stripSuggestedParagraphPropertyChanges(node);
|
|
381
|
+
const markInfo = expectParagraphAttrs(node).pPrMark?.info;
|
|
382
|
+
if (!(typeof markInfo === "object" && markInfo !== null && "provenance" in markInfo && markInfo.provenance === "suggested")) return stripped;
|
|
383
|
+
return {
|
|
384
|
+
...stripped ?? node.attrs,
|
|
385
|
+
pPrMark: null
|
|
367
386
|
};
|
|
368
|
-
if (removal.type === "restore-previous") {
|
|
369
|
-
Object.assign(nextAttrs, paragraphRejectAttrPatch(removal.previousFormatting));
|
|
370
|
-
nextAttrs["_originalFormatting"] = paragraphRejectOriginalFormatting(removal.previousFormatting, nextAttrs["_originalFormatting"]);
|
|
371
|
-
}
|
|
372
|
-
return nextAttrs;
|
|
373
387
|
}
|
|
374
388
|
if (name === "tableRow") {
|
|
375
389
|
const rowAttrs = expectTableRowAttrs(node);
|
|
@@ -536,10 +550,15 @@ function extractBlocks(inputDoc, refResolution = "resolve", styleResolver = null
|
|
|
536
550
|
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
537
551
|
blocks.push(convertPMBlockSdt(node, styleResolver));
|
|
538
552
|
previousStandaloneTextBox = null;
|
|
553
|
+
} else if (node.type.name === "blockCustomXml") {
|
|
554
|
+
blocks.push(convertPMBlockCustomXml(node, styleResolver));
|
|
555
|
+
previousStandaloneTextBox = null;
|
|
539
556
|
} else if (node.type.name === "preservedBlock") {
|
|
557
|
+
const { xml, readerText } = expectPreservedBlockAttrs(node);
|
|
540
558
|
blocks.push({
|
|
541
559
|
type: "preservedBlock",
|
|
542
|
-
xml
|
|
560
|
+
xml,
|
|
561
|
+
...readerText === void 0 ? {} : { readerText }
|
|
543
562
|
});
|
|
544
563
|
previousStandaloneTextBox = null;
|
|
545
564
|
} else if (node.type.name === "blockBookmarkBoundary") {
|
|
@@ -669,6 +688,16 @@ function convertPMBlockSdt(node, styleResolver) {
|
|
|
669
688
|
content: attrs._originallyEmpty === true && isStillSyntheticFiller(extracted) ? [] : extracted
|
|
670
689
|
};
|
|
671
690
|
}
|
|
691
|
+
function convertPMBlockCustomXml(node, styleResolver) {
|
|
692
|
+
const { openingXml, closingXml, _originallyEmpty } = expectBlockCustomXmlAttrs(node);
|
|
693
|
+
const extracted = extractBlocks(node.type.schema.node("doc", null, node.content), "inherit", styleResolver);
|
|
694
|
+
return {
|
|
695
|
+
type: "blockCustomXml",
|
|
696
|
+
openingXml,
|
|
697
|
+
closingXml,
|
|
698
|
+
content: _originallyEmpty === true && isStillSyntheticFiller(extracted) ? [] : extracted
|
|
699
|
+
};
|
|
700
|
+
}
|
|
672
701
|
function isStillSyntheticFiller(blocks) {
|
|
673
702
|
if (blocks.length !== 1) return false;
|
|
674
703
|
const block = blocks[0];
|
|
@@ -776,7 +805,7 @@ function replaceTextBoxAnchorInBlocks(blocks, marker, textBoxRun) {
|
|
|
776
805
|
for (const row of block.rows) for (const cell of row.cells) if (replaceTextBoxAnchorInBlocks(cell.content, marker, textBoxRun)) return true;
|
|
777
806
|
continue;
|
|
778
807
|
}
|
|
779
|
-
if (block.type !== "blockSdt") continue;
|
|
808
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
780
809
|
if (replaceTextBoxAnchorInBlocks(block.content, marker, textBoxRun)) return true;
|
|
781
810
|
}
|
|
782
811
|
return false;
|
|
@@ -845,7 +874,7 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
|
|
|
845
874
|
for (const row of block.rows) for (const cell of row.cells) if (removeTextBoxAnchorFromBlocks(cell.content, marker)) return true;
|
|
846
875
|
continue;
|
|
847
876
|
}
|
|
848
|
-
if (block.type !== "blockSdt") continue;
|
|
877
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
849
878
|
if (removeTextBoxAnchorFromBlocks(block.content, marker)) return true;
|
|
850
879
|
}
|
|
851
880
|
return false;
|
|
@@ -859,7 +888,7 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
|
|
|
859
888
|
function listRenderingFromAttrs(attrs) {
|
|
860
889
|
const numId = paragraphNumberingReferenceId$1(attrs.numPr);
|
|
861
890
|
if (numId === void 0) return;
|
|
862
|
-
if (!(attrs
|
|
891
|
+
if (!hasListRendering(attrs)) return;
|
|
863
892
|
return listRenderingFromAttrs$1({
|
|
864
893
|
attrs,
|
|
865
894
|
numId
|
|
@@ -989,6 +1018,35 @@ function assignBooleanToggle(result, attrs, orig, key) {
|
|
|
989
1018
|
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
990
1019
|
else result[key] = value;
|
|
991
1020
|
}
|
|
1021
|
+
const PARAGRAPH_INDENTATION_VALUE_FIELDS = [
|
|
1022
|
+
"indentLeft",
|
|
1023
|
+
"indentRight",
|
|
1024
|
+
"indentFirstLine"
|
|
1025
|
+
];
|
|
1026
|
+
/**
|
|
1027
|
+
* `w:ind` as the paragraph states it now.
|
|
1028
|
+
*
|
|
1029
|
+
* An indentation command edits the attrs and leaves `_originalFormatting`
|
|
1030
|
+
* alone, so a paragraph that arrived with any `w:pPr` of its own saved its
|
|
1031
|
+
* source indentation whatever the editor showed. A field the source stated is
|
|
1032
|
+
* written at its current value; one it did not is written only when the style
|
|
1033
|
+
* cascade does not already supply that value, as for a paragraph without
|
|
1034
|
+
* `_originalFormatting`.
|
|
1035
|
+
*/
|
|
1036
|
+
function assignParagraphIndentation(result, attrs, orig) {
|
|
1037
|
+
let changed = false;
|
|
1038
|
+
for (const key of PARAGRAPH_INDENTATION_VALUE_FIELDS) {
|
|
1039
|
+
const value = authoredParagraphValue(key, attrs[key] ?? void 0, orig, attrs._resolvedFormatting);
|
|
1040
|
+
if (value === (orig[key] ?? void 0)) continue;
|
|
1041
|
+
changed = true;
|
|
1042
|
+
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
1043
|
+
else result[key] = value;
|
|
1044
|
+
}
|
|
1045
|
+
const hanging = result.indentFirstLine !== void 0 && attrs.hangingIndent === true;
|
|
1046
|
+
if (!changed && hanging === (orig.hangingIndent === true)) return;
|
|
1047
|
+
if (hanging) result.hangingIndent = true;
|
|
1048
|
+
else Reflect.deleteProperty(result, "hangingIndent");
|
|
1049
|
+
}
|
|
992
1050
|
function paragraphAttrsToFormatting(attrs) {
|
|
993
1051
|
const directAlignment = directParagraphAlignment(attrs);
|
|
994
1052
|
const directSpacing = directParagraphSpacing(attrs);
|
|
@@ -1042,6 +1100,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1042
1100
|
}
|
|
1043
1101
|
if (attrs.styleId !== (orig.styleId ?? void 0)) if (attrs.styleId) result.styleId = attrs.styleId;
|
|
1044
1102
|
else delete result.styleId;
|
|
1103
|
+
assignParagraphIndentation(result, attrs, orig);
|
|
1045
1104
|
assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
|
|
1046
1105
|
assignBooleanToggle(result, attrs, orig, "widowControl");
|
|
1047
1106
|
assignBooleanToggle(result, attrs, orig, "keepNext");
|
|
@@ -1063,9 +1122,11 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1063
1122
|
const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
|
|
1064
1123
|
const bidi = authored("bidi", directionToAuthoredBidi(attrs.direction));
|
|
1065
1124
|
const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
|
|
1066
|
-
const
|
|
1125
|
+
const numbered = paragraphNumberingReferenceId$1(attrs.numPr ?? void 0) !== void 0;
|
|
1126
|
+
const statedIndent = (value) => value === 0 && !numbered ? void 0 : value;
|
|
1127
|
+
const indentLeft = statedIndent(authored("indentLeft", attrs.indentLeft));
|
|
1067
1128
|
const indentRight = authored("indentRight", attrs.indentRight);
|
|
1068
|
-
const indentFirstLine = authored("indentFirstLine", attrs.indentFirstLine);
|
|
1129
|
+
const indentFirstLine = statedIndent(authored("indentFirstLine", attrs.indentFirstLine));
|
|
1069
1130
|
const borders = authored("borders", attrs.borders);
|
|
1070
1131
|
const shading = authored("shading", attrs.shading);
|
|
1071
1132
|
const tabs = authored("tabs", attrs.tabs);
|
|
@@ -1078,7 +1139,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1078
1139
|
const kinsoku = authored("kinsoku", attrs.kinsoku);
|
|
1079
1140
|
const overflowPunctuation = authored("overflowPunctuation", attrs.overflowPunctuation);
|
|
1080
1141
|
const suppressAutoHyphens = authored("suppressAutoHyphens", attrs.suppressAutoHyphens);
|
|
1081
|
-
if (!(directAlignment !== void 0 || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || hasDirectLineSpacing || hasDirectLineSpacingRule || snapToGrid != null || indentLeft || indentRight || indentFirstLine || attrs.numPr || attrs.styleId || borders || shading || tabs || outlineLevel !== void 0 || contextualSpacing || attrs.spacingExplicit || bidi != null || pageBreakBefore != null || widowControl != null || keepNext != null || keepLines != null || runInWithNext != null || kinsoku != null || overflowPunctuation != null || suppressAutoHyphens != null)) return;
|
|
1142
|
+
if (!(directAlignment !== void 0 || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || hasDirectLineSpacing || hasDirectLineSpacingRule || snapToGrid != null || indentLeft !== void 0 || indentRight || indentFirstLine !== void 0 || attrs.numPr || attrs.styleId || borders || shading || tabs || outlineLevel !== void 0 || contextualSpacing || attrs.spacingExplicit || bidi != null || pageBreakBefore != null || widowControl != null || keepNext != null || keepLines != null || runInWithNext != null || kinsoku != null || overflowPunctuation != null || suppressAutoHyphens != null)) return;
|
|
1082
1143
|
const f = {};
|
|
1083
1144
|
if (directAlignment !== void 0) f.alignment = directAlignment;
|
|
1084
1145
|
if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
|
|
@@ -1089,9 +1150,9 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1089
1150
|
if (hasDirectLineSpacingRule && attrs.lineSpacingRule) f.lineSpacingRule = attrs.lineSpacingRule;
|
|
1090
1151
|
if (snapToGrid != null) f.snapToGrid = snapToGrid;
|
|
1091
1152
|
if (attrs.spacingExplicit) f.spacingExplicit = attrs.spacingExplicit;
|
|
1092
|
-
if (indentLeft) f.indentLeft = indentLeft;
|
|
1153
|
+
if (indentLeft !== void 0) f.indentLeft = indentLeft;
|
|
1093
1154
|
if (indentRight) f.indentRight = indentRight;
|
|
1094
|
-
if (indentFirstLine) f.indentFirstLine = indentFirstLine;
|
|
1155
|
+
if (indentFirstLine !== void 0) f.indentFirstLine = indentFirstLine;
|
|
1095
1156
|
if (attrs.hangingIndent && indentFirstLine) f.hangingIndent = attrs.hangingIndent;
|
|
1096
1157
|
if (attrs.numPr !== void 0 && !isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) f.numPr = attrs.numPr;
|
|
1097
1158
|
if (attrs.styleId) f.styleId = attrs.styleId;
|
|
@@ -1143,11 +1204,6 @@ function createTrackedRunWrapper(type, info, child) {
|
|
|
1143
1204
|
* document each time the same one is saved.
|
|
1144
1205
|
*/
|
|
1145
1206
|
const byCommentId = (ids) => [...ids].toSorted((a, b) => a - b);
|
|
1146
|
-
/** The wrappers `node` sits inside, outermost first; empty when it sits in none. */
|
|
1147
|
-
const inlineWrapperStackOf = (node) => {
|
|
1148
|
-
const mark = node.marks.find((candidate) => candidate.type.name === INLINE_WRAPPER_MARK_NAME);
|
|
1149
|
-
return mark ? expectInlineWrapperMarkAttrs(mark).stack : [];
|
|
1150
|
-
};
|
|
1151
1207
|
/** The authored hyperlink that owns a suffix of the node's wrapper stack. */
|
|
1152
1208
|
const inlineWrapperHyperlinkOriginOf = (node) => {
|
|
1153
1209
|
const mark = node.marks.find((candidate) => candidate.type.name === INLINE_WRAPPER_MARK_NAME);
|
|
@@ -1505,9 +1561,14 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1505
1561
|
}
|
|
1506
1562
|
if (insertionMark || deletionMark) {
|
|
1507
1563
|
flushCurrentInline();
|
|
1508
|
-
const changeMark =
|
|
1564
|
+
const changeMark = deletionMark ?? insertionMark;
|
|
1509
1565
|
if (!changeMark) return;
|
|
1510
1566
|
const changeAttrs = expectTrackedChangeMarkAttrs(changeMark);
|
|
1567
|
+
const revisionAncestors = enclosingInsertionAncestors({
|
|
1568
|
+
insertionMark: deletionMark ? insertionMark : void 0,
|
|
1569
|
+
ancestors: changeAttrs._docxRevisionAncestors ?? [],
|
|
1570
|
+
node
|
|
1571
|
+
});
|
|
1511
1572
|
const otherMarks = node.marks.filter((m) => m.type.name !== "insertion" && m.type.name !== "deletion");
|
|
1512
1573
|
const info = {
|
|
1513
1574
|
id: changeAttrs.revisionId,
|
|
@@ -1520,17 +1581,17 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1520
1581
|
};
|
|
1521
1582
|
if (changeAttrs.initials) info.initials = changeAttrs.initials;
|
|
1522
1583
|
let type;
|
|
1523
|
-
if (insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
|
|
1584
|
+
if (changeMark === insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
|
|
1524
1585
|
else type = changeAttrs.moveKind === "moveFrom" ? "moveFrom" : "deletion";
|
|
1525
1586
|
const outerWrapperCount = changeAttrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length;
|
|
1526
|
-
const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(
|
|
1587
|
+
const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(revisionAncestors)}`;
|
|
1527
1588
|
if (linkMark) {
|
|
1528
1589
|
const linkKey = getLinkKey(linkMark);
|
|
1529
1590
|
if (!currentTrackedChange || currentTrackedChange.type !== "hyperlink" || currentTrackedChange.key !== trackedChangeKey || currentTrackedChange.hyperlinkKey !== linkKey) {
|
|
1530
1591
|
const hyperlink = createIndexedHyperlink(linkMark);
|
|
1531
1592
|
const wrapper = createTrackedRunWrapper(type, info, hyperlink);
|
|
1532
1593
|
revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
|
|
1533
|
-
revisionAncestorsByWrapper.set(wrapper,
|
|
1594
|
+
revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
|
|
1534
1595
|
content.push(wrapper);
|
|
1535
1596
|
currentTrackedChange = {
|
|
1536
1597
|
type: "hyperlink",
|
|
@@ -1565,7 +1626,7 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1565
1626
|
if (!currentTrackedChange || currentTrackedChange.type !== "direct" || currentTrackedChange.key !== trackedChangeKey) {
|
|
1566
1627
|
const wrapper = createTrackedRunWrapper(type, info);
|
|
1567
1628
|
revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
|
|
1568
|
-
revisionAncestorsByWrapper.set(wrapper,
|
|
1629
|
+
revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
|
|
1569
1630
|
content.push(wrapper);
|
|
1570
1631
|
currentTrackedChange = {
|
|
1571
1632
|
type: "direct",
|
|
@@ -2255,18 +2316,19 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
|
|
|
2255
2316
|
};
|
|
2256
2317
|
if (marks && node.type.name === "field") restoreRunRecord(displayRun, marks);
|
|
2257
2318
|
const fieldContent = extractedContent.length > 0 ? synchronizeFieldDisplayText(extractedContent, displayText, displayRun) : [];
|
|
2258
|
-
const fallbackFieldContent = displayText ? [displayRun] :
|
|
2319
|
+
const fallbackFieldContent = displayText ? [displayRun] : reconcileEmptyFieldResultRuns(attrs._docxEmptyResultRuns, displayRun);
|
|
2259
2320
|
if (attrs.fieldKind === "complex") {
|
|
2260
2321
|
const complex = {
|
|
2261
2322
|
type: "complexField",
|
|
2262
2323
|
instruction: attrs.instruction,
|
|
2263
2324
|
fieldType: attrs.fieldType,
|
|
2264
|
-
fieldCode: [],
|
|
2325
|
+
fieldCode: attrs._docxFieldCode?.instruction === attrs.instruction ? attrs._docxFieldCode.runs : [],
|
|
2265
2326
|
fieldResult: fieldContent.length > 0 ? fieldContent.filter((content) => content.type === "run") : fallbackFieldContent
|
|
2266
2327
|
};
|
|
2267
2328
|
if (attrs.fldLock !== void 0) complex.fldLock = attrs.fldLock;
|
|
2268
2329
|
if (attrs.dirty !== void 0) complex.dirty = attrs.dirty;
|
|
2269
2330
|
if (attrs.fieldResultIsFallback !== void 0) complex.fieldResultIsFallback = attrs.fieldResultIsFallback;
|
|
2331
|
+
if (attrs.formFieldDataXml !== void 0) complex.formFieldDataXml = attrs.formFieldDataXml;
|
|
2270
2332
|
return complex;
|
|
2271
2333
|
}
|
|
2272
2334
|
const simple = {
|
|
@@ -2279,6 +2341,48 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
|
|
|
2279
2341
|
if (attrs.dirty !== void 0) simple.dirty = attrs.dirty;
|
|
2280
2342
|
return simple;
|
|
2281
2343
|
}
|
|
2344
|
+
const reconcileEmptyFieldResultRuns = (runs, displayRun) => {
|
|
2345
|
+
if (!runs?.length) return [];
|
|
2346
|
+
const firstFormatting = runs.findIndex((run) => run.formatting !== void 0);
|
|
2347
|
+
const formattingOwner = firstFormatting < 0 ? 0 : firstFormatting;
|
|
2348
|
+
const projectedChanges = displayRun.propertyChanges ?? [];
|
|
2349
|
+
const projectedById = /* @__PURE__ */ new Map();
|
|
2350
|
+
projectedChanges.forEach((change, index) => {
|
|
2351
|
+
const positions = projectedById.get(change.info.id) ?? [];
|
|
2352
|
+
positions.push(index);
|
|
2353
|
+
projectedById.set(change.info.id, positions);
|
|
2354
|
+
});
|
|
2355
|
+
const usedChanges = /* @__PURE__ */ new Set();
|
|
2356
|
+
const reconciled = runs.map((run, index) => {
|
|
2357
|
+
const propertyChanges = run.propertyChanges?.flatMap((change) => {
|
|
2358
|
+
const projectedIndex = projectedById.get(change.info.id)?.shift();
|
|
2359
|
+
if (projectedIndex === void 0) return [];
|
|
2360
|
+
usedChanges.add(projectedIndex);
|
|
2361
|
+
const projected = projectedChanges[projectedIndex];
|
|
2362
|
+
return projected ? [projected] : [];
|
|
2363
|
+
});
|
|
2364
|
+
if (index !== formattingOwner && !run.propertyChanges && index !== 0) return run;
|
|
2365
|
+
let formatting = index === formattingOwner ? displayRun.formatting : run.formatting;
|
|
2366
|
+
if (index === formattingOwner && !formatting && run.formatting && Object.keys(run.formatting).length === 0) formatting = run.formatting;
|
|
2367
|
+
const preservedAttributes = index === 0 ? displayRun.preservedAttributes ?? run.preservedAttributes : run.preservedAttributes;
|
|
2368
|
+
return {
|
|
2369
|
+
type: "run",
|
|
2370
|
+
content: run.content,
|
|
2371
|
+
...formatting ? { formatting } : {},
|
|
2372
|
+
...propertyChanges?.length ? { propertyChanges } : {},
|
|
2373
|
+
...preservedAttributes ? { preservedAttributes } : {}
|
|
2374
|
+
};
|
|
2375
|
+
});
|
|
2376
|
+
const newChanges = projectedChanges.filter((_, index) => !usedChanges.has(index));
|
|
2377
|
+
if (newChanges.length > 0) {
|
|
2378
|
+
const first = reconciled[0];
|
|
2379
|
+
if (first) reconciled[0] = {
|
|
2380
|
+
...first,
|
|
2381
|
+
propertyChanges: [...first.propertyChanges ?? [], ...newChanges]
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
return reconciled;
|
|
2385
|
+
};
|
|
2282
2386
|
const synchronizeFieldDisplayText = (content, displayText, fallbackRun) => {
|
|
2283
2387
|
let currentText = "";
|
|
2284
2388
|
const visitRunsIn = (items, visit) => {
|
|
@@ -2586,563 +2690,6 @@ function createShapeRun(node) {
|
|
|
2586
2690
|
restoreRunRecord(run, node.marks);
|
|
2587
2691
|
return run;
|
|
2588
2692
|
}
|
|
2589
|
-
const RUN_FORMATTING_VISUAL_GROUPS = {
|
|
2590
|
-
bold: "bold",
|
|
2591
|
-
boldCs: null,
|
|
2592
|
-
italic: "italic",
|
|
2593
|
-
italicCs: null,
|
|
2594
|
-
underline: "underline",
|
|
2595
|
-
strike: "strike",
|
|
2596
|
-
doubleStrike: "strike",
|
|
2597
|
-
vertAlign: "vertAlign",
|
|
2598
|
-
smallCaps: "smallCaps",
|
|
2599
|
-
allCaps: "allCaps",
|
|
2600
|
-
hidden: "hidden",
|
|
2601
|
-
noProof: null,
|
|
2602
|
-
color: "color",
|
|
2603
|
-
highlight: "highlight",
|
|
2604
|
-
shading: "shading",
|
|
2605
|
-
fontSize: "fontSize",
|
|
2606
|
-
fontSizeCs: null,
|
|
2607
|
-
fontFamily: "fontFamily",
|
|
2608
|
-
language: "language",
|
|
2609
|
-
spacing: "characterSpacing",
|
|
2610
|
-
position: "characterSpacing",
|
|
2611
|
-
scale: "characterSpacing",
|
|
2612
|
-
kerning: "characterSpacing",
|
|
2613
|
-
effect: "effect",
|
|
2614
|
-
emphasisMark: "emphasisMark",
|
|
2615
|
-
emboss: "emboss",
|
|
2616
|
-
imprint: "imprint",
|
|
2617
|
-
outline: "outline",
|
|
2618
|
-
shadow: "shadow",
|
|
2619
|
-
rtl: "rtl",
|
|
2620
|
-
cs: null,
|
|
2621
|
-
styleId: null,
|
|
2622
|
-
preserved: null
|
|
2623
|
-
};
|
|
2624
|
-
const RUN_FORMATTING_FAST_PATH_DISPOSITION = {
|
|
2625
|
-
bold: "visual",
|
|
2626
|
-
boldCs: "structural",
|
|
2627
|
-
italic: "visual",
|
|
2628
|
-
italicCs: "structural",
|
|
2629
|
-
underline: "visual",
|
|
2630
|
-
strike: "visual",
|
|
2631
|
-
doubleStrike: "visual",
|
|
2632
|
-
vertAlign: "visual",
|
|
2633
|
-
smallCaps: "visual",
|
|
2634
|
-
allCaps: "visual",
|
|
2635
|
-
hidden: "visual",
|
|
2636
|
-
noProof: "structural",
|
|
2637
|
-
color: "visual",
|
|
2638
|
-
highlight: "visual",
|
|
2639
|
-
shading: "visual",
|
|
2640
|
-
fontSize: "visual",
|
|
2641
|
-
fontSizeCs: "structural",
|
|
2642
|
-
fontFamily: "visual",
|
|
2643
|
-
language: "visual",
|
|
2644
|
-
spacing: "visual",
|
|
2645
|
-
position: "visual",
|
|
2646
|
-
scale: "visual",
|
|
2647
|
-
kerning: "visual",
|
|
2648
|
-
effect: "visual",
|
|
2649
|
-
emphasisMark: "visual",
|
|
2650
|
-
emboss: "visual",
|
|
2651
|
-
imprint: "visual",
|
|
2652
|
-
outline: "visual",
|
|
2653
|
-
shadow: "visual",
|
|
2654
|
-
rtl: "visual",
|
|
2655
|
-
cs: "structural",
|
|
2656
|
-
styleId: "character-style",
|
|
2657
|
-
preserved: "structural"
|
|
2658
|
-
};
|
|
2659
|
-
const hasOnlyCarrierlessVisualFormatting = (formatting) => {
|
|
2660
|
-
for (const property of Object.keys(formatting)) if (RUN_FORMATTING_FAST_PATH_DISPOSITION[property] !== "visual") return false;
|
|
2661
|
-
return true;
|
|
2662
|
-
};
|
|
2663
|
-
const visibleUnderline = (formatting) => {
|
|
2664
|
-
const underline = formatting?.underline;
|
|
2665
|
-
return underline?.style === "none" ? void 0 : underline;
|
|
2666
|
-
};
|
|
2667
|
-
const visibleStrike = (formatting) => {
|
|
2668
|
-
if (formatting?.doubleStrike === true) return "double";
|
|
2669
|
-
return formatting?.strike === true ? "single" : void 0;
|
|
2670
|
-
};
|
|
2671
|
-
const visibleColor = (formatting) => formatting?.color?.auto === true ? void 0 : formatting?.color;
|
|
2672
|
-
const visibleValue = (value) => value === "none" ? void 0 : value;
|
|
2673
|
-
/**
|
|
2674
|
-
* Compare the exact presentation encoded by PM run marks without allocating the
|
|
2675
|
-
* intermediate maps used by reconciliation. Non-visual authored state is
|
|
2676
|
-
* deliberately absent here: the carrierless fast path below excludes every
|
|
2677
|
-
* structural carrier before calling this predicate.
|
|
2678
|
-
*/
|
|
2679
|
-
const sameVisualFormatting = (left, right) => {
|
|
2680
|
-
if (left?.bold === true !== (right?.bold === true) || left?.italic === true !== (right?.italic === true) || !sameFormattingValue(visibleUnderline(left), visibleUnderline(right)) || visibleStrike(left) !== visibleStrike(right) || !sameFormattingValue(visibleColor(left), visibleColor(right)) || visibleValue(left?.highlight) !== visibleValue(right?.highlight) || (left?.fontSize || void 0) !== (right?.fontSize || void 0) || !sameFormattingValue(left?.fontFamily, right?.fontFamily) || !sameFormattingValue(left?.language, right?.language) || (left?.vertAlign === "superscript" || left?.vertAlign === "subscript" ? left.vertAlign : void 0) !== (right?.vertAlign === "superscript" || right?.vertAlign === "subscript" ? right.vertAlign : void 0) || left?.allCaps === true !== (right?.allCaps === true) || left?.smallCaps === true !== (right?.smallCaps === true) || left?.hidden === true !== (right?.hidden === true) || left?.emboss === true !== (right?.emboss === true) || left?.imprint === true !== (right?.imprint === true) || left?.shadow === true !== (right?.shadow === true) || left?.outline === true !== (right?.outline === true) || left?.rtl === true !== (right?.rtl === true) || (typeof left?.spacing === "number" ? left.spacing : null) !== (typeof right?.spacing === "number" ? right.spacing : null) || (typeof left?.position === "number" ? left.position : null) !== (typeof right?.position === "number" ? right.position : null) || (normalizeHorizontalScalePercent(left?.scale) ?? null) !== (normalizeHorizontalScalePercent(right?.scale) ?? null) || (typeof left?.kerning === "number" ? left.kerning : null) !== (typeof right?.kerning === "number" ? right.kerning : null) || visibleValue(left?.effect) !== visibleValue(right?.effect) || visibleValue(left?.emphasisMark) !== visibleValue(right?.emphasisMark)) return false;
|
|
2681
|
-
return sameFormattingValue(shadingToRunShadingAttrs(left?.shading), shadingToRunShadingAttrs(right?.shading));
|
|
2682
|
-
};
|
|
2683
|
-
const visualFormattingGroups = (formatting) => {
|
|
2684
|
-
const groups = /* @__PURE__ */ new Map();
|
|
2685
|
-
if (!formatting) return groups;
|
|
2686
|
-
if (formatting.bold) groups.set("bold", true);
|
|
2687
|
-
if (formatting.italic) groups.set("italic", true);
|
|
2688
|
-
if (formatting.underline && formatting.underline.style !== "none") groups.set("underline", {
|
|
2689
|
-
style: formatting.underline.style || "single",
|
|
2690
|
-
...formatting.underline.color ? { color: formatting.underline.color } : {}
|
|
2691
|
-
});
|
|
2692
|
-
if (formatting.strike || formatting.doubleStrike) groups.set("strike", formatting.doubleStrike ? "double" : "single");
|
|
2693
|
-
if (formatting.color && !formatting.color.auto) {
|
|
2694
|
-
const { rgb, themeColor, themeTint, themeShade } = formatting.color;
|
|
2695
|
-
groups.set("color", {
|
|
2696
|
-
...rgb ? { rgb } : {},
|
|
2697
|
-
...themeColor ? { themeColor } : {},
|
|
2698
|
-
...themeTint ? { themeTint } : {},
|
|
2699
|
-
...themeShade ? { themeShade } : {}
|
|
2700
|
-
});
|
|
2701
|
-
}
|
|
2702
|
-
if (formatting.highlight && formatting.highlight !== "none") groups.set("highlight", formatting.highlight);
|
|
2703
|
-
const shadingAttrs = shadingToRunShadingAttrs(formatting.shading);
|
|
2704
|
-
if (shadingAttrs) groups.set("shading", runShadingAttrsToShading(shadingAttrs));
|
|
2705
|
-
if (formatting.fontSize) groups.set("fontSize", formatting.fontSize);
|
|
2706
|
-
if (formatting.fontFamily) {
|
|
2707
|
-
const { ascii, hAnsi, eastAsia, cs, hint, asciiTheme, hAnsiTheme, eastAsiaTheme, csTheme } = formatting.fontFamily;
|
|
2708
|
-
groups.set("fontFamily", {
|
|
2709
|
-
...ascii ? { ascii } : {},
|
|
2710
|
-
...hAnsi ? { hAnsi } : {},
|
|
2711
|
-
...eastAsia ? { eastAsia } : {},
|
|
2712
|
-
...cs ? { cs } : {},
|
|
2713
|
-
...hint ? { hint } : {},
|
|
2714
|
-
...asciiTheme ? { asciiTheme } : {},
|
|
2715
|
-
...hAnsiTheme ? { hAnsiTheme } : {},
|
|
2716
|
-
...eastAsiaTheme ? { eastAsiaTheme } : {},
|
|
2717
|
-
...csTheme ? { csTheme } : {}
|
|
2718
|
-
});
|
|
2719
|
-
}
|
|
2720
|
-
if (formatting.language) {
|
|
2721
|
-
const { val, eastAsia, bidi } = formatting.language;
|
|
2722
|
-
groups.set("language", {
|
|
2723
|
-
...val ? { val } : {},
|
|
2724
|
-
...eastAsia ? { eastAsia } : {},
|
|
2725
|
-
...bidi ? { bidi } : {}
|
|
2726
|
-
});
|
|
2727
|
-
}
|
|
2728
|
-
if (formatting.vertAlign === "superscript" || formatting.vertAlign === "subscript") groups.set("vertAlign", formatting.vertAlign);
|
|
2729
|
-
for (const [property, group] of [
|
|
2730
|
-
["allCaps", "allCaps"],
|
|
2731
|
-
["smallCaps", "smallCaps"],
|
|
2732
|
-
["hidden", "hidden"],
|
|
2733
|
-
["emboss", "emboss"],
|
|
2734
|
-
["imprint", "imprint"],
|
|
2735
|
-
["shadow", "shadow"],
|
|
2736
|
-
["outline", "outline"],
|
|
2737
|
-
["rtl", "rtl"]
|
|
2738
|
-
]) if (formatting[property]) groups.set(group, true);
|
|
2739
|
-
const spacing = typeof formatting.spacing === "number" ? formatting.spacing : null;
|
|
2740
|
-
const position = typeof formatting.position === "number" ? formatting.position : null;
|
|
2741
|
-
const scale = normalizeHorizontalScalePercent(formatting.scale) ?? null;
|
|
2742
|
-
const kerning = typeof formatting.kerning === "number" ? formatting.kerning : null;
|
|
2743
|
-
if (spacing !== null || position !== null || scale !== null || kerning !== null) groups.set("characterSpacing", {
|
|
2744
|
-
spacing,
|
|
2745
|
-
position,
|
|
2746
|
-
scale,
|
|
2747
|
-
kerning
|
|
2748
|
-
});
|
|
2749
|
-
if (formatting.effect && formatting.effect !== "none") groups.set("effect", formatting.effect);
|
|
2750
|
-
if (formatting.emphasisMark && formatting.emphasisMark !== "none") groups.set("emphasisMark", formatting.emphasisMark);
|
|
2751
|
-
return groups;
|
|
2752
|
-
};
|
|
2753
|
-
const expectedRunFormattingOverrideAttrs = (authoredFormatting) => {
|
|
2754
|
-
const attrs = buildRunFormattingOverrideAttrs(authoredFormatting, {
|
|
2755
|
-
type: "authored-baseline",
|
|
2756
|
-
formatting: authoredFormatting
|
|
2757
|
-
});
|
|
2758
|
-
const hasDirectFormatting = Object.keys(authoredFormatting).some((property) => property !== "styleId");
|
|
2759
|
-
if (!attrs && !hasDirectFormatting) return;
|
|
2760
|
-
const expected = { ...attrs };
|
|
2761
|
-
const directFontProperties = [
|
|
2762
|
-
"color",
|
|
2763
|
-
"fontFamily",
|
|
2764
|
-
"fontSize"
|
|
2765
|
-
].filter((property) => authoredFormatting[property] !== void 0);
|
|
2766
|
-
if (directFontProperties.length > 0) expected.directFontProperties = directFontProperties;
|
|
2767
|
-
const complexScriptPropertyAbsences = [
|
|
2768
|
-
["bold", "boldCs"],
|
|
2769
|
-
["italic", "italicCs"],
|
|
2770
|
-
["fontSize", "fontSizeCs"]
|
|
2771
|
-
].filter(([ordinary, complex]) => authoredFormatting[ordinary] !== void 0 && authoredFormatting[complex] === void 0).map(([, complex]) => complex);
|
|
2772
|
-
if (complexScriptPropertyAbsences.length > 0) expected.complexScriptPropertyAbsences = complexScriptPropertyAbsences;
|
|
2773
|
-
return Object.keys(expected).length > 0 ? expected : void 0;
|
|
2774
|
-
};
|
|
2775
|
-
const changedVisualFormattingGroups = (observedFormatting, expectedFormatting) => {
|
|
2776
|
-
const actual = visualFormattingGroups(observedFormatting);
|
|
2777
|
-
const expected = visualFormattingGroups(expectedFormatting);
|
|
2778
|
-
const changed = /* @__PURE__ */ new Set();
|
|
2779
|
-
for (const group of /* @__PURE__ */ new Set([...actual.keys(), ...expected.keys()])) {
|
|
2780
|
-
const actualValue = actual.get(group);
|
|
2781
|
-
const expectedValue = expected.get(group);
|
|
2782
|
-
if (!sameFormattingValue(actualValue, expectedValue)) changed.add(group);
|
|
2783
|
-
}
|
|
2784
|
-
return changed;
|
|
2785
|
-
};
|
|
2786
|
-
const VISUAL_BOOLEAN_FORMATTING_PROPERTIES = /* @__PURE__ */ new Set([
|
|
2787
|
-
"allCaps",
|
|
2788
|
-
"bold",
|
|
2789
|
-
"doubleStrike",
|
|
2790
|
-
"emboss",
|
|
2791
|
-
"hidden",
|
|
2792
|
-
"imprint",
|
|
2793
|
-
"italic",
|
|
2794
|
-
"outline",
|
|
2795
|
-
"rtl",
|
|
2796
|
-
"shadow",
|
|
2797
|
-
"smallCaps",
|
|
2798
|
-
"strike"
|
|
2799
|
-
]);
|
|
2800
|
-
const fontFamilyDifference = (actual, inherited) => {
|
|
2801
|
-
const difference = {};
|
|
2802
|
-
for (const property of [
|
|
2803
|
-
"ascii",
|
|
2804
|
-
"hAnsi",
|
|
2805
|
-
"eastAsia",
|
|
2806
|
-
"cs",
|
|
2807
|
-
"hint",
|
|
2808
|
-
"asciiTheme",
|
|
2809
|
-
"hAnsiTheme",
|
|
2810
|
-
"eastAsiaTheme",
|
|
2811
|
-
"csTheme"
|
|
2812
|
-
]) {
|
|
2813
|
-
const value = actual[property];
|
|
2814
|
-
if (value !== void 0 && value !== inherited?.[property]) Reflect.set(difference, property, value);
|
|
2815
|
-
}
|
|
2816
|
-
return Object.keys(difference).length > 0 ? difference : void 0;
|
|
2817
|
-
};
|
|
2818
|
-
const DIRECT_OVERRIDE_FORMATTING_PROPERTIES = [
|
|
2819
|
-
"allCaps",
|
|
2820
|
-
"bold",
|
|
2821
|
-
"boldCs",
|
|
2822
|
-
"cs",
|
|
2823
|
-
"doubleStrike",
|
|
2824
|
-
"emboss",
|
|
2825
|
-
"fontSizeCs",
|
|
2826
|
-
"hidden",
|
|
2827
|
-
"noProof",
|
|
2828
|
-
"imprint",
|
|
2829
|
-
"italic",
|
|
2830
|
-
"italicCs",
|
|
2831
|
-
"outline",
|
|
2832
|
-
"rtl",
|
|
2833
|
-
"shadow",
|
|
2834
|
-
"smallCaps",
|
|
2835
|
-
"strike",
|
|
2836
|
-
"underline"
|
|
2837
|
-
];
|
|
2838
|
-
const POSITIVE_OVERRIDE_PROPERTIES_REPRESENTED_BY_VISUAL_MARKS = /* @__PURE__ */ new Set([
|
|
2839
|
-
"allCaps",
|
|
2840
|
-
"emboss",
|
|
2841
|
-
"hidden",
|
|
2842
|
-
"imprint",
|
|
2843
|
-
"outline",
|
|
2844
|
-
"rtl",
|
|
2845
|
-
"shadow",
|
|
2846
|
-
"smallCaps",
|
|
2847
|
-
"strike"
|
|
2848
|
-
]);
|
|
2849
|
-
const setFormattingFromOverrideSignal = (formatting, property, value) => {
|
|
2850
|
-
Reflect.deleteProperty(formatting, property);
|
|
2851
|
-
if (value === void 0) return;
|
|
2852
|
-
if (property === "underline") {
|
|
2853
|
-
formatting.underline = { style: "none" };
|
|
2854
|
-
return;
|
|
2855
|
-
}
|
|
2856
|
-
Reflect.set(formatting, property, value);
|
|
2857
|
-
};
|
|
2858
|
-
const sameFormattingValue = (left, right) => {
|
|
2859
|
-
if (left === right) return true;
|
|
2860
|
-
if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) return false;
|
|
2861
|
-
if (Array.isArray(left) || Array.isArray(right)) {
|
|
2862
|
-
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
|
|
2863
|
-
return left.every((value, index) => sameFormattingValue(value, right[index]));
|
|
2864
|
-
}
|
|
2865
|
-
const leftKeys = Object.keys(left);
|
|
2866
|
-
const rightKeys = Object.keys(right);
|
|
2867
|
-
if (leftKeys.length !== rightKeys.length) return false;
|
|
2868
|
-
return leftKeys.every((key) => Object.prototype.hasOwnProperty.call(right, key) && sameFormattingValue(Reflect.get(left, key), Reflect.get(right, key)));
|
|
2869
|
-
};
|
|
2870
|
-
const reconcileOverrideSignals = (formatting, current, expected, inheritedFormatting, observedFormatting) => {
|
|
2871
|
-
for (const property of DIRECT_OVERRIDE_FORMATTING_PROPERTIES) {
|
|
2872
|
-
if (sameFormattingValue(current?.[property], expected?.[property])) continue;
|
|
2873
|
-
if (current?.[property] === void 0 && expected?.[property] === true && POSITIVE_OVERRIDE_PROPERTIES_REPRESENTED_BY_VISUAL_MARKS.has(property)) continue;
|
|
2874
|
-
if (current && hasAuthoredRunFormattingProvenance(current) && expected?.[property] === void 0 && sameFormattingValue(current[property], inheritedFormatting?.[property])) continue;
|
|
2875
|
-
setFormattingFromOverrideSignal(formatting, property, current?.[property]);
|
|
2876
|
-
}
|
|
2877
|
-
for (const property of [
|
|
2878
|
-
"color",
|
|
2879
|
-
"fontFamily",
|
|
2880
|
-
"fontSize"
|
|
2881
|
-
]) {
|
|
2882
|
-
const currentIsDirect = current?.directFontProperties?.includes(property) === true;
|
|
2883
|
-
if (currentIsDirect === (expected?.directFontProperties?.includes(property) === true)) continue;
|
|
2884
|
-
if (!currentIsDirect) {
|
|
2885
|
-
Reflect.deleteProperty(formatting, property);
|
|
2886
|
-
continue;
|
|
2887
|
-
}
|
|
2888
|
-
const observed = observedFormatting[property];
|
|
2889
|
-
if (observed !== void 0) Reflect.set(formatting, property, observed);
|
|
2890
|
-
}
|
|
2891
|
-
for (const property of [
|
|
2892
|
-
"boldCs",
|
|
2893
|
-
"italicCs",
|
|
2894
|
-
"fontSizeCs"
|
|
2895
|
-
]) {
|
|
2896
|
-
const currentIsAbsent = current?.complexScriptPropertyAbsences?.includes(property) === true;
|
|
2897
|
-
if (currentIsAbsent !== (expected?.complexScriptPropertyAbsences?.includes(property) === true) && currentIsAbsent) Reflect.deleteProperty(formatting, property);
|
|
2898
|
-
}
|
|
2899
|
-
};
|
|
2900
|
-
/**
|
|
2901
|
-
* Reconcile source-authored provenance with the current visual mark set at the
|
|
2902
|
-
* one save boundary shared by editor commands, raw transactions and compare.
|
|
2903
|
-
* Unchanged groups keep exact source state (including equal direct values and
|
|
2904
|
-
* otherwise invisible sentinels); changed groups derive the smallest direct
|
|
2905
|
-
* override needed relative to the current style cascade.
|
|
2906
|
-
*/
|
|
2907
|
-
const reconcileAuthoredFormatting = ({ authoredFormatting, carrierlessContext, currentOverrideAttrs, inheritedFormatting, observedFormatting }) => {
|
|
2908
|
-
const hasAuthoredFormatting = Object.keys(authoredFormatting).length > 0;
|
|
2909
|
-
if (carrierlessContext === "ordinary" && currentOverrideAttrs === void 0 && !hasAuthoredFormatting && hasOnlyCarrierlessVisualFormatting(observedFormatting)) {
|
|
2910
|
-
if (sameVisualFormatting(observedFormatting, inheritedFormatting)) return authoredFormatting;
|
|
2911
|
-
if (observedFormatting.fontFamily === void 0 && sameVisualFormatting(inheritedFormatting, void 0)) return observedFormatting;
|
|
2912
|
-
}
|
|
2913
|
-
const expectedFormatting = hasAuthoredFormatting ? mergeTextFormatting(inheritedFormatting, authoredFormatting) : inheritedFormatting;
|
|
2914
|
-
const changedGroups = changedVisualFormattingGroups(observedFormatting, expectedFormatting);
|
|
2915
|
-
const reconciled = { ...authoredFormatting };
|
|
2916
|
-
for (const property of Object.keys(RUN_FORMATTING_VISUAL_GROUPS)) {
|
|
2917
|
-
const group = RUN_FORMATTING_VISUAL_GROUPS[property];
|
|
2918
|
-
if (group === null || !changedGroups.has(group)) continue;
|
|
2919
|
-
Reflect.deleteProperty(reconciled, property);
|
|
2920
|
-
if (VISUAL_BOOLEAN_FORMATTING_PROPERTIES.has(property)) {
|
|
2921
|
-
const observed = observedFormatting[property] === true;
|
|
2922
|
-
if (observed !== (inheritedFormatting?.[property] === true)) Reflect.set(reconciled, property, observed);
|
|
2923
|
-
continue;
|
|
2924
|
-
}
|
|
2925
|
-
const observed = observedFormatting[property];
|
|
2926
|
-
if (observed === void 0) continue;
|
|
2927
|
-
if (property === "fontFamily") {
|
|
2928
|
-
const difference = fontFamilyDifference(observed, inheritedFormatting?.fontFamily);
|
|
2929
|
-
if (difference) reconciled.fontFamily = difference;
|
|
2930
|
-
continue;
|
|
2931
|
-
}
|
|
2932
|
-
if (!sameFormattingValue(observed, inheritedFormatting?.[property])) Reflect.set(reconciled, property, observed);
|
|
2933
|
-
}
|
|
2934
|
-
if (currentOverrideAttrs !== void 0) reconcileOverrideSignals(reconciled, currentOverrideAttrs, expectedRunFormattingOverrideAttrs(authoredFormatting), inheritedFormatting, observedFormatting);
|
|
2935
|
-
return reconciled;
|
|
2936
|
-
};
|
|
2937
|
-
const formattingAuthorshipCost = (formatting) => {
|
|
2938
|
-
let cost = 0;
|
|
2939
|
-
const visit = (value) => {
|
|
2940
|
-
if (value === void 0) return;
|
|
2941
|
-
if (value === null || typeof value !== "object") {
|
|
2942
|
-
cost++;
|
|
2943
|
-
return;
|
|
2944
|
-
}
|
|
2945
|
-
const entries = Object.entries(value);
|
|
2946
|
-
if (entries.length === 0) {
|
|
2947
|
-
cost++;
|
|
2948
|
-
return;
|
|
2949
|
-
}
|
|
2950
|
-
for (const [, nested] of entries) visit(nested);
|
|
2951
|
-
};
|
|
2952
|
-
for (const [property, value] of Object.entries(formatting)) if (property !== "styleId") visit(value);
|
|
2953
|
-
return cost;
|
|
2954
|
-
};
|
|
2955
|
-
function marksToTextFormatting(marks, options) {
|
|
2956
|
-
const formatting = {};
|
|
2957
|
-
let directOverrideFormatting;
|
|
2958
|
-
let directFontProperties;
|
|
2959
|
-
let characterStyleId;
|
|
2960
|
-
let runFormattingOverrideMark;
|
|
2961
|
-
let currentOverrideAttrs;
|
|
2962
|
-
for (const mark of marks) switch (mark.type.name) {
|
|
2963
|
-
case "bold":
|
|
2964
|
-
formatting.bold = true;
|
|
2965
|
-
break;
|
|
2966
|
-
case "italic":
|
|
2967
|
-
formatting.italic = true;
|
|
2968
|
-
break;
|
|
2969
|
-
case "underline": {
|
|
2970
|
-
const attrs = expectUnderlineMarkAttrs(mark);
|
|
2971
|
-
const uline = { style: attrs.style || "single" };
|
|
2972
|
-
if (attrs.color) uline.color = attrs.color;
|
|
2973
|
-
formatting.underline = uline;
|
|
2974
|
-
break;
|
|
2975
|
-
}
|
|
2976
|
-
case "strike":
|
|
2977
|
-
if (expectStrikeMarkAttrs(mark).double) formatting.doubleStrike = true;
|
|
2978
|
-
else formatting.strike = true;
|
|
2979
|
-
break;
|
|
2980
|
-
case "textColor": {
|
|
2981
|
-
const attrs = expectTextColorMarkAttrs(mark);
|
|
2982
|
-
const colorVal = {};
|
|
2983
|
-
if (attrs.rgb) colorVal.rgb = attrs.rgb;
|
|
2984
|
-
if (attrs.themeColor) colorVal.themeColor = attrs.themeColor;
|
|
2985
|
-
if (attrs.themeTint) colorVal.themeTint = attrs.themeTint;
|
|
2986
|
-
if (attrs.themeShade) colorVal.themeShade = attrs.themeShade;
|
|
2987
|
-
formatting.color = colorVal;
|
|
2988
|
-
break;
|
|
2989
|
-
}
|
|
2990
|
-
case "highlight":
|
|
2991
|
-
formatting.highlight = expectHighlightMarkAttrs(mark).color;
|
|
2992
|
-
break;
|
|
2993
|
-
case "runShading":
|
|
2994
|
-
formatting.shading = runShadingAttrsToShading(expectRunShadingMarkAttrs(mark));
|
|
2995
|
-
break;
|
|
2996
|
-
case "fontSize":
|
|
2997
|
-
formatting.fontSize = expectFontSizeMarkAttrs(mark).size;
|
|
2998
|
-
break;
|
|
2999
|
-
case "fontFamily": {
|
|
3000
|
-
const attrs = expectFontFamilyMarkAttrs(mark);
|
|
3001
|
-
const ff = {};
|
|
3002
|
-
if (attrs.ascii) ff.ascii = attrs.ascii;
|
|
3003
|
-
if (attrs.hAnsi) ff.hAnsi = attrs.hAnsi;
|
|
3004
|
-
if (attrs.eastAsia) ff.eastAsia = attrs.eastAsia;
|
|
3005
|
-
if (attrs.hint) ff.hint = attrs.hint;
|
|
3006
|
-
if (attrs.cs) ff.cs = attrs.cs;
|
|
3007
|
-
if (attrs.asciiTheme) ff.asciiTheme = attrs.asciiTheme;
|
|
3008
|
-
if (attrs.hAnsiTheme) ff.hAnsiTheme = attrs.hAnsiTheme;
|
|
3009
|
-
if (attrs.eastAsiaTheme) ff.eastAsiaTheme = attrs.eastAsiaTheme;
|
|
3010
|
-
if (attrs.csTheme) ff.csTheme = attrs.csTheme;
|
|
3011
|
-
formatting.fontFamily = ff;
|
|
3012
|
-
break;
|
|
3013
|
-
}
|
|
3014
|
-
case "language": {
|
|
3015
|
-
const attrs = expectLanguageMarkAttrs(mark);
|
|
3016
|
-
formatting.language = {
|
|
3017
|
-
...attrs.val ? { val: attrs.val } : {},
|
|
3018
|
-
...attrs.eastAsia ? { eastAsia: attrs.eastAsia } : {},
|
|
3019
|
-
...attrs.bidi ? { bidi: attrs.bidi } : {}
|
|
3020
|
-
};
|
|
3021
|
-
break;
|
|
3022
|
-
}
|
|
3023
|
-
case "superscript":
|
|
3024
|
-
formatting.vertAlign = "superscript";
|
|
3025
|
-
break;
|
|
3026
|
-
case "subscript":
|
|
3027
|
-
formatting.vertAlign = "subscript";
|
|
3028
|
-
break;
|
|
3029
|
-
case "allCaps":
|
|
3030
|
-
formatting.allCaps = true;
|
|
3031
|
-
break;
|
|
3032
|
-
case "smallCaps":
|
|
3033
|
-
formatting.smallCaps = true;
|
|
3034
|
-
break;
|
|
3035
|
-
case "characterSpacing": {
|
|
3036
|
-
const attrs = expectCharacterSpacingMarkAttrs(mark);
|
|
3037
|
-
if (attrs.spacing !== void 0) formatting.spacing = attrs.spacing;
|
|
3038
|
-
if (attrs.position !== void 0) formatting.position = attrs.position;
|
|
3039
|
-
const horizontalScale = normalizeHorizontalScalePercent(attrs.scale);
|
|
3040
|
-
if (horizontalScale !== void 0) formatting.scale = horizontalScale;
|
|
3041
|
-
if (attrs.kerning !== void 0) formatting.kerning = attrs.kerning;
|
|
3042
|
-
break;
|
|
3043
|
-
}
|
|
3044
|
-
case "emboss":
|
|
3045
|
-
formatting.emboss = true;
|
|
3046
|
-
break;
|
|
3047
|
-
case "imprint":
|
|
3048
|
-
formatting.imprint = true;
|
|
3049
|
-
break;
|
|
3050
|
-
case "hidden":
|
|
3051
|
-
formatting.hidden = true;
|
|
3052
|
-
break;
|
|
3053
|
-
case "textShadow":
|
|
3054
|
-
formatting.shadow = true;
|
|
3055
|
-
break;
|
|
3056
|
-
case "emphasisMark":
|
|
3057
|
-
formatting.emphasisMark = expectEmphasisMarkAttrs(mark).type || "dot";
|
|
3058
|
-
break;
|
|
3059
|
-
case "textOutline":
|
|
3060
|
-
formatting.outline = true;
|
|
3061
|
-
break;
|
|
3062
|
-
case "rtl":
|
|
3063
|
-
formatting.rtl = true;
|
|
3064
|
-
break;
|
|
3065
|
-
case "textEffect":
|
|
3066
|
-
formatting.effect = expectTextEffectMarkAttrs(mark).effect;
|
|
3067
|
-
break;
|
|
3068
|
-
case "runFormattingOverride":
|
|
3069
|
-
runFormattingOverrideMark = mark;
|
|
3070
|
-
break;
|
|
3071
|
-
case "characterStyle": {
|
|
3072
|
-
const attrs = expectCharacterStyleMarkAttrs(mark);
|
|
3073
|
-
formatting.styleId = attrs.styleId;
|
|
3074
|
-
characterStyleId = attrs.styleId;
|
|
3075
|
-
break;
|
|
3076
|
-
}
|
|
3077
|
-
default: break;
|
|
3078
|
-
}
|
|
3079
|
-
let authoredFormatting = {};
|
|
3080
|
-
if (runFormattingOverrideMark) {
|
|
3081
|
-
const overrideAttrs = expectRunFormattingOverrideMarkAttrs(runFormattingOverrideMark);
|
|
3082
|
-
currentOverrideAttrs = overrideAttrs;
|
|
3083
|
-
directFontProperties = overrideAttrs.directFontProperties;
|
|
3084
|
-
directOverrideFormatting = {};
|
|
3085
|
-
applyRunFormattingOverrideAttrs(directOverrideFormatting, overrideAttrs);
|
|
3086
|
-
for (const property of directFontProperties ?? []) {
|
|
3087
|
-
const value = formatting[property];
|
|
3088
|
-
if (value !== void 0) Reflect.set(directOverrideFormatting, property, value);
|
|
3089
|
-
}
|
|
3090
|
-
authoredFormatting = authoredRunFormattingFromAttrs(overrideAttrs) ?? directOverrideFormatting;
|
|
3091
|
-
}
|
|
3092
|
-
if (characterStyleId !== void 0 && !options?.styleResolver) {
|
|
3093
|
-
const conservativeFormatting = mergeTextFormatting(formatting, directOverrideFormatting) ?? {};
|
|
3094
|
-
for (const property of currentOverrideAttrs?.complexScriptPropertyAbsences ?? []) Reflect.deleteProperty(conservativeFormatting, property);
|
|
3095
|
-
return {
|
|
3096
|
-
...conservativeFormatting,
|
|
3097
|
-
styleId: characterStyleId
|
|
3098
|
-
};
|
|
3099
|
-
}
|
|
3100
|
-
const inheritedFormatting = resolveEffectiveRunStyleFormatting({
|
|
3101
|
-
marks,
|
|
3102
|
-
paragraphFormatting: paragraphFormattingForRun({
|
|
3103
|
-
context: {
|
|
3104
|
-
baseParagraphFormatting: options?.baseParagraphFormatting,
|
|
3105
|
-
paragraphFormatting: options?.inheritedFormatting,
|
|
3106
|
-
paragraphMarkFormatting: options?.paragraphMarkFormatting,
|
|
3107
|
-
paragraphMarkPrecedesStyle: options?.paragraphMarkPrecedesStyle ?? false
|
|
3108
|
-
},
|
|
3109
|
-
directFormatting: authoredFormatting,
|
|
3110
|
-
marks
|
|
3111
|
-
}),
|
|
3112
|
-
...options?.styleResolver !== void 0 ? { styleResolver: options.styleResolver } : {}
|
|
3113
|
-
});
|
|
3114
|
-
let reconciled = reconcileAuthoredFormatting({
|
|
3115
|
-
authoredFormatting,
|
|
3116
|
-
carrierlessContext: options?.paragraphMarkFormatting === void 0 ? "ordinary" : "paragraph-mark",
|
|
3117
|
-
currentOverrideAttrs,
|
|
3118
|
-
inheritedFormatting,
|
|
3119
|
-
observedFormatting: formatting
|
|
3120
|
-
});
|
|
3121
|
-
if (runFormattingOverrideMark === void 0 && characterStyleId === void 0 && options?.paragraphMarkFormatting !== void 0) {
|
|
3122
|
-
const suppressedInheritedFormatting = resolveEffectiveRunStyleFormatting({
|
|
3123
|
-
marks,
|
|
3124
|
-
paragraphFormatting: suppressParagraphMarkFormatting({
|
|
3125
|
-
baseFormatting: options.baseParagraphFormatting,
|
|
3126
|
-
directFormatting: authoredFormatting,
|
|
3127
|
-
paragraphMarkFormatting: options.paragraphMarkFormatting,
|
|
3128
|
-
paragraphMarkPrecedesStyle: options.paragraphMarkPrecedesStyle ?? false
|
|
3129
|
-
}),
|
|
3130
|
-
...options.styleResolver !== void 0 ? { styleResolver: options.styleResolver } : {}
|
|
3131
|
-
});
|
|
3132
|
-
const suppressed = reconcileAuthoredFormatting({
|
|
3133
|
-
authoredFormatting,
|
|
3134
|
-
carrierlessContext: "paragraph-mark",
|
|
3135
|
-
currentOverrideAttrs,
|
|
3136
|
-
inheritedFormatting: suppressedInheritedFormatting,
|
|
3137
|
-
observedFormatting: formatting
|
|
3138
|
-
});
|
|
3139
|
-
if (formattingAuthorshipCost(suppressed) < formattingAuthorshipCost(reconciled)) reconciled = suppressed;
|
|
3140
|
-
}
|
|
3141
|
-
return {
|
|
3142
|
-
...reconciled,
|
|
3143
|
-
...characterStyleId !== void 0 ? { styleId: characterStyleId } : {}
|
|
3144
|
-
};
|
|
3145
|
-
}
|
|
3146
2693
|
/**
|
|
3147
2694
|
* Convert a ProseMirror table node to our Table type
|
|
3148
2695
|
*/
|
|
@@ -3214,6 +2761,7 @@ function restoreCarriedTableAttrs(table, attrs) {
|
|
|
3214
2761
|
if (Array.isArray(attrs.tblPrChange) && attrs.tblPrChange.length > 0) table.propertyChanges = [...attrs.tblPrChange];
|
|
3215
2762
|
if (attrs._bookmarks && attrs._bookmarks.length > 0) table.bookmarks = attrs._bookmarks;
|
|
3216
2763
|
if (hasSinkChildren(attrs._preserved)) table.preserved = attrs._preserved;
|
|
2764
|
+
if (attrs.carrierStack?.length) table.carrierStack = attrs.carrierStack;
|
|
3217
2765
|
}
|
|
3218
2766
|
function convertPMTableRows(node, documentCounts, styleResolver = null) {
|
|
3219
2767
|
const rows = [];
|
|
@@ -3316,7 +2864,7 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3316
2864
|
let activeMerge = activeVerticalMerges.get(gridColumn);
|
|
3317
2865
|
while (activeMerge) {
|
|
3318
2866
|
const preservedCell = activeMerge.continuationCells?.shift();
|
|
3319
|
-
cells.push(preservedCell
|
|
2867
|
+
cells.push(preservedCell ? continuationCellSpanning(preservedCell, activeMerge.colspan) : createVerticalMergeContinuationCell(activeMerge.colspan));
|
|
3320
2868
|
activeMerge.remainingRows -= 1;
|
|
3321
2869
|
if (activeMerge.remainingRows <= 0) activeVerticalMerges.delete(gridColumn);
|
|
3322
2870
|
gridColumn += activeMerge.colspan;
|
|
@@ -3358,6 +2906,7 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3358
2906
|
if (attrs._preservedAttributes && attrs._preservedAttributes.length > 0) row.preservedAttributes = attrs._preservedAttributes;
|
|
3359
2907
|
if (attrs._bookmarks && attrs._bookmarks.length > 0) row.bookmarks = attrs._bookmarks;
|
|
3360
2908
|
if (attrs.contentControls && attrs.contentControls.length > 0) row.contentControls = attrs.contentControls;
|
|
2909
|
+
if (attrs.carrierStack?.length) row.carrierStack = attrs.carrierStack;
|
|
3361
2910
|
if (hasSinkChildren(attrs._preserved)) row.preserved = attrs._preserved;
|
|
3362
2911
|
if (attrs.trIns) row.structuralChange = {
|
|
3363
2912
|
type: "tableRowInsertion",
|
|
@@ -3387,6 +2936,25 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3387
2936
|
};
|
|
3388
2937
|
return row;
|
|
3389
2938
|
}
|
|
2939
|
+
/**
|
|
2940
|
+
* A continuation cell the package arrived with, spanning the columns its merge
|
|
2941
|
+
* spans NOW. The cell is carried whole for its `w:tcPr` and content, but a
|
|
2942
|
+
* column deleted or inserted through the merge changes the merge's width, and
|
|
2943
|
+
* a continuation still stating the old one leaves the row wider or narrower
|
|
2944
|
+
* than the grid and no longer under the cell it continues.
|
|
2945
|
+
*/
|
|
2946
|
+
function continuationCellSpanning(cell, colspan) {
|
|
2947
|
+
if ((cell.formatting?.gridSpan ?? 1) === colspan) return cell;
|
|
2948
|
+
const { gridSpan: _staleSpan, ...formatting } = cell.formatting ?? {};
|
|
2949
|
+
return {
|
|
2950
|
+
...cell,
|
|
2951
|
+
formatting: {
|
|
2952
|
+
...formatting,
|
|
2953
|
+
vMerge: "continue",
|
|
2954
|
+
...colspan > 1 && { gridSpan: colspan }
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
3390
2958
|
function createVerticalMergeContinuationCell(colspan) {
|
|
3391
2959
|
const formatting = { vMerge: "continue" };
|
|
3392
2960
|
if (colspan > 1) formatting.gridSpan = colspan;
|
|
@@ -3448,6 +3016,9 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3448
3016
|
} else if (contentNode.type.name === "blockSdt") {
|
|
3449
3017
|
content.push(convertPMBlockSdt(contentNode, styleResolver));
|
|
3450
3018
|
previousStandaloneTextBox = null;
|
|
3019
|
+
} else if (contentNode.type.name === "blockCustomXml") {
|
|
3020
|
+
content.push(convertPMBlockCustomXml(contentNode, styleResolver));
|
|
3021
|
+
previousStandaloneTextBox = null;
|
|
3451
3022
|
} else if (contentNode.type.name === "textBox") previousStandaloneTextBox = appendTextBoxBlock(content, contentNode, {
|
|
3452
3023
|
pendingPageBreaks: 0,
|
|
3453
3024
|
previousStandaloneTextBox,
|
|
@@ -3475,6 +3046,7 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3475
3046
|
if (cellFormatting) cell.formatting = cellFormatting;
|
|
3476
3047
|
if (Array.isArray(attrs.tcPrChange) && attrs.tcPrChange.length > 0) cell.propertyChanges = [...attrs.tcPrChange];
|
|
3477
3048
|
if (attrs.contentControls && attrs.contentControls.length > 0) cell.contentControls = attrs.contentControls;
|
|
3049
|
+
if (attrs.carrierStack?.length) cell.carrierStack = attrs.carrierStack;
|
|
3478
3050
|
if (attrs.cellMarker) {
|
|
3479
3051
|
const info = {
|
|
3480
3052
|
id: attrs.cellMarker.info.revisionId,
|