@stll/folio-core 0.67.0 → 0.69.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/ai-edits/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +106 -36
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +31 -14
- package/dist/controller/canonicalComposition.js +35 -6
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +32 -7
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +23 -0
- package/dist/controller/canonicalLockGuard.js +133 -0
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +676 -46
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +133 -21
- package/dist/controller/canonicalSession.js +738 -205
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +4 -3
- package/dist/controller/canonicalStoryEditor.js +20 -15
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +4 -0
- package/dist/controller/headerFooterEditorManager.d.ts +7 -2
- package/dist/controller/headerFooterEditorManager.js +11 -6
- package/dist/controller/hiddenEditorApi.d.ts +17 -2
- package/dist/controller/hiddenEditorApi.js +4 -0
- package/dist/controller/hiddenEditorManager.d.ts +11 -3
- package/dist/controller/hiddenEditorManager.js +157 -48
- package/dist/controller/layoutPipeline.js +50 -16
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +7 -2
- package/dist/controller/noteEditorManager.js +11 -6
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
- package/dist/document-operations.d.ts +9 -1
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +11 -2
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +40 -5
- package/dist/docx/commentAnchorIndex.js +94 -12
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +27 -0
- package/dist/docx/hostCommentThreads.js +72 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +226 -96
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +29 -0
- package/dist/docx/paragraphPropertySource.js +106 -16
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +8 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +171 -33
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +5 -2
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +19 -2
- package/dist/docx/structuralXmlPatch.js +44 -11
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- 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/textStreamDom.js +3 -2
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +16 -6
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +42 -1
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +54 -46
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +16 -16
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- 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/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +2 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +30 -2
- package/dist/prosemirror/commands/comments.js +189 -18
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
- package/dist/prosemirror/conversion/toProseDoc.js +432 -76
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +37 -15
- package/dist/prosemirror/plugins/suggestionMode.js +33 -10
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +13 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +79 -5
- package/dist/redline.js +23 -9
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +38 -16
- package/dist/types/canonicalCapabilities.js +21 -18
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -3
|
@@ -3,8 +3,9 @@ import { markParagraphPropertySourceTransfers } from "../../docx/paragraphProper
|
|
|
3
3
|
import { RevisionResolutionStep } from "../../internal/revisionResolutionStep.js";
|
|
4
4
|
import { finalRevisionParagraphRanges } from "../../internal/revisionResolutionTracking.js";
|
|
5
5
|
import { deleteTextBoxesAnchoredAt, droppedTextBoxAnchorIds, moveTextBoxesPastNextParagraph } from "../anchoredTextBoxes.js";
|
|
6
|
-
import { expectFieldAttrs, expectParagraphAttrs, expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../attrs/index.js";
|
|
7
|
-
import { readCommentRangeBoundaryAttrs } from "../commentRangeBoundaryAttrs.js";
|
|
6
|
+
import { expectCommentMarkAttrs, expectFieldAttrs, expectParagraphAttrs, expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../attrs/index.js";
|
|
7
|
+
import { isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs } from "../commentRangeBoundaryAttrs.js";
|
|
8
|
+
import { retireThreadsResolvedAway } from "../commentRecords.js";
|
|
8
9
|
import { addedBreakCarrierBefore, finalParagraphsOf } from "../containerFinalParagraph.js";
|
|
9
10
|
import { enclosingRevisionIds, resolutionRemovesControl, withoutResolvedEnclosures } from "../contentControlRevisions.js";
|
|
10
11
|
import { copyOriginBoundaryAttrsAfterResolution } from "../copyOriginResolution.js";
|
|
@@ -15,6 +16,7 @@ import { markChangedParagraphRanges, markStructuralChange, markTrackedSectionEnd
|
|
|
15
16
|
import "../extensions/nodes/SdtExtension.js";
|
|
16
17
|
import { canonicalFieldNode } from "../fieldRepresentation.js";
|
|
17
18
|
import { isBlockBoundaryNode, normalizeKeptRangeBoundaries, paragraphRemainsOf, removeResolvedSubtree, revisionLayerRemovesContent } from "../keptRangeBoundaries.js";
|
|
19
|
+
import { lockedControlSpans, lockedControlViolationOfTransform } from "../lockedControls.js";
|
|
18
20
|
import { resolveStateStory } from "../markupViewProjection.js";
|
|
19
21
|
import { joinAtParagraphMark } from "../paragraphMarkJoin.js";
|
|
20
22
|
import { carryParagraphProperties, paragraphLeftAfter } from "../paragraphPropertyCarry.js";
|
|
@@ -47,6 +49,7 @@ import { Fragment } from "prosemirror-model";
|
|
|
47
49
|
import { TableMap } from "prosemirror-tables";
|
|
48
50
|
import { Mapping } from "prosemirror-transform";
|
|
49
51
|
import { paragraphMarkOutcome } from "@stll/docx-core/ops";
|
|
52
|
+
import { closeHistory } from "prosemirror-history";
|
|
50
53
|
// src/prosemirror/commands/comments.ts
|
|
51
54
|
/**
|
|
52
55
|
* Comment and Track Changes Commands
|
|
@@ -85,8 +88,17 @@ function removeCommentMark(commentId) {
|
|
|
85
88
|
return true;
|
|
86
89
|
};
|
|
87
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* What every review resolution does before it is dispatched: it retires the
|
|
93
|
+
* comment threads it left without an anchor, and it is an undo step of its
|
|
94
|
+
* own, never merged into the edit it resolves.
|
|
95
|
+
*/
|
|
96
|
+
const finishResolution = (state, tr) => {
|
|
97
|
+
retireThreadsResolvedAway(state, tr);
|
|
98
|
+
closeHistory(tr);
|
|
99
|
+
};
|
|
88
100
|
const keptIn = (range) => range.removals.flatMap(({ kept }) => kept);
|
|
89
|
-
function
|
|
101
|
+
function resolveChangeUnguarded(from, to, mode, revisionIds) {
|
|
90
102
|
return (state, dispatch) => {
|
|
91
103
|
const insertionType = state.schema.marks["insertion"];
|
|
92
104
|
const deletionType = state.schema.marks["deletion"];
|
|
@@ -522,7 +534,7 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
522
534
|
});
|
|
523
535
|
return false;
|
|
524
536
|
}
|
|
525
|
-
if (node
|
|
537
|
+
if (isCommentRangeBoundaryNode(node)) {
|
|
526
538
|
const attrs = readCommentRangeBoundaryAttrs(node);
|
|
527
539
|
if (attrs.ok && doomed.has(attrs.value.marker.id)) {
|
|
528
540
|
carriers.push({
|
|
@@ -547,6 +559,7 @@ function resolveChange(from, to, mode, revisionIds) {
|
|
|
547
559
|
for (const carrier of carriers.toReversed()) tr.delete(carrier.position, carrier.position + carrier.size);
|
|
548
560
|
}
|
|
549
561
|
normalizeKeptRangeBoundaries(tr, keptBoundaries);
|
|
562
|
+
finishResolution(state, tr);
|
|
550
563
|
if (tr.steps.length > 0) dispatch(tr);
|
|
551
564
|
}
|
|
552
565
|
return true;
|
|
@@ -894,6 +907,50 @@ function findParagraphBoundaryChangeAtPosition(state, pos) {
|
|
|
894
907
|
}
|
|
895
908
|
return null;
|
|
896
909
|
}
|
|
910
|
+
/** The transaction `command` would dispatch on `state`, or `null` when it would not apply. */
|
|
911
|
+
const attemptedTransaction = (command, state, view) => {
|
|
912
|
+
let attempted = null;
|
|
913
|
+
return command(state, (transaction) => {
|
|
914
|
+
attempted = transaction;
|
|
915
|
+
}, view) ? attempted : null;
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* `command`, refused when what it would do breaks a content control's lock
|
|
919
|
+
* (`lockedControlViolationOfTransform`). A document without a locked control
|
|
920
|
+
* runs it as it is.
|
|
921
|
+
*/
|
|
922
|
+
const honouringContentControlLocks = (command) => (state, dispatch, view) => {
|
|
923
|
+
if (lockedControlSpans(state.doc).length === 0) return command(state, dispatch, view);
|
|
924
|
+
const attempted = attemptedTransaction(command, state, view);
|
|
925
|
+
if (attempted === null) return false;
|
|
926
|
+
if (lockedControlViolationOfTransform(attempted) !== null) return false;
|
|
927
|
+
dispatch?.(attempted);
|
|
928
|
+
return true;
|
|
929
|
+
};
|
|
930
|
+
function resolveChange(from, to, mode, revisionIds) {
|
|
931
|
+
return honouringContentControlLocks(resolveChangeUnguarded(from, to, mode, revisionIds));
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* What the content-control locks say about resolving the tracked changes
|
|
935
|
+
* between `from` and `to` (only those of `revisionIds`, when given): `null`
|
|
936
|
+
* when they allow it or there is nothing there to resolve. A revision whose
|
|
937
|
+
* resolution would change a content-locked control's content, or remove a
|
|
938
|
+
* control locked against removal, stays pending.
|
|
939
|
+
*/
|
|
940
|
+
const changeResolutionLockViolation = (state, { from, to, mode, revisionIds }) => {
|
|
941
|
+
if (lockedControlSpans(state.doc).length === 0) return null;
|
|
942
|
+
const attempted = attemptedTransaction(resolveChangeUnguarded(from, to, mode, revisionIds), state);
|
|
943
|
+
return attempted === null ? null : lockedControlViolationOfTransform(attempted);
|
|
944
|
+
};
|
|
945
|
+
/** {@link changeResolutionLockViolation} for the revisions `revisionIds`, wherever they are. */
|
|
946
|
+
const revisionResolutionLockViolation = (state, revisionIds, mode) => {
|
|
947
|
+
const range = findAIEditRevisionRange(state, revisionIds);
|
|
948
|
+
return range === null ? null : changeResolutionLockViolation(state, {
|
|
949
|
+
...range,
|
|
950
|
+
mode,
|
|
951
|
+
revisionIds: typeof revisionIds === "number" ? [revisionIds] : revisionIds
|
|
952
|
+
});
|
|
953
|
+
};
|
|
897
954
|
/**
|
|
898
955
|
* Accept a tracked change at the given range.
|
|
899
956
|
* - Insertion: remove mark, keep text
|
|
@@ -936,6 +993,7 @@ const resolveAllChanges = (mode) => (state, dispatch) => {
|
|
|
936
993
|
removedEndpointCount: result.removedEndpointCount,
|
|
937
994
|
removedReferences: result.removedReferences
|
|
938
995
|
});
|
|
996
|
+
finishResolution(state, tr);
|
|
939
997
|
dispatch(tr);
|
|
940
998
|
return true;
|
|
941
999
|
};
|
|
@@ -944,19 +1002,65 @@ const resolveAllChanges = (mode) => (state, dispatch) => {
|
|
|
944
1002
|
* suggestions are present because this command cannot restage them.
|
|
945
1003
|
*/
|
|
946
1004
|
function acceptAllChanges() {
|
|
947
|
-
const resolve =
|
|
948
|
-
return (state, dispatch) => {
|
|
1005
|
+
const resolve = resolveAllChangesHonouringLocks("accept");
|
|
1006
|
+
return (state, dispatch, view) => {
|
|
949
1007
|
if (getSuggestions(state).length > 0) return false;
|
|
950
|
-
return resolve(state, dispatch);
|
|
1008
|
+
return resolve(state, dispatch, view);
|
|
951
1009
|
};
|
|
952
1010
|
}
|
|
953
1011
|
/**
|
|
954
1012
|
* Reject all tracked changes in the document.
|
|
955
1013
|
*/
|
|
956
1014
|
function rejectAllChanges() {
|
|
957
|
-
return
|
|
1015
|
+
return resolveAllChangesHonouringLocks("reject");
|
|
958
1016
|
}
|
|
959
1017
|
/**
|
|
1018
|
+
* The revisions of `state` that a content control's lock keeps from being
|
|
1019
|
+
* resolved in `mode`, each with the lock's verdict: see
|
|
1020
|
+
* {@link changeResolutionLockViolation}. Empty without a locked control.
|
|
1021
|
+
*/
|
|
1022
|
+
const lockHeldRevisions = (state, mode) => {
|
|
1023
|
+
const held = /* @__PURE__ */ new Map();
|
|
1024
|
+
if (lockedControlSpans(state.doc).length === 0) return held;
|
|
1025
|
+
for (const id of new Set(extractTrackedChanges(state).entries.flatMap(trackedChangeEntryRevisionIds))) {
|
|
1026
|
+
const violation = revisionResolutionLockViolation(state, id, mode);
|
|
1027
|
+
if (violation !== null) held.set(id, violation);
|
|
1028
|
+
}
|
|
1029
|
+
return held;
|
|
1030
|
+
};
|
|
1031
|
+
/** Every revision id one sidebar entry stands for. */
|
|
1032
|
+
const trackedChangeEntryRevisionIds = (entry) => [.../* @__PURE__ */ new Set([
|
|
1033
|
+
entry.revisionId,
|
|
1034
|
+
...entry.insertionRevisionId === void 0 ? [] : [entry.insertionRevisionId],
|
|
1035
|
+
...entry.coalescedRevisionIds ?? []
|
|
1036
|
+
])];
|
|
1037
|
+
/**
|
|
1038
|
+
* Resolve every tracked change a content control's lock allows. Without a
|
|
1039
|
+
* change the locks hold, the whole story resolves in one pass, as before;
|
|
1040
|
+
* otherwise each other change resolves on its own, in an editor view (a
|
|
1041
|
+
* transaction each), and the held ones stay pending as they are. Without a
|
|
1042
|
+
* view nothing resolves when any change is held.
|
|
1043
|
+
*/
|
|
1044
|
+
const resolveAllChangesHonouringLocks = (mode) => (state, dispatch, view) => {
|
|
1045
|
+
const resolveAll = resolveAllChanges(mode);
|
|
1046
|
+
if (lockedControlSpans(state.doc).length === 0) return resolveAll(state, dispatch, view);
|
|
1047
|
+
const attempted = attemptedTransaction(resolveAll, state, view);
|
|
1048
|
+
if (attempted === null) return false;
|
|
1049
|
+
if (lockedControlViolationOfTransform(attempted) === null) {
|
|
1050
|
+
dispatch?.(attempted);
|
|
1051
|
+
return true;
|
|
1052
|
+
}
|
|
1053
|
+
if (!dispatch) return true;
|
|
1054
|
+
if (!view) return false;
|
|
1055
|
+
const held = lockHeldRevisions(state, mode);
|
|
1056
|
+
const ids = new Set(extractTrackedChanges(state).entries.flatMap(trackedChangeEntryRevisionIds));
|
|
1057
|
+
for (const id of [...ids].toReversed()) {
|
|
1058
|
+
if (held.has(id)) continue;
|
|
1059
|
+
(mode === "accept" ? acceptAIEditRevision(id) : rejectAIEditRevision(id))(view.state, view.dispatch, view);
|
|
1060
|
+
}
|
|
1061
|
+
return true;
|
|
1062
|
+
};
|
|
1063
|
+
/**
|
|
960
1064
|
* Resolve a complete state synchronously for a headless reader or writer.
|
|
961
1065
|
*
|
|
962
1066
|
* Uses the same single-step resolver as the interactive editor command.
|
|
@@ -1086,6 +1190,46 @@ const SUGGESTION_MARK_NAMES = /* @__PURE__ */ new Set([
|
|
|
1086
1190
|
"runPropertyChange"
|
|
1087
1191
|
]);
|
|
1088
1192
|
const isSuggestionMark = (mark) => mark.attrs["provenance"] === "suggested" && SUGGESTION_MARK_NAMES.has(mark.type.name);
|
|
1193
|
+
/**
|
|
1194
|
+
* The suggestion a comment mark belongs to: a comment a suggestion proposed
|
|
1195
|
+
* is pending with it, never saved, accepted and rejected with it.
|
|
1196
|
+
*/
|
|
1197
|
+
const suggestedCommentOf = (mark) => {
|
|
1198
|
+
if (mark.type.name !== "comment") return null;
|
|
1199
|
+
const suggestionId = mark.attrs["suggestionId"];
|
|
1200
|
+
return typeof suggestionId === "string" && suggestionId.length > 0 ? suggestionId : null;
|
|
1201
|
+
};
|
|
1202
|
+
/** The ids of the comments a pending suggestion proposes. */
|
|
1203
|
+
function suggestionCommentIds(state, suggestionId) {
|
|
1204
|
+
return [...collectSuggestions(state).get(suggestionId)?.commentIds ?? []];
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Remove the comment marks of the suggestions `matches` selects, or, with
|
|
1208
|
+
* `keep`, clear their suggestion so they stay as ordinary comments. Mark
|
|
1209
|
+
* steps do not shift positions.
|
|
1210
|
+
*/
|
|
1211
|
+
const resolveSuggestedCommentMarks = (tr, matches, keep) => {
|
|
1212
|
+
const found = [];
|
|
1213
|
+
tr.doc.descendants((node, pos) => {
|
|
1214
|
+
if (!node.isInline) return void 0;
|
|
1215
|
+
for (const mark of node.marks) {
|
|
1216
|
+
const suggestionId = suggestedCommentOf(mark);
|
|
1217
|
+
if (suggestionId !== null && matches(suggestionId)) found.push({
|
|
1218
|
+
from: pos,
|
|
1219
|
+
to: pos + node.nodeSize,
|
|
1220
|
+
mark
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
for (const { from, to, mark } of found) {
|
|
1225
|
+
tr.removeMark(from, to, mark);
|
|
1226
|
+
if (keep) tr.addMark(from, to, mark.type.create({
|
|
1227
|
+
...mark.attrs,
|
|
1228
|
+
suggestionId: null
|
|
1229
|
+
}));
|
|
1230
|
+
}
|
|
1231
|
+
return found.length > 0;
|
|
1232
|
+
};
|
|
1089
1233
|
const suggestionKindOf = (mark) => {
|
|
1090
1234
|
if (mark.type.name === "insertion") return "insertion";
|
|
1091
1235
|
if (mark.type.name === "deletion") return "deletion";
|
|
@@ -1176,7 +1320,8 @@ const collectSuggestions = (state) => {
|
|
|
1176
1320
|
const created = {
|
|
1177
1321
|
segments: [],
|
|
1178
1322
|
kinds: /* @__PURE__ */ new Set(),
|
|
1179
|
-
revisionIds: /* @__PURE__ */ new Set()
|
|
1323
|
+
revisionIds: /* @__PURE__ */ new Set(),
|
|
1324
|
+
commentIds: /* @__PURE__ */ new Set()
|
|
1180
1325
|
};
|
|
1181
1326
|
bySuggestion.set(suggestionId, created);
|
|
1182
1327
|
return created;
|
|
@@ -1218,6 +1363,17 @@ const collectSuggestions = (state) => {
|
|
|
1218
1363
|
}
|
|
1219
1364
|
if (!node.isInline) return;
|
|
1220
1365
|
for (const mark of node.marks) {
|
|
1366
|
+
const commentSuggestion = suggestedCommentOf(mark);
|
|
1367
|
+
if (commentSuggestion !== null) {
|
|
1368
|
+
const entry = entryFor(commentSuggestion);
|
|
1369
|
+
entry.segments.push({
|
|
1370
|
+
from: pos,
|
|
1371
|
+
to: pos + node.nodeSize
|
|
1372
|
+
});
|
|
1373
|
+
entry.kinds.add("comment");
|
|
1374
|
+
entry.commentIds.add(expectCommentMarkAttrs(mark).commentId);
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1221
1377
|
if (!isSuggestionMark(mark)) continue;
|
|
1222
1378
|
const suggestionId = mark.attrs["suggestionId"];
|
|
1223
1379
|
if (typeof suggestionId !== "string" || suggestionId.length === 0) continue;
|
|
@@ -1240,8 +1396,10 @@ const collectSuggestions = (state) => {
|
|
|
1240
1396
|
* operations with one `suggestionId`) is `"mixed"`.
|
|
1241
1397
|
*/
|
|
1242
1398
|
const suggestionAppliedAs = (kinds) => {
|
|
1399
|
+
const changes = [...kinds].filter((kind) => kind !== "comment");
|
|
1400
|
+
if (changes.length === 0) return "direct";
|
|
1243
1401
|
if (!kinds.has("insertTable")) return "tracked";
|
|
1244
|
-
return
|
|
1402
|
+
return changes.some((kind) => kind !== "insertTable") ? "mixed" : "direct";
|
|
1245
1403
|
};
|
|
1246
1404
|
/** Merge sorted, possibly adjacent/overlapping segments into contiguous ranges. */
|
|
1247
1405
|
const mergeSegments = (segments) => {
|
|
@@ -1266,7 +1424,8 @@ const SUGGESTION_KIND_ORDER = [
|
|
|
1266
1424
|
"insertRow",
|
|
1267
1425
|
"deleteRow",
|
|
1268
1426
|
"insertColumn",
|
|
1269
|
-
"deleteColumn"
|
|
1427
|
+
"deleteColumn",
|
|
1428
|
+
"comment"
|
|
1270
1429
|
];
|
|
1271
1430
|
/**
|
|
1272
1431
|
* List every suggestion in the document for host consumption: its id, the
|
|
@@ -1756,8 +1915,12 @@ const acceptSuggestions = (matchesSuggestion, options) => {
|
|
|
1756
1915
|
shouldRotate: (_node, position) => directlyMarkedParagraphPositions.has(position),
|
|
1757
1916
|
fallbackAuthor: options.author
|
|
1758
1917
|
})) return false;
|
|
1918
|
+
if (resolveSuggestedCommentMarks(tr, matchesSuggestion, true)) changed = true;
|
|
1759
1919
|
if (!changed) return false;
|
|
1760
|
-
if (dispatch)
|
|
1920
|
+
if (dispatch) {
|
|
1921
|
+
finishResolution(state, tr);
|
|
1922
|
+
dispatch(tr);
|
|
1923
|
+
}
|
|
1761
1924
|
return true;
|
|
1762
1925
|
};
|
|
1763
1926
|
};
|
|
@@ -1798,7 +1961,7 @@ function rejectSuggestion(suggestionId) {
|
|
|
1798
1961
|
if (entry.revisionIds.size > 0) {
|
|
1799
1962
|
const ranges = mergeSegments(entry.segments);
|
|
1800
1963
|
const from = ranges[0]?.from ?? 0;
|
|
1801
|
-
|
|
1964
|
+
resolveChangeUnguarded(from, ranges.at(-1)?.to ?? from, "reject", [...entry.revisionIds])(state, (resolved) => {
|
|
1802
1965
|
tr = resolved;
|
|
1803
1966
|
});
|
|
1804
1967
|
}
|
|
@@ -1820,8 +1983,12 @@ function rejectSuggestion(suggestionId) {
|
|
|
1820
1983
|
tr: workingTr
|
|
1821
1984
|
})
|
|
1822
1985
|
})) return false;
|
|
1986
|
+
resolveSuggestedCommentMarks(workingTr, (id) => id === suggestionId, false);
|
|
1823
1987
|
if (workingTr.steps.length === 0) return false;
|
|
1824
|
-
if (dispatch)
|
|
1988
|
+
if (dispatch) {
|
|
1989
|
+
finishResolution(state, workingTr);
|
|
1990
|
+
dispatch(workingTr);
|
|
1991
|
+
}
|
|
1825
1992
|
return true;
|
|
1826
1993
|
};
|
|
1827
1994
|
}
|
|
@@ -1838,7 +2005,7 @@ function rejectAllSuggestions() {
|
|
|
1838
2005
|
}
|
|
1839
2006
|
const rotationCandidates = removesWholeNode ? collectAddedBreakRotationCandidates(state.doc) : [];
|
|
1840
2007
|
let tr = null;
|
|
1841
|
-
if (revisionIds.size > 0)
|
|
2008
|
+
if (revisionIds.size > 0) resolveChangeUnguarded(0, state.doc.content.size, "reject", [...revisionIds])(state, (resolved) => {
|
|
1842
2009
|
tr = resolved;
|
|
1843
2010
|
});
|
|
1844
2011
|
const workingTr = tr ?? state.tr;
|
|
@@ -1858,8 +2025,12 @@ function rejectAllSuggestions() {
|
|
|
1858
2025
|
tr: workingTr
|
|
1859
2026
|
})
|
|
1860
2027
|
})) return false;
|
|
2028
|
+
resolveSuggestedCommentMarks(workingTr, () => true, false);
|
|
1861
2029
|
if (workingTr.steps.length === 0) return false;
|
|
1862
|
-
if (dispatch)
|
|
2030
|
+
if (dispatch) {
|
|
2031
|
+
finishResolution(state, workingTr);
|
|
2032
|
+
dispatch(workingTr);
|
|
2033
|
+
}
|
|
1863
2034
|
return true;
|
|
1864
2035
|
};
|
|
1865
2036
|
}
|
|
@@ -1909,7 +2080,7 @@ function findChangeAtPosition(state, from, to) {
|
|
|
1909
2080
|
};
|
|
1910
2081
|
const $pos = state.doc.resolve(from);
|
|
1911
2082
|
const node = $pos.parent;
|
|
1912
|
-
if (!node.
|
|
2083
|
+
if (!node.inlineContent) return {
|
|
1913
2084
|
from,
|
|
1914
2085
|
to
|
|
1915
2086
|
};
|
|
@@ -2070,4 +2241,4 @@ function findPreviousChange(state, startPos) {
|
|
|
2070
2241
|
if (result.value === null && startPos < state.doc.content.size) return findPreviousChange(state, state.doc.content.size);
|
|
2071
2242
|
return result.value;
|
|
2072
2243
|
}
|
|
2073
|
-
export { acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, resolveAllChangesInHeadlessState, resolveAllChangesInHeadlessStateWithMapping, suggestionIdOfRevision };
|
|
2244
|
+
export { acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, changeResolutionLockViolation, findAIEditRevisionRange, findChangeAtPosition, findNextChange, findParagraphBoundaryChangeAtPosition, findPreviousChange, findSuggestionRange, getSuggestions, lockHeldRevisions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark, resolveAllChangesInHeadlessState, resolveAllChangesInHeadlessStateWithMapping, revisionResolutionLockViolation, suggestionCommentIds, suggestionIdOfRevision, trackedChangeEntryRevisionIds };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { TextColorAttrs } from "../schema/marks.js";
|
|
3
|
-
import "../schema/index.js";
|
|
4
3
|
import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
|
|
4
|
+
import "../schema/index.js";
|
|
5
5
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
|
|
6
6
|
import { Mark } from "prosemirror-model";
|
|
7
7
|
import { Command } from "prosemirror-state";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
|
|
1
2
|
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs, getParagraphAlignment, getParagraphBidi, getStyleId } from "../extensions/core/ParagraphExtension.js";
|
|
2
3
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
|
|
3
4
|
import { AcceptSuggestionOptions, FolioSuggestion, SuggestionAppliedAs, SuggestionKind, acceptAIEditRevision, acceptAllChanges, acceptAllSuggestions, acceptChange, acceptSuggestion, addCommentMark, findAIEditRevisionRange, findNextChange, findPreviousChange, findSuggestionRange, getSuggestions, rejectAIEditRevision, rejectAllChanges, rejectAllSuggestions, rejectChange, rejectSuggestion, removeCommentMark } from "./comments.js";
|
|
4
5
|
import { CapturedTextFormatting, PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./formatPainter.js";
|
|
5
|
-
import { clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive } from "../extensions/marks/markUtils.js";
|
|
6
6
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "../extensions/marks/HyperlinkExtension.js";
|
|
7
7
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, setUnderlineStyle, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./formatting.js";
|
|
8
8
|
import { getListInfo, isInList } from "../extensions/features/ListExtension.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expectCommentRangeBoundaryAttrs } from "./commentRangeBoundaryAttrs.js";
|
|
1
|
+
import { expectCommentRangeBoundaryAttrs, isCommentRangeBoundaryNode } from "./commentRangeBoundaryAttrs.js";
|
|
2
2
|
import { maxAnnotationIdInDoc, seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
3
3
|
import { readRangeAnchorAttrs } from "./rangeAnchorAttrs.js";
|
|
4
4
|
import { TaggedError } from "better-result";
|
|
@@ -57,7 +57,7 @@ function seedCommentAllocator(allocator, comments, view) {
|
|
|
57
57
|
const attrs = readRangeAnchorAttrs(node);
|
|
58
58
|
if (attrs.ok && attrs.value.start.type === "commentRangeStart") allocator.seedAbove(attrs.value.start.id);
|
|
59
59
|
}
|
|
60
|
-
if (node
|
|
60
|
+
if (isCommentRangeBoundaryNode(node)) allocator.seedAbove(expectCommentRangeBoundaryAttrs(node).marker.id);
|
|
61
61
|
});
|
|
62
62
|
max = Math.max(max, maxAnnotationIdInDoc(view.state.doc));
|
|
63
63
|
}
|
|
@@ -8,6 +8,12 @@ type CommentRangeBoundaryMarker = Extract<ParagraphContent, {
|
|
|
8
8
|
type CommentRangeBoundaryAttrs = {
|
|
9
9
|
marker: CommentRangeBoundaryMarker;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether a node is a comment range boundary, inside a paragraph or between
|
|
13
|
+
* blocks. Both carry the same marker, so every reader asks this rather than
|
|
14
|
+
* naming one of them.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isCommentRangeBoundaryNode: (node: Node) => boolean;
|
|
11
17
|
export declare const readCommentRangeBoundaryMarker: (value: unknown) => CommentRangeBoundaryMarker | undefined;
|
|
12
18
|
export declare const readCommentRangeBoundaryAttrs: (node: Node) => ReadProseMirrorAttrsResult<CommentRangeBoundaryAttrs>;
|
|
13
19
|
export declare const expectCommentRangeBoundaryAttrs: (node: Node) => CommentRangeBoundaryAttrs;
|
|
@@ -2,6 +2,12 @@ import { isDisplacedByCustomXml } from "./bookmarkBoundaryAttrs.js";
|
|
|
2
2
|
import { panic } from "better-result";
|
|
3
3
|
// src/prosemirror/commentRangeBoundaryAttrs.ts
|
|
4
4
|
const attrsCache = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Whether a node is a comment range boundary, inside a paragraph or between
|
|
7
|
+
* blocks. Both carry the same marker, so every reader asks this rather than
|
|
8
|
+
* naming one of them.
|
|
9
|
+
*/
|
|
10
|
+
const isCommentRangeBoundaryNode = (node) => node.type.name === "commentRangeBoundary" || node.type.name === "blockCommentRangeBoundary";
|
|
5
11
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
6
12
|
const readCommentRangeBoundaryMarker = (value) => {
|
|
7
13
|
if (!isRecord(value)) return void 0;
|
|
@@ -18,9 +24,9 @@ const readCommentRangeBoundaryMarker = (value) => {
|
|
|
18
24
|
};
|
|
19
25
|
const readCommentRangeBoundaryAttrs = (node) => {
|
|
20
26
|
const issues = [];
|
|
21
|
-
if (node
|
|
27
|
+
if (!isCommentRangeBoundaryNode(node)) issues.push({
|
|
22
28
|
path: "commentRangeBoundary.type.name",
|
|
23
|
-
message: `Expected commentRangeBoundary, got ${node.type.name}.`
|
|
29
|
+
message: `Expected commentRangeBoundary or blockCommentRangeBoundary, got ${node.type.name}.`
|
|
24
30
|
});
|
|
25
31
|
const marker = readCommentRangeBoundaryMarker(node.attrs["marker"]);
|
|
26
32
|
if (!marker) issues.push({
|
|
@@ -47,4 +53,4 @@ const expectCommentRangeBoundaryAttrs = (node) => {
|
|
|
47
53
|
attrsCache.set(node, result.value);
|
|
48
54
|
return result.value;
|
|
49
55
|
};
|
|
50
|
-
export { expectCommentRangeBoundaryAttrs, readCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker };
|
|
56
|
+
export { expectCommentRangeBoundaryAttrs, isCommentRangeBoundaryNode, readCommentRangeBoundaryAttrs, readCommentRangeBoundaryMarker };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Comment } from "../types/content.js";
|
|
2
|
+
import { Node, Schema } from "prosemirror-model";
|
|
3
|
+
import { EditorState, Plugin, Transaction } from "prosemirror-state";
|
|
4
|
+
import { EditorView } from "prosemirror-view";
|
|
5
|
+
import { Step, StepMap, StepResult } from "prosemirror-transform";
|
|
6
|
+
export type CommentRecords = readonly Comment[];
|
|
7
|
+
/**
|
|
8
|
+
* Replace the session's comment records. The document is unchanged, so the
|
|
9
|
+
* step maps nothing; its inverse puts back the records it replaced.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CommentRecordsStep extends Step {
|
|
12
|
+
readonly before: CommentRecords;
|
|
13
|
+
readonly after: CommentRecords;
|
|
14
|
+
constructor(before: CommentRecords, after: CommentRecords);
|
|
15
|
+
apply(doc: Node): StepResult;
|
|
16
|
+
getMap(): StepMap;
|
|
17
|
+
invert(): CommentRecordsStep;
|
|
18
|
+
map(): CommentRecordsStep;
|
|
19
|
+
merge(other: Step): CommentRecordsStep | null;
|
|
20
|
+
toJSON(): unknown;
|
|
21
|
+
static fromJSON(_schema: Schema, json: unknown): CommentRecordsStep;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Who changed the records: `edit` for user edits and history, which hosts
|
|
25
|
+
* report to their listeners; `sync` when a host wrote its own value in.
|
|
26
|
+
*/
|
|
27
|
+
export type CommentRecordsOrigin = "edit" | "sync";
|
|
28
|
+
type CommentRecordsPluginState = {
|
|
29
|
+
records: CommentRecords;
|
|
30
|
+
origin: CommentRecordsOrigin;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Told the records after every change; `null` when the view's state stops
|
|
34
|
+
* holding records (another session took the view over, or it was destroyed).
|
|
35
|
+
*/
|
|
36
|
+
type CommentRecordsListener = (records: CommentRecords | null, origin: CommentRecordsOrigin) => void;
|
|
37
|
+
/**
|
|
38
|
+
* The plugin that holds a session's comment records, starting from `initial`
|
|
39
|
+
* (the loaded document's comments).
|
|
40
|
+
*/
|
|
41
|
+
export declare function createCommentRecordsPlugin(initial: CommentRecords): Plugin<CommentRecordsPluginState>;
|
|
42
|
+
/** The session's comment records, or `null` when the state holds none. */
|
|
43
|
+
export declare function commentRecordsOf(state: EditorState): CommentRecords | null;
|
|
44
|
+
/**
|
|
45
|
+
* Call `listener` whenever the view's comment records change, including a
|
|
46
|
+
* state the view is given for a newly loaded document. Returns the
|
|
47
|
+
* unsubscribe function.
|
|
48
|
+
*/
|
|
49
|
+
export declare function subscribeCommentRecords(view: EditorView, listener: CommentRecordsListener): () => void;
|
|
50
|
+
/** The records a transaction ends on, given the state it started from. */
|
|
51
|
+
export declare function commentRecordsAfter(state: EditorState, transaction: Transaction): CommentRecords | null;
|
|
52
|
+
/**
|
|
53
|
+
* Add the step replacing the records `transaction` ends on with `next`.
|
|
54
|
+
* Returns false when the state holds no records.
|
|
55
|
+
*/
|
|
56
|
+
export declare function stepCommentRecords(state: EditorState, transaction: Transaction, next: CommentRecords): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* A transaction writing a host's value into the records: kept out of the
|
|
59
|
+
* undo history and reported as `sync`, so it is not echoed back to the host.
|
|
60
|
+
*/
|
|
61
|
+
export declare function syncCommentRecords(state: EditorState, next: CommentRecords): Transaction | null;
|
|
62
|
+
/**
|
|
63
|
+
* Whether a transaction only writes a host's comment list in: no document
|
|
64
|
+
* content and no user edit changes, so it neither marks the document changed
|
|
65
|
+
* nor needs an editable document.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isCommentRecordsSync(transaction: Transaction): boolean;
|
|
68
|
+
/** A comment and every reply whose parent chain reaches it. */
|
|
69
|
+
export declare function commentThreadIds(records: CommentRecords, id: number): Set<number>;
|
|
70
|
+
/**
|
|
71
|
+
* An undoable edit replacing the records with `next`, for a host change that
|
|
72
|
+
* touches no anchor (a reply, a resolution, a list the host computed).
|
|
73
|
+
*/
|
|
74
|
+
export declare function editCommentRecords(state: EditorState, next: CommentRecords): Transaction | null;
|
|
75
|
+
/** Append comments (new threads or replies) to the records. */
|
|
76
|
+
export declare function appendCommentRecords(state: EditorState, additions: readonly Comment[]): Transaction | null;
|
|
77
|
+
/** Mark one comment resolved or open again. */
|
|
78
|
+
export declare function setCommentResolved(state: EditorState, id: number, done: boolean): Transaction | null;
|
|
79
|
+
export type CommentRange = {
|
|
80
|
+
from: number;
|
|
81
|
+
to: number;
|
|
82
|
+
};
|
|
83
|
+
type DispatchingView = Pick<EditorView, "state" | "dispatch">;
|
|
84
|
+
/**
|
|
85
|
+
* Anchor a new thread on `range` and add its record, in one transaction.
|
|
86
|
+
* Returns null when the range is empty or out of the document.
|
|
87
|
+
*/
|
|
88
|
+
export declare function addCommentThread(state: EditorState, range: CommentRange, comment: Comment): Transaction | null;
|
|
89
|
+
/**
|
|
90
|
+
* Show the add-comment flow's highlight on `range`. The highlight is not an
|
|
91
|
+
* edit: it stays out of the undo history, so undoing a comment never brings
|
|
92
|
+
* it back.
|
|
93
|
+
*/
|
|
94
|
+
export declare function markPendingComment(view: DispatchingView, range: CommentRange, options?: {
|
|
95
|
+
selectEnd?: boolean;
|
|
96
|
+
}): boolean;
|
|
97
|
+
/** Remove the add-comment flow's highlight from `range`. */
|
|
98
|
+
export declare function clearPendingComment(view: DispatchingView, range: CommentRange): void;
|
|
99
|
+
/**
|
|
100
|
+
* The add-comment flow's commit: the highlight on `range` gives way to the
|
|
101
|
+
* new thread's mark, and the thread joins the records, as one undoable edit.
|
|
102
|
+
*/
|
|
103
|
+
export declare function commitCommentThread(view: DispatchingView, range: CommentRange, comment: Comment): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Remove every anchor of the comments in `ids` from the transaction's
|
|
106
|
+
* document: their `comment` marks, references and range boundaries.
|
|
107
|
+
*/
|
|
108
|
+
export declare function removeCommentAnchors(transaction: Transaction, ids: ReadonlySet<number>): void;
|
|
109
|
+
/** Delete a thread: its record, every reply under it, and its anchors. */
|
|
110
|
+
export declare function deleteCommentThread(state: EditorState, id: number): Transaction | null;
|
|
111
|
+
/**
|
|
112
|
+
* The comment ids a document names through a mark, reference or range
|
|
113
|
+
* boundary.
|
|
114
|
+
*/
|
|
115
|
+
export declare function commentIdsNamedIn(doc: Node): Set<number>;
|
|
116
|
+
/**
|
|
117
|
+
* Remove the threads a review resolution left without any anchor: accepting
|
|
118
|
+
* the deletion of everything a comment covers, or rejecting the suggestion
|
|
119
|
+
* that inserted it, retires the comment with its replies, in the same
|
|
120
|
+
* transaction. Other edits keep records whose anchors are gone for now (a
|
|
121
|
+
* cut keeps the thread for the paste).
|
|
122
|
+
*/
|
|
123
|
+
export declare function retireThreadsResolvedAway(state: EditorState, transaction: Transaction): void;
|
|
124
|
+
/**
|
|
125
|
+
* Add the records of `created` comments that `transaction`'s document names
|
|
126
|
+
* and the records lack, so comments a document operation anchors join the
|
|
127
|
+
* records in the operation's own transaction.
|
|
128
|
+
*/
|
|
129
|
+
export declare function recordCreatedComments(state: EditorState, transaction: Transaction, created: readonly Comment[]): void;
|
|
130
|
+
/**
|
|
131
|
+
* `view` for a document operation: its dispatch adds the records of the
|
|
132
|
+
* `created` comments the operation anchors, in the operation's transaction.
|
|
133
|
+
*/
|
|
134
|
+
export declare function recordingCommentsView(view: DispatchingView, created: readonly Comment[]): DispatchingView;
|
|
135
|
+
/** Panic unless the state holds records; for callers that require them. */
|
|
136
|
+
export declare function expectCommentRecords(state: EditorState): CommentRecords;
|
|
137
|
+
export {};
|