@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
|
@@ -9,8 +9,8 @@ import { CanonicalCommentRequest, CanonicalCommentResult } from "../types/canoni
|
|
|
9
9
|
import { CanonicalSectionPropertiesResult } from "../types/canonicalSections.js";
|
|
10
10
|
import { Node } from "prosemirror-model";
|
|
11
11
|
import { Command, EditorState, Transaction } from "prosemirror-state";
|
|
12
|
-
import { EditorView } from "prosemirror-view";
|
|
13
12
|
import { DocumentOp, FormattingPatch, OpStory } from "@stll/docx-core/ops";
|
|
13
|
+
import { EditorView } from "prosemirror-view";
|
|
14
14
|
type CanonicalStoryHistoryOptions = {
|
|
15
15
|
view: EditorView;
|
|
16
16
|
story: OpStory;
|
|
@@ -44,6 +44,11 @@ export type HiddenEditorApi = {
|
|
|
44
44
|
setCanonicalMode: (mode: CanonicalSessionMode) => boolean;
|
|
45
45
|
/** Resolve canonical revisions as one batch and journal its exact inverse. */
|
|
46
46
|
resolveCanonicalRevisions: (revisionIds: readonly number[], resolution: "accept" | "reject") => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Accept a pending suggestion as ordinary tracked changes by `author`, or
|
|
49
|
+
* reject it, as one journalled change.
|
|
50
|
+
*/
|
|
51
|
+
resolveCanonicalSuggestion: (suggestionId: string, resolution: "accept" | "reject", author: string) => boolean;
|
|
47
52
|
updateCanonicalInputLifecycle: (action: "beginComposition" | "endComposition" | "breakUndoGroup") => boolean;
|
|
48
53
|
applyCanonicalStoryHistory: (options: CanonicalStoryHistoryOptions) => boolean;
|
|
49
54
|
applyCanonicalOperations: (ops: readonly DocumentOp[]) => boolean;
|
|
@@ -56,6 +61,15 @@ export type HiddenEditorApi = {
|
|
|
56
61
|
} | null;
|
|
57
62
|
getCanonicalStoryProjection: (story: OpStory) => Node | null;
|
|
58
63
|
replaceCanonicalStoryText: (options: CanonicalStoryTextOptions) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The editor a person is working in for `story`: public operations on that
|
|
66
|
+
* story read its state, so its selection maps through them, and publish to
|
|
67
|
+
* it. A later view for the story replaces it; a destroyed one is ignored.
|
|
68
|
+
*/
|
|
69
|
+
noteCanonicalStoryView: (options: {
|
|
70
|
+
story: OpStory;
|
|
71
|
+
view: EditorView;
|
|
72
|
+
}) => void;
|
|
59
73
|
applyCanonicalDocumentOperations: (options: CanonicalPublicOperationOptions) => FolioDocumentOperationResult | null;
|
|
60
74
|
undoCanonicalDocumentOperations: (handle: FolioDocumentOperationUndoHandle) => FolioDocumentOperationUndoResult | null;
|
|
61
75
|
/** Focus the hidden editor */
|
|
@@ -95,9 +109,10 @@ export type HiddenEditorApiDeps = {
|
|
|
95
109
|
isCanonicalSaveCurrent?: HiddenEditorApi["isCanonicalSaveCurrent"];
|
|
96
110
|
setCanonicalMode?: HiddenEditorApi["setCanonicalMode"];
|
|
97
111
|
resolveCanonicalRevisions?: HiddenEditorApi["resolveCanonicalRevisions"];
|
|
112
|
+
resolveCanonicalSuggestion?: HiddenEditorApi["resolveCanonicalSuggestion"];
|
|
98
113
|
executeCanonicalCommand?: (command: Command) => boolean | undefined;
|
|
99
114
|
getCanonicalHistory?: () => Pick<HiddenEditorApi, "undo" | "redo" | "canUndo" | "canRedo"> | null;
|
|
100
|
-
canonicalOperations?: Pick<HiddenEditorApi, "updateCanonicalInputLifecycle" | "applyCanonicalOperations" | "applyCanonicalComment" | "applyCanonicalSectionProperties" | "getCanonicalStoryProjection" | "replaceCanonicalStoryText" | "applyCanonicalStoryHistory" | "getCanonicalStorySelection" | "applyCanonicalDocumentOperations" | "undoCanonicalDocumentOperations">;
|
|
115
|
+
canonicalOperations?: Pick<HiddenEditorApi, "updateCanonicalInputLifecycle" | "applyCanonicalOperations" | "applyCanonicalComment" | "applyCanonicalSectionProperties" | "getCanonicalStoryProjection" | "replaceCanonicalStoryText" | "noteCanonicalStoryView" | "applyCanonicalStoryHistory" | "getCanonicalStorySelection" | "applyCanonicalDocumentOperations" | "undoCanonicalDocumentOperations">;
|
|
101
116
|
isDestroying: () => boolean;
|
|
102
117
|
ensureView: () => void;
|
|
103
118
|
isViewRequested: () => boolean;
|
|
@@ -34,6 +34,7 @@ const createHiddenEditorApi = (deps) => {
|
|
|
34
34
|
getView: () => deps.getView() ?? null,
|
|
35
35
|
setCanonicalMode: (mode) => !deps.isDestroying() && (deps.setCanonicalMode?.(mode) ?? false),
|
|
36
36
|
resolveCanonicalRevisions: (revisionIds, resolution) => !deps.isDestroying() && (deps.resolveCanonicalRevisions?.(revisionIds, resolution) ?? false),
|
|
37
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => !deps.isDestroying() && (deps.resolveCanonicalSuggestion?.(suggestionId, resolution, author) ?? false),
|
|
37
38
|
getCanonicalComments: () => deps.getCanonicalComments?.() ?? null,
|
|
38
39
|
getCanonicalCommittedVersion: () => deps.getCanonicalCommittedVersion?.() ?? null,
|
|
39
40
|
captureCanonicalSave: () => deps.captureCanonicalSave?.() ?? null,
|
|
@@ -57,6 +58,9 @@ const createHiddenEditorApi = (deps) => {
|
|
|
57
58
|
getCanonicalStorySelection: (story) => deps.canonicalOperations?.getCanonicalStorySelection(story) ?? null,
|
|
58
59
|
getCanonicalStoryProjection: (story) => deps.canonicalOperations?.getCanonicalStoryProjection(story) ?? null,
|
|
59
60
|
replaceCanonicalStoryText: (options) => deps.canonicalOperations?.replaceCanonicalStoryText(options) ?? false,
|
|
61
|
+
noteCanonicalStoryView: (options) => {
|
|
62
|
+
deps.canonicalOperations?.noteCanonicalStoryView(options);
|
|
63
|
+
},
|
|
60
64
|
applyCanonicalDocumentOperations: (options) => deps.canonicalOperations?.applyCanonicalDocumentOperations(options) ?? null,
|
|
61
65
|
undoCanonicalDocumentOperations: (handle) => deps.canonicalOperations?.undoCanonicalDocumentOperations(handle) ?? null,
|
|
62
66
|
focus: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { EditorMode } from "../managers/EditorModeManager.js";
|
|
4
4
|
import { HiddenEditorApi } from "./hiddenEditorApi.js";
|
|
5
5
|
import { HiddenEditorStateReason } from "../layout-engine/layoutInstrumentation.js";
|
|
@@ -12,8 +12,9 @@ import * as Yjs from "yjs";
|
|
|
12
12
|
import { XmlFragment } from "yjs";
|
|
13
13
|
import * as YProseMirror from "y-prosemirror";
|
|
14
14
|
declare const CanonicalSessionRefusalErrorBase: TaggedErrorClass<"CanonicalSessionRefusalError">;
|
|
15
|
+
/** A refused input, with whether the session lacks the capability or the document forbids it. */
|
|
15
16
|
export declare class CanonicalSessionRefusalError extends CanonicalSessionRefusalErrorBase<{
|
|
16
|
-
|
|
17
|
+
ground: CanonicalRefusalGround;
|
|
17
18
|
message: string;
|
|
18
19
|
}> {}
|
|
19
20
|
type YProseMirrorModule = typeof YProseMirror;
|
|
@@ -65,7 +66,7 @@ export type HiddenEditorManagerDeps = {
|
|
|
65
66
|
getExperimentalSession?: () => "canonical" | undefined;
|
|
66
67
|
getEditingMode?: () => EditorMode;
|
|
67
68
|
getSuggestionAuthor?: () => string;
|
|
68
|
-
onSessionRefusal?: (reason: string,
|
|
69
|
+
onSessionRefusal?: (reason: string, ground: CanonicalRefusalGround, error?: Error) => void;
|
|
69
70
|
/**
|
|
70
71
|
* Identity of the loaded document as tracked by the adapter's loader: the
|
|
71
72
|
* same value across internal edits (so typing does not trigger an external
|
|
@@ -118,6 +119,13 @@ export type HiddenEditorManager = {
|
|
|
118
119
|
getView: () => EditorView | null;
|
|
119
120
|
isInitialized: () => boolean;
|
|
120
121
|
api: HiddenEditorApi;
|
|
122
|
+
/**
|
|
123
|
+
* The canonical session's own document, or null outside one, without the
|
|
124
|
+
* copy `api.getCanonicalDocument` makes for hosts. Each edit replaces it, so
|
|
125
|
+
* it stays as read; the editor's own story managers read it and never
|
|
126
|
+
* change it.
|
|
127
|
+
*/
|
|
128
|
+
readCanonicalDocument: () => document_d_exports.Document | null;
|
|
121
129
|
};
|
|
122
130
|
export declare const createHiddenEditorManager: (deps: HiddenEditorManagerDeps) => HiddenEditorManager;
|
|
123
131
|
export {};
|
|
@@ -4,6 +4,7 @@ import { isReadOnlyEditKey } from "../paged-layout/readOnlyEditAttempt.js";
|
|
|
4
4
|
import { getCanonicalCommandIntents } from "../prosemirror/canonicalCommands.js";
|
|
5
5
|
import { registerClipboardIntentHandler } from "../prosemirror/clipboardIntent.js";
|
|
6
6
|
import { pasteWithoutFormatting } from "../prosemirror/commands/pastePlainText.js";
|
|
7
|
+
import { createCommentRecordsPlugin, isCommentRecordsSync } from "../prosemirror/commentRecords.js";
|
|
7
8
|
import { createEmptyDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
8
9
|
import { registerEditorCommandOwner } from "../prosemirror/executeEditorCommand.js";
|
|
9
10
|
import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
|
|
@@ -11,13 +12,14 @@ import { ensureParaIdsInDoc, ensureParaIdsInState } from "../prosemirror/extensi
|
|
|
11
12
|
import { createParagraphChangeTrackerPlugin, markPackageChange } from "../prosemirror/extensions/features/ParagraphChangeTrackerExtension.js";
|
|
12
13
|
import { toggleMarkForAllScripts, toggleUnderlineMark } from "../prosemirror/extensions/marks/markUtils.js";
|
|
13
14
|
import { HyperlinkRemovalRefusal } from "../prosemirror/hyperlinkRemoval.js";
|
|
15
|
+
import { adoptNativeSelection, createNativeSelectionRefreshPlugin, isCompositionKeyDown } from "../prosemirror/nativeSelection.js";
|
|
14
16
|
import { markNoteReferenceReplay, noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
15
17
|
import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
|
|
16
18
|
import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
17
19
|
import { schema } from "../prosemirror/schema/index.js";
|
|
18
20
|
import { createTextInputPlugin } from "../prosemirror/textInput.js";
|
|
19
21
|
import { applyAttrSchemaMigrations, proseDocumentParagraphSourceContract, readYjsAttrSchemaVersion, readYjsParagraphSourceContract, withParagraphSourceContract, writeYjsDocumentMetadata } from "../prosemirror/yjsDocumentMetadata.js";
|
|
20
|
-
import { CANONICAL_GAP, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
22
|
+
import { CANONICAL_GAP, CANONICAL_RULE, usesCanonicalSession } from "../types/canonicalCapabilities.js";
|
|
21
23
|
import { prepareCanonicalPaste } from "./canonicalClipboard.js";
|
|
22
24
|
import { canonicalCommentBody, compileCanonicalComments } from "./canonicalComments.js";
|
|
23
25
|
import { createCanonicalInputBoundary } from "./canonicalInput.js";
|
|
@@ -29,11 +31,13 @@ import { prepareCanonicalAutoformat, prepareCanonicalCommands } from "./canonica
|
|
|
29
31
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
30
32
|
import { handleReadOnlySelectionKeyDown } from "./readOnlySelection.js";
|
|
31
33
|
import { Result, TaggedError, panic } from "better-result";
|
|
32
|
-
import {
|
|
34
|
+
import { CellSelection } from "prosemirror-tables";
|
|
35
|
+
import { OP_STORIES, freshCommentId, sameStory } from "@stll/docx-core/ops";
|
|
33
36
|
import { EditorState, Plugin } from "prosemirror-state";
|
|
34
37
|
import { EditorView } from "prosemirror-view";
|
|
35
38
|
// src/controller/hiddenEditorManager.ts
|
|
36
39
|
const CanonicalSessionRefusalErrorBase = TaggedError("CanonicalSessionRefusalError");
|
|
40
|
+
/** A refused input, with whether the session lacks the capability or the document forbids it. */
|
|
37
41
|
var CanonicalSessionRefusalError = class extends CanonicalSessionRefusalErrorBase {};
|
|
38
42
|
const normalizeSeedState = (state) => ensureBaseDirectionInState(ensureParaIdsInState(state));
|
|
39
43
|
const normalizeLocalSeedState = (state) => ensureBaseDirectionInState(state);
|
|
@@ -121,12 +125,12 @@ function createHiddenEditorState(options) {
|
|
|
121
125
|
recordHiddenEditorPhase(reason, "to-prose-doc", performance.now() - startedAt);
|
|
122
126
|
} else localDoc = ensureParaIdsInDoc(localDoc);
|
|
123
127
|
const styleResolverPlugin = createDocumentStylesPlugin(styles ?? document?.package.styles);
|
|
124
|
-
const numberingPlugin = createDocumentNumberingPlugin(document?.package.numbering);
|
|
125
128
|
const plugins = [
|
|
129
|
+
createDocumentNumberingPlugin(document?.package.numbering),
|
|
130
|
+
createCommentRecordsPlugin(document?.package.document.comments ?? []),
|
|
126
131
|
...externalPlugins,
|
|
127
132
|
...manager?.getPlugins() ?? [createTextInputPlugin()],
|
|
128
|
-
styleResolverPlugin
|
|
129
|
-
numberingPlugin
|
|
133
|
+
styleResolverPlugin
|
|
130
134
|
];
|
|
131
135
|
if (collaboration) {
|
|
132
136
|
if (!collaborationModules) panic("Collaboration modules must be loaded before creating collaborative editor state.");
|
|
@@ -222,11 +226,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
222
226
|
author: deps.getSuggestionAuthor?.() ?? "User"
|
|
223
227
|
} : { type: "editing" }));
|
|
224
228
|
};
|
|
225
|
-
const refuse = (reason,
|
|
229
|
+
const refuse = (reason, ground = { gap: CANONICAL_GAP.dispatch }) => {
|
|
226
230
|
const message = reason;
|
|
227
|
-
if (deps.onSessionRefusal) deps.onSessionRefusal(message,
|
|
231
|
+
if (deps.onSessionRefusal) deps.onSessionRefusal(message, ground);
|
|
228
232
|
else throw new CanonicalSessionRefusalError({
|
|
229
|
-
|
|
233
|
+
ground,
|
|
230
234
|
message
|
|
231
235
|
});
|
|
232
236
|
};
|
|
@@ -244,7 +248,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
244
248
|
reason,
|
|
245
249
|
documentIdentity
|
|
246
250
|
};
|
|
247
|
-
refuse(reason, CANONICAL_GAP.collaboration);
|
|
251
|
+
refuse(reason, { gap: CANONICAL_GAP.collaboration });
|
|
248
252
|
return false;
|
|
249
253
|
}
|
|
250
254
|
const result = createCanonicalSession(document, deps.getStyles());
|
|
@@ -254,7 +258,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
254
258
|
reason: result.error.message,
|
|
255
259
|
documentIdentity
|
|
256
260
|
};
|
|
257
|
-
refuse(result.error.message, result.error.
|
|
261
|
+
refuse(result.error.message, result.error.ground);
|
|
258
262
|
return false;
|
|
259
263
|
}
|
|
260
264
|
editorSession = {
|
|
@@ -269,9 +273,10 @@ const createHiddenEditorManager = (deps) => {
|
|
|
269
273
|
const canonicalState = (session) => EditorState.create({
|
|
270
274
|
doc: session.projection.doc,
|
|
271
275
|
plugins: [
|
|
276
|
+
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
272
277
|
createParagraphChangeTrackerPlugin(),
|
|
278
|
+
createNativeSelectionRefreshPlugin(),
|
|
273
279
|
createDocumentStyleContextPlugin(deps.getStyles() ?? session.document.package.styles),
|
|
274
|
-
createDocumentNumberingPlugin(session.document.package.numbering),
|
|
275
280
|
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) => props.transformPastedHTML === void 0 && props.transformPasted === void 0 && props.transformCopied === void 0 && props.clipboardTextSerializer === void 0 ? [] : [new Plugin({ props: {
|
|
276
281
|
...props.transformCopied === void 0 ? {} : { transformCopied: props.transformCopied },
|
|
277
282
|
...props.clipboardTextSerializer === void 0 ? {} : { clipboardTextSerializer: props.clipboardTextSerializer },
|
|
@@ -289,7 +294,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
289
294
|
session
|
|
290
295
|
});
|
|
291
296
|
if (result.isErr()) {
|
|
292
|
-
reportRefusal(result.error.message, result.error.
|
|
297
|
+
reportRefusal(result.error.message, result.error.ground);
|
|
293
298
|
return false;
|
|
294
299
|
}
|
|
295
300
|
const staged = result.value;
|
|
@@ -308,7 +313,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
308
313
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
309
314
|
const prepared = direction === "undo" ? session.prepareUndo(view.state) : session.prepareRedo(view.state);
|
|
310
315
|
if (prepared.isErr()) {
|
|
311
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
316
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
312
317
|
return false;
|
|
313
318
|
}
|
|
314
319
|
return publishCommit(prepared.value);
|
|
@@ -329,10 +334,10 @@ const createHiddenEditorManager = (deps) => {
|
|
|
329
334
|
if (described.isErr()) {
|
|
330
335
|
if (!(described.error instanceof HyperlinkRemovalRefusal)) throw described.error;
|
|
331
336
|
const refusal = new CanonicalSessionRefusalError({
|
|
332
|
-
gap: CANONICAL_GAP.commands,
|
|
337
|
+
ground: { gap: CANONICAL_GAP.commands },
|
|
333
338
|
message: described.error.message
|
|
334
339
|
});
|
|
335
|
-
refuse(refusal.message, refusal.
|
|
340
|
+
refuse(refusal.message, refusal.ground);
|
|
336
341
|
return false;
|
|
337
342
|
}
|
|
338
343
|
const intents = described.value;
|
|
@@ -344,7 +349,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
344
349
|
}, view);
|
|
345
350
|
const prepared = prepareCanonicalCommands(editorSession.session, view.state, intents);
|
|
346
351
|
if (prepared.isErr()) {
|
|
347
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
352
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
348
353
|
return false;
|
|
349
354
|
}
|
|
350
355
|
return publishCommit(prepared.value);
|
|
@@ -364,7 +369,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
364
369
|
if (mark !== void 0) command = name === "toggleUnderline" ? toggleUnderlineMark(mark) : toggleMarkForAllScripts(mark, name === "toggleBold" ? "bold" : "italic");
|
|
365
370
|
}
|
|
366
371
|
if (command === void 0) {
|
|
367
|
-
refuse("The formatting command is unavailable.", CANONICAL_GAP.commands);
|
|
372
|
+
refuse("The formatting command is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
368
373
|
return;
|
|
369
374
|
}
|
|
370
375
|
if (executeCanonicalCommand(command) === void 0) command(view.state, (transaction) => view?.dispatch(transaction), view);
|
|
@@ -372,11 +377,47 @@ const createHiddenEditorManager = (deps) => {
|
|
|
372
377
|
structure: (type) => {
|
|
373
378
|
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return;
|
|
374
379
|
syncCanonicalMode();
|
|
380
|
+
if (type === "deleteTable") {
|
|
381
|
+
const command = deps.getExtensionManager()?.getCommand("deleteTable")?.();
|
|
382
|
+
if (command === void 0) refuse("Deleting the table is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
383
|
+
else executeCanonicalCommand(command);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
375
386
|
const session = editorSession.session;
|
|
376
387
|
const state = view.state;
|
|
388
|
+
if (state.selection instanceof CellSelection && (type === "split" || type === "tab" || type === "lineBreak" || type === "pageBreak")) {
|
|
389
|
+
const overCells = session.prepareCellSelectionStructure(state, (at) => type === "split" ? {
|
|
390
|
+
type: "replaceFragment",
|
|
391
|
+
from: at,
|
|
392
|
+
to: at,
|
|
393
|
+
paragraphs: [{
|
|
394
|
+
type: "paragraph",
|
|
395
|
+
content: []
|
|
396
|
+
}, {
|
|
397
|
+
type: "paragraph",
|
|
398
|
+
content: []
|
|
399
|
+
}],
|
|
400
|
+
openStart: 1,
|
|
401
|
+
openEnd: 1
|
|
402
|
+
} : {
|
|
403
|
+
type: "insertAtom",
|
|
404
|
+
from: at,
|
|
405
|
+
to: at,
|
|
406
|
+
atom: type === "tab" ? { type: "tab" } : {
|
|
407
|
+
type: "break",
|
|
408
|
+
breakType: type === "pageBreak" ? "page" : "textWrapping"
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
if (overCells.isErr()) {
|
|
412
|
+
if (overCells.error.reason !== "noChange") refuse(overCells.error.message, overCells.error.ground);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
publishCommit(overCells.value);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
377
418
|
const selection = session.projection.selectionAt(state);
|
|
378
419
|
if (selection.isErr()) {
|
|
379
|
-
refuse(selection.error.message, selection.error.
|
|
420
|
+
refuse(selection.error.message, selection.error.ground);
|
|
380
421
|
return;
|
|
381
422
|
}
|
|
382
423
|
let prepared;
|
|
@@ -426,11 +467,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
426
467
|
const from = session.projection.addressAt(state.selection.from);
|
|
427
468
|
const to = session.projection.addressAt(state.selection.to);
|
|
428
469
|
if (from.isErr()) {
|
|
429
|
-
refuse(from.error.message, from.error.
|
|
470
|
+
refuse(from.error.message, from.error.ground);
|
|
430
471
|
return;
|
|
431
472
|
}
|
|
432
473
|
if (to.isErr()) {
|
|
433
|
-
refuse(to.error.message, to.error.
|
|
474
|
+
refuse(to.error.message, to.error.ground);
|
|
434
475
|
return;
|
|
435
476
|
}
|
|
436
477
|
prepared = session.prepareIntent(state, {
|
|
@@ -447,7 +488,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
447
488
|
default: return type;
|
|
448
489
|
}
|
|
449
490
|
if (prepared.isErr()) {
|
|
450
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
491
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
451
492
|
return;
|
|
452
493
|
}
|
|
453
494
|
publishCommit(prepared.value);
|
|
@@ -461,7 +502,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
461
502
|
if (deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
462
503
|
const begun = editorSession.session.beginComposition();
|
|
463
504
|
if (begun.isErr()) {
|
|
464
|
-
refuse(begun.error.message, begun.error.
|
|
505
|
+
refuse(begun.error.message, begun.error.ground);
|
|
465
506
|
return false;
|
|
466
507
|
}
|
|
467
508
|
return true;
|
|
@@ -501,7 +542,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
501
542
|
semantic: "replacement"
|
|
502
543
|
});
|
|
503
544
|
if (prepared.isErr()) {
|
|
504
|
-
refuse(prepared.error.message, prepared.error.
|
|
545
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
505
546
|
return true;
|
|
506
547
|
}
|
|
507
548
|
const copied = Result.try({
|
|
@@ -511,11 +552,11 @@ const createHiddenEditorManager = (deps) => {
|
|
|
511
552
|
event.clipboardData?.setData("text/plain", serialized.text);
|
|
512
553
|
},
|
|
513
554
|
catch: () => new CanonicalSessionRefusalError({
|
|
514
|
-
gap: CANONICAL_GAP.dispatch,
|
|
555
|
+
ground: { gap: CANONICAL_GAP.dispatch },
|
|
515
556
|
message: "The clipboard could not receive the cut content."
|
|
516
557
|
})
|
|
517
558
|
});
|
|
518
|
-
if (copied.isErr()) refuse(copied.error.message, copied.error.
|
|
559
|
+
if (copied.isErr()) refuse(copied.error.message, copied.error.ground);
|
|
519
560
|
else publishCommit(prepared.value);
|
|
520
561
|
return true;
|
|
521
562
|
},
|
|
@@ -527,7 +568,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
527
568
|
const rule = prepareCanonicalAutoformat(editorSession.session, view.state, intent);
|
|
528
569
|
const prepared = rule ?? editorSession.session.prepareReplace(view.state, intent);
|
|
529
570
|
if (prepared.isErr()) {
|
|
530
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
571
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
531
572
|
return;
|
|
532
573
|
}
|
|
533
574
|
const session = editorSession.session;
|
|
@@ -578,7 +619,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
578
619
|
editable: () => !deps.getReadOnly() && editorSession.type !== "refused",
|
|
579
620
|
dispatchTransaction: (transaction) => {
|
|
580
621
|
if (!view || isDestroying) return;
|
|
581
|
-
if (deps.getReadOnly() && transaction.docChanged) {
|
|
622
|
+
if (deps.getReadOnly() && transaction.docChanged && !isCommentRecordsSync(transaction)) {
|
|
582
623
|
deps.onReadOnlyEditAttempt();
|
|
583
624
|
return;
|
|
584
625
|
}
|
|
@@ -597,14 +638,14 @@ const createHiddenEditorManager = (deps) => {
|
|
|
597
638
|
if (modules && transaction.getMeta(modules.yProseMirror.ySyncPluginKey) !== void 0) markNoteReferenceReplay(transaction);
|
|
598
639
|
const applied = view.state.applyTransaction(transaction);
|
|
599
640
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
600
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, CANONICAL_GAP.dispatch, noteIssue);
|
|
641
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
601
642
|
if (editorSession.type === "canonical" && !applied.state.doc.eq(view.state.doc)) {
|
|
602
643
|
refuse("A plugin attempted an unclassified canonical document mutation.");
|
|
603
644
|
return;
|
|
604
645
|
}
|
|
605
646
|
view.updateState(applied.state);
|
|
606
|
-
const docChanged = applied.transactions.some((appliedTransaction) => appliedTransaction.docChanged);
|
|
607
|
-
const selectionChanged = applied.transactions.some((appliedTransaction) => appliedTransaction.selectionSet || appliedTransaction.docChanged);
|
|
647
|
+
const docChanged = applied.transactions.some((appliedTransaction) => appliedTransaction.docChanged && !isCommentRecordsSync(appliedTransaction));
|
|
648
|
+
const selectionChanged = applied.transactions.some((appliedTransaction) => appliedTransaction.selectionSet || appliedTransaction.docChanged && !isCommentRecordsSync(appliedTransaction));
|
|
608
649
|
deps.onTransaction({
|
|
609
650
|
transactions: applied.transactions,
|
|
610
651
|
newState: applied.state,
|
|
@@ -626,6 +667,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
626
667
|
return deps.onKeyDown(pmView, event);
|
|
627
668
|
},
|
|
628
669
|
handleTextInput: (pmView, from, to, text) => editorSession.type === "canonical" ? input.handleTextInput(pmView, from, to, text) : false,
|
|
670
|
+
handleKeyPress: (pmView, event) => editorSession.type === "canonical" && !deps.getReadOnly() && input.handleKeyPress(pmView, event),
|
|
629
671
|
handlePaste: (pmView, _event, slice) => {
|
|
630
672
|
if (editorSession.type !== "canonical") return false;
|
|
631
673
|
if (deps.getReadOnly()) {
|
|
@@ -639,7 +681,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
639
681
|
slice
|
|
640
682
|
});
|
|
641
683
|
if (prepared.isErr()) {
|
|
642
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
684
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
643
685
|
} else publishCommit(prepared.value);
|
|
644
686
|
return true;
|
|
645
687
|
},
|
|
@@ -682,13 +724,16 @@ const createHiddenEditorManager = (deps) => {
|
|
|
682
724
|
} : { pasteTarget: target }
|
|
683
725
|
});
|
|
684
726
|
if (prepared.isErr()) {
|
|
685
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
727
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
686
728
|
} else publishCommit(prepared.value);
|
|
687
729
|
return true;
|
|
688
730
|
},
|
|
689
731
|
handleScrollToSelection: suppressHiddenEditorScrollToSelection,
|
|
690
732
|
handleDOMEvents: {
|
|
691
|
-
keydown: (pmView, event) =>
|
|
733
|
+
keydown: (pmView, event) => {
|
|
734
|
+
if (!input.isComposing && !isCompositionKeyDown(event)) adoptNativeSelection(pmView);
|
|
735
|
+
return editorSession.type === "canonical" ? input.handleDOMEvents.keydown(pmView, event) : false;
|
|
736
|
+
},
|
|
692
737
|
focus: () => false,
|
|
693
738
|
blur: (pmView) => editorSession.type === "canonical" ? input.handleDOMEvents.blur(pmView) : false,
|
|
694
739
|
...createHiddenEditorClipboardHandlers(deps),
|
|
@@ -701,6 +746,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
701
746
|
},
|
|
702
747
|
cut: (pmView, event) => editorSession.type === "canonical" ? input.handleDOMEvents.cut(pmView, event) : createHiddenEditorClipboardHandlers(deps).cut(pmView, event),
|
|
703
748
|
beforeinput: (_view, event) => {
|
|
749
|
+
if (!input.isComposing && !event.isComposing) adoptNativeSelection(_view);
|
|
704
750
|
if (editorSession.type === "canonical" && !deps.getReadOnly()) return input.handleDOMEvents.beforeinput(_view, event);
|
|
705
751
|
if (!deps.getReadOnly()) return false;
|
|
706
752
|
deps.onReadOnlyEditAttempt();
|
|
@@ -746,7 +792,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
746
792
|
plain
|
|
747
793
|
});
|
|
748
794
|
if (prepared.isErr()) {
|
|
749
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
795
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
750
796
|
return false;
|
|
751
797
|
}
|
|
752
798
|
return publishCommit(prepared.value);
|
|
@@ -780,8 +826,12 @@ const createHiddenEditorManager = (deps) => {
|
|
|
780
826
|
}
|
|
781
827
|
};
|
|
782
828
|
const syncExternalDocument = () => {
|
|
783
|
-
if (
|
|
829
|
+
if (isDestroying) return;
|
|
784
830
|
const canonicalRequested = usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting);
|
|
831
|
+
if (!view) {
|
|
832
|
+
if (canonicalRequested && deps.getDocument() !== null) ensureView();
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
785
835
|
const collaboration = deps.getCollaboration();
|
|
786
836
|
const collaborationModules = deps.getCollaborationModules();
|
|
787
837
|
if (collaboration && !collaborationModules && !canonicalRequested) return;
|
|
@@ -821,6 +871,13 @@ const createHiddenEditorManager = (deps) => {
|
|
|
821
871
|
if (view.editable !== !readOnly) view.setProps({ editable: () => !deps.getReadOnly() });
|
|
822
872
|
syncHiddenEditorAccessibility(view, readOnly);
|
|
823
873
|
};
|
|
874
|
+
/**
|
|
875
|
+
* Publishes a commit to a secondary story: the body view takes the body
|
|
876
|
+
* projection the commit carries, and the story's open editor, if one is
|
|
877
|
+
* open, takes the story projection. With no story editor open, the commit
|
|
878
|
+
* is staged against the story's projection as it stood before the edit.
|
|
879
|
+
* Every path that edits a secondary story, editor or API, publishes here.
|
|
880
|
+
*/
|
|
824
881
|
const publishStoryCommit = (storyView, commit) => {
|
|
825
882
|
if (!view || editorSession.type !== "canonical") return false;
|
|
826
883
|
const session = editorSession.session;
|
|
@@ -845,15 +902,18 @@ const createHiddenEditorManager = (deps) => {
|
|
|
845
902
|
return false;
|
|
846
903
|
}
|
|
847
904
|
const staged = publishCanonicalProjection({
|
|
848
|
-
state: storyView.
|
|
905
|
+
state: storyView?.state ?? EditorState.create({
|
|
906
|
+
schema: view.state.schema,
|
|
907
|
+
doc: commit.transaction.before
|
|
908
|
+
}),
|
|
849
909
|
commit,
|
|
850
910
|
session
|
|
851
911
|
});
|
|
852
912
|
if (staged.isErr()) {
|
|
853
|
-
refuse(staged.error.message, staged.error.
|
|
913
|
+
refuse(staged.error.message, staged.error.ground);
|
|
854
914
|
return false;
|
|
855
915
|
}
|
|
856
|
-
storyView
|
|
916
|
+
storyView?.updateState(staged.value.state);
|
|
857
917
|
view.updateState(bodyStaged.value.state);
|
|
858
918
|
deps.onTransaction({
|
|
859
919
|
transactions: staged.value.transactions,
|
|
@@ -864,14 +924,38 @@ const createHiddenEditorManager = (deps) => {
|
|
|
864
924
|
return true;
|
|
865
925
|
};
|
|
866
926
|
let publicOperations = null;
|
|
927
|
+
/** The editor last in use for each secondary story, as its editors report it. */
|
|
928
|
+
const storyViews = [];
|
|
929
|
+
/** The open editor of `story` showing its committed projection, if any. */
|
|
930
|
+
const openStoryView = (session, story) => {
|
|
931
|
+
const entry = storyViews.find((candidate) => sameStory(candidate.story, story));
|
|
932
|
+
if (!entry || entry.view.isDestroyed) return null;
|
|
933
|
+
const projected = session.projectStory(story);
|
|
934
|
+
return projected.isOk() && entry.view.state.doc.eq(projected.value.doc) ? entry.view : null;
|
|
935
|
+
};
|
|
867
936
|
const getPublicOperations = () => {
|
|
868
937
|
if (editorSession.type !== "canonical") return null;
|
|
869
938
|
const session = editorSession.session;
|
|
870
939
|
if (publicOperations?.session === session) return publicOperations.executor;
|
|
871
940
|
const executor = new CanonicalPublicOperations({
|
|
872
941
|
session,
|
|
873
|
-
getState: (story) =>
|
|
874
|
-
|
|
942
|
+
getState: (story) => {
|
|
943
|
+
if (!view || deps.getReadOnly() || isDestroying) return null;
|
|
944
|
+
if (story === OP_STORIES.MAIN) return view.state;
|
|
945
|
+
const open = openStoryView(session, story);
|
|
946
|
+
if (open) return open.state;
|
|
947
|
+
const projected = session.projectStory(story);
|
|
948
|
+
return projected.isErr() ? null : EditorState.create({
|
|
949
|
+
schema: view.state.schema,
|
|
950
|
+
doc: projected.value.doc
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
publish: (commit) => {
|
|
954
|
+
const story = commit.selection.anchor.story;
|
|
955
|
+
if (story === OP_STORIES.MAIN) return publishCommit(commit);
|
|
956
|
+
const open = storyViews.find((candidate) => sameStory(candidate.story, story))?.view;
|
|
957
|
+
return publishStoryCommit(open && !open.isDestroyed && open.state.doc.eq(commit.transaction.before) ? open : null, commit);
|
|
958
|
+
}
|
|
875
959
|
});
|
|
876
960
|
publicOperations = {
|
|
877
961
|
session,
|
|
@@ -910,7 +994,23 @@ const createHiddenEditorManager = (deps) => {
|
|
|
910
994
|
resolution
|
|
911
995
|
});
|
|
912
996
|
if (prepared.isErr()) {
|
|
913
|
-
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.
|
|
997
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
const published = publishCommit(prepared.value);
|
|
1001
|
+
if (prepared.value.lockHeld !== void 0) refuse(`Revisions ${prepared.value.lockHeld.join(", ")} stay pending: resolving them changes a locked content control.`, { rule: CANONICAL_RULE.contentControlLock });
|
|
1002
|
+
return published;
|
|
1003
|
+
},
|
|
1004
|
+
resolveCanonicalSuggestion: (suggestionId, resolution, author) => {
|
|
1005
|
+
if (!view || deps.getReadOnly() || editorSession.type !== "canonical") return false;
|
|
1006
|
+
const prepared = editorSession.session.prepareSuggestion(view.state, {
|
|
1007
|
+
suggestionId,
|
|
1008
|
+
resolution,
|
|
1009
|
+
author,
|
|
1010
|
+
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
1011
|
+
});
|
|
1012
|
+
if (prepared.isErr()) {
|
|
1013
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
914
1014
|
return false;
|
|
915
1015
|
}
|
|
916
1016
|
return publishCommit(prepared.value);
|
|
@@ -926,7 +1026,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
926
1026
|
applyCanonicalSectionProperties: (patch) => {
|
|
927
1027
|
ensureView();
|
|
928
1028
|
const fail = (message) => {
|
|
929
|
-
refuse(message, CANONICAL_GAP.sectionProperties);
|
|
1029
|
+
refuse(message, { gap: CANONICAL_GAP.sectionProperties });
|
|
930
1030
|
return {
|
|
931
1031
|
status: "refused",
|
|
932
1032
|
gap: CANONICAL_GAP.sectionProperties,
|
|
@@ -955,7 +1055,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
955
1055
|
applyCanonicalComment: (request) => {
|
|
956
1056
|
ensureView();
|
|
957
1057
|
const fail = (message, retry = "never") => {
|
|
958
|
-
if (retry === "never") refuse(message, CANONICAL_GAP.comments);
|
|
1058
|
+
if (retry === "never") refuse(message, { gap: CANONICAL_GAP.comments });
|
|
959
1059
|
return {
|
|
960
1060
|
status: "refused",
|
|
961
1061
|
gap: CANONICAL_GAP.comments,
|
|
@@ -1076,7 +1176,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1076
1176
|
if (direction === "undo" ? !session.canUndo : !session.canRedo) return false;
|
|
1077
1177
|
const prepared = direction === "undo" ? session.prepareUndo(storyView.state, story) : session.prepareRedo(storyView.state, story);
|
|
1078
1178
|
if (prepared.isErr()) {
|
|
1079
|
-
refuse(prepared.error.message, prepared.error.
|
|
1179
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1080
1180
|
return false;
|
|
1081
1181
|
}
|
|
1082
1182
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -1086,21 +1186,29 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1086
1186
|
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1087
1187
|
const prepared = editorSession.session.prepareOperations(view.state, ops);
|
|
1088
1188
|
if (prepared.isErr()) {
|
|
1089
|
-
refuse(prepared.error.message, prepared.error.
|
|
1189
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1090
1190
|
return false;
|
|
1091
1191
|
}
|
|
1092
1192
|
return publishCommit(prepared.value);
|
|
1093
1193
|
},
|
|
1094
1194
|
getCanonicalStoryProjection: (story) => {
|
|
1095
|
-
if (usesCanonicalSession(deps.getExperimentalSession?.(), CANONICAL_GAP.authorityRouting)) ensureView();
|
|
1096
1195
|
if (editorSession.type !== "canonical" || editorSession.session.isComposing) return null;
|
|
1097
1196
|
const result = editorSession.session.projectStory(story);
|
|
1098
1197
|
if (result.isErr()) {
|
|
1099
|
-
refuse(result.error.message, result.error.
|
|
1198
|
+
refuse(result.error.message, result.error.ground);
|
|
1100
1199
|
return null;
|
|
1101
1200
|
}
|
|
1102
1201
|
return result.value.doc;
|
|
1103
1202
|
},
|
|
1203
|
+
noteCanonicalStoryView: ({ story, view: storyView }) => {
|
|
1204
|
+
if (story === OP_STORIES.MAIN) return;
|
|
1205
|
+
const index = storyViews.findIndex((candidate) => sameStory(candidate.story, story));
|
|
1206
|
+
if (index >= 0) storyViews.splice(index, 1);
|
|
1207
|
+
storyViews.push({
|
|
1208
|
+
story,
|
|
1209
|
+
view: storyView
|
|
1210
|
+
});
|
|
1211
|
+
},
|
|
1104
1212
|
replaceCanonicalStoryText: ({ view: storyView, story, intent }) => {
|
|
1105
1213
|
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1106
1214
|
syncCanonicalMode();
|
|
@@ -1109,7 +1217,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1109
1217
|
story
|
|
1110
1218
|
});
|
|
1111
1219
|
if (prepared.isErr()) {
|
|
1112
|
-
refuse(prepared.error.message, prepared.error.
|
|
1220
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
1113
1221
|
return false;
|
|
1114
1222
|
}
|
|
1115
1223
|
return publishStoryCommit(storyView, prepared.value);
|
|
@@ -1119,6 +1227,7 @@ const createHiddenEditorManager = (deps) => {
|
|
|
1119
1227
|
ensureView,
|
|
1120
1228
|
isViewRequested
|
|
1121
1229
|
}),
|
|
1230
|
+
readCanonicalDocument: () => editorSession.type === "canonical" ? editorSession.session.document : null,
|
|
1122
1231
|
isCanonicalComposing: () => editorSession.type === "canonical" && editorSession.session.isComposing
|
|
1123
1232
|
};
|
|
1124
1233
|
};
|