@stll/folio-core 0.69.0 → 0.71.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 +245 -12
- package/dist/{controller → canonical}/canonicalSession.js +1111 -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/derivedFields.d.ts +12 -0
- package/dist/canonical/derivedFields.js +111 -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 +33 -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 +19 -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 +94 -13
- package/dist/controller/hiddenEditorApi.js +42 -3
- package/dist/controller/hiddenEditorManager.d.ts +65 -17
- package/dist/controller/hiddenEditorManager.js +473 -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 +34 -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/derivedFields.d.ts +8 -0
- package/dist/prosemirror/plugins/derivedFields.js +52 -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/fields.d.ts +25 -0
- package/dist/types/fields.js +0 -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,32 +1,46 @@
|
|
|
1
1
|
import { splitsGraphemeCluster, splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getTrackedChangeGroupsForIds } from "../ai-edits/read.js";
|
|
3
|
+
import { CommentMarkerCache, paragraphCommentMarkers, positionedCommentGaps, visitCommentMarkerItems } from "../docx/commentAnchorIndex.js";
|
|
4
|
+
import { copyHeaderFooterBaselineHandles, getDocumentSourceBaseline } from "../docx/headerFooterVerbatim.js";
|
|
3
5
|
import { ListNormalizationCache } from "../docx/listModelNormalization.js";
|
|
4
|
-
import { cloneDocumentWithParagraphPropertySources,
|
|
6
|
+
import { cloneDocumentWithParagraphPropertySources, getProseParagraphPropertySourceToken, markParagraphPropertySourceTransfers } from "../docx/paragraphPropertySource.js";
|
|
5
7
|
import { visitInlineContentSlots } from "../docx/paragraphTraversal.js";
|
|
6
8
|
import { isCellMergeContinuation } from "../docx/tableParser.js";
|
|
9
|
+
import { referencedHeaderFooters, retiredHeaderFooters } from "../docx/unreferencedHeaderFooters.js";
|
|
7
10
|
import { calculateRowSpans } from "../docx/verticalMergeProjection.js";
|
|
11
|
+
import { canonicalOperationStagingAccess } from "../internal/canonicalOperationStaging.js";
|
|
12
|
+
import { recordCanonicalTyping } from "../internal/canonicalTyping.js";
|
|
8
13
|
import { canonicalCellSelectionRanges, canonicalContentPosition, canonicalSelectionRange } from "../prosemirror/canonicalSelectionRange.js";
|
|
9
14
|
import { expectCommentRangeBoundaryAttrs } from "../prosemirror/commentRangeBoundaryAttrs.js";
|
|
15
|
+
import { storyConversionOptions } from "../prosemirror/conversion/storyConversionOptions.js";
|
|
10
16
|
import { ProjectionBlockCache, collectPairedBookmarkIds, footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
11
|
-
import {
|
|
17
|
+
import { heldUnreferencedNotes } from "../prosemirror/noteReferenceReview.js";
|
|
18
|
+
import { preservesReplacementCommentAlignment } from "../prosemirror/replacedAnnotations.js";
|
|
12
19
|
import { runFormattingPatchFromMarks } from "../prosemirror/runFormattingFromMarks.js";
|
|
13
20
|
import { CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
21
|
+
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
22
|
+
import { itemBefore } from "../utils/listItems.js";
|
|
23
|
+
import { CanonicalIdLease } from "./canonicalIdLease.js";
|
|
14
24
|
import { InlineProjectionCache, canonicalNativeCells, projectCanonicalInline } from "./canonicalInlineProjection.js";
|
|
15
25
|
import { normalizeCanonicalListRendering } from "./canonicalListRendering.js";
|
|
16
26
|
import { lockViolationBetween } from "./canonicalLockGuard.js";
|
|
17
27
|
import { ParagraphIdIndex, sameIdOrder, storyFactContributions } from "./canonicalProjectionBlocks.js";
|
|
18
|
-
import {
|
|
28
|
+
import { rebaseHistorySteps, remoteSelection } from "./canonicalRemoteHistory.js";
|
|
29
|
+
import { canonicalRevisionLocks } from "./canonicalRevisionLocks.js";
|
|
30
|
+
import { changedWindow, unsupportedEditReason, unsupportedSeedReason } from "./canonicalSeedContent.js";
|
|
19
31
|
import { restoreCanonicalSelection } from "./canonicalSelection.js";
|
|
20
32
|
import { canonicalSourceRestores, normalizeCanonicalSource, withUneditedSourceRestored } from "./canonicalSourceNormalization.js";
|
|
21
33
|
import { mapTocSelection } from "./canonicalTocSelection.js";
|
|
34
|
+
import { controlEdgesAt } from "./controlEdges.js";
|
|
35
|
+
import { ownedSourceCopies, preservePropertySources, preservePropertySourcesWholeStories } from "./propertySourcePreservation.js";
|
|
22
36
|
import { Result, TaggedError, panic } from "better-result";
|
|
23
37
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
24
38
|
import { lockedControlMessage } from "@stll/docx-core/model";
|
|
25
39
|
import { Fragment } from "prosemirror-model";
|
|
26
40
|
import { CellSelection } from "prosemirror-tables";
|
|
27
|
-
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, normalizeForOps, packageParagraphIds, paragraphIdsIn, sameStory, suggestedCommentIds, suggestionRevisionInfos, survivingComments, validateOpsDocument } from "@stll/docx-core/ops";
|
|
41
|
+
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, ID_LEASE_KINDS, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, combineRecordedRevisions, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, formatParaId, freshLeasedIds, inverseMeetingDocument, isBlockBoundary, normalizeForOps, packageParagraphIds, paragraphIdsIn, paragraphsThroughTextBoxes, planWholeParagraphReplacement, sameStory, suggestedCommentIds, suggestionRevisionInfos, survivingComments, validateOpsDocument, withParagraphCopies } from "@stll/docx-core/ops";
|
|
28
42
|
import { AllSelection, NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
29
|
-
// src/
|
|
43
|
+
// src/canonical/canonicalSession.ts
|
|
30
44
|
const CanonicalSessionErrorBase = TaggedError("CanonicalSessionError");
|
|
31
45
|
var CanonicalSessionError = class extends CanonicalSessionErrorBase {};
|
|
32
46
|
const refuse = (message) => Result.err(new CanonicalSessionError({
|
|
@@ -34,6 +48,12 @@ const refuse = (message) => Result.err(new CanonicalSessionError({
|
|
|
34
48
|
message,
|
|
35
49
|
reason: "refused"
|
|
36
50
|
}));
|
|
51
|
+
/** A refusal under the gap or rule it belongs to. */
|
|
52
|
+
const refuseUnder = (ground, message) => Result.err(new CanonicalSessionError({
|
|
53
|
+
ground,
|
|
54
|
+
message,
|
|
55
|
+
reason: "refused"
|
|
56
|
+
}));
|
|
37
57
|
/** A change a content control's lock forbids: the document's rule, not a gap. */
|
|
38
58
|
const lockRefusal = (violation) => Result.err(new CanonicalSessionError({
|
|
39
59
|
ground: { rule: CANONICAL_RULE.contentControlLock },
|
|
@@ -45,6 +65,36 @@ const noChange = (message) => Result.err(new CanonicalSessionError({
|
|
|
45
65
|
message,
|
|
46
66
|
reason: "noChange"
|
|
47
67
|
}));
|
|
68
|
+
/**
|
|
69
|
+
* What the session says for an intent the compiler or the engine refused. A
|
|
70
|
+
* change the engine cannot record belongs to the capability that would record
|
|
71
|
+
* it: the tracked table records for a
|
|
72
|
+
* suggested row, column or table change. Every other refusal is unclassified.
|
|
73
|
+
*/
|
|
74
|
+
const intentRefusal = (intent, mode, { reason, message }) => {
|
|
75
|
+
if (reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE) return noChange(message);
|
|
76
|
+
if (reason === DOCUMENT_OP_REFUSAL_REASONS.UNRECORDABLE_LINK_SUGGESTION) return Result.err(new CanonicalSessionError({
|
|
77
|
+
ground: { rule: CANONICAL_RULE.linkSuggestionShape },
|
|
78
|
+
message,
|
|
79
|
+
reason: "refused"
|
|
80
|
+
}));
|
|
81
|
+
if (reason !== DOCUMENT_OP_REFUSAL_REASONS.UNTRACKABLE) return refuse(message);
|
|
82
|
+
let gap;
|
|
83
|
+
switch (intent.type) {
|
|
84
|
+
case "table":
|
|
85
|
+
case "tableRow":
|
|
86
|
+
case "tableBlock":
|
|
87
|
+
if (mode.type !== "suggesting") return refuse(message);
|
|
88
|
+
gap = CANONICAL_GAP.trackedTableStructure;
|
|
89
|
+
break;
|
|
90
|
+
default: return refuse(message);
|
|
91
|
+
}
|
|
92
|
+
return Result.err(new CanonicalSessionError({
|
|
93
|
+
ground: { gap },
|
|
94
|
+
message,
|
|
95
|
+
reason: "refused"
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
48
98
|
const COMMENT_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
49
99
|
DOCUMENT_OP_TYPES.CREATE_COMMENT,
|
|
50
100
|
DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT,
|
|
@@ -52,7 +102,8 @@ const COMMENT_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
|
52
102
|
DOCUMENT_OP_TYPES.DELETE_COMMENT,
|
|
53
103
|
DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE
|
|
54
104
|
]);
|
|
55
|
-
|
|
105
|
+
/** The story an operation edits, or null for one that edits the package. */
|
|
106
|
+
const operationStory = (op) => {
|
|
56
107
|
switch (op.type) {
|
|
57
108
|
case DOCUMENT_OP_TYPES.CREATE_COMMENT:
|
|
58
109
|
case DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT:
|
|
@@ -68,14 +119,27 @@ const operationChangesPackage = (op) => {
|
|
|
68
119
|
case DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES:
|
|
69
120
|
case DOCUMENT_OP_TYPES.CREATE_NUMBERING_INSTANCE:
|
|
70
121
|
case DOCUMENT_OP_TYPES.DELETE_NUMBERING_INSTANCE:
|
|
71
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_ENDPOINT: return
|
|
122
|
+
case DOCUMENT_OP_TYPES.SET_SECTION_ENDPOINT: return null;
|
|
72
123
|
default:
|
|
73
|
-
if ("story" in op) return
|
|
74
|
-
if ("at" in op) return
|
|
75
|
-
if ("from" in op) return
|
|
124
|
+
if ("story" in op) return op.story;
|
|
125
|
+
if ("at" in op) return op.at.story;
|
|
126
|
+
if ("from" in op) return op.from.story;
|
|
76
127
|
return op;
|
|
77
128
|
}
|
|
78
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* An edit inside a header or footer: the selective save writes every header
|
|
132
|
+
* and footer part whole, and declines one that needs a resource of its own,
|
|
133
|
+
* so the edit leaves the body's paragraph splice standing.
|
|
134
|
+
*/
|
|
135
|
+
const editsHeaderFooter = (op) => {
|
|
136
|
+
const story = operationStory(op);
|
|
137
|
+
return story !== null && story !== OP_STORIES.MAIN && (story.kind === "header" || story.kind === "footer");
|
|
138
|
+
};
|
|
139
|
+
const operationChangesPackage = (op) => {
|
|
140
|
+
const story = operationStory(op);
|
|
141
|
+
return story === null || !sameStory(story, OP_STORIES.MAIN) && !editsHeaderFooter(op);
|
|
142
|
+
};
|
|
79
143
|
const operationChangesStructure = (op) => {
|
|
80
144
|
switch (op.type) {
|
|
81
145
|
case DOCUMENT_OP_TYPES.DELETE_BLOCKS:
|
|
@@ -99,7 +163,8 @@ const operationChangesStructure = (op) => {
|
|
|
99
163
|
case DOCUMENT_OP_TYPES.SET_CELL_PROPS:
|
|
100
164
|
case DOCUMENT_OP_TYPES.SET_ROW_PROPS:
|
|
101
165
|
case DOCUMENT_OP_TYPES.SET_TABLE_PROPS:
|
|
102
|
-
case DOCUMENT_OP_TYPES.SET_REVISION_INFO:
|
|
166
|
+
case DOCUMENT_OP_TYPES.SET_REVISION_INFO:
|
|
167
|
+
case DOCUMENT_OP_TYPES.SET_CONTENT_CONTROL: return true;
|
|
103
168
|
case DOCUMENT_OP_TYPES.CREATE_HEADER_FOOTER:
|
|
104
169
|
case DOCUMENT_OP_TYPES.REMOVE_HEADER_FOOTER:
|
|
105
170
|
case DOCUMENT_OP_TYPES.ADD_NOTE:
|
|
@@ -223,6 +288,12 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
223
288
|
return address;
|
|
224
289
|
}
|
|
225
290
|
/** The paragraph whose content holds `position`, its ends included. */
|
|
291
|
+
/** Whether `position` lies in a text box's content. */
|
|
292
|
+
insideTextBox(position) {
|
|
293
|
+
const resolved = this.doc.resolve(Math.max(0, Math.min(position, this.doc.content.size)));
|
|
294
|
+
for (let depth = resolved.depth; depth > 0; depth -= 1) if (resolved.node(depth).type.name === "textBox") return true;
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
226
297
|
paragraphAround(position) {
|
|
227
298
|
let low = 0;
|
|
228
299
|
let high = this.starts.length - 1;
|
|
@@ -255,7 +326,7 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
255
326
|
if (!Number.isInteger(position)) return refuse("The input position is not an integer.");
|
|
256
327
|
position = canonicalContentPosition(this.doc, position);
|
|
257
328
|
const paragraph = this.paragraphAround(position);
|
|
258
|
-
if (paragraph === void 0) return refuse("The input is outside a plain paragraph.");
|
|
329
|
+
if (paragraph === void 0) return this.insideTextBox(position) ? refuseUnder({ gap: CANONICAL_GAP.publicUnsupportedInline }, "The canonical session holds no address in this paragraph, such as one in a text box.") : refuse("The input is outside a plain paragraph.");
|
|
259
330
|
const relative = position - paragraph.start;
|
|
260
331
|
const offset = paragraph.boundaries.findIndex((gaps) => gaps.some((gap) => gap.position === relative));
|
|
261
332
|
if (offset < 0) return refuse("The input splits an indivisible inline element.");
|
|
@@ -368,6 +439,15 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
368
439
|
const slot = this.index.get(blockId);
|
|
369
440
|
if (slot === void 0 || slot.paragraph < 0) return void 0;
|
|
370
441
|
const paragraph = this.addressOf(slot.block, slot.paragraph);
|
|
442
|
+
const index = paragraph.container.indexOf(paragraph.source);
|
|
443
|
+
if (index >= 0) {
|
|
444
|
+
let at = index + 1;
|
|
445
|
+
while (paragraph.source.sectionProperties === void 0 && paragraph.container[at] !== void 0 && isBlockBoundary(paragraph.container[at] ?? panic("A block is listed."))) at += 1;
|
|
446
|
+
const following = paragraph.container[at];
|
|
447
|
+
if (following?.type !== "paragraph" || following.paraId === void 0) return void 0;
|
|
448
|
+
const address = this.paragraph(following.paraId);
|
|
449
|
+
return address?.container === paragraph.container ? address : void 0;
|
|
450
|
+
}
|
|
371
451
|
let block = slot.block;
|
|
372
452
|
let next = slot.paragraph + 1;
|
|
373
453
|
while (block < this.blocks.length && next >= (this.blocks[block]?.paragraphs.length ?? 0)) {
|
|
@@ -407,39 +487,6 @@ const changedStories = ({ document, previous }) => {
|
|
|
407
487
|
}
|
|
408
488
|
return stories;
|
|
409
489
|
};
|
|
410
|
-
const preservePropertySources = ({ target, source, stories = documentStories(source), indentation = "derive" }) => {
|
|
411
|
-
const collectParagraphs = (blocks) => {
|
|
412
|
-
const paragraphs = [];
|
|
413
|
-
for (const block of blocks) {
|
|
414
|
-
if (block.type === "paragraph") {
|
|
415
|
-
paragraphs.push(block);
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
if (block.type !== "table") continue;
|
|
419
|
-
for (const row of block.rows) for (const cell of row.cells) paragraphs.push(...collectParagraphs(cell.content));
|
|
420
|
-
}
|
|
421
|
-
return paragraphs;
|
|
422
|
-
};
|
|
423
|
-
for (const story of stories) {
|
|
424
|
-
const originals = findStoryBody(source, story)?.content ?? [];
|
|
425
|
-
const derived = findStoryBody(target, story)?.content ?? [];
|
|
426
|
-
if (originals === derived) continue;
|
|
427
|
-
const originalParagraphs = collectParagraphs(originals);
|
|
428
|
-
const derivedParagraphs = collectParagraphs(derived);
|
|
429
|
-
const paragraphs = new Map(derivedParagraphs.flatMap((paragraph) => paragraph.paraId === void 0 ? [] : [[paragraph.paraId, paragraph]]));
|
|
430
|
-
for (const [index, original] of originalParagraphs.entries()) {
|
|
431
|
-
const next = original.paraId === void 0 ? derivedParagraphs.at(index) : paragraphs.get(original.paraId);
|
|
432
|
-
if (next !== void 0 && next !== original) {
|
|
433
|
-
copyParagraphPropertySource(next, original);
|
|
434
|
-
if (indentation === "restore") restoreParagraphIndentationProjection({
|
|
435
|
-
target: next,
|
|
436
|
-
source: original
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
copyDocumentParagraphPropertySourceContract(target, source);
|
|
442
|
-
};
|
|
443
490
|
const newStoryProjectionCaches = () => ({
|
|
444
491
|
blocks: new ProjectionBlockCache(),
|
|
445
492
|
inline: new InlineProjectionCache(),
|
|
@@ -454,6 +501,43 @@ const holdsTextBox = (paragraph) => {
|
|
|
454
501
|
});
|
|
455
502
|
return found;
|
|
456
503
|
};
|
|
504
|
+
/**
|
|
505
|
+
* The selection a publish shows, read back as addresses, with the
|
|
506
|
+
* transaction's text selection moved to exactly where those addresses place
|
|
507
|
+
* it. Undo and redo restore a selection by its addresses, so a publish must
|
|
508
|
+
* show the position its address gives back: one of several editor positions
|
|
509
|
+
* an address names (either side of a link's edge) becomes the one restoring
|
|
510
|
+
* gives, and a position no address names (inside a character, or where an
|
|
511
|
+
* unplaceable selection fell back) moves to the nearest one that has one.
|
|
512
|
+
*/
|
|
513
|
+
const placeShownSelection = (transaction, projection) => {
|
|
514
|
+
const current = transaction.selection;
|
|
515
|
+
if (current instanceof TextSelection) {
|
|
516
|
+
const size = transaction.doc.content.size;
|
|
517
|
+
const nearestAddressable = (position) => {
|
|
518
|
+
for (let distance = 0; distance <= size; distance += 1) for (const candidate of [position - distance, position + distance]) if (candidate >= 0 && candidate <= size && projection.addressAt(candidate).isOk()) return candidate;
|
|
519
|
+
};
|
|
520
|
+
const anchor = nearestAddressable(current.anchor);
|
|
521
|
+
const head = nearestAddressable(current.head);
|
|
522
|
+
if (anchor === void 0 || head === void 0) return void 0;
|
|
523
|
+
const addressed = {
|
|
524
|
+
anchor: projection.addressAt(anchor).unwrap(),
|
|
525
|
+
head: projection.addressAt(head).unwrap()
|
|
526
|
+
};
|
|
527
|
+
const placed = {
|
|
528
|
+
anchor: projection.positionAt(addressed.anchor),
|
|
529
|
+
head: projection.positionAt(addressed.head)
|
|
530
|
+
};
|
|
531
|
+
if (placed.anchor.isErr() || placed.head.isErr()) return void 0;
|
|
532
|
+
if (placed.anchor.value !== current.anchor || placed.head.value !== current.head) transaction.setSelection(TextSelection.create(transaction.doc, placed.anchor.value, placed.head.value));
|
|
533
|
+
return {
|
|
534
|
+
type: "text",
|
|
535
|
+
...addressed
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
const read = projection.selectionAt(transaction);
|
|
539
|
+
return read.isOk() ? read.value : void 0;
|
|
540
|
+
};
|
|
457
541
|
const structureRefusal = () => new CanonicalSessionError({
|
|
458
542
|
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
459
543
|
reason: "refused",
|
|
@@ -471,7 +555,7 @@ const visitBlockSources = (block, container, visit, insideSkippedContinuation) =
|
|
|
471
555
|
visit(block, container, insideSkippedContinuation);
|
|
472
556
|
return;
|
|
473
557
|
}
|
|
474
|
-
if (block.type === "blockSdt") {
|
|
558
|
+
if (block.type === "blockSdt" || block.type === "blockCustomXml") {
|
|
475
559
|
visitSourceParagraphs(block.content, visit, insideSkippedContinuation);
|
|
476
560
|
return;
|
|
477
561
|
}
|
|
@@ -486,9 +570,20 @@ const visitBlockSources = (block, container, visit, insideSkippedContinuation) =
|
|
|
486
570
|
}
|
|
487
571
|
}
|
|
488
572
|
};
|
|
573
|
+
/** The paragraphs of the text boxes a paragraph draws, those inside them included. */
|
|
574
|
+
const visitTextBoxSources = (paragraph, visit) => {
|
|
575
|
+
visitInlineContentSlots(paragraph, ({ item }) => {
|
|
576
|
+
if (item.type !== "run") return;
|
|
577
|
+
for (const content of item.content) if (content.type === "shape" && content.shape.textBody !== void 0) visitSourceParagraphs(content.shape.textBody.content, (source, container) => {
|
|
578
|
+
visit(source, container);
|
|
579
|
+
visitTextBoxSources(source, visit);
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
};
|
|
489
583
|
const collectSources = (content, start, end, takenElsewhere) => {
|
|
490
584
|
const found = {
|
|
491
585
|
located: /* @__PURE__ */ new Map(),
|
|
586
|
+
boxed: /* @__PURE__ */ new Map(),
|
|
492
587
|
idsByBlock: [],
|
|
493
588
|
all: [],
|
|
494
589
|
continuation: /* @__PURE__ */ new Set(),
|
|
@@ -500,6 +595,13 @@ const collectSources = (content, start, end, takenElsewhere) => {
|
|
|
500
595
|
};
|
|
501
596
|
const visit = (source, container, continuation) => {
|
|
502
597
|
found.all.push(source);
|
|
598
|
+
visitTextBoxSources(source, (boxed, boxContent) => {
|
|
599
|
+
if (boxed.paraId !== void 0 && !found.boxed.has(boxed.paraId)) found.boxed.set(boxed.paraId, {
|
|
600
|
+
source: boxed,
|
|
601
|
+
container: boxContent,
|
|
602
|
+
top: at.top
|
|
603
|
+
});
|
|
604
|
+
});
|
|
503
605
|
if (continuation) found.continuation.add(source);
|
|
504
606
|
if (source.paraId === void 0) return;
|
|
505
607
|
if (found.located.has(source.paraId) || takenElsewhere(source.paraId)) found.repeated = true;
|
|
@@ -540,6 +642,43 @@ var OpenComments = class {
|
|
|
540
642
|
}
|
|
541
643
|
};
|
|
542
644
|
/**
|
|
645
|
+
* The paragraphs of a text box's editor node, addressed as its story's
|
|
646
|
+
* paragraphs. A paragraph the session cannot place in the box's source (one
|
|
647
|
+
* the conversion drew without it) gets no address, so input there refuses
|
|
648
|
+
* and the box keeps its source as it was.
|
|
649
|
+
*/
|
|
650
|
+
const projectTextBoxParagraphs = ({ box, offset, walk, paragraphs }) => {
|
|
651
|
+
const open = new OpenComments([]);
|
|
652
|
+
const commentContext = {
|
|
653
|
+
rangedIds: walk.facts.rangedIds,
|
|
654
|
+
pointIds: walk.facts.pointIds,
|
|
655
|
+
openIds: open.ids
|
|
656
|
+
};
|
|
657
|
+
box.descendants((node, childOffset) => {
|
|
658
|
+
if (node.type.name !== "paragraph") return true;
|
|
659
|
+
const paraId = node.attrs["paraId"];
|
|
660
|
+
const located = typeof paraId === "string" ? walk.locateBoxed(paraId) : void 0;
|
|
661
|
+
if (typeof paraId !== "string" || located === void 0 || !walk.takeBoxed(located.source)) return false;
|
|
662
|
+
const inlineArgs = {
|
|
663
|
+
source: located.source,
|
|
664
|
+
paragraph: node,
|
|
665
|
+
pairedBookmarkIds: walk.facts.pairedBookmarkIds,
|
|
666
|
+
commentContext
|
|
667
|
+
};
|
|
668
|
+
const inline = walk.inline === void 0 ? projectCanonicalInline(inlineArgs) : walk.inline.project(inlineArgs);
|
|
669
|
+
if (inline.isOk()) paragraphs.push({
|
|
670
|
+
blockId: paraId,
|
|
671
|
+
container: located.container,
|
|
672
|
+
offset: offset + 1 + childOffset + 1,
|
|
673
|
+
inline: inline.value,
|
|
674
|
+
node,
|
|
675
|
+
source: located.source
|
|
676
|
+
});
|
|
677
|
+
passCommentMarkers(walk.markersOf(located.source), open);
|
|
678
|
+
return false;
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
543
682
|
* The paragraphs of the top-level node at `index`, each start from the
|
|
544
683
|
* node's own, and whether each came from the story block at that index.
|
|
545
684
|
*/
|
|
@@ -556,6 +695,12 @@ const projectBlock = (top, index, walk) => {
|
|
|
556
695
|
if (failure !== void 0) return false;
|
|
557
696
|
if (node.type.name === "textBox") {
|
|
558
697
|
if (node.attrs["_docxPlacement"] === "standalone" && node.attrs["_docxHostParagraph"] != null && !walk.claimTextBoxHost()) failure = structureRefusal();
|
|
698
|
+
else projectTextBoxParagraphs({
|
|
699
|
+
box: node,
|
|
700
|
+
offset,
|
|
701
|
+
walk,
|
|
702
|
+
paragraphs
|
|
703
|
+
});
|
|
559
704
|
return false;
|
|
560
705
|
}
|
|
561
706
|
if (node.type.name === "blockCommentRangeBoundary") {
|
|
@@ -566,6 +711,7 @@ const projectBlock = (top, index, walk) => {
|
|
|
566
711
|
}
|
|
567
712
|
if (node.type.name !== "paragraph") return true;
|
|
568
713
|
if (parent?.attrs["_omittedGridSlot"] != null) return false;
|
|
714
|
+
if ((parent?.type.name === "blockSdt" || parent?.type.name === "blockCustomXml") && parent.attrs["_originallyEmpty"] === true) return false;
|
|
569
715
|
const paraId = node.attrs["paraId"];
|
|
570
716
|
const located = typeof paraId === "string" ? walk.locate(paraId) : void 0;
|
|
571
717
|
if (typeof paraId !== "string" || located === void 0) {
|
|
@@ -578,6 +724,7 @@ const projectBlock = (top, index, walk) => {
|
|
|
578
724
|
return false;
|
|
579
725
|
}
|
|
580
726
|
if (located.top !== index) local = false;
|
|
727
|
+
passCommentMarkers(walk.positionedComments.before.get(source), walk.open);
|
|
581
728
|
const inlineArgs = {
|
|
582
729
|
source,
|
|
583
730
|
paragraph: node,
|
|
@@ -602,6 +749,7 @@ const projectBlock = (top, index, walk) => {
|
|
|
602
749
|
source
|
|
603
750
|
});
|
|
604
751
|
walk.passComments(source);
|
|
752
|
+
passCommentMarkers(walk.positionedComments.after.get(source), walk.open);
|
|
605
753
|
return false;
|
|
606
754
|
};
|
|
607
755
|
if (visit(top, 0, null) && top.content.size > 0) top.descendants((node, offset, parent) => visit(node, offset + 1, parent));
|
|
@@ -611,22 +759,28 @@ const projectBlock = (top, index, walk) => {
|
|
|
611
759
|
local
|
|
612
760
|
});
|
|
613
761
|
};
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
for (const item of markersOf(paragraph)) {
|
|
762
|
+
const passCommentMarkers = (markers, open) => {
|
|
763
|
+
for (const item of markers ?? []) {
|
|
617
764
|
if (item.type === "commentRangeStart") open.ids.add(item.id);
|
|
618
765
|
if (item.type === "commentRangeEnd") open.ids.delete(item.id);
|
|
619
766
|
}
|
|
620
767
|
};
|
|
768
|
+
/** Opens and closes the ranges a paragraph's markers start and end. */
|
|
769
|
+
const commentPasser = (markersOf, open) => (paragraph) => passCommentMarkers(markersOf(paragraph), open);
|
|
621
770
|
/** Every paragraph's address, walking every top-level node. */
|
|
622
771
|
const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
623
772
|
const pairedBookmarkIds = collectPairedBookmarkIds(content);
|
|
624
773
|
const rangedIds = /* @__PURE__ */ new Set();
|
|
625
774
|
const referencedIds = /* @__PURE__ */ new Set();
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
775
|
+
const commentWalk = {
|
|
776
|
+
markersOf,
|
|
777
|
+
visit(item) {
|
|
778
|
+
if (item.type === "commentRangeStart") rangedIds.add(item.id);
|
|
779
|
+
if (item.type === "commentReference") referencedIds.add(item.id);
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
visitCommentMarkerItems(content, commentWalk);
|
|
783
|
+
visitSourceParagraphs(content, (source) => visitTextBoxSources(source, (boxed) => visitCommentMarkerItems([boxed], commentWalk)));
|
|
630
784
|
const facts = {
|
|
631
785
|
pairedBookmarkIds,
|
|
632
786
|
rangedIds,
|
|
@@ -642,15 +796,24 @@ const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
|
642
796
|
const continuationSources = found.continuation;
|
|
643
797
|
const idsByBlock = found.idsByBlock;
|
|
644
798
|
const projectedSources = /* @__PURE__ */ new Set();
|
|
799
|
+
const projectedBoxed = /* @__PURE__ */ new Set();
|
|
645
800
|
const orderedSources = [...allSources];
|
|
646
801
|
const sourceOrder = new Map(orderedSources.map((source, index) => [source, index]));
|
|
647
802
|
const textBoxHosts = /* @__PURE__ */ new Set();
|
|
803
|
+
const positionedComments = positionedCommentGaps(content, continuationSources);
|
|
648
804
|
let nextSource = 0;
|
|
649
805
|
const walk = {
|
|
650
806
|
facts,
|
|
651
807
|
open,
|
|
652
808
|
content,
|
|
653
809
|
locate: (paraId) => sources.get(paraId),
|
|
810
|
+
locateBoxed: (paraId) => found.boxed.get(paraId),
|
|
811
|
+
takeBoxed: (source) => {
|
|
812
|
+
if (projectedBoxed.has(source)) return false;
|
|
813
|
+
projectedBoxed.add(source);
|
|
814
|
+
return true;
|
|
815
|
+
},
|
|
816
|
+
markersOf,
|
|
654
817
|
claimTextBoxHost: () => {
|
|
655
818
|
reusable = false;
|
|
656
819
|
let index = nextSource;
|
|
@@ -659,7 +822,9 @@ const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
|
659
822
|
if (host === void 0 || !holdsTextBox(host)) return false;
|
|
660
823
|
textBoxHosts.add(host);
|
|
661
824
|
nextSource = index + 1;
|
|
825
|
+
passCommentMarkers(positionedComments.before.get(host), open);
|
|
662
826
|
passComments(host);
|
|
827
|
+
passCommentMarkers(positionedComments.after.get(host), open);
|
|
663
828
|
return true;
|
|
664
829
|
},
|
|
665
830
|
take: (source) => {
|
|
@@ -669,6 +834,7 @@ const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
|
669
834
|
return true;
|
|
670
835
|
},
|
|
671
836
|
passComments,
|
|
837
|
+
positionedComments,
|
|
672
838
|
inline
|
|
673
839
|
};
|
|
674
840
|
const blocks = [];
|
|
@@ -727,11 +893,19 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
727
893
|
const continuationSources = found.continuation;
|
|
728
894
|
const open = new OpenComments(before[start - 1]?.openAfter ?? []);
|
|
729
895
|
const projectedSources = /* @__PURE__ */ new Set();
|
|
896
|
+
const projectedBoxed = /* @__PURE__ */ new Set();
|
|
730
897
|
const walk = {
|
|
731
898
|
facts: previous.facts,
|
|
732
899
|
open,
|
|
733
900
|
content,
|
|
734
901
|
locate: (paraId) => sources.get(paraId),
|
|
902
|
+
locateBoxed: (paraId) => found.boxed.get(paraId),
|
|
903
|
+
takeBoxed: (source) => {
|
|
904
|
+
if (projectedBoxed.has(source)) return false;
|
|
905
|
+
projectedBoxed.add(source);
|
|
906
|
+
return true;
|
|
907
|
+
},
|
|
908
|
+
markersOf,
|
|
735
909
|
claimTextBoxHost: () => false,
|
|
736
910
|
take: (source) => {
|
|
737
911
|
if (projectedSources.has(source)) return false;
|
|
@@ -739,6 +913,7 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
739
913
|
return true;
|
|
740
914
|
},
|
|
741
915
|
passComments: commentPasser(markersOf, open),
|
|
916
|
+
positionedComments: positionedCommentGaps(content.slice(start, newEnd), continuationSources),
|
|
742
917
|
inline
|
|
743
918
|
};
|
|
744
919
|
const window = [];
|
|
@@ -784,10 +959,11 @@ const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous }
|
|
|
784
959
|
const body = findStoryBody(document, story);
|
|
785
960
|
if (!body) return refuse("The canonical story no longer exists.");
|
|
786
961
|
const currentStyles = Object.hasOwn(document.package, "styles") ? document.package.styles : styles;
|
|
787
|
-
const options = {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
962
|
+
const options = storyConversionOptions({
|
|
963
|
+
styles: currentStyles,
|
|
964
|
+
theme: document.package.theme,
|
|
965
|
+
numbering: document.package.numbering
|
|
966
|
+
});
|
|
791
967
|
const converted = Result.try({
|
|
792
968
|
try: () => {
|
|
793
969
|
if (story === OP_STORIES.MAIN) return toProseDoc(document, caches === void 0 ? options : {
|
|
@@ -840,6 +1016,8 @@ const intentStory = (intent) => {
|
|
|
840
1016
|
const UNDO_GROUP_WINDOW_MS = 500;
|
|
841
1017
|
const samePosition = (left, right) => sameStory(left.story, right.story) && left.blockId === right.blockId && left.offset === right.offset && (left.zeroWidthBefore ?? 0) === (right.zeroWidthBefore ?? 0);
|
|
842
1018
|
const sameSelection = (left, right) => left.type === right.type && samePosition(left.anchor, right.anchor) && samePosition(left.head, right.head);
|
|
1019
|
+
/** The ops that undo `group`, applied to the document it left. */
|
|
1020
|
+
const undoOpsOf = (group) => group.undo.type === "replayed" ? group.undo.inverse : group.entries.toReversed().flatMap((entry) => entry.inverse);
|
|
843
1021
|
const continuesGroup = (previous, next) => {
|
|
844
1022
|
switch (next.semantic) {
|
|
845
1023
|
case "typing":
|
|
@@ -861,6 +1039,27 @@ const isCanonicalProjectionTransaction = (transaction, session) => {
|
|
|
861
1039
|
const authorization = authorizedProjections.get(transaction);
|
|
862
1040
|
return authorization?.session === session && authorization.version === session.version && transaction.doc.eq(authorization.doc);
|
|
863
1041
|
};
|
|
1042
|
+
/** A node's shape without its text, for a refusal that names a change. */
|
|
1043
|
+
const nodeShapeOf = (node) => JSON.stringify({
|
|
1044
|
+
type: node.type.name,
|
|
1045
|
+
attrs: node.attrs,
|
|
1046
|
+
children: node.content.content.map((child) => ({
|
|
1047
|
+
type: child.type.name,
|
|
1048
|
+
marks: child.marks.map((mark) => mark.toJSON())
|
|
1049
|
+
}))
|
|
1050
|
+
});
|
|
1051
|
+
/**
|
|
1052
|
+
* Where an appended transaction moved the published document off the
|
|
1053
|
+
* projection: the innermost node holding the first difference, by its type,
|
|
1054
|
+
* attributes and children's marks, so the refusal carries no document text.
|
|
1055
|
+
*/
|
|
1056
|
+
const projectionChangeOf = (projected, published) => {
|
|
1057
|
+
const at = projected.content.findDiffStart(published.content);
|
|
1058
|
+
if (at === null) return "a plugin appended a document change";
|
|
1059
|
+
const expected = projected.resolve(Math.min(at, projected.content.size));
|
|
1060
|
+
const actual = published.resolve(Math.min(at, published.content.size));
|
|
1061
|
+
return `a plugin changed the ${expected.parent.type.name} in body block ${expected.index(0)} from ${nodeShapeOf(expected.parent)} to ${nodeShapeOf(actual.parent)}`;
|
|
1062
|
+
};
|
|
864
1063
|
/** The model publishes only after PM and every plugin accept its exact projection. */
|
|
865
1064
|
const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
866
1065
|
if (!isCanonicalProjectionTransaction(commit.transaction, session)) return refuse("The staged canonical projection is unauthorized.");
|
|
@@ -874,11 +1073,22 @@ const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
|
874
1073
|
});
|
|
875
1074
|
if (applied.isErr()) return applied;
|
|
876
1075
|
const staged = applied.value;
|
|
877
|
-
if (!staged.transactions.includes(commit.transaction)
|
|
1076
|
+
if (!staged.transactions.includes(commit.transaction)) return refuse("A plugin refused or changed the canonical projection: a plugin filtered the projection transaction.");
|
|
1077
|
+
if (!staged.state.doc.eq(commit.projection.doc) || staged.transactions.some((transaction) => transaction.docChanged && !isCanonicalProjectionTransaction(transaction, session))) return refuse(`A plugin refused or changed the canonical projection: ${projectionChangeOf(commit.projection.doc, staged.state.doc)}.`);
|
|
878
1078
|
const published = commit.publish();
|
|
879
1079
|
if (published.isErr()) return published;
|
|
880
1080
|
return Result.ok(staged);
|
|
881
1081
|
};
|
|
1082
|
+
/**
|
|
1083
|
+
* How a change is admitted against content-control locks. An edit is judged
|
|
1084
|
+
* on its result. A restage rebuilds a pending suggestion recorded before the
|
|
1085
|
+
* save: no new edit, so a lock that arrived since does not refuse it, while
|
|
1086
|
+
* resolving the suggestion stays under the lock.
|
|
1087
|
+
*/
|
|
1088
|
+
const CANONICAL_ADMISSION = {
|
|
1089
|
+
edit: "edit",
|
|
1090
|
+
restage: "restage"
|
|
1091
|
+
};
|
|
882
1092
|
const storyProjectionKey = (story) => {
|
|
883
1093
|
switch (story.kind) {
|
|
884
1094
|
case "header":
|
|
@@ -888,6 +1098,55 @@ const storyProjectionKey = (story) => {
|
|
|
888
1098
|
default: return panic(`Unknown canonical story ${story}`);
|
|
889
1099
|
}
|
|
890
1100
|
};
|
|
1101
|
+
const sameStoryParts = (left, right) => ["headers", "footers"].every((kind) => canonicalJson([...left.package[kind]?.keys() ?? []].toSorted()) === canonicalJson([...right.package[kind]?.keys() ?? []].toSorted()));
|
|
1102
|
+
/**
|
|
1103
|
+
* What a save baseline keeps of the parsed saved package: its buffer, the
|
|
1104
|
+
* capture of its body, and its headers and footers with their verbatim
|
|
1105
|
+
* sources. The body content itself is not kept.
|
|
1106
|
+
*/
|
|
1107
|
+
const saveBaselineOf = (saved, buffer) => {
|
|
1108
|
+
const baseline = {
|
|
1109
|
+
originalBuffer: buffer,
|
|
1110
|
+
package: {
|
|
1111
|
+
document: {
|
|
1112
|
+
...saved.package.document,
|
|
1113
|
+
content: []
|
|
1114
|
+
},
|
|
1115
|
+
...saved.package.headers === void 0 ? {} : { headers: saved.package.headers },
|
|
1116
|
+
...saved.package.footers === void 0 ? {} : { footers: saved.package.footers }
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
copyHeaderFooterBaselineHandles(baseline, saved);
|
|
1120
|
+
return baseline;
|
|
1121
|
+
};
|
|
1122
|
+
/** Every note paragraph of `document`, in its text boxes too, by its id's key. */
|
|
1123
|
+
const noteParagraphsOf = (document) => {
|
|
1124
|
+
const paragraphs = /* @__PURE__ */ new Map();
|
|
1125
|
+
const notes = [...(document.package.footnotes ?? []).map(({ id, content }) => ({
|
|
1126
|
+
story: {
|
|
1127
|
+
kind: "footnote",
|
|
1128
|
+
id
|
|
1129
|
+
},
|
|
1130
|
+
content
|
|
1131
|
+
})), ...(document.package.endnotes ?? []).map(({ id, content }) => ({
|
|
1132
|
+
story: {
|
|
1133
|
+
kind: "endnote",
|
|
1134
|
+
id
|
|
1135
|
+
},
|
|
1136
|
+
content
|
|
1137
|
+
}))];
|
|
1138
|
+
for (const { story, content } of notes) for (const { paragraph } of paragraphsThroughTextBoxes(document, story)) if (paragraph.paraId !== void 0) paragraphs.set(paragraph.paraId.toUpperCase(), {
|
|
1139
|
+
paragraph,
|
|
1140
|
+
note: content
|
|
1141
|
+
});
|
|
1142
|
+
return paragraphs;
|
|
1143
|
+
};
|
|
1144
|
+
/** Every paragraph of `document`, in every story and text box, by its id's key. */
|
|
1145
|
+
const storyParagraphsOf = (document) => {
|
|
1146
|
+
const paragraphs = /* @__PURE__ */ new Map();
|
|
1147
|
+
for (const story of documentStories(document)) for (const { paragraph } of paragraphsThroughTextBoxes(document, story)) if (paragraph.paraId !== void 0) paragraphs.set(paragraph.paraId.toUpperCase(), paragraph);
|
|
1148
|
+
return paragraphs;
|
|
1149
|
+
};
|
|
891
1150
|
/** Immutable model authority with a journal staged independently of the PM view. */
|
|
892
1151
|
var CanonicalSession = class {
|
|
893
1152
|
currentDocument;
|
|
@@ -895,32 +1154,75 @@ var CanonicalSession = class {
|
|
|
895
1154
|
sourceBlockIds;
|
|
896
1155
|
currentVersion = 0;
|
|
897
1156
|
saveTouched = /* @__PURE__ */ new Set();
|
|
1157
|
+
/** Every paragraph an edit touched since the session opened, undo and redo included. */
|
|
1158
|
+
touchedSinceOpen = /* @__PURE__ */ new Set();
|
|
1159
|
+
/** The document as the session opened it, which note parts are written against. */
|
|
1160
|
+
openedDocument;
|
|
898
1161
|
saveStructure = "stable";
|
|
1162
|
+
/**
|
|
1163
|
+
* The package a save wrote, parsed, once it is the baseline later saves
|
|
1164
|
+
* patch against: `saveTouched` and `saveStructure` then count from its
|
|
1165
|
+
* version. Holding only the latest releases every earlier one.
|
|
1166
|
+
*/
|
|
1167
|
+
saveBaseline = null;
|
|
1168
|
+
/** A save whose package is being read to become the baseline. */
|
|
1169
|
+
pendingSaveBaseline = null;
|
|
899
1170
|
allocateIntentIds = createEditorIntentIdAllocator();
|
|
900
1171
|
mode = { type: "editing" };
|
|
901
1172
|
allocatedBlockIds = /* @__PURE__ */ new Set();
|
|
902
1173
|
nextBlockId = 1;
|
|
1174
|
+
leased;
|
|
903
1175
|
sourceOwners = /* @__PURE__ */ new Map();
|
|
904
1176
|
storyProjections = /* @__PURE__ */ new Map();
|
|
905
1177
|
currentSelection = null;
|
|
1178
|
+
/**
|
|
1179
|
+
* The selection the editor of each header, footer or note last showed,
|
|
1180
|
+
* keyed by story. Its editor records it whenever it changes, an edit in the
|
|
1181
|
+
* story commits it, and every peer's edit moves it with the text, as the
|
|
1182
|
+
* body's selection moves.
|
|
1183
|
+
*/
|
|
1184
|
+
storySelections = /* @__PURE__ */ new Map();
|
|
906
1185
|
applied = [];
|
|
907
1186
|
groupingBoundary = 0;
|
|
908
1187
|
lifecycle = { type: "committed" };
|
|
909
1188
|
undone = [];
|
|
1189
|
+
historyDropListeners = /* @__PURE__ */ new Set();
|
|
1190
|
+
committedListeners = /* @__PURE__ */ new Set();
|
|
1191
|
+
newOpId;
|
|
910
1192
|
styles;
|
|
911
1193
|
sourceRestores;
|
|
1194
|
+
/**
|
|
1195
|
+
* The ids of the paragraphs the session added to the stories it read in its
|
|
1196
|
+
* own form (a story's closing paragraph), which no package names: a reader
|
|
1197
|
+
* reports them as positional.
|
|
1198
|
+
*/
|
|
1199
|
+
get sourceMintedParaIds() {
|
|
1200
|
+
return new Set(this.sourceRestores.flatMap(({ minted }) => minted));
|
|
1201
|
+
}
|
|
1202
|
+
/** Notes the opened package held without a reference: content, kept on save. */
|
|
1203
|
+
heldUnreferencedNotes;
|
|
1204
|
+
/** Headers and footers a section of the opened package referenced. */
|
|
1205
|
+
referencedHeaderFootersAtOpen;
|
|
1206
|
+
/** {@link retiredHeaderFooters} of the document it was read from. */
|
|
1207
|
+
retiredHeaderFootersCache;
|
|
912
1208
|
/** What earlier projections converted, reused by every later one. */
|
|
913
1209
|
caches;
|
|
914
|
-
constructor({ document, projection, styles, sourceRestores = [], caches }) {
|
|
1210
|
+
constructor({ document, projection, styles, sourceRestores = [], caches, idLease, newOpId = () => crypto.randomUUID() }) {
|
|
1211
|
+
this.newOpId = newOpId;
|
|
1212
|
+
this.leased = idLease === void 0 ? void 0 : new CanonicalIdLease(idLease, document);
|
|
915
1213
|
this.sourceRestores = sourceRestores;
|
|
916
1214
|
this.caches = caches;
|
|
1215
|
+
this.heldUnreferencedNotes = heldUnreferencedNotes(document);
|
|
1216
|
+
this.referencedHeaderFootersAtOpen = referencedHeaderFooters(document);
|
|
1217
|
+
this.openedDocument = document;
|
|
917
1218
|
this.currentDocument = document;
|
|
918
1219
|
this.currentProjection = projection;
|
|
919
|
-
|
|
920
|
-
|
|
1220
|
+
const blockIds = packageParagraphIds(document.package);
|
|
1221
|
+
this.sourceBlockIds = new Set(blockIds);
|
|
1222
|
+
for (const blockId of blockIds) this.allocatedBlockIds.add(blockId.toUpperCase());
|
|
921
1223
|
this.advanceBlockId();
|
|
922
1224
|
this.styles = styles == null ? styles : structuredClone(styles);
|
|
923
|
-
this.rememberSources(document);
|
|
1225
|
+
this.rememberSources(document.package.document.content);
|
|
924
1226
|
}
|
|
925
1227
|
/** Render only the committed comment projection while provisional IME blocks document snapshots. */
|
|
926
1228
|
getCommittedComments() {
|
|
@@ -936,10 +1238,30 @@ var CanonicalSession = class {
|
|
|
936
1238
|
hasStyle(styleId) {
|
|
937
1239
|
return (this.styles ?? this.currentDocument.package.styles)?.styles.some((style) => style.styleId === styleId) ?? false;
|
|
938
1240
|
}
|
|
1241
|
+
/** How a replacement in the current mode removes the words it changes. */
|
|
1242
|
+
replacementRemoval() {
|
|
1243
|
+
switch (this.mode.type) {
|
|
1244
|
+
case "editing": return {
|
|
1245
|
+
type: "direct",
|
|
1246
|
+
comments: this.currentDocument.package.document.comments ?? []
|
|
1247
|
+
};
|
|
1248
|
+
case "suggesting": return { type: "tracked" };
|
|
1249
|
+
default: {
|
|
1250
|
+
const unhandled = this.mode;
|
|
1251
|
+
return panic(`Unknown canonical session mode ${String(unhandled)}`);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
939
1255
|
advanceBlockId() {
|
|
940
1256
|
while (this.allocatedBlockIds.has(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase())) this.nextBlockId += 1;
|
|
941
1257
|
}
|
|
942
1258
|
freshBlockId() {
|
|
1259
|
+
if (this.leased !== void 0) {
|
|
1260
|
+
const fresh = this.freshBlockIds([1]);
|
|
1261
|
+
if (fresh.isErr()) return fresh;
|
|
1262
|
+
const id = fresh.value[0]?.[0];
|
|
1263
|
+
return id === void 0 ? refuse("The paragraph identity lease is exhausted.") : Result.ok(id);
|
|
1264
|
+
}
|
|
943
1265
|
if (this.nextBlockId > 2147483647) return refuse("The paragraph identity space is exhausted.");
|
|
944
1266
|
return Result.ok(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase());
|
|
945
1267
|
}
|
|
@@ -951,6 +1273,16 @@ var CanonicalSession = class {
|
|
|
951
1273
|
freshBlockIds(counts) {
|
|
952
1274
|
const total = counts.reduce((sum, count) => sum + count, 0);
|
|
953
1275
|
const ids = [];
|
|
1276
|
+
if (this.leased !== void 0) {
|
|
1277
|
+
const leased = freshLeasedIds({
|
|
1278
|
+
lease: this.leased.lease,
|
|
1279
|
+
kind: ID_LEASE_KINDS.PARAGRAPH,
|
|
1280
|
+
count: total,
|
|
1281
|
+
taken: (id) => this.allocatedBlockIds.has(formatParaId(id))
|
|
1282
|
+
});
|
|
1283
|
+
if (leased.length < total) return refuse("The paragraph identity lease is exhausted.");
|
|
1284
|
+
ids.push(...leased.map(formatParaId));
|
|
1285
|
+
}
|
|
954
1286
|
for (let candidate = this.nextBlockId; ids.length < total; candidate += 1) {
|
|
955
1287
|
if (candidate > 2147483647) return refuse("The paragraph identity space is exhausted.");
|
|
956
1288
|
const id = candidate.toString(16).padStart(8, "0").toUpperCase();
|
|
@@ -965,18 +1297,22 @@ var CanonicalSession = class {
|
|
|
965
1297
|
return Result.ok(groups);
|
|
966
1298
|
}
|
|
967
1299
|
intentMode(document, intent) {
|
|
1300
|
+
const leased = this.leased === void 0 ? {} : { idLease: this.leased.lease };
|
|
968
1301
|
if (this.mode.type === "editing" && !this.intentNeedsIdentityIds(document, intent)) return {
|
|
969
1302
|
type: "editing",
|
|
970
|
-
reservedBlockIds: this.allocatedBlockIds
|
|
1303
|
+
reservedBlockIds: this.allocatedBlockIds,
|
|
1304
|
+
...leased
|
|
971
1305
|
};
|
|
972
|
-
const ids = this.allocateIntentIds(document, intent);
|
|
1306
|
+
const ids = this.allocateIntentIds(document, intent, this.leased?.lease);
|
|
973
1307
|
return this.mode.type === "editing" ? {
|
|
974
1308
|
type: "editing",
|
|
975
1309
|
newIds: ids.newIds,
|
|
976
|
-
reservedBlockIds: this.allocatedBlockIds
|
|
1310
|
+
reservedBlockIds: this.allocatedBlockIds,
|
|
1311
|
+
...leased
|
|
977
1312
|
} : {
|
|
978
1313
|
type: "suggesting",
|
|
979
1314
|
reservedBlockIds: this.allocatedBlockIds,
|
|
1315
|
+
...leased,
|
|
980
1316
|
revision: {
|
|
981
1317
|
id: ids.revisionId,
|
|
982
1318
|
author: this.mode.author,
|
|
@@ -1028,8 +1364,9 @@ var CanonicalSession = class {
|
|
|
1028
1364
|
return paragraph !== void 0 && hasIdentity(paragraph);
|
|
1029
1365
|
});
|
|
1030
1366
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1367
|
+
/** Record each paragraph among `blocks` as the owner of its id. */
|
|
1368
|
+
rememberSources(blocks) {
|
|
1369
|
+
for (const block of blocks) if (block.type === "paragraph" && block.paraId !== void 0) this.sourceOwners.set(block.paraId, block);
|
|
1033
1370
|
}
|
|
1034
1371
|
get document() {
|
|
1035
1372
|
if (this.isComposing) throw new CanonicalSessionError({
|
|
@@ -1039,20 +1376,147 @@ var CanonicalSession = class {
|
|
|
1039
1376
|
});
|
|
1040
1377
|
return this.currentDocument;
|
|
1041
1378
|
}
|
|
1379
|
+
/**
|
|
1380
|
+
* The `header:<rId>` and `footer:<rId>` parts a resolution retired: the
|
|
1381
|
+
* opened package referenced them and no section names them now. A save
|
|
1382
|
+
* drops them; a reader lists them no more.
|
|
1383
|
+
*/
|
|
1384
|
+
retiredHeaderFooters() {
|
|
1385
|
+
const document = this.currentDocument;
|
|
1386
|
+
if (this.retiredHeaderFootersCache?.document !== document) this.retiredHeaderFootersCache = {
|
|
1387
|
+
document,
|
|
1388
|
+
retired: retiredHeaderFooters(document, this.referencedHeaderFootersAtOpen)
|
|
1389
|
+
};
|
|
1390
|
+
return this.retiredHeaderFootersCache.retired;
|
|
1391
|
+
}
|
|
1042
1392
|
captureSaveSnapshot() {
|
|
1043
1393
|
if (this.isComposing) throw new CanonicalSessionError({
|
|
1044
1394
|
ground: { gap: CANONICAL_GAP.save },
|
|
1045
1395
|
reason: "refused",
|
|
1046
1396
|
message: "Composition must finish before saving the canonical document."
|
|
1047
1397
|
});
|
|
1048
|
-
const retainedBlockIdKeys = new Set([
|
|
1398
|
+
const retainedBlockIdKeys = new Set([
|
|
1399
|
+
...this.sourceBlockIds,
|
|
1400
|
+
...this.saveBaseline?.blockIds ?? [],
|
|
1401
|
+
...packageParagraphIds(this.currentDocument.package)
|
|
1402
|
+
].map((blockId) => blockId.toUpperCase()));
|
|
1403
|
+
const document = withUneditedSourceRestored(cloneDocumentWithParagraphPropertySources(this.currentDocument), this.sourceRestores);
|
|
1404
|
+
const noteParagraphs = this.noteParagraphChanges();
|
|
1049
1405
|
return {
|
|
1050
|
-
document
|
|
1406
|
+
document,
|
|
1407
|
+
...this.saveBaseline === null ? {} : { saveBaseline: {
|
|
1408
|
+
buffer: this.saveBaseline.buffer,
|
|
1409
|
+
document: this.saveBaseline.document
|
|
1410
|
+
} },
|
|
1051
1411
|
version: this.currentVersion,
|
|
1052
1412
|
changedBlockIds: [...this.saveTouched].filter((blockId) => retainedBlockIdKeys.has(blockId.toUpperCase())),
|
|
1053
|
-
structure: this.saveStructure
|
|
1413
|
+
structure: this.saveStructure,
|
|
1414
|
+
heldUnreferencedNotes: this.heldUnreferencedNotes,
|
|
1415
|
+
referencedHeaderFootersAtOpen: this.referencedHeaderFootersAtOpen,
|
|
1416
|
+
noteParagraphs,
|
|
1417
|
+
restoredSinceSource: this.paragraphsRestoredSinceSource(new Set(noteParagraphs.changedSinceSource.map((id) => id.toUpperCase())))
|
|
1054
1418
|
};
|
|
1055
1419
|
}
|
|
1420
|
+
/**
|
|
1421
|
+
* The paragraphs an edit touched since the session opened whose content is
|
|
1422
|
+
* again what the opened document held, between the same neighbours: an
|
|
1423
|
+
* edit and its undo, or a change and its rejection, left them as they were.
|
|
1424
|
+
* A paragraph added or removed beside one is placed by it, so it stays a
|
|
1425
|
+
* change, and so does a note paragraph in `changedNotes`, whose note
|
|
1426
|
+
* changed around it.
|
|
1427
|
+
*/
|
|
1428
|
+
paragraphsRestoredSinceSource(changedNotes) {
|
|
1429
|
+
if (this.touchedSinceOpen.size === 0) return [];
|
|
1430
|
+
const current = storyParagraphsOf(this.currentDocument);
|
|
1431
|
+
const opened = storyParagraphsOf(this.openedDocument);
|
|
1432
|
+
const neighbours = (paragraphs) => {
|
|
1433
|
+
const ids = [...paragraphs.keys()];
|
|
1434
|
+
return new Map(ids.map((id, index) => [id, `${ids[index - 1] ?? ""}|${ids[index + 1] ?? ""}`]));
|
|
1435
|
+
};
|
|
1436
|
+
const currentNeighbours = neighbours(current);
|
|
1437
|
+
const openedNeighbours = neighbours(opened);
|
|
1438
|
+
return [...this.touchedSinceOpen].filter((id) => {
|
|
1439
|
+
const key = id.toUpperCase();
|
|
1440
|
+
const now = current.get(key);
|
|
1441
|
+
const then = opened.get(key);
|
|
1442
|
+
return now !== void 0 && then !== void 0 && !changedNotes.has(key) && currentNeighbours.get(key) === openedNeighbours.get(key) && (now === then || canonicalJson(now) === canonicalJson(then));
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* The note paragraphs touched since the save baseline, and those that
|
|
1447
|
+
* differ from the opened document among the ones touched since it opened:
|
|
1448
|
+
* a note an edit and its undo left as it was is no change. A paragraph the
|
|
1449
|
+
* edit left as it was still counts when its note changed around it (cells
|
|
1450
|
+
* merged, a row's or cell's revision), which no paragraph records.
|
|
1451
|
+
*/
|
|
1452
|
+
noteParagraphChanges() {
|
|
1453
|
+
if (this.touchedSinceOpen.size === 0) return {
|
|
1454
|
+
touched: [],
|
|
1455
|
+
changedSinceSource: []
|
|
1456
|
+
};
|
|
1457
|
+
const current = noteParagraphsOf(this.currentDocument);
|
|
1458
|
+
const opened = noteParagraphsOf(this.openedDocument);
|
|
1459
|
+
const isNote = (id) => current.has(id.toUpperCase()) || opened.has(id.toUpperCase());
|
|
1460
|
+
const noteJson = /* @__PURE__ */ new Map();
|
|
1461
|
+
const jsonOf = (note) => {
|
|
1462
|
+
const known = noteJson.get(note);
|
|
1463
|
+
if (known !== void 0) return known;
|
|
1464
|
+
const json = canonicalJson(note);
|
|
1465
|
+
noteJson.set(note, json);
|
|
1466
|
+
return json;
|
|
1467
|
+
};
|
|
1468
|
+
return {
|
|
1469
|
+
touched: [...this.saveTouched].filter(isNote),
|
|
1470
|
+
changedSinceSource: [...this.touchedSinceOpen].filter((id) => {
|
|
1471
|
+
const now = current.get(id.toUpperCase());
|
|
1472
|
+
const then = opened.get(id.toUpperCase());
|
|
1473
|
+
if (now === void 0 || then === void 0) return now !== then;
|
|
1474
|
+
if (now.paragraph !== then.paragraph && canonicalJson(now.paragraph) !== canonicalJson(then.paragraph)) return true;
|
|
1475
|
+
return now.note !== then.note && jsonOf(now.note) !== jsonOf(then.note);
|
|
1476
|
+
})
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Start making the package saved at `version` the baseline later saves
|
|
1481
|
+
* patch against. Edits from now on are counted from that version too, so
|
|
1482
|
+
* {@link completeSaveBaseline} can swap the counts without losing one.
|
|
1483
|
+
* Refused unless `version` is the current one.
|
|
1484
|
+
*/
|
|
1485
|
+
beginSaveBaseline(version) {
|
|
1486
|
+
if (this.isComposing || version !== this.currentVersion) return false;
|
|
1487
|
+
this.pendingSaveBaseline = {
|
|
1488
|
+
version,
|
|
1489
|
+
blockIds: packageParagraphIds(this.currentDocument.package),
|
|
1490
|
+
touched: /* @__PURE__ */ new Set(),
|
|
1491
|
+
structure: "stable"
|
|
1492
|
+
};
|
|
1493
|
+
return true;
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Make `saved`, the package written at `version` as parsed, the baseline:
|
|
1497
|
+
* later saves patch it and count changes from that version, and an undo
|
|
1498
|
+
* past it counts as a change like any other edit. Declined, keeping the
|
|
1499
|
+
* previous baseline and its counts, when a later save started, or when
|
|
1500
|
+
* `saved` does not hold the body paragraphs the session held at `version`
|
|
1501
|
+
* in the same order, or the same headers and footers.
|
|
1502
|
+
*/
|
|
1503
|
+
completeSaveBaseline(version, saved) {
|
|
1504
|
+
const pending = this.pendingSaveBaseline;
|
|
1505
|
+
if (pending?.version !== version) return false;
|
|
1506
|
+
this.pendingSaveBaseline = null;
|
|
1507
|
+
const blockIds = packageParagraphIds(saved.package);
|
|
1508
|
+
const buffer = saved.originalBuffer;
|
|
1509
|
+
if (buffer === void 0 || getDocumentSourceBaseline(saved).type !== "captured" || blockIds.length !== pending.blockIds.length || blockIds.some((blockId, index) => blockId.toUpperCase() !== pending.blockIds[index]?.toUpperCase()) || !sameStoryParts(saved, this.currentDocument)) return false;
|
|
1510
|
+
this.saveBaseline = {
|
|
1511
|
+
version,
|
|
1512
|
+
blockIds,
|
|
1513
|
+
buffer,
|
|
1514
|
+
document: saveBaselineOf(saved, buffer)
|
|
1515
|
+
};
|
|
1516
|
+
this.saveTouched = pending.touched;
|
|
1517
|
+
this.saveStructure = pending.structure;
|
|
1518
|
+
return true;
|
|
1519
|
+
}
|
|
1056
1520
|
get projection() {
|
|
1057
1521
|
return this.currentProjection;
|
|
1058
1522
|
}
|
|
@@ -1066,10 +1530,56 @@ var CanonicalSession = class {
|
|
|
1066
1530
|
get selection() {
|
|
1067
1531
|
return this.currentSelection;
|
|
1068
1532
|
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Record the selection the editor of a header, footer or note shows, so a
|
|
1535
|
+
* peer's edit to the story moves it with the text (`storySelection`). The
|
|
1536
|
+
* state must show the story's current projection.
|
|
1537
|
+
*/
|
|
1538
|
+
recordStorySelection(state, story) {
|
|
1539
|
+
const projected = this.projectStory(story);
|
|
1540
|
+
if (projected.isErr()) return projected;
|
|
1541
|
+
const projection = projected.value;
|
|
1542
|
+
if (state.doc !== projection.doc && !state.doc.eq(projection.doc)) return refuse("The story editor shows a stale canonical projection.");
|
|
1543
|
+
const selection = projection.selectionAt(state);
|
|
1544
|
+
if (selection.isErr()) {
|
|
1545
|
+
this.storySelections.delete(storyProjectionKey(story));
|
|
1546
|
+
return selection;
|
|
1547
|
+
}
|
|
1548
|
+
this.storySelections.set(storyProjectionKey(story), selection.value);
|
|
1549
|
+
return Result.ok(void 0);
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* The selection the editor of `story` last recorded or committed, moved
|
|
1553
|
+
* over every peer's edit since; null before its editor recorded one.
|
|
1554
|
+
*/
|
|
1555
|
+
storySelection(story) {
|
|
1556
|
+
return this.storySelections.get(storyProjectionKey(story)) ?? null;
|
|
1557
|
+
}
|
|
1069
1558
|
/** Every paragraph identity this session has read or minted, live or retired. */
|
|
1070
1559
|
get reservedBlockIds() {
|
|
1071
1560
|
return this.allocatedBlockIds;
|
|
1072
1561
|
}
|
|
1562
|
+
/** The ids this session may still mint, when it holds a lease. */
|
|
1563
|
+
get idLease() {
|
|
1564
|
+
return this.leased?.lease;
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Take the lease a room granted a session opened before it joined: from
|
|
1568
|
+
* then on every id it mints comes from the lease. Only an unedited session
|
|
1569
|
+
* without a lease takes one.
|
|
1570
|
+
*/
|
|
1571
|
+
adoptIdLease(lease) {
|
|
1572
|
+
if (this.leased !== void 0) return refuse("The session already holds an id lease.");
|
|
1573
|
+
if (this.currentVersion !== 0) return refuse("The session was edited before it took an id lease.");
|
|
1574
|
+
this.leased = new CanonicalIdLease(lease, this.currentDocument);
|
|
1575
|
+
return Result.ok(void 0);
|
|
1576
|
+
}
|
|
1577
|
+
/** Add blocks the authority granted; ids this session already minted stay spent. */
|
|
1578
|
+
extendIdLease(lease) {
|
|
1579
|
+
if (this.leased === void 0) return refuse("The session was created without an id lease.");
|
|
1580
|
+
this.leased.extend(lease);
|
|
1581
|
+
return Result.ok(void 0);
|
|
1582
|
+
}
|
|
1073
1583
|
get version() {
|
|
1074
1584
|
return this.currentVersion;
|
|
1075
1585
|
}
|
|
@@ -1107,14 +1617,19 @@ var CanonicalSession = class {
|
|
|
1107
1617
|
const checked = this.checkState(state, projection);
|
|
1108
1618
|
if (checked.isErr()) return checked;
|
|
1109
1619
|
if (!Number.isFinite(time)) return refuse("The input time is invalid.");
|
|
1110
|
-
if (from > to || hasIllegalXmlCharacters(text) || /[\t\r\n]/u.test(text)) return refuse("Canonical input accepts a well-formed text replacement.");
|
|
1620
|
+
if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to) || from < 0 || to > projection.doc.content.size || from > to || hasIllegalXmlCharacters(text) || /[\t\r\n]/u.test(text)) return refuse("Canonical input accepts a well-formed text replacement.");
|
|
1111
1621
|
if (from === to && text.length === 0) return noChange("The input makes no text change.");
|
|
1112
1622
|
const replacesStructuralSelection = state.selection instanceof AllSelection && from === state.selection.from && to === state.selection.to;
|
|
1113
1623
|
if (state.selection instanceof CellSelection) {
|
|
1114
1624
|
if (from !== state.selection.from || to !== state.selection.to) return refuse("A replacement range cannot partially address a cell selection.");
|
|
1625
|
+
const ranges = canonicalCellSelectionRanges(state.selection);
|
|
1626
|
+
const firstRange = ranges.at(0);
|
|
1627
|
+
const lastRange = ranges.at(-1);
|
|
1628
|
+
if (firstRange === void 0 || lastRange === void 0) return refuse("The selected cells contain no editable text.");
|
|
1115
1629
|
const intents = [];
|
|
1630
|
+
const commentChanges = [];
|
|
1116
1631
|
let first = true;
|
|
1117
|
-
for (const range of
|
|
1632
|
+
for (const range of ranges) {
|
|
1118
1633
|
const edges = projection.rangeEdgesAt(range.from, range.to);
|
|
1119
1634
|
const cellFrom = projection.inputAddressAt(range.from, edges.start);
|
|
1120
1635
|
if (cellFrom.isErr()) return cellFrom;
|
|
@@ -1126,8 +1641,23 @@ var CanonicalSession = class {
|
|
|
1126
1641
|
to: cellTo.value,
|
|
1127
1642
|
text: first ? text : ""
|
|
1128
1643
|
});
|
|
1644
|
+
commentChanges.push({
|
|
1645
|
+
from: range.from,
|
|
1646
|
+
to: range.to,
|
|
1647
|
+
text: first ? text : "",
|
|
1648
|
+
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1649
|
+
});
|
|
1129
1650
|
first = false;
|
|
1130
1651
|
}
|
|
1652
|
+
if (text !== "" && !preservesReplacementCommentAlignment({
|
|
1653
|
+
doc: state.doc,
|
|
1654
|
+
source: {
|
|
1655
|
+
from: firstRange.from,
|
|
1656
|
+
to: lastRange.to
|
|
1657
|
+
},
|
|
1658
|
+
changes: commentChanges,
|
|
1659
|
+
removal: this.replacementRemoval()
|
|
1660
|
+
})) return refuseUnder({ gap: CANONICAL_GAP.commentReplacementAlignment }, "Canonical replacement cannot preserve the aligned comment ranges.");
|
|
1131
1661
|
return this.prepareIntents(state, {
|
|
1132
1662
|
intents,
|
|
1133
1663
|
semantic
|
|
@@ -1145,17 +1675,33 @@ var CanonicalSession = class {
|
|
|
1145
1675
|
if (start.isErr()) return start;
|
|
1146
1676
|
const end = inputFrom === inputTo && editCaret !== void 0 ? Result.ok(editCaret) : projection.inputAddressAt(inputTo, edges.end);
|
|
1147
1677
|
if (end.isErr()) return end;
|
|
1678
|
+
if (inputFrom < inputTo && text !== "") {
|
|
1679
|
+
const retirement = planWholeParagraphReplacement({
|
|
1680
|
+
document: this.currentDocument,
|
|
1681
|
+
from: start.value,
|
|
1682
|
+
to: end.value,
|
|
1683
|
+
suggesting: this.mode.type === "suggesting" ? { author: this.mode.author } : void 0
|
|
1684
|
+
});
|
|
1685
|
+
if (retirement.isErr()) return refuse(retirement.error.message);
|
|
1686
|
+
if (!preservesReplacementCommentAlignment({
|
|
1687
|
+
doc: state.doc,
|
|
1688
|
+
retiredCommentIds: retirement.value?.commentIds,
|
|
1689
|
+
removal: this.replacementRemoval(),
|
|
1690
|
+
source: {
|
|
1691
|
+
from: inputFrom,
|
|
1692
|
+
to: inputTo
|
|
1693
|
+
},
|
|
1694
|
+
changes: [{
|
|
1695
|
+
from: inputFrom,
|
|
1696
|
+
to: inputTo,
|
|
1697
|
+
text,
|
|
1698
|
+
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1699
|
+
}]
|
|
1700
|
+
})) return refuseUnder({ gap: CANONICAL_GAP.commentReplacementAlignment }, "Canonical replacement cannot preserve the aligned comment ranges.");
|
|
1701
|
+
}
|
|
1148
1702
|
const preSelection = projection.selectionAt(state);
|
|
1149
1703
|
if (preSelection.isErr()) return preSelection;
|
|
1150
|
-
const
|
|
1151
|
-
const resolved = state.doc.resolve(position);
|
|
1152
|
-
return resolved.parent.type.name === "sdt" && resolved.parentOffset === (side === "start" ? 0 : resolved.parent.content.size);
|
|
1153
|
-
};
|
|
1154
|
-
const inside = {
|
|
1155
|
-
...innerEdge(inputFrom, "start") ? { start: true } : {},
|
|
1156
|
-
...innerEdge(inputTo, "end") ? { end: true } : {}
|
|
1157
|
-
};
|
|
1158
|
-
if (this.mode.type === "suggesting" && text.length > 0 && inside.start === true && inside.end === true && state.doc.resolve(inputFrom).parent === state.doc.resolve(inputTo).parent) return refuse("A suggestion over a content control's whole text is unavailable in this session.");
|
|
1704
|
+
const inside = controlEdgesAt(state.doc, inputFrom, inputTo);
|
|
1159
1705
|
const intent = {
|
|
1160
1706
|
type: "replaceText",
|
|
1161
1707
|
from: start.value,
|
|
@@ -1179,39 +1725,49 @@ var CanonicalSession = class {
|
|
|
1179
1725
|
const isCaret = state.selection.empty;
|
|
1180
1726
|
const deletion = isCaret && text.length === 0 && (semantic === "deleteBackward" || semantic === "deleteForward") ? deletionRange(state, semantic === "deleteBackward" ? "backward" : "forward") : null;
|
|
1181
1727
|
const grouping = isCaret && (semantic === "typing" && from === to && from === state.selection.head || deletion?.isOk() && deletion.value.from === from && deletion.value.to === to) ? "run" : "isolated";
|
|
1728
|
+
const groupingKey = {
|
|
1729
|
+
preSelection: preSelection.value,
|
|
1730
|
+
postSelection,
|
|
1731
|
+
semantic,
|
|
1732
|
+
grouping: compositionPhase === "correction" ? "compositionCorrection" : grouping,
|
|
1733
|
+
time,
|
|
1734
|
+
boundary: this.groupingBoundary
|
|
1735
|
+
};
|
|
1736
|
+
const group = this.applied.at(-1);
|
|
1737
|
+
const previous = group?.entries.at(-1);
|
|
1738
|
+
const joins = group !== void 0 && previous !== void 0 && continuesGroup(previous, groupingKey);
|
|
1182
1739
|
return this.stage({
|
|
1183
1740
|
state,
|
|
1184
1741
|
story,
|
|
1185
1742
|
ops,
|
|
1186
1743
|
selection: postSelection,
|
|
1187
1744
|
origin: "input",
|
|
1745
|
+
history: joins ? "joined" : "opened",
|
|
1746
|
+
...semantic === "typing" && inputFrom === inputTo && text.length > 0 ? { typing: {
|
|
1747
|
+
at: start.value,
|
|
1748
|
+
after: caret,
|
|
1749
|
+
text
|
|
1750
|
+
} } : {},
|
|
1188
1751
|
...compiled.value.applied === void 0 ? {} : { stagedApplied: compiled.value.applied },
|
|
1189
|
-
onPublish: (inverse, version) => {
|
|
1752
|
+
onPublish: (inverse, version, shown) => {
|
|
1190
1753
|
const entry = {
|
|
1191
1754
|
type: "applied",
|
|
1192
1755
|
ops,
|
|
1193
1756
|
inverse,
|
|
1194
|
-
|
|
1195
|
-
postSelection,
|
|
1757
|
+
...groupingKey,
|
|
1196
1758
|
preDocument,
|
|
1197
1759
|
postDocument: this.currentDocument,
|
|
1198
1760
|
version,
|
|
1199
|
-
origin: "input"
|
|
1200
|
-
semantic,
|
|
1201
|
-
grouping: compositionPhase === "correction" ? "compositionCorrection" : grouping,
|
|
1202
|
-
time,
|
|
1203
|
-
boundary: this.groupingBoundary
|
|
1761
|
+
origin: "input"
|
|
1204
1762
|
};
|
|
1205
|
-
|
|
1206
|
-
const previous = group?.entries.at(-1);
|
|
1207
|
-
if (group !== void 0 && previous !== void 0 && continuesGroup(previous, entry)) {
|
|
1763
|
+
if (group !== void 0 && joins) {
|
|
1208
1764
|
group.entries.push(entry);
|
|
1209
|
-
group.postSelection =
|
|
1765
|
+
group.postSelection = shown;
|
|
1210
1766
|
} else this.applied.push({
|
|
1211
1767
|
entries: [entry],
|
|
1212
1768
|
undo: { type: "entries" },
|
|
1213
1769
|
preSelection: preSelection.value,
|
|
1214
|
-
postSelection
|
|
1770
|
+
postSelection: shown
|
|
1215
1771
|
});
|
|
1216
1772
|
this.undone.length = 0;
|
|
1217
1773
|
}
|
|
@@ -1280,31 +1836,28 @@ var CanonicalSession = class {
|
|
|
1280
1836
|
edits.push(imported.value);
|
|
1281
1837
|
}
|
|
1282
1838
|
for (const intent of intents) {
|
|
1283
|
-
if (this.mode.type === "suggesting" && (intent.type === "setHyperlink" || intent.type === "removeHyperlink" || intent.type === "insertHyperlink" || intent.type === "generateTOC")) return Result.err(new CanonicalSessionError({
|
|
1284
|
-
ground: { gap: CANONICAL_GAP.trackedHyperlinkResolution },
|
|
1285
|
-
reason: "refused",
|
|
1286
|
-
message: "Hyperlink and TOC suggestions require serializable wrapper review provenance."
|
|
1287
|
-
}));
|
|
1288
1839
|
const compiled = compileEditorIntent(document, {
|
|
1289
1840
|
intent,
|
|
1290
1841
|
mode: this.intentMode(document, intent),
|
|
1291
1842
|
firstBlockId: this.nextBlockId
|
|
1292
1843
|
});
|
|
1293
|
-
if (compiled.isErr())
|
|
1294
|
-
if (compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE) return noChange(compiled.error.message);
|
|
1295
|
-
if (compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.UNTRACKABLE && (intent.type === "setHyperlink" || intent.type === "removeHyperlink" || intent.type === "insertHyperlink")) return Result.err(new CanonicalSessionError({
|
|
1296
|
-
ground: { gap: CANONICAL_GAP.trackedHyperlinkResolution },
|
|
1297
|
-
reason: "refused",
|
|
1298
|
-
message: compiled.error.message
|
|
1299
|
-
}));
|
|
1300
|
-
return refuse(compiled.error.message);
|
|
1301
|
-
}
|
|
1844
|
+
if (compiled.isErr()) return intentRefusal(intent, this.mode, compiled.error);
|
|
1302
1845
|
const applied = compiled.value.applied === void 0 ? applyDocumentOps(document, compiled.value.ops) : Result.ok(compiled.value.applied);
|
|
1303
|
-
if (applied.isErr()) return
|
|
1846
|
+
if (applied.isErr()) return intentRefusal(intent, this.mode, applied.error);
|
|
1304
1847
|
document = applied.value.document;
|
|
1305
1848
|
edits.push(applied.value);
|
|
1306
1849
|
ops.push(...compiled.value.ops);
|
|
1307
|
-
if (intent.type === "
|
|
1850
|
+
if (this.mode.type === "suggesting" && (intent.type === "setHyperlink" || intent.type === "removeHyperlink")) postSelection = {
|
|
1851
|
+
type: "text",
|
|
1852
|
+
anchor: intent.from,
|
|
1853
|
+
head: compiled.value.selection
|
|
1854
|
+
};
|
|
1855
|
+
else if (this.mode.type === "suggesting" && intent.type === "generateTOC") postSelection = {
|
|
1856
|
+
type: "text",
|
|
1857
|
+
anchor: compiled.value.selection,
|
|
1858
|
+
head: compiled.value.selection
|
|
1859
|
+
};
|
|
1860
|
+
else if (intent.type === "generateTOC") {
|
|
1308
1861
|
const mapping = {
|
|
1309
1862
|
at: intent.at,
|
|
1310
1863
|
after: compiled.value.selection,
|
|
@@ -1322,7 +1875,7 @@ var CanonicalSession = class {
|
|
|
1322
1875
|
}
|
|
1323
1876
|
const stagedApplied = {
|
|
1324
1877
|
...combineEdits(this.currentDocument, edits),
|
|
1325
|
-
|
|
1878
|
+
...combineRecordedRevisions(edits)
|
|
1326
1879
|
};
|
|
1327
1880
|
return this.prepareJournalledOps({
|
|
1328
1881
|
state,
|
|
@@ -1339,7 +1892,80 @@ var CanonicalSession = class {
|
|
|
1339
1892
|
postSelection
|
|
1340
1893
|
});
|
|
1341
1894
|
}
|
|
1342
|
-
|
|
1895
|
+
/** Verify compiled insertions and stage only the chain this session applied. */
|
|
1896
|
+
beginVerifiedOperationStaging(access, admission) {
|
|
1897
|
+
if (access !== canonicalOperationStagingAccess) panic("Only the public-operation compiler may stage verified operations.");
|
|
1898
|
+
const base = this.currentDocument;
|
|
1899
|
+
const version = this.currentVersion;
|
|
1900
|
+
const verified = /* @__PURE__ */ new WeakMap();
|
|
1901
|
+
let document = base;
|
|
1902
|
+
const ops = [];
|
|
1903
|
+
const effects = [];
|
|
1904
|
+
const recorded = [];
|
|
1905
|
+
return {
|
|
1906
|
+
apply: (before, input) => {
|
|
1907
|
+
const op = structuredClone(input);
|
|
1908
|
+
return applyDocumentOps(before, [op]).map((applied) => {
|
|
1909
|
+
const { document: next, inverse, touched, revisions, folded } = applied;
|
|
1910
|
+
const view = Object.freeze({
|
|
1911
|
+
document: next,
|
|
1912
|
+
revisions: Object.freeze([...revisions]),
|
|
1913
|
+
folded: Object.freeze([...folded])
|
|
1914
|
+
});
|
|
1915
|
+
verified.set(view, {
|
|
1916
|
+
before,
|
|
1917
|
+
document: next,
|
|
1918
|
+
op,
|
|
1919
|
+
effect: {
|
|
1920
|
+
inverse,
|
|
1921
|
+
touched
|
|
1922
|
+
},
|
|
1923
|
+
recorded: {
|
|
1924
|
+
revisions,
|
|
1925
|
+
folded
|
|
1926
|
+
}
|
|
1927
|
+
});
|
|
1928
|
+
return view;
|
|
1929
|
+
});
|
|
1930
|
+
},
|
|
1931
|
+
append: (view) => {
|
|
1932
|
+
const step = verified.get(view);
|
|
1933
|
+
if (step === void 0 || step.before !== document) return false;
|
|
1934
|
+
verified.delete(view);
|
|
1935
|
+
document = step.document;
|
|
1936
|
+
ops.push(step.op);
|
|
1937
|
+
effects.push(step.effect);
|
|
1938
|
+
recorded.push(step.recorded);
|
|
1939
|
+
return true;
|
|
1940
|
+
},
|
|
1941
|
+
prepare: (state, postSelection) => {
|
|
1942
|
+
if (version !== this.currentVersion || base !== this.currentDocument) return refuse("The compiled operations use a stale canonical document.");
|
|
1943
|
+
const combined = combineEdits(document, effects.map(({ inverse, touched }) => ({
|
|
1944
|
+
document,
|
|
1945
|
+
inverse,
|
|
1946
|
+
touched
|
|
1947
|
+
})));
|
|
1948
|
+
return this.prepareJournalledOps({
|
|
1949
|
+
state,
|
|
1950
|
+
ops: [...ops],
|
|
1951
|
+
postSelection,
|
|
1952
|
+
stagedApplied: {
|
|
1953
|
+
...combined,
|
|
1954
|
+
...combineRecordedRevisions(recorded)
|
|
1955
|
+
},
|
|
1956
|
+
admission
|
|
1957
|
+
});
|
|
1958
|
+
},
|
|
1959
|
+
/** Stage operations the compiler applied itself, under this admission. */
|
|
1960
|
+
prepareOps: (state, compiled, postSelection) => this.prepareJournalledOps({
|
|
1961
|
+
state,
|
|
1962
|
+
ops: compiled,
|
|
1963
|
+
postSelection,
|
|
1964
|
+
admission
|
|
1965
|
+
})
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
prepareJournalledOps({ state, ops, postSelection, stagedApplied, semantic = "structure", admission }) {
|
|
1343
1969
|
const story = postSelection.anchor.story;
|
|
1344
1970
|
const projected = this.projectStory(story);
|
|
1345
1971
|
if (projected.isErr()) return projected;
|
|
@@ -1353,14 +1979,16 @@ var CanonicalSession = class {
|
|
|
1353
1979
|
ops,
|
|
1354
1980
|
selection: postSelection,
|
|
1355
1981
|
origin: "input",
|
|
1982
|
+
history: "opened",
|
|
1356
1983
|
...stagedApplied === void 0 ? {} : { stagedApplied },
|
|
1357
|
-
|
|
1984
|
+
...admission === void 0 ? {} : { admission },
|
|
1985
|
+
onPublish: (inverse, version, shown) => {
|
|
1358
1986
|
const entry = {
|
|
1359
1987
|
type: "applied",
|
|
1360
1988
|
ops,
|
|
1361
1989
|
inverse,
|
|
1362
1990
|
preSelection: preSelection.value,
|
|
1363
|
-
postSelection,
|
|
1991
|
+
postSelection: shown,
|
|
1364
1992
|
preDocument,
|
|
1365
1993
|
postDocument: this.currentDocument,
|
|
1366
1994
|
version,
|
|
@@ -1374,19 +2002,61 @@ var CanonicalSession = class {
|
|
|
1374
2002
|
entries: [entry],
|
|
1375
2003
|
undo: { type: "entries" },
|
|
1376
2004
|
preSelection: preSelection.value,
|
|
1377
|
-
postSelection
|
|
2005
|
+
postSelection: shown
|
|
1378
2006
|
});
|
|
1379
2007
|
this.undone.length = 0;
|
|
1380
2008
|
}
|
|
1381
2009
|
});
|
|
1382
2010
|
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Bring derived content (a host's derived fields) in line with the edit
|
|
2013
|
+
* just published: one commit that joins that edit's undo step, so undoing
|
|
2014
|
+
* the edit undoes both. Refused when no local edit is open.
|
|
2015
|
+
*/
|
|
2016
|
+
prepareDerivedUpdate(state, ops) {
|
|
2017
|
+
const group = this.applied.at(-1);
|
|
2018
|
+
if (group === void 0) return noChange("A derived update joins a local edit.");
|
|
2019
|
+
if (ops.length === 0) return noChange("The derived content is already current.");
|
|
2020
|
+
const selection = group.postSelection;
|
|
2021
|
+
const story = selection.anchor.story;
|
|
2022
|
+
const projected = this.projectStory(story);
|
|
2023
|
+
if (projected.isErr()) return projected;
|
|
2024
|
+
const preDocument = this.currentDocument;
|
|
2025
|
+
return this.stage({
|
|
2026
|
+
state,
|
|
2027
|
+
story,
|
|
2028
|
+
ops,
|
|
2029
|
+
selection,
|
|
2030
|
+
origin: "input",
|
|
2031
|
+
history: "joined",
|
|
2032
|
+
onPublish: (inverse, version, shown) => {
|
|
2033
|
+
group.entries.push({
|
|
2034
|
+
type: "applied",
|
|
2035
|
+
ops,
|
|
2036
|
+
inverse,
|
|
2037
|
+
preSelection: selection,
|
|
2038
|
+
postSelection: shown,
|
|
2039
|
+
preDocument,
|
|
2040
|
+
postDocument: this.currentDocument,
|
|
2041
|
+
version,
|
|
2042
|
+
origin: "input",
|
|
2043
|
+
semantic: "structure",
|
|
2044
|
+
grouping: "isolated",
|
|
2045
|
+
time: Date.now(),
|
|
2046
|
+
boundary: this.groupingBoundary
|
|
2047
|
+
});
|
|
2048
|
+
group.postSelection = shown;
|
|
2049
|
+
this.undone.length = 0;
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
1383
2053
|
prepareSplit(state) {
|
|
1384
2054
|
const from = this.projection.inputAddressAt(state.selection.from);
|
|
1385
2055
|
if (from.isErr()) return from;
|
|
1386
2056
|
const to = this.projection.inputAddressAt(state.selection.to);
|
|
1387
2057
|
if (to.isErr()) return to;
|
|
1388
2058
|
const source = this.projection.paragraph(from.value.blockId);
|
|
1389
|
-
const nextStyle = (this.styles
|
|
2059
|
+
const nextStyle = (Object.hasOwn(this.currentDocument.package, "styles") ? this.currentDocument.package.styles : this.styles)?.styles.find(({ styleId }) => styleId === source?.source.formatting?.styleId)?.next;
|
|
1390
2060
|
const fresh = this.freshBlockId();
|
|
1391
2061
|
if (fresh.isErr()) return fresh;
|
|
1392
2062
|
const intents = [{
|
|
@@ -1439,16 +2109,17 @@ var CanonicalSession = class {
|
|
|
1439
2109
|
revisionIds: ids,
|
|
1440
2110
|
decision: resolution
|
|
1441
2111
|
}];
|
|
1442
|
-
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
return violation !== null;
|
|
2112
|
+
const changes = getTrackedChangeGroupsForIds(state.doc, revisionIds);
|
|
2113
|
+
const locks = canonicalRevisionLocks({
|
|
2114
|
+
document: this.currentDocument,
|
|
2115
|
+
story: OP_STORIES.MAIN,
|
|
2116
|
+
groups: changes,
|
|
2117
|
+
decision: resolution
|
|
1449
2118
|
});
|
|
1450
|
-
|
|
1451
|
-
|
|
2119
|
+
const firstHeld = locks.held.at(0);
|
|
2120
|
+
if (firstHeld !== void 0 && locks.held.length === changes.length) return lockRefusal(firstHeld.violation);
|
|
2121
|
+
const lockHeld = locks.held.flatMap(({ ids }) => ids);
|
|
2122
|
+
const resolved = locks.unlocked.flat();
|
|
1452
2123
|
const ops = [...before, ...resolved.length === 0 ? [] : resolve(resolved)];
|
|
1453
2124
|
const applied = applyDocumentOps(this.currentDocument, ops);
|
|
1454
2125
|
if (applied.isErr()) return refuse(applied.error.message);
|
|
@@ -1492,17 +2163,25 @@ var CanonicalSession = class {
|
|
|
1492
2163
|
* comments stay as ordinary comments.
|
|
1493
2164
|
*/
|
|
1494
2165
|
prepareSuggestion(state, { suggestionId, resolution, author, date }) {
|
|
1495
|
-
const
|
|
2166
|
+
const revisions = documentStories(this.currentDocument).map((story) => ({
|
|
2167
|
+
story,
|
|
2168
|
+
infos: suggestionRevisionInfos(this.currentDocument, story, suggestionId)
|
|
2169
|
+
})).filter(({ infos }) => infos.length > 0);
|
|
1496
2170
|
const commentIds = suggestedCommentIds(this.currentDocument, suggestionId);
|
|
1497
|
-
if (
|
|
2171
|
+
if (revisions.length === 0 && commentIds.length === 0) return noChange(`No pending suggestion ${suggestionId}.`);
|
|
1498
2172
|
if (resolution === "reject") return this.prepareResolve(state, {
|
|
1499
|
-
revisionIds:
|
|
2173
|
+
revisionIds: [],
|
|
1500
2174
|
resolution: "reject",
|
|
1501
|
-
before: commentIds.map((id) => ({
|
|
2175
|
+
before: [...commentIds.map((id) => ({
|
|
1502
2176
|
type: DOCUMENT_OP_TYPES.DELETE_COMMENT,
|
|
1503
2177
|
id,
|
|
1504
2178
|
scope: "thread"
|
|
1505
|
-
}))
|
|
2179
|
+
})), ...revisions.toSorted(({ story: left }, { story: right }) => Number(left === OP_STORIES.MAIN) - Number(right === OP_STORIES.MAIN)).map(({ story, infos }) => ({
|
|
2180
|
+
type: DOCUMENT_OP_TYPES.RESOLVE_REVISION,
|
|
2181
|
+
story,
|
|
2182
|
+
revisionIds: infos.map(({ id }) => id),
|
|
2183
|
+
decision: "reject"
|
|
2184
|
+
}))]
|
|
1506
2185
|
});
|
|
1507
2186
|
const checked = this.checkState(state);
|
|
1508
2187
|
if (checked.isErr()) return checked;
|
|
@@ -1510,9 +2189,9 @@ var CanonicalSession = class {
|
|
|
1510
2189
|
if (selection.isErr()) return selection;
|
|
1511
2190
|
const comments = this.currentDocument.package.document.comments ?? [];
|
|
1512
2191
|
const ops = [];
|
|
1513
|
-
|
|
2192
|
+
for (const { story, infos } of revisions) ops.push({
|
|
1514
2193
|
type: DOCUMENT_OP_TYPES.SET_REVISION_INFO,
|
|
1515
|
-
story
|
|
2194
|
+
story,
|
|
1516
2195
|
infos: infos.map(({ id }) => ({
|
|
1517
2196
|
id,
|
|
1518
2197
|
author,
|
|
@@ -1540,8 +2219,8 @@ var CanonicalSession = class {
|
|
|
1540
2219
|
return refuse("The canonical story no longer exists.");
|
|
1541
2220
|
}
|
|
1542
2221
|
const cached = this.storyProjections.get(key);
|
|
1543
|
-
const theme = this.currentDocument.package
|
|
1544
|
-
if (cached?.content === body.content && cached.theme === theme) return Result.ok(cached.projection);
|
|
2222
|
+
const { styles, theme } = this.currentDocument.package;
|
|
2223
|
+
if (cached?.content === body.content && cached.styles === styles && cached.theme === theme) return Result.ok(cached.projection);
|
|
1545
2224
|
const projected = project({
|
|
1546
2225
|
document: this.currentDocument,
|
|
1547
2226
|
styles: this.styles,
|
|
@@ -1551,6 +2230,7 @@ var CanonicalSession = class {
|
|
|
1551
2230
|
});
|
|
1552
2231
|
if (projected.isOk()) this.storyProjections.set(key, {
|
|
1553
2232
|
content: body.content,
|
|
2233
|
+
styles,
|
|
1554
2234
|
theme,
|
|
1555
2235
|
projection: projected.value
|
|
1556
2236
|
});
|
|
@@ -1588,7 +2268,7 @@ var CanonicalSession = class {
|
|
|
1588
2268
|
}],
|
|
1589
2269
|
openStart: 0,
|
|
1590
2270
|
openEnd: 0
|
|
1591
|
-
});
|
|
2271
|
+
}, this.leased?.lease);
|
|
1592
2272
|
const next = {
|
|
1593
2273
|
...op,
|
|
1594
2274
|
...this.mode.type === "suggesting" ? { revision: {
|
|
@@ -1624,14 +2304,15 @@ var CanonicalSession = class {
|
|
|
1624
2304
|
ops: preparedOps,
|
|
1625
2305
|
selection: postSelection,
|
|
1626
2306
|
origin: "input",
|
|
1627
|
-
|
|
2307
|
+
history: "opened",
|
|
2308
|
+
onPublish: (inverse, version, shown) => {
|
|
1628
2309
|
this.applied.push({
|
|
1629
2310
|
entries: [{
|
|
1630
2311
|
type: "applied",
|
|
1631
2312
|
ops: preparedOps,
|
|
1632
2313
|
inverse,
|
|
1633
2314
|
preSelection: selected.value,
|
|
1634
|
-
postSelection,
|
|
2315
|
+
postSelection: shown,
|
|
1635
2316
|
preDocument,
|
|
1636
2317
|
postDocument: this.currentDocument,
|
|
1637
2318
|
version,
|
|
@@ -1643,23 +2324,193 @@ var CanonicalSession = class {
|
|
|
1643
2324
|
}],
|
|
1644
2325
|
undo: { type: "entries" },
|
|
1645
2326
|
preSelection: selected.value,
|
|
1646
|
-
postSelection
|
|
2327
|
+
postSelection: shown
|
|
1647
2328
|
});
|
|
1648
2329
|
this.undone.length = 0;
|
|
1649
2330
|
}
|
|
1650
2331
|
});
|
|
1651
2332
|
}
|
|
2333
|
+
/**
|
|
2334
|
+
* A step rebased over a remote edit keeps its inverse's preconditions, so
|
|
2335
|
+
* it may no longer apply. Such a step is dropped with every step beneath
|
|
2336
|
+
* it, which were recorded on top of what it would have restored.
|
|
2337
|
+
*/
|
|
2338
|
+
rebasedStepApplies(group, ops, stack) {
|
|
2339
|
+
if (group.rebased !== true) return Result.ok(void 0);
|
|
2340
|
+
const applied = applyDocumentOps(this.currentDocument, ops);
|
|
2341
|
+
if (applied.isOk()) return Result.ok(applied.value);
|
|
2342
|
+
const dropped = stack === "undo" ? {
|
|
2343
|
+
undo: this.applied.length,
|
|
2344
|
+
redo: 0
|
|
2345
|
+
} : {
|
|
2346
|
+
undo: 0,
|
|
2347
|
+
redo: this.undone.length
|
|
2348
|
+
};
|
|
2349
|
+
if (stack === "undo") this.applied.length = 0;
|
|
2350
|
+
else this.undone.length = 0;
|
|
2351
|
+
this.reportHistoryDrop(dropped);
|
|
2352
|
+
return refuse(`The ${stack} step no longer applies after a remote edit: ${applied.error.message}`);
|
|
2353
|
+
}
|
|
2354
|
+
/** Called with every history drop a remote edit causes; returns the unsubscribe. */
|
|
2355
|
+
onHistoryDrop(listener) {
|
|
2356
|
+
this.historyDropListeners.add(listener);
|
|
2357
|
+
return () => {
|
|
2358
|
+
this.historyDropListeners.delete(listener);
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Called with every commit once it is published, after the editor and its
|
|
2363
|
+
* plugins accepted the projection and the session's history recorded it;
|
|
2364
|
+
* returns the unsubscribe. A collaboration binding sends exactly these.
|
|
2365
|
+
*/
|
|
2366
|
+
onCommitted(listener) {
|
|
2367
|
+
this.committedListeners.add(listener);
|
|
2368
|
+
return () => {
|
|
2369
|
+
this.committedListeners.delete(listener);
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
reportHistoryDrop(drop) {
|
|
2373
|
+
if (drop.undo === 0 && drop.redo === 0) return;
|
|
2374
|
+
for (const listener of this.historyDropListeners) listener(drop);
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Stage another actor's sequenced edit through the same path as a local
|
|
2378
|
+
* one. `change` is what the optimistic client reported: its ops apply to
|
|
2379
|
+
* this session's document, already rebased over the pending local batches.
|
|
2380
|
+
* It journals no undo step and opens no undo group. The local undo and redo
|
|
2381
|
+
* steps are rebased over it; a step that no longer rebases is dropped with
|
|
2382
|
+
* every step beneath it and reported to `onHistoryDrop`, and a `replaced`
|
|
2383
|
+
* change drops them all. The selection moves by paragraph id and offset,
|
|
2384
|
+
* over a `replaced` change's `moves` when it has them. It waits while a composition is pending; any other refusal means this
|
|
2385
|
+
* session no longer follows the shared document.
|
|
2386
|
+
*/
|
|
2387
|
+
prepareRemote(state, change, story = OP_STORIES.MAIN) {
|
|
2388
|
+
const projected = this.projectStory(story);
|
|
2389
|
+
if (projected.isErr()) return projected;
|
|
2390
|
+
const checked = this.checkState(state, projected.value);
|
|
2391
|
+
if (checked.isErr()) return checked;
|
|
2392
|
+
const applied = applyDocumentOps(this.currentDocument, change.batch.ops);
|
|
2393
|
+
if (applied.isErr()) return refuse(applied.error.message);
|
|
2394
|
+
const shown = projected.value.selectionAt(state);
|
|
2395
|
+
const before = shown.isOk() ? shown.value : this.currentSelection;
|
|
2396
|
+
const selection = remoteSelection({
|
|
2397
|
+
selection: before,
|
|
2398
|
+
over: change.type === "replaced" ? change.moves ?? change.batch : change.batch,
|
|
2399
|
+
previous: this.currentDocument,
|
|
2400
|
+
document: applied.value.document,
|
|
2401
|
+
story
|
|
2402
|
+
});
|
|
2403
|
+
const history = this.rebasedHistory(change, selection);
|
|
2404
|
+
const storySelections = [...this.storySelections].flatMap(([key, held]) => findStoryBody(applied.value.document, held.head.story) === void 0 ? [] : [[key, remoteSelection({
|
|
2405
|
+
selection: held,
|
|
2406
|
+
over: change.batch,
|
|
2407
|
+
previous: this.currentDocument,
|
|
2408
|
+
document: applied.value.document,
|
|
2409
|
+
story: held.head.story
|
|
2410
|
+
})]]);
|
|
2411
|
+
return this.stage({
|
|
2412
|
+
state,
|
|
2413
|
+
story,
|
|
2414
|
+
ops: change.batch.ops,
|
|
2415
|
+
selection,
|
|
2416
|
+
origin: "remote",
|
|
2417
|
+
history: "remote",
|
|
2418
|
+
stagedApplied: applied.value,
|
|
2419
|
+
previousProjection: projected.value,
|
|
2420
|
+
opId: change.batch.opId,
|
|
2421
|
+
onPublish: () => {
|
|
2422
|
+
this.storySelections.clear();
|
|
2423
|
+
for (const [key, moved] of storySelections) this.storySelections.set(key, moved);
|
|
2424
|
+
const shownStory = selection.head.story;
|
|
2425
|
+
if (shownStory !== OP_STORIES.MAIN && findStoryBody(applied.value.document, shownStory) !== void 0) this.storySelections.set(storyProjectionKey(shownStory), selection);
|
|
2426
|
+
this.applied.splice(0, this.applied.length, ...history.applied);
|
|
2427
|
+
this.undone.splice(0, this.undone.length, ...history.undone);
|
|
2428
|
+
this.breakUndoGroup();
|
|
2429
|
+
this.reportHistoryDrop(history.dropped);
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
/** Both history stacks as they stand after `change`, top steps first rebased. */
|
|
2434
|
+
rebasedHistory(change, fallback) {
|
|
2435
|
+
if (change.type === "replaced") return {
|
|
2436
|
+
applied: [],
|
|
2437
|
+
undone: [],
|
|
2438
|
+
dropped: {
|
|
2439
|
+
undo: this.applied.length,
|
|
2440
|
+
redo: this.undone.length
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
const groups = this.applied.toReversed();
|
|
2444
|
+
const applied = rebaseHistorySteps({
|
|
2445
|
+
document: this.currentDocument,
|
|
2446
|
+
over: change.batch,
|
|
2447
|
+
fallback,
|
|
2448
|
+
steps: groups.map((group) => ({
|
|
2449
|
+
ops: undoOpsOf(group),
|
|
2450
|
+
before: group.postSelection,
|
|
2451
|
+
after: group.preSelection
|
|
2452
|
+
}))
|
|
2453
|
+
}).flatMap((step, index) => {
|
|
2454
|
+
const group = groups.at(index);
|
|
2455
|
+
return group === void 0 ? [] : [{
|
|
2456
|
+
entries: group.entries,
|
|
2457
|
+
undo: {
|
|
2458
|
+
type: "replayed",
|
|
2459
|
+
inverse: step.ops
|
|
2460
|
+
},
|
|
2461
|
+
preSelection: step.after,
|
|
2462
|
+
postSelection: step.before,
|
|
2463
|
+
rebased: true
|
|
2464
|
+
}];
|
|
2465
|
+
});
|
|
2466
|
+
const undoneSteps = this.undone.toReversed();
|
|
2467
|
+
const undone = rebaseHistorySteps({
|
|
2468
|
+
document: this.currentDocument,
|
|
2469
|
+
over: change.batch,
|
|
2470
|
+
fallback,
|
|
2471
|
+
steps: undoneSteps.map(({ group, redoOps }) => ({
|
|
2472
|
+
ops: redoOps,
|
|
2473
|
+
before: group.preSelection,
|
|
2474
|
+
after: group.postSelection
|
|
2475
|
+
}))
|
|
2476
|
+
}).flatMap((step, index) => {
|
|
2477
|
+
const entry = undoneSteps.at(index);
|
|
2478
|
+
return entry === void 0 ? [] : [{
|
|
2479
|
+
type: "undone",
|
|
2480
|
+
group: {
|
|
2481
|
+
...entry.group,
|
|
2482
|
+
preSelection: step.before,
|
|
2483
|
+
postSelection: step.after,
|
|
2484
|
+
rebased: true
|
|
2485
|
+
},
|
|
2486
|
+
redoOps: step.ops
|
|
2487
|
+
}];
|
|
2488
|
+
});
|
|
2489
|
+
return {
|
|
2490
|
+
applied: applied.toReversed(),
|
|
2491
|
+
undone: undone.toReversed(),
|
|
2492
|
+
dropped: {
|
|
2493
|
+
undo: groups.length - applied.length,
|
|
2494
|
+
redo: undoneSteps.length - undone.length
|
|
2495
|
+
}
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
1652
2498
|
prepareUndo(state, story = OP_STORIES.MAIN) {
|
|
1653
2499
|
const group = this.applied.at(-1);
|
|
1654
2500
|
if (group === void 0) return refuse("There is no canonical edit to undo.");
|
|
1655
|
-
const
|
|
2501
|
+
const ops = undoOpsOf(group);
|
|
2502
|
+
const rebased = this.rebasedStepApplies(group, ops, "undo");
|
|
2503
|
+
if (rebased.isErr()) return rebased;
|
|
2504
|
+
const propertySourceDocument = group.rebased === true ? void 0 : group.entries.at(0)?.preDocument;
|
|
1656
2505
|
return this.stage({
|
|
1657
2506
|
state,
|
|
1658
2507
|
story,
|
|
1659
|
-
ops
|
|
2508
|
+
ops,
|
|
1660
2509
|
selection: group.preSelection,
|
|
1661
2510
|
origin: "undo",
|
|
2511
|
+
history: "undo",
|
|
1662
2512
|
...propertySourceDocument === void 0 ? {} : { propertySourceDocument },
|
|
2513
|
+
...rebased.value === void 0 ? {} : { stagedApplied: rebased.value },
|
|
1663
2514
|
onPublish: (redoOps) => {
|
|
1664
2515
|
this.applied.pop();
|
|
1665
2516
|
this.undone.push({
|
|
@@ -1674,14 +2525,18 @@ var CanonicalSession = class {
|
|
|
1674
2525
|
prepareRedo(state, story = OP_STORIES.MAIN) {
|
|
1675
2526
|
const undone = this.undone.at(-1);
|
|
1676
2527
|
if (undone === void 0) return refuse("There is no canonical edit to redo.");
|
|
1677
|
-
const
|
|
2528
|
+
const rebased = this.rebasedStepApplies(undone.group, undone.redoOps, "redo");
|
|
2529
|
+
if (rebased.isErr()) return rebased;
|
|
2530
|
+
const propertySourceDocument = undone.group.rebased === true ? void 0 : undone.group.entries.at(-1)?.postDocument;
|
|
1678
2531
|
return this.stage({
|
|
1679
2532
|
state,
|
|
1680
2533
|
story,
|
|
1681
2534
|
ops: undone.redoOps,
|
|
1682
2535
|
selection: undone.group.postSelection,
|
|
1683
2536
|
origin: "redo",
|
|
2537
|
+
history: "redo",
|
|
1684
2538
|
...propertySourceDocument === void 0 ? {} : { propertySourceDocument },
|
|
2539
|
+
...rebased.value === void 0 ? {} : { stagedApplied: rebased.value },
|
|
1685
2540
|
onPublish: (inverse) => {
|
|
1686
2541
|
this.undone.pop();
|
|
1687
2542
|
this.applied.push({
|
|
@@ -1691,13 +2546,14 @@ var CanonicalSession = class {
|
|
|
1691
2546
|
inverse
|
|
1692
2547
|
},
|
|
1693
2548
|
preSelection: undone.group.preSelection,
|
|
1694
|
-
postSelection: undone.group.postSelection
|
|
2549
|
+
postSelection: undone.group.postSelection,
|
|
2550
|
+
...undone.group.rebased === true ? { rebased: true } : {}
|
|
1695
2551
|
});
|
|
1696
2552
|
this.breakUndoGroup();
|
|
1697
2553
|
}
|
|
1698
2554
|
});
|
|
1699
2555
|
}
|
|
1700
|
-
stage({ state, ops, selection, origin, onPublish, propertySourceDocument, stagedApplied, story = OP_STORIES.MAIN, previousProjection }) {
|
|
2556
|
+
stage({ state, ops, selection, origin, history, onPublish, propertySourceDocument, stagedApplied, story = OP_STORIES.MAIN, previousProjection, opId, typing, admission = CANONICAL_ADMISSION.edit }) {
|
|
1701
2557
|
const previous = previousProjection === void 0 ? this.projectStory(story) : Result.ok(previousProjection);
|
|
1702
2558
|
if (previous.isErr()) return previous;
|
|
1703
2559
|
const checked = this.checkState(state, previous.value);
|
|
@@ -1705,40 +2561,46 @@ var CanonicalSession = class {
|
|
|
1705
2561
|
const applied = stagedApplied === void 0 ? applyDocumentOps(this.currentDocument, ops) : Result.ok(stagedApplied);
|
|
1706
2562
|
if (applied.isErr()) return refuse(applied.error.message);
|
|
1707
2563
|
if (applied.value.inverse.length === 0) return noChange("The intent makes no document change.");
|
|
1708
|
-
const locked = lockViolationBetween(this.currentDocument, applied.value.document);
|
|
2564
|
+
const locked = admission === CANONICAL_ADMISSION.restage ? null : lockViolationBetween(this.currentDocument, applied.value.document);
|
|
1709
2565
|
if (locked !== null) return lockRefusal(locked);
|
|
1710
|
-
if (propertySourceDocument !== void 0) preservePropertySources({
|
|
2566
|
+
if (propertySourceDocument !== void 0) applied.value.document = preservePropertySources({
|
|
1711
2567
|
target: applied.value.document,
|
|
1712
2568
|
source: propertySourceDocument,
|
|
1713
2569
|
indentation: "restore"
|
|
1714
2570
|
});
|
|
1715
2571
|
const normalized = normalizeCanonicalListRendering(applied.value.document, this.caches.lists);
|
|
1716
2572
|
applied.value.document = normalized.document;
|
|
1717
|
-
applied.value.inverse = normalized.inverse.concat(applied.value.inverse);
|
|
2573
|
+
applied.value.inverse = inverseMeetingDocument(normalized.document, normalized.inverse.concat(applied.value.inverse));
|
|
2574
|
+
const leaseJudgement = origin === "remote" ? this.leased?.admit(applied.value.document) : this.leased?.judge(applied.value.document);
|
|
2575
|
+
if (leaseJudgement?.type === "outside") return refuse(`The ${leaseJudgement.id.kind} id ${leaseJudgement.id.id} is outside this author's id lease.`);
|
|
1718
2576
|
const changed = changedStories({
|
|
1719
2577
|
document: applied.value.document,
|
|
1720
2578
|
previous: this.currentDocument
|
|
1721
2579
|
});
|
|
1722
|
-
if (
|
|
2580
|
+
if (unsupportedEditReason({
|
|
2581
|
+
previous: this.currentDocument,
|
|
2582
|
+
document: applied.value.document,
|
|
2583
|
+
stories: changed
|
|
2584
|
+
}) !== null) return Result.err(new CanonicalSessionError({
|
|
1723
2585
|
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
1724
2586
|
reason: "refused",
|
|
1725
2587
|
message: "The operations produce unsupported canonical story content."
|
|
1726
2588
|
}));
|
|
1727
|
-
preservePropertySources({
|
|
2589
|
+
applied.value.document = preservePropertySources({
|
|
1728
2590
|
target: applied.value.document,
|
|
1729
2591
|
source: this.currentDocument,
|
|
1730
2592
|
stories: changed
|
|
1731
2593
|
});
|
|
1732
|
-
if (propertySourceDocument !== void 0) preservePropertySources({
|
|
2594
|
+
if (propertySourceDocument !== void 0) applied.value.document = preservePropertySources({
|
|
1733
2595
|
target: applied.value.document,
|
|
1734
2596
|
source: propertySourceDocument
|
|
1735
2597
|
});
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
2598
|
+
applied.value.document = withParagraphCopies({
|
|
2599
|
+
document: applied.value.document,
|
|
2600
|
+
story: OP_STORIES.MAIN,
|
|
2601
|
+
copies: ownedSourceCopies(this.sourceOwners, changedWindow(this.currentDocument.package.document.content, applied.value.document.package.document.content).added)
|
|
2602
|
+
});
|
|
2603
|
+
const remembered = changedWindow(this.currentDocument.package.document.content, applied.value.document.package.document.content).added;
|
|
1742
2604
|
const projectedStory = findStoryBody(applied.value.document, story) ? story : OP_STORIES.MAIN;
|
|
1743
2605
|
const projected = project({
|
|
1744
2606
|
document: applied.value.document,
|
|
@@ -1762,6 +2624,18 @@ var CanonicalSession = class {
|
|
|
1762
2624
|
const transaction = state.tr;
|
|
1763
2625
|
const before = state.doc;
|
|
1764
2626
|
const after = projected.value.doc;
|
|
2627
|
+
const retainedTokens = /* @__PURE__ */ new Set();
|
|
2628
|
+
const retainPropertyOwner = (node) => {
|
|
2629
|
+
if (node.type.name !== "paragraph") return true;
|
|
2630
|
+
const id = node.attrs["paraId"];
|
|
2631
|
+
const token = getProseParagraphPropertySourceToken(node);
|
|
2632
|
+
const owner = typeof id === "string" ? previous.value.paragraph(id) : void 0;
|
|
2633
|
+
if (typeof token === "string" && owner !== void 0 && getProseParagraphPropertySourceToken(owner.node) === token) retainedTokens.add(token);
|
|
2634
|
+
return false;
|
|
2635
|
+
};
|
|
2636
|
+
const retainPropertyOwnersIn = (node) => {
|
|
2637
|
+
if (retainPropertyOwner(node)) node.descendants(retainPropertyOwner);
|
|
2638
|
+
};
|
|
1765
2639
|
let prefix = 0;
|
|
1766
2640
|
let from = 0;
|
|
1767
2641
|
while (prefix < before.childCount && prefix < after.childCount && before.child(prefix).eq(after.child(prefix))) {
|
|
@@ -1780,8 +2654,16 @@ var CanonicalSession = class {
|
|
|
1780
2654
|
const replacement = [];
|
|
1781
2655
|
for (let index = prefix; index < newEnd; index += 1) replacement.push(after.child(index));
|
|
1782
2656
|
transaction.replaceWith(from, to, Fragment.fromArray(replacement));
|
|
2657
|
+
replacement.forEach(retainPropertyOwnersIn);
|
|
2658
|
+
}
|
|
2659
|
+
if (!transaction.doc.eq(projected.value.doc)) {
|
|
2660
|
+
transaction.replaceWith(0, transaction.doc.content.size, projected.value.doc.content);
|
|
2661
|
+
after.forEach(retainPropertyOwnersIn);
|
|
1783
2662
|
}
|
|
1784
|
-
|
|
2663
|
+
markParagraphPropertySourceTransfers(transaction, [...retainedTokens].map((selectedToken) => ({
|
|
2664
|
+
displacedToken: null,
|
|
2665
|
+
selectedToken
|
|
2666
|
+
})));
|
|
1785
2667
|
for (const [name, value] of Object.entries(projected.value.doc.attrs)) if (transaction.doc.attrs[name] !== value) transaction.setDocAttribute(name, value);
|
|
1786
2668
|
if (sameStory(selection.anchor.story, projectedStory) && sameStory(selection.head.story, projectedStory)) {
|
|
1787
2669
|
if (!restoreCanonicalSelection({
|
|
@@ -1794,6 +2676,7 @@ var CanonicalSession = class {
|
|
|
1794
2676
|
}
|
|
1795
2677
|
})) return refuse("Canonical history cannot restore the selected inline atom.");
|
|
1796
2678
|
}
|
|
2679
|
+
const shown = (sameStory(selection.anchor.story, projectedStory) && sameStory(selection.head.story, projectedStory) ? placeShownSelection(transaction, projected.value) : void 0) ?? selection;
|
|
1797
2680
|
const held = projected.value.heldAs(transaction.doc);
|
|
1798
2681
|
const heldBody = bodyProjection.value === projected.value ? held : bodyProjection.value;
|
|
1799
2682
|
transaction.setMeta(CANONICAL_PROJECTION_META, {
|
|
@@ -1801,7 +2684,6 @@ var CanonicalSession = class {
|
|
|
1801
2684
|
origin,
|
|
1802
2685
|
version: this.version + 1
|
|
1803
2686
|
});
|
|
1804
|
-
if (ops.some(operationChangesPackage)) markPackageChange(transaction);
|
|
1805
2687
|
transaction.setMeta("addToHistory", false);
|
|
1806
2688
|
const baseVersion = this.version;
|
|
1807
2689
|
const baseBoundary = this.groupingBoundary;
|
|
@@ -1812,6 +2694,7 @@ var CanonicalSession = class {
|
|
|
1812
2694
|
});
|
|
1813
2695
|
return Result.ok({
|
|
1814
2696
|
transaction,
|
|
2697
|
+
ops,
|
|
1815
2698
|
document: applied.value.document,
|
|
1816
2699
|
projection: held,
|
|
1817
2700
|
bodyProjection: heldBody,
|
|
@@ -1819,6 +2702,7 @@ var CanonicalSession = class {
|
|
|
1819
2702
|
touched: applied.value.touched,
|
|
1820
2703
|
version: baseVersion + 1,
|
|
1821
2704
|
origin,
|
|
2705
|
+
history,
|
|
1822
2706
|
publish: () => {
|
|
1823
2707
|
if (this.isComposing || this.groupingBoundary !== baseBoundary) return refuse("The staged canonical commit crossed a composition or selection boundary.");
|
|
1824
2708
|
if (this.version !== baseVersion) return refuse("The staged canonical commit is stale.");
|
|
@@ -1829,49 +2713,69 @@ var CanonicalSession = class {
|
|
|
1829
2713
|
if (op.type === DOCUMENT_OP_TYPES.ADD_NOTE) for (const blockId of paragraphIdsIn(op.note.content)) this.allocatedBlockIds.add(blockId.toUpperCase());
|
|
1830
2714
|
}
|
|
1831
2715
|
this.advanceBlockId();
|
|
1832
|
-
this.rememberSources(
|
|
2716
|
+
this.rememberSources(remembered);
|
|
1833
2717
|
if (projectedStory !== OP_STORIES.MAIN) {
|
|
1834
2718
|
const body = findStoryBody(applied.value.document, projectedStory);
|
|
1835
2719
|
if (body === void 0) panic("A staged story projection lost its source.");
|
|
1836
2720
|
this.storyProjections.set(storyProjectionKey(projectedStory), {
|
|
1837
2721
|
content: body.content,
|
|
2722
|
+
styles: applied.value.document.package.styles,
|
|
1838
2723
|
theme: applied.value.document.package.theme,
|
|
1839
2724
|
projection: held
|
|
1840
2725
|
});
|
|
1841
2726
|
}
|
|
1842
2727
|
this.currentSelection = selection;
|
|
2728
|
+
const selectedStory = selection.head.story;
|
|
2729
|
+
if (selectedStory !== OP_STORIES.MAIN) this.storySelections.set(storyProjectionKey(selectedStory), selection);
|
|
2730
|
+
for (const [key, kept] of this.storySelections) if (findStoryBody(applied.value.document, kept.head.story) === void 0) this.storySelections.delete(key);
|
|
1843
2731
|
this.currentDocument = applied.value.document;
|
|
1844
2732
|
this.currentProjection = heldBody;
|
|
2733
|
+
if (leaseJudgement?.type === "allowed") this.leased?.commit(leaseJudgement.census, leaseJudgement.ids);
|
|
2734
|
+
const pending = this.pendingSaveBaseline;
|
|
1845
2735
|
for (const ids of [
|
|
1846
2736
|
applied.value.touched.modified,
|
|
1847
2737
|
applied.value.touched.inserted,
|
|
1848
2738
|
applied.value.touched.removed
|
|
1849
|
-
]) for (const id of ids)
|
|
1850
|
-
|
|
1851
|
-
|
|
2739
|
+
]) for (const id of ids) {
|
|
2740
|
+
this.saveTouched.add(id);
|
|
2741
|
+
this.touchedSinceOpen.add(id);
|
|
2742
|
+
pending?.touched.add(id);
|
|
2743
|
+
}
|
|
2744
|
+
const bodyOps = ops.filter((op) => !COMMENT_OPERATION_TYPES.has(op.type) && !editsHeaderFooter(op));
|
|
2745
|
+
if (bodyOps.some(operationChangesStructure) || bodyOps.some(operationChangesPackage) || bodyOps.length > 0 && (applied.value.touched.inserted.length > 0 || applied.value.touched.removed.length > 0)) {
|
|
2746
|
+
this.saveStructure = "changed";
|
|
2747
|
+
if (pending) pending.structure = "changed";
|
|
2748
|
+
}
|
|
1852
2749
|
this.currentVersion = baseVersion + 1;
|
|
1853
|
-
onPublish(applied.value.inverse, this.currentVersion);
|
|
2750
|
+
onPublish(applied.value.inverse, this.currentVersion, shown);
|
|
2751
|
+
const committed = {
|
|
2752
|
+
opId: opId ?? this.newOpId(),
|
|
2753
|
+
ops,
|
|
2754
|
+
inverse: applied.value.inverse,
|
|
2755
|
+
version: this.currentVersion,
|
|
2756
|
+
origin
|
|
2757
|
+
};
|
|
2758
|
+
if (typing !== void 0) recordCanonicalTyping(committed, typing);
|
|
2759
|
+
for (const listener of this.committedListeners) listener(committed);
|
|
1854
2760
|
return Result.ok(void 0);
|
|
1855
2761
|
}
|
|
1856
2762
|
});
|
|
1857
2763
|
}
|
|
1858
2764
|
};
|
|
1859
|
-
const createCanonicalSession = (document, styles) => {
|
|
2765
|
+
const createCanonicalSession = (document, styles, { idLease, newOpId } = {}) => {
|
|
1860
2766
|
const owned = cloneDocumentWithParagraphPropertySources(document);
|
|
1861
2767
|
const source = normalizeCanonicalSource(owned);
|
|
1862
2768
|
const unsupported = unsupportedSeedReason(source.document);
|
|
1863
2769
|
if (unsupported !== null) return refuse(unsupported);
|
|
1864
|
-
const identified =
|
|
1865
|
-
|
|
1866
|
-
target: identified,
|
|
2770
|
+
const identified = preservePropertySourcesWholeStories({
|
|
2771
|
+
target: normalizeForOps(source.document),
|
|
1867
2772
|
source: owned
|
|
1868
2773
|
});
|
|
1869
2774
|
const validated = validateOpsDocument(identified);
|
|
1870
2775
|
if (validated.isErr()) return refuse(validated.error.message);
|
|
1871
2776
|
const caches = newStoryProjectionCaches();
|
|
1872
|
-
const normalized =
|
|
1873
|
-
|
|
1874
|
-
target: normalized,
|
|
2777
|
+
const normalized = preservePropertySourcesWholeStories({
|
|
2778
|
+
target: normalizeCanonicalListRendering(identified, caches.lists).document,
|
|
1875
2779
|
source: owned
|
|
1876
2780
|
});
|
|
1877
2781
|
const projected = project({
|
|
@@ -1885,7 +2789,9 @@ const createCanonicalSession = (document, styles) => {
|
|
|
1885
2789
|
projection: projected.value,
|
|
1886
2790
|
styles,
|
|
1887
2791
|
sourceRestores: canonicalSourceRestores(normalized, source.normalized),
|
|
1888
|
-
caches
|
|
2792
|
+
caches,
|
|
2793
|
+
idLease,
|
|
2794
|
+
newOpId
|
|
1889
2795
|
}));
|
|
1890
2796
|
};
|
|
1891
2797
|
const hasDeletedParagraphMark = (node) => {
|
|
@@ -1986,11 +2892,43 @@ const deletionRange = (state, direction) => {
|
|
|
1986
2892
|
let boundary = visibleOffset + (direction === "backward" ? -1 : 1);
|
|
1987
2893
|
while (splitsGraphemeCluster(text, boundary)) boundary += direction === "backward" ? -1 : 1;
|
|
1988
2894
|
const from = physicalStarts.at(direction === "backward" ? boundary : visibleOffset);
|
|
1989
|
-
const to = physicalEnds
|
|
2895
|
+
const to = itemBefore(physicalEnds, direction === "backward" ? visibleOffset : boundary);
|
|
1990
2896
|
if (from === void 0 || to === void 0) panic("Canonical deletion lost a grapheme boundary.");
|
|
1991
2897
|
return Result.ok({
|
|
1992
2898
|
from,
|
|
1993
2899
|
to
|
|
1994
2900
|
});
|
|
1995
2901
|
};
|
|
1996
|
-
|
|
2902
|
+
/**
|
|
2903
|
+
* The deletion a browser measured (by word or by line) as the visible
|
|
2904
|
+
* characters its range covers whole, in the caret's paragraph: from the first
|
|
2905
|
+
* such character's start to the last one's end. Zero-width anchors at the
|
|
2906
|
+
* range's edges stay, as they do beside a plain character deletion; an inline
|
|
2907
|
+
* atom only partly covered stays; `null` when the range covers no visible
|
|
2908
|
+
* character.
|
|
2909
|
+
*/
|
|
2910
|
+
const measuredDeletionRange = (state, measured) => {
|
|
2911
|
+
const context = visibleDeletionContext(state);
|
|
2912
|
+
if (context.isErr()) return context;
|
|
2913
|
+
const { physicalStarts, physicalEnds } = context.value;
|
|
2914
|
+
let from;
|
|
2915
|
+
let to;
|
|
2916
|
+
for (const [unit, start] of physicalStarts.entries()) {
|
|
2917
|
+
const end = physicalEnds.at(unit);
|
|
2918
|
+
if (end === void 0) panic("Canonical deletion lost a visible character's end.");
|
|
2919
|
+
if (start < measured.from || end > measured.to) continue;
|
|
2920
|
+
from ??= start;
|
|
2921
|
+
to = end;
|
|
2922
|
+
}
|
|
2923
|
+
if (from === void 0 || to === void 0) return Result.ok(null);
|
|
2924
|
+
let noteMarkers = 0;
|
|
2925
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
2926
|
+
if (node.type.name === "noteMarker") noteMarkers += 1;
|
|
2927
|
+
});
|
|
2928
|
+
if (noteMarkers > 0) return refuse("Automatic note marks cannot be deleted as characters.");
|
|
2929
|
+
return Result.ok({
|
|
2930
|
+
from,
|
|
2931
|
+
to
|
|
2932
|
+
});
|
|
2933
|
+
};
|
|
2934
|
+
export { CANONICAL_ADMISSION, CANONICAL_PROJECTION_META, CanonicalSessionError, createCanonicalSession, deletionRange, isCanonicalJoinBoundary, isCanonicalProjectionTransaction, measuredDeletionRange, newStoryProjectionCaches, project as projectCanonicalStory, publishCanonicalProjection };
|