@stll/folio-core 0.66.2 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +138 -17
- package/dist/ai-edits/batch-claims.js +5 -3
- package/dist/ai-edits/clean-text.js +4 -1
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/read.js +6 -4
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +32 -17
- package/dist/ai-edits/table-cell-mutations.js +3 -2
- package/dist/ai-edits/table-row-column-mutations.js +20 -6
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +77 -19
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -2
- package/dist/controller/canonicalInput.js +47 -2
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +328 -75
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +10 -3
- package/dist/controller/hiddenEditorManager.js +94 -38
- package/dist/controller/layoutPipeline.d.ts +2 -0
- package/dist/controller/layoutPipeline.js +55 -18
- package/dist/controller/layoutSession.d.ts +1 -0
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.d.ts +3 -1
- package/dist/display-list/build/tablePrimitives.js +49 -14
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/chartPreview.d.ts +4 -1
- package/dist/docx/chartPreview.js +26 -15
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/mainDocumentPart.d.ts +6 -0
- package/dist/docx/mainDocumentPart.js +65 -0
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/packageParts.d.ts +1 -1
- package/dist/docx/packageParts.js +10 -4
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/previewBudget.d.ts +6 -0
- package/dist/docx/previewBudget.js +7 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +42 -25
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/shapeAlternateContent.js +19 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/unzip.js +2 -0
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/wholeStoryRevisionResolution.js +57 -12
- package/dist/layout-bridge/convert/altChunkPlaceholder.d.ts +10 -0
- package/dist/layout-bridge/convert/altChunkPlaceholder.js +70 -0
- package/dist/layout-bridge/convert/fixedTableColumnWidths.js +2 -1
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +10 -0
- package/dist/layout-bridge/convert/flowConversionShared.js +11 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +4 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/tableConversion.js +25 -10
- package/dist/layout-bridge/convert/toFlowBlocks.js +4 -0
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/clickToPosition.js +5 -1
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +1 -0
- package/dist/layout-engine/measure/tableVisibleBand.d.ts +16 -0
- package/dist/layout-engine/measure/tableVisibleBand.js +28 -0
- package/dist/layout-engine/tableLayout.js +34 -7
- package/dist/layout-engine/tableRowBreak.d.ts +46 -0
- package/dist/layout-engine/tableRowBreak.js +193 -36
- package/dist/layout-engine/types.d.ts +43 -3
- package/dist/layout-painter/previewSvg.d.ts +8 -0
- package/dist/layout-painter/previewSvg.js +47 -0
- package/dist/layout-painter/renderImage.js +2 -1
- package/dist/layout-painter/renderPage.d.ts +5 -4
- package/dist/layout-painter/renderPage.js +52 -20
- package/dist/layout-painter/renderParagraph.js +3 -2
- package/dist/layout-painter/renderTable.d.ts +5 -2
- package/dist/layout-painter/renderTable.js +39 -22
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/anchoredTextBoxes.d.ts +2 -1
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +122 -18
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.d.ts +9 -0
- package/dist/prosemirror/commands/deleteBesideInlineAnchor.js +36 -0
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +6 -0
- package/dist/prosemirror/commands/pastePlainText.js +13 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.js +30 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +8 -2
- package/dist/prosemirror/commentReferenceIntegrity.js +22 -8
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +115 -35
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +325 -55
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +8 -9
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +46 -11
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +2 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +22 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +5 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +8 -4
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +5 -1
- package/dist/prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +4 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +119 -38
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/inlineAnchorDom.js +21 -0
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -8
- package/dist/prosemirror/plugins/suggestionMode.js +195 -30
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/rowGridOmissions.d.ts +11 -0
- package/dist/prosemirror/rowGridOmissions.js +21 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableGridMutation.d.ts +19 -2
- package/dist/prosemirror/tableGridMutation.js +118 -15
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +2 -0
- package/dist/prosemirror/tablePositionedBookmarks.js +80 -0
- package/dist/prosemirror/validation.js +2 -1
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
package/dist/ai-edits/apply.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NumberingIdsInUse } from "../docx/numberingIds.js";
|
|
2
2
|
import { FolioTableTemplates } from "./table-template.js";
|
|
3
|
-
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot } from "./types.js";
|
|
3
|
+
import { FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot, FolioAIResolvedEditOperation } from "./types.js";
|
|
4
4
|
import { WordDiffGranularity } from "./word-diff.js";
|
|
5
5
|
import { Node } from "prosemirror-model";
|
|
6
6
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
@@ -124,6 +124,14 @@ export type FolioAIEditApplyOutcome = FolioAIEditApplyResult & {
|
|
|
124
124
|
*/
|
|
125
125
|
nextRevisionId: number;
|
|
126
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Operation types applied in `"suggested"` mode. Every produced revision — an
|
|
129
|
+
* inline mark, a whole-node `_suggestedInsert` marker, or a suggested
|
|
130
|
+
* `trIns`/`trDel`/`cellMarker` — is stripped from serialized DOCX until
|
|
131
|
+
* accepted. Cell merge/split (not row/column ops) and comment ops stay
|
|
132
|
+
* `unsupportedMode`.
|
|
133
|
+
*/
|
|
134
|
+
export declare const SUGGESTED_SUPPORTED_OPERATION_TYPES: ReadonlySet<FolioAIResolvedEditOperation["type"]>;
|
|
127
135
|
export declare const applyFolioAIEditOperations: (options: ApplyFolioAIEditOperationsOptions) => FolioAIEditApplyOutcome;
|
|
128
136
|
/** {@link applyFolioAIEditOperations} for a caller holding every story. Internal. */
|
|
129
137
|
export declare const applyFolioAIEditOperationsInPackage: (options: ApplyFolioAIEditOperationsInPackageOptions) => FolioAIEditApplyOutcome;
|
package/dist/ai-edits/apply.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NO_NUMBERING_IDS_IN_USE } from "../docx/numberingIds.js";
|
|
2
|
-
import { isNumberingReference } from "../docx/numberingReference.js";
|
|
2
|
+
import { isNumberingReference as isNumberingReference$1 } from "../docx/numberingReference.js";
|
|
3
3
|
import { formattingEquals } from "../docx/runConsolidator.js";
|
|
4
4
|
import { isStyleSourcedParagraphNumbering } from "../internal/paragraphFormattingSerialization.js";
|
|
5
5
|
import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
|
|
@@ -16,6 +16,7 @@ import { markStructuralChange } from "../prosemirror/extensions/features/Paragra
|
|
|
16
16
|
import "../prosemirror/extensions/nodes/TextBoxAnchorExtension.js";
|
|
17
17
|
import { blockBoundariesOf, carriesCommentAnchor, inlineBoundariesOf, isBlockBoundaryNode, removeResolvedSubtree } from "../prosemirror/keptRangeBoundaries.js";
|
|
18
18
|
import { CLEARED_LIST_RENDERING_ATTRS } from "../prosemirror/listMarker.js";
|
|
19
|
+
import { lockedControlSpans } from "../prosemirror/lockedControls.js";
|
|
19
20
|
import { effectiveParagraphNumbering, paragraphNumberingAttr, paragraphNumberingSourcesFromBoundary, readParagraphNumberingAttr, removedNumberingAttr } from "../prosemirror/numberingAttr.js";
|
|
20
21
|
import { directParagraphAlignment } from "../prosemirror/paragraphAlignment.js";
|
|
21
22
|
import { styleResolvedParagraphFormatting } from "../prosemirror/paragraphFormattingProvenance.js";
|
|
@@ -46,11 +47,11 @@ import { buildCleanBlockText, resolveCleanTextRange } from "./clean-text.js";
|
|
|
46
47
|
import { hasInlineEmphasis, parseInlineEmphasisRuns, stripInlineEmphasisMarkers } from "./inline-emphasis.js";
|
|
47
48
|
import { applyTextChanges, changesFromSegments, keepAtomicSpans, planTextChanges, widenChangesToAtomicSpans } from "./minimal-replacement.js";
|
|
48
49
|
import { assertNewListsAllocated, resolveNewListOperations, stageNewListOperations } from "./newListNumbering.js";
|
|
49
|
-
import { cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, planChangesAroundNoteReferences, segmentsAroundNoteReferences } from "./note-references.js";
|
|
50
|
+
import { comparisonApplying, cutsIntoNoteReference, noteReferenceEditsAllowed, noteReferenceOf, noteReferenceSpansWithin, planChangesAroundNoteReferences, segmentsAroundNoteReferences } from "./note-references.js";
|
|
50
51
|
import { classifyResourceReference } from "./referenceClassification.js";
|
|
51
52
|
import { getFolioDocumentOperationRemovedBlockIds, getTrackedFolioDocumentOperationCarrierBlockId, getTrackedFolioDocumentOperationRemovedBlockIds } from "./removed-blocks.js";
|
|
52
53
|
import { separateRevisionStretches } from "./revisionStretches.js";
|
|
53
|
-
import { collectNoteReferenceLabels, hashFolioAIBlockStructuralBoundaries, hashFolioAIBlockText, isHiddenTableRow
|
|
54
|
+
import { collectNoteReferenceLabels, hashFolioAIBlockContent, hashFolioAIBlockStructuralBoundaries, hashFolioAIBlockText, isHiddenTableRow } from "./snapshot.js";
|
|
54
55
|
import { isEmptyTableCell, mergeTableRectangle, mergeTrackedVerticalTableCells, splitTableRectangle, splitTrackedVerticalTableCell } from "./table-cell-mutations.js";
|
|
55
56
|
import { planTableMutations } from "./table-mutation-plan.js";
|
|
56
57
|
import { applyTableColumnDeletion, applyTableColumnInsertion, applyTableRowDeletion, applyTableRowInsertion, describeUnplacedCellTexts, findTableColumnInsertion, findTableRowInsertion, getTableColumnCoordinateKey, markTableRowContent, splitCellParagraphTexts } from "./table-row-column-mutations.js";
|
|
@@ -58,6 +59,7 @@ import { findEnclosingTableCell, findEnclosingTableRow, findOutermostTableBounda
|
|
|
58
59
|
import { tableFromTemplate } from "./table-template.js";
|
|
59
60
|
import { wordDiffSessionFromOptions } from "./word-diff.js";
|
|
60
61
|
import { panic } from "better-result";
|
|
62
|
+
import { CONTENT_CONTROL_LOCK, REVIEW_CARRIERS, firstLockedControlViolation, lockedControlMessage } from "@stll/docx-core/model";
|
|
61
63
|
import { Fragment, Mark } from "prosemirror-model";
|
|
62
64
|
import { TableMap } from "prosemirror-tables";
|
|
63
65
|
import { canSplit } from "prosemirror-transform";
|
|
@@ -560,8 +562,7 @@ const applyBlockParagraphProperties = ({ tr, position, node, properties, styleRe
|
|
|
560
562
|
const OPERATION_TEXT_CONTEXT = {
|
|
561
563
|
baseParagraphFormatting: void 0,
|
|
562
564
|
paragraphFormatting: void 0,
|
|
563
|
-
paragraphMarkFormatting: void 0
|
|
564
|
-
paragraphMarkPrecedesStyle: false
|
|
565
|
+
paragraphMarkFormatting: void 0
|
|
565
566
|
};
|
|
566
567
|
const applyReplaceBlockStyleId = ({ item, tr, styleResolver, revisionInfo }) => {
|
|
567
568
|
if (item.operation.type !== "replaceBlock" || item.operation.styleId === void 0) return {
|
|
@@ -856,9 +857,16 @@ const applyTrackedInlineFormattingToRanges = ({ tr, schema, doc = tr.doc, ranges
|
|
|
856
857
|
suggestionId
|
|
857
858
|
};
|
|
858
859
|
const revisionIds = [];
|
|
860
|
+
let fieldChange = null;
|
|
859
861
|
for (const segment of segments) {
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
+
const { representation } = segment;
|
|
863
|
+
const insideField = fieldChange !== null && representation.role === "serialized-result" && representation.position < fieldChange.end;
|
|
864
|
+
const revisionId = insideField && fieldChange !== null ? fieldChange.id : revisionIdSeed + revisionIds.length;
|
|
865
|
+
if (!insideField) revisionIds.push(revisionId);
|
|
866
|
+
if (representation.role === "owner" && representation.carrierDisposition === "structured-field") fieldChange = {
|
|
867
|
+
id: revisionId,
|
|
868
|
+
end: representation.position + representation.node.nodeSize
|
|
869
|
+
};
|
|
862
870
|
const change = {
|
|
863
871
|
type: "runPropertyChange",
|
|
864
872
|
info: {
|
|
@@ -904,7 +912,7 @@ const collectLiveBlocksByHash = (doc) => {
|
|
|
904
912
|
fieldResults: "text",
|
|
905
913
|
noteReferences
|
|
906
914
|
}).text;
|
|
907
|
-
const hash =
|
|
915
|
+
const hash = hashFolioAIBlockContent(cleanText);
|
|
908
916
|
const bucket = byHash.get(hash) ?? [];
|
|
909
917
|
bucket.push({
|
|
910
918
|
from: pos,
|
|
@@ -1187,6 +1195,75 @@ const batchClaimOf = ({ item, doc, producesTrackedChanges }) => {
|
|
|
1187
1195
|
}
|
|
1188
1196
|
};
|
|
1189
1197
|
/**
|
|
1198
|
+
* The stretches an operation changes, for the content-control lock rule
|
|
1199
|
+
* (`lockedControlViolation`), read off the claim the batch already makes for
|
|
1200
|
+
* it. A comment changes nothing a lock guards, so it touches nothing.
|
|
1201
|
+
*/
|
|
1202
|
+
const lockTouchesOf = (item, claim) => {
|
|
1203
|
+
switch (claim.type) {
|
|
1204
|
+
case "text":
|
|
1205
|
+
case "split": return [{
|
|
1206
|
+
from: claim.from,
|
|
1207
|
+
to: claim.to,
|
|
1208
|
+
effect: "edit"
|
|
1209
|
+
}];
|
|
1210
|
+
case "annotation": return item.operation.type === "formatRange" ? [{
|
|
1211
|
+
from: claim.from,
|
|
1212
|
+
to: claim.to,
|
|
1213
|
+
effect: "edit"
|
|
1214
|
+
}] : [];
|
|
1215
|
+
case "rewriteBlock": {
|
|
1216
|
+
const content = {
|
|
1217
|
+
from: claim.block + 1,
|
|
1218
|
+
to: item.blockTo - 1
|
|
1219
|
+
};
|
|
1220
|
+
return [{
|
|
1221
|
+
...content,
|
|
1222
|
+
effect: "remove"
|
|
1223
|
+
}, {
|
|
1224
|
+
...content,
|
|
1225
|
+
effect: "edit"
|
|
1226
|
+
}];
|
|
1227
|
+
}
|
|
1228
|
+
case "paragraphProperties": return [{
|
|
1229
|
+
from: claim.block,
|
|
1230
|
+
to: claim.block,
|
|
1231
|
+
effect: "edit"
|
|
1232
|
+
}];
|
|
1233
|
+
case "deleteBlock": return [{
|
|
1234
|
+
from: claim.block,
|
|
1235
|
+
to: claim.end,
|
|
1236
|
+
effect: "remove"
|
|
1237
|
+
}];
|
|
1238
|
+
case "merge": return [{
|
|
1239
|
+
from: claim.next - 1,
|
|
1240
|
+
to: claim.next + 1,
|
|
1241
|
+
effect: "remove"
|
|
1242
|
+
}];
|
|
1243
|
+
case "insertion": return [{
|
|
1244
|
+
from: claim.at,
|
|
1245
|
+
to: claim.at,
|
|
1246
|
+
effect: "edit"
|
|
1247
|
+
}];
|
|
1248
|
+
case "tableRemoval": return claim.ranges.map(({ from, to }) => ({
|
|
1249
|
+
from,
|
|
1250
|
+
to,
|
|
1251
|
+
effect: "remove"
|
|
1252
|
+
}));
|
|
1253
|
+
case "tableStructure": return [{
|
|
1254
|
+
from: claim.table,
|
|
1255
|
+
to: claim.table,
|
|
1256
|
+
effect: "edit"
|
|
1257
|
+
}, ...claim.folded.map(({ from, to }) => ({
|
|
1258
|
+
from,
|
|
1259
|
+
to,
|
|
1260
|
+
effect: "remove"
|
|
1261
|
+
}))];
|
|
1262
|
+
case "unclaimed": return [];
|
|
1263
|
+
default: return panic("Unhandled batch claim", { claim });
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
/**
|
|
1190
1267
|
* The snapshot recorded an `hashOccurrenceCount` per anchor but
|
|
1191
1268
|
* not which ordinal within that bucket the block was — recompute
|
|
1192
1269
|
* on demand from the snapshot's anchor map. Stable iteration
|
|
@@ -1406,12 +1483,13 @@ const readNow = (item, tr) => {
|
|
|
1406
1483
|
* properties (see `carryParagraphProperties`). Null when the paragraph stands
|
|
1407
1484
|
* alone, or goes whole as a pending deletion.
|
|
1408
1485
|
*/
|
|
1409
|
-
const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences }) => {
|
|
1486
|
+
const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences, removedBreakPositions }) => {
|
|
1410
1487
|
const paragraph = doc.nodeAt(paragraphPos);
|
|
1411
1488
|
if (paragraph?.type.name !== "paragraph" || !isDeletedPPrMark(paragraph.attrs["pPrMark"]) || isPendingDeletion(doc, paragraphPos, paragraph, cleanText)) return null;
|
|
1412
1489
|
const survivor = paragraphLeftAfter({
|
|
1413
1490
|
doc,
|
|
1414
|
-
paragraphPos
|
|
1491
|
+
paragraphPos,
|
|
1492
|
+
...removedBreakPositions ? { removedBreakPositions } : {}
|
|
1415
1493
|
});
|
|
1416
1494
|
const left = survivor === null ? null : doc.nodeAt(survivor);
|
|
1417
1495
|
if (survivor === null || left?.type !== paragraph.type) return null;
|
|
@@ -1427,7 +1505,7 @@ const pendingJoinSurvivor = ({ doc, paragraphPos, cleanText, noteReferences }) =
|
|
|
1427
1505
|
* suggestion is read against the document as it stands, where the join has
|
|
1428
1506
|
* not run anything together yet, so it copies the paragraph it names.
|
|
1429
1507
|
*/
|
|
1430
|
-
const insertionFormattingAnchor = ({ item, tr, mode, noteReferences }) => {
|
|
1508
|
+
const insertionFormattingAnchor = ({ item, tr, mode, noteReferences, removedBreakPositions }) => {
|
|
1431
1509
|
if (mode === "suggested") return item;
|
|
1432
1510
|
const position = sinceRead(tr, item).map(item.blockFrom, 1);
|
|
1433
1511
|
const anchor = tr.doc.nodeAt(position);
|
|
@@ -1439,7 +1517,8 @@ const insertionFormattingAnchor = ({ item, tr, mode, noteReferences }) => {
|
|
|
1439
1517
|
fieldResults: "text",
|
|
1440
1518
|
noteReferences
|
|
1441
1519
|
}).text,
|
|
1442
|
-
noteReferences
|
|
1520
|
+
noteReferences,
|
|
1521
|
+
removedBreakPositions
|
|
1443
1522
|
});
|
|
1444
1523
|
const source = survivor === null ? null : tr.doc.nodeAt(survivor);
|
|
1445
1524
|
return source ? {
|
|
@@ -2732,6 +2811,28 @@ const buildInsertedParagraphs = ({ item, schema, formattingFromStyle, mode, auth
|
|
|
2732
2811
|
nextRevisionId
|
|
2733
2812
|
};
|
|
2734
2813
|
};
|
|
2814
|
+
/** The story's last block but for text boxes, which stand after their paragraph. */
|
|
2815
|
+
const lastBlockBeforeTextBoxes = (doc) => {
|
|
2816
|
+
let position = doc.content.size;
|
|
2817
|
+
for (let index = doc.childCount - 1; index >= 0; index--) {
|
|
2818
|
+
const node = doc.child(index);
|
|
2819
|
+
position -= node.nodeSize;
|
|
2820
|
+
if (node.type.name !== "textBox") return {
|
|
2821
|
+
node,
|
|
2822
|
+
position
|
|
2823
|
+
};
|
|
2824
|
+
}
|
|
2825
|
+
return null;
|
|
2826
|
+
};
|
|
2827
|
+
/**
|
|
2828
|
+
* A story that ended with a table now ends with a tracked paragraph: resolving
|
|
2829
|
+
* it away restores that ending, though a story otherwise keeps a final paragraph.
|
|
2830
|
+
*/
|
|
2831
|
+
const markTerminalTableReviewCarrier = (tr, before) => {
|
|
2832
|
+
if (lastBlockBeforeTextBoxes(before)?.node.type.name !== "table") return;
|
|
2833
|
+
const last = lastBlockBeforeTextBoxes(tr.doc);
|
|
2834
|
+
if (last?.node.type.name === "paragraph" && expectParagraphAttrs(last.node).pPrMark?.kind === "ins") tr.setNodeAttribute(last.position, "reviewCarrier", REVIEW_CARRIERS.TERMINAL_TABLE);
|
|
2835
|
+
};
|
|
2735
2836
|
const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: requestedOperations, mode = "tracked-changes", author = "AI", initials, createCommentId, revisionStamp, revisionIdSeed, wordDiff, wordDiffMode = "bounded", tableTemplates, replacementBackground = "clear", undefinedReferences, numberingIdsElsewhere }) => {
|
|
2736
2837
|
seedRevisionIdsFromDoc(view.state.doc);
|
|
2737
2838
|
const applied = [];
|
|
@@ -2782,6 +2883,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
2782
2883
|
const claimedTableRows = /* @__PURE__ */ new Set();
|
|
2783
2884
|
const claimedTableColumns = /* @__PURE__ */ new Set();
|
|
2784
2885
|
const batchClaims = new BatchClaims();
|
|
2886
|
+
const lockedControls = () => lockedControlSpans(view.state.doc);
|
|
2785
2887
|
const removedBlocksBy = /* @__PURE__ */ new Map();
|
|
2786
2888
|
const diffText = wordDiffMode === "coarse" ? coarseWordDiff : wordDiffSessionFromOptions(wordDiff).diff;
|
|
2787
2889
|
const producesTrackedChanges = mode !== "direct";
|
|
@@ -2909,6 +3011,15 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
2909
3011
|
doc: view.state.doc,
|
|
2910
3012
|
producesTrackedChanges
|
|
2911
3013
|
});
|
|
3014
|
+
const lockViolation = comparisonApplying() ? null : firstLockedControlViolation(lockedControls(), lockTouchesOf(resolution.operation, claim));
|
|
3015
|
+
if (lockViolation !== null) {
|
|
3016
|
+
skipped.push({
|
|
3017
|
+
id: operation.id,
|
|
3018
|
+
reason: CONTENT_CONTROL_LOCK,
|
|
3019
|
+
message: lockedControlMessage(lockViolation)
|
|
3020
|
+
});
|
|
3021
|
+
continue;
|
|
3022
|
+
}
|
|
2912
3023
|
const claimedBy = batchClaims.conflictOf(claim);
|
|
2913
3024
|
if (claimedBy !== null) {
|
|
2914
3025
|
skipped.push({
|
|
@@ -3189,7 +3300,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
3189
3300
|
item: insertion,
|
|
3190
3301
|
tr,
|
|
3191
3302
|
mode,
|
|
3192
|
-
noteReferences
|
|
3303
|
+
noteReferences,
|
|
3304
|
+
removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
|
|
3193
3305
|
});
|
|
3194
3306
|
const built = buildInsertedParagraphs({
|
|
3195
3307
|
item: formatted,
|
|
@@ -3598,7 +3710,8 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
3598
3710
|
item,
|
|
3599
3711
|
tr,
|
|
3600
3712
|
mode,
|
|
3601
|
-
noteReferences
|
|
3713
|
+
noteReferences,
|
|
3714
|
+
removedBreakPositions: pendingRemovedFinalBreakPositions(tr, deletedFinalParagraphs)
|
|
3602
3715
|
});
|
|
3603
3716
|
const built = buildInsertedParagraphs({
|
|
3604
3717
|
item: formatted,
|
|
@@ -4242,6 +4355,13 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
4242
4355
|
});
|
|
4243
4356
|
continue;
|
|
4244
4357
|
}
|
|
4358
|
+
if (tr.doc.resolve(item.from).parent !== tr.doc.nodeAt(item.blockFrom)) {
|
|
4359
|
+
skipped.push({
|
|
4360
|
+
id: item.operation.id,
|
|
4361
|
+
reason: "unsupportedBlock"
|
|
4362
|
+
});
|
|
4363
|
+
continue;
|
|
4364
|
+
}
|
|
4245
4365
|
allocateNewLists({
|
|
4246
4366
|
status: "willApply",
|
|
4247
4367
|
items: [item]
|
|
@@ -4589,6 +4709,7 @@ const applyFolioAIEditOperationsInternal = ({ view, snapshot, operations: reques
|
|
|
4589
4709
|
});
|
|
4590
4710
|
}
|
|
4591
4711
|
removeRowsWithoutCellsAfterBatch(tr, emptiedRows);
|
|
4712
|
+
markTerminalTableReviewCarrier(tr, view.state.doc);
|
|
4592
4713
|
if (tr.docChanged || deferredNoopFinalDeletions.size > 0) {
|
|
4593
4714
|
const batchRevisionIds = new Set(applied.flatMap(({ revisionIds }) => revisionIds ?? []));
|
|
4594
4715
|
tr = withoutRevisionsOnZeroWidthAnchors(tr, batchRevisionIds, deletedTextBoxAnchorIds);
|
|
@@ -5526,7 +5647,7 @@ const resolveStableBlock = ({ snapshot, blockId, liveBlocks, liveBlocksByParaId,
|
|
|
5526
5647
|
noteReferences
|
|
5527
5648
|
});
|
|
5528
5649
|
const currentText = cleanBlock.text;
|
|
5529
|
-
const currentTextHash =
|
|
5650
|
+
const currentTextHash = hashFolioAIBlockContent(currentText);
|
|
5530
5651
|
const structuralBoundaryHash = hashFolioAIBlockStructuralBoundaries(cleanBlock);
|
|
5531
5652
|
if (currentTextHash !== anchor.textHash || structuralBoundaryHash !== anchor.structuralBoundaryHash) return {
|
|
5532
5653
|
type: "skip",
|
|
@@ -6286,7 +6407,7 @@ const describeUndefinedParagraphStyle = ({ path, styleId, definedAs }, definitio
|
|
|
6286
6407
|
return `${path} "${styleId}" ${definedAs === void 0 ? "names no style in this document" : `names a ${definedAs} style, not a paragraph style`} (${available}).`;
|
|
6287
6408
|
};
|
|
6288
6409
|
/** The `w:num` id a stated numbering names, when it names one. */
|
|
6289
|
-
const statedNumberingInstance = (numbering) => numbering?.kind === "reference" && isNumberingReference(numbering.numId) ? numbering.numId : void 0;
|
|
6410
|
+
const statedNumberingInstance = (numbering) => numbering?.kind === "reference" && isNumberingReference$1(numbering.numId) ? numbering.numId : void 0;
|
|
6290
6411
|
/**
|
|
6291
6412
|
* Every numbering instance an operation names, with the field that names it.
|
|
6292
6413
|
* Only reference variants name an instance; inheritance, cancellation and level-only do not.
|
|
@@ -6344,4 +6465,4 @@ const getOperationQuote = (operation) => {
|
|
|
6344
6465
|
if (operation.type === "replaceInBlock") return operation.find;
|
|
6345
6466
|
if (operation.type === "commentOnBlock") return operation.quote;
|
|
6346
6467
|
};
|
|
6347
|
-
export { applyFolioAIEditOperations, applyFolioAIEditOperationsInPackage, insertCleanText, previewFolioAIEditOperations, previewFolioAIEditOperationsWithResult };
|
|
6468
|
+
export { SUGGESTED_SUPPORTED_OPERATION_TYPES, applyFolioAIEditOperations, applyFolioAIEditOperationsInPackage, insertCleanText, previewFolioAIEditOperations, previewFolioAIEditOperationsWithResult };
|
|
@@ -46,7 +46,8 @@ const blockRolesOf = (claim) => {
|
|
|
46
46
|
keepsParagraph: claim.keepsParagraph,
|
|
47
47
|
endsContainer: claim.endsContainer,
|
|
48
48
|
paragraphsBefore: claim.paragraphsBefore,
|
|
49
|
-
retiresBreakBefore: false
|
|
49
|
+
retiresBreakBefore: false,
|
|
50
|
+
everyParagraphBeforeGoes: false
|
|
50
51
|
}
|
|
51
52
|
}];
|
|
52
53
|
case "merge": return [{
|
|
@@ -108,7 +109,7 @@ const rolesConflict = (left, right) => {
|
|
|
108
109
|
if (ROLE_RANK[right.kind] > ROLE_RANK[left.kind]) return rolesConflict(right, left);
|
|
109
110
|
switch (left.kind) {
|
|
110
111
|
case "deleteBlock": switch (right.kind) {
|
|
111
|
-
case "paragraphProperties": return left.endsContainer && (!left.keepsParagraph || left.retiresBreakBefore);
|
|
112
|
+
case "paragraphProperties": return left.endsContainer && (!left.keepsParagraph || left.retiresBreakBefore || left.everyParagraphBeforeGoes);
|
|
112
113
|
case "mergeNext": return false;
|
|
113
114
|
default: return true;
|
|
114
115
|
}
|
|
@@ -176,7 +177,8 @@ var BatchClaims = class {
|
|
|
176
177
|
settled(role) {
|
|
177
178
|
return role.kind === "deleteBlock" ? {
|
|
178
179
|
...role,
|
|
179
|
-
retiresBreakBefore: this.retiresBreakBefore(role)
|
|
180
|
+
retiresBreakBefore: this.retiresBreakBefore(role),
|
|
181
|
+
everyParagraphBeforeGoes: role.paragraphsBefore.length > 0 && role.paragraphsBefore.every(({ block }) => (this.blocks.get(block) ?? []).some((entry) => entry.role.kind === "deleteBlock"))
|
|
180
182
|
} : role;
|
|
181
183
|
}
|
|
182
184
|
/** `claim`'s roles, given the insertions accepted so far. */
|
|
@@ -104,7 +104,10 @@ const buildCleanBlockText = (blockNode, blockFrom, { fieldResults, noteReference
|
|
|
104
104
|
});
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
let atomText;
|
|
108
|
+
if (fieldResults === "omitted") atomText = runFormattingInlineControlCharacter(node);
|
|
109
|
+
else if (node.type.name === "structuredField") atomText = node.textContent;
|
|
110
|
+
else atomText = runFormattingInlineAtomCleanText(node);
|
|
108
111
|
if (atomText !== null) {
|
|
109
112
|
if (isOmittedFromCleanView(node)) return false;
|
|
110
113
|
const startPos = blockFrom + 1 + pos;
|
|
@@ -7,11 +7,17 @@ import { InlineProvenanceTargetOptions } from "../compare/inline-provenance.js";
|
|
|
7
7
|
import { ImportReferencedStyleDefinitionsResult } from "../compare/style-resources.js";
|
|
8
8
|
import { FolioDocumentOperationBatch, FolioDocumentOperationResult, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult } from "../document-operations.js";
|
|
9
9
|
import { FolioPendingSuggestionLoadResult, FolioPendingSuggestionRecord } from "./pending-suggestions.js";
|
|
10
|
-
import { FolioReviewChange, FolioReviewChangeKind } from "./read.js";
|
|
10
|
+
import { FolioReviewChange, FolioReviewChangeKind, FolioReviewResolution, FolioReviewResolutionSkip } from "./read.js";
|
|
11
11
|
import { FolioStoryTable } from "./snapshot.js";
|
|
12
12
|
import { TableGeometryPairing } from "./table-geometry.js";
|
|
13
13
|
import { Node } from "prosemirror-model";
|
|
14
14
|
import { TaggedErrorClass } from "better-result";
|
|
15
|
+
/**
|
|
16
|
+
* How many document-operation batches a reviewer can step back through.
|
|
17
|
+
* Each entry holds the story's state before and after its batch; older
|
|
18
|
+
* entries are dropped, as an editor's undo history drops its oldest steps.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FOLIO_DOCUMENT_OPERATION_UNDO_LIMIT = 100;
|
|
15
21
|
/** Options for {@link FolioDocxReviewer.fromBuffer}. */
|
|
16
22
|
export type FolioDocxReviewerOptions = {
|
|
17
23
|
/** Default author for tracked changes and comments. (default: `"AI"`) */
|
|
@@ -319,21 +325,6 @@ export type FolioReviewCommentFilter = {
|
|
|
319
325
|
author?: string;
|
|
320
326
|
done?: boolean;
|
|
321
327
|
};
|
|
322
|
-
/**
|
|
323
|
-
* Headless `.docx` reviewer. Parse a buffer, read blocks, apply
|
|
324
|
-
* `FolioAIEditOperation`s against the document model, and write the reviewed
|
|
325
|
-
* `.docx` back out — no editor instance, no DOM.
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```ts
|
|
329
|
-
* const reviewer = await FolioDocxReviewer.fromBuffer(buffer, { author: "AI" });
|
|
330
|
-
* const { blocks } = reviewer.snapshot();
|
|
331
|
-
* reviewer.applyOperations([
|
|
332
|
-
* { id: "1", type: "replaceInBlock", blockId: blocks[0].id, find: "$50k", replace: "$500k" },
|
|
333
|
-
* ], { undefinedReferences: "refuse" });
|
|
334
|
-
* const reviewed = await reviewer.toBuffer();
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
328
|
export declare class FolioDocxReviewer {
|
|
338
329
|
/** Default author for tracked changes and comments. */
|
|
339
330
|
readonly author: string;
|
|
@@ -405,8 +396,14 @@ export declare class FolioDocxReviewer {
|
|
|
405
396
|
* renumbered — which is right for an insertion that renumbers the items
|
|
406
397
|
* below it, and wrong for a list whose FORMAT changed. Sorted so two
|
|
407
398
|
* packages can be compared entry by entry.
|
|
399
|
+
*
|
|
400
|
+
* Read for one story (the main one by default): a header, footer or note
|
|
401
|
+
* starts its lists against the package alone, so the lists it started are
|
|
402
|
+
* defined in its own reading, as its labels are, and in no other story's.
|
|
408
403
|
*/
|
|
409
404
|
readNumberingDefinitions(): FolioNumberingLevel[];
|
|
405
|
+
/** `null` when the document has no such story. */
|
|
406
|
+
readNumberingDefinitions(story: FolioEditableDocumentStoryHandle): FolioNumberingLevel[] | null;
|
|
410
407
|
/** Return parsed package metadata without exposing the mutable document model. */
|
|
411
408
|
getDocumentProperties(): Readonly<NonNullable<document_d_exports.Document["package"]["properties"]>> | null;
|
|
412
409
|
/** Snapshot one editable story into stable, operation-ready blocks. */
|
|
@@ -459,7 +456,11 @@ export declare class FolioDocxReviewer {
|
|
|
459
456
|
/** Apply a batch; the notes whose references it deletes or removes follow them. */
|
|
460
457
|
private applyDocumentOperationsInternal;
|
|
461
458
|
private applyDocumentOperationsToStoryState;
|
|
462
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* Undo the latest unchanged document-operation batch and its created
|
|
461
|
+
* comments. Only the last {@link FOLIO_DOCUMENT_OPERATION_UNDO_LIMIT}
|
|
462
|
+
* batches are kept; an older handle is `unknownHandle`.
|
|
463
|
+
*/
|
|
463
464
|
undoDocumentOperations(undoHandle: FolioDocumentOperationUndoHandle): FolioDocumentOperationUndoResult;
|
|
464
465
|
/**
|
|
465
466
|
* The body blocks with their stable ids, in document order — the same
|
|
@@ -551,7 +552,10 @@ export declare class FolioDocxReviewer {
|
|
|
551
552
|
* redline. Pass a {@link FolioReviewChange} from {@link getChanges} or its
|
|
552
553
|
* revision id. Reuses the editor's own accept command headlessly, so the
|
|
553
554
|
* resolved state persists on {@link toBuffer}. Returns `false` when the
|
|
554
|
-
* revision is no longer present (already resolved, or never existed)
|
|
555
|
+
* revision is no longer present (already resolved, or never existed), or
|
|
556
|
+
* when a content control's lock holds it: accepting would change a
|
|
557
|
+
* content-locked control's content or remove a control locked against
|
|
558
|
+
* removal. A held change stays pending as it is.
|
|
555
559
|
*/
|
|
556
560
|
acceptChange(target: FolioReviewChange | number): boolean;
|
|
557
561
|
private acceptChangeInternal;
|
|
@@ -575,10 +579,15 @@ export declare class FolioDocxReviewer {
|
|
|
575
579
|
* Every story, not just the body: a revision in a header or a footnote is
|
|
576
580
|
* one a reviewer meant to resolve, and leaving it behind means an accepted
|
|
577
581
|
* document still carries a redline nobody can see from the body.
|
|
582
|
+
*
|
|
583
|
+
* A change a content control's lock holds (see {@link acceptChange}) stays
|
|
584
|
+
* pending as it is and is listed in `skipped`; `resolved` counts the
|
|
585
|
+
* ordinary changes resolved.
|
|
578
586
|
*/
|
|
579
|
-
acceptAll():
|
|
587
|
+
acceptAll(): FolioReviewResolution;
|
|
580
588
|
/** Reject every tracked change in the package. See {@link acceptAll}. */
|
|
581
|
-
rejectAll():
|
|
589
|
+
rejectAll(): FolioReviewResolution;
|
|
590
|
+
private resolveAll;
|
|
582
591
|
private resolveWithSectionReferenceHistory;
|
|
583
592
|
private resolveEveryFinalSectionChange;
|
|
584
593
|
private resolveEveryStory;
|
|
@@ -598,6 +607,12 @@ export declare class FolioDocxReviewer {
|
|
|
598
607
|
*/
|
|
599
608
|
private noteKeysReferencedOutsideBody;
|
|
600
609
|
private resolveEveryStoryOnce;
|
|
610
|
+
/**
|
|
611
|
+
* Resolve each change of a story a content control's lock does not hold, on
|
|
612
|
+
* its own: the one-pass resolver takes the whole story or nothing. The held
|
|
613
|
+
* changes stay pending as they are and are reported in `skipped`.
|
|
614
|
+
*/
|
|
615
|
+
private resolveStoryAroundHeldChanges;
|
|
601
616
|
private acceptOrdinaryChangesWithSuggestions;
|
|
602
617
|
/** Resolve ordinary revisions on a detached in-memory document. */
|
|
603
618
|
toResolvedDocument(decision: "accept" | "reject"): document_d_exports.Document;
|
|
@@ -711,4 +726,4 @@ export type ApplyFolioAIEditsToBufferResult = FolioAIEditApplyResult & {
|
|
|
711
726
|
* operations to run.
|
|
712
727
|
*/
|
|
713
728
|
export declare const applyFolioAIEditsToBuffer: (buffer: ArrayBuffer, operations: FolioAIEditOperation[], options?: ApplyFolioAIEditsToBufferOptions) => Promise<ApplyFolioAIEditsToBufferResult>;
|
|
714
|
-
export type { FolioReviewChange, FolioReviewChangeKind, FolioRevisionStamp };
|
|
729
|
+
export type { FolioReviewChange, FolioReviewChangeKind, FolioReviewResolution, FolioReviewResolutionSkip, FolioRevisionStamp };
|