@stll/folio-core 0.72.0 → 0.74.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/README.md +12 -6
- package/dist/ai-edits/applyTypes.d.ts +85 -0
- package/dist/ai-edits/applyTypes.js +24 -0
- package/dist/ai-edits/clean-text.d.ts +7 -1
- package/dist/ai-edits/clean-text.js +23 -2
- package/dist/ai-edits/finalSectionReview.d.ts +1 -1
- package/dist/ai-edits/headless.d.ts +29 -147
- package/dist/ai-edits/headless.js +215 -1639
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -3
- package/dist/ai-edits/pending-suggestions.d.ts +14 -4
- package/dist/ai-edits/pending-suggestions.js +183 -90
- package/dist/ai-edits/pendingJoin.js +6 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +1 -1
- package/dist/ai-edits/snapshot.js +9 -4
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +2 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-geometry.js +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.js +1 -1
- package/dist/ai-edits/tableNodes.d.ts +38 -0
- package/dist/ai-edits/tableNodes.js +86 -0
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
- package/dist/ai-edits/undefinedReferences.d.ts +7 -0
- package/dist/canonical/batchCommentReferences.js +1 -0
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +5 -27
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +282 -75
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +9 -1
- package/dist/canonical/canonicalSession.js +106 -33
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/inline-atoms-model.d.ts +1 -1
- package/dist/compare/inline-atoms.d.ts +2 -2
- package/dist/compare/inline-provenance-model.d.ts +1 -1
- package/dist/compare/inline-provenance.d.ts +2 -2
- package/dist/compat/eigenpal.d.ts +3 -3
- package/dist/compat/eigenpal.js +2 -3
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.d.ts +13 -3
- package/dist/controller/canonicalClipboard.js +186 -50
- package/dist/controller/canonicalClipboardResources.d.ts +9 -1
- package/dist/controller/canonicalClipboardResources.js +22 -2
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInput.js +1 -1
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalReview.d.ts +1 -1
- package/dist/controller/canonicalReview.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStructure.js +1 -1
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalWatermark.d.ts +10 -0
- package/dist/controller/canonicalWatermark.js +37 -0
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/hiddenEditorApi.d.ts +1 -1
- package/dist/controller/hiddenEditorApi.js +2 -17
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +79 -23
- package/dist/document-operations.d.ts +1 -14
- package/dist/document-operations.js +1 -278
- package/dist/docx/canonicalSave.d.ts +1 -1
- package/dist/docx/canonicalSave.js +1 -1
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/paragraphParser.js +2 -2
- package/dist/docx/paragraphPropertySource.d.ts +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +3 -2
- package/dist/docx/reviewResolutionProvenance.js +31 -8
- package/dist/docx/revisionIdNormalization.js +30 -7
- package/dist/docx/rezip.d.ts +1 -1
- package/dist/docx/rezip.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +4 -36
- package/dist/docx/server/templatePlan/apply.d.ts +15 -0
- package/dist/docx/server/templatePlan/apply.js +658 -0
- package/dist/docx/server/templatePlan/blocks.d.ts +97 -0
- package/dist/docx/server/templatePlan/blocks.js +355 -0
- package/dist/docx/server/templatePlan/builders.d.ts +72 -0
- package/dist/docx/server/templatePlan/builders.js +237 -0
- package/dist/docx/server/templatePlan/emit.d.ts +118 -0
- package/dist/docx/server/templatePlan/emit.js +466 -0
- package/dist/docx/server/templatePlan/emphasis.d.ts +62 -0
- package/dist/docx/server/templatePlan/emphasis.js +173 -0
- package/dist/docx/server/templatePlan/inspect.d.ts +22 -0
- package/dist/docx/server/templatePlan/inspect.js +230 -0
- package/dist/docx/server/templatePlan/labels.d.ts +45 -0
- package/dist/docx/server/templatePlan/labels.js +155 -0
- package/dist/docx/server/templatePlan/package.d.ts +34 -0
- package/dist/docx/server/templatePlan/package.js +99 -0
- package/dist/docx/server/templatePlan/plan.d.ts +145 -0
- package/dist/docx/server/templatePlan/plan.js +875 -0
- package/dist/docx/server/templatePlan/planShape.d.ts +9 -0
- package/dist/docx/server/templatePlan/planShape.js +180 -0
- package/dist/docx/server/templatePlan/resources.d.ts +41 -0
- package/dist/docx/server/templatePlan/resources.js +136 -0
- package/dist/docx/server/templatePlan/story.d.ts +128 -0
- package/dist/docx/server/templatePlan/story.js +440 -0
- package/dist/docx/server/templatePlan/types.d.ts +442 -0
- package/dist/docx/server/templatePlan/types.js +29 -0
- package/dist/docx/server/templatePlan/verify.d.ts +40 -0
- package/dist/docx/server/templatePlan/verify.js +976 -0
- package/dist/docx/server/templatePlan/xml.d.ts +74 -0
- package/dist/docx/server/templatePlan/xml.js +125 -0
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +9 -0
- package/dist/docx/settingsHeaderFooterUpdate.js +45 -10
- package/dist/docx/structuralXmlPatch.js +9 -1
- package/dist/docx/tableGridXml.d.ts +30 -0
- package/dist/docx/tableGridXml.js +54 -0
- package/dist/docx/tableParser.js +7 -0
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -3
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/managers/ContextMenuManager.js +2 -1
- package/dist/managers/editorShortcuts.d.ts +1 -1
- package/dist/prosemirror/anchoredTextBoxes.d.ts +1 -1
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.d.ts +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +3 -3
- package/dist/prosemirror/commands/comments.js +4 -4
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commands/sectionBreak.js +1 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +1 -1
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +1 -1
- package/dist/prosemirror/commentRecords.d.ts +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/documentStructureCounts.d.ts +24 -0
- package/dist/prosemirror/documentStructureCounts.js +76 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -1
- package/dist/prosemirror/extensions/core/historyCommands.d.ts +16 -0
- package/dist/prosemirror/extensions/core/historyCommands.js +19 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedCellSections.d.ts +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +8 -41
- package/dist/prosemirror/extensions/types.d.ts +1 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +1 -1
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertionGaps.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.d.ts +1 -1
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.d.ts +1 -1
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/lockedControls.d.ts +1 -1
- package/dist/prosemirror/markupViewProjection.d.ts +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.d.ts +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/{extensions/features/ParaIdAllocatorExtension.d.ts → paraIds.d.ts} +13 -23
- package/dist/prosemirror/paraIds.js +152 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.d.ts +97 -0
- package/dist/prosemirror/paragraphChangeTrackerMeta.js +87 -0
- package/dist/prosemirror/paragraphMarkJoin.d.ts +1 -1
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +1 -1
- package/dist/prosemirror/pastedCommentCopies.d.ts +1 -1
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.js +17 -2
- package/dist/prosemirror/revisionCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/sectionMarkEdits.d.ts +1 -1
- package/dist/prosemirror/selectionBounds.d.ts +10 -0
- package/dist/prosemirror/selectionBounds.js +22 -0
- package/dist/prosemirror/storyListNumbering.d.ts +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.d.ts +1 -1
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableGridMutation.d.ts +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.d.ts +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +7 -2
- package/dist/server.js +6 -1
- package/dist/types/canonicalCapabilities.d.ts +13 -92
- package/dist/types/canonicalCapabilities.js +11 -85
- package/package.json +4 -4
- package/dist/ai-edits/apply.d.ts +0 -202
- package/dist/ai-edits/apply.js +0 -6759
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -18
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -122
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -408
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -135
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -566
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SUGGESTED_SUPPORTED_OPERATION_TYPES
|
|
1
|
+
import { SUGGESTED_SUPPORTED_OPERATION_TYPES } from "../ai-edits/applyTypes.js";
|
|
2
2
|
import { BatchClaims } from "../ai-edits/batch-claims.js";
|
|
3
3
|
import { describeCharacterSplit } from "../ai-edits/character-boundaries.js";
|
|
4
4
|
import { buildCleanBlockText, resolveCleanTextRange } from "../ai-edits/clean-text.js";
|
|
@@ -12,12 +12,13 @@ import { cutsIntoNoteReference, endsWithNoteReference, noteReferenceEditsAllowed
|
|
|
12
12
|
import { PENDING_BREAK_TABLE_REFUSAL, PENDING_JOIN_INSERTION_REFUSAL, firstParagraphJoiningTable, insertionAfterPendingBreak, isDeletedPPrMark, joinStopsAtTableAfter, pendingJoinParagraphs, pendingMarkEditOf, pendingMarkEditRefusal, pendingParagraphPropertiesRefusal } from "../ai-edits/pendingJoin.js";
|
|
13
13
|
import { addRetiredCommentReceipts } from "../ai-edits/retired-comment-receipts.js";
|
|
14
14
|
import { collectNoteReferenceLabels, hashFolioAIBlockContent, hashFolioAIBlockText } from "../ai-edits/snapshot.js";
|
|
15
|
-
import {
|
|
15
|
+
import { isInsertedPPrMark, snapshotBatchClaim } from "../ai-edits/snapshotBatchFacts.js";
|
|
16
16
|
import { mergesRemoveRow } from "../ai-edits/table-mutation-plan.js";
|
|
17
17
|
import { applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getInsertedPhysicalColumnRows, getTableColumnCoordinateKey, splitCellParagraphTexts } from "../ai-edits/table-row-column-mutations.js";
|
|
18
18
|
import { findEnclosingTableCell, findEnclosingTableRow, findOutermostTableBoundary, tableRectangleCutsMergedCell } from "../ai-edits/table-targets.js";
|
|
19
19
|
import { tableFromTemplate } from "../ai-edits/table-template.js";
|
|
20
20
|
import { supportsTableInsertionMode } from "../ai-edits/tableInsertionModes.js";
|
|
21
|
+
import { buildSignatureTableNode, buildTableNode } from "../ai-edits/tableNodes.js";
|
|
21
22
|
import { createOperationHeadingStyles, findUndefinedOperationReference, styleDefinitionLookup } from "../ai-edits/undefinedReferences.js";
|
|
22
23
|
import { wordDiffSessionFromOptions } from "../ai-edits/word-diff.js";
|
|
23
24
|
import { getFolioDocumentOperationIssues, getFolioDocumentOperationReceiptsForStory, parseFolioDocumentOperationBatch, withDistinctSuggestionIds } from "../document-operations.js";
|
|
@@ -27,13 +28,13 @@ import { expectRunPropertyChangeMarkAttrs, expectTableAttrs } from "../prosemirr
|
|
|
27
28
|
import { tableAnchor } from "../prosemirror/canonicalTableCommands.js";
|
|
28
29
|
import { paragraphEndsItsContainer } from "../prosemirror/containerFinalParagraph.js";
|
|
29
30
|
import { standaloneTableRowsFromProseMirror, tableAttrsToFormatting } from "../prosemirror/conversion/fromProseDoc.js";
|
|
30
|
-
import { ensureParaIdsInDoc } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
|
|
31
31
|
import { insertionGap } from "../prosemirror/insertionGaps.js";
|
|
32
|
+
import { ensureParaIdsInDoc } from "../prosemirror/paraIds.js";
|
|
32
33
|
import { forEachAnnotationIdInDoc } from "../prosemirror/plugins/revisionIds.js";
|
|
33
34
|
import { preservesReplacementCommentAlignment, splitAtKeptCommentBoundaries, surveyAcceptedReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
|
|
34
35
|
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
35
36
|
import { insertedColumnWidth, omittedSlotTakingColumn } from "../prosemirror/tableGridMutation.js";
|
|
36
|
-
import { paragraphGoes } from "../prosemirror/tableRunIn.js";
|
|
37
|
+
import { paragraphGoes, tableGoes } from "../prosemirror/tableRunIn.js";
|
|
37
38
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
38
39
|
import { readModel } from "../types/documentModel.js";
|
|
39
40
|
import { batchCommentReferenceShift, mapIntentPositions } from "./batchCommentReferences.js";
|
|
@@ -54,10 +55,10 @@ import { replacementRunSources } from "./replacementRunSources.js";
|
|
|
54
55
|
import { Result, TaggedError, panic } from "better-result";
|
|
55
56
|
import { commentAuthorIssue, trackedChangeAuthorIssue } from "@stll/docx-core";
|
|
56
57
|
import { CONTENT_CONTROL_LOCK, MAX_REVISION_ID, lockedControlMessage, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
57
|
-
import {
|
|
58
|
-
import { TableMap } from "prosemirror-tables";
|
|
59
|
-
import { BATCH_ANNOTATION_KINDS, DOCUMENT_OP_TYPES, ID_KIND_LIMITS, ID_LEASE_KINDS, OP_STORIES, SPLIT_HALVES, TYPED_TEXT_FORMATTING, applyDocumentOps, combineRecordedRevisions, compileEditorIntent, contentRank, createEditorIntentIdAllocator, deletionRemovesBlock, documentStories, finalBreakCarrier, findStoryBody, formatParaId, freshCommentId, groupInsertionRuns, idKey, introducedDocumentIds, isBlockBoundary, isCommentAnchorCarrierType, joinPropertyChangeLink, leasedIdCensus, locateParagraphThroughTextBoxes, noteDeletionOps, orderAddressingBeforeRemoval, orderBatchOperations, packageResourcesOpOf, paragraphLength, paragraphsThroughTextBoxes, pendingSuggestionIdsIn, revisionSpan } from "@stll/docx-core/ops";
|
|
58
|
+
import { BATCH_ANNOTATION_KINDS, DOCUMENT_OP_TYPES, ID_KIND_LIMITS, ID_LEASE_KINDS, OP_STORIES, SPLIT_HALVES, TYPED_TEXT_FORMATTING, applyDocumentOps, combineRecordedRevisions, compileEditorIntent, contentRank, createEditorIntentIdAllocator, deletionRemovesBlock, documentStories, finalBreakCarrier, findStoryBody, formatParaId, freshCommentId, groupInsertionRuns, idKey, introducedDocumentIds, isBlockBoundary, isCommentAnchorCarrierType, joinPropertyChangeLink, leasedIdCensus, locateParagraphThroughTextBoxes, noteDeletionOps, orderAddressingBeforeRemoval, orderBatchOperations, packageResourcesOpOf, paragraphHoldsContent, paragraphHoldsContentOnceAccepted, paragraphLength, paragraphsThroughTextBoxes, pendingSuggestionIdsIn, revisionSpan } from "@stll/docx-core/ops";
|
|
60
59
|
import { EditorState } from "prosemirror-state";
|
|
60
|
+
import { TableMap } from "prosemirror-tables";
|
|
61
|
+
import { Mark } from "prosemirror-model";
|
|
61
62
|
// src/canonical/canonicalPublicOperations.ts
|
|
62
63
|
/** Public batches compile against the read projection; only the canonical journal publishes. */
|
|
63
64
|
const tableLineRemovalKey = ({ axis, tablePosition, index }) => `${axis}:${tablePosition}:${index}`;
|
|
@@ -384,6 +385,15 @@ const rowClosingCellShapes = ({ items, doc }) => {
|
|
|
384
385
|
return refused;
|
|
385
386
|
};
|
|
386
387
|
/**
|
|
388
|
+
* Whether a deletion of a paragraph that a pending join runs words into
|
|
389
|
+
* takes those words too (`joinedWords`): tracked it does, as the joined
|
|
390
|
+
* paragraph carries the deleted one's id; a suggestion stays rejectable on
|
|
391
|
+
* its own and takes only the paragraph's own words. The deletion and the
|
|
392
|
+
* batch order both read this rule, so an edit of the joined words runs
|
|
393
|
+
* before the deletion only when the deletion takes them.
|
|
394
|
+
*/
|
|
395
|
+
const deletionTakesJoinedWords = (mode) => mode === "tracked-changes";
|
|
396
|
+
/**
|
|
387
397
|
* A paragraph's mark, as a block an operation addresses or removes: no
|
|
388
398
|
* block position is negative.
|
|
389
399
|
*/
|
|
@@ -413,7 +423,25 @@ const removedTableParagraphs = (doc, type, block) => {
|
|
|
413
423
|
return blocks;
|
|
414
424
|
};
|
|
415
425
|
const orderCanonicalBatch = ({ items, doc, mode }) => {
|
|
416
|
-
const deletionOf = new Map(
|
|
426
|
+
const deletionOf = /* @__PURE__ */ new Map();
|
|
427
|
+
const directTableDeletionOf = /* @__PURE__ */ new Map();
|
|
428
|
+
for (const item of items) {
|
|
429
|
+
const { claim, block } = item.plan;
|
|
430
|
+
if (claim.type === "deleteBlock") deletionOf.set(block, item);
|
|
431
|
+
if (mode === "direct" && claim.type === "tableRemoval" && claim.axis === "table") directTableDeletionOf.set(claim.table, item);
|
|
432
|
+
}
|
|
433
|
+
const precedingTableDeletionOf = /* @__PURE__ */ new Map();
|
|
434
|
+
if (directTableDeletionOf.size > 0) for (const item of deletionOf.values()) {
|
|
435
|
+
if (!item.removesParagraphBeforeBlock) continue;
|
|
436
|
+
const at = doc.resolve(item.plan.block);
|
|
437
|
+
let position = at.pos;
|
|
438
|
+
for (let index = at.index() - 1; index >= 0; index--) {
|
|
439
|
+
position -= at.parent.child(index).nodeSize;
|
|
440
|
+
const tableDeletion = directTableDeletionOf.get(position);
|
|
441
|
+
if (tableDeletion === void 0) break;
|
|
442
|
+
precedingTableDeletionOf.set(item, tableDeletion);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
417
445
|
const deleted = new Set(deletionOf.keys());
|
|
418
446
|
const joinedAway = new Set(items.flatMap(({ plan }) => plan.claim.type === "merge" && plan.claim.joinsNow ? [plan.block] : []));
|
|
419
447
|
const deletedSplits = new Set(items.flatMap(({ operation, plan }) => {
|
|
@@ -466,6 +494,8 @@ const orderCanonicalBatch = ({ items, doc, mode }) => {
|
|
|
466
494
|
rank: before.rank + steps
|
|
467
495
|
} : planned;
|
|
468
496
|
};
|
|
497
|
+
const precedingTableDeletion = precedingTableDeletionOf.get(item);
|
|
498
|
+
if (precedingTableDeletion !== void 0) return following(precedingTableDeletion, 1);
|
|
469
499
|
const deletion = plan.claim.type === "merge" && plan.claim.joinsNow ? deletionOf.get(plan.claim.next) : void 0;
|
|
470
500
|
if (deletion !== void 0) return following(deletion, 2);
|
|
471
501
|
const run = operation.type === "deleteBlock" ? deletedRunBeforeBlock(plan.block, item.retiresRunBreak !== void 0) : void 0;
|
|
@@ -531,7 +561,7 @@ const orderCanonicalBatch = ({ items, doc, mode }) => {
|
|
|
531
561
|
});
|
|
532
562
|
const takesCarrierMark = !prepended && carrier.type === "kept" && plan.address.type === "content" && plan.address.position < plan.block;
|
|
533
563
|
const joined = [];
|
|
534
|
-
if (mode
|
|
564
|
+
if (deletionTakesJoinedWords(mode) && !isDeletedPPrMark(paragraph.attrs["pPrMark"])) for (const { paragraph: previous } of before) {
|
|
535
565
|
if (!isDeletedPPrMark(doc.nodeAt(previous)?.attrs["pPrMark"])) break;
|
|
536
566
|
joined.push(previous);
|
|
537
567
|
}
|
|
@@ -701,6 +731,40 @@ const statedPropertiesIntents = ({ story, blockId, properties, mintList }) => {
|
|
|
701
731
|
};
|
|
702
732
|
const isBlockInsertion = (operation) => operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock";
|
|
703
733
|
const placesBlock = (operation) => isBlockInsertion(operation) || operation.type === "insertTable" || operation.type === "insertSignatureTable";
|
|
734
|
+
/** The side of the block it names that an insertion puts its block on. */
|
|
735
|
+
const placementSide = (operation) => {
|
|
736
|
+
switch (operation.type) {
|
|
737
|
+
case "insertBeforeBlock": return "before";
|
|
738
|
+
case "insertAfterBlock": return "after";
|
|
739
|
+
case "insertTable":
|
|
740
|
+
case "insertSignatureTable": return operation.position ?? "after";
|
|
741
|
+
default: return operation;
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
const placesTable = (operation) => operation.type === "insertTable" || operation.type === "insertSignatureTable";
|
|
745
|
+
/**
|
|
746
|
+
* Whether the last of the blocks a batch puts after a block, of `placed`
|
|
747
|
+
* beside it in input order, is a table: those land in that order, so it is
|
|
748
|
+
* the one right before the block after.
|
|
749
|
+
*/
|
|
750
|
+
const lastPutAfterIsTable = (placed) => {
|
|
751
|
+
const last = placed.findLast((operation) => placementSide(operation) === "after");
|
|
752
|
+
return last !== void 0 && placesTable(last);
|
|
753
|
+
};
|
|
754
|
+
const deletedParagraphPlacement = ({ beside, tableBefore, tableAfter, after }) => {
|
|
755
|
+
const before = beside.filter((operation) => placementSide(operation) === "before");
|
|
756
|
+
const last = before.at(-1);
|
|
757
|
+
const firstAfter = beside.find((operation) => placementSide(operation) === "after");
|
|
758
|
+
const precededByTable = last === void 0 ? tableBefore : placesTable(last);
|
|
759
|
+
const followedByTable = firstAfter === void 0 ? tableAfter : placesTable(firstAfter);
|
|
760
|
+
if (precededByTable && followedByTable) return { type: "keepsTablesApart" };
|
|
761
|
+
if (after === null || after.type.name === "paragraph") return { type: "inPlace" };
|
|
762
|
+
const firstParagraph = before.findIndex((operation) => operation.type === "insertBeforeBlock");
|
|
763
|
+
return {
|
|
764
|
+
type: "placedAfter",
|
|
765
|
+
operationIds: new Set(firstParagraph < 0 ? [] : before.slice(firstParagraph).map(({ id }) => id))
|
|
766
|
+
};
|
|
767
|
+
};
|
|
704
768
|
/**
|
|
705
769
|
* Where an insertion beside `paragraph` goes: beside the paragraph, or, for a
|
|
706
770
|
* paragraph in a table cell, beside the outermost table, as the default
|
|
@@ -1298,11 +1362,29 @@ const commentsRetiredBetween = (before, after) => {
|
|
|
1298
1362
|
return (before.package.document.comments ?? []).flatMap(({ id, parentId }) => parentId === void 0 && !kept.has(id) ? [id] : []);
|
|
1299
1363
|
};
|
|
1300
1364
|
/**
|
|
1365
|
+
* Whether only paragraphs accepting removes whole stand in `blocks`, one of
|
|
1366
|
+
* them at least pending removal: a join before them, once accepted, has no
|
|
1367
|
+
* words after it to separate. Range boundaries among them hold nothing.
|
|
1368
|
+
*/
|
|
1369
|
+
const onlyRemovedParagraphsFollow = (blocks) => {
|
|
1370
|
+
let removes = false;
|
|
1371
|
+
for (const block of blocks) {
|
|
1372
|
+
if (isBlockBoundary(block)) continue;
|
|
1373
|
+
if (block.type !== "paragraph" || paragraphHoldsContentOnceAccepted(block)) return false;
|
|
1374
|
+
removes ||= paragraphHoldsContent(block) || block.pPrMark?.kind === "del";
|
|
1375
|
+
}
|
|
1376
|
+
return removes;
|
|
1377
|
+
};
|
|
1378
|
+
/**
|
|
1301
1379
|
* A merge's intents as the batch stands in `document` when the merge runs.
|
|
1302
1380
|
* The separator goes in at the first paragraph's end as it now stands: an
|
|
1303
1381
|
* edit of that paragraph the batch ran first, a comment's reference among
|
|
1304
|
-
* them, may have changed its length.
|
|
1305
|
-
*
|
|
1382
|
+
* them, may have changed its length. Where only paragraphs accepting removes
|
|
1383
|
+
* whole follow it, deletions the batch made first among them, it goes in not
|
|
1384
|
+
* at all: accepting leaves no words after it to separate, as the legacy
|
|
1385
|
+
* engine reads the document as the merge runs. A deletion the batch refuses,
|
|
1386
|
+
* or makes after the merge, has not taken them. Direct, the join also binds
|
|
1387
|
+
* to the paragraph that now follows: a paragraph the batch deleted first is no
|
|
1306
1388
|
* longer there, so the merge joins across it, as merging after that deletion
|
|
1307
1389
|
* does; `undefined` when no paragraph follows any more. Tracked, a deleted
|
|
1308
1390
|
* paragraph stays, and the join keeps it, unless an earlier operation joined
|
|
@@ -1319,21 +1401,29 @@ const mergeIntentsAsItRuns = ({ document, story, intents, mode }) => {
|
|
|
1319
1401
|
const bindsToNext = mode === "direct" || !locations.some(({ paragraph }) => idKey(paragraph.paraId ?? "") === was);
|
|
1320
1402
|
if (here === void 0) return bindsToNext ? void 0 : intents;
|
|
1321
1403
|
const end = paragraphLength(here.paragraph);
|
|
1404
|
+
const siblings = locateParagraphThroughTextBoxes(document, story, join.blockId)?.blocks;
|
|
1405
|
+
const separates = siblings === void 0 || !onlyRemovedParagraphsFollow(siblings.slice(here.index + 1));
|
|
1322
1406
|
const separatorAtEnd = [];
|
|
1323
|
-
for (const intent of intents)
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
offset: end
|
|
1328
|
-
},
|
|
1329
|
-
to: {
|
|
1330
|
-
...intent.to,
|
|
1331
|
-
offset: end
|
|
1407
|
+
for (const intent of intents) {
|
|
1408
|
+
if (intent.type !== "replaceText" || idKey(intent.from.blockId) !== key || intent.from.offset !== intent.to.offset) {
|
|
1409
|
+
separatorAtEnd.push(intent);
|
|
1410
|
+
continue;
|
|
1332
1411
|
}
|
|
1333
|
-
|
|
1412
|
+
if (separates) separatorAtEnd.push({
|
|
1413
|
+
...intent,
|
|
1414
|
+
from: {
|
|
1415
|
+
...intent.from,
|
|
1416
|
+
offset: end
|
|
1417
|
+
},
|
|
1418
|
+
to: {
|
|
1419
|
+
...intent.to,
|
|
1420
|
+
offset: end
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1334
1424
|
if (!bindsToNext) return separatorAtEnd;
|
|
1335
1425
|
const next = locations[at + 1];
|
|
1336
|
-
const between =
|
|
1426
|
+
const between = siblings?.slice(here.index + 1, next?.index ?? here.index + 1);
|
|
1337
1427
|
const nextId = next !== void 0 && JSON.stringify(here.list) === JSON.stringify(next.list) && (here.index + 1 === next.index || here.paragraph.sectionProperties === void 0 && between !== void 0 && between.length === next.index - here.index - 1 && between.every(isBlockBoundary)) ? next.paragraph.paraId : void 0;
|
|
1338
1428
|
if (nextId === void 0) return void 0;
|
|
1339
1429
|
const boundToNext = (intent) => {
|
|
@@ -2457,6 +2547,36 @@ const mapColumnDeletionIntents = ({ intents, columnIndex, inserted, insertedAfte
|
|
|
2457
2547
|
return intent;
|
|
2458
2548
|
});
|
|
2459
2549
|
};
|
|
2550
|
+
/**
|
|
2551
|
+
* The words of `blockId` the batch's comments cover, in its clean text: a
|
|
2552
|
+
* batch's comments run before its edits, so an edit there meets them as it
|
|
2553
|
+
* meets the comments the paragraph already holds. A comment whose target no
|
|
2554
|
+
* longer matches covers nothing; its own resolution refuses it.
|
|
2555
|
+
*/
|
|
2556
|
+
const batchCommentSpans = (comments, blockId, text) => comments.flatMap((comment) => {
|
|
2557
|
+
switch (comment.type) {
|
|
2558
|
+
case "commentOnRange": {
|
|
2559
|
+
const { range } = comment;
|
|
2560
|
+
return range.blockId === blockId && hashFolioAIBlockText(text.slice(range.startOffset, range.endOffset)) === range.selectedTextHash ? [{
|
|
2561
|
+
start: range.startOffset,
|
|
2562
|
+
end: range.endOffset
|
|
2563
|
+
}] : [];
|
|
2564
|
+
}
|
|
2565
|
+
case "commentOnBlock": {
|
|
2566
|
+
if (comment.blockId !== blockId) return [];
|
|
2567
|
+
if (comment.quote === void 0) return [{
|
|
2568
|
+
start: 0,
|
|
2569
|
+
end: text.length
|
|
2570
|
+
}];
|
|
2571
|
+
const start = text.indexOf(comment.quote);
|
|
2572
|
+
return start < 0 || comment.quote === "" ? [] : [{
|
|
2573
|
+
start,
|
|
2574
|
+
end: start + comment.quote.length
|
|
2575
|
+
}];
|
|
2576
|
+
}
|
|
2577
|
+
default: return comment;
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2460
2580
|
/** Whether the batch deletes none of the paragraphs right before. */
|
|
2461
2581
|
const noDeletedRunBefore = ({ type }) => {
|
|
2462
2582
|
switch (type) {
|
|
@@ -2535,7 +2655,8 @@ const NO_BESIDE_DELETIONS = {
|
|
|
2535
2655
|
deleted: /* @__PURE__ */ new Set()
|
|
2536
2656
|
},
|
|
2537
2657
|
paragraphsAfter: /* @__PURE__ */ new Set(),
|
|
2538
|
-
paragraphsAfterEarlier: () => /* @__PURE__ */ new Set()
|
|
2658
|
+
paragraphsAfterEarlier: () => /* @__PURE__ */ new Set(),
|
|
2659
|
+
placedBeside: () => []
|
|
2539
2660
|
};
|
|
2540
2661
|
/**
|
|
2541
2662
|
* The stated numbering a request names, minting its new list once for the
|
|
@@ -2841,6 +2962,7 @@ var CanonicalPublicOperations = class {
|
|
|
2841
2962
|
...normalizations.length === 0 ? {} : { normalizations }
|
|
2842
2963
|
};
|
|
2843
2964
|
};
|
|
2965
|
+
const batchComments = batch.operations.filter((operation) => operation.type === "commentOnBlock" || operation.type === "commentOnRange");
|
|
2844
2966
|
const besideDeletions = {
|
|
2845
2967
|
deleted: new Set(batch.operations.flatMap((operation) => operation.type === "deleteBlock" ? [operation.blockId] : [])),
|
|
2846
2968
|
insertedBeside: new Set(batch.operations.flatMap((operation) => operation.type === "insertAfterBlock" || operation.type === "insertBeforeBlock" ? [operation.blockId] : [])),
|
|
@@ -2853,7 +2975,8 @@ var CanonicalPublicOperations = class {
|
|
|
2853
2975
|
paragraphsAfterEarlier: (operationId) => {
|
|
2854
2976
|
const index = batch.operations.findIndex(({ id }) => id === operationId);
|
|
2855
2977
|
return new Set(batch.operations.slice(0, Math.max(index, 0)).flatMap((operation) => operation.type === "insertAfterBlock" ? [operation.blockId] : []));
|
|
2856
|
-
}
|
|
2978
|
+
},
|
|
2979
|
+
placedBeside: (blockId) => batch.operations.filter((operation) => placesBlock(operation) && operation.blockId === blockId)
|
|
2857
2980
|
};
|
|
2858
2981
|
const inputIndices = new Map(batch.operations.map(({ id }, index) => [id, index]));
|
|
2859
2982
|
const planned = (item) => {
|
|
@@ -2938,7 +3061,8 @@ var CanonicalPublicOperations = class {
|
|
|
2938
3061
|
tracked: batch.mode !== "direct",
|
|
2939
3062
|
suggested: batch.mode === "suggested",
|
|
2940
3063
|
mintList,
|
|
2941
|
-
besideDeletions
|
|
3064
|
+
besideDeletions,
|
|
3065
|
+
batchComments
|
|
2942
3066
|
});
|
|
2943
3067
|
if (compiled.isErr()) {
|
|
2944
3068
|
const direct = compiled.error.refusedIn === "trackedMode" ? this.resolve({
|
|
@@ -2950,7 +3074,8 @@ var CanonicalPublicOperations = class {
|
|
|
2950
3074
|
tracked: false,
|
|
2951
3075
|
suggested: false,
|
|
2952
3076
|
mintList,
|
|
2953
|
-
besideDeletions
|
|
3077
|
+
besideDeletions,
|
|
3078
|
+
batchComments
|
|
2954
3079
|
}) : void 0;
|
|
2955
3080
|
if (direct?.isOk()) {
|
|
2956
3081
|
const candidate = planned(direct.value);
|
|
@@ -2971,8 +3096,8 @@ var CanonicalPublicOperations = class {
|
|
|
2971
3096
|
}
|
|
2972
3097
|
for (const item of [...resolved]) {
|
|
2973
3098
|
if (item.besideDeletion !== true || !state) continue;
|
|
2974
|
-
const {
|
|
2975
|
-
if (operation.type !== "deleteBlock" && operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock") continue;
|
|
3099
|
+
const operation = batch.operations.find(({ id }) => id === item.operation.id) ?? panic("A resolved operation lost its request.");
|
|
3100
|
+
if (operation.type !== "deleteBlock" && operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock" && operation.type !== "insertTable" && operation.type !== "insertSignatureTable") continue;
|
|
2976
3101
|
if (resolved.some(({ operation: other }) => operation.type === "deleteBlock" ? (other.type === "insertAfterBlock" || other.type === "insertBeforeBlock") && other.blockId === operation.blockId : other.type === "deleteBlock" && other.blockId === operation.blockId)) continue;
|
|
2977
3102
|
resolved.splice(resolved.indexOf(item), 1);
|
|
2978
3103
|
claims = new BatchClaims();
|
|
@@ -2986,7 +3111,8 @@ var CanonicalPublicOperations = class {
|
|
|
2986
3111
|
tracked: batch.mode !== "direct",
|
|
2987
3112
|
suggested: batch.mode === "suggested",
|
|
2988
3113
|
mintList,
|
|
2989
|
-
besideDeletions: NO_BESIDE_DELETIONS
|
|
3114
|
+
besideDeletions: NO_BESIDE_DELETIONS,
|
|
3115
|
+
batchComments
|
|
2990
3116
|
});
|
|
2991
3117
|
if (alone.isErr()) {
|
|
2992
3118
|
refuseResolution(operation.id, alone.error);
|
|
@@ -3118,7 +3244,7 @@ var CanonicalPublicOperations = class {
|
|
|
3118
3244
|
const retired = resolvedOperation.retiresBreakBefore === true ? retiredBreakAsItRuns(sourceDocument, story, rebound) : rebound;
|
|
3119
3245
|
const deleting = resolvedOperation.mayEndContainer === true ? finalDeletionIntentsAsItRuns(sourceDocument, story, retired) : retired;
|
|
3120
3246
|
const suggestionId = batch.mode === "suggested" ? ("suggestionId" in operation ? operation.suggestionId : void 0) ?? operation.id : void 0;
|
|
3121
|
-
const retracting = operation.type === "deleteBlock" && batch.mode !== "direct" && operation.moveId === void 0 ? takenOverBreakRetractionAsItRuns({
|
|
3247
|
+
const retracting = operation.type === "deleteBlock" && batch.mode !== "direct" && operation.moveId === void 0 && resolvedOperation.keepsTablesApart !== true ? takenOverBreakRetractionAsItRuns({
|
|
3122
3248
|
document: sourceDocument,
|
|
3123
3249
|
story,
|
|
3124
3250
|
blockId: operation.blockId,
|
|
@@ -3359,11 +3485,14 @@ var CanonicalPublicOperations = class {
|
|
|
3359
3485
|
verifiedOperation: compiled.value.verifiedOperation
|
|
3360
3486
|
};
|
|
3361
3487
|
};
|
|
3488
|
+
/** The operations that resolved but were declined as they ran. */
|
|
3489
|
+
const declinedAsRun = /* @__PURE__ */ new Set();
|
|
3362
3490
|
const commitOperation = (resolvedOperation, prepared) => {
|
|
3363
3491
|
const { operation, normalizations: adjustments } = resolvedOperation;
|
|
3364
3492
|
if (prepared.type === "declined") {
|
|
3365
3493
|
if (prepared.refusal !== void 0) refusals.set(operation.id, prepared.refusal);
|
|
3366
3494
|
skip(operation.id, prepared.reason, prepared.message);
|
|
3495
|
+
declinedAsRun.add(operation.id);
|
|
3367
3496
|
return;
|
|
3368
3497
|
}
|
|
3369
3498
|
const survivorMaps = operation.type === "deleteBlock" ? [survivorOf, deletionSurvivorOf] : [survivorOf];
|
|
@@ -3420,10 +3549,10 @@ var CanonicalPublicOperations = class {
|
|
|
3420
3549
|
};
|
|
3421
3550
|
/**
|
|
3422
3551
|
* Where an insertion stands among those at its gap: in batch order, but a
|
|
3423
|
-
*
|
|
3424
|
-
*
|
|
3552
|
+
* block put before one the direct batch deletes, placed after it instead
|
|
3553
|
+
* (`besideDeletion`), still goes ahead of the blocks put after it.
|
|
3425
3554
|
*/
|
|
3426
|
-
const placementOrderOf = (member) => member.besideDeletion === true && member.operation.
|
|
3555
|
+
const placementOrderOf = (member) => member.besideDeletion === true && placesBlock(member.operation) && placementSide(member.operation) === "after" ? orderOf(member) - batch.operations.length : orderOf(member);
|
|
3427
3556
|
const gaps = /* @__PURE__ */ new Map();
|
|
3428
3557
|
for (const member of executionOrder) {
|
|
3429
3558
|
if (!placesBlock(member.operation)) continue;
|
|
@@ -3703,6 +3832,35 @@ var CanonicalPublicOperations = class {
|
|
|
3703
3832
|
})]
|
|
3704
3833
|
};
|
|
3705
3834
|
}
|
|
3835
|
+
const declinedLayoutChanges = new Set(batch.atomic ? [] : batch.operations.flatMap((operation) => placesBlock(operation) && declinedAsRun.has(operation.id) || operation.type === "deleteTable" && !appliedById.has(operation.id) && besideDeletions.deleted.size > 0 ? [operation.id] : []));
|
|
3836
|
+
if (declinedLayoutChanges.size > 0 && batch.operations.some(({ type }) => type === "deleteBlock" || type === "mergeBlockWithNext")) {
|
|
3837
|
+
const rest = this.apply({
|
|
3838
|
+
...options,
|
|
3839
|
+
batch: {
|
|
3840
|
+
...batch,
|
|
3841
|
+
operations: batch.operations.filter(({ id }) => !declinedLayoutChanges.has(id))
|
|
3842
|
+
}
|
|
3843
|
+
});
|
|
3844
|
+
const declinedSkips = skipped.flatMap((failure) => {
|
|
3845
|
+
if (!declinedLayoutChanges.has(failure.id)) return [];
|
|
3846
|
+
const canonicalRefusal = refusals.get(failure.id);
|
|
3847
|
+
return [canonicalRefusal ? {
|
|
3848
|
+
...failure,
|
|
3849
|
+
canonicalRefusal
|
|
3850
|
+
} : failure];
|
|
3851
|
+
});
|
|
3852
|
+
const allSkipped = [...rest.skipped, ...declinedSkips].toSorted((left, right) => (inputOrder.get(left.id) ?? 0) - (inputOrder.get(right.id) ?? 0));
|
|
3853
|
+
return {
|
|
3854
|
+
...rest,
|
|
3855
|
+
skipped: allSkipped,
|
|
3856
|
+
issues: getFolioDocumentOperationIssues(batch.operations, allSkipped),
|
|
3857
|
+
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
3858
|
+
operations: batch.operations,
|
|
3859
|
+
applied: rest.applied,
|
|
3860
|
+
story: publicStory
|
|
3861
|
+
})
|
|
3862
|
+
};
|
|
3863
|
+
}
|
|
3706
3864
|
if (batch.atomic && skipped.length > 0) {
|
|
3707
3865
|
for (const { id } of appliedById.values()) skip(id, "atomicBatchRejected");
|
|
3708
3866
|
return result([], null);
|
|
@@ -3858,7 +4016,7 @@ var CanonicalPublicOperations = class {
|
|
|
3858
4016
|
* paragraph before it, whose mark then ends the list. Tracked, the text and
|
|
3859
4017
|
* the mark are marked deleted.
|
|
3860
4018
|
*/
|
|
3861
|
-
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, deletesJoinedWords, gainsFollower, followsInsertedTable, precedesInsertedTable,
|
|
4019
|
+
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, deletesJoinedWords, gainsFollower, keepsTablesApart, followsInsertedTable, precedesInsertedTable, bordersRemovedTable, previousGainsFollower, tableBeforeGainsFollower, endsOnceAccepted, deletedRun, deletedByBatch, refusal }) {
|
|
3862
4020
|
if (operation.comment !== void 0 && !tracked) return refusal("unsupportedBlock");
|
|
3863
4021
|
if (tracked && goesWholeOnAcceptance(paragraph.node)) return refusal("noopOperation");
|
|
3864
4022
|
const end = paragraph.start + paragraph.node.content.size;
|
|
@@ -3887,7 +4045,6 @@ var CanonicalPublicOperations = class {
|
|
|
3887
4045
|
},
|
|
3888
4046
|
...resolved
|
|
3889
4047
|
});
|
|
3890
|
-
const keepsTablesApart = after?.type.name === "table" && (before?.type.name === "table" || followsInsertedTable) && !precedesDeletedTable;
|
|
3891
4048
|
const joined = deletesJoinedWords ? joinedBefore(doc, paragraph.start - 1) : [];
|
|
3892
4049
|
const takesJoinedWords = deletesJoinedWords && !joined.some((id) => deletedByBatch.has(id));
|
|
3893
4050
|
const opening = takesJoinedWords ? joined.at(-1) : void 0;
|
|
@@ -3896,9 +4053,9 @@ var CanonicalPublicOperations = class {
|
|
|
3896
4053
|
paragraph.node.descendants((node) => {
|
|
3897
4054
|
if (node.isText && !node.marks.some(({ type }) => type.name === "insertion" || type.name === "deletion")) holdsOriginalWords = true;
|
|
3898
4055
|
});
|
|
3899
|
-
if (
|
|
4056
|
+
if (operation.moveId === void 0 && !gainsFollower && (keepsTablesApart || tracked && (after?.type.name === "table" || precedesInsertedTable) && isInsertedPPrMark(paragraph.node.attrs["pPrMark"]) && holdsOriginalWords)) {
|
|
3900
4057
|
if (paragraph.start === end) return refusal("noopOperation");
|
|
3901
|
-
const start = joinedWordsStart ?? paragraph.start;
|
|
4058
|
+
const start = keepsTablesApart ? paragraph.start : joinedWordsStart ?? paragraph.start;
|
|
3902
4059
|
const from = projection.addressAt(start);
|
|
3903
4060
|
const to = projection.addressAt(end);
|
|
3904
4061
|
if (from.isErr() || to.isErr()) return refusal("unsupportedBlock");
|
|
@@ -3911,7 +4068,8 @@ var CanonicalPublicOperations = class {
|
|
|
3911
4068
|
}],
|
|
3912
4069
|
normalizations: [],
|
|
3913
4070
|
from: start,
|
|
3914
|
-
to: end
|
|
4071
|
+
to: end,
|
|
4072
|
+
...keepsTablesApart ? { keepsTablesApart: true } : {}
|
|
3915
4073
|
});
|
|
3916
4074
|
}
|
|
3917
4075
|
const keepsSectionBreakBeforeBlock = tracked && after !== null && after.type.name !== "paragraph" && paragraph.node.attrs["_sectionProperties"] != null && previous !== void 0 && previous.node.attrs["_sectionProperties"] == null && operation.moveId === void 0 && !gainsFollower && !previousGainsFollower && noDeletedRunBefore(deletedRun);
|
|
@@ -3941,7 +4099,7 @@ var CanonicalPublicOperations = class {
|
|
|
3941
4099
|
}
|
|
3942
4100
|
let range;
|
|
3943
4101
|
if (!tracked) {
|
|
3944
|
-
if (after !== null && !followsInsertedTable && (before === null || (before.type.name === "paragraph" ||
|
|
4102
|
+
if (after !== null && !followsInsertedTable && (before === null || (before.type.name === "paragraph" || bordersRemovedTable) && paragraph.node.attrs["_sectionProperties"] == null)) return tracking({
|
|
3945
4103
|
intents: [{
|
|
3946
4104
|
type: "deleteParagraphs",
|
|
3947
4105
|
story: projectionStory,
|
|
@@ -4149,7 +4307,7 @@ var CanonicalPublicOperations = class {
|
|
|
4149
4307
|
default: return beside;
|
|
4150
4308
|
}
|
|
4151
4309
|
}
|
|
4152
|
-
resolveOperation({ operation, listStart, options, state, story, diff, tracked, suggested, mintList, besideDeletions }) {
|
|
4310
|
+
resolveOperation({ operation, listStart, options, state, story, diff, tracked, suggested, mintList, besideDeletions, batchComments }) {
|
|
4153
4311
|
const refusal = (reason, message) => Result.err(new CanonicalPublicOperationResolutionError({
|
|
4154
4312
|
reason,
|
|
4155
4313
|
message: message ?? `The operation was refused: ${reason}.`,
|
|
@@ -4222,7 +4380,37 @@ var CanonicalPublicOperations = class {
|
|
|
4222
4380
|
const hash = hashFolioAIBlockContent(clean.text);
|
|
4223
4381
|
if (operation.precondition && hash !== operation.precondition.blockTextHash) return refusal("preconditionFailed");
|
|
4224
4382
|
if (hash !== anchor.textHash) return refusal("changedBlock");
|
|
4225
|
-
const
|
|
4383
|
+
const blockAfter = state.doc.resolve(paragraph.start + paragraph.node.content.size + 1).nodeAfter;
|
|
4384
|
+
const followed = blockAfter?.type.name === "paragraph";
|
|
4385
|
+
const blockBefore = state.doc.resolve(paragraph.start - 1).nodeBefore;
|
|
4386
|
+
const previousId = blockBefore?.type.name === "paragraph" ? blockBefore.attrs["paraId"] : void 0;
|
|
4387
|
+
const batchRemovesTable = (block) => besideDeletions.tables.deleted.size > 0 && tableParagraphIds(block).some((id) => besideDeletions.tables.deleted.has(id));
|
|
4388
|
+
const tableWillBeRemoved = (block) => block.type.name === "table" && (tracked && tableGoes(block, "accept") || batchRemovesTable(block));
|
|
4389
|
+
const resolveDeletedPlacement = () => {
|
|
4390
|
+
let beforePos = paragraph.start - 1;
|
|
4391
|
+
let afterPos = beforePos + paragraph.node.nodeSize;
|
|
4392
|
+
let before = blockBefore;
|
|
4393
|
+
let after = blockAfter;
|
|
4394
|
+
while (before !== null && tableWillBeRemoved(before)) {
|
|
4395
|
+
beforePos -= before.nodeSize;
|
|
4396
|
+
before = state.doc.resolve(beforePos).nodeBefore;
|
|
4397
|
+
}
|
|
4398
|
+
while (after !== null && tableWillBeRemoved(after)) {
|
|
4399
|
+
const beyond = state.doc.resolve(afterPos + after.nodeSize).nodeAfter;
|
|
4400
|
+
if (!batchRemovesTable(after) && beyond?.type.name === "paragraph" && typeof beyond.attrs["paraId"] === "string" && besideDeletions.deleted.has(beyond.attrs["paraId"])) break;
|
|
4401
|
+
afterPos += after.nodeSize;
|
|
4402
|
+
after = beyond;
|
|
4403
|
+
}
|
|
4404
|
+
const precedingId = before?.type.name === "paragraph" ? before.attrs["paraId"] : void 0;
|
|
4405
|
+
return deletedParagraphPlacement({
|
|
4406
|
+
beside: besideDeletions.placedBeside(blockId),
|
|
4407
|
+
tableBefore: before?.type.name === "table" || typeof precedingId === "string" && lastPutAfterIsTable(besideDeletions.placedBeside(precedingId)),
|
|
4408
|
+
tableAfter: after?.type.name === "table",
|
|
4409
|
+
after: blockAfter
|
|
4410
|
+
});
|
|
4411
|
+
};
|
|
4412
|
+
const besideDeleted = besideDeletions.deleted.has(blockId) ? resolveDeletedPlacement() : void 0;
|
|
4413
|
+
const keepsTablesApart = besideDeleted?.type === "keepsTablesApart";
|
|
4226
4414
|
if (isTableStructureOperation(operation)) return resolveTableStructure({
|
|
4227
4415
|
operation,
|
|
4228
4416
|
paragraph,
|
|
@@ -4237,17 +4425,27 @@ var CanonicalPublicOperations = class {
|
|
|
4237
4425
|
deleted: besideDeletions.deleted,
|
|
4238
4426
|
template: options.tableTemplates?.get(operation.id)
|
|
4239
4427
|
});
|
|
4240
|
-
if (operation.type === "insertTable" || operation.type === "insertSignatureTable")
|
|
4241
|
-
operation
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4428
|
+
if (operation.type === "insertTable" || operation.type === "insertSignatureTable") {
|
|
4429
|
+
const besideDeletion = !tracked && listStart === void 0 && besideDeleted?.type === "placedAfter" && besideDeleted.operationIds.has(operation.id);
|
|
4430
|
+
const inserted = resolveTableInsertion({
|
|
4431
|
+
operation: besideDeletion ? {
|
|
4432
|
+
...operation,
|
|
4433
|
+
position: "after"
|
|
4434
|
+
} : operation,
|
|
4435
|
+
...listStart === void 0 ? {} : { listStart },
|
|
4436
|
+
paragraph,
|
|
4437
|
+
projection: projection.value,
|
|
4438
|
+
story,
|
|
4439
|
+
noteReferences,
|
|
4440
|
+
refusal,
|
|
4441
|
+
skipAlike,
|
|
4442
|
+
template: options.tableTemplates?.get(operation.id)
|
|
4443
|
+
});
|
|
4444
|
+
return besideDeletion && inserted.isOk() ? Result.ok({
|
|
4445
|
+
...inserted.value,
|
|
4446
|
+
besideDeletion: true
|
|
4447
|
+
}) : inserted;
|
|
4448
|
+
}
|
|
4251
4449
|
if (isBlockInsertion(operation) && listStart !== void 0) return resolveBlockInsertion({
|
|
4252
4450
|
operation,
|
|
4253
4451
|
listStart,
|
|
@@ -4262,9 +4460,8 @@ var CanonicalPublicOperations = class {
|
|
|
4262
4460
|
skipAlike
|
|
4263
4461
|
});
|
|
4264
4462
|
if (isBlockInsertion(operation)) {
|
|
4265
|
-
const besideDeletion = !tracked && operation.type === "insertBeforeBlock" && !followed && besideDeletions.deleted.has(blockId);
|
|
4266
|
-
const
|
|
4267
|
-
const insertion = besideDeletion && after !== null ? {
|
|
4463
|
+
const besideDeletion = !tracked && operation.type === "insertBeforeBlock" && !followed && besideDeletions.deleted.has(blockId) && !keepsTablesApart;
|
|
4464
|
+
const insertion = besideDeletion && blockAfter !== null ? {
|
|
4268
4465
|
...operation,
|
|
4269
4466
|
type: "insertAfterBlock"
|
|
4270
4467
|
} : operation;
|
|
@@ -4311,12 +4508,11 @@ var CanonicalPublicOperations = class {
|
|
|
4311
4508
|
refusal
|
|
4312
4509
|
});
|
|
4313
4510
|
if (operation.type === "deleteBlock") {
|
|
4314
|
-
const gainsFollower = !followed && besideDeletions.insertedBeside.has(blockId);
|
|
4315
|
-
const before =
|
|
4316
|
-
const after =
|
|
4511
|
+
const gainsFollower = !followed && besideDeletions.insertedBeside.has(blockId) && !keepsTablesApart;
|
|
4512
|
+
const before = blockBefore;
|
|
4513
|
+
const after = blockAfter;
|
|
4317
4514
|
const endsOnceAccepted = tracked && operation.moveId === void 0 && followersGoOnAcceptance(state.doc, paragraph.start + paragraph.node.content.size + 1);
|
|
4318
|
-
const
|
|
4319
|
-
const followsInsertedTable = !followed && (besideDeletions.tables.before.has(blockId) || typeof previousId === "string" && besideDeletions.tables.after.has(previousId));
|
|
4515
|
+
const followsInsertedTable = keepsTablesApart || !followed && (besideDeletions.tables.before.has(blockId) || typeof previousId === "string" && besideDeletions.tables.after.has(previousId));
|
|
4320
4516
|
const tableBeforeGainsFollower = !followed && before !== null && before.type.name !== "paragraph" && paragraphIdsIn(before).some((id) => besideDeletions.paragraphsAfter.has(id));
|
|
4321
4517
|
const deleted = this.resolveBlockDeletion({
|
|
4322
4518
|
operation,
|
|
@@ -4325,11 +4521,12 @@ var CanonicalPublicOperations = class {
|
|
|
4325
4521
|
projectionStory: story,
|
|
4326
4522
|
doc: state.doc,
|
|
4327
4523
|
tracked,
|
|
4328
|
-
deletesJoinedWords:
|
|
4524
|
+
deletesJoinedWords: deletionTakesJoinedWords(options.batch.mode ?? "tracked-changes"),
|
|
4329
4525
|
gainsFollower,
|
|
4526
|
+
keepsTablesApart,
|
|
4330
4527
|
followsInsertedTable,
|
|
4331
4528
|
precedesInsertedTable: besideDeletions.tables.after.has(blockId) && !besideDeletions.paragraphsAfter.has(blockId),
|
|
4332
|
-
|
|
4529
|
+
bordersRemovedTable: before !== null && tableWillBeRemoved(before) || after !== null && tableWillBeRemoved(after),
|
|
4333
4530
|
previousGainsFollower: (!followed || endsOnceAccepted) && typeof previousId === "string" && (besideDeletions.paragraphsAfter.has(previousId) || besideDeletions.deleted.has(previousId)),
|
|
4334
4531
|
tableBeforeGainsFollower,
|
|
4335
4532
|
endsOnceAccepted,
|
|
@@ -4430,13 +4627,16 @@ var CanonicalPublicOperations = class {
|
|
|
4430
4627
|
from: from.value,
|
|
4431
4628
|
to: to.value
|
|
4432
4629
|
});
|
|
4433
|
-
if (operation.type === "commentOnBlock" || operation.type === "commentOnRange")
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4630
|
+
if (operation.type === "commentOnBlock" || operation.type === "commentOnRange") {
|
|
4631
|
+
if (options.batch.mode === "suggested" && start === end) return refusal("emptyOperation", "A proposed comment needs words of the paragraph to cover.");
|
|
4632
|
+
return Result.ok({
|
|
4633
|
+
...resolvedComment,
|
|
4634
|
+
intents: [],
|
|
4635
|
+
normalizations: [],
|
|
4636
|
+
from: range.from,
|
|
4637
|
+
to: range.to
|
|
4638
|
+
});
|
|
4639
|
+
}
|
|
4440
4640
|
const restyle = restyles && operation.type === "replaceBlock" && operation.styleId !== void 0 ? statedPropertiesIntents({
|
|
4441
4641
|
story,
|
|
4442
4642
|
blockId: paragraph.blockId,
|
|
@@ -4532,10 +4732,18 @@ var CanonicalPublicOperations = class {
|
|
|
4532
4732
|
planChanges: tracked ? (source, target) => changesFromSegments(diff(source, target)) : planTextChanges,
|
|
4533
4733
|
...tracked ? { keepFieldsOf: planTextChanges } : {}
|
|
4534
4734
|
});
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4735
|
+
const addedComments = tracked ? batchCommentSpans(batchComments, blockId, clean.text) : [];
|
|
4736
|
+
const changesCommentedWords = (changes) => changes?.some((change) => clean.offsets.slice(start + change.start, start + change.end).some((position) => paragraph.node.nodeAt(position - paragraph.start)?.marks.some((mark) => mark.type.name === "comment")) || change.end > change.start && addedComments.some((span) => span.start < start + change.end && start + change.start < span.end)) === true;
|
|
4737
|
+
if (tracked && changesCommentedWords([{
|
|
4738
|
+
start: 0,
|
|
4739
|
+
end: end - start
|
|
4740
|
+
}])) {
|
|
4741
|
+
const directCuts = planReplacementChanges({
|
|
4742
|
+
...replacementSource,
|
|
4743
|
+
planChanges: planTextChanges
|
|
4744
|
+
});
|
|
4745
|
+
if (changesCommentedWords(planned) || changesCommentedWords(directCuts)) planned = directCuts;
|
|
4746
|
+
}
|
|
4539
4747
|
if (planned === null) return panic("A replacement's planned changes must reproduce it.");
|
|
4540
4748
|
const changes = cutAroundRepeatedSeparators(replacementSource.source, planned).map((change) => ({
|
|
4541
4749
|
start: start + change.start,
|
|
@@ -4745,8 +4953,7 @@ var CanonicalPublicOperations = class {
|
|
|
4745
4953
|
}
|
|
4746
4954
|
intents.push(...restyle);
|
|
4747
4955
|
} else if (operation.type === "mergeBlockWithNext" && intent.type === "joinParagraphs") {
|
|
4748
|
-
const
|
|
4749
|
-
const separator = followedOnlyByDeletedParagraphs(projection.value.doc, paragraph.start - 1 + paragraph.node.nodeSize, vanishing) ? "" : operation.separator ?? "";
|
|
4956
|
+
const separator = operation.separator ?? "";
|
|
4750
4957
|
if (separator !== "") {
|
|
4751
4958
|
const at = projection.value.addressAt(paragraph.start + paragraph.node.content.size);
|
|
4752
4959
|
if (at.isErr()) return refusal("unsupportedBlock");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { panic } from "better-result";
|
|
2
|
-
import { CellSelection } from "prosemirror-tables";
|
|
3
2
|
import { AllSelection, NodeSelection, TextSelection } from "prosemirror-state";
|
|
3
|
+
import { CellSelection } from "prosemirror-tables";
|
|
4
4
|
// src/canonical/canonicalSelection.ts
|
|
5
5
|
/** Restore the admitted selection kind after a canonical projection changes. */
|
|
6
6
|
const restoreCanonicalSelection = ({ transaction, projection, selection, unavailable }) => {
|