@stll/folio-core 0.66.2 → 0.68.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 +138 -17
- package/dist/ai-edits/batch-claims.js +5 -3
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +32 -17
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- 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 +29 -12
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +77 -19
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -2
- package/dist/controller/canonicalInput.js +47 -2
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +328 -75
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- 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 +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +10 -3
- package/dist/controller/hiddenEditorManager.js +94 -38
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +55 -18
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +49 -14
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- 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 +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- 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/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 +17 -0
- package/dist/docx/hostCommentThreads.js +49 -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 +227 -96
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- 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/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- 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 +6 -0
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -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 +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +42 -25
- 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 +3 -1
- 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/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/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/shapeAlternateContent.js +19 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- 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/unzip.js +2 -0
- package/dist/docx/verticalMergeProjection.js +1 -1
- 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/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/wholeStoryRevisionResolution.js +57 -12
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/tableConversion.js +25 -10
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- 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.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +34 -7
- package/dist/layout-engine/tableRowBreak.d.ts +46 -0
- package/dist/layout-engine/tableRowBreak.js +193 -36
- package/dist/layout-engine/types.d.ts +43 -3
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +5 -4
- package/dist/layout-painter/renderPage.js +52 -20
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +39 -22
- 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/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/attrs/index.js +1 -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 +25 -0
- package/dist/prosemirror/commands/comments.js +122 -18
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- 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/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +325 -55
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/index.d.ts +2 -2
- 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/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +195 -30
- 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/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -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/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 +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/validation.js +2 -1
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- 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 -2
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { SUGGESTED_SUPPORTED_OPERATION_TYPES } from "../ai-edits/apply.js";
|
|
1
2
|
import { splitsGraphemeCluster, splitsSurrogatePair } from "../ai-edits/character-boundaries.js";
|
|
2
3
|
import { buildCleanBlockText, resolveCleanTextRange } from "../ai-edits/clean-text.js";
|
|
3
4
|
import { stripInlineEmphasisMarkers } from "../ai-edits/inline-emphasis.js";
|
|
4
|
-
import { collectNoteReferenceLabels, hashFolioAIBlockText } from "../ai-edits/snapshot.js";
|
|
5
|
+
import { collectNoteReferenceLabels, hashFolioAIBlockContent, hashFolioAIBlockText } from "../ai-edits/snapshot.js";
|
|
5
6
|
import { wordDiffSessionFromOptions } from "../ai-edits/word-diff.js";
|
|
6
|
-
import { getFolioDocumentOperationIssues, getFolioDocumentOperationReceiptsForStory, parseFolioDocumentOperationBatch } from "../document-operations.js";
|
|
7
|
+
import { getFolioDocumentOperationIssues, getFolioDocumentOperationReceiptsForStory, parseFolioDocumentOperationBatch, withDistinctSuggestionIds } from "../document-operations.js";
|
|
7
8
|
import { maxAnnotationIdInDoc } from "../prosemirror/plugins/revisionIds.js";
|
|
8
9
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
9
10
|
import { canonicalCommentBody, compileCanonicalComments } from "./canonicalComments.js";
|
|
11
|
+
import { lockViolationBetween } from "./canonicalLockGuard.js";
|
|
10
12
|
import { Result, TaggedError, panic } from "better-result";
|
|
13
|
+
import { CONTENT_CONTROL_LOCK, lockedControlMessage } from "@stll/docx-core/model";
|
|
11
14
|
import { Mark } from "prosemirror-model";
|
|
12
|
-
import { OP_STORIES, applyDocumentOps, compileEditorIntent, createEditorIntentIdAllocator, documentStories, findStoryBody, freshCommentId, paragraphLength } from "@stll/docx-core/ops";
|
|
15
|
+
import { OP_STORIES, applyDocumentOps, compileEditorIntent, createEditorIntentIdAllocator, documentStories, findStoryBody, freshCommentId, paragraphLength, pendingSuggestionIdsIn } from "@stll/docx-core/ops";
|
|
13
16
|
// src/controller/canonicalPublicOperations.ts
|
|
14
17
|
/** Public batches compile against the read projection; only the canonical journal publishes. */
|
|
15
18
|
/** A new public kind cannot bypass a canonical compiler/refusal decision. */
|
|
@@ -20,10 +23,10 @@ const CANONICAL_PUBLIC_OPERATION_DISPOSITIONS = {
|
|
|
20
23
|
splitBlock: "compile",
|
|
21
24
|
formatRange: "compile",
|
|
22
25
|
mergeBlockWithNext: "compile",
|
|
23
|
-
setBlockParagraphProperties:
|
|
24
|
-
insertAfterBlock:
|
|
25
|
-
insertBeforeBlock:
|
|
26
|
-
deleteBlock:
|
|
26
|
+
setBlockParagraphProperties: "compile",
|
|
27
|
+
insertAfterBlock: "compile",
|
|
28
|
+
insertBeforeBlock: "compile",
|
|
29
|
+
deleteBlock: "compile",
|
|
27
30
|
commentOnBlock: "compile",
|
|
28
31
|
commentOnRange: "compile",
|
|
29
32
|
insertTable: CANONICAL_GAP.publicTableStructure,
|
|
@@ -51,7 +54,144 @@ const resolveComment = ({ operation, from, to }) => {
|
|
|
51
54
|
operation
|
|
52
55
|
};
|
|
53
56
|
};
|
|
54
|
-
const
|
|
57
|
+
const SPACING_FIELDS = [
|
|
58
|
+
"spaceBefore",
|
|
59
|
+
"spaceAfter",
|
|
60
|
+
"lineSpacing",
|
|
61
|
+
"lineSpacingRule",
|
|
62
|
+
"beforeAutospacing",
|
|
63
|
+
"afterAutospacing"
|
|
64
|
+
];
|
|
65
|
+
const INDENTATION_FIELDS = [
|
|
66
|
+
"indentLeft",
|
|
67
|
+
"indentRight",
|
|
68
|
+
"indentFirstLine",
|
|
69
|
+
"hangingIndent"
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* The stated paragraph properties an operation writes: each given property
|
|
73
|
+
* as it says, a spacing or indentation object as the whole direct child, so
|
|
74
|
+
* an attribute it leaves out is removed, and `null` clears a property back
|
|
75
|
+
* to what the style gives.
|
|
76
|
+
*/
|
|
77
|
+
const statedParagraphPatch = (properties) => {
|
|
78
|
+
const patch = {};
|
|
79
|
+
if (properties.styleId !== void 0) patch["styleId"] = properties.styleId;
|
|
80
|
+
if (properties.outlineLevel !== void 0) patch["outlineLevel"] = properties.outlineLevel;
|
|
81
|
+
if (properties.alignment !== void 0) patch["alignment"] = properties.alignment;
|
|
82
|
+
const { spacing, indentation } = properties;
|
|
83
|
+
if (spacing !== void 0) for (const field of SPACING_FIELDS) patch[field] = spacing === null ? null : spacing[field] ?? null;
|
|
84
|
+
if (indentation !== void 0) for (const field of INDENTATION_FIELDS) patch[field] = indentation === null ? null : indentation[field] ?? null;
|
|
85
|
+
return patch;
|
|
86
|
+
};
|
|
87
|
+
const resolveParagraphProperties = ({ operation, paragraph, projection, refusal }) => {
|
|
88
|
+
if (operation.properties.numbering !== void 0) return refusal("unsupportedBlock", "Canonical paragraph numbering changes are unavailable.");
|
|
89
|
+
const patch = statedParagraphPatch(operation.properties);
|
|
90
|
+
if (Object.keys(patch).length === 0) return refusal("emptyOperation");
|
|
91
|
+
const at = projection.addressAt(paragraph.start);
|
|
92
|
+
if (at.isErr()) return refusal("unsupportedBlock");
|
|
93
|
+
const intents = [{
|
|
94
|
+
type: "formatParagraph",
|
|
95
|
+
at: at.value,
|
|
96
|
+
patch
|
|
97
|
+
}];
|
|
98
|
+
return Result.ok({
|
|
99
|
+
type: "plain",
|
|
100
|
+
operation,
|
|
101
|
+
intents,
|
|
102
|
+
normalizations: [],
|
|
103
|
+
from: paragraph.start,
|
|
104
|
+
to: paragraph.start + paragraph.node.content.size
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const isBlockInsertion = (operation) => operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock";
|
|
108
|
+
/**
|
|
109
|
+
* One new paragraph beside the anchor, as the default engine writes it: the
|
|
110
|
+
* anchor's stated paragraph properties unless `inheritFormatting` is false,
|
|
111
|
+
* with the operation's own on top, holding the text as one plain run.
|
|
112
|
+
*/
|
|
113
|
+
const resolveBlockInsertion = ({ operation, paragraph, story, refusal }) => {
|
|
114
|
+
const unavailable = [
|
|
115
|
+
["numbering", "paragraph numbering"],
|
|
116
|
+
["moveId", "tracked moves"],
|
|
117
|
+
["comment", "comments on an inserted block"]
|
|
118
|
+
].find(([key]) => operation[key] !== void 0);
|
|
119
|
+
if (unavailable !== void 0) return refusal("unsupportedBlock", `Canonical block insertion with ${unavailable[1]} is unavailable.`);
|
|
120
|
+
const { text } = operation;
|
|
121
|
+
if (stripInlineEmphasisMarkers(text) !== text) return refusal("unsupportedBlock", "Canonical public emphasis replacements are unavailable.");
|
|
122
|
+
const inline = operation.lineBreakMode === "inline";
|
|
123
|
+
if (/\[\^(?:e)?\d+\]/u.test(text) || inline && text.includes("\r")) return refusal("unsupportedBlock", "Canonical block insertion requires plain text.");
|
|
124
|
+
const split = !inline && LINE_BREAK_PATTERN.test(text);
|
|
125
|
+
const lines = split ? text.split(LINE_BREAK_PATTERN).filter((line) => line.trim().length > 0) : [text];
|
|
126
|
+
const texts = lines.length === 0 ? [""] : lines;
|
|
127
|
+
const formatting = operation.inheritFormatting === false ? {} : { ...paragraph.source.formatting };
|
|
128
|
+
for (const [key, value] of Object.entries(statedParagraphPatch({
|
|
129
|
+
...operation.styleId === void 0 ? {} : { styleId: operation.styleId },
|
|
130
|
+
...operation.outlineLevel === void 0 ? {} : { outlineLevel: operation.outlineLevel },
|
|
131
|
+
...operation.alignment === void 0 ? {} : { alignment: operation.alignment },
|
|
132
|
+
...operation.spacing === void 0 ? {} : { spacing: operation.spacing },
|
|
133
|
+
...operation.indentation === void 0 ? {} : { indentation: operation.indentation }
|
|
134
|
+
}))) if (value === null) Reflect.deleteProperty(formatting, key);
|
|
135
|
+
else formatting[key] = value;
|
|
136
|
+
const everyParagraph = operation.formattingScope === "allParagraphs";
|
|
137
|
+
const paragraphs = texts.map((line, index) => {
|
|
138
|
+
const own = index === 0 || everyParagraph ? { ...formatting } : {};
|
|
139
|
+
if (index === 0 && operation.pageBreakBefore === true) own["pageBreakBefore"] = true;
|
|
140
|
+
const pageBreak = index === 0 ? operation.hardPageBreak : void 0;
|
|
141
|
+
let content = [];
|
|
142
|
+
if (pageBreak !== void 0) content = [{
|
|
143
|
+
type: "run",
|
|
144
|
+
content: [{
|
|
145
|
+
type: "break",
|
|
146
|
+
breakType: "page",
|
|
147
|
+
...pageBreak.clear === void 0 ? {} : { clear: pageBreak.clear }
|
|
148
|
+
}]
|
|
149
|
+
}];
|
|
150
|
+
else if (line !== "") content = [{
|
|
151
|
+
type: "run",
|
|
152
|
+
content: inlineText(line)
|
|
153
|
+
}];
|
|
154
|
+
return {
|
|
155
|
+
type: "paragraph",
|
|
156
|
+
content,
|
|
157
|
+
...Object.keys(own).length === 0 ? {} : { formatting: own }
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const intents = [{
|
|
161
|
+
type: "insertParagraphs",
|
|
162
|
+
story,
|
|
163
|
+
at: {
|
|
164
|
+
type: operation.type === "insertAfterBlock" ? "after" : "before",
|
|
165
|
+
blockId: paragraph.blockId
|
|
166
|
+
},
|
|
167
|
+
paragraphs
|
|
168
|
+
}];
|
|
169
|
+
const position = operation.type === "insertAfterBlock" ? paragraph.start + paragraph.node.content.size : paragraph.start;
|
|
170
|
+
const normalizations = split ? [{
|
|
171
|
+
id: operation.id,
|
|
172
|
+
code: "splitMultilineText",
|
|
173
|
+
paragraphCount: texts.length
|
|
174
|
+
}] : [];
|
|
175
|
+
return Result.ok({
|
|
176
|
+
type: "plain",
|
|
177
|
+
operation,
|
|
178
|
+
intents,
|
|
179
|
+
normalizations,
|
|
180
|
+
from: position,
|
|
181
|
+
to: position
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
const LINE_BREAK_PATTERN = /\r\n|\r|\n/u;
|
|
185
|
+
/** A line's text with each tab and line break as the element it is. */
|
|
186
|
+
const inlineText = (line) => line.split(/([\t\n])/u).flatMap((part) => {
|
|
187
|
+
if (part === " ") return [{ type: "tab" }];
|
|
188
|
+
if (part === "\n") return [{ type: "break" }];
|
|
189
|
+
return part === "" ? [] : [{
|
|
190
|
+
type: "text",
|
|
191
|
+
text: part
|
|
192
|
+
}];
|
|
193
|
+
});
|
|
194
|
+
const compilePublicIntents = ({ document, intents, mode, author, date, suggestionId, nextRevisionId, allocate }) => {
|
|
55
195
|
const ops = [];
|
|
56
196
|
const revisions = [];
|
|
57
197
|
for (const sourceIntent of intents) {
|
|
@@ -73,7 +213,8 @@ const compilePublicIntents = ({ document, intents, mode, author, date, nextRevis
|
|
|
73
213
|
revision: {
|
|
74
214
|
id: firstRevisionId,
|
|
75
215
|
author,
|
|
76
|
-
date
|
|
216
|
+
date,
|
|
217
|
+
...suggestionId === void 0 ? {} : { suggestionId }
|
|
77
218
|
},
|
|
78
219
|
newIds: {
|
|
79
220
|
control: ids.newIds.control,
|
|
@@ -129,8 +270,9 @@ var CanonicalPublicOperations = class {
|
|
|
129
270
|
this.options = options;
|
|
130
271
|
}
|
|
131
272
|
apply(options) {
|
|
132
|
-
const batch = parseFolioDocumentOperationBatch(options.batch);
|
|
133
273
|
const { session } = this.options;
|
|
274
|
+
const parsed = parseFolioDocumentOperationBatch(options.batch);
|
|
275
|
+
const batch = parsed.mode !== "suggested" || options.restagesSuggestions === true || session.isComposing ? parsed : withDistinctSuggestionIds(parsed, /* @__PURE__ */ new Set([...pendingSuggestionIdsIn(session.document), ...options.pendingSuggestionIds ?? []]));
|
|
134
276
|
const publicStory = options.story ?? "main";
|
|
135
277
|
const story = canonicalPublicStory(publicStory);
|
|
136
278
|
const state = this.options.getState(story);
|
|
@@ -189,9 +331,8 @@ var CanonicalPublicOperations = class {
|
|
|
189
331
|
skip(operation.id, "documentNotEditable");
|
|
190
332
|
continue;
|
|
191
333
|
}
|
|
192
|
-
if (batch.mode === "suggested") {
|
|
193
|
-
|
|
194
|
-
skip(operation.id, "unsupportedMode", "Canonical pending suggestions are unavailable.");
|
|
334
|
+
if (batch.mode === "suggested" && !SUGGESTED_SUPPORTED_OPERATION_TYPES.has(operation.type)) {
|
|
335
|
+
skip(operation.id, "unsupportedMode");
|
|
195
336
|
continue;
|
|
196
337
|
}
|
|
197
338
|
if (options.tableTemplates !== void 0 || options.undefinedReferences === "keep") {
|
|
@@ -210,7 +351,8 @@ var CanonicalPublicOperations = class {
|
|
|
210
351
|
options,
|
|
211
352
|
state,
|
|
212
353
|
story,
|
|
213
|
-
diff
|
|
354
|
+
diff,
|
|
355
|
+
tracked: batch.mode !== "direct"
|
|
214
356
|
});
|
|
215
357
|
if (compiled.isErr()) {
|
|
216
358
|
if (compiled.error.reason === "unsupportedBlock") refusals.set(operation.id, { gap: CANONICAL_GAP.publicUnsupportedInline });
|
|
@@ -236,12 +378,14 @@ var CanonicalPublicOperations = class {
|
|
|
236
378
|
const date = options.revisionStamp?.date ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
237
379
|
for (const resolvedOperation of resolved) {
|
|
238
380
|
const { operation, intents, normalizations: adjustments } = resolvedOperation;
|
|
381
|
+
const suggestionId = batch.mode === "suggested" ? ("suggestionId" in operation ? operation.suggestionId : void 0) ?? operation.id : void 0;
|
|
239
382
|
const compiled = compilePublicIntents({
|
|
240
383
|
document,
|
|
241
384
|
intents,
|
|
242
385
|
allocate,
|
|
243
386
|
nextRevisionId,
|
|
244
387
|
mode: batch.mode === "direct" ? "direct" : "tracked-changes",
|
|
388
|
+
suggestionId,
|
|
245
389
|
author: options.author ?? "AI",
|
|
246
390
|
date
|
|
247
391
|
});
|
|
@@ -306,6 +450,11 @@ var CanonicalPublicOperations = class {
|
|
|
306
450
|
skip(operation.id, "noopOperation");
|
|
307
451
|
continue;
|
|
308
452
|
}
|
|
453
|
+
const locked = lockViolationBetween(document, nextDocument);
|
|
454
|
+
if (locked !== null) {
|
|
455
|
+
skip(operation.id, CONTENT_CONTROL_LOCK, `Refused: ${lockedControlMessage(locked)}`);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
309
458
|
normalizations.push(...adjustments);
|
|
310
459
|
document = nextDocument;
|
|
311
460
|
ops.push(...operationOps);
|
|
@@ -318,7 +467,8 @@ var CanonicalPublicOperations = class {
|
|
|
318
467
|
...revisionId === void 0 ? {} : {
|
|
319
468
|
revisionId,
|
|
320
469
|
revisionIds
|
|
321
|
-
}
|
|
470
|
+
},
|
|
471
|
+
...suggestionId === void 0 ? {} : { suggestionId }
|
|
322
472
|
});
|
|
323
473
|
}
|
|
324
474
|
if (batch.atomic && skipped.length > 0) {
|
|
@@ -394,7 +544,85 @@ var CanonicalPublicOperations = class {
|
|
|
394
544
|
undoHandle: handle
|
|
395
545
|
};
|
|
396
546
|
}
|
|
397
|
-
|
|
547
|
+
/**
|
|
548
|
+
* A whole paragraph removed as the editor removes a selection of it with
|
|
549
|
+
* its paragraph mark: from its start to the start of the paragraph after
|
|
550
|
+
* it, or, for the paragraph that ends its block list, from the end of the
|
|
551
|
+
* paragraph before it, whose mark then ends the list. Tracked, the text and
|
|
552
|
+
* the mark are marked deleted.
|
|
553
|
+
*/
|
|
554
|
+
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, refusal }) {
|
|
555
|
+
if (operation.comment !== void 0) return refusal("unsupportedBlock", "Canonical comments on a deleted block are unavailable.");
|
|
556
|
+
if (operation.moveId !== void 0) return refusal("unsupportedBlock", "Canonical tracked moves are unavailable.");
|
|
557
|
+
const end = paragraph.start + paragraph.node.content.size;
|
|
558
|
+
const after = doc.resolve(end + 1).nodeAfter;
|
|
559
|
+
const before = doc.resolve(paragraph.start - 1).nodeBefore;
|
|
560
|
+
const neighbour = (node) => {
|
|
561
|
+
const id = node?.attrs["paraId"];
|
|
562
|
+
return node?.type.name === "paragraph" && typeof id === "string" ? projection.paragraph(id) : void 0;
|
|
563
|
+
};
|
|
564
|
+
const next = neighbour(after);
|
|
565
|
+
const previous = neighbour(before);
|
|
566
|
+
if (tracked && next === void 0 && after !== null) return refusal("unsupportedBlock", "Canonical tracked deletion of a paragraph before a table is unavailable.");
|
|
567
|
+
let range;
|
|
568
|
+
if (next !== void 0) range = {
|
|
569
|
+
from: paragraph.start,
|
|
570
|
+
to: next.start
|
|
571
|
+
};
|
|
572
|
+
else if (!tracked) {
|
|
573
|
+
const own = (from, to) => {
|
|
574
|
+
const start = projection.addressAt(from);
|
|
575
|
+
const stop = projection.addressAt(to);
|
|
576
|
+
return start.isErr() || stop.isErr() ? refusal("unsupportedBlock") : Result.ok(from === to ? [] : [{
|
|
577
|
+
type: "replaceText",
|
|
578
|
+
from: start.value,
|
|
579
|
+
to: stop.value,
|
|
580
|
+
text: ""
|
|
581
|
+
}]);
|
|
582
|
+
};
|
|
583
|
+
const cleared = own(paragraph.start, end);
|
|
584
|
+
if (cleared.isErr()) return cleared;
|
|
585
|
+
const intents = [...cleared.value];
|
|
586
|
+
if (previous !== void 0) intents.push({
|
|
587
|
+
type: "joinParagraphs",
|
|
588
|
+
story: projectionStory,
|
|
589
|
+
blockId: previous.blockId,
|
|
590
|
+
nextBlockId: paragraph.blockId,
|
|
591
|
+
survivor: "first"
|
|
592
|
+
});
|
|
593
|
+
if (intents.length === 0) return refusal("noopOperation");
|
|
594
|
+
return Result.ok({
|
|
595
|
+
type: "plain",
|
|
596
|
+
operation,
|
|
597
|
+
intents,
|
|
598
|
+
normalizations: [],
|
|
599
|
+
from: previous === void 0 ? paragraph.start : previous.start,
|
|
600
|
+
to: end
|
|
601
|
+
});
|
|
602
|
+
} else if (previous !== void 0) range = {
|
|
603
|
+
from: previous.start + previous.node.content.size,
|
|
604
|
+
to: end
|
|
605
|
+
};
|
|
606
|
+
if (range === void 0) return refusal("unsupportedBlock", "Canonical deletion of the only paragraph in its container is unavailable.");
|
|
607
|
+
const from = projection.addressAt(range.from);
|
|
608
|
+
const to = projection.addressAt(range.to);
|
|
609
|
+
if (from.isErr() || to.isErr()) return refusal("unsupportedBlock");
|
|
610
|
+
const intents = [{
|
|
611
|
+
type: "replaceText",
|
|
612
|
+
from: from.value,
|
|
613
|
+
to: to.value,
|
|
614
|
+
text: ""
|
|
615
|
+
}];
|
|
616
|
+
return Result.ok({
|
|
617
|
+
type: "plain",
|
|
618
|
+
operation,
|
|
619
|
+
intents,
|
|
620
|
+
normalizations: [],
|
|
621
|
+
from: Math.min(range.from, paragraph.start),
|
|
622
|
+
to: Math.max(range.to, end)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
resolve({ operation, options, state, story, diff, tracked }) {
|
|
398
626
|
const refusal = (reason, message) => Result.err(new CanonicalPublicOperationResolutionError({
|
|
399
627
|
reason,
|
|
400
628
|
message: message ?? `The operation was refused: ${reason}.`
|
|
@@ -407,7 +635,11 @@ var CanonicalPublicOperations = class {
|
|
|
407
635
|
case "formatRange":
|
|
408
636
|
case "mergeBlockWithNext":
|
|
409
637
|
case "commentOnRange":
|
|
410
|
-
case "commentOnBlock":
|
|
638
|
+
case "commentOnBlock":
|
|
639
|
+
case "deleteBlock":
|
|
640
|
+
case "setBlockParagraphProperties":
|
|
641
|
+
case "insertAfterBlock":
|
|
642
|
+
case "insertBeforeBlock": break;
|
|
411
643
|
default: return refusal("unsupportedBlock", `Canonical public operation ${operation.type} is unavailable.`);
|
|
412
644
|
}
|
|
413
645
|
const blockId = operation.type === "replaceRange" || operation.type === "formatRange" || operation.type === "commentOnRange" ? operation.range.blockId : operation.blockId;
|
|
@@ -421,9 +653,30 @@ var CanonicalPublicOperations = class {
|
|
|
421
653
|
fieldResults: "text",
|
|
422
654
|
noteReferences: collectNoteReferenceLabels(state.doc)
|
|
423
655
|
});
|
|
424
|
-
const hash =
|
|
656
|
+
const hash = hashFolioAIBlockContent(clean.text);
|
|
425
657
|
if (operation.precondition && hash !== operation.precondition.blockTextHash) return refusal("preconditionFailed");
|
|
426
658
|
if (hash !== anchor.textHash) return refusal("changedBlock");
|
|
659
|
+
if (isBlockInsertion(operation)) return resolveBlockInsertion({
|
|
660
|
+
operation,
|
|
661
|
+
paragraph,
|
|
662
|
+
story,
|
|
663
|
+
refusal
|
|
664
|
+
});
|
|
665
|
+
if (operation.type === "setBlockParagraphProperties") return resolveParagraphProperties({
|
|
666
|
+
operation,
|
|
667
|
+
paragraph,
|
|
668
|
+
projection: projection.value,
|
|
669
|
+
refusal
|
|
670
|
+
});
|
|
671
|
+
if (operation.type === "deleteBlock") return this.resolveBlockDeletion({
|
|
672
|
+
operation,
|
|
673
|
+
paragraph,
|
|
674
|
+
projection: projection.value,
|
|
675
|
+
projectionStory: story,
|
|
676
|
+
doc: state.doc,
|
|
677
|
+
tracked,
|
|
678
|
+
refusal
|
|
679
|
+
});
|
|
427
680
|
let start = 0;
|
|
428
681
|
let end = clean.text.length;
|
|
429
682
|
let text = "";
|
|
@@ -617,8 +870,9 @@ var CanonicalPublicOperations = class {
|
|
|
617
870
|
code: "uniformReplacementFormatting"
|
|
618
871
|
});
|
|
619
872
|
}
|
|
620
|
-
const
|
|
621
|
-
const
|
|
873
|
+
const edges = gap.from < gap.to ? projection.value.rangeEdgesAt(gap.from, gap.to) : void 0;
|
|
874
|
+
const changeFrom = projection.value.addressAt(gap.from, edges?.start);
|
|
875
|
+
const changeTo = projection.value.addressAt(gap.to, edges?.end);
|
|
622
876
|
if (changeFrom.isErr() || changeTo.isErr()) return refusal("unsupportedBlock");
|
|
623
877
|
intents.push({
|
|
624
878
|
type: "replaceText",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
|
+
import { ListNormalizationCache } from "../docx/listModelNormalization.js";
|
|
4
|
+
import { ProjectionBlockCache } from "../prosemirror/conversion/toProseDoc.js";
|
|
3
5
|
import { CanonicalSaveSnapshot } from "../types/canonicalSave.js";
|
|
4
|
-
import { CanonicalInlineGap } from "./canonicalInlineProjection.js";
|
|
6
|
+
import { CanonicalInlineGap, CanonicalSeamExtent, InlineProjectionCache } from "./canonicalInlineProjection.js";
|
|
5
7
|
import { Node } from "prosemirror-model";
|
|
6
8
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
7
9
|
import { Err, Ok, Result, TaggedErrorClass } from "better-result";
|
|
@@ -9,8 +11,8 @@ import { DocumentOp, EditorIntent, OpStory, TextPosition, TouchedBlocks } from "
|
|
|
9
11
|
declare const CanonicalSessionErrorBase: TaggedErrorClass<"CanonicalSessionError">;
|
|
10
12
|
export declare class CanonicalSessionError extends CanonicalSessionErrorBase<{
|
|
11
13
|
message: string;
|
|
12
|
-
gap: CanonicalGap;
|
|
13
14
|
reason: "refused" | "noChange";
|
|
15
|
+
ground: CanonicalRefusalGround;
|
|
14
16
|
}> {}
|
|
15
17
|
export type CanonicalSelection = {
|
|
16
18
|
type: "text" | "inlineNode" | "cell" | "all";
|
|
@@ -31,9 +33,17 @@ type ParagraphAddress = {
|
|
|
31
33
|
start: number;
|
|
32
34
|
text: string;
|
|
33
35
|
boundaries: readonly (readonly CanonicalInlineGap[])[];
|
|
36
|
+
seams: readonly (readonly CanonicalSeamExtent[])[];
|
|
34
37
|
node: Node;
|
|
35
38
|
source: document_d_exports.Paragraph;
|
|
36
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Which source gap an editor position names where invisible markers (comment
|
|
42
|
+
* ranges, bookmarks, permission ranges, proofing marks) share it: a caret
|
|
43
|
+
* takes the gap typed text takes (the seam's own gap); `afterMarkers` takes the
|
|
44
|
+
* seam's last gap and `beforeMarkers` its first.
|
|
45
|
+
*/
|
|
46
|
+
export type CanonicalAddressEdge = "caret" | "afterMarkers" | "beforeMarkers";
|
|
37
47
|
type CanonicalProjectionOptions = {
|
|
38
48
|
doc: Node;
|
|
39
49
|
paragraphs: readonly ParagraphAddress[];
|
|
@@ -46,13 +56,55 @@ declare class CanonicalProjection {
|
|
|
46
56
|
private readonly paragraphs;
|
|
47
57
|
private readonly paragraphsById;
|
|
48
58
|
constructor({ doc, paragraphs, story }: CanonicalProjectionOptions);
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The same projection held as `doc`, a document equal to this one's. A
|
|
61
|
+
* commit's transaction ends on a document equal to the projection it staged,
|
|
62
|
+
* sharing the blocks it left; holding that document lets the next commit see
|
|
63
|
+
* the state it was given is the projection without comparing every node.
|
|
64
|
+
*/
|
|
65
|
+
heldAs(doc: Node): CanonicalProjection;
|
|
66
|
+
addressAt(position: number, edge?: CanonicalAddressEdge): Result<TextPosition, CanonicalSessionError>;
|
|
67
|
+
/**
|
|
68
|
+
* The source gaps a selection from `from` to `to` replaces between. Its
|
|
69
|
+
* edges stay inside the markers beside them, so replacing exactly the
|
|
70
|
+
* words a comment covers keeps the comment on the new text. A selection of
|
|
71
|
+
* a paragraph's whole text takes that paragraph's markers with it: an edge
|
|
72
|
+
* at the very start of a paragraph whose text the selection covers to its
|
|
73
|
+
* end reaches before the markers there, and an edge at the very end of a
|
|
74
|
+
* paragraph the selection covers from its start reaches after them, so a
|
|
75
|
+
* comment on nothing but the replaced text is emptied, as removing the
|
|
76
|
+
* text would empty it.
|
|
77
|
+
*/
|
|
78
|
+
rangeEdgesAt(from: number, to: number): {
|
|
79
|
+
start: CanonicalAddressEdge;
|
|
80
|
+
end: CanonicalAddressEdge;
|
|
81
|
+
};
|
|
82
|
+
inputAddressAt(position: number, edge?: CanonicalAddressEdge): Result<TextPosition, CanonicalSessionError>;
|
|
51
83
|
positionAt(address: TextPosition): Result<number, CanonicalSessionError>;
|
|
52
84
|
selectionAt(state: EditorState): Result<CanonicalSelection, CanonicalSessionError>;
|
|
85
|
+
/** The first paragraph the projection addresses, in document order. */
|
|
86
|
+
get firstParagraph(): ParagraphAddress | undefined;
|
|
53
87
|
paragraph(blockId: string): ParagraphAddress | undefined;
|
|
54
88
|
nextParagraphInContainer(blockId: string): ParagraphAddress | undefined;
|
|
55
89
|
}
|
|
90
|
+
/** A session's projection pieces, reused by every projection of its stories. */
|
|
91
|
+
type StoryProjectionCaches = {
|
|
92
|
+
/** The main story's converted blocks. */
|
|
93
|
+
blocks: ProjectionBlockCache;
|
|
94
|
+
/** Each paragraph's gaps, by its source and editor node. */
|
|
95
|
+
inline: InlineProjectionCache;
|
|
96
|
+
/** Each story's normalized list rendering, by block and the counters before it. */
|
|
97
|
+
lists: ListNormalizationCache;
|
|
98
|
+
};
|
|
99
|
+
export declare const newStoryProjectionCaches: () => StoryProjectionCaches;
|
|
100
|
+
type ProjectStoryOptions = {
|
|
101
|
+
document: document_d_exports.Document;
|
|
102
|
+
styles: document_d_exports.StyleDefinitions | null | undefined;
|
|
103
|
+
story?: OpStory;
|
|
104
|
+
/** What earlier projections converted, kept by its session. */
|
|
105
|
+
caches?: StoryProjectionCaches;
|
|
106
|
+
};
|
|
107
|
+
declare const project: ({ document, styles, story, caches }: ProjectStoryOptions) => Result<CanonicalProjection, CanonicalSessionError>;
|
|
56
108
|
/** Input intent, never projection-step adjacency, determines the journal partition. */
|
|
57
109
|
export type CanonicalInputSemantic = "typing" | "deleteBackward" | "deleteForward" | "paste" | "composition" | "replacement" | "structure";
|
|
58
110
|
export type CanonicalCommit = {
|
|
@@ -64,6 +116,8 @@ export type CanonicalCommit = {
|
|
|
64
116
|
touched: TouchedBlocks;
|
|
65
117
|
version: number;
|
|
66
118
|
origin: CanonicalOrigin;
|
|
119
|
+
/** Revisions a content control lock held back; they stay pending. */
|
|
120
|
+
lockHeld?: readonly number[];
|
|
67
121
|
/** Publish only after every projection/plugin transaction has been accepted. */
|
|
68
122
|
publish: () => Result<void, CanonicalSessionError>;
|
|
69
123
|
};
|
|
@@ -83,6 +137,7 @@ type CanonicalSessionSeedOptions = {
|
|
|
83
137
|
document: document_d_exports.Document;
|
|
84
138
|
projection: CanonicalProjection;
|
|
85
139
|
styles: document_d_exports.StyleDefinitions | null | undefined;
|
|
140
|
+
caches: StoryProjectionCaches;
|
|
86
141
|
};
|
|
87
142
|
type CanonicalReplaceTextInput = {
|
|
88
143
|
from: number;
|
|
@@ -117,7 +172,9 @@ declare class CanonicalSession {
|
|
|
117
172
|
private lifecycle;
|
|
118
173
|
private readonly undone;
|
|
119
174
|
private readonly styles;
|
|
120
|
-
|
|
175
|
+
/** What earlier projections converted, reused by every later one. */
|
|
176
|
+
private readonly caches;
|
|
177
|
+
constructor({ document, projection, styles, caches }: CanonicalSessionSeedOptions);
|
|
121
178
|
/** Render only the committed comment projection while provisional IME blocks document snapshots. */
|
|
122
179
|
getCommittedComments(): document_d_exports.Comment[];
|
|
123
180
|
setMode(mode: CanonicalSessionMode): void;
|
|
@@ -136,6 +193,8 @@ declare class CanonicalSession {
|
|
|
136
193
|
get document(): document_d_exports.Document;
|
|
137
194
|
captureSaveSnapshot(): CanonicalSaveSnapshot;
|
|
138
195
|
get projection(): CanonicalProjection;
|
|
196
|
+
/** The caret the last published edit returned, when the editor shows it at `position`. */
|
|
197
|
+
private editCaretAt;
|
|
139
198
|
get selection(): CanonicalSelection | null;
|
|
140
199
|
get version(): number;
|
|
141
200
|
get canUndo(): boolean;
|
|
@@ -146,6 +205,15 @@ declare class CanonicalSession {
|
|
|
146
205
|
endComposition(): void;
|
|
147
206
|
private checkState;
|
|
148
207
|
prepareReplace(state: EditorState, { from, to, text, story, semantic, compositionPhase, time }: CanonicalReplaceTextInput): Result<CanonicalCommit, CanonicalSessionError>;
|
|
208
|
+
/**
|
|
209
|
+
* A structural edit over selected cells: each selected cell is cleared and
|
|
210
|
+
* the edit happens at the start of the first, as the editor's own command
|
|
211
|
+
* does over a cell selection. One commit, so one undo step.
|
|
212
|
+
*/
|
|
213
|
+
prepareCellSelectionStructure(state: EditorState, structure: (at: TextPosition) => EditorIntent, { resourceOps, semantic }?: {
|
|
214
|
+
resourceOps?: readonly DocumentOp[];
|
|
215
|
+
semantic?: CanonicalInputSemantic;
|
|
216
|
+
}): Result<CanonicalCommit, CanonicalSessionError>;
|
|
149
217
|
prepareIntent(state: EditorState, intent: EditorIntent): Result<CanonicalCommit, CanonicalSessionError>;
|
|
150
218
|
prepareIntents(state: EditorState, { intents, resourceOps, semantic }: {
|
|
151
219
|
intents: readonly EditorIntent[];
|
|
@@ -160,6 +228,18 @@ declare class CanonicalSession {
|
|
|
160
228
|
revisionIds: readonly number[];
|
|
161
229
|
resolution: "accept" | "reject";
|
|
162
230
|
}): Result<CanonicalCommit, CanonicalSessionError>;
|
|
231
|
+
/**
|
|
232
|
+
* Accept or reject one pending suggestion. Rejecting it rejects its
|
|
233
|
+
* revisions. Accepting it adopts them as ordinary tracked changes by
|
|
234
|
+
* `author`, keeping their ids, as the editor does: the change then waits
|
|
235
|
+
* for review like any other.
|
|
236
|
+
*/
|
|
237
|
+
prepareSuggestion(state: EditorState, { suggestionId, resolution, author, date }: {
|
|
238
|
+
suggestionId: string;
|
|
239
|
+
resolution: "accept" | "reject";
|
|
240
|
+
author: string;
|
|
241
|
+
date: string;
|
|
242
|
+
}): Result<CanonicalCommit, CanonicalSessionError>;
|
|
163
243
|
projectStory(story: OpStory): Result<CanonicalProjection, CanonicalSessionError>;
|
|
164
244
|
prepareOperations(state: EditorState, ops: readonly DocumentOp[]): Result<CanonicalCommit, CanonicalSessionError>;
|
|
165
245
|
prepareUndo(state: EditorState, story?: OpStory): Result<CanonicalCommit, CanonicalSessionError>;
|
|
@@ -173,4 +253,4 @@ export declare const deletionRange: (state: EditorState, direction: "backward" |
|
|
|
173
253
|
from: number;
|
|
174
254
|
to: number;
|
|
175
255
|
}, CanonicalSessionError>;
|
|
176
|
-
export type
|
|
256
|
+
export { type CanonicalProjection, type CanonicalSession, project as projectCanonicalStory };
|