@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
package/dist/ai-edits/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FolioContentParagraphKind } from "../compare/content-types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationBatchInput, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationResultBase, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "../document-operations.js";
|
|
3
3
|
import { getFolioParaIdFromBlockId } from "../types/block-id.js";
|
|
4
|
-
import { FolioAIEditApplyOutcome, FolioAIEditView, FolioRevisionStamp, FolioWordDiffOptions
|
|
4
|
+
import { FolioAIEditApplyOutcome, FolioAIEditView, FolioRevisionStamp, FolioWordDiffOptions } from "./applyTypes.js";
|
|
5
5
|
import { DocPositionRange, clampRangeToDocSize, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange } from "./blockRange.js";
|
|
6
6
|
import { buildAnnotatedBlockText } from "./clean-text.js";
|
|
7
7
|
import { FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioApplyDocumentOperationsToStoryOptions, FolioDocumentStory, FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, FolioEditableDocumentStoryHandle, FolioReadReviewedStoryOptions, FolioResolveReviewedStoryOptions, FolioResolvedReviewedView, FolioReviewedStory, FolioReviewedView, UnsupportedFolioReviewedViewError, isFolioResolvedReviewedView, isFolioReviewedView } from "./headless.js";
|
|
@@ -13,4 +13,4 @@ import { createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver,
|
|
|
13
13
|
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIBlockStructuralBoundary, FolioAIBlockTableLocation, FolioAIComment, FolioAIDiagnosticBlock, FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditNormalization, FolioAIEditNormalizationCode, FolioAIEditOperation, FolioAIEditParagraphIdentity, FolioAIEditPrecondition, FolioAIEditReviewMeta, FolioAIEditSeverity, FolioAIEditSkipReason, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAIInlineBooleanProperty, FolioAIInlineFormatting, FolioAIInlineFormattingPatch, FolioAIInsertFormattingScope, FolioAIParagraphBlock, FolioAIParagraphSpacing, FolioAISignatureParty, FolioAITextRangeHandle, FolioDocumentNavigationTarget, FolioDocumentOutline, FolioDocumentOutlineEntry, FolioDocumentSection, FolioDocumentSectionHandle, FolioDocumentSectionReadResult } from "./types.js";
|
|
14
14
|
import { FolioUndefinedReferencePolicy } from "./undefinedReferences.js";
|
|
15
15
|
import { WORD_DIFF_GRANULARITIES, WordDiffGranularity, WordDiffNormalization, WordDiffOptions, WordDiffSegment, diffWordSegments } from "./word-diff.js";
|
|
16
|
-
export { type
|
|
16
|
+
export { type DocPositionRange, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_PENDING_SUGGESTION_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIBlockTableLocation, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditAppliedOperation, type FolioAIEditApplyMode, type FolioAIEditApplyOutcome, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditParagraphIdentity, type FolioAIEditPrecondition, type FolioAIEditReviewMeta, type FolioAIEditSeverity, type FolioAIEditSkipReason, type FolioAIEditSkippedOperation, type FolioAIEditSnapshot, type FolioAIEditView, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIInsertFormattingScope, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAISignatureParty, type FolioAITextRangeHandle, type FolioAbsorbedBlock, type FolioApplyDocumentOperationsToStoryOptions, type FolioCommentAnchor, type FolioContentParagraphKind, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchInput, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioEditableDocumentStoryHandle, type FolioPendingSuggestionLoadResult, type FolioPendingSuggestionRecord, FolioPendingSuggestionRegistry, type FolioPendingSuggestionStaleReason, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeKind, type FolioReviewResolution, type FolioReviewResolutionSkip, type FolioReviewedStory, type FolioReviewedView, type FolioRevisionStamp, type FolioUndefinedReferencePolicy, type FolioWordDiffOptions, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, WORD_DIFF_GRANULARITIES, type WordDiffGranularity, type WordDiffNormalization, type WordDiffOptions, type WordDiffSegment, assertSupportedFolioDocumentOperationVersion, buildAnnotatedBlockText, clampRangeToDocSize, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, createPendingSuggestionSourceSnapshot, diffWordSegments, getCommentAnchorsFromDoc, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedChangesFromDoc, hashFolioAIBlockText, isFolioAIContentBlock, isFolioDocumentOperationModeSupported, isFolioResolvedReviewedView, isFolioReviewedView, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, readFolioDocumentSection, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange };
|
package/dist/ai-edits/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError,
|
|
1
|
+
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "../document-operations.js";
|
|
2
2
|
import { getFolioParaIdFromBlockId } from "../types/block-id.js";
|
|
3
|
-
import { applyFolioAIEditOperations } from "./apply.js";
|
|
4
3
|
import { clampRangeToDocSize, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange } from "./blockRange.js";
|
|
5
4
|
import { buildAnnotatedBlockText } from "./clean-text.js";
|
|
6
5
|
import { FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, UnsupportedFolioReviewedViewError, isFolioResolvedReviewedView, isFolioReviewedView } from "./headless.js";
|
|
@@ -10,4 +9,4 @@ import { getFolioDocumentOperationRemovedBlockIds } from "./removed-blocks.js";
|
|
|
10
9
|
import { getFolioDocumentOutline, readFolioDocumentSection } from "./scoped-reading.js";
|
|
11
10
|
import { createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, hashFolioAIBlockText, isFolioAIContentBlock, normalizeFolioAIBlockText } from "./snapshot.js";
|
|
12
11
|
import { WORD_DIFF_GRANULARITIES, diffWordSegments } from "./word-diff.js";
|
|
13
|
-
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_PENDING_SUGGESTION_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, FolioPendingSuggestionRegistry, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, WORD_DIFF_GRANULARITIES,
|
|
12
|
+
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_PENDING_SUGGESTION_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FolioDocumentStoryNotFoundError, FolioPendingSuggestionRegistry, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioReviewedViewError, WORD_DIFF_GRANULARITIES, assertSupportedFolioDocumentOperationVersion, buildAnnotatedBlockText, clampRangeToDocSize, createFolioAIEditSnapshot, createFolioAIEditSnapshotWithStyleResolver, createFolioAITextRangeHandle, createPendingSuggestionSourceSnapshot, diffWordSegments, getCommentAnchorsFromDoc, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedChangesFromDoc, hashFolioAIBlockText, isFolioAIContentBlock, isFolioDocumentOperationModeSupported, isFolioResolvedReviewedView, isFolioReviewedView, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, readFolioDocumentSection, resolveFolioAIBlockRange, resolveFolioAITextRange, resolvePassageRange };
|
|
@@ -20,8 +20,15 @@ export type FolioPendingSuggestionRecord = {
|
|
|
20
20
|
provenance: "suggested";
|
|
21
21
|
sourceDocumentFingerprint: string;
|
|
22
22
|
commentId?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Set when the record no longer restages: a review resolution removed the
|
|
25
|
+
* paragraph it names, and no paragraph a save holds keeps the suggestion's
|
|
26
|
+
* words or place. The suggestion stays pending in this session; loading the
|
|
27
|
+
* record reports it stale with this reason.
|
|
28
|
+
*/
|
|
29
|
+
retired?: "anchorRemoved";
|
|
23
30
|
};
|
|
24
|
-
export type FolioPendingSuggestionStaleReason = "missingAnchor" | "ambiguousAnchor" | "textChanged" | "unsupportedVersion" | "documentChanged" | "invalidRecord" | "applyFailed";
|
|
31
|
+
export type FolioPendingSuggestionStaleReason = "anchorRemoved" | "missingAnchor" | "ambiguousAnchor" | "textChanged" | "unsupportedVersion" | "documentChanged" | "invalidRecord" | "applyFailed";
|
|
25
32
|
export type FolioPendingSuggestionLoadResult = {
|
|
26
33
|
status: "restaged";
|
|
27
34
|
suggestionId: string;
|
|
@@ -92,9 +99,12 @@ export declare class FolioPendingSuggestionRegistry {
|
|
|
92
99
|
suggestionIds(): Set<string>;
|
|
93
100
|
/**
|
|
94
101
|
* Anchor every live record whose paragraph is gone from its story, a
|
|
95
|
-
* resolution or an edit having removed it,
|
|
96
|
-
* suggestion
|
|
97
|
-
*
|
|
102
|
+
* resolution or an edit having removed it, where a save keeps its
|
|
103
|
+
* suggestion: a split at its own paragraph mark, text proposals over the
|
|
104
|
+
* saved words their marks cover, and block insertions beside the
|
|
105
|
+
* paragraphs they add ({@link placedRecord}). A record none of these
|
|
106
|
+
* places is retired ({@link retiredRecord}): no record restages on a
|
|
107
|
+
* removed or absorbed paragraph. Run after the change publishes.
|
|
98
108
|
*/
|
|
99
109
|
placeRemovedAnchors({ activeSuggestionIds, stateForStory, savedSource }: PlaceRemovedAnchorsOptions): void;
|
|
100
110
|
/**
|
|
@@ -129,33 +129,78 @@ const containerKey = ({ containerPath = [], table }) => canonicalJson({
|
|
|
129
129
|
]
|
|
130
130
|
});
|
|
131
131
|
const suggestionSnapshot = (state) => createFolioAIEditSnapshotWithStyleResolver(state.doc, getDocumentStyleResolver(state));
|
|
132
|
-
/**
|
|
133
|
-
const
|
|
132
|
+
/** `rejected` read as a snapshot, its paragraphs in the order a save lists them. */
|
|
133
|
+
const settledSnapshot = ({ state }) => createFolioAIEditSnapshotWithStyleResolver(state.doc, getDocumentStyleResolver(state));
|
|
134
|
+
/**
|
|
135
|
+
* The paragraph at `paragraphStart` of the rejected story, as a save names
|
|
136
|
+
* it: the saved package may name the paragraphs otherwise, and both read
|
|
137
|
+
* alike. `null` when the save reads other text there.
|
|
138
|
+
*/
|
|
139
|
+
const savedParagraphAt = ({ rejected, settled, saved, paragraphStart }) => {
|
|
140
|
+
const paragraph = rejected.state.doc.nodeAt(paragraphStart);
|
|
141
|
+
const index = settled.blocks.findIndex(({ id }) => settled.anchors[id]?.from === paragraphStart);
|
|
142
|
+
const block = index < 0 ? void 0 : saved.blocks[index];
|
|
143
|
+
const anchor = block === void 0 ? void 0 : saved.anchors[block.id];
|
|
144
|
+
if (paragraph === null || block === void 0 || anchor === void 0) return null;
|
|
145
|
+
const clean = buildCleanBlockText(paragraph, paragraphStart, { fieldResults: "text" });
|
|
146
|
+
if (anchor.text !== clean.text) return null;
|
|
147
|
+
return {
|
|
148
|
+
block,
|
|
149
|
+
anchor,
|
|
150
|
+
offsetAt: (position) => {
|
|
151
|
+
const offset = clean.offsets.findIndex((at) => at >= position);
|
|
152
|
+
return offset < 0 ? clean.text.length : offset;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* A split follows its own paragraph mark as edits move it through the story.
|
|
158
|
+
* It stands at the end of the paragraph that mark closes, which a save reads
|
|
159
|
+
* inside the paragraph the split joins back into; words other proposals show
|
|
160
|
+
* there are no saved text, so the offset counts only what a save holds.
|
|
161
|
+
* `null` when the mark is gone, or stands in no saved paragraph or at its
|
|
162
|
+
* edge.
|
|
163
|
+
*/
|
|
164
|
+
const currentSplitRecord = ({ record, state, saved }) => {
|
|
134
165
|
const { operation, suggestionId, splitRevisionId } = record;
|
|
135
166
|
if (operation.type !== "splitBlock" || splitRevisionId === void 0) return null;
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
const mark = expectParagraphAttrs(
|
|
141
|
-
if (mark?.kind
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
167
|
+
const ends = [];
|
|
168
|
+
state.doc.descendants((node, position) => {
|
|
169
|
+
if (ends.length > 0) return false;
|
|
170
|
+
if (node.type.name !== "paragraph") return true;
|
|
171
|
+
const mark = expectParagraphAttrs(node).pPrMark;
|
|
172
|
+
if (mark?.kind === "ins" && mark.info.id === splitRevisionId && mark.info.suggestionId === suggestionId) ends.push(position + node.nodeSize - 1);
|
|
173
|
+
return false;
|
|
174
|
+
});
|
|
175
|
+
const end = ends.at(0);
|
|
176
|
+
if (end === void 0) return null;
|
|
177
|
+
const rejected = rejectEverySuggestionMapped(state);
|
|
178
|
+
const at = rejected.mapping.map(end, -1);
|
|
179
|
+
const $at = rejected.state.doc.resolve(at);
|
|
180
|
+
if ($at.parent.type.name !== "paragraph") return null;
|
|
181
|
+
const paragraph = savedParagraphAt({
|
|
182
|
+
rejected,
|
|
183
|
+
settled: settledSnapshot(rejected),
|
|
184
|
+
saved,
|
|
185
|
+
paragraphStart: $at.before()
|
|
186
|
+
});
|
|
187
|
+
if (paragraph === null) return null;
|
|
188
|
+
const { block, anchor, offsetAt } = paragraph;
|
|
189
|
+
const offset = offsetAt(at);
|
|
190
|
+
if (offset === 0 || offset >= anchor.text.length) return null;
|
|
191
|
+
return {
|
|
192
|
+
...record,
|
|
193
|
+
operation: {
|
|
194
|
+
...operation,
|
|
195
|
+
blockId: block.id,
|
|
196
|
+
offset
|
|
197
|
+
},
|
|
198
|
+
anchor: {
|
|
199
|
+
blockId: block.id,
|
|
200
|
+
paraId: getFolioParaIdFromBlockId(block.id),
|
|
201
|
+
originalTextHash: anchor.textHash
|
|
202
|
+
}
|
|
203
|
+
};
|
|
159
204
|
};
|
|
160
205
|
/** `record` as the text replacement of `from` to `to` in a saved block. */
|
|
161
206
|
const rangeProposal = ({ record, blockId, saved: { text, textHash }, from, to, replace, id, comment }) => {
|
|
@@ -271,7 +316,7 @@ const currentTextRecords = ({ records, state, saved }) => {
|
|
|
271
316
|
});
|
|
272
317
|
else span.last = index;
|
|
273
318
|
}
|
|
274
|
-
const settled =
|
|
319
|
+
const settled = settledSnapshot(rejected);
|
|
275
320
|
const ids = records.map(({ operation }) => operation.id);
|
|
276
321
|
const nextId = (position) => {
|
|
277
322
|
const known = ids[position];
|
|
@@ -284,19 +329,16 @@ const currentTextRecords = ({ records, state, saved }) => {
|
|
|
284
329
|
};
|
|
285
330
|
const current = [];
|
|
286
331
|
for (const [paragraphStart, { first, last }] of spans) {
|
|
287
|
-
const paragraph = rejected.state.doc.nodeAt(paragraphStart);
|
|
288
332
|
const start = pieces[first];
|
|
289
333
|
const end = pieces[last];
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return offset < 0 ? clean.text.length : offset;
|
|
299
|
-
};
|
|
334
|
+
const paragraph = savedParagraphAt({
|
|
335
|
+
rejected,
|
|
336
|
+
settled,
|
|
337
|
+
saved,
|
|
338
|
+
paragraphStart
|
|
339
|
+
});
|
|
340
|
+
if (start === void 0 || end === void 0 || paragraph === null) return null;
|
|
341
|
+
const { block, anchor, offsetAt } = paragraph;
|
|
300
342
|
const from = offsetAt(savedStart(start));
|
|
301
343
|
const to = Math.max(from, offsetAt(rejected.mapping.map(end.to, -1)));
|
|
302
344
|
let replace = "";
|
|
@@ -328,50 +370,69 @@ const currentTextRecords = ({ records, state, saved }) => {
|
|
|
328
370
|
};
|
|
329
371
|
/**
|
|
330
372
|
* `record`, a block insertion whose anchor paragraph is gone, anchored where
|
|
331
|
-
* its paragraphs stand
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
373
|
+
* its paragraphs stand, using a saved neighbour on the same side of other
|
|
374
|
+
* pending insertions when possible. `null` for a record of another
|
|
375
|
+
* kind, whose words a save does not hold once its paragraph is gone, and
|
|
376
|
+
* for an insertion with no paragraph of its own or no saved one beside it.
|
|
335
377
|
*/
|
|
336
378
|
const placedRecord = ({ record, live, saved, ranges }) => {
|
|
337
|
-
const { operation
|
|
338
|
-
if (operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock") return
|
|
339
|
-
suggestionId,
|
|
340
|
-
type: operation.type
|
|
341
|
-
});
|
|
379
|
+
const { operation } = record;
|
|
380
|
+
if (operation.type !== "insertAfterBlock" && operation.type !== "insertBeforeBlock") return null;
|
|
342
381
|
const savedIds = new Set(saved.blocks.map(({ id }) => id));
|
|
343
|
-
const
|
|
382
|
+
const isOwn = ({ id }) => {
|
|
344
383
|
const anchor = live.anchors[id];
|
|
345
|
-
|
|
346
|
-
|
|
384
|
+
if (anchor === void 0) return false;
|
|
385
|
+
return savedIds.has(id) ? ranges.some(({ from, to }) => from <= anchor.from + 1 && anchor.to - 1 <= to) : ranges.some(({ from, to }) => from < anchor.to && anchor.from < to);
|
|
386
|
+
};
|
|
387
|
+
const index = live.blocks.findIndex(isOwn);
|
|
347
388
|
const placed = live.blocks.at(index);
|
|
348
|
-
if (index < 0 || placed === void 0) return
|
|
389
|
+
if (index < 0 || placed === void 0) return null;
|
|
349
390
|
const container = containerKey(placed);
|
|
350
391
|
const besideIn = (step) => {
|
|
392
|
+
let crossesProposal = false;
|
|
351
393
|
for (let at = index + step; at >= 0 && at < live.blocks.length; at += step) {
|
|
352
394
|
const block = live.blocks.at(at);
|
|
353
|
-
if (block === void 0 ||
|
|
354
|
-
|
|
395
|
+
if (block === void 0 || containerKey(block) !== container) break;
|
|
396
|
+
if (isOwn(block)) continue;
|
|
397
|
+
if (savedIds.has(block.id)) return {
|
|
398
|
+
block,
|
|
399
|
+
crossesProposal
|
|
400
|
+
};
|
|
401
|
+
crossesProposal = true;
|
|
355
402
|
}
|
|
356
403
|
};
|
|
357
404
|
const next = besideIn(1);
|
|
358
|
-
const
|
|
405
|
+
const previous = besideIn(-1);
|
|
406
|
+
const before = next !== void 0 && (!next.crossesProposal || previous?.crossesProposal !== false);
|
|
407
|
+
const neighbour = before ? next.block : previous?.block;
|
|
359
408
|
const anchor = neighbour === void 0 ? void 0 : saved.anchors[neighbour.id];
|
|
360
|
-
if (neighbour === void 0 || anchor === void 0) return
|
|
409
|
+
if (neighbour === void 0 || anchor === void 0) return null;
|
|
361
410
|
return {
|
|
362
411
|
...record,
|
|
363
412
|
operation: {
|
|
364
413
|
...operation,
|
|
365
|
-
type:
|
|
366
|
-
blockId: neighbour.id
|
|
414
|
+
type: before ? "insertBeforeBlock" : "insertAfterBlock",
|
|
415
|
+
blockId: neighbour.id,
|
|
416
|
+
...operation.precondition !== void 0 && { precondition: { blockTextHash: anchor.textHash } }
|
|
367
417
|
},
|
|
368
418
|
anchor: {
|
|
369
419
|
blockId: neighbour.id,
|
|
370
|
-
paraId: neighbour.id,
|
|
420
|
+
paraId: getFolioParaIdFromBlockId(neighbour.id),
|
|
371
421
|
originalTextHash: anchor.textHash
|
|
372
422
|
}
|
|
373
423
|
};
|
|
374
424
|
};
|
|
425
|
+
/**
|
|
426
|
+
* `record` once nothing a save holds keeps its words or place: it keeps the
|
|
427
|
+
* anchor it had, for the host to read, and restages nowhere.
|
|
428
|
+
*/
|
|
429
|
+
const retiredRecord = (record) => {
|
|
430
|
+
const { splitRevisionId: _, ...rest } = record;
|
|
431
|
+
return {
|
|
432
|
+
...rest,
|
|
433
|
+
retired: "anchorRemoved"
|
|
434
|
+
};
|
|
435
|
+
};
|
|
375
436
|
const storyFromUnknown = (value) => {
|
|
376
437
|
if (!isObject(value)) return null;
|
|
377
438
|
switch (value["type"]) {
|
|
@@ -403,11 +464,21 @@ const recordKey = (record) => canonicalJson([
|
|
|
403
464
|
record.suggestionId,
|
|
404
465
|
record.operation.id
|
|
405
466
|
]);
|
|
467
|
+
/** A persisted `retired` field: `undefined` when absent, `null` when invalid. */
|
|
468
|
+
const retirementFromUnknown = (value) => {
|
|
469
|
+
switch (value) {
|
|
470
|
+
case void 0: return;
|
|
471
|
+
case "anchorRemoved": return "anchorRemoved";
|
|
472
|
+
default: return null;
|
|
473
|
+
}
|
|
474
|
+
};
|
|
406
475
|
const parseRecord = (value) => {
|
|
407
476
|
if (!isObject(value) || !isObject(value["anchor"])) return null;
|
|
408
477
|
const story = storyFromUnknown(value["story"]);
|
|
409
478
|
const anchor = value["anchor"];
|
|
410
479
|
if (story === null || typeof value["suggestionId"] !== "string" || typeof value["author"] !== "string" || value["provenance"] !== "suggested" || typeof value["sourceDocumentFingerprint"] !== "string" || value["commentId"] !== void 0 && (typeof value["commentId"] !== "number" || !Number.isSafeInteger(value["commentId"])) || typeof anchor["blockId"] !== "string" || anchor["paraId"] !== null && typeof anchor["paraId"] !== "string" || typeof anchor["originalTextHash"] !== "string") return null;
|
|
480
|
+
const retired = retirementFromUnknown(value["retired"]);
|
|
481
|
+
if (retired === null) return null;
|
|
411
482
|
let operation;
|
|
412
483
|
try {
|
|
413
484
|
const parsed = parseFolioDocumentOperationBatch({
|
|
@@ -440,7 +511,8 @@ const parseRecord = (value) => {
|
|
|
440
511
|
author: value["author"],
|
|
441
512
|
provenance: "suggested",
|
|
442
513
|
sourceDocumentFingerprint: value["sourceDocumentFingerprint"],
|
|
443
|
-
...typeof value["commentId"] === "number" && Number.isSafeInteger(value["commentId"]) && { commentId: value["commentId"] }
|
|
514
|
+
...typeof value["commentId"] === "number" && Number.isSafeInteger(value["commentId"]) && { commentId: value["commentId"] },
|
|
515
|
+
...retired !== void 0 && { retired }
|
|
444
516
|
};
|
|
445
517
|
};
|
|
446
518
|
/** Tracks only operations that successfully staged in `suggested` mode. */
|
|
@@ -464,15 +536,18 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
464
536
|
}
|
|
465
537
|
/**
|
|
466
538
|
* Anchor every live record whose paragraph is gone from its story, a
|
|
467
|
-
* resolution or an edit having removed it,
|
|
468
|
-
* suggestion
|
|
469
|
-
*
|
|
539
|
+
* resolution or an edit having removed it, where a save keeps its
|
|
540
|
+
* suggestion: a split at its own paragraph mark, text proposals over the
|
|
541
|
+
* saved words their marks cover, and block insertions beside the
|
|
542
|
+
* paragraphs they add ({@link placedRecord}). A record none of these
|
|
543
|
+
* places is retired ({@link retiredRecord}): no record restages on a
|
|
544
|
+
* removed or absorbed paragraph. Run after the change publishes.
|
|
470
545
|
*/
|
|
471
546
|
placeRemovedAnchors({ activeSuggestionIds, stateForStory, savedSource }) {
|
|
472
547
|
const views = /* @__PURE__ */ new Map();
|
|
473
548
|
for (const [key, record] of Array.from(this.records)) {
|
|
474
549
|
const { suggestionId, story, anchor } = record;
|
|
475
|
-
if (this.records.get(key) !== record || !activeSuggestionIds.has(suggestionId) || anchor.paraId === null) continue;
|
|
550
|
+
if (this.records.get(key) !== record || !activeSuggestionIds.has(suggestionId) || anchor.paraId === null || record.retired !== void 0) continue;
|
|
476
551
|
const storyKey = canonicalJson(story);
|
|
477
552
|
let view = views.get(storyKey);
|
|
478
553
|
if (view === void 0) {
|
|
@@ -484,11 +559,12 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
484
559
|
views.set(storyKey, view);
|
|
485
560
|
}
|
|
486
561
|
if (view === null || view.live.anchors[anchor.paraId] !== void 0) continue;
|
|
487
|
-
|
|
488
|
-
|
|
562
|
+
if (view.saved === void 0) view.saved = savedSource?.(story) ?? null;
|
|
563
|
+
const saved = view.saved;
|
|
564
|
+
if (saved !== null && (record.splitRevisionId !== void 0 || proposesText(record.operation))) {
|
|
489
565
|
const split = currentSplitRecord({
|
|
490
566
|
record,
|
|
491
|
-
|
|
567
|
+
state: view.state,
|
|
492
568
|
saved
|
|
493
569
|
});
|
|
494
570
|
if (split !== null) {
|
|
@@ -508,12 +584,13 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
508
584
|
}
|
|
509
585
|
}
|
|
510
586
|
const ranges = getSuggestions(view.state).find((entry) => entry.suggestionId === suggestionId)?.ranges ?? [];
|
|
511
|
-
|
|
587
|
+
const placed = placedRecord({
|
|
512
588
|
record,
|
|
513
589
|
live: view.live,
|
|
514
|
-
saved: createPendingSuggestionSourceSnapshot(view.state, /* @__PURE__ */ new Set()),
|
|
590
|
+
saved: saved ?? createPendingSuggestionSourceSnapshot(view.state, /* @__PURE__ */ new Set()),
|
|
515
591
|
ranges
|
|
516
|
-
})
|
|
592
|
+
});
|
|
593
|
+
this.records.set(key, placed ?? retiredRecord(record));
|
|
517
594
|
}
|
|
518
595
|
}
|
|
519
596
|
/**
|
|
@@ -530,7 +607,7 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
530
607
|
*/
|
|
531
608
|
prepareAbsorption({ survivors, activeSuggestionIds, sourceSnapshotForStory }) {
|
|
532
609
|
const absorbing = new Set([...survivors.keys()].map((paraId) => finalSurvivor(survivors, paraId)));
|
|
533
|
-
const affected = [...this.records].filter(([, { suggestionId, anchor }]) => activeSuggestionIds.has(suggestionId) && anchor.paraId !== null && (survivors.has(anchor.paraId) || absorbing.has(anchor.paraId)));
|
|
610
|
+
const affected = [...this.records].filter(([, { suggestionId, anchor, retired }]) => activeSuggestionIds.has(suggestionId) && retired === void 0 && anchor.paraId !== null && (survivors.has(anchor.paraId) || absorbing.has(anchor.paraId)));
|
|
534
611
|
if (affected.length === 0) return null;
|
|
535
612
|
const before = /* @__PURE__ */ new Map();
|
|
536
613
|
for (const [, { story }] of affected) {
|
|
@@ -625,29 +702,40 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
625
702
|
commentIds.add(record.commentId);
|
|
626
703
|
commentIdsByStory.set(storyKey, commentIds);
|
|
627
704
|
}
|
|
705
|
+
const savedStoryOf = (story) => {
|
|
706
|
+
const storyKey = canonicalJson(story);
|
|
707
|
+
const cached = savedStories.get(storyKey);
|
|
708
|
+
if (cached !== void 0) return cached;
|
|
709
|
+
const snapshot = snapshotForStory(story, commentIdsByStory.get(storyKey) ?? /* @__PURE__ */ new Set());
|
|
710
|
+
const saved = snapshot === null ? null : {
|
|
711
|
+
snapshot,
|
|
712
|
+
fingerprint: fingerprintOf(snapshot, story)
|
|
713
|
+
};
|
|
714
|
+
savedStories.set(storyKey, saved);
|
|
715
|
+
return saved;
|
|
716
|
+
};
|
|
717
|
+
const liveStateOf = (story) => {
|
|
718
|
+
const storyKey = canonicalJson(story);
|
|
719
|
+
const cached = liveStories.get(storyKey);
|
|
720
|
+
if (cached !== void 0) return cached;
|
|
721
|
+
const state = stateForStory?.(story) ?? null;
|
|
722
|
+
liveStories.set(storyKey, state);
|
|
723
|
+
return state;
|
|
724
|
+
};
|
|
725
|
+
if (stateForStory !== void 0) this.placeRemovedAnchors({
|
|
726
|
+
activeSuggestionIds,
|
|
727
|
+
stateForStory: liveStateOf,
|
|
728
|
+
savedSource: (story) => savedStoryOf(story)?.snapshot ?? null
|
|
729
|
+
});
|
|
628
730
|
for (const [key, record] of this.records) if (activeSuggestionIds.has(record.suggestionId)) {
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
if (saved === void 0) {
|
|
632
|
-
const snapshot = snapshotForStory(record.story, commentIdsByStory.get(storyKey) ?? /* @__PURE__ */ new Set());
|
|
633
|
-
if (!snapshot) continue;
|
|
634
|
-
saved = {
|
|
635
|
-
snapshot,
|
|
636
|
-
fingerprint: fingerprintOf(snapshot, record.story)
|
|
637
|
-
};
|
|
638
|
-
savedStories.set(storyKey, saved);
|
|
639
|
-
}
|
|
731
|
+
const saved = savedStoryOf(record.story);
|
|
732
|
+
if (saved === null) continue;
|
|
640
733
|
let updated = record;
|
|
641
|
-
if (record.splitRevisionId !== void 0
|
|
642
|
-
|
|
643
|
-
if (
|
|
644
|
-
const state = stateForStory(record.story);
|
|
645
|
-
live = state === null ? null : suggestionSnapshot(state);
|
|
646
|
-
liveStories.set(storyKey, live);
|
|
647
|
-
}
|
|
648
|
-
if (live !== null) updated = currentSplitRecord({
|
|
734
|
+
if (record.splitRevisionId !== void 0) {
|
|
735
|
+
const state = liveStateOf(record.story);
|
|
736
|
+
if (state !== null) updated = currentSplitRecord({
|
|
649
737
|
record,
|
|
650
|
-
|
|
738
|
+
state,
|
|
651
739
|
saved: saved.snapshot
|
|
652
740
|
}) ?? record;
|
|
653
741
|
}
|
|
@@ -659,7 +747,7 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
659
747
|
const { splitRevisionId: _, ...external } = current;
|
|
660
748
|
pending.push(structuredClone(external));
|
|
661
749
|
} else this.records.delete(key);
|
|
662
|
-
for (const [storyKey,
|
|
750
|
+
for (const [storyKey, saved] of savedStories) if (saved !== null) this.sourceFingerprints.set(storyKey, saved.fingerprint);
|
|
663
751
|
if (pending.length === 0) this.sourceFingerprints.clear();
|
|
664
752
|
return pending;
|
|
665
753
|
}
|
|
@@ -693,6 +781,11 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
693
781
|
reason: "invalidRecord"
|
|
694
782
|
};
|
|
695
783
|
}
|
|
784
|
+
if (record.retired !== void 0) return {
|
|
785
|
+
status: "stale",
|
|
786
|
+
suggestionId,
|
|
787
|
+
reason: record.retired
|
|
788
|
+
};
|
|
696
789
|
const storyKey = canonicalJson(record.story);
|
|
697
790
|
if (!baselines.has(storyKey)) {
|
|
698
791
|
const snapshot = snapshotForStory(record.story);
|
|
@@ -8,6 +8,11 @@ import { buildCleanBlockText } from "./clean-text.js";
|
|
|
8
8
|
// src/ai-edits/pendingJoin.ts
|
|
9
9
|
/** A paragraph mark that is a pending deletion, or a relocation's source. */
|
|
10
10
|
const isDeletedPPrMark = (value) => typeof value === "object" && value !== null && "kind" in value && (value.kind === "del" || value.kind === "moveFrom");
|
|
11
|
+
/**
|
|
12
|
+
* A paragraph mark accepting removes: a deleted one, or an added one another
|
|
13
|
+
* author deleted after (`deletion`), as docx-core's `markGoes` reads it.
|
|
14
|
+
*/
|
|
15
|
+
const markGoesWhenAccepted = (value) => isDeletedPPrMark(value) || typeof value === "object" && value !== null && "deletion" in value && value.deletion !== void 0 && value.deletion !== null;
|
|
11
16
|
/** A table row's or cell's revision record. */
|
|
12
17
|
const hasRevisionMarker = (value) => typeof value === "object" && value !== null && "revisionId" in value;
|
|
13
18
|
/** Whether a table cell is pending deletion. */
|
|
@@ -28,7 +33,7 @@ const isDeletedCell = (cell) => {
|
|
|
28
33
|
* rejecting the deletion, which is the reviewer's call, not a side effect.
|
|
29
34
|
*/
|
|
30
35
|
const isPendingDeletion = (doc, blockFrom, paragraph, cleanText) => {
|
|
31
|
-
if (cleanText.length === 0 &&
|
|
36
|
+
if (cleanText.length === 0 && markGoesWhenAccepted(paragraph.attrs["pPrMark"])) return true;
|
|
32
37
|
const $block = doc.resolve(blockFrom);
|
|
33
38
|
for (let depth = $block.depth; depth > 0; depth -= 1) {
|
|
34
39
|
const ancestor = $block.node(depth);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FolioAIEditAppliedOperation, FolioAIEditOperation } from "./types.js";
|
|
2
|
-
import { Node } from "prosemirror-model";
|
|
3
2
|
import { EditorState } from "prosemirror-state";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
4
|
type TextSpan = {
|
|
5
5
|
from: number;
|
|
6
6
|
to: number;
|
|
@@ -5,6 +5,7 @@ import { OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC, isOpaqueNestedRowMarkup, opa
|
|
|
5
5
|
import { recreateProseNodeWithParagraphPropertySource } from "../docx/paragraphPropertySource.js";
|
|
6
6
|
import { expectCharacterStyleMarkAttrs, expectHyperlinkMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
7
7
|
import { createListLabelCounter } from "../prosemirror/listLabels.js";
|
|
8
|
+
import { CLEARED_LIST_RENDERING_ATTRS } from "../prosemirror/listMarker.js";
|
|
8
9
|
import { paragraphNumberingAttr, readParagraphNumberingAttr } from "../prosemirror/numberingAttr.js";
|
|
9
10
|
import { readOutlineLevelAttr } from "../prosemirror/outlineLevelAttr.js";
|
|
10
11
|
import { directParagraphAlignment } from "../prosemirror/paragraphAlignment.js";
|
|
@@ -20,8 +21,8 @@ import { splitsSurrogatePair } from "./character-boundaries.js";
|
|
|
20
21
|
import { buildCleanBlockText } from "./clean-text.js";
|
|
21
22
|
import { createNoteReferenceLabeler } from "./note-references.js";
|
|
22
23
|
import { panic } from "better-result";
|
|
23
|
-
import { Fragment } from "prosemirror-model";
|
|
24
24
|
import { TableMap } from "prosemirror-tables";
|
|
25
|
+
import { Fragment } from "prosemirror-model";
|
|
25
26
|
// src/ai-edits/snapshot.ts
|
|
26
27
|
const metadataBySnapshot = /* @__PURE__ */ new WeakMap();
|
|
27
28
|
const metadataOf = (snapshot) => metadataBySnapshot.get(snapshot) ?? panic("Metadata was requested for a snapshot that did not record it");
|
|
@@ -655,6 +656,12 @@ const getBlockKind = (headingLevel, showsMarker) => {
|
|
|
655
656
|
return showsMarker ? "listItem" : "paragraph";
|
|
656
657
|
};
|
|
657
658
|
/** Rebind cached style numbering to the current style before the owner reads it. */
|
|
659
|
+
/**
|
|
660
|
+
* The attrs without the cached list rendering keys. The list counter reads
|
|
661
|
+
* those keys with `!= null`, so an absent key clears like the null that
|
|
662
|
+
* {@link CLEARED_LIST_RENDERING_ATTRS} writes into editor state.
|
|
663
|
+
*/
|
|
664
|
+
const withoutListRenderingAttrs = (attrs) => Object.fromEntries(Object.entries(attrs).filter(([key]) => !Object.hasOwn(CLEARED_LIST_RENDERING_ATTRS, key)));
|
|
658
665
|
const snapshotListAttrs = (attrs, styleResolver) => {
|
|
659
666
|
if (styleResolver === null) return attrs;
|
|
660
667
|
if (!(typeof attrs.styleId === "string" || attrs.numPrFromStyle !== null && attrs.numPrFromStyle !== void 0 || attrs.numPr?.kind === "levelOnly" || attrs._propertyChanges?.some(({ previousFormatting }) => previousFormatting !== void 0 && (typeof previousFormatting.styleId === "string" || previousFormatting.numPrFromStyle !== null && previousFormatting.numPrFromStyle !== void 0 || previousFormatting.numPr?.kind === "levelOnly")) === true)) return attrs;
|
|
@@ -664,12 +671,10 @@ const snapshotListAttrs = (attrs, styleResolver) => {
|
|
|
664
671
|
return numbering === void 0 ? null : paragraphNumberingAttr(numbering);
|
|
665
672
|
};
|
|
666
673
|
const currentStyleNumbering = styleNumberingAttr(attrs.styleId);
|
|
667
|
-
const currentAttrs = { ...attrs };
|
|
674
|
+
const currentAttrs = attrs.numPr == null && attrs.numPrFromStyle != null && currentStyleNumbering === null ? withoutListRenderingAttrs({ ...attrs }) : { ...attrs };
|
|
668
675
|
delete currentAttrs.numPrFromStyle;
|
|
669
|
-
const cancelsStaleStyleNumbering = (attrs.numPr === null || attrs.numPr === void 0) && currentStyleNumbering === null && attrs._propertyChanges !== null && attrs._propertyChanges !== void 0 && attrs._propertyChanges.length > 0;
|
|
670
676
|
return {
|
|
671
677
|
...currentAttrs,
|
|
672
|
-
...cancelsStaleStyleNumbering ? { numPr: paragraphNumberingAttr({ kind: "none" }) } : {},
|
|
673
678
|
...currentStyleNumbering === null ? {} : { numPrFromStyle: currentStyleNumbering },
|
|
674
679
|
...attrs._propertyChanges === null || attrs._propertyChanges === void 0 ? {} : { _propertyChanges: attrs._propertyChanges.map((change) => ({
|
|
675
680
|
...change,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableRectangle } from "./table-mutation-plan.js";
|
|
2
|
-
import { Node } from "prosemirror-model";
|
|
3
2
|
import { Transaction } from "prosemirror-state";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
4
|
type TableCellRectangleMutationOptions = {
|
|
5
5
|
tr: Transaction;
|
|
6
6
|
tablePosition: number;
|
|
@@ -2,13 +2,13 @@ import { decodeTableCellParagraphSourcePayload, restoreTableCellsWithParagraphPr
|
|
|
2
2
|
import { expectTableCellAttrs } from "../prosemirror/attrs/index.js";
|
|
3
3
|
import { standaloneTableCellFromProseMirror } from "../prosemirror/conversion/fromProseDoc.js";
|
|
4
4
|
import { standaloneTableCellToProseMirror } from "../prosemirror/conversion/toProseDoc.js";
|
|
5
|
-
import { markStructuralChange } from "../prosemirror/
|
|
5
|
+
import { markStructuralChange } from "../prosemirror/paragraphChangeTrackerMeta.js";
|
|
6
6
|
import { removeRowsWithoutCells } from "../prosemirror/tableGridMutation.js";
|
|
7
7
|
import { tableRectanglesEqual } from "./table-mutation-plan.js";
|
|
8
8
|
import { tableRectangleCutsMergedCell } from "./table-targets.js";
|
|
9
9
|
import { Result } from "better-result";
|
|
10
|
-
import { Fragment } from "prosemirror-model";
|
|
11
10
|
import { TableMap } from "prosemirror-tables";
|
|
11
|
+
import { Fragment } from "prosemirror-model";
|
|
12
12
|
// src/ai-edits/table-cell-mutations.ts
|
|
13
13
|
const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
|
|
14
14
|
const map = TableMap.get(table);
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
* comparison carries and checks, and the three can never drift apart.
|
|
24
24
|
*/
|
|
25
25
|
import { FolioStoryTable } from "./snapshot.js";
|
|
26
|
-
import { Node } from "prosemirror-model";
|
|
27
26
|
import { Transaction } from "prosemirror-state";
|
|
27
|
+
import { Node } from "prosemirror-model";
|
|
28
28
|
import { OpStory, SetCellPropsOp, SetRowPropsOp, SetTablePropsOp } from "@stll/docx-core/ops";
|
|
29
29
|
/** Where a cell sits: which table, which row of it, which cell of that row. */
|
|
30
30
|
export type TableCellCoordinate = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tableCellRejectAttrPatch, tableRejectAttrPatch, tableRowRejectAttrPatch } from "../prosemirror/commands/propertyChangeScope.js";
|
|
2
2
|
import { tableAttrsToFormatting, tableCellAttrsToFormatting, tableRowAttrsToFormatting } from "../prosemirror/conversion/fromProseDoc.js";
|
|
3
|
-
import { markStructuralChange } from "../prosemirror/
|
|
3
|
+
import { markStructuralChange } from "../prosemirror/paragraphChangeTrackerMeta.js";
|
|
4
4
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
5
5
|
import { DOCUMENT_OP_TYPES } from "@stll/docx-core/ops";
|
|
6
6
|
// src/ai-edits/table-geometry.ts
|