@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
|
@@ -1,1276 +0,0 @@
|
|
|
1
|
-
import { SUGGESTED_SUPPORTED_OPERATION_TYPES } from "../ai-edits/apply.js";
|
|
2
|
-
import { splitsGraphemeCluster, splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
3
|
-
import { buildCleanBlockText, resolveCleanTextRange } from "../ai-edits/clean-text.js";
|
|
4
|
-
import { stripInlineEmphasisMarkers } from "../ai-edits/inline-emphasis.js";
|
|
5
|
-
import { createBatchListMinter } from "../ai-edits/newListNumbering.js";
|
|
6
|
-
import { collectNoteReferenceLabels, hashFolioAIBlockContent, hashFolioAIBlockText } from "../ai-edits/snapshot.js";
|
|
7
|
-
import { findOutermostTableBoundary } from "../ai-edits/table-targets.js";
|
|
8
|
-
import { wordDiffSessionFromOptions } from "../ai-edits/word-diff.js";
|
|
9
|
-
import { getFolioDocumentOperationIssues, getFolioDocumentOperationReceiptsForStory, parseFolioDocumentOperationBatch, withDistinctSuggestionIds } from "../document-operations.js";
|
|
10
|
-
import { maxAnnotationIdInDoc } from "../prosemirror/plugins/revisionIds.js";
|
|
11
|
-
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
12
|
-
import { canonicalCommentBody, compileCanonicalComments } from "./canonicalComments.js";
|
|
13
|
-
import { lockViolationBetween } from "./canonicalLockGuard.js";
|
|
14
|
-
import { Result, TaggedError, panic } from "better-result";
|
|
15
|
-
import { CONTENT_CONTROL_LOCK, lockedControlMessage, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
16
|
-
import { Mark } from "prosemirror-model";
|
|
17
|
-
import { applyDocumentOps, compileEditorIntent, createEditorIntentIdAllocator, documentStories, findStoryBody, freshCommentId, paragraphLength, pendingSuggestionIdsIn, revisionSpan, storyParagraphs } from "@stll/docx-core/ops";
|
|
18
|
-
// src/controller/canonicalPublicOperations.ts
|
|
19
|
-
/** Public batches compile against the read projection; only the canonical journal publishes. */
|
|
20
|
-
/** A new public kind cannot bypass a canonical compiler/refusal decision. */
|
|
21
|
-
const CANONICAL_PUBLIC_OPERATION_DISPOSITIONS = {
|
|
22
|
-
replaceInBlock: "compile",
|
|
23
|
-
replaceRange: "compile",
|
|
24
|
-
replaceBlock: "compile",
|
|
25
|
-
splitBlock: "compile",
|
|
26
|
-
formatRange: "compile",
|
|
27
|
-
mergeBlockWithNext: "compile",
|
|
28
|
-
setBlockParagraphProperties: "compile",
|
|
29
|
-
insertAfterBlock: "compile",
|
|
30
|
-
insertBeforeBlock: "compile",
|
|
31
|
-
deleteBlock: "compile",
|
|
32
|
-
commentOnBlock: "compile",
|
|
33
|
-
commentOnRange: "compile",
|
|
34
|
-
insertTable: CANONICAL_GAP.publicTableStructure,
|
|
35
|
-
insertSignatureTable: CANONICAL_GAP.publicTableStructure,
|
|
36
|
-
deleteTable: CANONICAL_GAP.publicTableStructure,
|
|
37
|
-
insertTableRow: CANONICAL_GAP.publicTableStructure,
|
|
38
|
-
deleteTableRow: CANONICAL_GAP.publicTableStructure,
|
|
39
|
-
insertTableColumn: CANONICAL_GAP.publicTableStructure,
|
|
40
|
-
deleteTableColumn: CANONICAL_GAP.publicTableStructure,
|
|
41
|
-
mergeTableCells: CANONICAL_GAP.publicTableStructure,
|
|
42
|
-
splitTableCell: CANONICAL_GAP.publicTableStructure
|
|
43
|
-
};
|
|
44
|
-
const resolveComment = ({ operation, from, to }) => {
|
|
45
|
-
if ("comment" in operation && operation.comment !== void 0) return {
|
|
46
|
-
type: "commented",
|
|
47
|
-
operation,
|
|
48
|
-
comment: {
|
|
49
|
-
text: operation.comment.text,
|
|
50
|
-
from,
|
|
51
|
-
to
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
type: "plain",
|
|
56
|
-
operation
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
const SPACING_FIELDS = [
|
|
60
|
-
"spaceBefore",
|
|
61
|
-
"spaceAfter",
|
|
62
|
-
"lineSpacing",
|
|
63
|
-
"lineSpacingRule",
|
|
64
|
-
"beforeAutospacing",
|
|
65
|
-
"afterAutospacing"
|
|
66
|
-
];
|
|
67
|
-
const INDENTATION_FIELDS = [
|
|
68
|
-
"indentLeft",
|
|
69
|
-
"indentRight",
|
|
70
|
-
"indentFirstLine",
|
|
71
|
-
"hangingIndent"
|
|
72
|
-
];
|
|
73
|
-
/**
|
|
74
|
-
* The stated paragraph properties an operation writes: each given property
|
|
75
|
-
* as it says, a spacing or indentation object as the whole direct child, so
|
|
76
|
-
* an attribute it leaves out is removed, and `null` clears a property back
|
|
77
|
-
* to what the style gives.
|
|
78
|
-
*/
|
|
79
|
-
const statedParagraphPatch = (properties) => {
|
|
80
|
-
const patch = {};
|
|
81
|
-
if (properties.styleId !== void 0) patch["styleId"] = properties.styleId;
|
|
82
|
-
if (properties.outlineLevel !== void 0) patch["outlineLevel"] = properties.outlineLevel;
|
|
83
|
-
if (properties.alignment !== void 0) patch["alignment"] = properties.alignment;
|
|
84
|
-
const { numbering } = properties;
|
|
85
|
-
if (numbering !== void 0 && numbering.kind !== "newList") patch["numPr"] = numbering.kind === "inherit" ? null : numbering;
|
|
86
|
-
const { spacing, indentation } = properties;
|
|
87
|
-
if (spacing !== void 0) for (const field of SPACING_FIELDS) patch[field] = spacing === null ? null : spacing[field] ?? null;
|
|
88
|
-
if (indentation !== void 0) for (const field of INDENTATION_FIELDS) patch[field] = indentation === null ? null : indentation[field] ?? null;
|
|
89
|
-
return patch;
|
|
90
|
-
};
|
|
91
|
-
const resolveParagraphProperties = ({ operation, paragraph, projection, mintList, refusal }) => {
|
|
92
|
-
const requested = operation.properties.numbering;
|
|
93
|
-
const stated = statedNumbering(requested, mintList);
|
|
94
|
-
const patch = statedParagraphPatch({
|
|
95
|
-
...operation.properties,
|
|
96
|
-
...stated.numbering === void 0 ? {} : { numbering: stated.numbering }
|
|
97
|
-
});
|
|
98
|
-
if (Object.keys(patch).length === 0) return refusal("emptyOperation");
|
|
99
|
-
const at = projection.addressAt(paragraph.start);
|
|
100
|
-
if (at.isErr()) return refusal("unsupportedBlock");
|
|
101
|
-
const intents = [{
|
|
102
|
-
type: "formatParagraph",
|
|
103
|
-
at: at.value,
|
|
104
|
-
patch,
|
|
105
|
-
...stated.newList === void 0 ? {} : { newList: stated.newList }
|
|
106
|
-
}];
|
|
107
|
-
return Result.ok({
|
|
108
|
-
type: "plain",
|
|
109
|
-
operation,
|
|
110
|
-
intents,
|
|
111
|
-
normalizations: [],
|
|
112
|
-
from: paragraph.start,
|
|
113
|
-
to: paragraph.start + paragraph.node.content.size
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* The intent that states `properties` on one paragraph by its identity,
|
|
118
|
-
* none when they state nothing.
|
|
119
|
-
*/
|
|
120
|
-
const statedPropertiesIntents = ({ story, blockId, properties, mintList }) => {
|
|
121
|
-
if (properties === void 0) return [];
|
|
122
|
-
const stated = statedNumbering(properties.numbering, mintList);
|
|
123
|
-
const patch = statedParagraphPatch({
|
|
124
|
-
...properties,
|
|
125
|
-
...stated.numbering === void 0 ? {} : { numbering: stated.numbering }
|
|
126
|
-
});
|
|
127
|
-
if (Object.keys(patch).length === 0) return [];
|
|
128
|
-
return [{
|
|
129
|
-
type: "formatParagraph",
|
|
130
|
-
at: {
|
|
131
|
-
story,
|
|
132
|
-
blockId,
|
|
133
|
-
offset: 0
|
|
134
|
-
},
|
|
135
|
-
patch,
|
|
136
|
-
...stated.newList === void 0 ? {} : { newList: stated.newList }
|
|
137
|
-
}];
|
|
138
|
-
};
|
|
139
|
-
const isBlockInsertion = (operation) => operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock";
|
|
140
|
-
/**
|
|
141
|
-
* Where an insertion beside `paragraph` goes: beside the paragraph, or, for a
|
|
142
|
-
* paragraph in a table cell, beside the outermost table, as the default
|
|
143
|
-
* engine places it. The point names the paragraph on the far side of the
|
|
144
|
-
* table; none stands there when the table starts or ends its container.
|
|
145
|
-
*/
|
|
146
|
-
const blockInsertionPlace = (operation, paragraph, projection) => {
|
|
147
|
-
const side = operation.type === "insertAfterBlock" ? "after" : "before";
|
|
148
|
-
const table = findOutermostTableBoundary(projection.doc, paragraph.start - 1);
|
|
149
|
-
if (table === null) return {
|
|
150
|
-
at: {
|
|
151
|
-
type: side,
|
|
152
|
-
blockId: paragraph.blockId
|
|
153
|
-
},
|
|
154
|
-
position: side === "after" ? paragraph.start + paragraph.node.content.size : paragraph.start
|
|
155
|
-
};
|
|
156
|
-
const position = table[side];
|
|
157
|
-
const resolved = projection.doc.resolve(position);
|
|
158
|
-
const beside = side === "after" ? resolved.nodeAfter : resolved.nodeBefore;
|
|
159
|
-
if (beside?.type.name !== "paragraph") return void 0;
|
|
160
|
-
const neighbour = projection.paragraphStartingAt(side === "after" ? position : position - beside.nodeSize);
|
|
161
|
-
if (neighbour === void 0) return void 0;
|
|
162
|
-
return {
|
|
163
|
-
at: {
|
|
164
|
-
type: side === "after" ? "before" : "after",
|
|
165
|
-
blockId: neighbour.blockId
|
|
166
|
-
},
|
|
167
|
-
position
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* One new paragraph beside the anchor, as the default engine writes it: the
|
|
172
|
-
* anchor's stated paragraph properties unless `inheritFormatting` is false,
|
|
173
|
-
* with the operation's own on top, holding the text as one plain run.
|
|
174
|
-
*/
|
|
175
|
-
const resolveBlockInsertion = ({ operation, paragraph, projection, story, mintList, refusal }) => {
|
|
176
|
-
const requested = operation.numbering;
|
|
177
|
-
const stated = statedNumbering(requested, mintList);
|
|
178
|
-
const { text } = operation;
|
|
179
|
-
if (stripInlineEmphasisMarkers(text) !== text) return refusal("unsupportedBlock", "Canonical public emphasis replacements are unavailable.");
|
|
180
|
-
const inline = operation.lineBreakMode === "inline";
|
|
181
|
-
if (/\[\^(?:e)?\d+\]/u.test(text)) return refusal("unsupportedBlock", "Canonical block insertion requires plain text.");
|
|
182
|
-
const split = !inline && LINE_BREAK_PATTERN.test(text);
|
|
183
|
-
const lines = split ? text.split(LINE_BREAK_PATTERN).filter((line) => line.trim().length > 0) : [text];
|
|
184
|
-
const texts = lines.length === 0 ? [""] : lines;
|
|
185
|
-
const formatting = operation.inheritFormatting === false ? {} : { ...paragraph.source.formatting };
|
|
186
|
-
for (const [key, value] of Object.entries(statedParagraphPatch({
|
|
187
|
-
...operation.styleId === void 0 ? {} : { styleId: operation.styleId },
|
|
188
|
-
...operation.outlineLevel === void 0 ? {} : { outlineLevel: operation.outlineLevel },
|
|
189
|
-
...operation.alignment === void 0 ? {} : { alignment: operation.alignment },
|
|
190
|
-
...operation.spacing === void 0 ? {} : { spacing: operation.spacing },
|
|
191
|
-
...operation.indentation === void 0 ? {} : { indentation: operation.indentation },
|
|
192
|
-
...stated.numbering === void 0 ? {} : { numbering: stated.numbering }
|
|
193
|
-
}))) if (value === null) Reflect.deleteProperty(formatting, key);
|
|
194
|
-
else formatting[key] = value;
|
|
195
|
-
const everyParagraph = operation.formattingScope === "allParagraphs";
|
|
196
|
-
const paragraphs = texts.map((line, index) => {
|
|
197
|
-
const own = index === 0 || everyParagraph ? { ...formatting } : {};
|
|
198
|
-
if (index === 0 && operation.pageBreakBefore === true) own["pageBreakBefore"] = true;
|
|
199
|
-
const pageBreak = index === 0 ? operation.hardPageBreak : void 0;
|
|
200
|
-
let content = [];
|
|
201
|
-
if (pageBreak !== void 0) content = [{
|
|
202
|
-
type: "run",
|
|
203
|
-
content: [{
|
|
204
|
-
type: "break",
|
|
205
|
-
breakType: "page",
|
|
206
|
-
...pageBreak.clear === void 0 ? {} : { clear: pageBreak.clear }
|
|
207
|
-
}]
|
|
208
|
-
}];
|
|
209
|
-
else if (line !== "") content = [{
|
|
210
|
-
type: "run",
|
|
211
|
-
content: inlineText(line)
|
|
212
|
-
}];
|
|
213
|
-
return {
|
|
214
|
-
type: "paragraph",
|
|
215
|
-
content,
|
|
216
|
-
...Object.keys(own).length === 0 ? {} : { formatting: own }
|
|
217
|
-
};
|
|
218
|
-
});
|
|
219
|
-
const place = blockInsertionPlace(operation, paragraph, projection);
|
|
220
|
-
if (place === void 0) return refusal("unsupportedBlock", "Canonical insertion beside a table needs a paragraph on that side of it.");
|
|
221
|
-
const intents = [{
|
|
222
|
-
type: "insertParagraphs",
|
|
223
|
-
story,
|
|
224
|
-
at: place.at,
|
|
225
|
-
paragraphs,
|
|
226
|
-
...stated.newList === void 0 ? {} : { newList: stated.newList }
|
|
227
|
-
}];
|
|
228
|
-
const { position } = place;
|
|
229
|
-
if (operation.comment !== void 0 && texts.every((line) => line.length === 0)) return refusal("unsupportedBlock");
|
|
230
|
-
const resolved = {
|
|
231
|
-
intents,
|
|
232
|
-
normalizations: split ? [{
|
|
233
|
-
id: operation.id,
|
|
234
|
-
code: "splitMultilineText",
|
|
235
|
-
paragraphCount: texts.length
|
|
236
|
-
}] : [],
|
|
237
|
-
from: position,
|
|
238
|
-
to: position
|
|
239
|
-
};
|
|
240
|
-
if (operation.comment === void 0) return Result.ok({
|
|
241
|
-
type: "plain",
|
|
242
|
-
operation,
|
|
243
|
-
...resolved
|
|
244
|
-
});
|
|
245
|
-
const anchor = {
|
|
246
|
-
story,
|
|
247
|
-
blockId: place.at.blockId,
|
|
248
|
-
offset: 0
|
|
249
|
-
};
|
|
250
|
-
return Result.ok({
|
|
251
|
-
type: "commented",
|
|
252
|
-
operation,
|
|
253
|
-
comment: {
|
|
254
|
-
text: operation.comment.text,
|
|
255
|
-
from: anchor,
|
|
256
|
-
to: anchor,
|
|
257
|
-
inserted: true
|
|
258
|
-
},
|
|
259
|
-
...resolved
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
const LINE_BREAK_PATTERN = /\r\n|\r|\n/u;
|
|
263
|
-
/**
|
|
264
|
-
* The operations a canonical suggestion can carry: the default engine's;
|
|
265
|
-
* splits and merges, which the canonical session records as tracked paragraph
|
|
266
|
-
* marks stamped with the suggestion; and comments, which it holds as proposed
|
|
267
|
-
* by the suggestion until it is accepted or rejected.
|
|
268
|
-
*/
|
|
269
|
-
const CANONICAL_SUGGESTED_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
270
|
-
...SUGGESTED_SUPPORTED_OPERATION_TYPES,
|
|
271
|
-
"splitBlock",
|
|
272
|
-
"mergeBlockWithNext",
|
|
273
|
-
"commentOnRange",
|
|
274
|
-
"commentOnBlock"
|
|
275
|
-
]);
|
|
276
|
-
/**
|
|
277
|
-
* Whether one of two resolved operations inserts beside the paragraph the
|
|
278
|
-
* other deletes by identity: they touch only at that paragraph's edge, and
|
|
279
|
-
* both apply, as in the default engine. A deletion of a paragraph that ends
|
|
280
|
-
* its container still refuses the insertion beside it.
|
|
281
|
-
*/
|
|
282
|
-
const besideItsDeletion = (left, right) => {
|
|
283
|
-
const pair = ({ operation: insertion }, { operation: deletion, removesParagraphBeforeBlock }) => (insertion.type === "insertAfterBlock" || insertion.type === "insertBeforeBlock") && deletion.type === "deleteBlock" && removesParagraphBeforeBlock === true && insertion.blockId === deletion.blockId;
|
|
284
|
-
return pair(left, right) || pair(right, left);
|
|
285
|
-
};
|
|
286
|
-
/** A block operation without the move it names: a plain insertion or deletion. */
|
|
287
|
-
const withoutMove = (operation) => {
|
|
288
|
-
if (operation.type !== "deleteBlock" && operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock") return operation;
|
|
289
|
-
const { moveId: _moveId, ...plain } = operation;
|
|
290
|
-
return plain;
|
|
291
|
-
};
|
|
292
|
-
/** The move a block operation names, if it is a half of one. */
|
|
293
|
-
const blockMoveId = (operation) => operation.type === "deleteBlock" || operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock" ? operation.moveId : void 0;
|
|
294
|
-
/**
|
|
295
|
-
* A line's text with each tab and line break as the element it is; CRLF, CR
|
|
296
|
-
* and LF are each one line break.
|
|
297
|
-
*/
|
|
298
|
-
const inlineText = (line) => line.split(/(\t|\r\n|\r|\n)/u).flatMap((part) => {
|
|
299
|
-
if (part === " ") return [{ type: "tab" }];
|
|
300
|
-
if (LINE_BREAK_PATTERN.test(part)) return [{ type: "break" }];
|
|
301
|
-
return part === "" ? [] : [{
|
|
302
|
-
type: "text",
|
|
303
|
-
text: part
|
|
304
|
-
}];
|
|
305
|
-
});
|
|
306
|
-
const compilePublicIntents = ({ document, intents, mode, author, date, suggestionId, nextRevisionId, allocate, reservedBlockIds }) => {
|
|
307
|
-
const ops = [];
|
|
308
|
-
const revisions = [];
|
|
309
|
-
const allocated = /* @__PURE__ */ new Map();
|
|
310
|
-
for (const sourceIntent of intents) {
|
|
311
|
-
const ids = allocate(document, sourceIntent);
|
|
312
|
-
let intent = sourceIntent;
|
|
313
|
-
if (sourceIntent.type === "splitParagraph") {
|
|
314
|
-
allocated.set(sourceIntent.newBlockId, ids.newBlockId);
|
|
315
|
-
intent = {
|
|
316
|
-
type: "splitParagraph",
|
|
317
|
-
at: sourceIntent.at,
|
|
318
|
-
...sourceIntent.to === void 0 ? {} : { to: sourceIntent.to },
|
|
319
|
-
...sourceIntent.newHalf === void 0 ? {} : { newHalf: sourceIntent.newHalf },
|
|
320
|
-
newBlockId: ids.newBlockId
|
|
321
|
-
};
|
|
322
|
-
} else if (sourceIntent.type === "formatParagraph") {
|
|
323
|
-
const blockId = allocated.get(sourceIntent.at.blockId);
|
|
324
|
-
if (blockId !== void 0) intent = {
|
|
325
|
-
...sourceIntent,
|
|
326
|
-
at: {
|
|
327
|
-
...sourceIntent.at,
|
|
328
|
-
blockId
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
const firstRevisionId = nextRevisionId;
|
|
333
|
-
const compiled = compileEditorIntent(document, {
|
|
334
|
-
intent,
|
|
335
|
-
mode: mode === "direct" ? {
|
|
336
|
-
type: "editing",
|
|
337
|
-
newIds: ids.newIds,
|
|
338
|
-
reservedBlockIds
|
|
339
|
-
} : {
|
|
340
|
-
type: "suggesting",
|
|
341
|
-
reservedBlockIds,
|
|
342
|
-
revision: {
|
|
343
|
-
id: firstRevisionId,
|
|
344
|
-
author,
|
|
345
|
-
date,
|
|
346
|
-
...suggestionId === void 0 ? {} : { suggestionId }
|
|
347
|
-
},
|
|
348
|
-
newIds: {
|
|
349
|
-
control: ids.newIds.control,
|
|
350
|
-
revision: ids.newIds.revision.map((_, index) => firstRevisionId + index + 1)
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
if (compiled.isErr()) return Result.err(compiled.error);
|
|
355
|
-
const applied = applyDocumentOps(document, compiled.value.ops);
|
|
356
|
-
if (applied.isErr()) return Result.err(applied.error);
|
|
357
|
-
document = applied.value.document;
|
|
358
|
-
ops.push(...compiled.value.ops);
|
|
359
|
-
revisions.push(...applied.value.revisions);
|
|
360
|
-
for (const id of applied.value.revisions) nextRevisionId = Math.max(nextRevisionId, id + 1);
|
|
361
|
-
}
|
|
362
|
-
return Result.ok({
|
|
363
|
-
document,
|
|
364
|
-
ops,
|
|
365
|
-
revisions,
|
|
366
|
-
nextRevisionId
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
|
-
const CanonicalPublicOperationResolutionErrorBase = TaggedError("CanonicalPublicOperationResolutionError");
|
|
370
|
-
var CanonicalPublicOperationResolutionError = class extends CanonicalPublicOperationResolutionErrorBase {};
|
|
371
|
-
/**
|
|
372
|
-
* The stated numbering a request names, minting its new list once for the
|
|
373
|
-
* operation, as the default engine allocates one instance per operation.
|
|
374
|
-
*/
|
|
375
|
-
const statedNumbering = (numbering, mint) => {
|
|
376
|
-
if (numbering === void 0) return {};
|
|
377
|
-
if (numbering.kind !== "newList") return { numbering };
|
|
378
|
-
const minted = mint(numbering.format);
|
|
379
|
-
return {
|
|
380
|
-
numbering: paragraphNumberingReference({
|
|
381
|
-
numId: minted.numId,
|
|
382
|
-
ilvl: numbering.level ?? 0
|
|
383
|
-
}),
|
|
384
|
-
newList: minted.newList
|
|
385
|
-
};
|
|
386
|
-
};
|
|
387
|
-
const canonicalPublicStory = (story) => {
|
|
388
|
-
if (story === "main") return story;
|
|
389
|
-
switch (story.type) {
|
|
390
|
-
case "header":
|
|
391
|
-
case "footer": return {
|
|
392
|
-
kind: story.type,
|
|
393
|
-
rId: story.relationshipId
|
|
394
|
-
};
|
|
395
|
-
case "footnote":
|
|
396
|
-
case "endnote": return {
|
|
397
|
-
kind: story.type,
|
|
398
|
-
id: story.noteId
|
|
399
|
-
};
|
|
400
|
-
default: return panic(`Unknown public operation story ${story}`);
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
const batchStatus = (batch, skippedCount) => {
|
|
404
|
-
if (batch.dryRun) return "previewed";
|
|
405
|
-
if (batch.atomic && skippedCount > 0) return "rejected";
|
|
406
|
-
return "committed";
|
|
407
|
-
};
|
|
408
|
-
/** Handles address isolated journal groups; no second document or PM history is retained. */
|
|
409
|
-
var CanonicalPublicOperations = class {
|
|
410
|
-
options;
|
|
411
|
-
handles = [];
|
|
412
|
-
nextHandle = 1;
|
|
413
|
-
handleNamespace = crypto.randomUUID();
|
|
414
|
-
constructor(options) {
|
|
415
|
-
this.options = options;
|
|
416
|
-
}
|
|
417
|
-
apply(options) {
|
|
418
|
-
const { session } = this.options;
|
|
419
|
-
const parsed = parseFolioDocumentOperationBatch(options.batch);
|
|
420
|
-
const batch = parsed.mode !== "suggested" || options.restagesSuggestions === true || session.isComposing ? parsed : withDistinctSuggestionIds(parsed, /* @__PURE__ */ new Set([...pendingSuggestionIdsIn(session.document), ...options.pendingSuggestionIds ?? []]));
|
|
421
|
-
const publicStory = options.story ?? "main";
|
|
422
|
-
const story = canonicalPublicStory(publicStory);
|
|
423
|
-
const state = this.options.getState(story);
|
|
424
|
-
const projected = session.projectStory(story);
|
|
425
|
-
const skipped = [];
|
|
426
|
-
const normalizations = [];
|
|
427
|
-
const refusals = /* @__PURE__ */ new Map();
|
|
428
|
-
const resolved = [];
|
|
429
|
-
const mintList = createBatchListMinter(() => session.document);
|
|
430
|
-
const { diff } = wordDiffSessionFromOptions(options.wordDiff);
|
|
431
|
-
let nextRevisionId = options.revisionStamp?.idSeed ?? 1;
|
|
432
|
-
if (!session.isComposing && options.revisionStamp === void 0) for (const currentStory of documentStories(session.document)) {
|
|
433
|
-
const currentProjection = session.projectStory(currentStory);
|
|
434
|
-
if (currentProjection.isOk()) nextRevisionId = Math.max(nextRevisionId, maxAnnotationIdInDoc(currentProjection.value.doc) + 1);
|
|
435
|
-
}
|
|
436
|
-
const skip = (id, reason, message) => {
|
|
437
|
-
skipped.push({
|
|
438
|
-
id,
|
|
439
|
-
reason,
|
|
440
|
-
...message === void 0 ? {} : { message }
|
|
441
|
-
});
|
|
442
|
-
};
|
|
443
|
-
const result = (applied, undoHandle) => {
|
|
444
|
-
const failures = new Map(skipped.map((item) => [item.id, item]));
|
|
445
|
-
const ordered = batch.operations.flatMap(({ id }) => {
|
|
446
|
-
const failure = failures.get(id);
|
|
447
|
-
if (!failure) return [];
|
|
448
|
-
const canonicalRefusal = refusals.get(id);
|
|
449
|
-
return [canonicalRefusal ? {
|
|
450
|
-
...failure,
|
|
451
|
-
canonicalRefusal
|
|
452
|
-
} : failure];
|
|
453
|
-
});
|
|
454
|
-
return {
|
|
455
|
-
version: 1,
|
|
456
|
-
status: batchStatus(batch, ordered.length),
|
|
457
|
-
applied,
|
|
458
|
-
skipped: ordered,
|
|
459
|
-
issues: getFolioDocumentOperationIssues(batch.operations, ordered),
|
|
460
|
-
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
461
|
-
operations: batch.operations,
|
|
462
|
-
applied,
|
|
463
|
-
story: publicStory
|
|
464
|
-
}),
|
|
465
|
-
undoHandle,
|
|
466
|
-
nextRevisionId,
|
|
467
|
-
...normalizations.length === 0 ? {} : { normalizations }
|
|
468
|
-
};
|
|
469
|
-
};
|
|
470
|
-
const besideDeletions = {
|
|
471
|
-
deleted: new Set(batch.operations.flatMap((operation) => operation.type === "deleteBlock" ? [operation.blockId] : [])),
|
|
472
|
-
insertedBeside: new Set(batch.operations.flatMap((operation) => operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock" ? [operation.blockId] : []))
|
|
473
|
-
};
|
|
474
|
-
const overlapsResolved = (candidate) => resolved.some((earlier) => earlier !== candidate && !besideItsDeletion(earlier, candidate) && (candidate.from < earlier.to && candidate.to > earlier.from || earlier.from === earlier.to && candidate.from <= earlier.from && candidate.to >= earlier.from || candidate.from === candidate.to && candidate.from >= earlier.from && candidate.from <= earlier.to));
|
|
475
|
-
for (const operation of batch.operations) {
|
|
476
|
-
if (!state || projected.isErr() || session.isComposing) {
|
|
477
|
-
skip(operation.id, "documentNotEditable");
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
if (batch.mode === "suggested" && !CANONICAL_SUGGESTED_OPERATION_TYPES.has(operation.type)) {
|
|
481
|
-
skip(operation.id, "unsupportedMode");
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
if (options.tableTemplates !== void 0 || options.undefinedReferences === "keep") {
|
|
485
|
-
refusals.set(operation.id, { gap: CANONICAL_GAP.publicUnsupportedInline });
|
|
486
|
-
skip(operation.id, "unsupportedBlock", "This canonical compiler does not support the supplied execution options.");
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
const disposition = CANONICAL_PUBLIC_OPERATION_DISPOSITIONS[operation.type];
|
|
490
|
-
if (disposition !== "compile") {
|
|
491
|
-
refusals.set(operation.id, { gap: disposition });
|
|
492
|
-
skip(operation.id, "unsupportedBlock");
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
const compiled = this.resolve({
|
|
496
|
-
operation,
|
|
497
|
-
options,
|
|
498
|
-
state,
|
|
499
|
-
story,
|
|
500
|
-
diff,
|
|
501
|
-
tracked: batch.mode !== "direct",
|
|
502
|
-
mintList,
|
|
503
|
-
besideDeletions
|
|
504
|
-
});
|
|
505
|
-
if (compiled.isErr()) {
|
|
506
|
-
if (compiled.error.reason === "unsupportedBlock") refusals.set(operation.id, { gap: CANONICAL_GAP.publicUnsupportedInline });
|
|
507
|
-
skip(operation.id, compiled.error.reason, compiled.error.message);
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
if (overlapsResolved(compiled.value)) {
|
|
511
|
-
skip(operation.id, "overlappingOperation");
|
|
512
|
-
continue;
|
|
513
|
-
}
|
|
514
|
-
resolved.push(compiled.value);
|
|
515
|
-
}
|
|
516
|
-
for (const item of [...resolved]) {
|
|
517
|
-
if (item.besideDeletion !== true || !state) continue;
|
|
518
|
-
const { operation } = item;
|
|
519
|
-
if (operation.type !== "deleteBlock" && operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock") continue;
|
|
520
|
-
if (resolved.some(({ operation: other }) => operation.type === "deleteBlock" ? (other.type === "insertAfterBlock" || other.type === "insertBeforeBlock") && other.blockId === operation.blockId : other.type === "deleteBlock" && other.blockId === operation.blockId)) continue;
|
|
521
|
-
resolved.splice(resolved.indexOf(item), 1);
|
|
522
|
-
const alone = this.resolve({
|
|
523
|
-
operation,
|
|
524
|
-
options,
|
|
525
|
-
state,
|
|
526
|
-
story,
|
|
527
|
-
diff,
|
|
528
|
-
tracked: batch.mode !== "direct",
|
|
529
|
-
mintList,
|
|
530
|
-
besideDeletions: {
|
|
531
|
-
deleted: /* @__PURE__ */ new Set(),
|
|
532
|
-
insertedBeside: /* @__PURE__ */ new Set()
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
if (alone.isErr()) {
|
|
536
|
-
skip(operation.id, alone.error.reason, alone.error.message);
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
if (overlapsResolved(alone.value)) {
|
|
540
|
-
skip(operation.id, "overlappingOperation");
|
|
541
|
-
continue;
|
|
542
|
-
}
|
|
543
|
-
resolved.push(alone.value);
|
|
544
|
-
}
|
|
545
|
-
const moveSides = /* @__PURE__ */ new Map();
|
|
546
|
-
for (const { operation } of resolved) {
|
|
547
|
-
const moveId = blockMoveId(operation);
|
|
548
|
-
if (moveId === void 0) continue;
|
|
549
|
-
const sides = moveSides.get(moveId) ?? {
|
|
550
|
-
from: 0,
|
|
551
|
-
to: 0
|
|
552
|
-
};
|
|
553
|
-
if (operation.type === "deleteBlock") sides.from += 1;
|
|
554
|
-
else sides.to += 1;
|
|
555
|
-
moveSides.set(moveId, sides);
|
|
556
|
-
}
|
|
557
|
-
const unpairable = new Set(batch.mode === "suggested" ? resolved.flatMap(({ operation }) => operation.type === "insertBeforeBlock" && operation.moveId !== void 0 && resolved.some((candidate) => candidate.operation.type === "deleteBlock" && candidate.operation.moveId === operation.moveId && candidate.operation.blockId === operation.blockId) ? [operation.moveId] : []) : []);
|
|
558
|
-
const paired = (moveId) => !unpairable.has(moveId) && moveSides.get(moveId)?.from === 1 && moveSides.get(moveId)?.to === 1;
|
|
559
|
-
const pairedMoves = /* @__PURE__ */ new Set();
|
|
560
|
-
for (const [index, item] of resolved.entries()) {
|
|
561
|
-
const moveId = blockMoveId(item.operation);
|
|
562
|
-
if (moveId === void 0) continue;
|
|
563
|
-
if (!paired(moveId)) {
|
|
564
|
-
normalizations.push({
|
|
565
|
-
id: item.operation.id,
|
|
566
|
-
code: "unpairedMove",
|
|
567
|
-
moveId
|
|
568
|
-
});
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
pairedMoves.add(moveId);
|
|
572
|
-
const intents = [];
|
|
573
|
-
for (const intent of item.intents) intents.push(intent.type === "insertParagraphs" || intent.type === "deleteParagraphs" ? Object.assign({}, intent, { move: true }) : intent);
|
|
574
|
-
resolved[index] = {
|
|
575
|
-
...item,
|
|
576
|
-
intents
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
if (batch.atomic && skipped.length > 0) {
|
|
580
|
-
for (const { operation } of resolved) skip(operation.id, "atomicBatchRejected");
|
|
581
|
-
return result([], null);
|
|
582
|
-
}
|
|
583
|
-
if (!state || projected.isErr() || session.isComposing) return result([], null);
|
|
584
|
-
resolved.sort((left, right) => right.from - left.from || left.to - left.from - (right.to - right.from));
|
|
585
|
-
let document = session.document;
|
|
586
|
-
const ops = [];
|
|
587
|
-
const appliedById = /* @__PURE__ */ new Map();
|
|
588
|
-
const allocate = createEditorIntentIdAllocator({ reservedBlockIds: session.reservedBlockIds });
|
|
589
|
-
const date = options.revisionStamp?.date ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
590
|
-
for (const resolvedOperation of resolved) {
|
|
591
|
-
const { operation, intents, normalizations: adjustments } = resolvedOperation;
|
|
592
|
-
const suggestionId = batch.mode === "suggested" ? ("suggestionId" in operation ? operation.suggestionId : void 0) ?? operation.id : void 0;
|
|
593
|
-
const compiled = compilePublicIntents({
|
|
594
|
-
document,
|
|
595
|
-
intents,
|
|
596
|
-
allocate,
|
|
597
|
-
reservedBlockIds: session.reservedBlockIds,
|
|
598
|
-
nextRevisionId,
|
|
599
|
-
mode: batch.mode === "direct" ? "direct" : "tracked-changes",
|
|
600
|
-
suggestionId,
|
|
601
|
-
author: options.author ?? "AI",
|
|
602
|
-
date
|
|
603
|
-
});
|
|
604
|
-
if (compiled.isErr()) {
|
|
605
|
-
refusals.set(operation.id, { gap: CANONICAL_GAP.publicUnsupportedInline });
|
|
606
|
-
skip(operation.id, "unsupportedBlock", compiled.error.message);
|
|
607
|
-
continue;
|
|
608
|
-
}
|
|
609
|
-
let nextDocument = compiled.value.document;
|
|
610
|
-
const operationOps = [...compiled.value.ops];
|
|
611
|
-
let commentId;
|
|
612
|
-
switch (resolvedOperation.type) {
|
|
613
|
-
case "plain": break;
|
|
614
|
-
case "commented": {
|
|
615
|
-
const { comment } = resolvedOperation;
|
|
616
|
-
const id = freshCommentId(nextDocument);
|
|
617
|
-
const proposedBy = suggestionId === void 0 ? {} : { suggestionId };
|
|
618
|
-
if (comment.inserted === true) {
|
|
619
|
-
const paragraphsIn = (current) => {
|
|
620
|
-
const body = findStoryBody(current, story);
|
|
621
|
-
return body === void 0 ? [] : storyParagraphs(body).map(({ paragraph }) => paragraph);
|
|
622
|
-
};
|
|
623
|
-
const known = new Set(paragraphsIn(document).flatMap(({ paraId }) => paraId === void 0 ? [] : [paraId]));
|
|
624
|
-
const added = paragraphsIn(nextDocument).filter(({ paraId }) => paraId !== void 0 && !known.has(paraId));
|
|
625
|
-
const firstAdded = added.at(0);
|
|
626
|
-
const lastAdded = added.at(-1);
|
|
627
|
-
const commented = id.isErr() || firstAdded?.paraId === void 0 || lastAdded?.paraId === void 0 ? void 0 : compileCanonicalComments({
|
|
628
|
-
document: nextDocument,
|
|
629
|
-
command: {
|
|
630
|
-
type: "create",
|
|
631
|
-
comment: {
|
|
632
|
-
id: id.value,
|
|
633
|
-
author: options.author ?? "AI",
|
|
634
|
-
date,
|
|
635
|
-
done: false,
|
|
636
|
-
content: canonicalCommentBody(nextDocument, comment.text),
|
|
637
|
-
...proposedBy
|
|
638
|
-
},
|
|
639
|
-
anchor: {
|
|
640
|
-
kind: "range",
|
|
641
|
-
from: {
|
|
642
|
-
story,
|
|
643
|
-
blockId: firstAdded.paraId,
|
|
644
|
-
offset: 0
|
|
645
|
-
},
|
|
646
|
-
to: {
|
|
647
|
-
story,
|
|
648
|
-
blockId: lastAdded.paraId,
|
|
649
|
-
offset: paragraphLength(lastAdded)
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
if (commented === void 0 || commented.isErr() || id.isErr()) {
|
|
655
|
-
refusals.set(operation.id, { gap: CANONICAL_GAP.publicComments });
|
|
656
|
-
skip(operation.id, "unsupportedBlock", commented?.isErr() === true ? commented.error.message : "The inserted paragraphs cannot carry the comment.");
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
nextDocument = commented.value.document;
|
|
660
|
-
operationOps.push(...commented.value.ops);
|
|
661
|
-
commentId = id.value;
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
const anchorIn = (current) => {
|
|
665
|
-
const body = findStoryBody(current, story);
|
|
666
|
-
return body === void 0 ? void 0 : storyParagraphs(body).find(({ paragraph }) => paragraph.paraId === comment.from.blockId)?.paragraph;
|
|
667
|
-
};
|
|
668
|
-
const before = anchorIn(document);
|
|
669
|
-
const after = anchorIn(nextDocument);
|
|
670
|
-
if (id.isErr() || before === void 0 || after === void 0) {
|
|
671
|
-
refusals.set(operation.id, { gap: CANONICAL_GAP.publicComments });
|
|
672
|
-
skip(operation.id, "unsupportedBlock", id.isErr() ? id.error.message : "The comment anchor no longer exists.");
|
|
673
|
-
continue;
|
|
674
|
-
}
|
|
675
|
-
const changed = batch.mode === "direct" ? void 0 : revisionSpan(after.content, new Set(compiled.value.revisions));
|
|
676
|
-
const from = changed === void 0 ? comment.from : {
|
|
677
|
-
story: comment.from.story,
|
|
678
|
-
blockId: comment.from.blockId,
|
|
679
|
-
offset: changed.from
|
|
680
|
-
};
|
|
681
|
-
const to = changed === void 0 ? {
|
|
682
|
-
...comment.to,
|
|
683
|
-
offset: comment.to.offset + paragraphLength(after) - paragraphLength(before)
|
|
684
|
-
} : {
|
|
685
|
-
story: comment.from.story,
|
|
686
|
-
blockId: comment.from.blockId,
|
|
687
|
-
offset: changed.to
|
|
688
|
-
};
|
|
689
|
-
const commented = compileCanonicalComments({
|
|
690
|
-
document: nextDocument,
|
|
691
|
-
command: {
|
|
692
|
-
type: "create",
|
|
693
|
-
comment: {
|
|
694
|
-
id: id.value,
|
|
695
|
-
author: options.author ?? "AI",
|
|
696
|
-
date,
|
|
697
|
-
done: false,
|
|
698
|
-
content: canonicalCommentBody(nextDocument, comment.text),
|
|
699
|
-
...proposedBy
|
|
700
|
-
},
|
|
701
|
-
anchor: to.offset === from.offset ? {
|
|
702
|
-
kind: "point",
|
|
703
|
-
at: from
|
|
704
|
-
} : {
|
|
705
|
-
kind: "range",
|
|
706
|
-
from,
|
|
707
|
-
to
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
if (commented.isErr()) {
|
|
712
|
-
refusals.set(operation.id, { gap: CANONICAL_GAP.publicComments });
|
|
713
|
-
skip(operation.id, "unsupportedBlock", commented.error.message);
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
nextDocument = commented.value.document;
|
|
717
|
-
operationOps.push(...commented.value.ops);
|
|
718
|
-
commentId = id.value;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
default: panic(`Unknown resolved operation ${resolvedOperation}`);
|
|
722
|
-
}
|
|
723
|
-
if (operationOps.length === 0) {
|
|
724
|
-
skip(operation.id, "noopOperation");
|
|
725
|
-
continue;
|
|
726
|
-
}
|
|
727
|
-
const locked = lockViolationBetween(document, nextDocument);
|
|
728
|
-
if (locked !== null) {
|
|
729
|
-
skip(operation.id, CONTENT_CONTROL_LOCK, `Refused: ${lockedControlMessage(locked)}`);
|
|
730
|
-
continue;
|
|
731
|
-
}
|
|
732
|
-
normalizations.push(...adjustments);
|
|
733
|
-
document = nextDocument;
|
|
734
|
-
ops.push(...operationOps);
|
|
735
|
-
nextRevisionId = Math.max(compiled.value.nextRevisionId, (commentId ?? -1) + 1);
|
|
736
|
-
const revisionIds = compiled.value.revisions;
|
|
737
|
-
const revisionId = revisionIds.at(0);
|
|
738
|
-
appliedById.set(operation.id, {
|
|
739
|
-
id: operation.id,
|
|
740
|
-
...commentId === void 0 ? {} : { commentId },
|
|
741
|
-
...revisionId === void 0 ? {} : {
|
|
742
|
-
revisionId,
|
|
743
|
-
revisionIds
|
|
744
|
-
},
|
|
745
|
-
...suggestionId === void 0 ? {} : { suggestionId }
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
const applyingHalves = /* @__PURE__ */ new Map();
|
|
749
|
-
for (const { operation } of resolved) {
|
|
750
|
-
const moveId = blockMoveId(operation);
|
|
751
|
-
if (moveId !== void 0 && appliedById.has(operation.id)) applyingHalves.set(moveId, (applyingHalves.get(moveId) ?? 0) + 1);
|
|
752
|
-
}
|
|
753
|
-
const orphaned = new Set([...pairedMoves].filter((moveId) => applyingHalves.get(moveId) === 1));
|
|
754
|
-
if (orphaned.size > 0) {
|
|
755
|
-
const orphanedMove = (operation) => {
|
|
756
|
-
const moveId = blockMoveId(operation);
|
|
757
|
-
return moveId !== void 0 && orphaned.has(moveId);
|
|
758
|
-
};
|
|
759
|
-
const plain = this.apply({
|
|
760
|
-
...options,
|
|
761
|
-
batch: {
|
|
762
|
-
...batch,
|
|
763
|
-
operations: batch.operations.map((operation) => orphanedMove(operation) ? withoutMove(operation) : operation)
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
const appliedIds = new Set(plain.applied.map(({ id }) => id));
|
|
767
|
-
return {
|
|
768
|
-
...plain,
|
|
769
|
-
normalizations: [...plain.normalizations ?? [], ...batch.operations.flatMap((operation) => {
|
|
770
|
-
const moveId = blockMoveId(operation);
|
|
771
|
-
return moveId !== void 0 && orphaned.has(moveId) && appliedIds.has(operation.id) ? [{
|
|
772
|
-
id: operation.id,
|
|
773
|
-
code: "unpairedMove",
|
|
774
|
-
moveId
|
|
775
|
-
}] : [];
|
|
776
|
-
})]
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
if (batch.atomic && skipped.length > 0) {
|
|
780
|
-
for (const { id } of appliedById.values()) skip(id, "atomicBatchRejected");
|
|
781
|
-
return result([], null);
|
|
782
|
-
}
|
|
783
|
-
if (ops.length === 0) return result([], null);
|
|
784
|
-
const selection = projected.value.selectionAt(state);
|
|
785
|
-
const prepared = selection.isErr() ? selection : session.prepareOps(state, ops, selection.value);
|
|
786
|
-
if (prepared.isErr()) {
|
|
787
|
-
for (const { id } of appliedById.values()) {
|
|
788
|
-
refusals.set(id, { gap: CANONICAL_GAP.publicUnsupportedInline });
|
|
789
|
-
skip(id, prepared.error.reason === "noChange" ? "noopOperation" : "unsupportedBlock", prepared.error.message);
|
|
790
|
-
}
|
|
791
|
-
return result([], null);
|
|
792
|
-
}
|
|
793
|
-
const applied = batch.operations.flatMap(({ id }) => {
|
|
794
|
-
const entry = appliedById.get(id);
|
|
795
|
-
return entry ? [batch.dryRun ? { id } : entry] : [];
|
|
796
|
-
});
|
|
797
|
-
if (batch.dryRun) return result(applied, null);
|
|
798
|
-
if (!this.options.publish(prepared.value)) {
|
|
799
|
-
for (const { id } of applied) skip(id, "documentNotEditable");
|
|
800
|
-
return result([], null);
|
|
801
|
-
}
|
|
802
|
-
const handle = {
|
|
803
|
-
type: "documentOperationUndo",
|
|
804
|
-
id: `canonical-${this.handleNamespace}-${String(this.nextHandle++)}`
|
|
805
|
-
};
|
|
806
|
-
this.handles.push({
|
|
807
|
-
handle,
|
|
808
|
-
version: session.version,
|
|
809
|
-
story
|
|
810
|
-
});
|
|
811
|
-
return result(applied, handle);
|
|
812
|
-
}
|
|
813
|
-
undo(handle) {
|
|
814
|
-
const index = this.handles.findIndex(({ handle: existing }) => existing.id === handle.id && existing.type === handle.type);
|
|
815
|
-
if (index < 0) return {
|
|
816
|
-
status: "rejected",
|
|
817
|
-
undoHandle: handle,
|
|
818
|
-
reason: "unknownHandle"
|
|
819
|
-
};
|
|
820
|
-
if (index !== this.handles.length - 1) return {
|
|
821
|
-
status: "rejected",
|
|
822
|
-
undoHandle: handle,
|
|
823
|
-
reason: "notLatest"
|
|
824
|
-
};
|
|
825
|
-
const entry = this.handles.at(-1);
|
|
826
|
-
const { session } = this.options;
|
|
827
|
-
if (!entry || entry.version !== session.version) return {
|
|
828
|
-
status: "rejected",
|
|
829
|
-
undoHandle: handle,
|
|
830
|
-
reason: "documentChanged"
|
|
831
|
-
};
|
|
832
|
-
const state = this.options.getState(entry.story);
|
|
833
|
-
if (!state) return {
|
|
834
|
-
status: "rejected",
|
|
835
|
-
undoHandle: handle,
|
|
836
|
-
reason: "documentChanged"
|
|
837
|
-
};
|
|
838
|
-
const prepared = session.prepareUndo(state, entry.story);
|
|
839
|
-
if (prepared.isErr() || !this.options.publish(prepared.value)) return {
|
|
840
|
-
status: "rejected",
|
|
841
|
-
undoHandle: handle,
|
|
842
|
-
reason: "documentChanged"
|
|
843
|
-
};
|
|
844
|
-
this.handles.pop();
|
|
845
|
-
const previous = this.handles.at(-1);
|
|
846
|
-
if (previous && previous.version === entry.version - 1) previous.version = session.version;
|
|
847
|
-
return {
|
|
848
|
-
status: "undone",
|
|
849
|
-
undoHandle: handle
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* A whole paragraph removed as the editor removes a selection of it with
|
|
854
|
-
* its paragraph mark: from its start to the start of the paragraph after
|
|
855
|
-
* it, or, for the paragraph that ends its block list, from the end of the
|
|
856
|
-
* paragraph before it, whose mark then ends the list. Tracked, the text and
|
|
857
|
-
* the mark are marked deleted.
|
|
858
|
-
*/
|
|
859
|
-
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, gainsFollower, refusal }) {
|
|
860
|
-
if (operation.comment !== void 0 && !tracked) return refusal("unsupportedBlock");
|
|
861
|
-
const end = paragraph.start + paragraph.node.content.size;
|
|
862
|
-
const after = doc.resolve(end + 1).nodeAfter;
|
|
863
|
-
const before = doc.resolve(paragraph.start - 1).nodeBefore;
|
|
864
|
-
const neighbour = (node) => {
|
|
865
|
-
const id = node?.attrs["paraId"];
|
|
866
|
-
return node?.type.name === "paragraph" && typeof id === "string" ? projection.paragraph(id) : void 0;
|
|
867
|
-
};
|
|
868
|
-
const next = neighbour(after);
|
|
869
|
-
const previous = neighbour(before);
|
|
870
|
-
const commentFrom = projection.addressAt(paragraph.start);
|
|
871
|
-
const commentTo = projection.addressAt(end);
|
|
872
|
-
if (commentFrom.isErr() || commentTo.isErr()) return refusal("unsupportedBlock");
|
|
873
|
-
const tracking = (resolved) => Result.ok(operation.comment === void 0 ? {
|
|
874
|
-
type: "plain",
|
|
875
|
-
operation,
|
|
876
|
-
...resolved
|
|
877
|
-
} : {
|
|
878
|
-
type: "commented",
|
|
879
|
-
operation,
|
|
880
|
-
comment: {
|
|
881
|
-
text: operation.comment.text,
|
|
882
|
-
from: commentFrom.value,
|
|
883
|
-
to: commentTo.value
|
|
884
|
-
},
|
|
885
|
-
...resolved
|
|
886
|
-
});
|
|
887
|
-
if (next !== void 0 || gainsFollower || tracked && (after !== null || operation.moveId !== void 0)) return tracking({
|
|
888
|
-
intents: [{
|
|
889
|
-
type: "deleteParagraphs",
|
|
890
|
-
story: projectionStory,
|
|
891
|
-
blockIds: [paragraph.blockId]
|
|
892
|
-
}],
|
|
893
|
-
normalizations: [],
|
|
894
|
-
from: paragraph.start,
|
|
895
|
-
to: end,
|
|
896
|
-
...after === null && !gainsFollower ? {} : { removesParagraphBeforeBlock: true }
|
|
897
|
-
});
|
|
898
|
-
let range;
|
|
899
|
-
if (!tracked) {
|
|
900
|
-
const own = (from, to) => {
|
|
901
|
-
const start = projection.addressAt(from);
|
|
902
|
-
const stop = projection.addressAt(to);
|
|
903
|
-
return start.isErr() || stop.isErr() ? refusal("unsupportedBlock") : Result.ok(from === to ? [] : [{
|
|
904
|
-
type: "replaceText",
|
|
905
|
-
from: start.value,
|
|
906
|
-
to: stop.value,
|
|
907
|
-
text: ""
|
|
908
|
-
}]);
|
|
909
|
-
};
|
|
910
|
-
const cleared = own(paragraph.start, end);
|
|
911
|
-
if (cleared.isErr()) return cleared;
|
|
912
|
-
const intents = [...cleared.value];
|
|
913
|
-
if (previous !== void 0) intents.push({
|
|
914
|
-
type: "joinParagraphs",
|
|
915
|
-
story: projectionStory,
|
|
916
|
-
blockId: previous.blockId,
|
|
917
|
-
nextBlockId: paragraph.blockId,
|
|
918
|
-
survivor: "first"
|
|
919
|
-
});
|
|
920
|
-
if (intents.length === 0) return refusal("noopOperation");
|
|
921
|
-
return Result.ok({
|
|
922
|
-
type: "plain",
|
|
923
|
-
operation,
|
|
924
|
-
intents,
|
|
925
|
-
normalizations: [],
|
|
926
|
-
from: previous === void 0 ? paragraph.start : previous.start,
|
|
927
|
-
to: end
|
|
928
|
-
});
|
|
929
|
-
} else if (previous !== void 0) range = {
|
|
930
|
-
from: previous.start + previous.node.content.size,
|
|
931
|
-
to: end
|
|
932
|
-
};
|
|
933
|
-
if (range === void 0) return refusal("unsupportedBlock", "Canonical deletion of the only paragraph in its container is unavailable.");
|
|
934
|
-
const from = projection.addressAt(range.from);
|
|
935
|
-
const to = projection.addressAt(range.to);
|
|
936
|
-
if (from.isErr() || to.isErr()) return refusal("unsupportedBlock");
|
|
937
|
-
return tracking({
|
|
938
|
-
intents: [{
|
|
939
|
-
type: "replaceText",
|
|
940
|
-
from: from.value,
|
|
941
|
-
to: to.value,
|
|
942
|
-
text: ""
|
|
943
|
-
}],
|
|
944
|
-
normalizations: [],
|
|
945
|
-
from: Math.min(range.from, paragraph.start),
|
|
946
|
-
to: Math.max(range.to, end)
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
resolve({ operation, options, state, story, diff, tracked, mintList, besideDeletions }) {
|
|
950
|
-
const refusal = (reason, message) => Result.err(new CanonicalPublicOperationResolutionError({
|
|
951
|
-
reason,
|
|
952
|
-
message: message ?? `The operation was refused: ${reason}.`
|
|
953
|
-
}));
|
|
954
|
-
switch (operation.type) {
|
|
955
|
-
case "replaceInBlock":
|
|
956
|
-
case "replaceRange":
|
|
957
|
-
case "replaceBlock":
|
|
958
|
-
case "splitBlock":
|
|
959
|
-
case "formatRange":
|
|
960
|
-
case "mergeBlockWithNext":
|
|
961
|
-
case "commentOnRange":
|
|
962
|
-
case "commentOnBlock":
|
|
963
|
-
case "deleteBlock":
|
|
964
|
-
case "setBlockParagraphProperties":
|
|
965
|
-
case "insertAfterBlock":
|
|
966
|
-
case "insertBeforeBlock": break;
|
|
967
|
-
default: return refusal("unsupportedBlock", `Canonical public operation ${operation.type} is unavailable.`);
|
|
968
|
-
}
|
|
969
|
-
const blockId = operation.type === "replaceRange" || operation.type === "formatRange" || operation.type === "commentOnRange" ? operation.range.blockId : operation.blockId;
|
|
970
|
-
const anchor = Object.hasOwn(options.snapshot.anchors, blockId) ? options.snapshot.anchors[blockId] : void 0;
|
|
971
|
-
const projection = this.options.session.projectStory(story);
|
|
972
|
-
if (!anchor || projection.isErr()) return refusal("missingBlock");
|
|
973
|
-
const paragraph = projection.value.paragraph(blockId);
|
|
974
|
-
if (!paragraph) return refusal("missingBlock");
|
|
975
|
-
if (paragraph.source.pPrMark?.kind === "del" || paragraph.source.pPrMark?.kind === "moveFrom") return refusal("pendingDeletion");
|
|
976
|
-
const clean = buildCleanBlockText(paragraph.node, paragraph.start - 1, {
|
|
977
|
-
fieldResults: "text",
|
|
978
|
-
noteReferences: collectNoteReferenceLabels(state.doc)
|
|
979
|
-
});
|
|
980
|
-
const hash = hashFolioAIBlockContent(clean.text);
|
|
981
|
-
if (operation.precondition && hash !== operation.precondition.blockTextHash) return refusal("preconditionFailed");
|
|
982
|
-
if (hash !== anchor.textHash) return refusal("changedBlock");
|
|
983
|
-
const followed = state.doc.resolve(paragraph.start + paragraph.node.content.size + 1).nodeAfter?.type.name === "paragraph";
|
|
984
|
-
if (isBlockInsertion(operation)) {
|
|
985
|
-
const besideDeletion = !tracked && operation.type === "insertBeforeBlock" && !followed && besideDeletions.deleted.has(blockId);
|
|
986
|
-
const inserted = resolveBlockInsertion({
|
|
987
|
-
operation: besideDeletion ? {
|
|
988
|
-
...operation,
|
|
989
|
-
type: "insertAfterBlock"
|
|
990
|
-
} : operation,
|
|
991
|
-
paragraph,
|
|
992
|
-
projection: projection.value,
|
|
993
|
-
story,
|
|
994
|
-
mintList,
|
|
995
|
-
refusal
|
|
996
|
-
});
|
|
997
|
-
return besideDeletion && inserted.isOk() ? Result.ok({
|
|
998
|
-
...inserted.value,
|
|
999
|
-
besideDeletion: true
|
|
1000
|
-
}) : inserted;
|
|
1001
|
-
}
|
|
1002
|
-
if (operation.type === "setBlockParagraphProperties") return resolveParagraphProperties({
|
|
1003
|
-
operation,
|
|
1004
|
-
paragraph,
|
|
1005
|
-
projection: projection.value,
|
|
1006
|
-
mintList,
|
|
1007
|
-
refusal
|
|
1008
|
-
});
|
|
1009
|
-
if (operation.type === "deleteBlock") {
|
|
1010
|
-
const gainsFollower = !followed && besideDeletions.insertedBeside.has(blockId);
|
|
1011
|
-
const deleted = this.resolveBlockDeletion({
|
|
1012
|
-
operation,
|
|
1013
|
-
paragraph,
|
|
1014
|
-
projection: projection.value,
|
|
1015
|
-
projectionStory: story,
|
|
1016
|
-
doc: state.doc,
|
|
1017
|
-
tracked,
|
|
1018
|
-
gainsFollower,
|
|
1019
|
-
refusal
|
|
1020
|
-
});
|
|
1021
|
-
return gainsFollower && deleted.isOk() ? Result.ok({
|
|
1022
|
-
...deleted.value,
|
|
1023
|
-
besideDeletion: true
|
|
1024
|
-
}) : deleted;
|
|
1025
|
-
}
|
|
1026
|
-
let start = 0;
|
|
1027
|
-
let end = clean.text.length;
|
|
1028
|
-
let text = "";
|
|
1029
|
-
switch (operation.type) {
|
|
1030
|
-
case "replaceInBlock":
|
|
1031
|
-
if (operation.find === "") return refusal("emptyOperation");
|
|
1032
|
-
start = clean.text.indexOf(operation.find);
|
|
1033
|
-
if (start < 0) return refusal("missingFind");
|
|
1034
|
-
if (clean.text.indexOf(operation.find, start + 1) >= 0) return refusal("ambiguousFind");
|
|
1035
|
-
end = start + operation.find.length;
|
|
1036
|
-
text = operation.replace;
|
|
1037
|
-
break;
|
|
1038
|
-
case "commentOnBlock":
|
|
1039
|
-
if (operation.quote !== void 0) {
|
|
1040
|
-
start = clean.text.indexOf(operation.quote);
|
|
1041
|
-
if (start < 0) return refusal("missingFind");
|
|
1042
|
-
if (clean.text.indexOf(operation.quote, start + 1) >= 0) return refusal("ambiguousFind");
|
|
1043
|
-
end = start + operation.quote.length;
|
|
1044
|
-
}
|
|
1045
|
-
break;
|
|
1046
|
-
case "replaceRange":
|
|
1047
|
-
case "formatRange":
|
|
1048
|
-
case "commentOnRange":
|
|
1049
|
-
start = operation.range.startOffset;
|
|
1050
|
-
end = operation.range.endOffset;
|
|
1051
|
-
if (hashFolioAIBlockText(clean.text.slice(start, end)) !== operation.range.selectedTextHash) return refusal("staleRange");
|
|
1052
|
-
text = operation.type === "replaceRange" ? operation.replace : "";
|
|
1053
|
-
break;
|
|
1054
|
-
case "replaceBlock":
|
|
1055
|
-
if (operation.styleId !== void 0 || operation.preserveFormatting === false) return refusal("unsupportedBlock", "Canonical replacement paragraph properties are unavailable.");
|
|
1056
|
-
text = operation.text;
|
|
1057
|
-
break;
|
|
1058
|
-
case "splitBlock":
|
|
1059
|
-
start = operation.offset;
|
|
1060
|
-
end = start + (operation.separator?.length ?? 0);
|
|
1061
|
-
if (start <= 0 || start >= clean.text.length || clean.text.slice(start, end) !== (operation.separator ?? "")) return refusal("staleRange");
|
|
1062
|
-
break;
|
|
1063
|
-
case "mergeBlockWithNext":
|
|
1064
|
-
if (/[\t\r\n]/u.test(operation.separator ?? "")) return refusal("unsupportedBlock", "Canonical public join separators require plain text.");
|
|
1065
|
-
start = clean.text.length;
|
|
1066
|
-
end = start;
|
|
1067
|
-
break;
|
|
1068
|
-
default: return operation;
|
|
1069
|
-
}
|
|
1070
|
-
if ([start, end].some((offset) => splitsSurrogatePair(clean.text, offset) || splitsGraphemeCluster(clean.text, offset))) return refusal("splitsCharacter");
|
|
1071
|
-
if (clean.structuralBoundaries.some((boundary) => boundary.type === "noteReference" && start < boundary.offset + boundary.length && end > boundary.offset)) return refusal("protectedReference");
|
|
1072
|
-
if (stripInlineEmphasisMarkers(text) !== text) return refusal("unsupportedBlock", "Canonical public emphasis replacements are unavailable.");
|
|
1073
|
-
if (/\[\^(?:e)?\d+\]/u.test(text) || /[\t\r\n]/u.test(text)) return refusal("unsupportedBlock", "Canonical public replacements require plain text.");
|
|
1074
|
-
const range = resolveCleanTextRange({
|
|
1075
|
-
cleanBlock: clean,
|
|
1076
|
-
startOffset: start,
|
|
1077
|
-
endOffset: end
|
|
1078
|
-
});
|
|
1079
|
-
if (!range) return refusal("staleRange");
|
|
1080
|
-
const from = projection.value.addressAt(range.from);
|
|
1081
|
-
const to = projection.value.addressAt(range.to);
|
|
1082
|
-
if (from.isErr() || to.isErr()) return refusal("unsupportedBlock");
|
|
1083
|
-
const resolvedComment = resolveComment({
|
|
1084
|
-
operation,
|
|
1085
|
-
from: from.value,
|
|
1086
|
-
to: to.value
|
|
1087
|
-
});
|
|
1088
|
-
if (operation.type === "commentOnBlock" || operation.type === "commentOnRange") return Result.ok({
|
|
1089
|
-
...resolvedComment,
|
|
1090
|
-
intents: [],
|
|
1091
|
-
normalizations: [],
|
|
1092
|
-
from: range.from,
|
|
1093
|
-
to: range.to
|
|
1094
|
-
});
|
|
1095
|
-
if (resolvedComment.type === "plain" && operation.type !== "splitBlock" && operation.type !== "formatRange" && operation.type !== "mergeBlockWithNext" && clean.text.slice(start, end) === text) return refusal("noopOperation");
|
|
1096
|
-
let intent;
|
|
1097
|
-
switch (operation.type) {
|
|
1098
|
-
case "splitBlock":
|
|
1099
|
-
intent = {
|
|
1100
|
-
type: "splitParagraph",
|
|
1101
|
-
at: from.value,
|
|
1102
|
-
to: to.value,
|
|
1103
|
-
newHalf: "second",
|
|
1104
|
-
newBlockId: createEditorIntentIdAllocator({ reservedBlockIds: this.options.session.reservedBlockIds })(this.options.session.document, {
|
|
1105
|
-
type: "splitParagraph",
|
|
1106
|
-
at: from.value,
|
|
1107
|
-
to: to.value
|
|
1108
|
-
}).newBlockId
|
|
1109
|
-
};
|
|
1110
|
-
break;
|
|
1111
|
-
case "mergeBlockWithNext": {
|
|
1112
|
-
const next = projection.value.nextParagraphInContainer(blockId);
|
|
1113
|
-
if (next === void 0) return refusal("missingBlock");
|
|
1114
|
-
intent = {
|
|
1115
|
-
type: "joinParagraphs",
|
|
1116
|
-
story,
|
|
1117
|
-
blockId,
|
|
1118
|
-
nextBlockId: next.blockId,
|
|
1119
|
-
survivor: "first"
|
|
1120
|
-
};
|
|
1121
|
-
break;
|
|
1122
|
-
}
|
|
1123
|
-
case "formatRange": {
|
|
1124
|
-
const formatting = operation.formatting;
|
|
1125
|
-
const patch = {
|
|
1126
|
-
...formatting.bold === void 0 ? {} : { bold: formatting.bold },
|
|
1127
|
-
...formatting.italic === void 0 ? {} : { italic: formatting.italic },
|
|
1128
|
-
...formatting.underline === void 0 ? {} : { underline: formatting.underline === null ? null : { style: formatting.underline ? "single" : "none" } },
|
|
1129
|
-
...formatting.strike === void 0 ? {} : {
|
|
1130
|
-
strike: formatting.strike,
|
|
1131
|
-
doubleStrike: null
|
|
1132
|
-
},
|
|
1133
|
-
...formatting.fontSizePt === void 0 ? {} : { fontSize: formatting.fontSizePt === null ? null : formatting.fontSizePt * 2 },
|
|
1134
|
-
...formatting.fontFamily === void 0 ? {} : { fontFamily: formatting.fontFamily === null ? null : {
|
|
1135
|
-
ascii: formatting.fontFamily,
|
|
1136
|
-
hAnsi: formatting.fontFamily
|
|
1137
|
-
} },
|
|
1138
|
-
...formatting.color === void 0 ? {} : { color: formatting.color === null ? null : { rgb: formatting.color.replace(/^#/u, "").toUpperCase() } }
|
|
1139
|
-
};
|
|
1140
|
-
intent = {
|
|
1141
|
-
type: "formatRun",
|
|
1142
|
-
from: from.value,
|
|
1143
|
-
to: to.value,
|
|
1144
|
-
patch
|
|
1145
|
-
};
|
|
1146
|
-
break;
|
|
1147
|
-
}
|
|
1148
|
-
case "replaceInBlock":
|
|
1149
|
-
case "replaceRange":
|
|
1150
|
-
case "replaceBlock":
|
|
1151
|
-
intent = {
|
|
1152
|
-
type: "replaceText",
|
|
1153
|
-
from: from.value,
|
|
1154
|
-
to: to.value,
|
|
1155
|
-
text,
|
|
1156
|
-
...options.replacementBackground === "keep" ? {} : { runPropsPatch: {
|
|
1157
|
-
highlight: null,
|
|
1158
|
-
shading: null
|
|
1159
|
-
} }
|
|
1160
|
-
};
|
|
1161
|
-
break;
|
|
1162
|
-
default: return panic(`Unknown canonical public operation ${operation}`);
|
|
1163
|
-
}
|
|
1164
|
-
const intents = [];
|
|
1165
|
-
const normalizations = [];
|
|
1166
|
-
if (intent.type === "replaceText") {
|
|
1167
|
-
let offset = start;
|
|
1168
|
-
let pending = null;
|
|
1169
|
-
const changes = [];
|
|
1170
|
-
for (const segment of diff(clean.text.slice(start, end), text)) switch (segment.type) {
|
|
1171
|
-
case "equal":
|
|
1172
|
-
if (pending) changes.push(pending);
|
|
1173
|
-
pending = null;
|
|
1174
|
-
offset += segment.text.length;
|
|
1175
|
-
break;
|
|
1176
|
-
case "del":
|
|
1177
|
-
pending ??= {
|
|
1178
|
-
start: offset,
|
|
1179
|
-
end: offset,
|
|
1180
|
-
text: ""
|
|
1181
|
-
};
|
|
1182
|
-
offset += segment.text.length;
|
|
1183
|
-
pending.end = offset;
|
|
1184
|
-
break;
|
|
1185
|
-
case "ins":
|
|
1186
|
-
pending ??= {
|
|
1187
|
-
start: offset,
|
|
1188
|
-
end: offset,
|
|
1189
|
-
text: ""
|
|
1190
|
-
};
|
|
1191
|
-
pending.text += segment.text;
|
|
1192
|
-
break;
|
|
1193
|
-
default: {
|
|
1194
|
-
const unreachable = segment.type;
|
|
1195
|
-
return panic(`Unknown replacement diff ${unreachable}`);
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
if (pending) changes.push(pending);
|
|
1199
|
-
for (const change of changes.toReversed()) {
|
|
1200
|
-
const gap = resolveCleanTextRange({
|
|
1201
|
-
cleanBlock: clean,
|
|
1202
|
-
startOffset: change.start,
|
|
1203
|
-
endOffset: change.end
|
|
1204
|
-
});
|
|
1205
|
-
if (!gap) return refusal("unsupportedBlock");
|
|
1206
|
-
if (change.text.length > 0 && gap.from < gap.to) {
|
|
1207
|
-
let first = null;
|
|
1208
|
-
let uniform = true;
|
|
1209
|
-
paragraph.node.nodesBetween(gap.from - paragraph.start, gap.to - paragraph.start, (node) => {
|
|
1210
|
-
if (!node.isText || node.marks.some((mark) => mark.type.name === "deletion")) return;
|
|
1211
|
-
const marks = node.marks.filter((mark) => mark.type.name !== "insertion");
|
|
1212
|
-
if (first === null) first = marks;
|
|
1213
|
-
else if (!Mark.sameSet(first, marks)) uniform = false;
|
|
1214
|
-
});
|
|
1215
|
-
if (!uniform && normalizations.length === 0) normalizations.push({
|
|
1216
|
-
id: operation.id,
|
|
1217
|
-
code: "uniformReplacementFormatting"
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
const lastCharacter = change.end > change.start ? clean.offsets[change.end - 1] : void 0;
|
|
1221
|
-
const changeEnd = lastCharacter === void 0 ? gap.to : Math.max(gap.from, Math.min(gap.to, lastCharacter + 1));
|
|
1222
|
-
const edges = gap.from < changeEnd ? projection.value.rangeEdgesAt(gap.from, changeEnd) : void 0;
|
|
1223
|
-
const changeFrom = projection.value.addressAt(gap.from, edges?.start);
|
|
1224
|
-
const changeTo = projection.value.addressAt(changeEnd, edges?.end);
|
|
1225
|
-
if (changeFrom.isErr() || changeTo.isErr()) return refusal("unsupportedBlock");
|
|
1226
|
-
intents.push({
|
|
1227
|
-
type: "replaceText",
|
|
1228
|
-
from: changeFrom.value,
|
|
1229
|
-
to: changeTo.value,
|
|
1230
|
-
text: change.text,
|
|
1231
|
-
...intent.runPropsPatch === void 0 ? {} : { runPropsPatch: intent.runPropsPatch }
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
} else if (operation.type === "mergeBlockWithNext" && intent.type === "joinParagraphs") {
|
|
1235
|
-
const separator = operation.separator ?? "";
|
|
1236
|
-
if (separator !== "") {
|
|
1237
|
-
const at = projection.value.addressAt(paragraph.start + paragraph.node.content.size);
|
|
1238
|
-
if (at.isErr()) return refusal("unsupportedBlock");
|
|
1239
|
-
intents.push({
|
|
1240
|
-
type: "replaceText",
|
|
1241
|
-
from: at.value,
|
|
1242
|
-
to: at.value,
|
|
1243
|
-
text: separator
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
1246
|
-
intents.push(intent);
|
|
1247
|
-
intents.push(...statedPropertiesIntents({
|
|
1248
|
-
story,
|
|
1249
|
-
blockId: tracked ? intent.nextBlockId : intent.blockId,
|
|
1250
|
-
properties: operation.mergedParagraphProperties,
|
|
1251
|
-
mintList
|
|
1252
|
-
}));
|
|
1253
|
-
} else if (operation.type === "splitBlock" && intent.type === "splitParagraph") {
|
|
1254
|
-
intents.push(intent);
|
|
1255
|
-
for (const [half, properties] of [[paragraph.blockId, operation.firstParagraphProperties], [intent.newBlockId, operation.secondParagraphProperties]]) intents.push(...statedPropertiesIntents({
|
|
1256
|
-
story,
|
|
1257
|
-
blockId: half,
|
|
1258
|
-
properties,
|
|
1259
|
-
mintList
|
|
1260
|
-
}));
|
|
1261
|
-
} else intents.push(intent);
|
|
1262
|
-
const structural = operation.type === "splitBlock" || operation.type === "mergeBlockWithNext";
|
|
1263
|
-
const nextParagraph = operation.type === "mergeBlockWithNext" && intent.type === "joinParagraphs" ? projection.value.paragraph(intent.nextBlockId) : void 0;
|
|
1264
|
-
let claimedTo = range.to;
|
|
1265
|
-
if (structural) claimedTo = paragraph.start + paragraph.node.content.size;
|
|
1266
|
-
if (nextParagraph) claimedTo = nextParagraph.start + nextParagraph.node.content.size;
|
|
1267
|
-
return Result.ok({
|
|
1268
|
-
...resolvedComment,
|
|
1269
|
-
intents,
|
|
1270
|
-
normalizations,
|
|
1271
|
-
from: structural ? paragraph.start : range.from,
|
|
1272
|
-
to: claimedTo
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
};
|
|
1276
|
-
export { CANONICAL_PUBLIC_OPERATION_DISPOSITIONS, CanonicalPublicOperations };
|