@stll/folio-core 0.68.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +4 -4
- package/dist/ai-edits/apply.d.ts +39 -16
- package/dist/ai-edits/apply.js +1014 -723
- package/dist/ai-edits/block-identity.d.ts +6 -0
- package/dist/ai-edits/block-identity.js +11 -1
- package/dist/ai-edits/blockRange.d.ts +9 -0
- package/dist/ai-edits/clean-text.d.ts +2 -0
- package/dist/ai-edits/clean-text.js +2 -1
- package/dist/ai-edits/comment-lifecycle.d.ts +24 -0
- package/dist/ai-edits/comment-lifecycle.js +17 -8
- package/dist/ai-edits/directJoin.d.ts +30 -0
- package/dist/ai-edits/directJoin.js +30 -0
- package/dist/ai-edits/existingRevisions.d.ts +9 -0
- package/dist/ai-edits/existingRevisions.js +30 -0
- package/dist/ai-edits/finalSectionReview.d.ts +11 -0
- package/dist/ai-edits/finalSectionReview.js +26 -0
- package/dist/ai-edits/headless.d.ts +275 -14
- package/dist/ai-edits/headless.js +1597 -195
- 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 +31 -7
- package/dist/ai-edits/newListNumbering.js +46 -8
- 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 +483 -22
- 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/canonical/canonicalLockGuard.d.ts +34 -0
- package/dist/canonical/canonicalLockGuard.js +208 -0
- package/dist/{controller → canonical}/canonicalOperations.js +1 -1
- package/dist/canonical/canonicalProjectionBlocks.d.ts +89 -0
- package/dist/canonical/canonicalProjectionBlocks.js +79 -0
- 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/canonical/canonicalSeedContent.js +179 -0
- package/dist/{controller → canonical}/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +515 -0
- package/dist/canonical/canonicalSession.js +2892 -0
- package/dist/canonical/canonicalSourceNormalization.d.ts +42 -0
- package/dist/canonical/canonicalSourceNormalization.js +166 -0
- package/dist/{controller → canonical}/canonicalTocSelection.js +1 -1
- package/dist/canonical/canonicalTrackedBatchFidelity.d.ts +9 -0
- package/dist/canonical/canonicalTrackedBatchFidelity.js +125 -0
- package/dist/canonical/canonicalWholeTextFidelity.d.ts +21 -0
- package/dist/canonical/canonicalWholeTextFidelity.js +88 -0
- package/dist/canonical/commentAnchorParagraph.d.ts +10 -0
- package/dist/canonical/commentAnchorParagraph.js +11 -0
- package/dist/canonical/controlEdges.d.ts +12 -0
- package/dist/canonical/controlEdges.js +17 -0
- package/dist/canonical/paragraphPatchAsRead.d.ts +19 -0
- package/dist/canonical/paragraphPatchAsRead.js +32 -0
- package/dist/canonical/propertySourcePreservation.d.ts +38 -0
- package/dist/canonical/propertySourcePreservation.js +129 -0
- package/dist/canonical/replacementRunSources.d.ts +29 -0
- package/dist/canonical/replacementRunSources.js +78 -0
- package/dist/compare/compare.d.ts +8 -6
- package/dist/compare/compare.js +37 -8
- package/dist/compare/content-alignment.d.ts +10 -1
- package/dist/compare/content-alignment.js +188 -27
- package/dist/compare/content.d.ts +9 -1
- package/dist/compare/content.js +2 -2
- package/dist/compare/formatting.d.ts +1 -0
- package/dist/compare/import-style-closure.d.ts +1 -1
- package/dist/compare/inline-atom-alignment.d.ts +83 -0
- package/dist/compare/inline-atom-alignment.js +173 -0
- package/dist/compare/inline-atoms-model.d.ts +65 -0
- package/dist/compare/inline-atoms-model.js +1131 -0
- package/dist/compare/inline-atoms.d.ts +4 -4
- package/dist/compare/inline-atoms.js +28 -139
- package/dist/compare/inline-provenance-model.d.ts +37 -0
- package/dist/compare/inline-provenance-model.js +138 -0
- package/dist/compare/inline-provenance.d.ts +52 -4
- package/dist/compare/inline-provenance.js +40 -7
- package/dist/compare/plan.d.ts +38 -4
- package/dist/compare/plan.js +22 -8
- package/dist/compare/scenario.d.ts +22 -1
- package/dist/compare/section-boundary-properties.d.ts +38 -5
- package/dist/compare/section-boundary-properties.js +164 -48
- package/dist/compare/style-resources.d.ts +3 -2
- package/dist/compare/style-resources.js +5 -4
- package/dist/compare/types.d.ts +5 -2
- package/dist/compare/verification.d.ts +24 -3
- package/dist/compare/verification.js +25 -18
- package/dist/compat/eigenpal.d.ts +32 -31
- package/dist/compat/eigenpal.js +3 -5
- package/dist/content-controls/findContentControls.d.ts +9 -0
- package/dist/content-controls/index.d.ts +8 -0
- package/dist/content-controls/mutateContentControls.d.ts +9 -0
- package/dist/controller/activeEditorStory.d.ts +1 -0
- package/dist/controller/anonymizationHighlights.d.ts +56 -0
- package/dist/controller/anonymizationHighlights.js +148 -0
- package/dist/controller/autocompleteSuggestion.d.ts +85 -0
- package/dist/controller/autocompleteSuggestion.js +213 -0
- package/dist/controller/canonicalClipboard.d.ts +2 -2
- package/dist/controller/canonicalClipboard.js +36 -16
- 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 +48 -13
- 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 +100 -17
- 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 +13 -1
- package/dist/controller/canonicalStoryEditor.js +55 -19
- 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 +21 -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 +17 -6
- package/dist/controller/headerFooterEditorManager.js +29 -25
- package/dist/controller/hiddenEditorApi.d.ts +97 -14
- package/dist/controller/hiddenEditorApi.js +44 -3
- package/dist/controller/hiddenEditorManager.d.ts +68 -16
- package/dist/controller/hiddenEditorManager.js +440 -85
- package/dist/controller/hyphenationReadiness.d.ts +10 -0
- package/dist/controller/layoutPipeline.d.ts +14 -12
- package/dist/controller/layoutPipeline.js +66 -54
- package/dist/controller/layoutSession.d.ts +10 -6
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/legacyTextAddress.d.ts +9 -0
- package/dist/controller/legacyTextAddress.js +52 -0
- package/dist/controller/noteEditorManager.d.ts +18 -6
- package/dist/controller/noteEditorManager.js +38 -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 +21 -11
- 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 +34 -4
- 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 +133 -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 +46 -1
- package/dist/docx/commentAnchorIndex.js +187 -7
- 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 +49 -21
- 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 +21 -2
- package/dist/docx/hostCommentThreads.js +25 -2
- 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 -143
- package/dist/docx/listNumberingInstances.d.ts +39 -9
- package/dist/docx/listNumberingInstances.js +91 -44
- 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/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingParser.d.ts +12 -0
- package/dist/docx/numberingReference.d.ts +10 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +19 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- 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 +60 -4
- package/dist/docx/paragraphPropertySource.js +239 -27
- 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 +105 -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/removeHeaderFooterParts.js +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 +284 -40
- 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 +46 -7
- 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 +3 -1
- package/dist/docx/serializer/partNamespaces.js +4 -2
- 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 +1 -1
- 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 +291 -69
- 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 +139 -35
- 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 +23 -19
- package/dist/docx/xmlParser.js +2 -20
- 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 +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/index.d.ts +33 -31
- package/dist/index.js +3 -4
- package/dist/internal/canonicalOperationStaging.d.ts +2 -0
- package/dist/internal/canonicalOperationStaging.js +4 -0
- package/dist/internal/canonicalTyping.d.ts +9 -0
- package/dist/internal/canonicalTyping.js +7 -0
- package/dist/internal/compare/inline-presentation.d.ts +8 -0
- package/dist/internal/indexedPositionMap.js +2 -1
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/revisionResolutionInline.js +13 -13
- package/dist/internal/revisionResolutionStep.js +1 -0
- package/dist/internal/revisionResolutionTracking.js +2 -1
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- 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/cellSelectionHighlight.js +3 -3
- 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/flowBlockPostprocessing.js +20 -12
- 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 +37 -8
- package/dist/layout-bridge/convert/flowConversionShared.js +39 -6
- 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 +25 -9
- package/dist/layout-bridge/convert/paragraphAttrs.js +12 -5
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +36 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +130 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +20 -6
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- 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 +7 -2
- 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/sectionBoundaries.js +16 -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 +200 -18
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +96 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +10 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +45 -44
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +1 -0
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- 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 +15 -14
- package/dist/layout-bridge/sectionColumns.d.ts +10 -1
- package/dist/layout-bridge/tableInsertHover.js +2 -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 +8 -0
- package/dist/layout-engine/measure/cache.js +9 -1
- 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 +20 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -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 +41 -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/imageLayout.js +2 -1
- package/dist/layout-painter/index.d.ts +12 -6
- package/dist/layout-painter/pageShellStyles.d.ts +19 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/previewSvg.d.ts +7 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +119 -0
- 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/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.d.ts +8 -0
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.d.ts +10 -3
- package/dist/layout-painter/renderPage.js +31 -33
- package/dist/layout-painter/renderParagraph.d.ts +6 -0
- package/dist/layout-painter/renderParagraph.js +36 -19
- package/dist/layout-painter/renderTable.d.ts +10 -1
- package/dist/layout-painter/renderTable.js +121 -36
- package/dist/layout-painter/renderTextBox.d.ts +9 -0
- package/dist/layout-painter/renderTextBox.js +2 -2
- 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/layout-painter/sdtBoundary.js +3 -2
- 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/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- 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 +26 -7
- package/dist/paged-layout/scrollToPmPosition.d.ts +15 -0
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- 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 +19 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- 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 +2 -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 +27 -2
- package/dist/prosemirror/commands/comments.js +459 -159
- 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 +154 -0
- package/dist/prosemirror/commentRecords.js +527 -0
- 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 +81 -61
- package/dist/prosemirror/conversion/index.d.ts +7 -2
- 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 +48 -14
- package/dist/prosemirror/conversion/toProseDoc.js +294 -145
- 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 +30 -3
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +65 -45
- 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/CommentExtension.js +3 -1
- 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/CommentReferenceExtension.js +3 -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 +51 -0
- package/dist/prosemirror/nativeSelection.js +124 -0
- 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/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -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 +34 -8
- package/dist/prosemirror/paragraphMarkJoin.js +176 -18
- 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 +24 -30
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +17 -0
- package/dist/prosemirror/plugins/documentNumbering.d.ts +2 -1
- package/dist/prosemirror/plugins/documentNumbering.js +33 -14
- 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 +225 -35
- 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 +30 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- 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 +21 -1
- 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/storyListNumbering.js +7 -2
- 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 +20 -9
- package/dist/prosemirror/tableResize.js +60 -49
- 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/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +5 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +6 -0
- package/dist/prosemirror/utils/visualLineNavigation.js +21 -19
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +84 -16
- 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/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RemoteSelectionOverlay.js +3 -3
- package/dist/render-dom/RenderedDomContext.js +7 -6
- 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 +52 -53
- package/dist/types/canonicalCapabilities.js +54 -56
- package/dist/types/canonicalSave.d.ts +36 -0
- package/dist/types/documentModel.d.ts +37 -0
- package/dist/types/documentModel.js +24 -0
- package/dist/types/docxSerialization.d.ts +10 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/remote-selection.d.ts +2 -1
- package/dist/types/selectiveSaveDecline.d.ts +44 -0
- package/dist/types/selectiveSaveDecline.js +0 -0
- package/dist/types/tableWidthKind.d.ts +2 -0
- package/dist/types/tableWidthKind.js +9 -0
- package/dist/utils/base64.d.ts +20 -0
- package/dist/utils/borderCss.d.ts +18 -1
- package/dist/utils/colorResolver.d.ts +12 -11
- package/dist/utils/createDocument.d.ts +8 -1
- package/dist/utils/createDocument.js +20 -2
- package/dist/utils/diagonalHatch.d.ts +2 -0
- package/dist/utils/diagonalHatch.js +16 -0
- package/dist/utils/extremes.d.ts +4 -0
- package/dist/utils/extremes.js +14 -0
- package/dist/utils/findMatchView.d.ts +2 -2
- package/dist/utils/findMatchView.js +4 -3
- 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 +21 -7
- 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/mergeDocumentContent.js +2 -2
- package/dist/utils/outlineHeadings.d.ts +1 -1
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- 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 -8
- package/dist/controller/canonicalLockGuard.d.ts +0 -8
- package/dist/controller/canonicalLockGuard.js +0 -88
- package/dist/controller/canonicalPublicOperations.js +0 -900
- package/dist/controller/canonicalSession.d.ts +0 -256
- package/dist/controller/canonicalSession.js +0 -1717
- 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,1717 +0,0 @@
|
|
|
1
|
-
import { splitsGraphemeCluster, splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
2
|
-
import { rangedCommentIds, visitCommentMarkers } from "../docx/commentAnchorIndex.js";
|
|
3
|
-
import { ListNormalizationCache } from "../docx/listModelNormalization.js";
|
|
4
|
-
import { cloneDocumentWithParagraphPropertySources, copyDocumentParagraphPropertySourceContract, copyParagraphPropertySource, restoreParagraphIndentationProjection } from "../docx/paragraphPropertySource.js";
|
|
5
|
-
import { visitInlineContentSlots } from "../docx/paragraphTraversal.js";
|
|
6
|
-
import { isCellMergeContinuation } from "../docx/tableParser.js";
|
|
7
|
-
import { calculateRowSpans } from "../docx/verticalMergeProjection.js";
|
|
8
|
-
import { canonicalCellSelectionRanges, canonicalContentPosition, canonicalSelectionRange } from "../prosemirror/canonicalSelectionRange.js";
|
|
9
|
-
import { expectCommentRangeBoundaryAttrs } from "../prosemirror/commentRangeBoundaryAttrs.js";
|
|
10
|
-
import { ProjectionBlockCache, collectPairedBookmarkIds, footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
11
|
-
import { markPackageChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
|
|
12
|
-
import { runFormattingPatchFromMarks } from "../prosemirror/runFormattingFromMarks.js";
|
|
13
|
-
import { CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
14
|
-
import { InlineProjectionCache, canonicalInlineSourceIssue, canonicalNativeCells, projectCanonicalInline } from "./canonicalInlineProjection.js";
|
|
15
|
-
import { normalizeCanonicalListRendering } from "./canonicalListRendering.js";
|
|
16
|
-
import { lockViolationBetween } from "./canonicalLockGuard.js";
|
|
17
|
-
import { restoreCanonicalSelection } from "./canonicalSelection.js";
|
|
18
|
-
import { mapTocSelection } from "./canonicalTocSelection.js";
|
|
19
|
-
import { Result, TaggedError, panic } from "better-result";
|
|
20
|
-
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
21
|
-
import { lockedControlMessage } from "@stll/docx-core/model";
|
|
22
|
-
import { Fragment } from "prosemirror-model";
|
|
23
|
-
import { CellSelection } from "prosemirror-tables";
|
|
24
|
-
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, commentDocumentIssue, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, normalizeForOps, packageParagraphIds, paragraphIdsIn, sameStory, suggestionRevisionInfos, survivingComments, validateOpsDocument } from "@stll/docx-core/ops";
|
|
25
|
-
import { AllSelection, NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
26
|
-
// src/controller/canonicalSession.ts
|
|
27
|
-
const CanonicalSessionErrorBase = TaggedError("CanonicalSessionError");
|
|
28
|
-
var CanonicalSessionError = class extends CanonicalSessionErrorBase {};
|
|
29
|
-
const refuse = (message) => Result.err(new CanonicalSessionError({
|
|
30
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
31
|
-
message,
|
|
32
|
-
reason: "refused"
|
|
33
|
-
}));
|
|
34
|
-
/** A change a content control's lock forbids: the document's rule, not a gap. */
|
|
35
|
-
const lockRefusal = (violation) => Result.err(new CanonicalSessionError({
|
|
36
|
-
ground: { rule: CANONICAL_RULE.contentControlLock },
|
|
37
|
-
message: `Refused: ${lockedControlMessage(violation)}`,
|
|
38
|
-
reason: "refused"
|
|
39
|
-
}));
|
|
40
|
-
const noChange = (message) => Result.err(new CanonicalSessionError({
|
|
41
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
42
|
-
message,
|
|
43
|
-
reason: "noChange"
|
|
44
|
-
}));
|
|
45
|
-
const COMMENT_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
46
|
-
DOCUMENT_OP_TYPES.CREATE_COMMENT,
|
|
47
|
-
DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT,
|
|
48
|
-
DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION,
|
|
49
|
-
DOCUMENT_OP_TYPES.DELETE_COMMENT,
|
|
50
|
-
DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE
|
|
51
|
-
]);
|
|
52
|
-
const operationChangesPackage = (op) => {
|
|
53
|
-
switch (op.type) {
|
|
54
|
-
case DOCUMENT_OP_TYPES.CREATE_COMMENT:
|
|
55
|
-
case DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT:
|
|
56
|
-
case DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION:
|
|
57
|
-
case DOCUMENT_OP_TYPES.DELETE_COMMENT:
|
|
58
|
-
case DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE:
|
|
59
|
-
case DOCUMENT_OP_TYPES.CREATE_HEADER_FOOTER:
|
|
60
|
-
case DOCUMENT_OP_TYPES.REMOVE_HEADER_FOOTER:
|
|
61
|
-
case DOCUMENT_OP_TYPES.ADD_NOTE:
|
|
62
|
-
case DOCUMENT_OP_TYPES.REMOVE_NOTE:
|
|
63
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_PROPS:
|
|
64
|
-
case DOCUMENT_OP_TYPES.RESTORE_STORY_PARTS:
|
|
65
|
-
case DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES:
|
|
66
|
-
case DOCUMENT_OP_TYPES.CREATE_NUMBERING_INSTANCE:
|
|
67
|
-
case DOCUMENT_OP_TYPES.DELETE_NUMBERING_INSTANCE:
|
|
68
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_ENDPOINT: return true;
|
|
69
|
-
default:
|
|
70
|
-
if ("story" in op) return !sameStory(op.story, OP_STORIES.MAIN);
|
|
71
|
-
if ("at" in op) return !sameStory(op.at.story, OP_STORIES.MAIN);
|
|
72
|
-
if ("from" in op) return !sameStory(op.from.story, OP_STORIES.MAIN);
|
|
73
|
-
return op;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const operationChangesStructure = (op) => {
|
|
77
|
-
switch (op.type) {
|
|
78
|
-
case DOCUMENT_OP_TYPES.DELETE_BLOCKS:
|
|
79
|
-
case DOCUMENT_OP_TYPES.INSERT_BLOCKS:
|
|
80
|
-
case DOCUMENT_OP_TYPES.SPLIT_BLOCK:
|
|
81
|
-
case DOCUMENT_OP_TYPES.JOIN_BLOCKS:
|
|
82
|
-
case DOCUMENT_OP_TYPES.REPLACE_BLOCKS:
|
|
83
|
-
case DOCUMENT_OP_TYPES.INSERT_TABLE:
|
|
84
|
-
case DOCUMENT_OP_TYPES.DELETE_TABLE:
|
|
85
|
-
case DOCUMENT_OP_TYPES.SET_CONTAINER_BLOCKS:
|
|
86
|
-
case DOCUMENT_OP_TYPES.INSERT_ROW:
|
|
87
|
-
case DOCUMENT_OP_TYPES.DELETE_ROW:
|
|
88
|
-
case DOCUMENT_OP_TYPES.SET_TABLE_ROWS:
|
|
89
|
-
case DOCUMENT_OP_TYPES.INSERT_COLUMN:
|
|
90
|
-
case DOCUMENT_OP_TYPES.DELETE_COLUMN:
|
|
91
|
-
case DOCUMENT_OP_TYPES.MERGE_CELLS:
|
|
92
|
-
case DOCUMENT_OP_TYPES.SPLIT_CELL:
|
|
93
|
-
case DOCUMENT_OP_TYPES.SET_TABLE:
|
|
94
|
-
case DOCUMENT_OP_TYPES.RESOLVE_REVISION:
|
|
95
|
-
case DOCUMENT_OP_TYPES.SET_TABLE_GRID:
|
|
96
|
-
case DOCUMENT_OP_TYPES.SET_CELL_PROPS:
|
|
97
|
-
case DOCUMENT_OP_TYPES.SET_ROW_PROPS:
|
|
98
|
-
case DOCUMENT_OP_TYPES.SET_TABLE_PROPS:
|
|
99
|
-
case DOCUMENT_OP_TYPES.SET_REVISION_INFO: return true;
|
|
100
|
-
case DOCUMENT_OP_TYPES.CREATE_HEADER_FOOTER:
|
|
101
|
-
case DOCUMENT_OP_TYPES.REMOVE_HEADER_FOOTER:
|
|
102
|
-
case DOCUMENT_OP_TYPES.ADD_NOTE:
|
|
103
|
-
case DOCUMENT_OP_TYPES.REMOVE_NOTE:
|
|
104
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_PROPS:
|
|
105
|
-
case DOCUMENT_OP_TYPES.RESTORE_STORY_PARTS:
|
|
106
|
-
case DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES:
|
|
107
|
-
case DOCUMENT_OP_TYPES.CREATE_NUMBERING_INSTANCE:
|
|
108
|
-
case DOCUMENT_OP_TYPES.DELETE_NUMBERING_INSTANCE:
|
|
109
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_ENDPOINT: return true;
|
|
110
|
-
case DOCUMENT_OP_TYPES.INSERT_TEXT:
|
|
111
|
-
case DOCUMENT_OP_TYPES.INSERT_CONTENT:
|
|
112
|
-
case DOCUMENT_OP_TYPES.DELETE_RANGE:
|
|
113
|
-
case DOCUMENT_OP_TYPES.SPLIT_INLINE:
|
|
114
|
-
case DOCUMENT_OP_TYPES.JOIN_INLINE:
|
|
115
|
-
case DOCUMENT_OP_TYPES.SET_RUN_PROPS:
|
|
116
|
-
case DOCUMENT_OP_TYPES.SET_PARAGRAPH_PROPS:
|
|
117
|
-
case DOCUMENT_OP_TYPES.SET_PARAGRAPH_REVIEW:
|
|
118
|
-
case DOCUMENT_OP_TYPES.REPLACE_INLINE:
|
|
119
|
-
case DOCUMENT_OP_TYPES.CREATE_COMMENT:
|
|
120
|
-
case DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT:
|
|
121
|
-
case DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION:
|
|
122
|
-
case DOCUMENT_OP_TYPES.DELETE_COMMENT:
|
|
123
|
-
case DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE: return false;
|
|
124
|
-
default: return op;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const operationChangesBodyProjection = (op) => {
|
|
128
|
-
switch (op.type) {
|
|
129
|
-
case DOCUMENT_OP_TYPES.CREATE_COMMENT:
|
|
130
|
-
case DOCUMENT_OP_TYPES.UPDATE_COMMENT_CONTENT:
|
|
131
|
-
case DOCUMENT_OP_TYPES.SET_COMMENT_RESOLUTION:
|
|
132
|
-
case DOCUMENT_OP_TYPES.DELETE_COMMENT:
|
|
133
|
-
case DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE:
|
|
134
|
-
case DOCUMENT_OP_TYPES.CREATE_HEADER_FOOTER:
|
|
135
|
-
case DOCUMENT_OP_TYPES.REMOVE_HEADER_FOOTER:
|
|
136
|
-
case DOCUMENT_OP_TYPES.ADD_NOTE:
|
|
137
|
-
case DOCUMENT_OP_TYPES.REMOVE_NOTE:
|
|
138
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_PROPS:
|
|
139
|
-
case DOCUMENT_OP_TYPES.RESTORE_STORY_PARTS:
|
|
140
|
-
case DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES:
|
|
141
|
-
case DOCUMENT_OP_TYPES.CREATE_NUMBERING_INSTANCE:
|
|
142
|
-
case DOCUMENT_OP_TYPES.DELETE_NUMBERING_INSTANCE:
|
|
143
|
-
case DOCUMENT_OP_TYPES.SET_SECTION_ENDPOINT: return true;
|
|
144
|
-
default:
|
|
145
|
-
if ("story" in op) return sameStory(op.story, OP_STORIES.MAIN);
|
|
146
|
-
if ("at" in op) return sameStory(op.at.story, OP_STORIES.MAIN);
|
|
147
|
-
if ("from" in op) return sameStory(op.from.story, OP_STORIES.MAIN);
|
|
148
|
-
return op;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const CANONICAL_PROJECTION_META = "folioCanonicalProjection";
|
|
152
|
-
/** Paragraph gaps bind logical units and source zero-width ordinals to PM positions. */
|
|
153
|
-
var CanonicalProjection = class CanonicalProjection {
|
|
154
|
-
doc;
|
|
155
|
-
story;
|
|
156
|
-
paragraphs;
|
|
157
|
-
paragraphsById;
|
|
158
|
-
constructor({ doc, paragraphs, story }) {
|
|
159
|
-
this.story = story;
|
|
160
|
-
this.doc = doc;
|
|
161
|
-
this.paragraphs = paragraphs;
|
|
162
|
-
this.paragraphsById = new Map(paragraphs.map((paragraph) => [paragraph.blockId, paragraph]));
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* The same projection held as `doc`, a document equal to this one's. A
|
|
166
|
-
* commit's transaction ends on a document equal to the projection it staged,
|
|
167
|
-
* sharing the blocks it left; holding that document lets the next commit see
|
|
168
|
-
* the state it was given is the projection without comparing every node.
|
|
169
|
-
*/
|
|
170
|
-
heldAs(doc) {
|
|
171
|
-
return new CanonicalProjection({
|
|
172
|
-
doc,
|
|
173
|
-
paragraphs: this.paragraphs,
|
|
174
|
-
story: this.story
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
addressAt(position, edge = "caret") {
|
|
178
|
-
if (!Number.isInteger(position)) return refuse("The input position is not an integer.");
|
|
179
|
-
position = canonicalContentPosition(this.doc, position);
|
|
180
|
-
const paragraph = this.paragraphs.find(({ start, node }) => position >= start && position <= start + node.content.size);
|
|
181
|
-
if (paragraph === void 0) return refuse("The input is outside a plain paragraph.");
|
|
182
|
-
const relative = position - paragraph.start;
|
|
183
|
-
const offset = paragraph.boundaries.findIndex((gaps) => gaps.some((gap) => gap.position === relative));
|
|
184
|
-
if (offset < 0) return refuse("The input splits an indivisible inline element.");
|
|
185
|
-
if (splitsSurrogatePair(paragraph.text, offset)) return refuse("The input would split a surrogate pair.");
|
|
186
|
-
const gaps = paragraph.boundaries.at(offset) ?? panic("Missing canonical boundary");
|
|
187
|
-
const index = gaps.findIndex((entry) => entry.position === relative);
|
|
188
|
-
const gap = gaps[index] ?? panic("Missing canonical native gap");
|
|
189
|
-
const seam = paragraph.seams.at(offset)?.[index] ?? panic("Missing canonical seam");
|
|
190
|
-
let ordinal = gap.zeroWidthBefore;
|
|
191
|
-
if (edge === "afterMarkers") ordinal = seam.last;
|
|
192
|
-
if (edge === "beforeMarkers") ordinal = seam.first;
|
|
193
|
-
return Result.ok({
|
|
194
|
-
story: this.story,
|
|
195
|
-
blockId: paragraph.blockId,
|
|
196
|
-
offset,
|
|
197
|
-
...gaps.length > 1 || ordinal > 0 || seam.first !== seam.last ? { zeroWidthBefore: ordinal } : {}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* The source gaps a selection from `from` to `to` replaces between. Its
|
|
202
|
-
* edges stay inside the markers beside them, so replacing exactly the
|
|
203
|
-
* words a comment covers keeps the comment on the new text. A selection of
|
|
204
|
-
* a paragraph's whole text takes that paragraph's markers with it: an edge
|
|
205
|
-
* at the very start of a paragraph whose text the selection covers to its
|
|
206
|
-
* end reaches before the markers there, and an edge at the very end of a
|
|
207
|
-
* paragraph the selection covers from its start reaches after them, so a
|
|
208
|
-
* comment on nothing but the replaced text is emptied, as removing the
|
|
209
|
-
* text would empty it.
|
|
210
|
-
*/
|
|
211
|
-
rangeEdgesAt(from, to) {
|
|
212
|
-
const paragraphOf = (position) => {
|
|
213
|
-
const content = canonicalContentPosition(this.doc, position);
|
|
214
|
-
return this.paragraphs.find(({ start, node }) => content >= start && content <= start + node.content.size);
|
|
215
|
-
};
|
|
216
|
-
const first = paragraphOf(from);
|
|
217
|
-
const last = paragraphOf(to);
|
|
218
|
-
const startsWhole = first !== void 0 && canonicalContentPosition(this.doc, from) === first.start && canonicalContentPosition(this.doc, to) >= first.start + first.node.content.size;
|
|
219
|
-
const endsWhole = last !== void 0 && canonicalContentPosition(this.doc, to) === last.start + last.node.content.size && canonicalContentPosition(this.doc, from) <= last.start;
|
|
220
|
-
return {
|
|
221
|
-
start: startsWhole ? "beforeMarkers" : "afterMarkers",
|
|
222
|
-
end: endsWhole ? "afterMarkers" : "beforeMarkers"
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
inputAddressAt(position, edge = "caret") {
|
|
226
|
-
const address = this.addressAt(position, edge);
|
|
227
|
-
if (address.isErr()) return address;
|
|
228
|
-
const paragraph = this.paragraph(address.value.blockId);
|
|
229
|
-
if (paragraph === void 0) panic("Input lost its paragraph.");
|
|
230
|
-
let destination = position;
|
|
231
|
-
paragraph.node.forEach((node, start) => {
|
|
232
|
-
if (node.marks.some((mark) => mark.type.name === "deletion") && destination > paragraph.start + start && destination < paragraph.start + start + node.nodeSize) destination = paragraph.start + start + node.nodeSize;
|
|
233
|
-
});
|
|
234
|
-
return destination === position ? address : this.addressAt(destination, edge);
|
|
235
|
-
}
|
|
236
|
-
positionAt(address) {
|
|
237
|
-
const paragraph = this.paragraph(address.blockId);
|
|
238
|
-
if (!sameStory(address.story, this.story) || paragraph === void 0 || !Number.isInteger(address.offset) || address.offset < 0 || address.offset > paragraph.text.length || splitsSurrogatePair(paragraph.text, address.offset)) return refuse("The canonical selection is outside a plain paragraph.");
|
|
239
|
-
const gaps = paragraph.boundaries.at(address.offset) ?? panic("Missing canonical boundary");
|
|
240
|
-
const seams = paragraph.seams.at(address.offset) ?? panic("Missing canonical seams");
|
|
241
|
-
const lastOrdinal = (seams.at(-1) ?? panic("Missing canonical seam")).last;
|
|
242
|
-
const ordinal = address.zeroWidthBefore ?? lastOrdinal;
|
|
243
|
-
const gap = gaps.find(({ zeroWidthBefore }) => zeroWidthBefore === ordinal) ?? gaps.find((_, index) => {
|
|
244
|
-
const seam = seams[index];
|
|
245
|
-
return seam !== void 0 && seam.first <= ordinal && ordinal <= seam.last;
|
|
246
|
-
});
|
|
247
|
-
if (!Number.isInteger(ordinal) || ordinal < 0 || ordinal > lastOrdinal) return refuse("The canonical selection is outside a paragraph gap.");
|
|
248
|
-
if (gap === void 0) return refuse("This source gap is inside a collapsed or erased inline boundary and has no editor position.");
|
|
249
|
-
return Result.ok(paragraph.start + gap.position);
|
|
250
|
-
}
|
|
251
|
-
selectionAt(state) {
|
|
252
|
-
const selection = state.selection;
|
|
253
|
-
let type;
|
|
254
|
-
let anchorPosition = selection.anchor;
|
|
255
|
-
let headPosition = selection.head;
|
|
256
|
-
if (selection instanceof TextSelection) type = "text";
|
|
257
|
-
else if (selection instanceof CellSelection) {
|
|
258
|
-
type = "cell";
|
|
259
|
-
anchorPosition = Selection.atStart(selection.$anchorCell.nodeAfter ?? panic("Missing anchor cell")).from + selection.$anchorCell.pos + 1;
|
|
260
|
-
headPosition = Selection.atEnd(selection.$headCell.nodeAfter ?? panic("Missing head cell")).to + selection.$headCell.pos + 1;
|
|
261
|
-
} else if (selection instanceof NodeSelection && selection.node.isInline && selection.node.isAtom && selection.node.type.name !== "noteMarker") type = "inlineNode";
|
|
262
|
-
else if (selection instanceof AllSelection) {
|
|
263
|
-
type = "all";
|
|
264
|
-
const range = canonicalSelectionRange(state);
|
|
265
|
-
anchorPosition = range.from;
|
|
266
|
-
headPosition = range.to;
|
|
267
|
-
} else return refuse("Canonical input requires text, an inline atom, or the whole document selection.");
|
|
268
|
-
const anchor = this.addressAt(anchorPosition);
|
|
269
|
-
if (anchor.isErr()) return anchor;
|
|
270
|
-
const head = this.addressAt(headPosition);
|
|
271
|
-
if (head.isErr()) return head;
|
|
272
|
-
return Result.ok({
|
|
273
|
-
type,
|
|
274
|
-
anchor: anchor.value,
|
|
275
|
-
head: head.value
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
/** The first paragraph the projection addresses, in document order. */
|
|
279
|
-
get firstParagraph() {
|
|
280
|
-
return this.paragraphs.at(0);
|
|
281
|
-
}
|
|
282
|
-
paragraph(blockId) {
|
|
283
|
-
return this.paragraphsById.get(blockId);
|
|
284
|
-
}
|
|
285
|
-
nextParagraphInContainer(blockId) {
|
|
286
|
-
const index = this.paragraphs.findIndex((paragraph) => paragraph.blockId === blockId);
|
|
287
|
-
if (index < 0) return void 0;
|
|
288
|
-
const paragraph = this.paragraphs.at(index);
|
|
289
|
-
const next = this.paragraphs.at(index + 1);
|
|
290
|
-
return paragraph?.container === next?.container ? next : void 0;
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
/** Immutable operations retain content identities for every untouched story. */
|
|
294
|
-
const changedStories = ({ document, previous }) => {
|
|
295
|
-
const stories = [];
|
|
296
|
-
if (document.package.document.content !== previous.package.document.content) stories.push(OP_STORIES.MAIN);
|
|
297
|
-
for (const kind of ["header", "footer"]) {
|
|
298
|
-
const parts = kind === "header" ? document.package.headers : document.package.footers;
|
|
299
|
-
const prior = kind === "header" ? previous.package.headers : previous.package.footers;
|
|
300
|
-
if (parts === prior) continue;
|
|
301
|
-
for (const [rId, body] of parts ?? []) if (body.content !== prior?.get(rId)?.content) stories.push({
|
|
302
|
-
kind,
|
|
303
|
-
rId
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
for (const kind of ["footnote", "endnote"]) {
|
|
307
|
-
const notes = kind === "footnote" ? document.package.footnotes : document.package.endnotes;
|
|
308
|
-
const prior = kind === "footnote" ? previous.package.footnotes : previous.package.endnotes;
|
|
309
|
-
if (notes === prior) continue;
|
|
310
|
-
const priorById = new Map(prior?.map((note) => [note.id, note]));
|
|
311
|
-
for (const note of notes ?? []) {
|
|
312
|
-
const original = priorById.get(note.id);
|
|
313
|
-
if (note.content !== original?.content || note.noteType !== original?.noteType) stories.push({
|
|
314
|
-
kind,
|
|
315
|
-
id: note.id
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return stories;
|
|
320
|
-
};
|
|
321
|
-
const preservePropertySources = ({ target, source, stories = documentStories(source), indentation = "derive" }) => {
|
|
322
|
-
const collectParagraphs = (blocks) => {
|
|
323
|
-
const paragraphs = [];
|
|
324
|
-
for (const block of blocks) {
|
|
325
|
-
if (block.type === "paragraph") {
|
|
326
|
-
paragraphs.push(block);
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
if (block.type !== "table") continue;
|
|
330
|
-
for (const row of block.rows) for (const cell of row.cells) paragraphs.push(...collectParagraphs(cell.content));
|
|
331
|
-
}
|
|
332
|
-
return paragraphs;
|
|
333
|
-
};
|
|
334
|
-
for (const story of stories) {
|
|
335
|
-
const originals = findStoryBody(source, story)?.content ?? [];
|
|
336
|
-
const derived = findStoryBody(target, story)?.content ?? [];
|
|
337
|
-
if (originals === derived) continue;
|
|
338
|
-
const originalParagraphs = collectParagraphs(originals);
|
|
339
|
-
const derivedParagraphs = collectParagraphs(derived);
|
|
340
|
-
const paragraphs = new Map(derivedParagraphs.flatMap((paragraph) => paragraph.paraId === void 0 ? [] : [[paragraph.paraId, paragraph]]));
|
|
341
|
-
for (const [index, original] of originalParagraphs.entries()) {
|
|
342
|
-
const next = original.paraId === void 0 ? derivedParagraphs.at(index) : paragraphs.get(original.paraId);
|
|
343
|
-
if (next !== void 0 && next !== original) {
|
|
344
|
-
copyParagraphPropertySource(next, original);
|
|
345
|
-
if (indentation === "restore") restoreParagraphIndentationProjection({
|
|
346
|
-
target: next,
|
|
347
|
-
source: original
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
copyDocumentParagraphPropertySourceContract(target, source);
|
|
353
|
-
};
|
|
354
|
-
const unsupportedSeedReason = (document, stories = documentStories(document)) => {
|
|
355
|
-
const commentIssue = commentDocumentIssue(document, "all");
|
|
356
|
-
if (commentIssue !== void 0) return commentIssue;
|
|
357
|
-
for (const story of stories) {
|
|
358
|
-
const body = findStoryBody(document, story);
|
|
359
|
-
if (story !== OP_STORIES.MAIN && (story.kind === "footnote" || story.kind === "endnote")) {
|
|
360
|
-
const note = (story.kind === "footnote" ? document.package.footnotes : document.package.endnotes)?.find(({ id }) => id === story.id);
|
|
361
|
-
if (note?.noteType !== void 0 && note.noteType !== "normal") continue;
|
|
362
|
-
}
|
|
363
|
-
const content = body?.content;
|
|
364
|
-
if (!content || content.length === 0) return "Canonical sessions require a nonempty paragraph story.";
|
|
365
|
-
const paragraphs = [];
|
|
366
|
-
const collect = (blocks) => {
|
|
367
|
-
for (const block of blocks) {
|
|
368
|
-
if (block.type === "paragraph") {
|
|
369
|
-
paragraphs.push(block);
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
if (block.type === "commentRangeStart" || block.type === "commentRangeEnd" || block.type === "bookmarkStart" || block.type === "bookmarkEnd" || block.type === "moveFromRangeStart" || block.type === "moveFromRangeEnd" || block.type === "moveToRangeStart" || block.type === "moveToRangeEnd") continue;
|
|
373
|
-
if (block.type === "preservedBlock") continue;
|
|
374
|
-
if (block.type === "blockSdt") {
|
|
375
|
-
const issue = collect(block.content);
|
|
376
|
-
if (issue !== null) return issue;
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
if (block.type !== "table") return "Canonical sessions currently require paragraphs, tables and supported inline atoms.";
|
|
380
|
-
for (const row of block.rows) for (const cell of row.cells) {
|
|
381
|
-
const issue = collect(cell.content);
|
|
382
|
-
if (issue !== null) return issue;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return null;
|
|
386
|
-
};
|
|
387
|
-
const blockIssue = collect(content);
|
|
388
|
-
if (blockIssue !== null) return blockIssue;
|
|
389
|
-
for (const paragraph of paragraphs) {
|
|
390
|
-
if (paragraph.reviewCarrier !== void 0) return "Canonical sessions currently require plain paragraphs and supported inline atoms.";
|
|
391
|
-
const issue = canonicalInlineSourceIssue(paragraph.content);
|
|
392
|
-
if (issue !== null) return issue;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return null;
|
|
396
|
-
};
|
|
397
|
-
const newStoryProjectionCaches = () => ({
|
|
398
|
-
blocks: new ProjectionBlockCache(),
|
|
399
|
-
inline: new InlineProjectionCache(),
|
|
400
|
-
lists: new ListNormalizationCache()
|
|
401
|
-
});
|
|
402
|
-
/** Whether a paragraph anchors a text box, which converts to a block of its own. */
|
|
403
|
-
const holdsTextBox = (paragraph) => {
|
|
404
|
-
let found = false;
|
|
405
|
-
visitInlineContentSlots(paragraph, ({ item }) => {
|
|
406
|
-
if (item.type === "run" && item.content.some((content) => content.type === "shape" && content.shape.textBody !== void 0)) found = true;
|
|
407
|
-
});
|
|
408
|
-
return found;
|
|
409
|
-
};
|
|
410
|
-
const project = ({ document, styles, story = OP_STORIES.MAIN, caches }) => {
|
|
411
|
-
const body = findStoryBody(document, story);
|
|
412
|
-
if (!body) return refuse("The canonical story no longer exists.");
|
|
413
|
-
const currentStyles = Object.hasOwn(document.package, "styles") ? document.package.styles : styles;
|
|
414
|
-
const options = {
|
|
415
|
-
...currentStyles == null ? {} : { styles: currentStyles },
|
|
416
|
-
...document.package.theme === void 0 ? {} : { theme: document.package.theme }
|
|
417
|
-
};
|
|
418
|
-
const converted = Result.try({
|
|
419
|
-
try: () => {
|
|
420
|
-
if (story === OP_STORIES.MAIN) return toProseDoc(document, caches === void 0 ? options : {
|
|
421
|
-
...options,
|
|
422
|
-
blockCache: caches.blocks
|
|
423
|
-
});
|
|
424
|
-
if (story.kind === "header" || story.kind === "footer") return headerFooterToProseDoc(body.content, options);
|
|
425
|
-
return footnoteToProseDoc(body.content, options);
|
|
426
|
-
},
|
|
427
|
-
catch: (cause) => new CanonicalSessionError({
|
|
428
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
429
|
-
reason: "refused",
|
|
430
|
-
message: `Canonical projection failed: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
431
|
-
})
|
|
432
|
-
});
|
|
433
|
-
if (converted.isErr()) return converted;
|
|
434
|
-
const pairedBookmarkIds = collectPairedBookmarkIds(body.content);
|
|
435
|
-
const commentContext = {
|
|
436
|
-
rangedIds: rangedCommentIds(body.content),
|
|
437
|
-
pointIds: /* @__PURE__ */ new Set(),
|
|
438
|
-
openIds: /* @__PURE__ */ new Set()
|
|
439
|
-
};
|
|
440
|
-
visitCommentMarkers(body.content, ({ item }) => {
|
|
441
|
-
if (item.type === "commentReference" && !commentContext.rangedIds.has(item.id)) commentContext.pointIds.add(item.id);
|
|
442
|
-
});
|
|
443
|
-
const sources = /* @__PURE__ */ new Map();
|
|
444
|
-
const allSources = /* @__PURE__ */ new Set();
|
|
445
|
-
const continuationSources = /* @__PURE__ */ new Set();
|
|
446
|
-
const collectSources = (blocks, insideSkippedContinuation = false) => {
|
|
447
|
-
for (const block of blocks) {
|
|
448
|
-
if (block.type === "paragraph") {
|
|
449
|
-
allSources.add(block);
|
|
450
|
-
if (insideSkippedContinuation) continuationSources.add(block);
|
|
451
|
-
if (block.paraId !== void 0) sources.set(block.paraId, {
|
|
452
|
-
source: block,
|
|
453
|
-
container: blocks
|
|
454
|
-
});
|
|
455
|
-
continue;
|
|
456
|
-
}
|
|
457
|
-
if (block.type === "blockSdt") {
|
|
458
|
-
collectSources(block.content, insideSkippedContinuation);
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
if (block.type !== "table") continue;
|
|
462
|
-
const rowSpans = calculateRowSpans(block);
|
|
463
|
-
for (const [rowIndex, row] of block.rows.entries()) {
|
|
464
|
-
let column = row.formatting?.gridBefore ?? 0;
|
|
465
|
-
for (const cell of row.cells) {
|
|
466
|
-
const skippedContinuation = isCellMergeContinuation(cell) && (rowSpans.get(`${rowIndex}-${column}`)?.skip ?? false);
|
|
467
|
-
collectSources(cell.content, insideSkippedContinuation || skippedContinuation);
|
|
468
|
-
column += cell.formatting?.gridSpan ?? 1;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
collectSources(body.content);
|
|
474
|
-
const paragraphs = [];
|
|
475
|
-
const projectedSources = /* @__PURE__ */ new Set();
|
|
476
|
-
const orderedSources = [...allSources];
|
|
477
|
-
const sourceOrder = new Map(orderedSources.map((source, index) => [source, index]));
|
|
478
|
-
const textBoxHosts = /* @__PURE__ */ new Set();
|
|
479
|
-
let nextSource = 0;
|
|
480
|
-
const claimTextBoxHost = () => {
|
|
481
|
-
let index = nextSource;
|
|
482
|
-
while (index < orderedSources.length && continuationSources.has(orderedSources[index] ?? panic("No source"))) index += 1;
|
|
483
|
-
const host = orderedSources[index];
|
|
484
|
-
if (host === void 0 || !holdsTextBox(host)) return false;
|
|
485
|
-
textBoxHosts.add(host);
|
|
486
|
-
nextSource = index + 1;
|
|
487
|
-
visitCommentMarkers([host], ({ item }) => {
|
|
488
|
-
if (item.type === "commentRangeStart") commentContext.openIds.add(item.id);
|
|
489
|
-
if (item.type === "commentRangeEnd") commentContext.openIds.delete(item.id);
|
|
490
|
-
});
|
|
491
|
-
return true;
|
|
492
|
-
};
|
|
493
|
-
let failure;
|
|
494
|
-
converted.value.descendants((node, offset, parent) => {
|
|
495
|
-
if (failure !== void 0) return false;
|
|
496
|
-
if (node.type.name === "textBox") {
|
|
497
|
-
if (node.attrs["_docxPlacement"] === "standalone" && node.attrs["_docxHostParagraph"] != null && !claimTextBoxHost()) failure = new CanonicalSessionError({
|
|
498
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
499
|
-
reason: "refused",
|
|
500
|
-
message: "The projection changed paragraph structure."
|
|
501
|
-
});
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
if (node.type.name === "blockCommentRangeBoundary") {
|
|
505
|
-
const { marker } = expectCommentRangeBoundaryAttrs(node);
|
|
506
|
-
if (marker.type === "commentRangeStart") commentContext.openIds.add(marker.id);
|
|
507
|
-
else commentContext.openIds.delete(marker.id);
|
|
508
|
-
return false;
|
|
509
|
-
}
|
|
510
|
-
if (node.type.name !== "paragraph") return true;
|
|
511
|
-
if (parent?.attrs["_omittedGridSlot"] != null) return false;
|
|
512
|
-
const paraId = node.attrs["paraId"];
|
|
513
|
-
const located = typeof paraId === "string" ? sources.get(paraId) : void 0;
|
|
514
|
-
if (typeof paraId !== "string" || located === void 0) {
|
|
515
|
-
failure = new CanonicalSessionError({
|
|
516
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
517
|
-
reason: "refused",
|
|
518
|
-
message: "The projection changed paragraph structure."
|
|
519
|
-
});
|
|
520
|
-
return false;
|
|
521
|
-
}
|
|
522
|
-
const { source, container } = located;
|
|
523
|
-
if (projectedSources.has(source)) {
|
|
524
|
-
failure = new CanonicalSessionError({
|
|
525
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
526
|
-
reason: "refused",
|
|
527
|
-
message: "The projection changed paragraph structure."
|
|
528
|
-
});
|
|
529
|
-
return false;
|
|
530
|
-
}
|
|
531
|
-
projectedSources.add(source);
|
|
532
|
-
nextSource = (sourceOrder.get(source) ?? panic("Unordered source")) + 1;
|
|
533
|
-
const inlineArgs = {
|
|
534
|
-
source,
|
|
535
|
-
paragraph: node,
|
|
536
|
-
pairedBookmarkIds,
|
|
537
|
-
commentContext
|
|
538
|
-
};
|
|
539
|
-
const inline = caches === void 0 ? projectCanonicalInline(inlineArgs) : caches.inline.project(inlineArgs);
|
|
540
|
-
if (inline.isErr()) {
|
|
541
|
-
failure = new CanonicalSessionError({
|
|
542
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
543
|
-
reason: "refused",
|
|
544
|
-
message: inline.error.message
|
|
545
|
-
});
|
|
546
|
-
return false;
|
|
547
|
-
}
|
|
548
|
-
paragraphs.push({
|
|
549
|
-
blockId: paraId,
|
|
550
|
-
container,
|
|
551
|
-
start: offset + 1,
|
|
552
|
-
...inline.value,
|
|
553
|
-
node,
|
|
554
|
-
source
|
|
555
|
-
});
|
|
556
|
-
visitCommentMarkers([source], ({ item }) => {
|
|
557
|
-
if (item.type === "commentRangeStart") commentContext.openIds.add(item.id);
|
|
558
|
-
if (item.type === "commentRangeEnd") commentContext.openIds.delete(item.id);
|
|
559
|
-
});
|
|
560
|
-
return false;
|
|
561
|
-
});
|
|
562
|
-
if (failure !== void 0) return Result.err(failure);
|
|
563
|
-
if (projectedSources.size + continuationSources.size + textBoxHosts.size !== allSources.size || [...projectedSources].some((source) => continuationSources.has(source) || textBoxHosts.has(source)) || [...textBoxHosts].some((source) => continuationSources.has(source))) return refuse("The projection changed paragraph structure.");
|
|
564
|
-
return Result.ok(new CanonicalProjection({
|
|
565
|
-
doc: converted.value,
|
|
566
|
-
paragraphs,
|
|
567
|
-
story
|
|
568
|
-
}));
|
|
569
|
-
};
|
|
570
|
-
const intentStory = (intent) => {
|
|
571
|
-
switch (intent.type) {
|
|
572
|
-
case "setHyperlink":
|
|
573
|
-
case "removeHyperlink":
|
|
574
|
-
case "insertHyperlink":
|
|
575
|
-
case "replaceFragment":
|
|
576
|
-
case "moveFragment":
|
|
577
|
-
case "replaceText":
|
|
578
|
-
case "formatRun":
|
|
579
|
-
case "insertAtom": return intent.from.story;
|
|
580
|
-
case "generateTOC":
|
|
581
|
-
case "splitParagraph":
|
|
582
|
-
case "formatParagraph": return intent.at.story;
|
|
583
|
-
case "setList": return intent.items.at(0)?.at.story ?? panic("A list intent requires a paragraph.");
|
|
584
|
-
case "joinParagraphs":
|
|
585
|
-
case "insertParagraphs": return intent.story;
|
|
586
|
-
case "table":
|
|
587
|
-
case "tableRow":
|
|
588
|
-
case "tableBlock": return intent.operation.story;
|
|
589
|
-
default: return intent;
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
const UNDO_GROUP_WINDOW_MS = 500;
|
|
593
|
-
const samePosition = (left, right) => sameStory(left.story, right.story) && left.blockId === right.blockId && left.offset === right.offset && (left.zeroWidthBefore ?? 0) === (right.zeroWidthBefore ?? 0);
|
|
594
|
-
const sameSelection = (left, right) => left.type === right.type && samePosition(left.anchor, right.anchor) && samePosition(left.head, right.head);
|
|
595
|
-
const continuesGroup = (previous, next) => {
|
|
596
|
-
switch (next.semantic) {
|
|
597
|
-
case "typing":
|
|
598
|
-
case "deleteBackward":
|
|
599
|
-
case "deleteForward": return previous.grouping === "run" && next.grouping === "run" && previous.semantic === next.semantic && previous.boundary === next.boundary && next.time >= previous.time && next.time - previous.time <= UNDO_GROUP_WINDOW_MS && sameSelection(previous.postSelection, next.preSelection) && samePosition(next.preSelection.anchor, next.preSelection.head);
|
|
600
|
-
case "composition": return next.grouping === "compositionCorrection" && previous.semantic === "composition" && previous.boundary === next.boundary && sameSelection(previous.postSelection, next.preSelection);
|
|
601
|
-
case "paste":
|
|
602
|
-
case "replacement":
|
|
603
|
-
case "structure": return false;
|
|
604
|
-
default: {
|
|
605
|
-
const unreachable = next.semantic;
|
|
606
|
-
return panic(`Unknown canonical input semantic ${unreachable}`);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
const authorizedProjections = /* @__PURE__ */ new WeakMap();
|
|
611
|
-
/** Metadata is descriptive; transaction identity and session version authorize mutations. */
|
|
612
|
-
const isCanonicalProjectionTransaction = (transaction, session) => {
|
|
613
|
-
const authorization = authorizedProjections.get(transaction);
|
|
614
|
-
return authorization?.session === session && authorization.version === session.version && transaction.doc.eq(authorization.doc);
|
|
615
|
-
};
|
|
616
|
-
/** The model publishes only after PM and every plugin accept its exact projection. */
|
|
617
|
-
const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
618
|
-
if (!isCanonicalProjectionTransaction(commit.transaction, session)) return refuse("The staged canonical projection is unauthorized.");
|
|
619
|
-
const applied = Result.try({
|
|
620
|
-
try: () => state.applyTransaction(commit.transaction),
|
|
621
|
-
catch: (cause) => new CanonicalSessionError({
|
|
622
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
623
|
-
reason: "refused",
|
|
624
|
-
message: `Canonical plugin staging failed: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
625
|
-
})
|
|
626
|
-
});
|
|
627
|
-
if (applied.isErr()) return applied;
|
|
628
|
-
const staged = applied.value;
|
|
629
|
-
if (!staged.transactions.includes(commit.transaction) || !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.");
|
|
630
|
-
const published = commit.publish();
|
|
631
|
-
if (published.isErr()) return published;
|
|
632
|
-
return Result.ok(staged);
|
|
633
|
-
};
|
|
634
|
-
const storyProjectionKey = (story) => {
|
|
635
|
-
switch (story.kind) {
|
|
636
|
-
case "header":
|
|
637
|
-
case "footer": return `${story.kind}:${story.rId}`;
|
|
638
|
-
case "footnote":
|
|
639
|
-
case "endnote": return `${story.kind}:${story.id}`;
|
|
640
|
-
default: return panic(`Unknown canonical story ${story}`);
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
/** Immutable model authority with a journal staged independently of the PM view. */
|
|
644
|
-
var CanonicalSession = class {
|
|
645
|
-
currentDocument;
|
|
646
|
-
currentProjection;
|
|
647
|
-
sourceBlockIds;
|
|
648
|
-
currentVersion = 0;
|
|
649
|
-
saveTouched = /* @__PURE__ */ new Set();
|
|
650
|
-
saveStructure = "stable";
|
|
651
|
-
allocateIntentIds = createEditorIntentIdAllocator();
|
|
652
|
-
mode = { type: "editing" };
|
|
653
|
-
allocatedBlockIds = /* @__PURE__ */ new Set();
|
|
654
|
-
nextBlockId = 1;
|
|
655
|
-
sourceOwners = /* @__PURE__ */ new Map();
|
|
656
|
-
storyProjections = /* @__PURE__ */ new Map();
|
|
657
|
-
currentSelection = null;
|
|
658
|
-
applied = [];
|
|
659
|
-
groupingBoundary = 0;
|
|
660
|
-
lifecycle = { type: "committed" };
|
|
661
|
-
undone = [];
|
|
662
|
-
styles;
|
|
663
|
-
/** What earlier projections converted, reused by every later one. */
|
|
664
|
-
caches;
|
|
665
|
-
constructor({ document, projection, styles, caches }) {
|
|
666
|
-
this.caches = caches;
|
|
667
|
-
this.currentDocument = document;
|
|
668
|
-
this.currentProjection = projection;
|
|
669
|
-
this.sourceBlockIds = new Set(packageParagraphIds(document.package));
|
|
670
|
-
for (const blockId of packageParagraphIds(document.package)) this.allocatedBlockIds.add(blockId.toUpperCase());
|
|
671
|
-
this.advanceBlockId();
|
|
672
|
-
this.styles = styles == null ? styles : structuredClone(styles);
|
|
673
|
-
this.rememberSources(document);
|
|
674
|
-
}
|
|
675
|
-
/** Render only the committed comment projection while provisional IME blocks document snapshots. */
|
|
676
|
-
getCommittedComments() {
|
|
677
|
-
return structuredClone(survivingComments(this.currentDocument));
|
|
678
|
-
}
|
|
679
|
-
setMode(mode) {
|
|
680
|
-
if (this.mode.type !== mode.type || this.mode.type === "suggesting" && mode.type === "suggesting" && this.mode.author !== mode.author) this.breakUndoGroup();
|
|
681
|
-
this.mode = mode.type === "editing" ? { type: "editing" } : {
|
|
682
|
-
type: "suggesting",
|
|
683
|
-
author: mode.author
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
hasStyle(styleId) {
|
|
687
|
-
return (this.styles ?? this.currentDocument.package.styles)?.styles.some((style) => style.styleId === styleId) ?? false;
|
|
688
|
-
}
|
|
689
|
-
advanceBlockId() {
|
|
690
|
-
while (this.allocatedBlockIds.has(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase())) this.nextBlockId += 1;
|
|
691
|
-
}
|
|
692
|
-
freshBlockId() {
|
|
693
|
-
if (this.nextBlockId > 2147483647) return refuse("The paragraph identity space is exhausted.");
|
|
694
|
-
return Result.ok(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase());
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Paragraph identities for one prepared batch, one group per requested count;
|
|
698
|
-
* none matches a live or retired identity and no two groups overlap. Nothing is
|
|
699
|
-
* reserved until the batch applies, so a batch asks once for all its groups.
|
|
700
|
-
*/
|
|
701
|
-
freshBlockIds(counts) {
|
|
702
|
-
const total = counts.reduce((sum, count) => sum + count, 0);
|
|
703
|
-
const ids = [];
|
|
704
|
-
for (let candidate = this.nextBlockId; ids.length < total; candidate += 1) {
|
|
705
|
-
if (candidate > 2147483647) return refuse("The paragraph identity space is exhausted.");
|
|
706
|
-
const id = candidate.toString(16).padStart(8, "0").toUpperCase();
|
|
707
|
-
if (!this.allocatedBlockIds.has(id)) ids.push(id);
|
|
708
|
-
}
|
|
709
|
-
const groups = [];
|
|
710
|
-
let offset = 0;
|
|
711
|
-
for (const count of counts) {
|
|
712
|
-
groups.push(ids.slice(offset, offset + count));
|
|
713
|
-
offset += count;
|
|
714
|
-
}
|
|
715
|
-
return Result.ok(groups);
|
|
716
|
-
}
|
|
717
|
-
intentMode(document, intent) {
|
|
718
|
-
if (this.mode.type === "editing" && !this.intentNeedsIdentityIds(document, intent)) return {
|
|
719
|
-
type: "editing",
|
|
720
|
-
reservedBlockIds: this.allocatedBlockIds
|
|
721
|
-
};
|
|
722
|
-
const ids = this.allocateIntentIds(document, intent);
|
|
723
|
-
return this.mode.type === "editing" ? {
|
|
724
|
-
type: "editing",
|
|
725
|
-
newIds: ids.newIds,
|
|
726
|
-
reservedBlockIds: this.allocatedBlockIds
|
|
727
|
-
} : {
|
|
728
|
-
type: "suggesting",
|
|
729
|
-
reservedBlockIds: this.allocatedBlockIds,
|
|
730
|
-
revision: {
|
|
731
|
-
id: ids.revisionId,
|
|
732
|
-
author: this.mode.author,
|
|
733
|
-
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
734
|
-
},
|
|
735
|
-
newIds: ids.newIds
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
intentNeedsIdentityIds(document, intent) {
|
|
739
|
-
let blockIds;
|
|
740
|
-
switch (intent.type) {
|
|
741
|
-
case "table":
|
|
742
|
-
case "tableRow":
|
|
743
|
-
case "tableBlock":
|
|
744
|
-
case "insertParagraphs": return true;
|
|
745
|
-
case "generateTOC":
|
|
746
|
-
case "setList":
|
|
747
|
-
case "formatParagraph": return false;
|
|
748
|
-
case "setHyperlink":
|
|
749
|
-
case "removeHyperlink":
|
|
750
|
-
case "insertHyperlink":
|
|
751
|
-
case "replaceFragment":
|
|
752
|
-
case "moveFragment": return true;
|
|
753
|
-
case "replaceText":
|
|
754
|
-
case "insertAtom":
|
|
755
|
-
case "formatRun":
|
|
756
|
-
if (intent.from.blockId !== intent.to.blockId) return true;
|
|
757
|
-
blockIds = [intent.from.blockId];
|
|
758
|
-
break;
|
|
759
|
-
case "splitParagraph":
|
|
760
|
-
if (intent.to !== void 0 && intent.at.blockId !== intent.to.blockId) return true;
|
|
761
|
-
blockIds = [intent.at.blockId];
|
|
762
|
-
break;
|
|
763
|
-
case "joinParagraphs":
|
|
764
|
-
blockIds = [intent.blockId, intent.nextBlockId];
|
|
765
|
-
break;
|
|
766
|
-
default: return intent;
|
|
767
|
-
}
|
|
768
|
-
const hasIdentity = (value) => {
|
|
769
|
-
if (typeof value !== "object" || value === null) return false;
|
|
770
|
-
if (Array.isArray(value)) return value.some(hasIdentity);
|
|
771
|
-
if ("id" in value && typeof value.id === "number" && ("author" in value || "sdtType" in value)) return true;
|
|
772
|
-
return Object.values(value).some(hasIdentity);
|
|
773
|
-
};
|
|
774
|
-
const story = intentStory(intent);
|
|
775
|
-
return blockIds.some((blockId) => {
|
|
776
|
-
const paragraph = document === this.currentDocument && story === OP_STORIES.MAIN ? this.currentProjection.paragraph(blockId)?.source : findStoryBody(document, story)?.content.find((block) => block.type === "paragraph" && block.paraId === blockId);
|
|
777
|
-
return paragraph !== void 0 && hasIdentity(paragraph);
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
rememberSources(document) {
|
|
781
|
-
for (const block of document.package.document.content) if (block.type === "paragraph" && block.paraId !== void 0) this.sourceOwners.set(block.paraId, block);
|
|
782
|
-
}
|
|
783
|
-
get document() {
|
|
784
|
-
if (this.isComposing) throw new CanonicalSessionError({
|
|
785
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
786
|
-
reason: "refused",
|
|
787
|
-
message: "Composition must finish before taking a snapshot."
|
|
788
|
-
});
|
|
789
|
-
return this.currentDocument;
|
|
790
|
-
}
|
|
791
|
-
captureSaveSnapshot() {
|
|
792
|
-
if (this.isComposing) throw new CanonicalSessionError({
|
|
793
|
-
ground: { gap: CANONICAL_GAP.save },
|
|
794
|
-
reason: "refused",
|
|
795
|
-
message: "Composition must finish before saving the canonical document."
|
|
796
|
-
});
|
|
797
|
-
const retainedBlockIdKeys = new Set([...this.sourceBlockIds, ...packageParagraphIds(this.currentDocument.package)].map((blockId) => blockId.toUpperCase()));
|
|
798
|
-
return {
|
|
799
|
-
document: cloneDocumentWithParagraphPropertySources(this.currentDocument),
|
|
800
|
-
version: this.currentVersion,
|
|
801
|
-
changedBlockIds: [...this.saveTouched].filter((blockId) => retainedBlockIdKeys.has(blockId.toUpperCase())),
|
|
802
|
-
structure: this.saveStructure
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
get projection() {
|
|
806
|
-
return this.currentProjection;
|
|
807
|
-
}
|
|
808
|
-
/** The caret the last published edit returned, when the editor shows it at `position`. */
|
|
809
|
-
editCaretAt(projection, position) {
|
|
810
|
-
const caret = this.currentSelection;
|
|
811
|
-
if (caret === null || caret.type !== "text" || caret.anchor.offset !== caret.head.offset || caret.anchor.blockId !== caret.head.blockId || (caret.anchor.zeroWidthBefore ?? null) !== (caret.head.zeroWidthBefore ?? null) || !sameStory(caret.head.story, projection.story)) return void 0;
|
|
812
|
-
const shown = projection.positionAt(caret.head);
|
|
813
|
-
return shown.isOk() && shown.value === position ? caret.head : void 0;
|
|
814
|
-
}
|
|
815
|
-
get selection() {
|
|
816
|
-
return this.currentSelection;
|
|
817
|
-
}
|
|
818
|
-
get version() {
|
|
819
|
-
return this.currentVersion;
|
|
820
|
-
}
|
|
821
|
-
get canUndo() {
|
|
822
|
-
return this.applied.length > 0;
|
|
823
|
-
}
|
|
824
|
-
get canRedo() {
|
|
825
|
-
return this.undone.length > 0;
|
|
826
|
-
}
|
|
827
|
-
get isComposing() {
|
|
828
|
-
return this.lifecycle.type === "composing";
|
|
829
|
-
}
|
|
830
|
-
breakUndoGroup() {
|
|
831
|
-
this.groupingBoundary += 1;
|
|
832
|
-
}
|
|
833
|
-
beginComposition() {
|
|
834
|
-
if (this.isComposing) return refuse("A canonical composition is already pending.");
|
|
835
|
-
this.lifecycle = { type: "composing" };
|
|
836
|
-
this.breakUndoGroup();
|
|
837
|
-
return Result.ok(void 0);
|
|
838
|
-
}
|
|
839
|
-
endComposition() {
|
|
840
|
-
this.lifecycle = { type: "committed" };
|
|
841
|
-
this.breakUndoGroup();
|
|
842
|
-
}
|
|
843
|
-
checkState(state, projection = this.projection) {
|
|
844
|
-
if (this.isComposing) return refuse("Composition must finish before committing another edit.");
|
|
845
|
-
if (state.doc !== projection.doc && !state.doc.eq(projection.doc)) return refuse("The input uses a stale canonical projection.");
|
|
846
|
-
return Result.ok(void 0);
|
|
847
|
-
}
|
|
848
|
-
prepareReplace(state, { from, to, text, story = OP_STORIES.MAIN, semantic = "replacement", compositionPhase, time = Date.now() }) {
|
|
849
|
-
const projected = this.projectStory(story);
|
|
850
|
-
if (projected.isErr()) return projected;
|
|
851
|
-
const projection = projected.value;
|
|
852
|
-
const checked = this.checkState(state, projection);
|
|
853
|
-
if (checked.isErr()) return checked;
|
|
854
|
-
if (!Number.isFinite(time)) return refuse("The input time is invalid.");
|
|
855
|
-
if (from > to || hasIllegalXmlCharacters(text) || /[\t\r\n]/u.test(text)) return refuse("Canonical input accepts a well-formed text replacement.");
|
|
856
|
-
if (from === to && text.length === 0) return noChange("The input makes no text change.");
|
|
857
|
-
const replacesStructuralSelection = state.selection instanceof AllSelection && from === state.selection.from && to === state.selection.to;
|
|
858
|
-
if (state.selection instanceof CellSelection) {
|
|
859
|
-
if (from !== state.selection.from || to !== state.selection.to) return refuse("A replacement range cannot partially address a cell selection.");
|
|
860
|
-
const intents = [];
|
|
861
|
-
let first = true;
|
|
862
|
-
for (const range of canonicalCellSelectionRanges(state.selection)) {
|
|
863
|
-
const edges = projection.rangeEdgesAt(range.from, range.to);
|
|
864
|
-
const cellFrom = projection.inputAddressAt(range.from, edges.start);
|
|
865
|
-
if (cellFrom.isErr()) return cellFrom;
|
|
866
|
-
const cellTo = projection.inputAddressAt(range.to, edges.end);
|
|
867
|
-
if (cellTo.isErr()) return cellTo;
|
|
868
|
-
intents.push({
|
|
869
|
-
type: "replaceText",
|
|
870
|
-
from: cellFrom.value,
|
|
871
|
-
to: cellTo.value,
|
|
872
|
-
text: first ? text : ""
|
|
873
|
-
});
|
|
874
|
-
first = false;
|
|
875
|
-
}
|
|
876
|
-
return this.prepareIntents(state, {
|
|
877
|
-
intents,
|
|
878
|
-
semantic
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
const range = canonicalSelectionRange(state);
|
|
882
|
-
const inputFrom = replacesStructuralSelection ? range.from : from;
|
|
883
|
-
const inputTo = replacesStructuralSelection ? range.to : to;
|
|
884
|
-
const edges = inputFrom === inputTo ? {
|
|
885
|
-
start: "caret",
|
|
886
|
-
end: "caret"
|
|
887
|
-
} : projection.rangeEdgesAt(inputFrom, inputTo);
|
|
888
|
-
const editCaret = this.editCaretAt(projection, inputFrom);
|
|
889
|
-
const start = inputFrom === inputTo && editCaret !== void 0 ? Result.ok(editCaret) : projection.inputAddressAt(inputFrom, edges.start);
|
|
890
|
-
if (start.isErr()) return start;
|
|
891
|
-
const end = inputFrom === inputTo && editCaret !== void 0 ? Result.ok(editCaret) : projection.inputAddressAt(inputTo, edges.end);
|
|
892
|
-
if (end.isErr()) return end;
|
|
893
|
-
const preSelection = projection.selectionAt(state);
|
|
894
|
-
if (preSelection.isErr()) return preSelection;
|
|
895
|
-
const innerEdge = (position, side) => {
|
|
896
|
-
const resolved = state.doc.resolve(position);
|
|
897
|
-
return resolved.parent.type.name === "sdt" && resolved.parentOffset === (side === "start" ? 0 : resolved.parent.content.size);
|
|
898
|
-
};
|
|
899
|
-
const inside = {
|
|
900
|
-
...innerEdge(inputFrom, "start") ? { start: true } : {},
|
|
901
|
-
...innerEdge(inputTo, "end") ? { end: true } : {}
|
|
902
|
-
};
|
|
903
|
-
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.");
|
|
904
|
-
const intent = {
|
|
905
|
-
type: "replaceText",
|
|
906
|
-
from: start.value,
|
|
907
|
-
to: end.value,
|
|
908
|
-
text,
|
|
909
|
-
...Object.keys(inside).length === 0 ? {} : { inside },
|
|
910
|
-
...state.storedMarks === null ? {} : { runPropsPatch: runFormattingPatchFromMarks(state.selection.$from.marks(), state.storedMarks) }
|
|
911
|
-
};
|
|
912
|
-
const compiled = compileEditorIntent(this.currentDocument, {
|
|
913
|
-
intent,
|
|
914
|
-
mode: this.intentMode(this.currentDocument, intent)
|
|
915
|
-
});
|
|
916
|
-
if (compiled.isErr()) return compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(compiled.error.message) : refuse(compiled.error.message);
|
|
917
|
-
const { ops, selection: caret } = compiled.value;
|
|
918
|
-
const postSelection = {
|
|
919
|
-
type: "text",
|
|
920
|
-
anchor: caret,
|
|
921
|
-
head: caret
|
|
922
|
-
};
|
|
923
|
-
const preDocument = this.currentDocument;
|
|
924
|
-
const isCaret = state.selection.empty;
|
|
925
|
-
const deletion = isCaret && text.length === 0 && (semantic === "deleteBackward" || semantic === "deleteForward") ? deletionRange(state, semantic === "deleteBackward" ? "backward" : "forward") : null;
|
|
926
|
-
const grouping = isCaret && (semantic === "typing" && from === to && from === state.selection.head || deletion?.isOk() && deletion.value.from === from && deletion.value.to === to) ? "run" : "isolated";
|
|
927
|
-
return this.stage({
|
|
928
|
-
state,
|
|
929
|
-
story,
|
|
930
|
-
ops,
|
|
931
|
-
selection: postSelection,
|
|
932
|
-
origin: "input",
|
|
933
|
-
onPublish: (inverse, version) => {
|
|
934
|
-
const entry = {
|
|
935
|
-
type: "applied",
|
|
936
|
-
ops,
|
|
937
|
-
inverse,
|
|
938
|
-
preSelection: preSelection.value,
|
|
939
|
-
postSelection,
|
|
940
|
-
preDocument,
|
|
941
|
-
postDocument: this.currentDocument,
|
|
942
|
-
version,
|
|
943
|
-
origin: "input",
|
|
944
|
-
semantic,
|
|
945
|
-
grouping: compositionPhase === "correction" ? "compositionCorrection" : grouping,
|
|
946
|
-
time,
|
|
947
|
-
boundary: this.groupingBoundary
|
|
948
|
-
};
|
|
949
|
-
const group = this.applied.at(-1);
|
|
950
|
-
const previous = group?.entries.at(-1);
|
|
951
|
-
if (group !== void 0 && previous !== void 0 && continuesGroup(previous, entry)) {
|
|
952
|
-
group.entries.push(entry);
|
|
953
|
-
group.postSelection = postSelection;
|
|
954
|
-
} else this.applied.push({
|
|
955
|
-
entries: [entry],
|
|
956
|
-
undo: { type: "entries" },
|
|
957
|
-
preSelection: preSelection.value,
|
|
958
|
-
postSelection
|
|
959
|
-
});
|
|
960
|
-
this.undone.length = 0;
|
|
961
|
-
}
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* A structural edit over selected cells: each selected cell is cleared and
|
|
966
|
-
* the edit happens at the start of the first, as the editor's own command
|
|
967
|
-
* does over a cell selection. One commit, so one undo step.
|
|
968
|
-
*/
|
|
969
|
-
prepareCellSelectionStructure(state, structure, { resourceOps = [], semantic = "structure" } = {}) {
|
|
970
|
-
if (!(state.selection instanceof CellSelection)) return refuse("The structural edit needs a cell selection.");
|
|
971
|
-
const projected = this.projectStory(OP_STORIES.MAIN);
|
|
972
|
-
if (projected.isErr()) return projected;
|
|
973
|
-
const projection = projected.value;
|
|
974
|
-
const intents = [];
|
|
975
|
-
let first;
|
|
976
|
-
for (const range of canonicalCellSelectionRanges(state.selection)) {
|
|
977
|
-
const edges = projection.rangeEdgesAt(range.from, range.to);
|
|
978
|
-
const cellFrom = projection.inputAddressAt(range.from, edges.start);
|
|
979
|
-
if (cellFrom.isErr()) return cellFrom;
|
|
980
|
-
const cellTo = projection.inputAddressAt(range.to, edges.end);
|
|
981
|
-
if (cellTo.isErr()) return cellTo;
|
|
982
|
-
first ??= cellFrom.value;
|
|
983
|
-
if (cellFrom.value.blockId !== cellTo.value.blockId || cellFrom.value.offset !== cellTo.value.offset) intents.push({
|
|
984
|
-
type: "replaceText",
|
|
985
|
-
from: cellFrom.value,
|
|
986
|
-
to: cellTo.value,
|
|
987
|
-
text: ""
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
if (first === void 0) return refuse("The cell selection is empty.");
|
|
991
|
-
intents.push(structure({
|
|
992
|
-
...first,
|
|
993
|
-
offset: 0,
|
|
994
|
-
zeroWidthBefore: 0
|
|
995
|
-
}));
|
|
996
|
-
return this.prepareIntents(state, {
|
|
997
|
-
intents,
|
|
998
|
-
resourceOps,
|
|
999
|
-
semantic
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
prepareIntent(state, intent) {
|
|
1003
|
-
return this.prepareIntents(state, { intents: [intent] });
|
|
1004
|
-
}
|
|
1005
|
-
prepareIntents(state, { intents, resourceOps = [], semantic = "structure" }) {
|
|
1006
|
-
const first = intents.at(0);
|
|
1007
|
-
if (first === void 0) return noChange("The intent batch is empty.");
|
|
1008
|
-
const story = intentStory(first);
|
|
1009
|
-
if (intents.some((intent) => !sameStory(story, intentStory(intent)))) return refuse("A compound input must address one story.");
|
|
1010
|
-
const projected = this.projectStory(story);
|
|
1011
|
-
if (projected.isErr()) return projected;
|
|
1012
|
-
const checked = this.checkState(state, projected.value);
|
|
1013
|
-
if (checked.isErr()) return checked;
|
|
1014
|
-
const preSelection = projected.value.selectionAt(state);
|
|
1015
|
-
if (preSelection.isErr()) return preSelection;
|
|
1016
|
-
let document = this.currentDocument;
|
|
1017
|
-
let postSelection = preSelection.value;
|
|
1018
|
-
const ops = [...resourceOps];
|
|
1019
|
-
const edits = [];
|
|
1020
|
-
if (resourceOps.length > 0) {
|
|
1021
|
-
const imported = applyDocumentOps(document, resourceOps);
|
|
1022
|
-
if (imported.isErr()) return refuse(imported.error.message);
|
|
1023
|
-
document = imported.value.document;
|
|
1024
|
-
edits.push(imported.value);
|
|
1025
|
-
}
|
|
1026
|
-
for (const intent of intents) {
|
|
1027
|
-
if (this.mode.type === "suggesting" && (intent.type === "setHyperlink" || intent.type === "removeHyperlink" || intent.type === "insertHyperlink" || intent.type === "generateTOC")) return Result.err(new CanonicalSessionError({
|
|
1028
|
-
ground: { gap: CANONICAL_GAP.trackedHyperlinkResolution },
|
|
1029
|
-
reason: "refused",
|
|
1030
|
-
message: "Hyperlink and TOC suggestions require serializable wrapper review provenance."
|
|
1031
|
-
}));
|
|
1032
|
-
const compiled = compileEditorIntent(document, {
|
|
1033
|
-
intent,
|
|
1034
|
-
mode: this.intentMode(document, intent),
|
|
1035
|
-
firstBlockId: this.nextBlockId
|
|
1036
|
-
});
|
|
1037
|
-
if (compiled.isErr()) {
|
|
1038
|
-
if (compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE) return noChange(compiled.error.message);
|
|
1039
|
-
if (compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.UNTRACKABLE && (intent.type === "setHyperlink" || intent.type === "removeHyperlink" || intent.type === "insertHyperlink")) return Result.err(new CanonicalSessionError({
|
|
1040
|
-
ground: { gap: CANONICAL_GAP.trackedHyperlinkResolution },
|
|
1041
|
-
reason: "refused",
|
|
1042
|
-
message: compiled.error.message
|
|
1043
|
-
}));
|
|
1044
|
-
return refuse(compiled.error.message);
|
|
1045
|
-
}
|
|
1046
|
-
const applied = applyDocumentOps(document, compiled.value.ops);
|
|
1047
|
-
if (applied.isErr()) return applied.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(applied.error.message) : refuse(applied.error.message);
|
|
1048
|
-
document = applied.value.document;
|
|
1049
|
-
edits.push(applied.value);
|
|
1050
|
-
ops.push(...compiled.value.ops);
|
|
1051
|
-
if (intent.type === "generateTOC") {
|
|
1052
|
-
const mapping = {
|
|
1053
|
-
at: intent.at,
|
|
1054
|
-
after: compiled.value.selection,
|
|
1055
|
-
ops: compiled.value.ops
|
|
1056
|
-
};
|
|
1057
|
-
postSelection = Object.assign({}, postSelection, {
|
|
1058
|
-
anchor: mapTocSelection(postSelection.anchor, mapping),
|
|
1059
|
-
head: mapTocSelection(postSelection.head, mapping)
|
|
1060
|
-
});
|
|
1061
|
-
} else if (intent.type !== "setHyperlink" && intent.type !== "removeHyperlink" && intent.type !== "formatRun" && intent.type !== "formatParagraph" && intent.type !== "setList") postSelection = {
|
|
1062
|
-
type: "text",
|
|
1063
|
-
anchor: compiled.value.selection,
|
|
1064
|
-
head: compiled.value.selection
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
const stagedApplied = {
|
|
1068
|
-
...combineEdits(this.currentDocument, edits),
|
|
1069
|
-
revisions: edits.flatMap(({ revisions }) => revisions)
|
|
1070
|
-
};
|
|
1071
|
-
return this.prepareJournalledOps({
|
|
1072
|
-
state,
|
|
1073
|
-
ops,
|
|
1074
|
-
postSelection,
|
|
1075
|
-
stagedApplied,
|
|
1076
|
-
semantic
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
prepareOps(state, ops, postSelection) {
|
|
1080
|
-
return this.prepareJournalledOps({
|
|
1081
|
-
state,
|
|
1082
|
-
ops,
|
|
1083
|
-
postSelection
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
prepareJournalledOps({ state, ops, postSelection, stagedApplied, semantic = "structure" }) {
|
|
1087
|
-
const story = postSelection.anchor.story;
|
|
1088
|
-
const projected = this.projectStory(story);
|
|
1089
|
-
if (projected.isErr()) return projected;
|
|
1090
|
-
const preSelection = projected.value.selectionAt(state);
|
|
1091
|
-
if (preSelection.isErr()) return preSelection;
|
|
1092
|
-
if (ops.length === 0 || stagedApplied?.inverse.length === 0) return noChange("The intent makes no document change.");
|
|
1093
|
-
const preDocument = this.currentDocument;
|
|
1094
|
-
return this.stage({
|
|
1095
|
-
state,
|
|
1096
|
-
story,
|
|
1097
|
-
ops,
|
|
1098
|
-
selection: postSelection,
|
|
1099
|
-
origin: "input",
|
|
1100
|
-
...stagedApplied === void 0 ? {} : { stagedApplied },
|
|
1101
|
-
onPublish: (inverse, version) => {
|
|
1102
|
-
const entry = {
|
|
1103
|
-
type: "applied",
|
|
1104
|
-
ops,
|
|
1105
|
-
inverse,
|
|
1106
|
-
preSelection: preSelection.value,
|
|
1107
|
-
postSelection,
|
|
1108
|
-
preDocument,
|
|
1109
|
-
postDocument: this.currentDocument,
|
|
1110
|
-
version,
|
|
1111
|
-
origin: "input",
|
|
1112
|
-
semantic,
|
|
1113
|
-
grouping: "isolated",
|
|
1114
|
-
time: Date.now(),
|
|
1115
|
-
boundary: this.groupingBoundary
|
|
1116
|
-
};
|
|
1117
|
-
this.applied.push({
|
|
1118
|
-
entries: [entry],
|
|
1119
|
-
undo: { type: "entries" },
|
|
1120
|
-
preSelection: preSelection.value,
|
|
1121
|
-
postSelection
|
|
1122
|
-
});
|
|
1123
|
-
this.undone.length = 0;
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
prepareSplit(state) {
|
|
1128
|
-
const from = this.projection.inputAddressAt(state.selection.from);
|
|
1129
|
-
if (from.isErr()) return from;
|
|
1130
|
-
const to = this.projection.inputAddressAt(state.selection.to);
|
|
1131
|
-
if (to.isErr()) return to;
|
|
1132
|
-
const source = this.projection.paragraph(from.value.blockId);
|
|
1133
|
-
const nextStyle = (this.styles ?? this.currentDocument.package.styles)?.styles.find(({ styleId }) => styleId === source?.source.formatting?.styleId)?.next;
|
|
1134
|
-
const fresh = this.freshBlockId();
|
|
1135
|
-
if (fresh.isErr()) return fresh;
|
|
1136
|
-
const intents = [{
|
|
1137
|
-
type: "splitParagraph",
|
|
1138
|
-
at: from.value,
|
|
1139
|
-
to: to.value,
|
|
1140
|
-
newBlockId: fresh.value
|
|
1141
|
-
}];
|
|
1142
|
-
if (state.selection.empty && source !== void 0 && from.value.offset === source.text.length && nextStyle !== void 0 && nextStyle !== source.source.formatting?.styleId) intents.push({
|
|
1143
|
-
type: "formatParagraph",
|
|
1144
|
-
at: {
|
|
1145
|
-
...from.value,
|
|
1146
|
-
offset: 0
|
|
1147
|
-
},
|
|
1148
|
-
patch: { styleId: nextStyle }
|
|
1149
|
-
});
|
|
1150
|
-
return this.prepareIntents(state, { intents });
|
|
1151
|
-
}
|
|
1152
|
-
prepareJoin(state, direction) {
|
|
1153
|
-
const checked = this.checkState(state);
|
|
1154
|
-
if (checked.isErr()) return checked;
|
|
1155
|
-
if (!state.selection.empty) return refuse("Join requires a collapsed text selection.");
|
|
1156
|
-
const at = this.projection.inputAddressAt(state.selection.from);
|
|
1157
|
-
if (at.isErr()) return at;
|
|
1158
|
-
const groups = editorParagraphGroups(this.currentDocument, at.value.story);
|
|
1159
|
-
const index = groups.findIndex(({ paragraphs }) => paragraphs.some((paragraph) => paragraph.paraId === at.value.blockId));
|
|
1160
|
-
if (index < 0 || direction === "backward" && index === 0) return noChange("There is no adjacent paragraph to join.");
|
|
1161
|
-
const firstGroup = groups.at(direction === "backward" ? index - 1 : index);
|
|
1162
|
-
const secondGroup = groups.at(direction === "backward" ? index : index + 1);
|
|
1163
|
-
const first = firstGroup?.paragraphs.at(-1);
|
|
1164
|
-
const second = secondGroup?.paragraphs.at(0);
|
|
1165
|
-
if (!first?.paraId || !second?.paraId) return noChange("There is no adjacent paragraph to join.");
|
|
1166
|
-
if (this.projection.paragraph(first.paraId)?.container !== this.projection.paragraph(second.paraId)?.container) return noChange("There is no adjacent paragraph to join.");
|
|
1167
|
-
if (!isCanonicalJoinBoundary(state, direction)) return refuse("Join requires a caret at a paragraph boundary.");
|
|
1168
|
-
return this.prepareIntent(state, {
|
|
1169
|
-
type: "joinParagraphs",
|
|
1170
|
-
story: at.value.story,
|
|
1171
|
-
blockId: first.paraId,
|
|
1172
|
-
nextBlockId: second.paraId
|
|
1173
|
-
});
|
|
1174
|
-
}
|
|
1175
|
-
prepareResolve(state, { revisionIds, resolution }) {
|
|
1176
|
-
const checked = this.checkState(state);
|
|
1177
|
-
if (checked.isErr()) return checked;
|
|
1178
|
-
const preSelection = this.projection.selectionAt(state);
|
|
1179
|
-
if (preSelection.isErr()) return preSelection;
|
|
1180
|
-
const resolve = (ids) => [{
|
|
1181
|
-
type: DOCUMENT_OP_TYPES.RESOLVE_REVISION,
|
|
1182
|
-
story: OP_STORIES.MAIN,
|
|
1183
|
-
revisionIds: ids,
|
|
1184
|
-
decision: resolution
|
|
1185
|
-
}];
|
|
1186
|
-
let firstHeld = null;
|
|
1187
|
-
const lockHeld = revisionIds.filter((id) => {
|
|
1188
|
-
const alone = applyDocumentOps(this.currentDocument, resolve([id]));
|
|
1189
|
-
if (alone.isErr()) return false;
|
|
1190
|
-
const violation = lockViolationBetween(this.currentDocument, alone.value.document);
|
|
1191
|
-
firstHeld ??= violation;
|
|
1192
|
-
return violation !== null;
|
|
1193
|
-
});
|
|
1194
|
-
if (firstHeld !== null && lockHeld.length === revisionIds.length) return lockRefusal(firstHeld);
|
|
1195
|
-
const ops = resolve(revisionIds.filter((id) => !lockHeld.includes(id)));
|
|
1196
|
-
const applied = applyDocumentOps(this.currentDocument, ops);
|
|
1197
|
-
if (applied.isErr()) return refuse(applied.error.message);
|
|
1198
|
-
const projected = project({
|
|
1199
|
-
document: applied.value.document,
|
|
1200
|
-
styles: this.styles,
|
|
1201
|
-
caches: this.caches
|
|
1202
|
-
});
|
|
1203
|
-
if (projected.isErr()) return projected;
|
|
1204
|
-
const surviving = projected.value.paragraph(preSelection.value.head.blockId);
|
|
1205
|
-
const first = projected.value.firstParagraph;
|
|
1206
|
-
if (first === void 0) return refuse("Resolution left no paragraph.");
|
|
1207
|
-
let offset = surviving ? Math.min(preSelection.value.head.offset, surviving.text.length) : 0;
|
|
1208
|
-
if (surviving && splitsSurrogatePair(surviving.text, offset)) offset -= 1;
|
|
1209
|
-
const caret = {
|
|
1210
|
-
story: OP_STORIES.MAIN,
|
|
1211
|
-
blockId: surviving?.blockId ?? first.blockId,
|
|
1212
|
-
offset
|
|
1213
|
-
};
|
|
1214
|
-
const prepared = this.prepareJournalledOps({
|
|
1215
|
-
state,
|
|
1216
|
-
ops,
|
|
1217
|
-
postSelection: {
|
|
1218
|
-
type: "text",
|
|
1219
|
-
anchor: caret,
|
|
1220
|
-
head: caret
|
|
1221
|
-
},
|
|
1222
|
-
stagedApplied: applied.value
|
|
1223
|
-
});
|
|
1224
|
-
return prepared.isOk() && lockHeld.length > 0 ? Result.ok({
|
|
1225
|
-
...prepared.value,
|
|
1226
|
-
lockHeld
|
|
1227
|
-
}) : prepared;
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* Accept or reject one pending suggestion. Rejecting it rejects its
|
|
1231
|
-
* revisions. Accepting it adopts them as ordinary tracked changes by
|
|
1232
|
-
* `author`, keeping their ids, as the editor does: the change then waits
|
|
1233
|
-
* for review like any other.
|
|
1234
|
-
*/
|
|
1235
|
-
prepareSuggestion(state, { suggestionId, resolution, author, date }) {
|
|
1236
|
-
const infos = suggestionRevisionInfos(this.currentDocument, OP_STORIES.MAIN, suggestionId);
|
|
1237
|
-
if (infos.length === 0) return noChange(`No pending suggestion ${suggestionId}.`);
|
|
1238
|
-
if (resolution === "reject") return this.prepareResolve(state, {
|
|
1239
|
-
revisionIds: infos.map(({ id }) => id),
|
|
1240
|
-
resolution: "reject"
|
|
1241
|
-
});
|
|
1242
|
-
const checked = this.checkState(state);
|
|
1243
|
-
if (checked.isErr()) return checked;
|
|
1244
|
-
const selection = this.projection.selectionAt(state);
|
|
1245
|
-
if (selection.isErr()) return selection;
|
|
1246
|
-
return this.prepareJournalledOps({
|
|
1247
|
-
state,
|
|
1248
|
-
ops: [{
|
|
1249
|
-
type: DOCUMENT_OP_TYPES.SET_REVISION_INFO,
|
|
1250
|
-
story: OP_STORIES.MAIN,
|
|
1251
|
-
infos: infos.map(({ id }) => ({
|
|
1252
|
-
id,
|
|
1253
|
-
author,
|
|
1254
|
-
date
|
|
1255
|
-
}))
|
|
1256
|
-
}],
|
|
1257
|
-
postSelection: selection.value
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
projectStory(story) {
|
|
1261
|
-
if (story === OP_STORIES.MAIN) return Result.ok(this.projection);
|
|
1262
|
-
const key = storyProjectionKey(story);
|
|
1263
|
-
const body = findStoryBody(this.currentDocument, story);
|
|
1264
|
-
if (body === void 0) {
|
|
1265
|
-
this.storyProjections.delete(key);
|
|
1266
|
-
return refuse("The canonical story no longer exists.");
|
|
1267
|
-
}
|
|
1268
|
-
const cached = this.storyProjections.get(key);
|
|
1269
|
-
const theme = this.currentDocument.package.theme;
|
|
1270
|
-
if (cached?.content === body.content && cached.theme === theme) return Result.ok(cached.projection);
|
|
1271
|
-
const projected = project({
|
|
1272
|
-
document: this.currentDocument,
|
|
1273
|
-
styles: this.styles,
|
|
1274
|
-
caches: this.caches,
|
|
1275
|
-
story
|
|
1276
|
-
});
|
|
1277
|
-
if (projected.isOk()) this.storyProjections.set(key, {
|
|
1278
|
-
content: body.content,
|
|
1279
|
-
theme,
|
|
1280
|
-
projection: projected.value
|
|
1281
|
-
});
|
|
1282
|
-
return projected;
|
|
1283
|
-
}
|
|
1284
|
-
prepareOperations(state, ops) {
|
|
1285
|
-
if (ops.length === 0) return refuse("The operation batch is empty.");
|
|
1286
|
-
const selected = this.projection.selectionAt(state);
|
|
1287
|
-
if (selected.isErr()) return selected;
|
|
1288
|
-
let preparedOps = ops;
|
|
1289
|
-
if (ops.every((op) => op.type === DOCUMENT_OP_TYPES.ADD_NOTE || op.type === DOCUMENT_OP_TYPES.REMOVE_NOTE)) {
|
|
1290
|
-
const tracked = [];
|
|
1291
|
-
let document = this.currentDocument;
|
|
1292
|
-
for (const op of ops) {
|
|
1293
|
-
if (op.type !== DOCUMENT_OP_TYPES.ADD_NOTE && op.type !== DOCUMENT_OP_TYPES.REMOVE_NOTE) panic("A note operation batch contains only note operations.");
|
|
1294
|
-
const allocation = this.allocateIntentIds(document, {
|
|
1295
|
-
type: "replaceFragment",
|
|
1296
|
-
from: {
|
|
1297
|
-
...op.at,
|
|
1298
|
-
offset: 0
|
|
1299
|
-
},
|
|
1300
|
-
to: {
|
|
1301
|
-
...op.at,
|
|
1302
|
-
offset: Number.MAX_SAFE_INTEGER
|
|
1303
|
-
},
|
|
1304
|
-
paragraphs: [{
|
|
1305
|
-
type: "paragraph",
|
|
1306
|
-
content: [{
|
|
1307
|
-
type: "run",
|
|
1308
|
-
content: [{
|
|
1309
|
-
type: "break",
|
|
1310
|
-
breakType: "page"
|
|
1311
|
-
}]
|
|
1312
|
-
}]
|
|
1313
|
-
}],
|
|
1314
|
-
openStart: 0,
|
|
1315
|
-
openEnd: 0
|
|
1316
|
-
});
|
|
1317
|
-
const next = {
|
|
1318
|
-
...op,
|
|
1319
|
-
...this.mode.type === "suggesting" ? { revision: {
|
|
1320
|
-
id: allocation.revisionId,
|
|
1321
|
-
author: this.mode.author,
|
|
1322
|
-
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
1323
|
-
} } : {},
|
|
1324
|
-
newIds: allocation.newIds
|
|
1325
|
-
};
|
|
1326
|
-
if (ops.length > 1) {
|
|
1327
|
-
const applied = applyDocumentOp(cloneDocumentWithParagraphPropertySources(document), structuredClone(next));
|
|
1328
|
-
if (applied.isErr()) return refuse(applied.error.message);
|
|
1329
|
-
document = applied.value.document;
|
|
1330
|
-
}
|
|
1331
|
-
tracked.push(next);
|
|
1332
|
-
}
|
|
1333
|
-
preparedOps = tracked;
|
|
1334
|
-
}
|
|
1335
|
-
const addedNotes = preparedOps.filter((op) => op.type === DOCUMENT_OP_TYPES.ADD_NOTE);
|
|
1336
|
-
const atSelection = addedNotes.find(({ at }) => [selected.value.anchor, selected.value.head].some((end) => sameStory(at.story, end.story) && at.blockId === end.blockId && at.offset === end.offset));
|
|
1337
|
-
const caret = atSelection === void 0 ? void 0 : {
|
|
1338
|
-
...atSelection.at,
|
|
1339
|
-
offset: atSelection.at.offset + addedNotes.filter(({ at }) => sameStory(at.story, atSelection.at.story) && at.blockId === atSelection.at.blockId && at.offset <= atSelection.at.offset).length
|
|
1340
|
-
};
|
|
1341
|
-
const postSelection = addedNotes.length === preparedOps.length && caret !== void 0 ? {
|
|
1342
|
-
type: "text",
|
|
1343
|
-
anchor: caret,
|
|
1344
|
-
head: caret
|
|
1345
|
-
} : selected.value;
|
|
1346
|
-
const preDocument = this.currentDocument;
|
|
1347
|
-
return this.stage({
|
|
1348
|
-
state,
|
|
1349
|
-
ops: preparedOps,
|
|
1350
|
-
selection: postSelection,
|
|
1351
|
-
origin: "input",
|
|
1352
|
-
onPublish: (inverse, version) => {
|
|
1353
|
-
this.applied.push({
|
|
1354
|
-
entries: [{
|
|
1355
|
-
type: "applied",
|
|
1356
|
-
ops: preparedOps,
|
|
1357
|
-
inverse,
|
|
1358
|
-
preSelection: selected.value,
|
|
1359
|
-
postSelection,
|
|
1360
|
-
preDocument,
|
|
1361
|
-
postDocument: this.currentDocument,
|
|
1362
|
-
version,
|
|
1363
|
-
origin: "input",
|
|
1364
|
-
semantic: "structure",
|
|
1365
|
-
grouping: "isolated",
|
|
1366
|
-
time: Date.now(),
|
|
1367
|
-
boundary: this.groupingBoundary
|
|
1368
|
-
}],
|
|
1369
|
-
undo: { type: "entries" },
|
|
1370
|
-
preSelection: selected.value,
|
|
1371
|
-
postSelection
|
|
1372
|
-
});
|
|
1373
|
-
this.undone.length = 0;
|
|
1374
|
-
}
|
|
1375
|
-
});
|
|
1376
|
-
}
|
|
1377
|
-
prepareUndo(state, story = OP_STORIES.MAIN) {
|
|
1378
|
-
const group = this.applied.at(-1);
|
|
1379
|
-
if (group === void 0) return refuse("There is no canonical edit to undo.");
|
|
1380
|
-
const propertySourceDocument = group.entries.at(0)?.preDocument;
|
|
1381
|
-
return this.stage({
|
|
1382
|
-
state,
|
|
1383
|
-
story,
|
|
1384
|
-
ops: group.undo.type === "replayed" ? group.undo.inverse : group.entries.toReversed().flatMap((entry) => entry.inverse),
|
|
1385
|
-
selection: group.preSelection,
|
|
1386
|
-
origin: "undo",
|
|
1387
|
-
...propertySourceDocument === void 0 ? {} : { propertySourceDocument },
|
|
1388
|
-
onPublish: (redoOps) => {
|
|
1389
|
-
this.applied.pop();
|
|
1390
|
-
this.undone.push({
|
|
1391
|
-
type: "undone",
|
|
1392
|
-
group,
|
|
1393
|
-
redoOps
|
|
1394
|
-
});
|
|
1395
|
-
this.breakUndoGroup();
|
|
1396
|
-
}
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
prepareRedo(state, story = OP_STORIES.MAIN) {
|
|
1400
|
-
const undone = this.undone.at(-1);
|
|
1401
|
-
if (undone === void 0) return refuse("There is no canonical edit to redo.");
|
|
1402
|
-
const propertySourceDocument = undone.group.entries.at(-1)?.postDocument;
|
|
1403
|
-
return this.stage({
|
|
1404
|
-
state,
|
|
1405
|
-
story,
|
|
1406
|
-
ops: undone.redoOps,
|
|
1407
|
-
selection: undone.group.postSelection,
|
|
1408
|
-
origin: "redo",
|
|
1409
|
-
...propertySourceDocument === void 0 ? {} : { propertySourceDocument },
|
|
1410
|
-
onPublish: (inverse) => {
|
|
1411
|
-
this.undone.pop();
|
|
1412
|
-
this.applied.push({
|
|
1413
|
-
entries: undone.group.entries,
|
|
1414
|
-
undo: {
|
|
1415
|
-
type: "replayed",
|
|
1416
|
-
inverse
|
|
1417
|
-
},
|
|
1418
|
-
preSelection: undone.group.preSelection,
|
|
1419
|
-
postSelection: undone.group.postSelection
|
|
1420
|
-
});
|
|
1421
|
-
this.breakUndoGroup();
|
|
1422
|
-
}
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
stage({ state, ops, selection, origin, onPublish, propertySourceDocument, stagedApplied, story = OP_STORIES.MAIN, previousProjection }) {
|
|
1426
|
-
const previous = previousProjection === void 0 ? this.projectStory(story) : Result.ok(previousProjection);
|
|
1427
|
-
if (previous.isErr()) return previous;
|
|
1428
|
-
const checked = this.checkState(state, previous.value);
|
|
1429
|
-
if (checked.isErr()) return checked;
|
|
1430
|
-
const applied = stagedApplied === void 0 ? applyDocumentOps(this.currentDocument, ops) : Result.ok(stagedApplied);
|
|
1431
|
-
if (applied.isErr()) return refuse(applied.error.message);
|
|
1432
|
-
if (applied.value.inverse.length === 0) return noChange("The intent makes no document change.");
|
|
1433
|
-
const locked = lockViolationBetween(this.currentDocument, applied.value.document);
|
|
1434
|
-
if (locked !== null) return lockRefusal(locked);
|
|
1435
|
-
if (propertySourceDocument !== void 0) preservePropertySources({
|
|
1436
|
-
target: applied.value.document,
|
|
1437
|
-
source: propertySourceDocument,
|
|
1438
|
-
indentation: "restore"
|
|
1439
|
-
});
|
|
1440
|
-
const normalized = normalizeCanonicalListRendering(applied.value.document, this.caches.lists);
|
|
1441
|
-
applied.value.document = normalized.document;
|
|
1442
|
-
applied.value.inverse = normalized.inverse.concat(applied.value.inverse);
|
|
1443
|
-
const changed = changedStories({
|
|
1444
|
-
document: applied.value.document,
|
|
1445
|
-
previous: this.currentDocument
|
|
1446
|
-
});
|
|
1447
|
-
if (unsupportedSeedReason(applied.value.document, changed) !== null) return Result.err(new CanonicalSessionError({
|
|
1448
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
1449
|
-
reason: "refused",
|
|
1450
|
-
message: "The operations produce unsupported canonical story content."
|
|
1451
|
-
}));
|
|
1452
|
-
preservePropertySources({
|
|
1453
|
-
target: applied.value.document,
|
|
1454
|
-
source: this.currentDocument,
|
|
1455
|
-
stories: changed
|
|
1456
|
-
});
|
|
1457
|
-
if (propertySourceDocument !== void 0) preservePropertySources({
|
|
1458
|
-
target: applied.value.document,
|
|
1459
|
-
source: propertySourceDocument
|
|
1460
|
-
});
|
|
1461
|
-
const stagedSources = new Map(this.sourceOwners);
|
|
1462
|
-
for (const block of applied.value.document.package.document.content) {
|
|
1463
|
-
if (block.type !== "paragraph" || block.paraId === void 0) continue;
|
|
1464
|
-
const source = stagedSources.get(block.paraId);
|
|
1465
|
-
if (source && block !== source) copyParagraphPropertySource(block, source);
|
|
1466
|
-
}
|
|
1467
|
-
const projectedStory = findStoryBody(applied.value.document, story) ? story : OP_STORIES.MAIN;
|
|
1468
|
-
const projected = project({
|
|
1469
|
-
document: applied.value.document,
|
|
1470
|
-
styles: this.styles,
|
|
1471
|
-
caches: this.caches,
|
|
1472
|
-
story: projectedStory
|
|
1473
|
-
});
|
|
1474
|
-
if (projected.isErr()) return projected;
|
|
1475
|
-
const bodyProjection = (() => {
|
|
1476
|
-
if (sameStory(projectedStory, OP_STORIES.MAIN)) return projected;
|
|
1477
|
-
if (ops.some(operationChangesBodyProjection)) return project({
|
|
1478
|
-
document: applied.value.document,
|
|
1479
|
-
styles: this.styles,
|
|
1480
|
-
caches: this.caches
|
|
1481
|
-
});
|
|
1482
|
-
return Result.ok(this.currentProjection);
|
|
1483
|
-
})();
|
|
1484
|
-
if (bodyProjection.isErr()) return bodyProjection;
|
|
1485
|
-
const transaction = state.tr;
|
|
1486
|
-
const before = state.doc;
|
|
1487
|
-
const after = projected.value.doc;
|
|
1488
|
-
let prefix = 0;
|
|
1489
|
-
let from = 0;
|
|
1490
|
-
while (prefix < before.childCount && prefix < after.childCount && before.child(prefix).eq(after.child(prefix))) {
|
|
1491
|
-
from += before.child(prefix).nodeSize;
|
|
1492
|
-
prefix += 1;
|
|
1493
|
-
}
|
|
1494
|
-
let oldEnd = before.childCount;
|
|
1495
|
-
let newEnd = after.childCount;
|
|
1496
|
-
let to = before.content.size;
|
|
1497
|
-
while (oldEnd > prefix && newEnd > prefix && before.child(oldEnd - 1).eq(after.child(newEnd - 1))) {
|
|
1498
|
-
oldEnd -= 1;
|
|
1499
|
-
newEnd -= 1;
|
|
1500
|
-
to -= before.child(oldEnd).nodeSize;
|
|
1501
|
-
}
|
|
1502
|
-
if (oldEnd !== prefix || newEnd !== prefix) {
|
|
1503
|
-
const replacement = [];
|
|
1504
|
-
for (let index = prefix; index < newEnd; index += 1) replacement.push(after.child(index));
|
|
1505
|
-
transaction.replaceWith(from, to, Fragment.fromArray(replacement));
|
|
1506
|
-
}
|
|
1507
|
-
if (!transaction.doc.eq(projected.value.doc)) transaction.replaceWith(0, transaction.doc.content.size, projected.value.doc.content);
|
|
1508
|
-
for (const [name, value] of Object.entries(projected.value.doc.attrs)) if (transaction.doc.attrs[name] !== value) transaction.setDocAttribute(name, value);
|
|
1509
|
-
if (sameStory(selection.anchor.story, projectedStory) && sameStory(selection.head.story, projectedStory)) {
|
|
1510
|
-
if (!restoreCanonicalSelection({
|
|
1511
|
-
transaction,
|
|
1512
|
-
projection: projected.value,
|
|
1513
|
-
selection,
|
|
1514
|
-
unavailable: {
|
|
1515
|
-
type: "near",
|
|
1516
|
-
anchor: state.selection.anchor
|
|
1517
|
-
}
|
|
1518
|
-
})) return refuse("Canonical history cannot restore the selected inline atom.");
|
|
1519
|
-
}
|
|
1520
|
-
const held = projected.value.heldAs(transaction.doc);
|
|
1521
|
-
const heldBody = bodyProjection.value === projected.value ? held : bodyProjection.value;
|
|
1522
|
-
transaction.setMeta(CANONICAL_PROJECTION_META, {
|
|
1523
|
-
type: "canonical",
|
|
1524
|
-
origin,
|
|
1525
|
-
version: this.version + 1
|
|
1526
|
-
});
|
|
1527
|
-
if (ops.some(operationChangesPackage)) markPackageChange(transaction);
|
|
1528
|
-
transaction.setMeta("addToHistory", false);
|
|
1529
|
-
const baseVersion = this.version;
|
|
1530
|
-
const baseBoundary = this.groupingBoundary;
|
|
1531
|
-
authorizedProjections.set(transaction, {
|
|
1532
|
-
session: this,
|
|
1533
|
-
version: baseVersion,
|
|
1534
|
-
doc: projected.value.doc
|
|
1535
|
-
});
|
|
1536
|
-
return Result.ok({
|
|
1537
|
-
transaction,
|
|
1538
|
-
document: applied.value.document,
|
|
1539
|
-
projection: held,
|
|
1540
|
-
bodyProjection: heldBody,
|
|
1541
|
-
selection,
|
|
1542
|
-
touched: applied.value.touched,
|
|
1543
|
-
version: baseVersion + 1,
|
|
1544
|
-
origin,
|
|
1545
|
-
publish: () => {
|
|
1546
|
-
if (this.isComposing || this.groupingBoundary !== baseBoundary) return refuse("The staged canonical commit crossed a composition or selection boundary.");
|
|
1547
|
-
if (this.version !== baseVersion) return refuse("The staged canonical commit is stale.");
|
|
1548
|
-
if (!isCanonicalProjectionTransaction(transaction, this)) return refuse("The staged canonical projection was changed after preparation.");
|
|
1549
|
-
for (const blockId of applied.value.touched.inserted) this.allocatedBlockIds.add(blockId.toUpperCase());
|
|
1550
|
-
for (const op of ops) {
|
|
1551
|
-
if (op.type === DOCUMENT_OP_TYPES.SPLIT_BLOCK) this.allocatedBlockIds.add(op.newBlockId.toUpperCase());
|
|
1552
|
-
if (op.type === DOCUMENT_OP_TYPES.ADD_NOTE) for (const blockId of paragraphIdsIn(op.note.content)) this.allocatedBlockIds.add(blockId.toUpperCase());
|
|
1553
|
-
}
|
|
1554
|
-
this.advanceBlockId();
|
|
1555
|
-
this.rememberSources(applied.value.document);
|
|
1556
|
-
if (projectedStory !== OP_STORIES.MAIN) {
|
|
1557
|
-
const body = findStoryBody(applied.value.document, projectedStory);
|
|
1558
|
-
if (body === void 0) panic("A staged story projection lost its source.");
|
|
1559
|
-
this.storyProjections.set(storyProjectionKey(projectedStory), {
|
|
1560
|
-
content: body.content,
|
|
1561
|
-
theme: applied.value.document.package.theme,
|
|
1562
|
-
projection: held
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
|
-
this.currentSelection = selection;
|
|
1566
|
-
this.currentDocument = applied.value.document;
|
|
1567
|
-
this.currentProjection = heldBody;
|
|
1568
|
-
for (const ids of [
|
|
1569
|
-
applied.value.touched.modified,
|
|
1570
|
-
applied.value.touched.inserted,
|
|
1571
|
-
applied.value.touched.removed
|
|
1572
|
-
]) for (const id of ids) this.saveTouched.add(id);
|
|
1573
|
-
const bodyOps = ops.filter((op) => !COMMENT_OPERATION_TYPES.has(op.type));
|
|
1574
|
-
if (bodyOps.some(operationChangesStructure) || bodyOps.some(operationChangesPackage) || bodyOps.length > 0 && (applied.value.touched.inserted.length > 0 || applied.value.touched.removed.length > 0)) this.saveStructure = "changed";
|
|
1575
|
-
this.currentVersion = baseVersion + 1;
|
|
1576
|
-
onPublish(applied.value.inverse, this.currentVersion);
|
|
1577
|
-
return Result.ok(void 0);
|
|
1578
|
-
}
|
|
1579
|
-
});
|
|
1580
|
-
}
|
|
1581
|
-
};
|
|
1582
|
-
const createCanonicalSession = (document, styles) => {
|
|
1583
|
-
const unsupported = unsupportedSeedReason(document);
|
|
1584
|
-
if (unsupported !== null) return refuse(unsupported);
|
|
1585
|
-
const owned = cloneDocumentWithParagraphPropertySources(document);
|
|
1586
|
-
const identified = normalizeForOps(owned);
|
|
1587
|
-
preservePropertySources({
|
|
1588
|
-
target: identified,
|
|
1589
|
-
source: owned
|
|
1590
|
-
});
|
|
1591
|
-
const validated = validateOpsDocument(identified);
|
|
1592
|
-
if (validated.isErr()) return refuse(validated.error.message);
|
|
1593
|
-
const caches = newStoryProjectionCaches();
|
|
1594
|
-
const normalized = normalizeCanonicalListRendering(identified, caches.lists).document;
|
|
1595
|
-
preservePropertySources({
|
|
1596
|
-
target: normalized,
|
|
1597
|
-
source: owned
|
|
1598
|
-
});
|
|
1599
|
-
const projected = project({
|
|
1600
|
-
document: normalized,
|
|
1601
|
-
styles,
|
|
1602
|
-
caches
|
|
1603
|
-
});
|
|
1604
|
-
if (projected.isErr()) return projected;
|
|
1605
|
-
return Result.ok(new CanonicalSession({
|
|
1606
|
-
document: normalized,
|
|
1607
|
-
projection: projected.value,
|
|
1608
|
-
styles,
|
|
1609
|
-
caches
|
|
1610
|
-
}));
|
|
1611
|
-
};
|
|
1612
|
-
const hasDeletedParagraphMark = (node) => {
|
|
1613
|
-
const mark = node.attrs["pPrMark"];
|
|
1614
|
-
return typeof mark === "object" && mark !== null && "kind" in mark && (mark.kind === "del" || mark.kind === "moveFrom");
|
|
1615
|
-
};
|
|
1616
|
-
/** Visible graphemes concatenate across retained deletions and deleted paragraph marks. */
|
|
1617
|
-
const visibleDeletionContext = (state) => {
|
|
1618
|
-
const { selection } = state;
|
|
1619
|
-
const paragraphDepth = selection.$from.depth;
|
|
1620
|
-
const containerDepth = paragraphDepth - 1;
|
|
1621
|
-
if (containerDepth < 0 || selection.$from.node(paragraphDepth).type.name !== "paragraph") return refuse("Canonical deletion requires a caret inside a paragraph.");
|
|
1622
|
-
const container = selection.$from.node(containerDepth);
|
|
1623
|
-
const containerStart = selection.$from.start(containerDepth);
|
|
1624
|
-
const index = selection.$from.index(containerDepth);
|
|
1625
|
-
let first = index;
|
|
1626
|
-
while (first > 0 && hasDeletedParagraphMark(container.child(first - 1))) first -= 1;
|
|
1627
|
-
let last = index;
|
|
1628
|
-
while (last + 1 < container.childCount && hasDeletedParagraphMark(container.child(last))) last += 1;
|
|
1629
|
-
let text = "";
|
|
1630
|
-
const physicalStarts = [];
|
|
1631
|
-
const physicalEnds = [];
|
|
1632
|
-
let visibleOffset = 0;
|
|
1633
|
-
let issue;
|
|
1634
|
-
container.forEach((paragraph, paragraphOffset, paragraphIndex) => {
|
|
1635
|
-
if (paragraphIndex < first || paragraphIndex > last) return;
|
|
1636
|
-
const native = canonicalNativeCells(paragraph);
|
|
1637
|
-
if (native.isErr()) {
|
|
1638
|
-
issue = new CanonicalSessionError({
|
|
1639
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
1640
|
-
reason: "refused",
|
|
1641
|
-
message: native.error.message
|
|
1642
|
-
});
|
|
1643
|
-
return;
|
|
1644
|
-
}
|
|
1645
|
-
for (const cell of native.value) {
|
|
1646
|
-
if (cell.type === "zeroWidth" || cell.node.marks.some((mark) => mark.type.name === "deletion")) continue;
|
|
1647
|
-
const value = cell.type === "text" ? cell.text : "";
|
|
1648
|
-
const from = containerStart + paragraphOffset + 1 + cell.from;
|
|
1649
|
-
const to = containerStart + paragraphOffset + 1 + cell.to;
|
|
1650
|
-
if (cell.type !== "text" && selection.from > from && selection.from < to) {
|
|
1651
|
-
issue = new CanonicalSessionError({
|
|
1652
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
1653
|
-
reason: "refused",
|
|
1654
|
-
message: "Character deletion cannot start inside an inline atom."
|
|
1655
|
-
});
|
|
1656
|
-
return;
|
|
1657
|
-
}
|
|
1658
|
-
for (let unit = 0; unit < value.length; unit += 1) {
|
|
1659
|
-
const position = from + (cell.type === "text" ? unit : 0);
|
|
1660
|
-
physicalStarts.push(position);
|
|
1661
|
-
text += value.charAt(unit);
|
|
1662
|
-
physicalEnds.push(cell.type === "text" ? position + 1 : to);
|
|
1663
|
-
if (position < selection.from) visibleOffset += 1;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
});
|
|
1667
|
-
return issue === void 0 ? Result.ok({
|
|
1668
|
-
text,
|
|
1669
|
-
physicalStarts,
|
|
1670
|
-
physicalEnds,
|
|
1671
|
-
visibleOffset
|
|
1672
|
-
}) : Result.err(issue);
|
|
1673
|
-
};
|
|
1674
|
-
const isCanonicalJoinBoundary = (state, direction) => {
|
|
1675
|
-
if (!(state.selection instanceof TextSelection) || !state.selection.empty) return false;
|
|
1676
|
-
const context = visibleDeletionContext(state);
|
|
1677
|
-
if (context.isErr()) return false;
|
|
1678
|
-
const { text, visibleOffset } = context.value;
|
|
1679
|
-
return visibleOffset === (direction === "backward" ? 0 : text.length);
|
|
1680
|
-
};
|
|
1681
|
-
/** Native character deletion consumes one whole visible grapheme. */
|
|
1682
|
-
const deletionRange = (state, direction) => {
|
|
1683
|
-
const { selection } = state;
|
|
1684
|
-
if (selection instanceof NodeSelection && selection.node.isInline && selection.node.isAtom && selection.node.type.name !== "noteMarker") return Result.ok({
|
|
1685
|
-
from: selection.from,
|
|
1686
|
-
to: selection.to
|
|
1687
|
-
});
|
|
1688
|
-
if (selection instanceof CellSelection) return Result.ok({
|
|
1689
|
-
from: selection.from,
|
|
1690
|
-
to: selection.to
|
|
1691
|
-
});
|
|
1692
|
-
if (selection instanceof AllSelection) return Result.ok(canonicalSelectionRange(state));
|
|
1693
|
-
if (!(selection instanceof TextSelection)) return refuse("Canonical deletion requires text, an inline atom, or the whole document selection.");
|
|
1694
|
-
if (!selection.empty) return Result.ok({
|
|
1695
|
-
from: selection.from,
|
|
1696
|
-
to: selection.to
|
|
1697
|
-
});
|
|
1698
|
-
const parent = selection.$from.parent;
|
|
1699
|
-
const offset = selection.$from.parentOffset;
|
|
1700
|
-
if ((direction === "backward" ? parent.childBefore(offset).node : parent.childAfter(offset).node)?.type.name === "noteMarker") return refuse("Automatic note marks cannot be deleted as characters.");
|
|
1701
|
-
const context = visibleDeletionContext(state);
|
|
1702
|
-
if (context.isErr()) return context;
|
|
1703
|
-
const { text, physicalStarts, physicalEnds, visibleOffset } = context.value;
|
|
1704
|
-
if (splitsSurrogatePair(text, visibleOffset)) return refuse("The deletion would split a surrogate pair.");
|
|
1705
|
-
if (splitsGraphemeCluster(text, visibleOffset)) return refuse("Character deletion requires a caret at a grapheme boundary.");
|
|
1706
|
-
if (direction === "backward" && visibleOffset === 0 || direction === "forward" && visibleOffset === text.length) return refuse("There is no visible character to delete in this paragraph.");
|
|
1707
|
-
let boundary = visibleOffset + (direction === "backward" ? -1 : 1);
|
|
1708
|
-
while (splitsGraphemeCluster(text, boundary)) boundary += direction === "backward" ? -1 : 1;
|
|
1709
|
-
const from = physicalStarts.at(direction === "backward" ? boundary : visibleOffset);
|
|
1710
|
-
const to = physicalEnds.at((direction === "backward" ? visibleOffset : boundary) - 1);
|
|
1711
|
-
if (from === void 0 || to === void 0) panic("Canonical deletion lost a grapheme boundary.");
|
|
1712
|
-
return Result.ok({
|
|
1713
|
-
from,
|
|
1714
|
-
to
|
|
1715
|
-
});
|
|
1716
|
-
};
|
|
1717
|
-
export { CANONICAL_PROJECTION_META, CanonicalSessionError, createCanonicalSession, deletionRange, isCanonicalJoinBoundary, isCanonicalProjectionTransaction, newStoryProjectionCaches, project as projectCanonicalStory, publishCanonicalProjection };
|