@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
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import { restoreTableCellsWithParagraphPropertySources, transportTableCellsWithParagraphPropertySources } from "../../docx/paragraphPropertySource.js";
|
|
2
|
+
import { isTableCellMergeRevisionContinuation, isTableCellMergeRevisionValue } from "../../docx/tableParser.js";
|
|
3
|
+
import { expectTableAttrs, mergeTableAttrs } from "../attrs/index.js";
|
|
4
|
+
import { nodePropertyRevisionSites, propertyRevisionRecords } from "../revisionCarriers.js";
|
|
5
|
+
import { getTableCellMergeChange } from "../tableCellMergeRevision.js";
|
|
6
|
+
import { isTableCellRetainedInReviewView } from "../tableCellRevisionVisibility.js";
|
|
7
|
+
import { resolveAllNodePropertyChangeAttrs } from "./resolveNodePropertyChangeAttrs.js";
|
|
8
|
+
import { acceptedMergeFoldsIntoCellAbove, createRestoredTableCell, hasMatchingCollapsedTableCellMerge, tableCellContinuationCells, tableCellContinuationFromNode, tableCellContinuationPayload } from "./tableCellMergeResolution.js";
|
|
9
|
+
import { panic } from "better-result";
|
|
10
|
+
import { TableMap } from "prosemirror-tables";
|
|
11
|
+
import { StepMap } from "prosemirror-transform";
|
|
12
|
+
//#region src/prosemirror/commands/resolveAllTableChanges.ts
|
|
13
|
+
const indexedTableCells = (map) => {
|
|
14
|
+
const rectangles = /* @__PURE__ */ new Map();
|
|
15
|
+
for (let index = 0; index < map.map.length; index++) {
|
|
16
|
+
const position = map.map[index];
|
|
17
|
+
if (position === void 0 || rectangles.has(position)) continue;
|
|
18
|
+
const left = index % map.width;
|
|
19
|
+
const top = Math.floor(index / map.width);
|
|
20
|
+
let right = left + 1;
|
|
21
|
+
let bottom = top + 1;
|
|
22
|
+
while (right < map.width && map.map[index + right - left] === position) right++;
|
|
23
|
+
while (bottom < map.height && map.map[index + (bottom - top) * map.width] === position) bottom++;
|
|
24
|
+
rectangles.set(position, {
|
|
25
|
+
left,
|
|
26
|
+
top,
|
|
27
|
+
right,
|
|
28
|
+
bottom
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return (position) => rectangles.get(position) ?? panic("Missing table resolution rectangle", { position });
|
|
32
|
+
};
|
|
33
|
+
const elementAt = (items, index) => {
|
|
34
|
+
const item = items.at(index);
|
|
35
|
+
return item === void 0 ? panic("Missing table resolution element", { index }) : item;
|
|
36
|
+
};
|
|
37
|
+
const tableResolutionMetadata = ({ sourceTable, table, rows, tableTouched }) => {
|
|
38
|
+
const changedParagraphRanges = [];
|
|
39
|
+
const paragraphOffsets = [];
|
|
40
|
+
const anchors = [];
|
|
41
|
+
const finalCellStarts = [];
|
|
42
|
+
if (tableTouched) changedParagraphRanges.push({
|
|
43
|
+
from: 0,
|
|
44
|
+
to: table.nodeSize
|
|
45
|
+
});
|
|
46
|
+
let rowStart = 1;
|
|
47
|
+
for (let rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
48
|
+
const row = table.child(rowIndex);
|
|
49
|
+
const metadata = elementAt(rows, rowIndex);
|
|
50
|
+
if (!tableTouched && metadata.touched) changedParagraphRanges.push({
|
|
51
|
+
from: rowStart,
|
|
52
|
+
to: rowStart + row.nodeSize
|
|
53
|
+
});
|
|
54
|
+
let cellStart = rowStart + 1;
|
|
55
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) {
|
|
56
|
+
const cell = row.child(cellIndex);
|
|
57
|
+
const cellMetadata = elementAt(metadata.cells, cellIndex);
|
|
58
|
+
finalCellStarts.push(cellStart);
|
|
59
|
+
if (cellMetadata.mapSourcePosition >= 0) anchors.push({
|
|
60
|
+
source: cellMetadata.mapSourcePosition + 1,
|
|
61
|
+
final: cellStart,
|
|
62
|
+
size: cell.nodeSize
|
|
63
|
+
});
|
|
64
|
+
if (!tableTouched && !metadata.touched && cellMetadata.touched) changedParagraphRanges.push({
|
|
65
|
+
from: cellStart,
|
|
66
|
+
to: cellStart + cell.nodeSize
|
|
67
|
+
});
|
|
68
|
+
if (cellMetadata.sourcePosition >= 0) {
|
|
69
|
+
const sourceCellPosition = cellMetadata.sourcePosition;
|
|
70
|
+
const finalCellPosition = cellStart;
|
|
71
|
+
cell.descendants((node, offset) => {
|
|
72
|
+
if (node.type.name === "table") return false;
|
|
73
|
+
if (node.type.name !== "paragraph") return true;
|
|
74
|
+
paragraphOffsets.push({
|
|
75
|
+
source: sourceCellPosition + 2 + offset,
|
|
76
|
+
final: finalCellPosition + 1 + offset
|
|
77
|
+
});
|
|
78
|
+
return false;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
cellStart += cell.nodeSize;
|
|
82
|
+
}
|
|
83
|
+
rowStart += row.nodeSize;
|
|
84
|
+
}
|
|
85
|
+
const sourceCellStarts = [];
|
|
86
|
+
let sourceRowStart = 1;
|
|
87
|
+
for (let rowIndex = 0; rowIndex < sourceTable.childCount; rowIndex++) {
|
|
88
|
+
const row = sourceTable.child(rowIndex);
|
|
89
|
+
let cellStart = sourceRowStart + 1;
|
|
90
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) {
|
|
91
|
+
sourceCellStarts.push(cellStart);
|
|
92
|
+
cellStart += row.child(cellIndex).nodeSize;
|
|
93
|
+
}
|
|
94
|
+
sourceRowStart += row.nodeSize;
|
|
95
|
+
}
|
|
96
|
+
const ranges = [];
|
|
97
|
+
let sourceCursor = 0;
|
|
98
|
+
let finalCursor = 0;
|
|
99
|
+
let sourceCellIndex = 0;
|
|
100
|
+
let finalCellIndex = 0;
|
|
101
|
+
for (const anchor of [...anchors, {
|
|
102
|
+
source: sourceTable.nodeSize,
|
|
103
|
+
final: table.nodeSize,
|
|
104
|
+
size: 0
|
|
105
|
+
}]) {
|
|
106
|
+
if (anchor.source < sourceCursor || anchor.final < finalCursor) continue;
|
|
107
|
+
while (sourceCellStarts.at(sourceCellIndex) !== void 0 && elementAt(sourceCellStarts, sourceCellIndex) < sourceCursor) sourceCellIndex++;
|
|
108
|
+
while (finalCellStarts.at(finalCellIndex) !== void 0 && elementAt(finalCellStarts, finalCellIndex) < finalCursor) finalCellIndex++;
|
|
109
|
+
const sourceGap = anchor.source - sourceCursor;
|
|
110
|
+
const finalGap = anchor.final - finalCursor;
|
|
111
|
+
const hasUnmatchedCell = (sourceCellStarts.at(sourceCellIndex) ?? Infinity) < anchor.source || (finalCellStarts.at(finalCellIndex) ?? Infinity) < anchor.final;
|
|
112
|
+
if (sourceGap !== finalGap || hasUnmatchedCell) ranges.push(sourceCursor, sourceGap, finalGap);
|
|
113
|
+
sourceCursor = anchor.source + anchor.size;
|
|
114
|
+
finalCursor = anchor.final + anchor.size;
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
changedParagraphRanges,
|
|
118
|
+
paragraphOffsets,
|
|
119
|
+
positionMap: new StepMap(ranges)
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const hasNodePropertyRevision = (node) => nodePropertyRevisionSites(node.type.name).some((site) => site.resolution === "node-attrs" && propertyRevisionRecords(node, site).length > 0);
|
|
123
|
+
const rowRevisionKind = (row) => {
|
|
124
|
+
for (const kind of ["trIns", "trDel"]) {
|
|
125
|
+
const marker = row.attrs[kind];
|
|
126
|
+
if (typeof marker === "object" && marker !== null && "revisionId" in marker && typeof marker.revisionId === "number") return kind;
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
};
|
|
130
|
+
const cellRevisionMarker = (cell) => {
|
|
131
|
+
const marker = cell.attrs["cellMarker"];
|
|
132
|
+
if (typeof marker !== "object" || marker === null || !("kind" in marker) || marker.kind !== "ins" && marker.kind !== "del" && marker.kind !== "merge" || !("info" in marker) || typeof marker.info !== "object" || marker.info === null || !("revisionId" in marker.info) || typeof marker.info.revisionId !== "number") return null;
|
|
133
|
+
const verticalMergeOriginal = "verticalMergeOriginal" in marker && isTableCellMergeRevisionValue(marker.verticalMergeOriginal) ? marker.verticalMergeOriginal : void 0;
|
|
134
|
+
const verticalMerge = "verticalMerge" in marker && isTableCellMergeRevisionValue(marker.verticalMerge) ? marker.verticalMerge : void 0;
|
|
135
|
+
return {
|
|
136
|
+
kind: marker.kind,
|
|
137
|
+
info: { revisionId: marker.info.revisionId },
|
|
138
|
+
...verticalMergeOriginal ? { verticalMergeOriginal } : {},
|
|
139
|
+
...verticalMerge ? { verticalMerge } : {}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Resolve a table in one grid pass for row revisions and ordinary cell
|
|
144
|
+
* membership revisions. The grid records each original cell rectangle once;
|
|
145
|
+
* retaining rows reduces its rowspan, while a cell whose starting row is
|
|
146
|
+
* removed moves to the next retained row inside that rectangle. This is the
|
|
147
|
+
* same topology operation as prosemirror-tables' removeRow.
|
|
148
|
+
*/
|
|
149
|
+
const resolveAllTableChanges = ({ table, resolvedRows, mode }) => {
|
|
150
|
+
const sourceRows = resolvedRows ?? Array.from({ length: table.childCount }, (_, i) => table.child(i));
|
|
151
|
+
const tableWithResolvedChildren = table.type.create(table.attrs, sourceRows, table.marks);
|
|
152
|
+
const tablePropertyTouched = hasNodePropertyRevision(tableWithResolvedChildren);
|
|
153
|
+
const rowPropertyTouched = sourceRows.map(hasNodePropertyRevision);
|
|
154
|
+
const propertyResolvedTable = resolveTablePropertyAttrs(tableWithResolvedChildren, mode);
|
|
155
|
+
const rows = Array.from({ length: propertyResolvedTable.childCount }, (_, i) => propertyResolvedTable.child(i));
|
|
156
|
+
const rowKinds = rows.map(rowRevisionKind);
|
|
157
|
+
const keepRows = rowKinds.map((kind) => kind === null || kind === "trIns" === (mode === "accept"));
|
|
158
|
+
const hasRowRevision = rowKinds.some((kind) => kind !== null);
|
|
159
|
+
const hasMerge = rows.some((row) => {
|
|
160
|
+
for (let i = 0; i < row.childCount; i++) {
|
|
161
|
+
const cell = row.child(i);
|
|
162
|
+
if (cellRevisionMarker(cell)?.kind === "merge" || hasMatchingCollapsedTableCellMerge(cell, null)) return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
});
|
|
166
|
+
const map = TableMap.get(propertyResolvedTable);
|
|
167
|
+
const cellRectangle = indexedTableCells(map);
|
|
168
|
+
const cells = [];
|
|
169
|
+
let rowOffset = 0;
|
|
170
|
+
let hasCellRevision = false;
|
|
171
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
172
|
+
const row = elementAt(rows, rowIndex);
|
|
173
|
+
let cellOffset = rowOffset + 1;
|
|
174
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) {
|
|
175
|
+
const cell = row.child(cellIndex);
|
|
176
|
+
const rectangle = cellRectangle(cellOffset);
|
|
177
|
+
const marker = cellRevisionMarker(cell);
|
|
178
|
+
if ((marker?.kind === "ins" || marker?.kind === "del" ? marker : null) !== null) hasCellRevision = true;
|
|
179
|
+
cells.push({
|
|
180
|
+
node: cell,
|
|
181
|
+
left: rectangle.left,
|
|
182
|
+
originRow: rowIndex,
|
|
183
|
+
bottom: rectangle.bottom,
|
|
184
|
+
sourcePosition: cellOffset,
|
|
185
|
+
mapSourcePosition: cellOffset,
|
|
186
|
+
touched: hasNodePropertyRevision(elementAt(sourceRows, rowIndex).child(cellIndex))
|
|
187
|
+
});
|
|
188
|
+
cellOffset += cell.nodeSize;
|
|
189
|
+
}
|
|
190
|
+
rowOffset += row.nodeSize;
|
|
191
|
+
}
|
|
192
|
+
if (!keepRows.some(Boolean)) return {
|
|
193
|
+
node: null,
|
|
194
|
+
changed: true,
|
|
195
|
+
structural: hasRowRevision || hasCellRevision,
|
|
196
|
+
failed: false,
|
|
197
|
+
changedParagraphRanges: [],
|
|
198
|
+
paragraphOffsets: [],
|
|
199
|
+
positionMap: new StepMap([
|
|
200
|
+
0,
|
|
201
|
+
tableWithResolvedChildren.nodeSize,
|
|
202
|
+
0
|
|
203
|
+
])
|
|
204
|
+
};
|
|
205
|
+
const keptBefore = [0];
|
|
206
|
+
for (const keep of keepRows) keptBefore.push((keptBefore.at(-1) ?? 0) + Number(keep));
|
|
207
|
+
const nextKeptRow = rows.map(() => rows.length);
|
|
208
|
+
let next = rows.length;
|
|
209
|
+
for (let index = rows.length - 1; index >= 0; index--) {
|
|
210
|
+
if (elementAt(keepRows, index)) next = index;
|
|
211
|
+
nextKeptRow[index] = next;
|
|
212
|
+
}
|
|
213
|
+
const placements = rows.map(() => []);
|
|
214
|
+
for (const cell of cells) {
|
|
215
|
+
const destination = elementAt(nextKeptRow, cell.originRow);
|
|
216
|
+
if (destination >= cell.bottom) continue;
|
|
217
|
+
const rowspan = elementAt(keptBefore, cell.bottom) - elementAt(keptBefore, destination);
|
|
218
|
+
elementAt(placements, destination)[cell.left] = {
|
|
219
|
+
...cell,
|
|
220
|
+
mapSourcePosition: destination === cell.originRow ? cell.mapSourcePosition : -1,
|
|
221
|
+
touched: cell.touched || rowspan !== cell.node.attrs["rowspan"],
|
|
222
|
+
node: rowspan === cell.node.attrs["rowspan"] ? cell.node : cell.node.type.create({
|
|
223
|
+
...cell.node.attrs,
|
|
224
|
+
rowspan
|
|
225
|
+
}, cell.node.content, cell.node.marks)
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const nextRows = [];
|
|
229
|
+
const rowMetadata = [];
|
|
230
|
+
for (let index = 0; index < rows.length; index++) {
|
|
231
|
+
if (!elementAt(keepRows, index)) continue;
|
|
232
|
+
const row = elementAt(rows, index);
|
|
233
|
+
const rowCells = elementAt(placements, index).flatMap((placement) => placement === void 0 ? [] : [placement.node]);
|
|
234
|
+
const kind = elementAt(rowKinds, index);
|
|
235
|
+
const attrs = kind ? {
|
|
236
|
+
...row.attrs,
|
|
237
|
+
[kind]: null
|
|
238
|
+
} : row.attrs;
|
|
239
|
+
nextRows.push(row.type.create(attrs, rowCells, row.marks));
|
|
240
|
+
rowMetadata.push({
|
|
241
|
+
touched: elementAt(rowPropertyTouched, index) || kind !== null,
|
|
242
|
+
cells: elementAt(placements, index).flatMap((placement) => placement === void 0 ? [] : [placement])
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const nextTable = propertyResolvedTable.type.create(propertyResolvedTable.attrs, nextRows, propertyResolvedTable.marks);
|
|
246
|
+
if (hasMerge || hasCellRevision) return resolvePureTableMerges({
|
|
247
|
+
table: nextTable,
|
|
248
|
+
mode,
|
|
249
|
+
rowMetadata,
|
|
250
|
+
tablePropertyTouched,
|
|
251
|
+
sourceTable: tableWithResolvedChildren
|
|
252
|
+
});
|
|
253
|
+
const structural = hasRowRevision || hasCellRevision || hasTablePropertyRevision(tableWithResolvedChildren);
|
|
254
|
+
return {
|
|
255
|
+
node: nextTable,
|
|
256
|
+
changed: structural || !nextTable.eq(table),
|
|
257
|
+
structural,
|
|
258
|
+
failed: false,
|
|
259
|
+
...tableResolutionMetadata({
|
|
260
|
+
table: nextTable,
|
|
261
|
+
rows: rowMetadata,
|
|
262
|
+
tableTouched: tablePropertyTouched,
|
|
263
|
+
sourceTable: tableWithResolvedChildren
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
const resolveTablePropertyAttrs = (table, mode) => {
|
|
268
|
+
const rows = [];
|
|
269
|
+
for (let rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
270
|
+
const row = table.child(rowIndex);
|
|
271
|
+
const cells = [];
|
|
272
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) cells.push(resolveAllNodePropertyChangeAttrs(row.child(cellIndex), mode));
|
|
273
|
+
rows.push(resolveAllNodePropertyChangeAttrs(row.type.create(row.attrs, cells, row.marks), mode));
|
|
274
|
+
}
|
|
275
|
+
return resolveAllNodePropertyChangeAttrs(table.type.create(table.attrs, rows, table.marks), mode);
|
|
276
|
+
};
|
|
277
|
+
const hasTablePropertyRevision = (table) => {
|
|
278
|
+
if (table.attrs["tblPrChange"] != null) return true;
|
|
279
|
+
for (let rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
280
|
+
const row = table.child(rowIndex);
|
|
281
|
+
if (row.attrs["trPrChange"] != null || row.attrs["tblPrExChange"] != null) return true;
|
|
282
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) if (row.child(cellIndex).attrs["tcPrChange"] != null) return true;
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
};
|
|
286
|
+
const appendContinuation = (sequence, cell) => {
|
|
287
|
+
const link = {
|
|
288
|
+
cell,
|
|
289
|
+
next: null
|
|
290
|
+
};
|
|
291
|
+
if (sequence.tail) sequence.tail.next = link;
|
|
292
|
+
else sequence.head = link;
|
|
293
|
+
sequence.tail = link;
|
|
294
|
+
};
|
|
295
|
+
const continuationSequence = (cells) => {
|
|
296
|
+
const sequence = {
|
|
297
|
+
head: null,
|
|
298
|
+
tail: null
|
|
299
|
+
};
|
|
300
|
+
for (const cell of cells) appendContinuation(sequence, cell);
|
|
301
|
+
return sequence;
|
|
302
|
+
};
|
|
303
|
+
const appendContinuationSequence = (destination, source) => {
|
|
304
|
+
if (!source.head) return;
|
|
305
|
+
if (destination.tail) destination.tail.next = source.head;
|
|
306
|
+
else destination.head = source.head;
|
|
307
|
+
destination.tail = source.tail;
|
|
308
|
+
};
|
|
309
|
+
const materializeContinuation = (entry) => {
|
|
310
|
+
if (!entry.continuation) return;
|
|
311
|
+
const cells = [];
|
|
312
|
+
for (let link = entry.continuation.head; link !== null; link = link.next) cells.push(link.cell);
|
|
313
|
+
entry.node = entry.node.type.create({
|
|
314
|
+
...entry.node.attrs,
|
|
315
|
+
_docxVMergeContinuationCells: transportTableCellsWithParagraphPropertySources(cells)
|
|
316
|
+
}, entry.node.content, entry.node.marks);
|
|
317
|
+
entry.continuation = null;
|
|
318
|
+
};
|
|
319
|
+
const failedTableResolution = (table) => ({
|
|
320
|
+
node: table,
|
|
321
|
+
changed: false,
|
|
322
|
+
structural: false,
|
|
323
|
+
failed: true,
|
|
324
|
+
changedParagraphRanges: [],
|
|
325
|
+
paragraphOffsets: [],
|
|
326
|
+
positionMap: StepMap.empty
|
|
327
|
+
});
|
|
328
|
+
/** Replay width deletions by live column rank without shifting the remaining array. */
|
|
329
|
+
const compactColumnWidths = (widths, removals) => {
|
|
330
|
+
if (removals.length === 0) return [...widths];
|
|
331
|
+
const length = widths.length;
|
|
332
|
+
const tree = new Int32Array(length + 1);
|
|
333
|
+
const removed = new Uint8Array(length);
|
|
334
|
+
for (let index = 1; index <= length; index++) tree[index] = index & -index;
|
|
335
|
+
let highestBit = 1;
|
|
336
|
+
while (highestBit * 2 <= length) highestBit *= 2;
|
|
337
|
+
let remaining = length;
|
|
338
|
+
for (const { left, count } of removals) {
|
|
339
|
+
const start = Math.min(left, remaining);
|
|
340
|
+
const removedCount = Math.min(count, remaining - start);
|
|
341
|
+
for (let deleted = 0; deleted < removedCount; deleted++) {
|
|
342
|
+
let rank = start + 1;
|
|
343
|
+
let originalIndex = 0;
|
|
344
|
+
for (let bit = highestBit; bit > 0; bit >>= 1) {
|
|
345
|
+
const next = originalIndex + bit;
|
|
346
|
+
if (next <= length && (tree[next] ?? 0) < rank) {
|
|
347
|
+
originalIndex = next;
|
|
348
|
+
rank -= tree[next] ?? 0;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
removed[originalIndex] = 1;
|
|
352
|
+
for (let index = originalIndex + 1; index <= length; index += index & -index) tree[index] = (tree[index] ?? 0) - 1;
|
|
353
|
+
remaining--;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return widths.filter((_width, index) => removed[index] === 0);
|
|
357
|
+
};
|
|
358
|
+
/** Resolve all cell edits in reverse order against one grid and mutable slots. */
|
|
359
|
+
const resolvePureTableMerges = ({ table, mode, rowMetadata, tablePropertyTouched, sourceTable }) => {
|
|
360
|
+
const map = TableMap.get(table);
|
|
361
|
+
const cellRectangle = indexedTableCells(map);
|
|
362
|
+
const rows = Array.from({ length: table.childCount }, (_, index) => table.child(index));
|
|
363
|
+
const rowCells = rows.map(() => /* @__PURE__ */ new Map());
|
|
364
|
+
const rowOccupancy = rows.map(() => 0);
|
|
365
|
+
const activeRows = rows.map(() => true);
|
|
366
|
+
const widthCounts = /* @__PURE__ */ new Map();
|
|
367
|
+
const authoredWidths = expectTableAttrs(table).columnWidths;
|
|
368
|
+
const columnWidths = authoredWidths?.length === map.width ? [...authoredWidths] : void 0;
|
|
369
|
+
const widthRemovals = [];
|
|
370
|
+
let currentWidth = map.width;
|
|
371
|
+
let removedCell = false;
|
|
372
|
+
const deletedRows = /* @__PURE__ */ new Set();
|
|
373
|
+
const byPosition = /* @__PURE__ */ new Map();
|
|
374
|
+
const ordered = [];
|
|
375
|
+
let rowOffset = 0;
|
|
376
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
377
|
+
const row = elementAt(rows, rowIndex);
|
|
378
|
+
let cellOffset = rowOffset + 1;
|
|
379
|
+
for (let cellIndex = 0; cellIndex < row.childCount; cellIndex++) {
|
|
380
|
+
const node = row.child(cellIndex);
|
|
381
|
+
const rectangle = cellRectangle(cellOffset);
|
|
382
|
+
const left = rectangle.left;
|
|
383
|
+
for (let coveredRow = rectangle.top; coveredRow < rectangle.bottom; coveredRow++) rowOccupancy[coveredRow] = elementAt(rowOccupancy, coveredRow) + (rectangle.right - rectangle.left);
|
|
384
|
+
const initial = elementAt(elementAt(rowMetadata, rowIndex).cells, cellIndex);
|
|
385
|
+
const entry = {
|
|
386
|
+
node,
|
|
387
|
+
position: cellOffset,
|
|
388
|
+
left,
|
|
389
|
+
row: rowIndex,
|
|
390
|
+
sourcePosition: initial.sourcePosition,
|
|
391
|
+
mapSourcePosition: initial.mapSourcePosition,
|
|
392
|
+
touched: initial.touched,
|
|
393
|
+
continuation: null
|
|
394
|
+
};
|
|
395
|
+
elementAt(rowCells, rowIndex).set(left, entry);
|
|
396
|
+
byPosition.set(cellOffset, entry);
|
|
397
|
+
ordered.push(entry);
|
|
398
|
+
cellOffset += node.nodeSize;
|
|
399
|
+
}
|
|
400
|
+
rowOffset += row.nodeSize;
|
|
401
|
+
}
|
|
402
|
+
for (const width of rowOccupancy) widthCounts.set(width, (widthCounts.get(width) ?? 0) + 1);
|
|
403
|
+
const changeRowWidth = (rowIndex, nextWidth) => {
|
|
404
|
+
if (!elementAt(activeRows, rowIndex)) return;
|
|
405
|
+
const previous = elementAt(rowOccupancy, rowIndex);
|
|
406
|
+
widthCounts.set(previous, (widthCounts.get(previous) ?? 0) - 1);
|
|
407
|
+
rowOccupancy[rowIndex] = nextWidth;
|
|
408
|
+
widthCounts.set(nextWidth, (widthCounts.get(nextWidth) ?? 0) + 1);
|
|
409
|
+
};
|
|
410
|
+
for (let index = ordered.length - 1; index >= 0; index--) {
|
|
411
|
+
const entry = elementAt(ordered, index);
|
|
412
|
+
const marker = cellRevisionMarker(entry.node);
|
|
413
|
+
if (marker && marker.kind !== "merge") {
|
|
414
|
+
const view = mode === "accept" ? "final" : "original";
|
|
415
|
+
if (isTableCellRetainedInReviewView(marker.kind, view)) {
|
|
416
|
+
entry.touched = true;
|
|
417
|
+
entry.node = entry.node.type.create({
|
|
418
|
+
...entry.node.attrs,
|
|
419
|
+
cellMarker: null
|
|
420
|
+
}, entry.node.content, entry.node.marks);
|
|
421
|
+
} else {
|
|
422
|
+
removedCell = true;
|
|
423
|
+
const previousWidth = currentWidth;
|
|
424
|
+
const rectangle = cellRectangle(entry.position);
|
|
425
|
+
const colspan = rectangle.right - rectangle.left;
|
|
426
|
+
for (let coveredRow = rectangle.top; coveredRow < rectangle.bottom; coveredRow++) changeRowWidth(coveredRow, elementAt(rowOccupancy, coveredRow) - colspan);
|
|
427
|
+
elementAt(rowCells, entry.row).delete(entry.left);
|
|
428
|
+
if (elementAt(rowCells, entry.row).size === 0) {
|
|
429
|
+
deletedRows.add(entry.row);
|
|
430
|
+
activeRows[entry.row] = false;
|
|
431
|
+
const rowWidth = elementAt(rowOccupancy, entry.row);
|
|
432
|
+
widthCounts.set(rowWidth, (widthCounts.get(rowWidth) ?? 0) - 1);
|
|
433
|
+
}
|
|
434
|
+
while (currentWidth > 0 && (widthCounts.get(currentWidth) ?? 0) === 0) currentWidth--;
|
|
435
|
+
if (columnWidths && currentWidth < previousWidth) widthRemovals.push({
|
|
436
|
+
left: entry.left,
|
|
437
|
+
count: previousWidth - currentWidth
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
} else if (marker?.kind === "merge") {
|
|
441
|
+
const joinsAbove = mode === "accept" ? isTableCellMergeRevisionContinuation(marker.verticalMerge) && acceptedMergeFoldsIntoCellAbove(entry.node) : isTableCellMergeRevisionContinuation(marker.verticalMergeOriginal);
|
|
442
|
+
if (mode === "accept" && !joinsAbove) {
|
|
443
|
+
entry.touched = true;
|
|
444
|
+
entry.node = entry.node.type.create({
|
|
445
|
+
...entry.node.attrs,
|
|
446
|
+
cellMarker: null
|
|
447
|
+
}, entry.node.content, entry.node.marks);
|
|
448
|
+
} else if (!joinsAbove) {
|
|
449
|
+
entry.touched = true;
|
|
450
|
+
const original = entry.node.attrs["_originalFormatting"];
|
|
451
|
+
let formatting = original;
|
|
452
|
+
if (typeof original === "object" && original !== null) {
|
|
453
|
+
const copy = { ...original };
|
|
454
|
+
delete copy["vMerge"];
|
|
455
|
+
formatting = copy;
|
|
456
|
+
}
|
|
457
|
+
entry.node = entry.node.type.create({
|
|
458
|
+
...entry.node.attrs,
|
|
459
|
+
cellMarker: null,
|
|
460
|
+
_originalFormatting: formatting
|
|
461
|
+
}, entry.node.content, entry.node.marks);
|
|
462
|
+
} else {
|
|
463
|
+
const rectangle = cellRectangle(entry.position);
|
|
464
|
+
if (rectangle.top === 0) return failedTableResolution(table);
|
|
465
|
+
const abovePosition = map.map[(rectangle.top - 1) * map.width + rectangle.left];
|
|
466
|
+
if (abovePosition === void 0) return failedTableResolution(table);
|
|
467
|
+
const aboveRectangle = cellRectangle(abovePosition);
|
|
468
|
+
const above = byPosition.get(abovePosition);
|
|
469
|
+
if (!above || !elementAt(rowCells, above.row).has(above.left) || aboveRectangle.left !== rectangle.left || aboveRectangle.right !== rectangle.right || aboveRectangle.bottom !== rectangle.top) return failedTableResolution(table);
|
|
470
|
+
const aboveRowspan = above.node.attrs["rowspan"];
|
|
471
|
+
const cellRowspan = entry.node.attrs["rowspan"];
|
|
472
|
+
if (typeof aboveRowspan !== "number" || typeof cellRowspan !== "number" || aboveRowspan < 1 || cellRowspan < 1) return failedTableResolution(table);
|
|
473
|
+
above.continuation ??= continuationSequence(tableCellContinuationCells(above.node, aboveRowspan));
|
|
474
|
+
appendContinuation(above.continuation, tableCellContinuationFromNode(entry.node));
|
|
475
|
+
const nested = entry.continuation ?? continuationSequence(tableCellContinuationPayload(entry.node)?.cells ?? []);
|
|
476
|
+
appendContinuationSequence(above.continuation, nested);
|
|
477
|
+
above.node = above.node.type.create({
|
|
478
|
+
...above.node.attrs,
|
|
479
|
+
rowspan: aboveRowspan + cellRowspan
|
|
480
|
+
}, above.node.content, above.node.marks);
|
|
481
|
+
elementAt(rowCells, entry.row).delete(entry.left);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (!elementAt(rowCells, entry.row).has(entry.left)) continue;
|
|
485
|
+
if (!tableCellContinuationPayload(entry.node)?.cells.some((cell) => getTableCellMergeChange(cell) !== null)) continue;
|
|
486
|
+
materializeContinuation(entry);
|
|
487
|
+
const payload = tableCellContinuationPayload(entry.node);
|
|
488
|
+
if (!payload) return failedTableResolution(table);
|
|
489
|
+
const stored = payload.cells;
|
|
490
|
+
const splitIndices = [];
|
|
491
|
+
let matched = false;
|
|
492
|
+
const nextCells = stored.map((source, sourceIndex) => {
|
|
493
|
+
const change = getTableCellMergeChange(source);
|
|
494
|
+
if (!change) return source;
|
|
495
|
+
matched = true;
|
|
496
|
+
if (mode === "reject" && isTableCellMergeRevisionContinuation(change.verticalMerge) && !isTableCellMergeRevisionContinuation(change.verticalMergeOriginal)) splitIndices.push(sourceIndex);
|
|
497
|
+
const cleaned = { ...source };
|
|
498
|
+
delete cleaned.structuralChange;
|
|
499
|
+
return cleaned;
|
|
500
|
+
});
|
|
501
|
+
if (!matched) continue;
|
|
502
|
+
if (mode === "accept" || splitIndices.length === 0) {
|
|
503
|
+
entry.touched = true;
|
|
504
|
+
entry.node = entry.node.type.create({
|
|
505
|
+
...entry.node.attrs,
|
|
506
|
+
_docxVMergeContinuationCells: nextCells
|
|
507
|
+
}, entry.node.content, entry.node.marks);
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
const firstSplitIndex = splitIndices.at(0);
|
|
511
|
+
if (firstSplitIndex === void 0 || splitIndices.length !== stored.length - firstSplitIndex || splitIndices.some((splitIndex, offset) => splitIndex !== firstSplitIndex + offset)) return failedTableResolution(table);
|
|
512
|
+
const rectangle = cellRectangle(entry.position);
|
|
513
|
+
const rowspan = entry.node.attrs["rowspan"];
|
|
514
|
+
if (typeof rowspan !== "number" || rowspan !== stored.length + 1 || rectangle.bottom - rectangle.top !== rowspan) return failedTableResolution(table);
|
|
515
|
+
const restored = restoreTableCellsWithParagraphPropertySources(payload);
|
|
516
|
+
for (const splitIndex of splitIndices) {
|
|
517
|
+
const source = restored[splitIndex];
|
|
518
|
+
const restoredCell = source && createRestoredTableCell(entry.node, source);
|
|
519
|
+
const rowIndex = rectangle.top + splitIndex + 1;
|
|
520
|
+
if (!restoredCell || elementAt(rowCells, rowIndex).has(rectangle.left)) return failedTableResolution(table);
|
|
521
|
+
elementAt(rowCells, rowIndex).set(rectangle.left, {
|
|
522
|
+
node: restoredCell,
|
|
523
|
+
position: -1,
|
|
524
|
+
left: rectangle.left,
|
|
525
|
+
row: rowIndex,
|
|
526
|
+
sourcePosition: -1,
|
|
527
|
+
mapSourcePosition: -1,
|
|
528
|
+
touched: true,
|
|
529
|
+
continuation: null
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
const remaining = nextCells.slice(0, firstSplitIndex);
|
|
533
|
+
entry.node = entry.node.type.create({
|
|
534
|
+
...entry.node.attrs,
|
|
535
|
+
rowspan: firstSplitIndex + 1,
|
|
536
|
+
_docxVMergeContinuationCells: remaining.length > 0 ? remaining : null
|
|
537
|
+
}, entry.node.content, entry.node.marks);
|
|
538
|
+
}
|
|
539
|
+
if (deletedRows.size === rows.length) return {
|
|
540
|
+
node: null,
|
|
541
|
+
changed: true,
|
|
542
|
+
structural: true,
|
|
543
|
+
failed: false,
|
|
544
|
+
changedParagraphRanges: [],
|
|
545
|
+
paragraphOffsets: [],
|
|
546
|
+
positionMap: new StepMap([
|
|
547
|
+
0,
|
|
548
|
+
sourceTable.nodeSize,
|
|
549
|
+
0
|
|
550
|
+
])
|
|
551
|
+
};
|
|
552
|
+
const keptBefore = [0];
|
|
553
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) keptBefore.push((keptBefore.at(-1) ?? 0) + Number(!deletedRows.has(rowIndex)));
|
|
554
|
+
const compacted = rows.map(() => /* @__PURE__ */ new Map());
|
|
555
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) for (const entry of elementAt(rowCells, rowIndex).values()) {
|
|
556
|
+
materializeContinuation(entry);
|
|
557
|
+
const originalRowspan = entry.node.attrs["rowspan"];
|
|
558
|
+
if (typeof originalRowspan !== "number") continue;
|
|
559
|
+
const bottom = Math.min(rowIndex + originalRowspan, rows.length);
|
|
560
|
+
let destination = rowIndex;
|
|
561
|
+
while (destination < bottom && deletedRows.has(destination)) destination++;
|
|
562
|
+
if (destination === bottom) continue;
|
|
563
|
+
const rowspan = elementAt(keptBefore, bottom) - elementAt(keptBefore, destination);
|
|
564
|
+
const node = rowspan === originalRowspan ? entry.node : entry.node.type.create({
|
|
565
|
+
...entry.node.attrs,
|
|
566
|
+
rowspan
|
|
567
|
+
}, entry.node.content, entry.node.marks);
|
|
568
|
+
elementAt(compacted, destination).set(entry.left, {
|
|
569
|
+
...entry,
|
|
570
|
+
node,
|
|
571
|
+
row: destination,
|
|
572
|
+
touched: entry.touched || rowspan !== originalRowspan
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
const nextRowMetadata = [];
|
|
576
|
+
const nextRows = rows.flatMap((row, rowIndex) => {
|
|
577
|
+
if (deletedRows.has(rowIndex)) return [];
|
|
578
|
+
const cells = [];
|
|
579
|
+
const cellMetadata = [];
|
|
580
|
+
for (let column = 0; column < map.width; column++) {
|
|
581
|
+
const entry = elementAt(compacted, rowIndex).get(column);
|
|
582
|
+
if (entry) {
|
|
583
|
+
cells.push(entry.node);
|
|
584
|
+
cellMetadata.push(entry);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
nextRowMetadata.push({
|
|
588
|
+
touched: elementAt(rowMetadata, rowIndex).touched,
|
|
589
|
+
cells: cellMetadata
|
|
590
|
+
});
|
|
591
|
+
return [row.type.create(row.attrs, cells, row.marks)];
|
|
592
|
+
});
|
|
593
|
+
let nextTable = table.type.create(table.attrs, nextRows, table.marks);
|
|
594
|
+
const nextWidth = TableMap.get(nextTable).width;
|
|
595
|
+
const gridChanged = removedCell && nextWidth < map.width;
|
|
596
|
+
if (gridChanged) {
|
|
597
|
+
const survivingColumnWidths = columnWidths === void 0 ? void 0 : compactColumnWidths(columnWidths, widthRemovals);
|
|
598
|
+
const formatting = expectTableAttrs(nextTable)._originalFormatting;
|
|
599
|
+
const originalFormatting = formatting ? { ...formatting } : void 0;
|
|
600
|
+
if (originalFormatting) delete originalFormatting.gridSourceXml;
|
|
601
|
+
nextTable = nextTable.type.create(mergeTableAttrs(nextTable, {
|
|
602
|
+
columnWidths: survivingColumnWidths?.length === nextWidth ? survivingColumnWidths : void 0,
|
|
603
|
+
_originalFormatting: originalFormatting
|
|
604
|
+
}), nextTable.content, nextTable.marks);
|
|
605
|
+
}
|
|
606
|
+
return {
|
|
607
|
+
node: nextTable,
|
|
608
|
+
changed: true,
|
|
609
|
+
structural: true,
|
|
610
|
+
failed: false,
|
|
611
|
+
...tableResolutionMetadata({
|
|
612
|
+
table: nextTable,
|
|
613
|
+
rows: nextRowMetadata,
|
|
614
|
+
tableTouched: tablePropertyTouched || gridChanged,
|
|
615
|
+
sourceTable
|
|
616
|
+
})
|
|
617
|
+
};
|
|
618
|
+
};
|
|
619
|
+
//#endregion
|
|
620
|
+
export { resolveAllTableChanges };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NodeAttrsPropertyRevisionSite } from "../revisionCarriers.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
//#region src/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts
|
|
4
|
+
/** Resolve one property-change site without a transaction. */
|
|
5
|
+
type ResolveNodePropertyChangeAttrsOptions = {
|
|
6
|
+
node: Node;
|
|
7
|
+
site: NodeAttrsPropertyRevisionSite;
|
|
8
|
+
mode: "accept" | "reject";
|
|
9
|
+
revisionSet: ReadonlySet<number> | null;
|
|
10
|
+
};
|
|
11
|
+
declare const resolveNodePropertyChangeAttrs: ({ node, site, mode, revisionSet }: ResolveNodePropertyChangeAttrsOptions) => Record<string, unknown> | null;
|
|
12
|
+
/** Resolve every node-attr site, including both independent sites on a row. */
|
|
13
|
+
declare const resolveAllNodePropertyChangeAttrs: (node: Node, mode: "accept" | "reject") => Node;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { resolveAllNodePropertyChangeAttrs, resolveNodePropertyChangeAttrs };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { nodePropertyRevisionSites, propertyRevisionMetadata, propertyRevisionRecords } from "../revisionCarriers.js";
|
|
2
|
+
import { tableCellRejectAttrPatch, tablePropertyExceptionsRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch } from "./propertyChangeScope.js";
|
|
3
|
+
//#region src/prosemirror/commands/resolveNodePropertyChangeAttrs.ts
|
|
4
|
+
/** The old property set each node-attr revision restores on rejection. */
|
|
5
|
+
const NODE_ATTRS_REJECT_PATCHES = {
|
|
6
|
+
tablePropertyChange: (previousFormatting) => tableRejectAttrPatch(previousFormatting),
|
|
7
|
+
tablePropertyExceptionChange: (previousFormatting) => tablePropertyExceptionsRejectAttrPatch(previousFormatting),
|
|
8
|
+
tableRowPropertyChange: (previousFormatting) => tableRowRejectAttrPatch(previousFormatting),
|
|
9
|
+
tableCellPropertyChange: (previousFormatting, node) => tableCellRejectAttrPatch(previousFormatting, node.attrs["_originalFormatting"])
|
|
10
|
+
};
|
|
11
|
+
const resolveNodePropertyChangeAttrs = ({ node, site, mode, revisionSet }) => {
|
|
12
|
+
const changes = propertyRevisionRecords(node, site);
|
|
13
|
+
if (changes.length === 0) return null;
|
|
14
|
+
const matches = changes.filter((change) => {
|
|
15
|
+
const metadata = propertyRevisionMetadata(change.info);
|
|
16
|
+
return revisionSet === null || metadata !== null && revisionSet.has(metadata.id);
|
|
17
|
+
});
|
|
18
|
+
if (matches.length === 0) return null;
|
|
19
|
+
const remaining = revisionSet === null ? [] : changes.filter((change) => !matches.includes(change));
|
|
20
|
+
const nextAttrs = {
|
|
21
|
+
...node.attrs,
|
|
22
|
+
[site.attr]: remaining.length > 0 ? remaining : null
|
|
23
|
+
};
|
|
24
|
+
if (mode === "reject") {
|
|
25
|
+
const rejectPatch = NODE_ATTRS_REJECT_PATCHES[site.kind];
|
|
26
|
+
for (const change of matches.toReversed()) Object.assign(nextAttrs, rejectPatch(change.previousFormatting, node));
|
|
27
|
+
}
|
|
28
|
+
return nextAttrs;
|
|
29
|
+
};
|
|
30
|
+
/** Resolve every node-attr site, including both independent sites on a row. */
|
|
31
|
+
const resolveAllNodePropertyChangeAttrs = (node, mode) => {
|
|
32
|
+
let current = node;
|
|
33
|
+
for (const site of nodePropertyRevisionSites(node.type.name)) {
|
|
34
|
+
if (site.resolution !== "node-attrs") continue;
|
|
35
|
+
const attrs = resolveNodePropertyChangeAttrs({
|
|
36
|
+
node: current,
|
|
37
|
+
site,
|
|
38
|
+
mode,
|
|
39
|
+
revisionSet: null
|
|
40
|
+
});
|
|
41
|
+
if (attrs !== null) current = current.type.create(attrs, current.content, current.marks);
|
|
42
|
+
}
|
|
43
|
+
return current;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { resolveAllNodePropertyChangeAttrs, resolveNodePropertyChangeAttrs };
|