@stll/folio-core 0.69.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +4 -4
- package/dist/ai-edits/apply.d.ts +39 -16
- package/dist/ai-edits/apply.js +1014 -723
- package/dist/ai-edits/block-identity.d.ts +6 -0
- package/dist/ai-edits/block-identity.js +11 -1
- package/dist/ai-edits/blockRange.d.ts +9 -0
- package/dist/ai-edits/clean-text.d.ts +2 -0
- package/dist/ai-edits/clean-text.js +2 -1
- package/dist/ai-edits/comment-lifecycle.d.ts +24 -0
- package/dist/ai-edits/comment-lifecycle.js +17 -8
- package/dist/ai-edits/directJoin.d.ts +30 -0
- package/dist/ai-edits/directJoin.js +30 -0
- package/dist/ai-edits/existingRevisions.d.ts +9 -0
- package/dist/ai-edits/existingRevisions.js +30 -0
- package/dist/ai-edits/finalSectionReview.d.ts +11 -0
- package/dist/ai-edits/finalSectionReview.js +26 -0
- package/dist/ai-edits/headless.d.ts +275 -14
- package/dist/ai-edits/headless.js +1595 -193
- package/dist/ai-edits/index.d.ts +11 -10
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/markdownInsertion.d.ts +25 -0
- package/dist/ai-edits/markdownInsertion.js +67 -0
- package/dist/ai-edits/minimal-replacement.d.ts +120 -1
- package/dist/ai-edits/minimal-replacement.js +81 -1
- package/dist/ai-edits/newListNumbering.d.ts +20 -9
- package/dist/ai-edits/newListNumbering.js +25 -10
- package/dist/ai-edits/note-references.d.ts +19 -1
- package/dist/ai-edits/note-references.js +3 -1
- package/dist/ai-edits/pending-suggestions.d.ts +44 -2
- package/dist/ai-edits/pending-suggestions.js +481 -20
- package/dist/ai-edits/pendingJoin.d.ts +170 -0
- package/dist/ai-edits/pendingJoin.js +272 -0
- package/dist/ai-edits/read.d.ts +57 -4
- package/dist/ai-edits/read.js +317 -40
- package/dist/ai-edits/removed-blocks.d.ts +1 -1
- package/dist/ai-edits/result-validation.d.ts +36 -1
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +20 -0
- package/dist/ai-edits/retired-comment-receipts.js +165 -0
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/snapshot.d.ts +12 -3
- package/dist/ai-edits/snapshot.js +9 -7
- package/dist/ai-edits/snapshotBatchFacts.d.ts +52 -0
- package/dist/ai-edits/snapshotBatchFacts.js +184 -0
- package/dist/ai-edits/table-geometry.d.ts +45 -11
- package/dist/ai-edits/table-geometry.js +141 -26
- package/dist/ai-edits/table-mutation-plan.d.ts +12 -0
- package/dist/ai-edits/table-mutation-plan.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +26 -3
- package/dist/ai-edits/table-row-column-mutations.js +90 -11
- package/dist/ai-edits/table-template.d.ts +21 -0
- package/dist/ai-edits/tableInsertionModes.d.ts +10 -0
- package/dist/ai-edits/tableInsertionModes.js +8 -0
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +23 -0
- package/dist/ai-edits/tracked-batch-fidelity.js +357 -0
- package/dist/ai-edits/types.d.ts +81 -15
- package/dist/ai-edits/undefinedReferences.d.ts +49 -0
- package/dist/ai-edits/undefinedReferences.js +234 -0
- package/dist/ai-suggestions/apply.d.ts +12 -0
- package/dist/ai-suggestions/conflict.d.ts +9 -0
- package/dist/ai-suggestions/text-positions.d.ts +13 -0
- package/dist/canonical/batchCommentReferences.d.ts +20 -0
- package/dist/canonical/batchCommentReferences.js +93 -0
- package/dist/canonical/canonicalBatchReview.d.ts +25 -0
- package/dist/canonical/canonicalBatchReview.js +132 -0
- package/dist/{controller → canonical}/canonicalComments.d.ts +7 -4
- package/dist/{controller → canonical}/canonicalComments.js +36 -9
- package/dist/canonical/canonicalCompilerRefusal.d.ts +13 -0
- package/dist/canonical/canonicalCompilerRefusal.js +75 -0
- package/dist/canonical/canonicalIdLease.d.ts +40 -0
- package/dist/canonical/canonicalIdLease.js +96 -0
- package/dist/{controller → canonical}/canonicalInlineProjection.d.ts +1 -1
- package/dist/{controller → canonical}/canonicalInlineProjection.js +40 -20
- package/dist/canonical/canonicalInsertedCommentRange.d.ts +15 -0
- package/dist/canonical/canonicalInsertedCommentRange.js +43 -0
- package/dist/canonical/canonicalInsertionReplayIds.d.ts +40 -0
- package/dist/canonical/canonicalInsertionReplayIds.js +73 -0
- package/dist/canonical/canonicalJoinedReceipts.d.ts +11 -0
- package/dist/canonical/canonicalJoinedReceipts.js +22 -0
- package/dist/{controller → canonical}/canonicalListRendering.js +1 -1
- package/dist/{controller → canonical}/canonicalLockGuard.d.ts +12 -1
- package/dist/{controller → canonical}/canonicalLockGuard.js +96 -21
- package/dist/{controller → canonical}/canonicalOperations.js +1 -1
- package/dist/{controller → canonical}/canonicalProjectionBlocks.d.ts +11 -1
- package/dist/{controller → canonical}/canonicalProjectionBlocks.js +8 -4
- package/dist/{controller → canonical}/canonicalPublicOperations.d.ts +24 -9
- package/dist/canonical/canonicalPublicOperations.js +4791 -0
- package/dist/canonical/canonicalRemoteHistory.d.ts +48 -0
- package/dist/canonical/canonicalRemoteHistory.js +176 -0
- package/dist/canonical/canonicalRevisionLocks.d.ts +18 -0
- package/dist/canonical/canonicalRevisionLocks.js +30 -0
- package/dist/canonical/canonicalRevisionReceipts.d.ts +15 -0
- package/dist/canonical/canonicalRevisionReceipts.js +25 -0
- package/dist/canonical/canonicalRoomBase.d.ts +23 -0
- package/dist/canonical/canonicalRoomBase.js +38 -0
- package/dist/canonical/canonicalSeedContent.d.ts +36 -0
- package/dist/{controller → canonical}/canonicalSeedContent.js +53 -5
- package/dist/{controller → canonical}/canonicalSelection.js +1 -1
- package/dist/{controller → canonical}/canonicalSession.d.ts +239 -12
- package/dist/{controller → canonical}/canonicalSession.js +1069 -173
- package/dist/canonical/canonicalSourceNormalization.d.ts +42 -0
- package/dist/{controller → canonical}/canonicalSourceNormalization.js +41 -23
- package/dist/{controller → canonical}/canonicalTocSelection.js +1 -1
- package/dist/canonical/canonicalTrackedBatchFidelity.d.ts +9 -0
- package/dist/canonical/canonicalTrackedBatchFidelity.js +125 -0
- package/dist/canonical/canonicalWholeTextFidelity.d.ts +21 -0
- package/dist/canonical/canonicalWholeTextFidelity.js +88 -0
- package/dist/canonical/commentAnchorParagraph.d.ts +10 -0
- package/dist/canonical/commentAnchorParagraph.js +11 -0
- package/dist/canonical/controlEdges.d.ts +12 -0
- package/dist/canonical/controlEdges.js +17 -0
- package/dist/canonical/paragraphPatchAsRead.d.ts +19 -0
- package/dist/canonical/paragraphPatchAsRead.js +32 -0
- package/dist/canonical/propertySourcePreservation.d.ts +38 -0
- package/dist/canonical/propertySourcePreservation.js +129 -0
- package/dist/canonical/replacementRunSources.d.ts +29 -0
- package/dist/canonical/replacementRunSources.js +78 -0
- package/dist/compare/compare.d.ts +8 -6
- package/dist/compare/compare.js +37 -8
- package/dist/compare/content-alignment.d.ts +10 -1
- package/dist/compare/content-alignment.js +188 -27
- package/dist/compare/content.d.ts +9 -1
- package/dist/compare/content.js +2 -2
- package/dist/compare/formatting.d.ts +1 -0
- package/dist/compare/import-style-closure.d.ts +1 -1
- package/dist/compare/inline-atom-alignment.d.ts +83 -0
- package/dist/compare/inline-atom-alignment.js +173 -0
- package/dist/compare/inline-atoms-model.d.ts +65 -0
- package/dist/compare/inline-atoms-model.js +1131 -0
- package/dist/compare/inline-atoms.d.ts +4 -4
- package/dist/compare/inline-atoms.js +28 -139
- package/dist/compare/inline-provenance-model.d.ts +37 -0
- package/dist/compare/inline-provenance-model.js +138 -0
- package/dist/compare/inline-provenance.d.ts +52 -4
- package/dist/compare/inline-provenance.js +40 -7
- package/dist/compare/plan.d.ts +38 -4
- package/dist/compare/plan.js +22 -8
- package/dist/compare/scenario.d.ts +22 -1
- package/dist/compare/section-boundary-properties.d.ts +38 -5
- package/dist/compare/section-boundary-properties.js +164 -48
- package/dist/compare/style-resources.d.ts +3 -2
- package/dist/compare/style-resources.js +5 -4
- package/dist/compare/types.d.ts +5 -2
- package/dist/compare/verification.d.ts +24 -3
- package/dist/compare/verification.js +25 -18
- package/dist/compat/eigenpal.d.ts +32 -31
- package/dist/compat/eigenpal.js +3 -5
- package/dist/content-controls/findContentControls.d.ts +9 -0
- package/dist/content-controls/index.d.ts +8 -0
- package/dist/content-controls/mutateContentControls.d.ts +9 -0
- package/dist/controller/activeEditorStory.d.ts +1 -0
- package/dist/controller/anonymizationHighlights.d.ts +56 -0
- package/dist/controller/anonymizationHighlights.js +148 -0
- package/dist/controller/autocompleteSuggestion.d.ts +85 -0
- package/dist/controller/autocompleteSuggestion.js +213 -0
- package/dist/controller/canonicalClipboard.d.ts +2 -2
- package/dist/controller/canonicalClipboard.js +34 -14
- package/dist/controller/canonicalClipboardResources.js +9 -4
- package/dist/controller/canonicalCollaboration.d.ts +147 -0
- package/dist/controller/canonicalCollaboration.js +360 -0
- package/dist/controller/canonicalComposition.d.ts +7 -1
- package/dist/controller/canonicalComposition.js +14 -8
- package/dist/controller/canonicalContentControlValue.d.ts +17 -0
- package/dist/controller/canonicalContentControlValue.js +72 -0
- package/dist/controller/canonicalIndexedDbJournal.d.ts +6 -0
- package/dist/controller/canonicalIndexedDbJournal.js +80 -0
- package/dist/controller/canonicalInput.d.ts +13 -2
- package/dist/controller/canonicalInput.js +96 -11
- package/dist/controller/canonicalPresence.d.ts +63 -0
- package/dist/controller/canonicalPresence.js +125 -0
- package/dist/controller/canonicalReview.d.ts +1 -1
- package/dist/controller/canonicalReview.js +1 -1
- package/dist/controller/canonicalRoomAuthority.d.ts +66 -0
- package/dist/controller/canonicalRoomAuthority.js +119 -0
- package/dist/controller/canonicalRoomEditor.d.ts +87 -0
- package/dist/controller/canonicalRoomEditor.js +98 -0
- package/dist/controller/canonicalRoomTransport.d.ts +79 -0
- package/dist/controller/canonicalRoomTransport.js +104 -0
- package/dist/controller/canonicalRoomWire.d.ts +80 -0
- package/dist/controller/canonicalRoomWire.js +155 -0
- package/dist/controller/canonicalStoryEditor.d.ts +12 -0
- package/dist/controller/canonicalStoryEditor.js +39 -7
- package/dist/controller/canonicalStructure.d.ts +15 -5
- package/dist/controller/canonicalStructure.js +95 -34
- package/dist/controller/canonicalTabRoom.d.ts +91 -0
- package/dist/controller/canonicalTabRoom.js +553 -0
- package/dist/controller/canonicalYjsRoom.d.ts +102 -0
- package/dist/controller/canonicalYjsRoom.js +454 -0
- package/dist/controller/contentControlWidgetController.d.ts +16 -0
- package/dist/controller/contentControlWidgetController.js +7 -1
- package/dist/controller/documentChangeNotification.d.ts +5 -0
- package/dist/controller/documentChangeNotification.js +7 -0
- package/dist/controller/folioEditor.d.ts +12 -4
- package/dist/controller/folioEditor.js +18 -1
- package/dist/controller/folioEditorEvents.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +14 -1
- package/dist/controller/fontReadiness.js +4 -4
- package/dist/controller/headerFooterEditorManager.d.ts +13 -7
- package/dist/controller/headerFooterEditorManager.js +24 -25
- package/dist/controller/hiddenEditorApi.d.ts +87 -13
- package/dist/controller/hiddenEditorApi.js +41 -3
- package/dist/controller/hiddenEditorManager.d.ts +62 -17
- package/dist/controller/hiddenEditorManager.js +378 -78
- package/dist/controller/hyphenationReadiness.d.ts +10 -0
- package/dist/controller/layoutPipeline.d.ts +14 -12
- package/dist/controller/layoutPipeline.js +64 -53
- package/dist/controller/layoutSession.d.ts +7 -6
- package/dist/controller/legacyTextAddress.d.ts +9 -0
- package/dist/controller/legacyTextAddress.js +52 -0
- package/dist/controller/noteEditorManager.d.ts +14 -7
- package/dist/controller/noteEditorManager.js +33 -32
- package/dist/controller/textPositionLookup.d.ts +24 -0
- package/dist/controller/textPositionLookup.js +78 -0
- package/dist/display-list/build/buildContext.d.ts +11 -0
- package/dist/display-list/build/buildDisplayList.d.ts +14 -1
- package/dist/display-list/build/colors.d.ts +8 -0
- package/dist/display-list/build/floatingImages.d.ts +10 -0
- package/dist/display-list/build/fontTable.d.ts +8 -0
- package/dist/display-list/build/furniture.d.ts +14 -2
- package/dist/display-list/build/glyphs.d.ts +7 -0
- package/dist/display-list/build/headerFooterPrimitives.d.ts +13 -0
- package/dist/display-list/build/imagePrimitives.d.ts +10 -0
- package/dist/display-list/build/pageBorderPrimitives.d.ts +16 -2
- package/dist/display-list/build/pageFurniture.d.ts +13 -0
- package/dist/display-list/build/paragraphPrimitives.d.ts +18 -0
- package/dist/display-list/build/paragraphPrimitives.js +17 -5
- package/dist/display-list/build/previewPrimitives.d.ts +14 -0
- package/dist/display-list/build/regions.d.ts +14 -0
- package/dist/display-list/build/storyPrimitives.d.ts +16 -0
- package/dist/display-list/build/strokes.d.ts +21 -3
- package/dist/display-list/build/strokes.js +2 -3
- package/dist/display-list/build/tablePrimitives.d.ts +15 -1
- package/dist/display-list/build/tablePrimitives.js +92 -55
- package/dist/display-list/build/textBoxPrimitives.d.ts +6 -0
- package/dist/display-list/build/unsupported.d.ts +10 -0
- package/dist/display-list/build/watermarkPrimitives.d.ts +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.d.ts +33 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +12 -4
- package/dist/display-list/editor/displayListPagePainter.d.ts +29 -1
- package/dist/display-list/editor/pageRenderer.d.ts +7 -0
- package/dist/display-list/html/renderDisplayListToHtml.d.ts +10 -0
- package/dist/display-list/primitives.d.ts +12 -1
- package/dist/display-list/selectDisplayPages.d.ts +8 -0
- package/dist/display-list/types.d.ts +11 -0
- package/dist/document-operations.d.ts +35 -5
- package/dist/document-operations.js +178 -40
- package/dist/docx/attributeRemainder.d.ts +35 -1
- package/dist/docx/automaticNoteMarkImport.d.ts +12 -0
- package/dist/docx/automaticNoteMarkImport.js +41 -0
- package/dist/docx/blockContentParser.d.ts +14 -5
- package/dist/docx/blockContentParser.js +19 -0
- package/dist/docx/blockPlainText.d.ts +14 -0
- package/dist/docx/blockPlainText.js +55 -4
- package/dist/docx/bookmarkParser.d.ts +17 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +14 -0
- package/dist/docx/borderParser.d.ts +11 -0
- package/dist/docx/builtInStyles.d.ts +44 -1
- package/dist/docx/canonicalSave.d.ts +14 -4
- package/dist/docx/canonicalSave.js +128 -30
- package/dist/docx/canonicalSessionInput.d.ts +59 -4
- package/dist/docx/canonicalSessionInput.js +147 -6
- package/dist/docx/canonicalStoryRepack.d.ts +1 -0
- package/dist/docx/canonicalStoryRepack.js +2 -2
- package/dist/docx/chartPreview.js +10 -9
- package/dist/docx/commentAnchorIndex.d.ts +33 -7
- package/dist/docx/commentAnchorIndex.js +162 -36
- package/dist/docx/commentIdNormalization.d.ts +14 -0
- package/dist/docx/commentParagraphIds.d.ts +17 -0
- package/dist/docx/commentParagraphIds.js +79 -0
- package/dist/docx/commentParser.d.ts +20 -1
- package/dist/docx/commentParser.js +5 -0
- package/dist/docx/commentRangeIntegrity.js +27 -11
- package/dist/docx/commentRangeJoin.d.ts +21 -1
- package/dist/docx/commentRangeJoin.js +5 -1
- package/dist/docx/commentReferenceCompletion.d.ts +29 -2
- package/dist/docx/commentReferenceCompletion.js +4 -3
- package/dist/docx/commentReferenceNormalization.d.ts +17 -0
- package/dist/docx/commentReferenceNormalization.js +484 -49
- package/dist/docx/commentReplyMarkers.d.ts +22 -0
- package/dist/docx/compatibility.d.ts +10 -0
- package/dist/docx/containerChildren.d.ts +26 -1
- package/dist/docx/containerChildren.js +29 -3
- package/dist/docx/contentTypeRegistry.d.ts +16 -0
- package/dist/docx/contentTypeRegistry.js +48 -20
- package/dist/docx/danglingRelationshipReferences.d.ts +13 -0
- package/dist/docx/defaultParagraphStyle.d.ts +14 -1
- package/dist/docx/documentClone.d.ts +3 -2
- package/dist/docx/documentClone.js +1 -1
- package/dist/docx/documentParser.d.ts +28 -3
- package/dist/docx/documentParser.js +71 -4
- package/dist/docx/drawingAnchor.d.ts +17 -0
- package/dist/docx/drawingGroupChildren.d.ts +12 -0
- package/dist/docx/drawingIdNormalization.d.ts +8 -0
- package/dist/docx/drawingIdNormalization.js +46 -1
- package/dist/docx/drawingUtils.d.ts +6 -0
- package/dist/docx/drawingUtils.js +2 -2
- package/dist/docx/encryption/agileDecryption.d.ts +7 -0
- package/dist/docx/ensureParaIds.d.ts +73 -0
- package/dist/docx/ensureParaIds.js +299 -59
- package/dist/docx/ensureUniqueControlIds.js +10 -3
- package/dist/docx/ensureUniqueRevisionIds.d.ts +28 -0
- package/dist/docx/ensureUniqueRevisionIds.js +140 -0
- package/dist/docx/fieldParser.d.ts +27 -2
- package/dist/docx/fieldState.d.ts +15 -0
- package/dist/docx/fieldWrapperCaptures.d.ts +18 -0
- package/dist/docx/fieldWrapperCaptures.js +117 -0
- package/dist/docx/foldedListNumberFields.d.ts +14 -0
- package/dist/docx/fontTableParser.d.ts +11 -0
- package/dist/docx/footnoteParser.d.ts +24 -3
- package/dist/docx/footnoteParser.js +29 -6
- package/dist/docx/graphicFrameLocks.d.ts +9 -1
- package/dist/docx/groupDrawingParser.d.ts +2 -2
- package/dist/docx/headerFooterParser.d.ts +37 -5
- package/dist/docx/headerFooterParser.js +18 -4
- package/dist/docx/headerFooterRefParser.d.ts +7 -0
- package/dist/docx/hostCommentThreads.d.ts +10 -1
- package/dist/docx/hyperlinkParser.d.ts +20 -3
- package/dist/docx/hyperlinkParser.js +19 -24
- package/dist/docx/imageParser.d.ts +27 -0
- package/dist/docx/index.d.ts +3 -3
- package/dist/docx/inlineContentRemovals.d.ts +8 -0
- package/dist/docx/inlineWrapperContent.d.ts +33 -1
- package/dist/docx/inlineWrapperContent.js +145 -1
- package/dist/docx/inlineWrapperParser.d.ts +14 -0
- package/dist/docx/listMarkerComputation.d.ts +37 -6
- package/dist/docx/listMarkerComputation.js +77 -28
- package/dist/docx/listModelNormalization.d.ts +24 -8
- package/dist/docx/listModelNormalization.js +426 -142
- package/dist/docx/listNumberingInstances.d.ts +38 -8
- package/dist/docx/listNumberingInstances.js +89 -42
- package/dist/docx/mainDocumentPart.d.ts +22 -1
- package/dist/docx/mainDocumentPart.js +51 -12
- package/dist/docx/markupRangeMarker.d.ts +16 -0
- package/dist/docx/markupRangeMarker.js +11 -2
- package/dist/docx/mathToMathml.d.ts +28 -0
- package/dist/docx/mergePropertyChangeLinks.d.ts +11 -0
- package/dist/docx/mergePropertyChangeLinks.js +30 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +6 -0
- package/dist/docx/normalizeBaseDirection.d.ts +17 -0
- package/dist/docx/normalizedSourceParts.d.ts +21 -0
- package/dist/docx/normalizedSourceParts.js +81 -0
- package/dist/docx/notePropertiesParser.d.ts +7 -0
- package/dist/docx/noteReferenceMark.d.ts +9 -0
- package/dist/docx/noteReferenceStyles.d.ts +13 -0
- package/dist/docx/numberingParser.d.ts +12 -0
- package/dist/docx/numberingReference.d.ts +10 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +15 -0
- package/dist/docx/packageRelationshipsRoot.d.ts +24 -0
- package/dist/docx/packageRelationshipsRoot.js +28 -0
- package/dist/docx/packageUnnamedParagraphIds.d.ts +18 -0
- package/dist/docx/packageUnnamedParagraphIds.js +78 -0
- package/dist/docx/paraIdAttribute.d.ts +15 -0
- package/dist/docx/paragraphParser.d.ts +15 -3
- package/dist/docx/paragraphParser.js +126 -140
- package/dist/docx/paragraphProperties.d.ts +15 -1
- package/dist/docx/paragraphProperties.js +3 -5
- package/dist/docx/paragraphPropertySource.d.ts +55 -21
- package/dist/docx/paragraphPropertySource.js +183 -40
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTraversal.d.ts +39 -4
- package/dist/docx/paragraphTraversal.js +158 -42
- package/dist/docx/parseContext.d.ts +15 -0
- package/dist/docx/parseWarningMessage.d.ts +9 -0
- package/dist/docx/parseWarningMessage.js +7 -0
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +103 -29
- package/dist/docx/parserEnums.d.ts +21 -0
- package/dist/docx/partRelationships.d.ts +15 -0
- package/dist/docx/partRelationships.js +58 -0
- package/dist/docx/preservedRunContent.d.ts +2 -1
- package/dist/docx/preservedRunContent.js +40 -1
- package/dist/docx/previewBudget.d.ts +31 -0
- package/dist/docx/relsParser.d.ts +23 -0
- package/dist/docx/removeHeaderFooterParts.d.ts +1 -1
- package/dist/docx/replyToComment.d.ts +22 -1
- package/dist/docx/replyToComment.js +25 -21
- package/dist/docx/reviewResolutionProvenance.d.ts +32 -5
- package/dist/docx/reviewResolutionProvenance.js +229 -38
- package/dist/docx/rezip.d.ts +58 -11
- package/dist/docx/rezip.js +367 -101
- package/dist/docx/runConsolidator.d.ts +13 -0
- package/dist/docx/runParser.d.ts +4 -3
- package/dist/docx/runParser.js +27 -6
- package/dist/docx/runPayload.d.ts +29 -0
- package/dist/docx/saveDiagnostics.d.ts +3 -5
- package/dist/docx/sdtProperties.d.ts +17 -0
- package/dist/docx/sdtPropertiesPatch.d.ts +14 -0
- package/dist/docx/sectionParser.d.ts +21 -0
- package/dist/docx/sectionParser.js +1 -6
- package/dist/docx/selectiveSave.js +271 -80
- package/dist/docx/selectiveXmlPatch.d.ts +36 -1
- package/dist/docx/selectiveXmlPatch.js +342 -78
- package/dist/docx/serializer/blockSdtSerializer.d.ts +10 -0
- package/dist/docx/serializer/borderSerializer.d.ts +8 -0
- package/dist/docx/serializer/commentSerializer.d.ts +12 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.d.ts +21 -3
- package/dist/docx/serializer/documentSerializer.js +44 -6
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +14 -0
- package/dist/docx/serializer/headerFooterSerializer.d.ts +11 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
- package/dist/docx/serializer/markupRangeAttributes.js +3 -1
- package/dist/docx/serializer/noteSerializer.d.ts +21 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +14 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +11 -0
- package/dist/docx/serializer/paragraphSerializer.js +21 -9
- package/dist/docx/serializer/partNamespaces.d.ts +2 -0
- package/dist/docx/serializer/partNamespaces.js +3 -1
- package/dist/docx/serializer/runSerializer.js +12 -3
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +15 -0
- package/dist/docx/serializer/stylesSerializer.d.ts +26 -1
- package/dist/docx/serializer/stylesSerializer.js +111 -23
- package/dist/docx/serializer/tableSerializer.js +9 -7
- package/dist/docx/serializer/themeSerializer.d.ts +2 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.js +1 -1
- package/dist/docx/server/build.d.ts +2 -2
- package/dist/docx/server/changeListFormat.d.ts +20 -0
- package/dist/docx/server/changeListFormat.js +102 -0
- package/dist/docx/server/createBilingualDocument.d.ts +21 -0
- package/dist/docx/server/materializeYjsDocx.js +2 -2
- package/dist/docx/server/migrateYjsAttrSchema.js +5 -5
- package/dist/docx/sessionListPruning.d.ts +11 -0
- package/dist/docx/settingsParser.d.ts +10 -0
- package/dist/docx/shadingParser.d.ts +10 -0
- package/dist/docx/shapeAlternateContent.js +9 -2
- package/dist/docx/shapeParser.d.ts +27 -0
- package/dist/docx/splitRevisionPieces.d.ts +1 -1
- package/dist/docx/storyBlockReplay.d.ts +37 -3
- package/dist/docx/storyBlockReplay.js +277 -68
- package/dist/docx/strictNames.d.ts +12 -1
- package/dist/docx/strictValueEncodings.gen.d.ts +9 -0
- package/dist/docx/structuralXmlPatch.d.ts +19 -3
- package/dist/docx/structuralXmlPatch.js +136 -53
- package/dist/docx/styleParser.d.ts +20 -3
- package/dist/docx/styleParser.js +3 -2
- package/dist/docx/tableLook.d.ts +15 -1
- package/dist/docx/tableParser.d.ts +17 -6
- package/dist/docx/tableParser.js +10 -5
- package/dist/docx/textBoxContentParser.d.ts +3 -2
- package/dist/docx/textBoxParser.d.ts +30 -3
- package/dist/docx/themeColorAttribute.d.ts +11 -0
- package/dist/docx/themeParser.d.ts +17 -5
- package/dist/docx/trackedMoveRangeNormalization.d.ts +9 -0
- package/dist/docx/trackedMoveRangeNormalization.js +40 -16
- package/dist/docx/transitionalSpelling.d.ts +9 -0
- package/dist/docx/unnamedParagraphIds.d.ts +33 -0
- package/dist/docx/unnamedParagraphIds.js +43 -0
- package/dist/docx/unreferencedHeaderFooters.d.ts +27 -0
- package/dist/docx/unreferencedHeaderFooters.js +130 -0
- package/dist/docx/unzip.d.ts +25 -0
- package/dist/docx/verbatimCapture.d.ts +18 -0
- package/dist/docx/verbatimCapture.js +76 -9
- package/dist/docx/vmlImageParser.d.ts +32 -1
- package/dist/docx/watermarkParser.d.ts +21 -0
- package/dist/docx/wrapPolygon.d.ts +11 -0
- package/dist/docx/wrapTypes.d.ts +6 -0
- package/dist/docx/xmlParser.d.ts +22 -18
- package/dist/docx/xmlParser.js +1 -18
- package/dist/docx/xmlRootInsertion.d.ts +8 -0
- package/dist/docx/xmlRootInsertion.js +28 -0
- package/dist/docx/xmlSafety.d.ts +1 -0
- package/dist/docx/xmlSafety.js +7 -11
- package/dist/export-pdf.d.ts +24 -1
- package/dist/fields/resolveFieldValues.js +2 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -2
- package/dist/fonts/headlessMeasure.d.ts +16 -0
- package/dist/generated/text_shaper.js +71 -59
- package/dist/generated/text_shaper_bg.wasm +0 -0
- package/dist/headless-layout.d.ts +36 -5
- package/dist/headless-layout.js +19 -4
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/index.d.ts +33 -31
- package/dist/index.js +3 -4
- package/dist/internal/canonicalOperationStaging.d.ts +2 -0
- package/dist/internal/canonicalOperationStaging.js +4 -0
- package/dist/internal/canonicalTyping.d.ts +9 -0
- package/dist/internal/canonicalTyping.js +7 -0
- package/dist/internal/compare/inline-presentation.d.ts +8 -0
- package/dist/internal/indexedPositionMap.js +2 -1
- package/dist/internal/revisionResolutionInline.js +13 -13
- package/dist/internal/revisionResolutionStep.js +1 -0
- package/dist/internal/revisionResolutionTracking.js +2 -1
- package/dist/internal/wholeStoryRevisionResolution.d.ts +1 -1
- package/dist/internal/wholeStoryRevisionResolution.js +57 -66
- package/dist/layout-bridge/cellSelectionHighlight.d.ts +8 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +7 -0
- package/dist/layout-bridge/convert/editingFont.d.ts +26 -0
- package/dist/layout-bridge/convert/editingFont.js +42 -0
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +19 -1
- package/dist/layout-bridge/convert/flowBlockPostprocessing.d.ts +5 -0
- package/dist/layout-bridge/convert/flowBorders.d.ts +10 -4
- package/dist/layout-bridge/convert/flowBorders.js +13 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +27 -12
- package/dist/layout-bridge/convert/flowConversionShared.js +36 -11
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +12 -4
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +25 -5
- package/dist/layout-bridge/convert/imageConversion.d.ts +5 -1
- package/dist/layout-bridge/convert/listMarkers.d.ts +12 -7
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +21 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +4 -1
- package/dist/layout-bridge/convert/noteReferences.d.ts +4 -0
- package/dist/layout-bridge/convert/pageBreakSplitting.d.ts +4 -0
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +13 -8
- package/dist/layout-bridge/convert/paragraphAttrs.js +1 -1
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +3 -10
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +8 -4
- package/dist/layout-bridge/convert/paragraphFrames.d.ts +2 -4
- package/dist/layout-bridge/convert/paragraphFrames.js +4 -4
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +13 -4
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +5 -0
- package/dist/layout-bridge/convert/paragraphRuns.js +18 -4
- package/dist/layout-bridge/convert/runFormattingMerge.d.ts +10 -4
- package/dist/layout-bridge/convert/runMarkFormatting.d.ts +8 -3
- package/dist/layout-bridge/convert/runMarkFormatting.js +3 -5
- package/dist/layout-bridge/convert/sectionBoundaries.d.ts +4 -0
- package/dist/layout-bridge/convert/tableConversion.d.ts +15 -5
- package/dist/layout-bridge/convert/tableConversion.js +40 -19
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +38 -1
- package/dist/layout-bridge/convert/textBoxFill.d.ts +7 -2
- package/dist/layout-bridge/convert/textFormattingConversion.d.ts +18 -12
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +8 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +67 -14
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +26 -4
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +10 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +4 -4
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +1 -0
- package/dist/layout-bridge/engine/blockIndex.d.ts +3 -0
- package/dist/layout-bridge/engine/clickToPosition.d.ts +9 -0
- package/dist/layout-bridge/engine/hitTest.d.ts +6 -0
- package/dist/layout-bridge/engine/hitTest.js +3 -3
- package/dist/layout-bridge/engine/measuring/index.d.ts +20 -8
- package/dist/layout-bridge/engine/selectionRects.d.ts +9 -0
- package/dist/layout-bridge/headerFooterLayout.d.ts +12 -0
- package/dist/layout-bridge/headerFooterLayout.js +3 -3
- package/dist/layout-bridge/sectionColumns.d.ts +10 -1
- package/dist/layout-engine/footnoteContinuation.d.ts +8 -0
- package/dist/layout-engine/imageLayout.d.ts +4 -1
- package/dist/layout-engine/index.d.ts +10 -5
- package/dist/layout-engine/index.js +9 -3
- package/dist/layout-engine/keep-together.d.ts +6 -0
- package/dist/layout-engine/layoutFlowShared.d.ts +4 -0
- package/dist/layout-engine/layoutInstrumentation.d.ts +40 -1
- package/dist/layout-engine/layoutInstrumentation.js +26 -4
- package/dist/layout-engine/lineFlow.d.ts +1 -0
- package/dist/layout-engine/lineFlow.js +4 -1
- package/dist/layout-engine/measure/advanceComposition.d.ts +14 -1
- package/dist/layout-engine/measure/automaticTextSpacing.d.ts +1 -1
- package/dist/layout-engine/measure/cache.d.ts +6 -0
- package/dist/layout-engine/measure/cache.js +3 -0
- package/dist/layout-engine/measure/crossRunWords.d.ts +1 -1
- package/dist/layout-engine/measure/floatingLineClearance.d.ts +4 -0
- package/dist/layout-engine/measure/floatingTablePosition.d.ts +32 -1
- package/dist/layout-engine/measure/floatingTablePosition.js +49 -1
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +16 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +18 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +4 -0
- package/dist/layout-engine/measure/index.d.ts +18 -8
- package/dist/layout-engine/measure/index.js +2 -1
- package/dist/layout-engine/measure/inlineObjectMetrics.d.ts +4 -0
- package/dist/layout-engine/measure/justification.d.ts +5 -1
- package/dist/layout-engine/measure/lineFitting.d.ts +6 -1
- package/dist/layout-engine/measure/lineTypography.d.ts +6 -1
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +16 -1
- package/dist/layout-engine/measure/measureBlocks.d.ts +4 -1
- package/dist/layout-engine/measure/measureBlocks.js +127 -102
- package/dist/layout-engine/measure/measureContainer.d.ts +17 -0
- package/dist/layout-engine/measure/measureHelpers.d.ts +10 -1
- package/dist/layout-engine/measure/measureParagraph.d.ts +7 -1
- package/dist/layout-engine/measure/measureParagraph.js +51 -21
- package/dist/layout-engine/measure/measureProvider.d.ts +10 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +8 -0
- package/dist/layout-engine/measure/measureWorker.d.ts +30 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +14 -0
- package/dist/layout-engine/measure/measuresHoldNoPositions.d.ts +40 -0
- package/dist/layout-engine/measure/measuresHoldNoPositions.js +14 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +12 -0
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +21 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.js +20 -1
- package/dist/layout-engine/measure/paragraphTabs.d.ts +4 -0
- package/dist/layout-engine/measure/raisedTableWrap.d.ts +16 -0
- package/dist/layout-engine/measure/raisedTableWrap.js +105 -0
- package/dist/layout-engine/measure/tableBorderBands.d.ts +35 -0
- package/dist/layout-engine/measure/tableBorderBands.js +251 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -1
- package/dist/layout-engine/measure/tableCellFlow.d.ts +4 -4
- package/dist/layout-engine/measure/tableCellFlow.js +7 -10
- package/dist/layout-engine/measure/tableCellGrid.d.ts +4 -1
- package/dist/layout-engine/measure/tableCellGrid.js +30 -3
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableMeasureMemo.d.ts +23 -0
- package/dist/layout-engine/measure/tableMeasureMemo.js +40 -0
- package/dist/layout-engine/measure/tableNoWrapWidths.d.ts +12 -0
- package/dist/layout-engine/measure/tableNoWrapWidths.js +73 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +6 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +7 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +10 -1
- package/dist/layout-engine/paginator.d.ts +6 -0
- package/dist/layout-engine/paginator.js +6 -5
- package/dist/layout-engine/paragraphLayout.d.ts +5 -1
- package/dist/layout-engine/paragraphSpacing.d.ts +17 -2
- package/dist/layout-engine/paragraphSpacing.js +103 -15
- package/dist/layout-engine/pmPageIndex.d.ts +14 -1
- package/dist/layout-engine/pmPageIndex.js +10 -1
- package/dist/layout-engine/section-breaks.d.ts +6 -0
- package/dist/layout-engine/sectionLayout.d.ts +6 -1
- package/dist/layout-engine/sectionVerticalAlignment.js +2 -1
- package/dist/layout-engine/tableHeaderCompatibility.d.ts +3 -0
- package/dist/layout-engine/tableHeaderCompatibility.js +5 -0
- package/dist/layout-engine/tableLayout.d.ts +17 -6
- package/dist/layout-engine/tableLayout.js +36 -25
- package/dist/layout-engine/tableRowBreak.d.ts +16 -0
- package/dist/layout-engine/tableRowBreak.js +2 -1
- package/dist/layout-engine/textBoxFlow.d.ts +9 -0
- package/dist/layout-engine/textBoxLayout.d.ts +5 -1
- package/dist/layout-engine/types.d.ts +35 -2
- package/dist/layout-engine/types.js +77 -27
- package/dist/layout-painter/borderStroke.d.ts +1 -1
- package/dist/layout-painter/characterFillBand.d.ts +14 -0
- package/dist/layout-painter/characterFillBand.js +79 -0
- package/dist/layout-painter/imageLayout.d.ts +11 -2
- package/dist/layout-painter/index.d.ts +12 -6
- package/dist/layout-painter/pageShellStyles.d.ts +9 -0
- package/dist/layout-painter/previewSvg.d.ts +7 -0
- package/dist/layout-painter/reconcileRenderedContent.js +3 -1
- package/dist/layout-painter/registry/modules/image.d.ts +7 -0
- package/dist/layout-painter/registry/modules/paragraph.d.ts +8 -0
- package/dist/layout-painter/registry/modules/table.d.ts +6 -0
- package/dist/layout-painter/registry/modules/textBox.d.ts +3 -0
- package/dist/layout-painter/registry/modules.d.ts +10 -0
- package/dist/layout-painter/registry/registry.d.ts +8 -0
- package/dist/layout-painter/registry/types.d.ts +11 -0
- package/dist/layout-painter/renderFragment.d.ts +6 -0
- package/dist/layout-painter/renderImage.d.ts +8 -0
- package/dist/layout-painter/renderPage.d.ts +10 -3
- package/dist/layout-painter/renderPage.js +23 -4
- package/dist/layout-painter/renderParagraph.d.ts +6 -0
- package/dist/layout-painter/renderParagraph.js +33 -16
- package/dist/layout-painter/renderTable.d.ts +10 -1
- package/dist/layout-painter/renderTable.js +112 -24
- package/dist/layout-painter/renderTextBox.d.ts +9 -0
- package/dist/layout-painter/renderUtils.d.ts +5 -1
- package/dist/layout-painter/renderWatermark.d.ts +11 -1
- package/dist/layout-painter/sdtBoundary.d.ts +10 -0
- package/dist/managers/ClipboardManager.d.ts +13 -0
- package/dist/managers/ContextMenuManager.d.ts +16 -4
- package/dist/managers/ContextMenuManager.js +3 -3
- package/dist/managers/DocumentLoaderManager.d.ts +19 -5
- package/dist/managers/DocumentLoaderManager.js +48 -13
- package/dist/managers/EditorModeManager.d.ts +11 -0
- package/dist/managers/ErrorManager.d.ts +11 -0
- package/dist/managers/FindReplaceManager.d.ts +14 -27
- package/dist/managers/FindReplaceManager.js +0 -49
- package/dist/managers/HistoryManager.d.ts +18 -0
- package/dist/managers/TableSelectionManager.d.ts +18 -4
- package/dist/managers/TableSelectionManager.js +22 -5
- package/dist/managers/editorShortcuts.d.ts +14 -2
- package/dist/managers/editorShortcuts.js +5 -3
- package/dist/managers/types.d.ts +15 -1
- package/dist/markdown/annotations.d.ts +9 -0
- package/dist/markdown/countParagraphList.d.ts +8 -0
- package/dist/markdown/escape.d.ts +6 -4
- package/dist/markdown/escape.js +17 -8
- package/dist/markdown/images.d.ts +11 -0
- package/dist/markdown/index.d.ts +24 -1
- package/dist/markdown/index.js +18 -1
- package/dist/markdown/internals.d.ts +7 -0
- package/dist/markdown/renderBlock.d.ts +5 -0
- package/dist/markdown/renderBlock.js +2 -7
- package/dist/markdown/renderParagraph.d.ts +22 -2
- package/dist/markdown/renderParagraph.js +11 -9
- package/dist/markdown/renderRuns.d.ts +10 -0
- package/dist/markdown/renderRuns.js +36 -3
- package/dist/markdown/renderTable.d.ts +7 -0
- package/dist/markdown/renderTable.js +2 -2
- package/dist/markdown/trailers.d.ts +7 -0
- package/dist/markdown/types.d.ts +9 -2
- package/dist/model.d.ts +25 -3
- package/dist/paged-layout/pageText.d.ts +1 -1
- package/dist/paged-layout/paragraphFlash.d.ts +3 -0
- package/dist/paged-layout/rangeProjection.d.ts +20 -1
- package/dist/paged-layout/rangeProjection.js +22 -4
- package/dist/paged-layout/scrollToPmPosition.d.ts +15 -0
- package/dist/paged-layout/sectionBlockWidths.d.ts +2 -2
- package/dist/paged-layout/sectionGeometry.d.ts +4 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +13 -0
- package/dist/panel-layout.d.ts +18 -1
- package/dist/panel-layout.js +36 -2
- package/dist/pdf/contentStream.d.ts +12 -0
- package/dist/pdf/fonts.d.ts +19 -0
- package/dist/pdf/paint.d.ts +9 -1
- package/dist/pdf/paint.js +51 -0
- package/dist/prosemirror/acceptedBlockNeighbours.d.ts +50 -0
- package/dist/prosemirror/acceptedBlockNeighbours.js +63 -0
- package/dist/prosemirror/alternateContentAttrs.d.ts +1 -1
- package/dist/prosemirror/anchoredTextBoxes.d.ts +20 -0
- package/dist/prosemirror/attrs/index.d.ts +2 -2
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/authoredTransformAttrs.d.ts +14 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -2
- package/dist/prosemirror/canonicalCommands.d.ts +26 -1
- package/dist/prosemirror/canonicalCommands.js +12 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +14 -0
- package/dist/prosemirror/canonicalTableCommands.js +18 -6
- package/dist/prosemirror/cellDragSelection.d.ts +9 -0
- package/dist/prosemirror/commands/comments.d.ts +22 -0
- package/dist/prosemirror/commands/comments.js +374 -154
- package/dist/prosemirror/commands/contentControls.d.ts +20 -3
- package/dist/prosemirror/commands/contentControls.js +18 -1
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +11 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +10 -0
- package/dist/prosemirror/commands/formatPainter.js +0 -1
- package/dist/prosemirror/commands/formatting.d.ts +9 -2
- package/dist/prosemirror/commands/hyperlink.d.ts +12 -0
- package/dist/prosemirror/commands/image.d.ts +12 -0
- package/dist/prosemirror/commands/index.d.ts +10 -5
- package/dist/prosemirror/commands/pageBreak.d.ts +3 -0
- package/dist/prosemirror/commands/paragraph.d.ts +8 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +8 -0
- package/dist/prosemirror/commands/pastePlainText.js +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +28 -15
- package/dist/prosemirror/commands/propertyChangeScope.js +5 -12
- package/dist/prosemirror/commands/replaceRangeText.d.ts +22 -0
- package/dist/prosemirror/commands/replaceRangeText.js +44 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +3 -2
- package/dist/prosemirror/commands/resolveParagraphProperties.js +4 -8
- package/dist/prosemirror/commands/rulerParagraph.d.ts +25 -0
- package/dist/prosemirror/commands/rulerParagraph.js +18 -0
- package/dist/prosemirror/commands/sectionBreak.d.ts +5 -0
- package/dist/prosemirror/commands/table.d.ts +7 -0
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.d.ts +12 -6
- package/dist/prosemirror/commentIdAllocator.js +38 -29
- package/dist/prosemirror/commentOps.d.ts +7 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +1 -1
- package/dist/prosemirror/commentRangeInlineAtoms.d.ts +4 -3
- package/dist/prosemirror/commentRangeInlineAtoms.js +1 -1
- package/dist/prosemirror/commentRecords.d.ts +17 -0
- package/dist/prosemirror/commentRecords.js +132 -5
- package/dist/prosemirror/commentReferenceAttrs.d.ts +1 -1
- package/dist/prosemirror/commentReferenceIntegrity.js +93 -14
- package/dist/prosemirror/containerFinalParagraph.d.ts +2 -0
- package/dist/prosemirror/containerFinalParagraph.js +3 -1
- package/dist/prosemirror/contentControlRevisions.d.ts +14 -0
- package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +5 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +72 -58
- package/dist/prosemirror/conversion/index.d.ts +6 -1
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +21 -0
- package/dist/prosemirror/conversion/runShadingMark.d.ts +13 -1
- package/dist/prosemirror/conversion/storyConversionOptions.d.ts +16 -0
- package/dist/prosemirror/conversion/storyConversionOptions.js +13 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +35 -10
- package/dist/prosemirror/conversion/toProseDoc.js +197 -136
- package/dist/prosemirror/copyOriginResolution.js +23 -10
- package/dist/prosemirror/documentSchema.d.ts +12 -0
- package/dist/prosemirror/emptyRangeAnchor.d.ts +39 -8
- package/dist/prosemirror/emptyRangeAnchor.js +63 -10
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +7 -0
- package/dist/prosemirror/extensions/ExtensionManager.js +2 -0
- package/dist/prosemirror/extensions/StarterKit.d.ts +11 -2
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +3 -2
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +13 -4
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +5 -3
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/create.d.ts +6 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +5 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -3
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +20 -23
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +38 -21
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +8 -3
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +5 -14
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +17 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +7 -3
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +32 -3
- package/dist/prosemirror/extensions/features/pasteCleanup.js +23 -3
- package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +22 -0
- package/dist/prosemirror/extensions/features/pastedCellSections.js +78 -0
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +22 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +1 -0
- package/dist/prosemirror/extensions/markRegistry.d.ts +14 -1
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +4 -6
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +5 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +17 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/HyphenElementExtension.d.ts +19 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -2
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +2 -1
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +7 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +10 -3
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/BlockMoveRangeBoundaryExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +17 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.d.ts +1 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +38 -4
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +2 -1
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +1 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/nodes/PageBreakRunExtension.d.ts +1 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +25 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +1 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +7 -19
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +1 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +3 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +8 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +6 -6
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +9 -0
- package/dist/prosemirror/extensions/types.d.ts +10 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +13 -1
- package/dist/prosemirror/imageCommit.d.ts +10 -0
- package/dist/prosemirror/index.d.ts +30 -20
- package/dist/prosemirror/indexedNodeLookup.d.ts +11 -0
- package/dist/prosemirror/inlineWrapperStack.d.ts +12 -0
- package/dist/prosemirror/insertOperations.d.ts +10 -1
- package/dist/prosemirror/insertOperations.js +2 -2
- package/dist/prosemirror/insertionGaps.d.ts +21 -0
- package/dist/prosemirror/insertionGaps.js +86 -0
- package/dist/prosemirror/keptRangeBoundaries.d.ts +16 -12
- package/dist/prosemirror/keptRangeBoundaries.js +28 -34
- package/dist/prosemirror/listAutoformatMarkers.d.ts +11 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +5 -0
- package/dist/prosemirror/listLabels.d.ts +16 -3
- package/dist/prosemirror/listLabels.js +0 -6
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listNumbering.d.ts +1 -1
- package/dist/prosemirror/listRendering.d.ts +2 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +10 -1
- package/dist/prosemirror/lockedControls.d.ts +6 -0
- package/dist/prosemirror/markupViewNotes.d.ts +11 -1
- package/dist/prosemirror/markupViewProjection.d.ts +21 -4
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +21 -3
- package/dist/prosemirror/nativeSelection.js +69 -19
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +17 -3
- package/dist/prosemirror/noteReferenceReview.js +26 -5
- package/dist/prosemirror/pageBreakRunProjection.d.ts +2 -1
- package/dist/prosemirror/paraText.d.ts +14 -0
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +13 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +6 -3
- package/dist/prosemirror/paragraphIndentation.js +2 -3
- package/dist/prosemirror/paragraphList.d.ts +1 -1
- package/dist/prosemirror/paragraphMarkJoin.d.ts +29 -1
- package/dist/prosemirror/paragraphMarkJoin.js +25 -6
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +15 -1
- package/dist/prosemirror/paragraphPropertyCarry.js +5 -3
- package/dist/prosemirror/paragraphSpacing.d.ts +1 -1
- package/dist/prosemirror/pastePlacement.d.ts +17 -0
- package/dist/prosemirror/pastePlacement.js +22 -0
- package/dist/prosemirror/pastedCommentCopies.d.ts +87 -0
- package/dist/prosemirror/pastedCommentCopies.js +379 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +12 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +14 -0
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +15 -9
- package/dist/prosemirror/plugins/contentControlWidgets.js +22 -28
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +17 -0
- package/dist/prosemirror/plugins/documentNumbering.d.ts +2 -1
- package/dist/prosemirror/plugins/documentStyleState.d.ts +3 -4
- package/dist/prosemirror/plugins/documentStyles.d.ts +20 -3
- package/dist/prosemirror/plugins/index.d.ts +7 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +18 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +12 -2
- package/dist/prosemirror/plugins/pmTextScan.d.ts +18 -0
- package/dist/prosemirror/plugins/pmTextScan.js +42 -33
- package/dist/prosemirror/plugins/revisionIds.d.ts +14 -1
- package/dist/prosemirror/plugins/revisionIds.js +5 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +12 -2
- package/dist/prosemirror/plugins/suggestionMode.d.ts +14 -11
- package/dist/prosemirror/plugins/suggestionMode.js +212 -34
- package/dist/prosemirror/plugins/templateDirectives.d.ts +17 -0
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +23 -0
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +19 -0
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +19 -0
- package/dist/prosemirror/positionSweep.d.ts +21 -0
- package/dist/prosemirror/queries.d.ts +9 -0
- package/dist/prosemirror/queries.js +2 -2
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -2
- package/dist/prosemirror/rangeAnchorAttrs.js +55 -33
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +17 -0
- package/dist/prosemirror/replaceFindMatches.d.ts +20 -0
- package/dist/prosemirror/replaceFindMatches.js +33 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +143 -0
- package/dist/prosemirror/replacedAnnotations.js +223 -26
- package/dist/prosemirror/revisionCarriers.js +9 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +3 -3
- package/dist/prosemirror/runFormattingFromMarks.js +10 -51
- package/dist/prosemirror/runFormattingProvenance.d.ts +2 -1
- package/dist/prosemirror/runFormattingProvenance.js +2 -1
- package/dist/prosemirror/runFormattingReconciliation.js +3 -12
- package/dist/prosemirror/runIdentity.d.ts +14 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +7 -0
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +5 -13
- package/dist/prosemirror/runPropertyChangeResolution.js +13 -30
- package/dist/prosemirror/runStyleFormatting.d.ts +42 -113
- package/dist/prosemirror/runStyleFormatting.js +17 -74
- package/dist/prosemirror/schema/index.d.ts +8 -1
- package/dist/prosemirror/schema/marks.d.ts +16 -2
- package/dist/prosemirror/schema/nodes.d.ts +15 -14
- package/dist/prosemirror/sectionCarrier.d.ts +21 -0
- package/dist/prosemirror/sectionMarkEdits.d.ts +18 -0
- package/dist/prosemirror/selectionState.d.ts +10 -4
- package/dist/prosemirror/storyListNumbering.d.ts +10 -0
- package/dist/prosemirror/styles/index.d.ts +3 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +20 -18
- package/dist/prosemirror/styles/paragraphStyleCascade.js +10 -19
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +4 -3
- package/dist/prosemirror/styles/styleResolver.d.ts +40 -15
- package/dist/prosemirror/styles/styleResolver.js +6 -6
- package/dist/prosemirror/styles/styleToggleCascade.d.ts +18 -11
- package/dist/prosemirror/styles/styleToggleCascade.js +2 -11
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +20 -7
- package/dist/prosemirror/styles/tableStyleRegions.js +14 -13
- package/dist/prosemirror/tableCellPaste.d.ts +21 -0
- package/dist/prosemirror/tableCellPaste.js +32 -2
- package/dist/prosemirror/tableGridMutation.d.ts +9 -0
- package/dist/prosemirror/tableGridMutation.js +34 -2
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +6 -0
- package/dist/prosemirror/tableResize.d.ts +10 -0
- package/dist/prosemirror/tableRunIn.d.ts +26 -1
- package/dist/prosemirror/tableRunIn.js +39 -11
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +1 -1
- package/dist/prosemirror/textBoxHostCollapse.d.ts +11 -0
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +5 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +6 -0
- package/dist/prosemirror/utils/visualLineNavigation.js +1 -1
- package/dist/prosemirror/validation.js +6 -11
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +9 -3
- package/dist/prosemirror/yjsDocumentMetadata.js +49 -10
- package/dist/prosemirror/zeroWidthAnchors.d.ts +18 -0
- package/dist/redline.d.ts +4 -1
- package/dist/redline.js +21 -13
- package/dist/render-dom/BodySelectionOverlay.d.ts +5 -0
- package/dist/render-dom/RemoteSelectionOverlay.js +3 -3
- package/dist/server.d.ts +30 -18
- package/dist/server.js +4 -3
- package/dist/shaping/placeRun.d.ts +8 -0
- package/dist/shaping/shaper.d.ts +19 -0
- package/dist/style-engine/index.d.ts +5 -0
- package/dist/style-engine/styleEngine.d.ts +32 -13
- package/dist/style-sets/extract.d.ts +1 -1
- package/dist/style-sets/styleSetNormalization.d.ts +20 -1
- package/dist/text-shaping.d.ts +9 -1
- package/dist/types/anonymization.d.ts +17 -0
- package/dist/types/anonymization.js +0 -0
- package/dist/types/autocomplete.d.ts +46 -0
- package/dist/types/autocomplete.js +0 -0
- package/dist/types/canonicalCapabilities.d.ts +40 -42
- package/dist/types/canonicalCapabilities.js +43 -44
- package/dist/types/canonicalSave.d.ts +36 -0
- package/dist/types/documentModel.d.ts +37 -0
- package/dist/types/documentModel.js +24 -0
- package/dist/types/docxSerialization.d.ts +10 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/remote-selection.d.ts +2 -1
- package/dist/types/selectiveSaveDecline.d.ts +44 -0
- package/dist/types/selectiveSaveDecline.js +0 -0
- package/dist/types/tableWidthKind.d.ts +2 -0
- package/dist/types/tableWidthKind.js +9 -0
- package/dist/utils/base64.d.ts +20 -0
- package/dist/utils/borderCss.d.ts +18 -1
- package/dist/utils/colorResolver.d.ts +12 -11
- package/dist/utils/createDocument.d.ts +8 -1
- package/dist/utils/createDocument.js +20 -2
- package/dist/utils/diagonalHatch.d.ts +2 -0
- package/dist/utils/diagonalHatch.js +16 -0
- package/dist/utils/extremes.d.ts +4 -0
- package/dist/utils/extremes.js +14 -0
- package/dist/utils/findMatchView.d.ts +2 -2
- package/dist/utils/findReplace.d.ts +2 -2
- package/dist/utils/findReplace.js +3 -2
- package/dist/utils/fontFamilyMerge.d.ts +2 -1
- package/dist/utils/fontResolver.d.ts +11 -2
- package/dist/utils/formatToStyle.d.ts +22 -8
- package/dist/utils/headerFooter.d.ts +16 -2
- package/dist/utils/headerFooter.js +2 -6
- package/dist/utils/imageResize.js +1 -1
- package/dist/utils/listItems.d.ts +7 -0
- package/dist/utils/listItems.js +9 -0
- package/dist/utils/mergeDocumentContent.d.ts +7 -0
- package/dist/utils/outlineHeadings.d.ts +1 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +11 -3
- package/dist/utils/paragraphFormattingMerge.js +0 -8
- package/dist/utils/paragraphInlineLayout.js +2 -1
- package/dist/utils/repeatingStrokeGradient.d.ts +8 -0
- package/dist/utils/repeatingStrokeGradient.js +13 -0
- package/dist/utils/rotationBoundingBox.d.ts +8 -0
- package/dist/utils/rulerControl.d.ts +71 -0
- package/dist/utils/rulerControl.js +94 -0
- package/dist/utils/tableOperations.d.ts +20 -4
- package/dist/utils/tableOperations.js +1 -0
- package/dist/utils/textDirectionFlow.d.ts +10 -0
- package/dist/utils/textFormattingMerge.d.ts +18 -2
- package/dist/utils/textFormattingMerge.js +0 -20
- package/dist/utils/units.d.ts +2 -0
- package/dist/utils/units.js +3 -1
- package/dist/version-comparison.d.ts +63 -1
- package/dist/version-comparison.js +2 -1
- package/dist/watermark/index.d.ts +11 -0
- package/dist/watermark/index.js +0 -5
- package/package.json +7 -7
- package/dist/controller/canonicalPublicOperations.js +0 -1276
- package/dist/controller/canonicalSeedContent.d.ts +0 -12
- package/dist/controller/canonicalSourceNormalization.d.ts +0 -21
- package/dist/docx/canonicalResourceSave.d.ts +0 -15
- package/dist/docx/canonicalResourceSave.js +0 -27
- package/dist/internal/acceptedBlockProjection.d.ts +0 -9
- package/dist/internal/acceptedBlockProjection.js +0 -50
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +0 -60
- package/dist/prosemirror/plugins/anonymizationDecorations.js +0 -111
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +0 -127
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +0 -282
- package/dist/utils/replaceText.d.ts +0 -25
- package/dist/utils/replaceText.js +0 -242
- /package/dist/{controller → canonical}/canonicalListRendering.d.ts +0 -0
- /package/dist/{controller → canonical}/canonicalOperations.d.ts +0 -0
- /package/dist/{controller → canonical}/canonicalSelection.d.ts +0 -0
- /package/dist/{controller → canonical}/canonicalTocSelection.d.ts +0 -0
|
@@ -0,0 +1,1131 @@
|
|
|
1
|
+
import { drawingXmlWithoutIdentity, takeDrawingId, usedDrawingIds, withDrawingId } from "../docx/drawingIdNormalization.js";
|
|
2
|
+
import { rebindDrawingImageRelationship } from "../docx/drawingRelationships.js";
|
|
3
|
+
import { RELATIONSHIP_TYPES } from "../docx/relsParser.js";
|
|
4
|
+
import { readModel, writableCopy } from "../types/documentModel.js";
|
|
5
|
+
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
6
|
+
import { createNoteReferenceNumbering, noteReferenceMarker } from "../utils/noteReferenceLabels.js";
|
|
7
|
+
import { base64ToBytes } from "../utils/textEncoding.js";
|
|
8
|
+
import { MISSING_NOTE_DETAIL, atomActionRangeCount, atomActionTieRank, fieldResultOwnershipOf, insertionAnchors, matchingAtoms, ownsFieldResult, sameBlockTopology, sameSupportedAtoms } from "./inline-atom-alignment.js";
|
|
9
|
+
import { panic } from "better-result";
|
|
10
|
+
import { DRAWING_RAW_XML_MODES, relationshipIdOf } from "@stll/docx-core/model";
|
|
11
|
+
import { DOCUMENT_OP_TYPES, applyDocumentOp, findStoryBody, packageResourcesOpOf, revisionIdDemand } from "@stll/docx-core/ops";
|
|
12
|
+
// src/compare/inline-atoms-model.ts
|
|
13
|
+
/**
|
|
14
|
+
* Restore the inline atoms a comparison's text operations leave out, on the
|
|
15
|
+
* document model: fields, embedded pictures and page breaks the revised story
|
|
16
|
+
* has where the reviewed story has none (or the other way round), and the note
|
|
17
|
+
* references whose markers those operations wrote as text.
|
|
18
|
+
*
|
|
19
|
+
* The reviewed story is read as accepting every change would leave it, so it
|
|
20
|
+
* lines up block for block with the revised story; each character of that view
|
|
21
|
+
* keeps the paragraph and offset it occupies in the story as it stands, and
|
|
22
|
+
* the result is a batch of document operations addressed there. Nothing here
|
|
23
|
+
* edits a document: the batch applies as one commit, in order.
|
|
24
|
+
*/
|
|
25
|
+
const comparePoints = (left, right) => left.order - right.order || left.offset - right.offset || left.zeroWidthBefore - right.zeroWidthBefore;
|
|
26
|
+
const childNodesOf = (node) => {
|
|
27
|
+
switch (node.type) {
|
|
28
|
+
case "run": return node.content;
|
|
29
|
+
case "hyperlink": return node.children;
|
|
30
|
+
case "insertion":
|
|
31
|
+
case "deletion":
|
|
32
|
+
case "moveFrom":
|
|
33
|
+
case "moveTo":
|
|
34
|
+
case "inlineSdt":
|
|
35
|
+
case "inlineWrapper": return node.content;
|
|
36
|
+
default: return;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** Units of `offsets.ts`: what a leaf adds to its paragraph's offset space. */
|
|
40
|
+
const leafWidthOf = (node) => {
|
|
41
|
+
switch (node.type) {
|
|
42
|
+
case "text": return node.text === "" ? "zeroWidth" : "characters";
|
|
43
|
+
case "noteMarker":
|
|
44
|
+
case "renderedPageBreak":
|
|
45
|
+
case "bookmarkStart":
|
|
46
|
+
case "bookmarkEnd":
|
|
47
|
+
case "commentRangeStart":
|
|
48
|
+
case "commentRangeEnd":
|
|
49
|
+
case "moveFromRangeStart":
|
|
50
|
+
case "moveFromRangeEnd":
|
|
51
|
+
case "moveToRangeStart":
|
|
52
|
+
case "moveToRangeEnd": return "zeroWidth";
|
|
53
|
+
case "preservedInline": return node.text === "" ? "zeroWidth" : "unit";
|
|
54
|
+
default: return childNodesOf(node) === void 0 ? "unit" : "zeroWidth";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/** What content adds to its paragraph's offset space once it is inserted. */
|
|
58
|
+
const offsetWidthOf = (node) => {
|
|
59
|
+
const children = childNodesOf(node);
|
|
60
|
+
if (children !== void 0 && children.length > 0) return children.reduce((width, child) => width + offsetWidthOf(child), 0);
|
|
61
|
+
if (leafWidthOf(node) === "zeroWidth") return 0;
|
|
62
|
+
return node.type === "text" ? node.text.length : 1;
|
|
63
|
+
};
|
|
64
|
+
/** Every leaf of a paragraph in document order, as `leafSpans` counts them. */
|
|
65
|
+
const paragraphLeaves = (paragraph) => {
|
|
66
|
+
const leaves = [];
|
|
67
|
+
let position = 0;
|
|
68
|
+
let zeroWidthSeen = 0;
|
|
69
|
+
const walk = (items, { run, removed, insertion }) => {
|
|
70
|
+
for (const node of items) {
|
|
71
|
+
const children = childNodesOf(node);
|
|
72
|
+
if (children !== void 0 && children.length > 0) {
|
|
73
|
+
walk(children, {
|
|
74
|
+
run: node.type === "run" ? node : run,
|
|
75
|
+
removed: removed || node.type === "deletion" || node.type === "moveFrom",
|
|
76
|
+
insertion: node.type === "insertion" || node.type === "moveTo" ? node.info : insertion
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const width = leafWidthOf(node);
|
|
81
|
+
const before = {
|
|
82
|
+
offset: position,
|
|
83
|
+
zeroWidthBefore: zeroWidthSeen
|
|
84
|
+
};
|
|
85
|
+
if (width === "zeroWidth") zeroWidthSeen += 1;
|
|
86
|
+
else {
|
|
87
|
+
position += node.type === "text" ? node.text.length : 1;
|
|
88
|
+
zeroWidthSeen = 0;
|
|
89
|
+
}
|
|
90
|
+
leaves.push({
|
|
91
|
+
node,
|
|
92
|
+
width,
|
|
93
|
+
run,
|
|
94
|
+
removed,
|
|
95
|
+
insertion,
|
|
96
|
+
before,
|
|
97
|
+
after: {
|
|
98
|
+
offset: position,
|
|
99
|
+
zeroWidthBefore: zeroWidthSeen
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
walk(paragraph.content, {
|
|
105
|
+
run: void 0,
|
|
106
|
+
removed: false,
|
|
107
|
+
insertion: void 0
|
|
108
|
+
});
|
|
109
|
+
return leaves;
|
|
110
|
+
};
|
|
111
|
+
const isShapeWithText = (node) => node.type === "shape" && node.shape.textBody !== void 0;
|
|
112
|
+
const textBoxBlocksOf = (leaves) => leaves.flatMap(({ node }) => node.type === "shape" && node.shape.textBody !== void 0 ? node.shape.textBody.content : []);
|
|
113
|
+
/**
|
|
114
|
+
* A paragraph holding only text-box anchors stands as its text boxes alone,
|
|
115
|
+
* unless something else of it has to stay: its section or a zero-width marker.
|
|
116
|
+
*/
|
|
117
|
+
const standsAsItsTextBoxes = (paragraph, leaves) => paragraph.sectionProperties === void 0 && leaves.some(({ node }) => isShapeWithText(node)) && leaves.every(({ node }) => isShapeWithText(node));
|
|
118
|
+
const removesMark = (paragraph) => paragraph.pPrMark?.kind === "del" || paragraph.pPrMark?.kind === "moveFrom";
|
|
119
|
+
/** Whether a block-list entry is content or a range boundary between blocks. */
|
|
120
|
+
const BLOCK_ROLES = {
|
|
121
|
+
paragraph: "content",
|
|
122
|
+
table: "content",
|
|
123
|
+
blockSdt: "content",
|
|
124
|
+
blockCustomXml: "content",
|
|
125
|
+
preservedBlock: "content",
|
|
126
|
+
bookmarkStart: "boundary",
|
|
127
|
+
bookmarkEnd: "boundary",
|
|
128
|
+
commentRangeStart: "boundary",
|
|
129
|
+
commentRangeEnd: "boundary",
|
|
130
|
+
moveFromRangeStart: "boundary",
|
|
131
|
+
moveFromRangeEnd: "boundary",
|
|
132
|
+
moveToRangeStart: "boundary",
|
|
133
|
+
moveToRangeEnd: "boundary"
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The block after `index` that accepting a removed mark joins: range
|
|
137
|
+
* boundaries standing between the two paragraphs go into the joined one, as
|
|
138
|
+
* the resolution moves them there.
|
|
139
|
+
*/
|
|
140
|
+
const blockJoinedAfter = (list, index) => {
|
|
141
|
+
for (let at = index + 1; at < list.length; at += 1) {
|
|
142
|
+
const block = list[at];
|
|
143
|
+
if (block && BLOCK_ROLES[block.type] === "content") return block;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const readStory = (blocks) => {
|
|
147
|
+
const chains = [];
|
|
148
|
+
const paragraphs = [];
|
|
149
|
+
let pending = [];
|
|
150
|
+
const visit = (list, removed) => {
|
|
151
|
+
for (const [index, block] of list.entries()) switch (block.type) {
|
|
152
|
+
case "paragraph": {
|
|
153
|
+
const paraId = block.paraId ?? panic("A canonical paragraph has no paragraph id", { index });
|
|
154
|
+
const leaves = paragraphLeaves(block);
|
|
155
|
+
const read = {
|
|
156
|
+
paragraph: block,
|
|
157
|
+
paraId,
|
|
158
|
+
order: paragraphs.length,
|
|
159
|
+
leaves
|
|
160
|
+
};
|
|
161
|
+
paragraphs.push(read);
|
|
162
|
+
if (removed) break;
|
|
163
|
+
const textBoxes = textBoxBlocksOf(leaves);
|
|
164
|
+
if (!standsAsItsTextBoxes(block, leaves)) {
|
|
165
|
+
pending.push(read);
|
|
166
|
+
if (!(removesMark(block) && block.sectionProperties === void 0 && blockJoinedAfter(list, index)?.type === "paragraph")) {
|
|
167
|
+
chains.push(pending);
|
|
168
|
+
pending = [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (textBoxes.length > 0) visit(textBoxes, false);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
case "table":
|
|
175
|
+
for (const row of block.rows) {
|
|
176
|
+
const rowRemoved = removed || row.structuralChange?.type === "tableRowDeletion";
|
|
177
|
+
for (const cell of row.cells) visit(cell.content, rowRemoved || cell.structuralChange?.type === "tableCellDeletion");
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
case "blockSdt":
|
|
181
|
+
case "blockCustomXml":
|
|
182
|
+
visit(block.content, removed);
|
|
183
|
+
break;
|
|
184
|
+
case "preservedBlock":
|
|
185
|
+
case "bookmarkStart":
|
|
186
|
+
case "bookmarkEnd":
|
|
187
|
+
case "commentRangeStart":
|
|
188
|
+
case "commentRangeEnd":
|
|
189
|
+
case "moveFromRangeStart":
|
|
190
|
+
case "moveFromRangeEnd":
|
|
191
|
+
case "moveToRangeStart":
|
|
192
|
+
case "moveToRangeEnd": break;
|
|
193
|
+
default: return block;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
visit(blocks, false);
|
|
197
|
+
if (pending.length > 0) chains.push(pending);
|
|
198
|
+
return {
|
|
199
|
+
chains,
|
|
200
|
+
paragraphs
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
const readStoryOf = ({ document, story }) => {
|
|
204
|
+
const body = findStoryBody(readModel(document), story);
|
|
205
|
+
return readStory(body?.content ?? []);
|
|
206
|
+
};
|
|
207
|
+
const fieldResultRuns = (field) => field.type === "simpleField" ? field.content.filter((item) => item.type === "run") : field.fieldResult;
|
|
208
|
+
/**
|
|
209
|
+
* The run formatting a field's result shows: its first formatted result run,
|
|
210
|
+
* or the field's own when it has no result at all.
|
|
211
|
+
*/
|
|
212
|
+
const fieldFormattingOf = (field) => {
|
|
213
|
+
const results = fieldResultRuns(field);
|
|
214
|
+
const first = results.find((run) => run.formatting !== void 0);
|
|
215
|
+
if (first?.formatting !== void 0) return first.formatting;
|
|
216
|
+
return field.type === "complexField" && results.length === 0 ? field.formatting : void 0;
|
|
217
|
+
};
|
|
218
|
+
const CONTROL_TEXT_BY_RUN_CONTENT = {
|
|
219
|
+
tab: " ",
|
|
220
|
+
softHyphen: "",
|
|
221
|
+
noBreakHyphen: "‑"
|
|
222
|
+
};
|
|
223
|
+
/** What a field's result reads as: its text, tabs and line breaks. */
|
|
224
|
+
const fieldResultText = (field) => {
|
|
225
|
+
let text = "";
|
|
226
|
+
for (const run of fieldResultRuns(field)) for (const content of run.content) if (content.type === "text") text += content.text;
|
|
227
|
+
else if (content.type === "break" && content.breakType !== "page") text += "\n";
|
|
228
|
+
else if (content.type === "tab" || content.type === "softHyphen" || content.type === "noBreakHyphen") text += CONTROL_TEXT_BY_RUN_CONTENT[content.type];
|
|
229
|
+
return text;
|
|
230
|
+
};
|
|
231
|
+
/** A run whose leaves the editor rejoins into one `w:r`, which marks it. */
|
|
232
|
+
const runCarriesIdentity = (run) => run.preservedAttributes !== void 0 || run.formatting?.preserved !== void 0 || run.formatting !== void 0 && Object.keys(run.formatting).length === 0 || run.content.some((content) => content.type === "break" && content.breakType === "page") || run.content.length > 1 && run.content.some((content) => content.type !== "text");
|
|
233
|
+
/**
|
|
234
|
+
* Whether a field's result is plain text in one formatting, which the editor
|
|
235
|
+
* holds as one field atom. Any other result is structured content around which
|
|
236
|
+
* a comparison edits as it edits text.
|
|
237
|
+
*/
|
|
238
|
+
const isPlainField = (field) => {
|
|
239
|
+
if (field.type === "simpleField" && field.content.some((item) => item.type !== "run")) return false;
|
|
240
|
+
let formatting;
|
|
241
|
+
for (const run of fieldResultRuns(field)) {
|
|
242
|
+
if (runCarriesIdentity(run)) return false;
|
|
243
|
+
for (const content of run.content) {
|
|
244
|
+
if (content.type !== "text") return false;
|
|
245
|
+
if (content.text === "") continue;
|
|
246
|
+
const own = canonicalJson(run.formatting);
|
|
247
|
+
formatting ??= own;
|
|
248
|
+
if (formatting !== own) return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
};
|
|
253
|
+
/** A field's document facts, as the editor's field atom holds them. */
|
|
254
|
+
const fieldFacts = (field) => {
|
|
255
|
+
const displayText = fieldResultText(field);
|
|
256
|
+
const results = fieldResultRuns(field);
|
|
257
|
+
const emptyResultRuns = displayText === "" && results.length > 0 && (field.type === "complexField" || field.content.length === results.length) && results.every((run) => run.content.every((item) => item.type === "text" && item.text === "")) ? results : void 0;
|
|
258
|
+
const fieldResultIsFallback = field.type === "complexField" ? field.fieldResultIsFallback : void 0;
|
|
259
|
+
return {
|
|
260
|
+
fieldType: field.fieldType,
|
|
261
|
+
instruction: field.instruction,
|
|
262
|
+
displayText,
|
|
263
|
+
fldLock: field.fldLock,
|
|
264
|
+
dirty: field.dirty,
|
|
265
|
+
fieldResultIsFallback,
|
|
266
|
+
formFieldDataXml: field.type === "complexField" ? field.formFieldDataXml : void 0,
|
|
267
|
+
emptyResultRuns,
|
|
268
|
+
...fieldResultIsFallback === void 0 ? {} : { fieldKind: field.type === "simpleField" ? "simple" : "complex" }
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
/** The relationship a comparison's picture takes until save gives it its own. */
|
|
272
|
+
const COMPARISON_IMAGE_RELATIONSHIP = relationshipIdOf("rId_img_compare") ?? panic("The comparison's picture relationship names nothing.");
|
|
273
|
+
/**
|
|
274
|
+
* A picture detached from its package, or `null` when the comparison cannot
|
|
275
|
+
* carry it: no embedded media, a linked picture, or markup it cannot rebind.
|
|
276
|
+
*/
|
|
277
|
+
const detachedDrawing = (drawing) => {
|
|
278
|
+
const { image } = drawing;
|
|
279
|
+
if (image.src?.startsWith("data:") !== true || image.hlinkRId !== void 0 || image.hlinkHref !== void 0) return null;
|
|
280
|
+
const rawXml = drawing.rawXml === void 0 ? void 0 : rebindDrawingImageRelationship({
|
|
281
|
+
xml: drawing.rawXml,
|
|
282
|
+
previousId: image.rId === void 0 ? "" : String(image.rId),
|
|
283
|
+
nextId: COMPARISON_IMAGE_RELATIONSHIP
|
|
284
|
+
});
|
|
285
|
+
if (rawXml === null) return null;
|
|
286
|
+
return {
|
|
287
|
+
...drawing,
|
|
288
|
+
image: {
|
|
289
|
+
...image,
|
|
290
|
+
rId: COMPARISON_IMAGE_RELATIONSHIP
|
|
291
|
+
},
|
|
292
|
+
...rawXml === void 0 ? {} : { rawXml }
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
const ownFormatting = (run) => run?.formatting !== void 0 && Object.keys(run.formatting).length > 0 ? run.formatting : void 0;
|
|
296
|
+
/**
|
|
297
|
+
* A picture's document facts: not the drawing id, which only numbers it, nor
|
|
298
|
+
* the name of the media part holding its bytes, which a package chooses (a
|
|
299
|
+
* comparison copying a picture in names its own part).
|
|
300
|
+
*/
|
|
301
|
+
const drawingKey = (drawing, run) => canonicalJson({
|
|
302
|
+
type: "image",
|
|
303
|
+
image: {
|
|
304
|
+
...drawing.image,
|
|
305
|
+
id: void 0,
|
|
306
|
+
filename: void 0
|
|
307
|
+
},
|
|
308
|
+
rawXml: drawing.rawXml === void 0 ? void 0 : drawingXmlWithoutIdentity(drawing.rawXml),
|
|
309
|
+
rawXmlMode: drawing.rawXmlMode,
|
|
310
|
+
rawImageFingerprint: drawing.rawXmlMode === DRAWING_RAW_XML_MODES.PRESERVE_ONLY ? void 0 : drawing.rawImageFingerprint,
|
|
311
|
+
runFormatting: ownFormatting(run)
|
|
312
|
+
});
|
|
313
|
+
/** A run holding one atom of another run, with that run's formatting. */
|
|
314
|
+
const runWith = (run, content) => ({
|
|
315
|
+
type: "run",
|
|
316
|
+
...run?.formatting === void 0 ? {} : { formatting: run.formatting },
|
|
317
|
+
content: [content]
|
|
318
|
+
});
|
|
319
|
+
const supportedAtomOf = (leaf) => {
|
|
320
|
+
const { node, run } = leaf;
|
|
321
|
+
switch (node.type) {
|
|
322
|
+
case "simpleField":
|
|
323
|
+
case "complexField":
|
|
324
|
+
if (!isPlainField(node)) return null;
|
|
325
|
+
return {
|
|
326
|
+
key: canonicalJson({
|
|
327
|
+
type: "field",
|
|
328
|
+
...fieldFacts(node)
|
|
329
|
+
}),
|
|
330
|
+
resultText: fieldResultText(node),
|
|
331
|
+
content: node
|
|
332
|
+
};
|
|
333
|
+
case "break":
|
|
334
|
+
if (node.breakType !== "page") return null;
|
|
335
|
+
return {
|
|
336
|
+
key: canonicalJson({
|
|
337
|
+
type: "pageBreakRun",
|
|
338
|
+
clear: node.clear
|
|
339
|
+
}),
|
|
340
|
+
resultText: null,
|
|
341
|
+
content: runWith(run, node)
|
|
342
|
+
};
|
|
343
|
+
case "drawing": {
|
|
344
|
+
const detached = detachedDrawing(node);
|
|
345
|
+
if (detached === null) return null;
|
|
346
|
+
return {
|
|
347
|
+
key: drawingKey(detached, run),
|
|
348
|
+
resultText: null,
|
|
349
|
+
content: runWith(run, detached)
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
default: return null;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* The topology key of an inline atom the comparison does not restore, or
|
|
357
|
+
* `null` for text and for what the editor holds as no atom at all.
|
|
358
|
+
*/
|
|
359
|
+
const unsupportedTopologyKeyOf = (leaf) => {
|
|
360
|
+
const { node, run } = leaf;
|
|
361
|
+
switch (node.type) {
|
|
362
|
+
case "text":
|
|
363
|
+
case "renderedPageBreak":
|
|
364
|
+
case "footnoteRef":
|
|
365
|
+
case "endnoteRef":
|
|
366
|
+
case "softHyphen":
|
|
367
|
+
case "noBreakHyphen": return null;
|
|
368
|
+
case "simpleField":
|
|
369
|
+
case "complexField": return `structuredField:${canonicalJson(fieldFacts(node))}`;
|
|
370
|
+
case "drawing": return `image:${drawingKey(node, run)}`;
|
|
371
|
+
case "shape": return node.shape.textBody === void 0 ? `shape:${canonicalJson({
|
|
372
|
+
shape: node,
|
|
373
|
+
runFormatting: ownFormatting(run)
|
|
374
|
+
})}` : `textBoxAnchor:${canonicalJson(ownFormatting(run))}`;
|
|
375
|
+
case "break": return `hardBreak:${canonicalJson(node)}`;
|
|
376
|
+
default: return childNodesOf(node) === void 0 ? `${node.type}:${canonicalJson(node)}` : null;
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
const isHidden = (leaf) => {
|
|
380
|
+
switch (leaf.node.type) {
|
|
381
|
+
case "simpleField":
|
|
382
|
+
case "complexField": return fieldFormattingOf(leaf.node)?.hidden === true;
|
|
383
|
+
default: return leaf.run?.formatting?.hidden === true;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const pointBefore = ({ leaf, paragraph }) => ({
|
|
387
|
+
paraId: paragraph.paraId,
|
|
388
|
+
order: paragraph.order,
|
|
389
|
+
...leaf.before
|
|
390
|
+
});
|
|
391
|
+
const pointAfter = ({ leaf, paragraph }) => ({
|
|
392
|
+
paraId: paragraph.paraId,
|
|
393
|
+
order: paragraph.order,
|
|
394
|
+
...leaf.after
|
|
395
|
+
});
|
|
396
|
+
const paragraphStart = (paragraph) => ({
|
|
397
|
+
paraId: paragraph.paraId,
|
|
398
|
+
order: paragraph.order,
|
|
399
|
+
offset: 0,
|
|
400
|
+
zeroWidthBefore: 0
|
|
401
|
+
});
|
|
402
|
+
/**
|
|
403
|
+
* A point of the accepted block in the story as it stands, placed as the
|
|
404
|
+
* review's own position mapping places it: past what accepting removes right
|
|
405
|
+
* there, and past the paragraph end accepting joins away.
|
|
406
|
+
*/
|
|
407
|
+
const pastRemoved = ({ chain, paragraphIndex, leafIndex, point }) => {
|
|
408
|
+
let current = point;
|
|
409
|
+
let paragraphAt = paragraphIndex;
|
|
410
|
+
let leafAt = leafIndex;
|
|
411
|
+
for (;;) {
|
|
412
|
+
const paragraph = chain[paragraphAt];
|
|
413
|
+
if (paragraph === void 0) return current;
|
|
414
|
+
const leaf = paragraph.leaves[leafAt];
|
|
415
|
+
if (leaf === void 0) {
|
|
416
|
+
const next = chain[paragraphAt + 1];
|
|
417
|
+
if (next === void 0) return current;
|
|
418
|
+
paragraphAt += 1;
|
|
419
|
+
leafAt = 0;
|
|
420
|
+
current = paragraphStart(next);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (!leaf.removed) return current;
|
|
424
|
+
current = pointAfter({
|
|
425
|
+
leaf,
|
|
426
|
+
paragraph,
|
|
427
|
+
paragraphIndex: paragraphAt,
|
|
428
|
+
leafIndex: leafAt
|
|
429
|
+
});
|
|
430
|
+
leafAt += 1;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
/** The point just past a leaf of an accepted block. */
|
|
434
|
+
const pastLeaf = (chain, at) => pastRemoved({
|
|
435
|
+
chain,
|
|
436
|
+
paragraphIndex: at.paragraphIndex,
|
|
437
|
+
leafIndex: at.leafIndex + 1,
|
|
438
|
+
point: pointAfter(at)
|
|
439
|
+
});
|
|
440
|
+
/** The point just past clean-text character `index` of a block. */
|
|
441
|
+
const pastCharacter = (block, index) => {
|
|
442
|
+
const character = block.characters[index];
|
|
443
|
+
const before = block.offsets[index];
|
|
444
|
+
if (character === void 0 || before === void 0) return void 0;
|
|
445
|
+
return character.last ? pastLeaf(block.chain, character.at) : {
|
|
446
|
+
...before,
|
|
447
|
+
offset: before.offset + 1,
|
|
448
|
+
zeroWidthBefore: 0
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
/** The editor's clean text of an accepted block, and its atoms, on the model. */
|
|
452
|
+
const readBlock = ({ chain, fieldResults, noteReferences }) => {
|
|
453
|
+
const survivor = chain.at(-1) ?? panic("An accepted block has a paragraph");
|
|
454
|
+
let text = "";
|
|
455
|
+
const offsets = [];
|
|
456
|
+
const characters = [];
|
|
457
|
+
const supported = [];
|
|
458
|
+
const unsupportedTopology = [];
|
|
459
|
+
const references = [];
|
|
460
|
+
const labels = noteReferences === "sourceText" ? void 0 : noteReferences;
|
|
461
|
+
let localNumbering;
|
|
462
|
+
let lastContributing;
|
|
463
|
+
/** Characters a unit shows: each anchors at the unit, which has no inside. */
|
|
464
|
+
const append = (shown, at) => {
|
|
465
|
+
if (shown === "") return;
|
|
466
|
+
const before = pointBefore(at);
|
|
467
|
+
for (let index = 0; index < shown.length; index++) {
|
|
468
|
+
offsets.push(before);
|
|
469
|
+
characters.push({
|
|
470
|
+
at,
|
|
471
|
+
last: index === shown.length - 1
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
text += shown;
|
|
475
|
+
lastContributing = at;
|
|
476
|
+
};
|
|
477
|
+
for (const [paragraphIndex, paragraph] of chain.entries()) for (const [leafIndex, leaf] of paragraph.leaves.entries()) {
|
|
478
|
+
if (leaf.removed) continue;
|
|
479
|
+
const at = {
|
|
480
|
+
leaf,
|
|
481
|
+
paragraph,
|
|
482
|
+
paragraphIndex,
|
|
483
|
+
leafIndex
|
|
484
|
+
};
|
|
485
|
+
const { node } = leaf;
|
|
486
|
+
const atom = supportedAtomOf(leaf);
|
|
487
|
+
if (atom !== null) supported.push({
|
|
488
|
+
...atom,
|
|
489
|
+
offset: text.length,
|
|
490
|
+
at
|
|
491
|
+
});
|
|
492
|
+
else {
|
|
493
|
+
const key = unsupportedTopologyKeyOf(leaf);
|
|
494
|
+
if (key !== null) unsupportedTopology.push({
|
|
495
|
+
offset: text.length,
|
|
496
|
+
key
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
if (isHidden(leaf)) continue;
|
|
500
|
+
switch (node.type) {
|
|
501
|
+
case "text": {
|
|
502
|
+
const before = pointBefore(at);
|
|
503
|
+
for (let index = 0; index < node.text.length; index++) {
|
|
504
|
+
offsets.push(index === 0 ? before : {
|
|
505
|
+
...before,
|
|
506
|
+
offset: before.offset + index,
|
|
507
|
+
zeroWidthBefore: 0
|
|
508
|
+
});
|
|
509
|
+
characters.push({
|
|
510
|
+
at,
|
|
511
|
+
last: index === node.text.length - 1
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
text += node.text;
|
|
515
|
+
lastContributing = at;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
case "footnoteRef":
|
|
519
|
+
case "endnoteRef": {
|
|
520
|
+
const reference = {
|
|
521
|
+
noteType: node.type === "endnoteRef" ? "endnote" : "footnote",
|
|
522
|
+
noteId: String(node.id)
|
|
523
|
+
};
|
|
524
|
+
if (labels === void 0) {
|
|
525
|
+
append(reference.noteId, at);
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
const label = labels.labelOf(reference) ?? noteReferenceMarker(reference.noteType, (localNumbering ??= createNoteReferenceNumbering()).next(reference.noteType, reference.noteId).displayNumber);
|
|
529
|
+
references.push({
|
|
530
|
+
...reference,
|
|
531
|
+
offset: text.length,
|
|
532
|
+
length: label.length,
|
|
533
|
+
reference: node
|
|
534
|
+
});
|
|
535
|
+
append(label, at);
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
case "tab":
|
|
539
|
+
case "softHyphen":
|
|
540
|
+
case "noBreakHyphen":
|
|
541
|
+
append(CONTROL_TEXT_BY_RUN_CONTENT[node.type], at);
|
|
542
|
+
break;
|
|
543
|
+
case "break":
|
|
544
|
+
if (node.breakType !== "page") append("\n", at);
|
|
545
|
+
break;
|
|
546
|
+
case "simpleField":
|
|
547
|
+
case "complexField": if (atom === null || fieldResults === "text") append(fieldResultText(node), at);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const first = chain.at(0) ?? survivor;
|
|
551
|
+
offsets.push(lastContributing === void 0 ? pastRemoved({
|
|
552
|
+
chain,
|
|
553
|
+
paragraphIndex: 0,
|
|
554
|
+
leafIndex: 0,
|
|
555
|
+
point: paragraphStart(first)
|
|
556
|
+
}) : pastLeaf(chain, lastContributing));
|
|
557
|
+
return {
|
|
558
|
+
blockType: "paragraph",
|
|
559
|
+
chain,
|
|
560
|
+
cleanText: text,
|
|
561
|
+
offsets,
|
|
562
|
+
characters,
|
|
563
|
+
supported,
|
|
564
|
+
unsupportedTopology,
|
|
565
|
+
noteReferences: references,
|
|
566
|
+
survivor
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
const readBlocks = (reading, fieldResults, noteReferences) => reading.chains.map((chain) => readBlock({
|
|
570
|
+
chain,
|
|
571
|
+
fieldResults,
|
|
572
|
+
noteReferences
|
|
573
|
+
}));
|
|
574
|
+
const noteReferenceKey = ({ noteType, noteId }) => `${noteType}:${noteId}`;
|
|
575
|
+
const allLeaves = (reading) => reading.paragraphs.flatMap(({ leaves }) => leaves);
|
|
576
|
+
/** Every note a story references, tracked-deleted references included. */
|
|
577
|
+
const referencedNotesOf = (reading) => {
|
|
578
|
+
const notes = /* @__PURE__ */ new Set();
|
|
579
|
+
for (const { node } of allLeaves(reading)) if (node.type === "footnoteRef" || node.type === "endnoteRef") notes.add(noteReferenceKey({
|
|
580
|
+
noteType: node.type === "endnoteRef" ? "endnote" : "footnote",
|
|
581
|
+
noteId: String(node.id)
|
|
582
|
+
}));
|
|
583
|
+
return notes;
|
|
584
|
+
};
|
|
585
|
+
const hasNoteReference = (reading) => allLeaves(reading).some(({ node }) => node.type === "footnoteRef" || node.type === "endnoteRef");
|
|
586
|
+
/** Whether a story holds an atom of a kind the comparison restores. */
|
|
587
|
+
const hasSupportedAtom = (reading) => allLeaves(reading).some(({ node }) => {
|
|
588
|
+
switch (node.type) {
|
|
589
|
+
case "simpleField":
|
|
590
|
+
case "complexField": return isPlainField(node);
|
|
591
|
+
case "break": return node.breakType === "page";
|
|
592
|
+
case "drawing": return true;
|
|
593
|
+
default: return false;
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
/**
|
|
597
|
+
* Whether this comparison inserted text that may stand for a note reference.
|
|
598
|
+
* Operations carry clean text, where a reference reads as its marker, so an
|
|
599
|
+
* operation that brings a reference writes the marker as text.
|
|
600
|
+
*/
|
|
601
|
+
const wroteNoteReferenceMarker = (reading, originalRevisionIdSeed) => allLeaves(reading).some(({ node, insertion }) => node.type === "text" && node.text.includes("[^") && insertion !== void 0 && insertion.id >= originalRevisionIdSeed);
|
|
602
|
+
/** Leaves of one paragraph that overlap `[from, to)`. */
|
|
603
|
+
const leavesBetween = (paragraph, from, to) => paragraph.leaves.filter(({ before, after, width }) => width === "zeroWidth" && before.offset > from && before.offset < to || width !== "zeroWidth" && before.offset < to && after.offset > from);
|
|
604
|
+
/**
|
|
605
|
+
* Whether `[from, to)` is exactly `expectedText`, all of it this comparison's
|
|
606
|
+
* own insertion or all of it retained content, and nothing but text.
|
|
607
|
+
*/
|
|
608
|
+
const textRangeDisposition = ({ paragraphs, from, to, expectedText, originalRevisionIdSeed }) => {
|
|
609
|
+
if (from.paraId !== to.paraId || from.offset >= to.offset) return null;
|
|
610
|
+
const paragraph = paragraphs.get(from.paraId);
|
|
611
|
+
if (paragraph === void 0) return null;
|
|
612
|
+
let text = "";
|
|
613
|
+
let disposition;
|
|
614
|
+
for (const leaf of leavesBetween(paragraph, from.offset, to.offset)) {
|
|
615
|
+
if (leaf.node.type !== "text" || leaf.removed) return null;
|
|
616
|
+
const start = Math.max(from.offset, leaf.before.offset);
|
|
617
|
+
const end = Math.min(to.offset, leaf.after.offset);
|
|
618
|
+
text += leaf.node.text.slice(start - leaf.before.offset, end - leaf.before.offset);
|
|
619
|
+
let current = "retained";
|
|
620
|
+
if (leaf.insertion !== void 0) {
|
|
621
|
+
if (leaf.insertion.id < originalRevisionIdSeed) return null;
|
|
622
|
+
current = "inserted";
|
|
623
|
+
}
|
|
624
|
+
if (disposition !== void 0 && disposition !== current) return null;
|
|
625
|
+
disposition = current;
|
|
626
|
+
}
|
|
627
|
+
return text === expectedText ? disposition ?? null : null;
|
|
628
|
+
};
|
|
629
|
+
const atomDisposition = (leaf, originalRevisionIdSeed) => {
|
|
630
|
+
if (leaf.removed) return null;
|
|
631
|
+
if (leaf.insertion === void 0) return "retained";
|
|
632
|
+
return leaf.insertion.id >= originalRevisionIdSeed ? "inserted" : null;
|
|
633
|
+
};
|
|
634
|
+
const actionRangeCount = (action) => {
|
|
635
|
+
switch (action.kind) {
|
|
636
|
+
case "replace-text": return atomActionRangeCount(action.textDisposition);
|
|
637
|
+
case "replace-atom": return atomActionRangeCount(action.atomDisposition);
|
|
638
|
+
case "insert":
|
|
639
|
+
case "delete":
|
|
640
|
+
case "note-reference": return atomActionRangeCount(null);
|
|
641
|
+
default: return action;
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
/** A revised block's id in the snapshot the comparison planned against. */
|
|
645
|
+
const targetBlockIdOf = (snapshot, block) => Object.hasOwn(snapshot.anchors, block.survivor.paraId) ? block.survivor.paraId : void 0;
|
|
646
|
+
/**
|
|
647
|
+
* Where a point of the story as it stood lands after the batch's earlier
|
|
648
|
+
* edits, with the review's affinity: `1` past what was inserted there, `-1`
|
|
649
|
+
* before it.
|
|
650
|
+
*/
|
|
651
|
+
const mapPoint = (edits, point, assoc) => {
|
|
652
|
+
let { offset, zeroWidthBefore } = point;
|
|
653
|
+
for (const edit of edits.get(point.paraId) ?? []) {
|
|
654
|
+
const end = edit.offset + edit.deleted;
|
|
655
|
+
if (offset < edit.offset) continue;
|
|
656
|
+
if (offset > end) {
|
|
657
|
+
offset += edit.inserted - edit.deleted;
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
let side = assoc;
|
|
661
|
+
if (edit.deleted > 0 && offset === edit.offset) side = -1;
|
|
662
|
+
else if (edit.deleted > 0 && offset === end) side = 1;
|
|
663
|
+
const mapped = side < 0 ? edit.offset : edit.offset + edit.inserted;
|
|
664
|
+
if (mapped !== offset) zeroWidthBefore = 0;
|
|
665
|
+
offset = mapped;
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
...point,
|
|
669
|
+
offset,
|
|
670
|
+
zeroWidthBefore
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* Restore field, picture and page-break atoms omitted by text-only comparison
|
|
675
|
+
* operations, and the note references whose markers they wrote as text, as
|
|
676
|
+
* document operations on the reviewed story.
|
|
677
|
+
*/
|
|
678
|
+
const matchInlineAtomsOnModel = ({ document, story, target, revisionStamp, originalRevisionIdSeed, author, maxRanges, noteReferenceLabels, baseNotes }) => {
|
|
679
|
+
if (!Number.isSafeInteger(maxRanges) || maxRanges < 0) return { status: "budget-exceeded" };
|
|
680
|
+
const live = readStoryOf({
|
|
681
|
+
document,
|
|
682
|
+
story
|
|
683
|
+
});
|
|
684
|
+
const revised = readStoryOf(target);
|
|
685
|
+
const restoresNoteReferences = wroteNoteReferenceMarker(live, originalRevisionIdSeed) && hasNoteReference(revised);
|
|
686
|
+
const noteReferences = restoresNoteReferences ? noteReferenceLabels : "sourceText";
|
|
687
|
+
const unchanged = {
|
|
688
|
+
status: "matched",
|
|
689
|
+
operations: [],
|
|
690
|
+
nextRevisionId: revisionStamp.idSeed,
|
|
691
|
+
changedTargetBlockIds: [],
|
|
692
|
+
rangeCount: 0
|
|
693
|
+
};
|
|
694
|
+
if (!restoresNoteReferences && !hasSupportedAtom(live) && !hasSupportedAtom(revised)) return unchanged;
|
|
695
|
+
const liveBlocks = readBlocks(live, "text", noteReferences);
|
|
696
|
+
const targetBlocks = readBlocks(revised, "text", noteReferences);
|
|
697
|
+
if (liveBlocks.length !== targetBlocks.length) return { status: "unalignable" };
|
|
698
|
+
const paragraphs = new Map(live.paragraphs.map((paragraph) => [paragraph.paraId, paragraph]));
|
|
699
|
+
const actions = [];
|
|
700
|
+
let rangeCount = 0;
|
|
701
|
+
const planAction = (action) => {
|
|
702
|
+
const nextRangeCount = rangeCount + actionRangeCount(action);
|
|
703
|
+
if (nextRangeCount > maxRanges) return false;
|
|
704
|
+
rangeCount = nextRangeCount;
|
|
705
|
+
actions.push(action);
|
|
706
|
+
return true;
|
|
707
|
+
};
|
|
708
|
+
let referencedNotes;
|
|
709
|
+
let omittedLiveBlocks;
|
|
710
|
+
let omittedTargetBlocks;
|
|
711
|
+
for (const [index, fullLive] of liveBlocks.entries()) {
|
|
712
|
+
const fullTarget = targetBlocks[index];
|
|
713
|
+
if (!fullTarget) return { status: "unalignable" };
|
|
714
|
+
const targetBlockId = targetBlockIdOf(target.snapshot, fullTarget);
|
|
715
|
+
if ((fullLive.noteReferences.length > 0 || fullTarget.noteReferences.length > 0) && fullLive.cleanText === fullTarget.cleanText) {
|
|
716
|
+
const kept = new Map(fullLive.noteReferences.map((reference) => [reference.offset, reference]));
|
|
717
|
+
for (const reference of fullTarget.noteReferences) {
|
|
718
|
+
const liveReference = kept.get(reference.offset);
|
|
719
|
+
if (liveReference) {
|
|
720
|
+
kept.delete(reference.offset);
|
|
721
|
+
if (noteReferenceKey(liveReference) !== noteReferenceKey(reference) || liveReference.length !== reference.length) return { status: "unalignable" };
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
referencedNotes ??= baseNotes ?? referencedNotesOf(live);
|
|
725
|
+
if (!referencedNotes.has(noteReferenceKey(reference))) return {
|
|
726
|
+
status: "unalignable",
|
|
727
|
+
detail: MISSING_NOTE_DETAIL
|
|
728
|
+
};
|
|
729
|
+
const from = fullLive.offsets[reference.offset];
|
|
730
|
+
const to = pastCharacter(fullLive, reference.offset + reference.length - 1);
|
|
731
|
+
const written = fullLive.characters[reference.offset]?.at.leaf;
|
|
732
|
+
if (from === void 0 || to === void 0 || written === void 0) return { status: "unalignable" };
|
|
733
|
+
if (textRangeDisposition({
|
|
734
|
+
paragraphs,
|
|
735
|
+
from,
|
|
736
|
+
to,
|
|
737
|
+
expectedText: fullTarget.cleanText.slice(reference.offset, reference.offset + reference.length),
|
|
738
|
+
originalRevisionIdSeed
|
|
739
|
+
}) !== "inserted" || written.insertion === void 0) return { status: "unalignable" };
|
|
740
|
+
if (!planAction({
|
|
741
|
+
kind: "note-reference",
|
|
742
|
+
from,
|
|
743
|
+
to,
|
|
744
|
+
content: runWith(written.run, reference.reference),
|
|
745
|
+
insertion: written.insertion,
|
|
746
|
+
targetBlockId
|
|
747
|
+
})) return { status: "budget-exceeded" };
|
|
748
|
+
}
|
|
749
|
+
if (kept.size > 0) return { status: "unalignable" };
|
|
750
|
+
}
|
|
751
|
+
if (fullLive.supported.length === 0 && fullTarget.supported.length === 0) continue;
|
|
752
|
+
if (sameSupportedAtoms(fullLive, fullTarget)) continue;
|
|
753
|
+
let liveBlock = fullLive;
|
|
754
|
+
let targetBlock = fullTarget;
|
|
755
|
+
let fieldResults = "text";
|
|
756
|
+
if (!sameBlockTopology(liveBlock, targetBlock)) {
|
|
757
|
+
omittedLiveBlocks ??= readBlocks(live, "omitted", noteReferences);
|
|
758
|
+
omittedTargetBlocks ??= readBlocks(revised, "omitted", noteReferences);
|
|
759
|
+
const omittedLive = omittedLiveBlocks[index];
|
|
760
|
+
const omittedTarget = omittedTargetBlocks[index];
|
|
761
|
+
if (!omittedLive || !omittedTarget || !sameBlockTopology(omittedLive, omittedTarget)) return { status: "unalignable" };
|
|
762
|
+
liveBlock = omittedLive;
|
|
763
|
+
targetBlock = omittedTarget;
|
|
764
|
+
fieldResults = "omitted";
|
|
765
|
+
}
|
|
766
|
+
const matches = matchingAtoms({
|
|
767
|
+
live: liveBlock.supported,
|
|
768
|
+
target: targetBlock.supported
|
|
769
|
+
});
|
|
770
|
+
const matchedLive = new Set(matches.map(([liveIndex]) => liveIndex));
|
|
771
|
+
const matchedTarget = new Set(matches.map(([, targetIndex]) => targetIndex));
|
|
772
|
+
const anchors = insertionAnchors({
|
|
773
|
+
live: liveBlock.supported,
|
|
774
|
+
target: targetBlock.supported,
|
|
775
|
+
matches
|
|
776
|
+
});
|
|
777
|
+
const liveFieldResultOwnership = fieldResultOwnershipOf(liveBlock.supported);
|
|
778
|
+
const targetFieldResultOwnership = fieldResultOwnershipOf(targetBlock.supported);
|
|
779
|
+
for (const [liveIndex, atom] of liveBlock.supported.entries()) {
|
|
780
|
+
if (matchedLive.has(liveIndex)) continue;
|
|
781
|
+
const from = pointBefore(atom.at);
|
|
782
|
+
const to = pointAfter(atom.at);
|
|
783
|
+
const { resultText } = atom;
|
|
784
|
+
if (fieldResults === "text" && resultText && !ownsFieldResult({
|
|
785
|
+
ownership: targetFieldResultOwnership,
|
|
786
|
+
offset: atom.offset,
|
|
787
|
+
resultText
|
|
788
|
+
})) {
|
|
789
|
+
const disposition = atomDisposition(atom.at.leaf, originalRevisionIdSeed);
|
|
790
|
+
if (disposition === null) return { status: "unalignable" };
|
|
791
|
+
const field = atom.at.leaf.node;
|
|
792
|
+
if (!planAction({
|
|
793
|
+
kind: "replace-atom",
|
|
794
|
+
from,
|
|
795
|
+
to,
|
|
796
|
+
text: resultText,
|
|
797
|
+
atomDisposition: disposition,
|
|
798
|
+
formatting: field.type === "simpleField" || field.type === "complexField" ? fieldFormattingOf(field) : void 0,
|
|
799
|
+
targetBlockId
|
|
800
|
+
})) return { status: "budget-exceeded" };
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
const disposition = atomDisposition(atom.at.leaf, originalRevisionIdSeed);
|
|
804
|
+
if (disposition === null) return { status: "unalignable" };
|
|
805
|
+
if (!planAction({
|
|
806
|
+
kind: "delete",
|
|
807
|
+
from,
|
|
808
|
+
to,
|
|
809
|
+
disposition,
|
|
810
|
+
targetBlockId
|
|
811
|
+
})) return { status: "budget-exceeded" };
|
|
812
|
+
}
|
|
813
|
+
for (const [targetIndex, atom] of targetBlock.supported.entries()) {
|
|
814
|
+
if (matchedTarget.has(targetIndex)) continue;
|
|
815
|
+
const anchor = anchors.get(targetIndex);
|
|
816
|
+
const anchorAtom = anchor === void 0 ? void 0 : liveBlock.supported[anchor.liveIndex];
|
|
817
|
+
let from;
|
|
818
|
+
if (anchor === void 0 || anchorAtom === void 0) from = liveBlock.offsets[atom.offset];
|
|
819
|
+
else from = anchor.side === "before" ? pointBefore(anchorAtom.at) : pastLeaf(liveBlock.chain, anchorAtom.at);
|
|
820
|
+
if (from === void 0) return { status: "unalignable" };
|
|
821
|
+
const { resultText } = atom;
|
|
822
|
+
if (fieldResults === "text" && resultText && !ownsFieldResult({
|
|
823
|
+
ownership: liveFieldResultOwnership,
|
|
824
|
+
offset: atom.offset,
|
|
825
|
+
resultText
|
|
826
|
+
})) {
|
|
827
|
+
const to = pastCharacter(liveBlock, atom.offset + resultText.length - 1);
|
|
828
|
+
if (to === void 0) return { status: "unalignable" };
|
|
829
|
+
const textDisposition = textRangeDisposition({
|
|
830
|
+
paragraphs,
|
|
831
|
+
from,
|
|
832
|
+
to,
|
|
833
|
+
expectedText: resultText,
|
|
834
|
+
originalRevisionIdSeed
|
|
835
|
+
});
|
|
836
|
+
if (textDisposition === null) return { status: "unalignable" };
|
|
837
|
+
if (!planAction({
|
|
838
|
+
kind: "replace-text",
|
|
839
|
+
from,
|
|
840
|
+
to,
|
|
841
|
+
content: atom.content,
|
|
842
|
+
textDisposition,
|
|
843
|
+
targetBlockId
|
|
844
|
+
})) return { status: "budget-exceeded" };
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
if (!planAction({
|
|
848
|
+
kind: "insert",
|
|
849
|
+
from,
|
|
850
|
+
content: atom.content,
|
|
851
|
+
targetBlockId
|
|
852
|
+
})) return { status: "budget-exceeded" };
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return writeActions({
|
|
856
|
+
document,
|
|
857
|
+
actions,
|
|
858
|
+
story,
|
|
859
|
+
author,
|
|
860
|
+
revisionStamp,
|
|
861
|
+
rangeCount
|
|
862
|
+
});
|
|
863
|
+
};
|
|
864
|
+
const PICTURE_DATA_URL = /^data:(image\/[a-z0-9.+-]+);base64,([A-Za-z0-9+/=\s]+)$/iu;
|
|
865
|
+
/** The picture of a revised atom, when the atom inserts one. */
|
|
866
|
+
const insertedPictureOf = (content) => {
|
|
867
|
+
if (content.type !== "run") return void 0;
|
|
868
|
+
const drawing = content.content.at(0);
|
|
869
|
+
return drawing?.type === "drawing" && drawing.image.rId === COMPARISON_IMAGE_RELATIONSHIP ? drawing : void 0;
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* The batch that carries the planned actions out, from the end of the story
|
|
873
|
+
* back, each edit addressed where the earlier ones left its point. Every
|
|
874
|
+
* operation is applied to a copy as it is written, so the batch names the
|
|
875
|
+
* ids the records it cuts take, and a picture brings its media and
|
|
876
|
+
* relationship ahead of it.
|
|
877
|
+
*/
|
|
878
|
+
const writeActions = ({ document, actions, story, author, revisionStamp, rangeCount }) => {
|
|
879
|
+
const operations = [];
|
|
880
|
+
let current = readModel(document);
|
|
881
|
+
const edits = /* @__PURE__ */ new Map();
|
|
882
|
+
const changedTargetBlockIds = /* @__PURE__ */ new Set();
|
|
883
|
+
let nextRevisionId = revisionStamp.idSeed;
|
|
884
|
+
let refusal;
|
|
885
|
+
/** The drawing ids in use, read when the first picture comes in. */
|
|
886
|
+
let drawingIds;
|
|
887
|
+
const stamp = () => ({
|
|
888
|
+
id: nextRevisionId++,
|
|
889
|
+
author,
|
|
890
|
+
date: revisionStamp.date
|
|
891
|
+
});
|
|
892
|
+
const position = (point) => ({
|
|
893
|
+
story,
|
|
894
|
+
blockId: point.paraId,
|
|
895
|
+
offset: point.offset,
|
|
896
|
+
zeroWidthBefore: point.zeroWidthBefore
|
|
897
|
+
});
|
|
898
|
+
const record = (point, edit) => {
|
|
899
|
+
const list = edits.get(point.paraId);
|
|
900
|
+
if (list === void 0) edits.set(point.paraId, [edit]);
|
|
901
|
+
else list.push(edit);
|
|
902
|
+
};
|
|
903
|
+
/** Apply one operation to the copy and keep it, or note why it cannot apply. */
|
|
904
|
+
const emit = (op) => {
|
|
905
|
+
if (refusal !== void 0) return false;
|
|
906
|
+
const applied = applyDocumentOp(current, op);
|
|
907
|
+
if (applied.isErr()) {
|
|
908
|
+
refusal = applied.error.message;
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
current = applied.value.document;
|
|
912
|
+
operations.push(op);
|
|
913
|
+
return true;
|
|
914
|
+
};
|
|
915
|
+
/** The ids the records an edit cuts in two take, after its stamp's. */
|
|
916
|
+
const freshIds = (op) => {
|
|
917
|
+
const demand = revisionIdDemand(current, op);
|
|
918
|
+
if (demand.isErr()) {
|
|
919
|
+
refusal ??= demand.error.message;
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
if (demand.value === 0) return void 0;
|
|
923
|
+
return { revision: Array.from({ length: demand.value }, () => nextRevisionId++) };
|
|
924
|
+
};
|
|
925
|
+
/** A picture's media and relationship, added to the package for it. */
|
|
926
|
+
const withPictureResources = (picture) => {
|
|
927
|
+
const { src } = picture.image;
|
|
928
|
+
const data = src === void 0 ? null : PICTURE_DATA_URL.exec(src);
|
|
929
|
+
const mimeType = data?.at(1);
|
|
930
|
+
const payload = data?.at(2);
|
|
931
|
+
if (src === void 0 || mimeType === void 0 || payload === void 0) {
|
|
932
|
+
refusal ??= "A restored picture has no embedded image bytes.";
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const relationships = new Map(current.package.relationships);
|
|
936
|
+
let relationshipIndex = relationships.size + 1;
|
|
937
|
+
while (relationships.has(`rId${String(relationshipIndex)}`)) relationshipIndex += 1;
|
|
938
|
+
const id = relationshipIdOf(`rId${String(relationshipIndex)}`);
|
|
939
|
+
const media = new Map(current.package.media);
|
|
940
|
+
const extension = mimeType.toLowerCase() === "image/jpeg" ? "jpg" : mimeType.slice(6);
|
|
941
|
+
let mediaIndex = media.size + 1;
|
|
942
|
+
while (media.has(`word/media/compare${String(mediaIndex)}.${extension}`)) mediaIndex += 1;
|
|
943
|
+
const path = `word/media/compare${String(mediaIndex)}.${extension}`;
|
|
944
|
+
if (id === void 0) {
|
|
945
|
+
refusal ??= "A restored picture's relationship id names nothing.";
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
media.set(path, {
|
|
949
|
+
path,
|
|
950
|
+
mimeType,
|
|
951
|
+
data: base64ToBytes(payload).slice().buffer,
|
|
952
|
+
dataUrl: src
|
|
953
|
+
});
|
|
954
|
+
relationships.set(id, {
|
|
955
|
+
id,
|
|
956
|
+
type: RELATIONSHIP_TYPES.image,
|
|
957
|
+
target: path.slice(5)
|
|
958
|
+
});
|
|
959
|
+
const rawXml = picture.rawXml === void 0 ? void 0 : rebindDrawingImageRelationship({
|
|
960
|
+
xml: picture.rawXml,
|
|
961
|
+
previousId: COMPARISON_IMAGE_RELATIONSHIP,
|
|
962
|
+
nextId: id
|
|
963
|
+
});
|
|
964
|
+
if (rawXml === null) {
|
|
965
|
+
refusal ??= "A restored picture's markup names no single image.";
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
if (!emit(packageResourcesOpOf({
|
|
969
|
+
before: current,
|
|
970
|
+
after: {
|
|
971
|
+
...current,
|
|
972
|
+
package: {
|
|
973
|
+
...current.package,
|
|
974
|
+
relationships,
|
|
975
|
+
media
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}))) return void 0;
|
|
979
|
+
drawingIds ??= usedDrawingIds({
|
|
980
|
+
documentBody: current.package.document,
|
|
981
|
+
headers: current.package.headers,
|
|
982
|
+
footers: current.package.footers,
|
|
983
|
+
footnotes: current.package.footnotes,
|
|
984
|
+
endnotes: current.package.endnotes
|
|
985
|
+
});
|
|
986
|
+
return withDrawingId({
|
|
987
|
+
...picture,
|
|
988
|
+
image: {
|
|
989
|
+
...picture.image,
|
|
990
|
+
rId: id
|
|
991
|
+
},
|
|
992
|
+
...rawXml === void 0 ? {} : { rawXml }
|
|
993
|
+
}, takeDrawingId(drawingIds));
|
|
994
|
+
};
|
|
995
|
+
const insert = (at, content, revision, recordsEdit = true) => {
|
|
996
|
+
const picture = insertedPictureOf(content);
|
|
997
|
+
let inserted = content;
|
|
998
|
+
if (picture !== void 0 && content.type === "run") {
|
|
999
|
+
const placed = withPictureResources(picture);
|
|
1000
|
+
if (placed === void 0) return false;
|
|
1001
|
+
inserted = {
|
|
1002
|
+
...content,
|
|
1003
|
+
content: [placed]
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
const op = {
|
|
1007
|
+
type: DOCUMENT_OP_TYPES.INSERT_CONTENT,
|
|
1008
|
+
at: position(at),
|
|
1009
|
+
slice: {
|
|
1010
|
+
content: [writableCopy(inserted)],
|
|
1011
|
+
openStart: 0,
|
|
1012
|
+
openEnd: 0
|
|
1013
|
+
},
|
|
1014
|
+
revision
|
|
1015
|
+
};
|
|
1016
|
+
const newIds = freshIds(op);
|
|
1017
|
+
if (refusal !== void 0) return false;
|
|
1018
|
+
if (!emit(newIds === void 0 ? op : {
|
|
1019
|
+
...op,
|
|
1020
|
+
newIds
|
|
1021
|
+
})) return false;
|
|
1022
|
+
if (recordsEdit) record(at, {
|
|
1023
|
+
offset: at.offset,
|
|
1024
|
+
deleted: 0,
|
|
1025
|
+
inserted: offsetWidthOf(inserted)
|
|
1026
|
+
});
|
|
1027
|
+
return true;
|
|
1028
|
+
};
|
|
1029
|
+
/** Remove `[from, to)`: the comparison's own insertion goes, anything else is marked deleted. */
|
|
1030
|
+
const remove = (from, to, disposition, recordsEdit = true) => {
|
|
1031
|
+
switch (disposition) {
|
|
1032
|
+
case "inserted": {
|
|
1033
|
+
const op = {
|
|
1034
|
+
type: DOCUMENT_OP_TYPES.DELETE_RANGE,
|
|
1035
|
+
from: position(from),
|
|
1036
|
+
to: position(to)
|
|
1037
|
+
};
|
|
1038
|
+
if (!emit(op)) return false;
|
|
1039
|
+
if (recordsEdit) record(from, {
|
|
1040
|
+
offset: from.offset,
|
|
1041
|
+
deleted: to.offset - from.offset,
|
|
1042
|
+
inserted: 0
|
|
1043
|
+
});
|
|
1044
|
+
return true;
|
|
1045
|
+
}
|
|
1046
|
+
case "retained": {
|
|
1047
|
+
const op = {
|
|
1048
|
+
type: DOCUMENT_OP_TYPES.DELETE_RANGE,
|
|
1049
|
+
from: position(from),
|
|
1050
|
+
to: position(to),
|
|
1051
|
+
revision: stamp()
|
|
1052
|
+
};
|
|
1053
|
+
const newIds = freshIds(op);
|
|
1054
|
+
if (refusal !== void 0) return false;
|
|
1055
|
+
return emit(newIds === void 0 ? op : {
|
|
1056
|
+
...op,
|
|
1057
|
+
newIds
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
default: return disposition;
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
const ordered = actions.toSorted((left, right) => comparePoints(right.from, left.from) || atomActionTieRank(left.kind) - atomActionTieRank(right.kind));
|
|
1064
|
+
for (const action of ordered) {
|
|
1065
|
+
let written;
|
|
1066
|
+
switch (action.kind) {
|
|
1067
|
+
case "insert":
|
|
1068
|
+
written = insert(mapPoint(edits, action.from, 1), action.content, stamp());
|
|
1069
|
+
break;
|
|
1070
|
+
case "replace-text":
|
|
1071
|
+
case "replace-atom": {
|
|
1072
|
+
const from = mapPoint(edits, action.from, 1);
|
|
1073
|
+
const to = mapPoint(edits, action.to, -1);
|
|
1074
|
+
if (from.paraId !== to.paraId || from.offset >= to.offset) return { status: "unalignable" };
|
|
1075
|
+
written = remove(from, to, action.kind === "replace-text" ? action.textDisposition : action.atomDisposition) && insert(mapPoint(edits, action.from, 1), action.kind === "replace-text" ? action.content : {
|
|
1076
|
+
type: "run",
|
|
1077
|
+
...action.formatting === void 0 ? {} : { formatting: action.formatting },
|
|
1078
|
+
content: [{
|
|
1079
|
+
type: "text",
|
|
1080
|
+
text: action.text
|
|
1081
|
+
}]
|
|
1082
|
+
}, stamp());
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
case "note-reference": {
|
|
1086
|
+
const from = mapPoint(edits, action.from, 1);
|
|
1087
|
+
const to = mapPoint(edits, action.to, -1);
|
|
1088
|
+
if (from.paraId !== to.paraId || from.offset >= to.offset) return { status: "unalignable" };
|
|
1089
|
+
written = insert(from, action.content, {
|
|
1090
|
+
id: nextRevisionId++,
|
|
1091
|
+
author: action.insertion.author,
|
|
1092
|
+
date: action.insertion.date ?? revisionStamp.date
|
|
1093
|
+
}, false) && remove({
|
|
1094
|
+
...from,
|
|
1095
|
+
offset: from.offset + 1,
|
|
1096
|
+
zeroWidthBefore: 0
|
|
1097
|
+
}, {
|
|
1098
|
+
...to,
|
|
1099
|
+
offset: to.offset + 1
|
|
1100
|
+
}, "inserted", false);
|
|
1101
|
+
if (written) record(from, {
|
|
1102
|
+
offset: from.offset,
|
|
1103
|
+
deleted: to.offset - from.offset,
|
|
1104
|
+
inserted: 1
|
|
1105
|
+
});
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case "delete": {
|
|
1109
|
+
const from = mapPoint(edits, action.from, 1);
|
|
1110
|
+
const to = mapPoint(edits, action.to, -1);
|
|
1111
|
+
if (from.paraId !== to.paraId || to.offset - from.offset !== 1) return { status: "unalignable" };
|
|
1112
|
+
written = remove(from, to, action.disposition);
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
default: return action;
|
|
1116
|
+
}
|
|
1117
|
+
if (!written) return {
|
|
1118
|
+
status: "unalignable",
|
|
1119
|
+
detail: `inline atoms cannot be restored as document operations: ${refusal ?? "an operation was refused"}`
|
|
1120
|
+
};
|
|
1121
|
+
if (action.targetBlockId) changedTargetBlockIds.add(action.targetBlockId);
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
status: "matched",
|
|
1125
|
+
operations,
|
|
1126
|
+
nextRevisionId,
|
|
1127
|
+
changedTargetBlockIds: [...changedTargetBlockIds],
|
|
1128
|
+
rangeCount
|
|
1129
|
+
};
|
|
1130
|
+
};
|
|
1131
|
+
export { matchInlineAtomsOnModel };
|