@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
|
@@ -5,6 +5,7 @@ import { restoreCanonicalSelection } from "../canonical/canonicalSelection.js";
|
|
|
5
5
|
import { CanonicalSessionError, createCanonicalSession, publishCanonicalProjection } from "../canonical/canonicalSession.js";
|
|
6
6
|
import { derivedFieldOps, fieldInsertionParagraph } from "../canonical/derivedFields.js";
|
|
7
7
|
import { parseDocx } from "../docx/parser.js";
|
|
8
|
+
import { clipboardTransformPlugin } from "../internal/clipboardTransformPlugin.js";
|
|
8
9
|
import { editingFontContextOf, editingFontFamily } from "../layout-bridge/convert/editingFont.js";
|
|
9
10
|
import { recordHiddenEditorPhase, recordHiddenEditorStateCreate } from "../layout-engine/layoutInstrumentation.js";
|
|
10
11
|
import { suppressHiddenEditorScrollToSelection } from "../paged-layout/hiddenEditorScroll.js";
|
|
@@ -17,18 +18,18 @@ import { createCommentRecordsPlugin, isCommentRecordsSync } from "../prosemirror
|
|
|
17
18
|
import { createEmptyDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
18
19
|
import { registerEditorCommandOwner } from "../prosemirror/executeEditorCommand.js";
|
|
19
20
|
import { ensureBaseDirectionInState } from "../prosemirror/extensions/features/AutoBidiDetectionExtension.js";
|
|
20
|
-
import { ensureParaIdsInDoc } from "../prosemirror/extensions/features/ParaIdAllocatorExtension.js";
|
|
21
21
|
import { toggleMarkForAllScripts, toggleUnderlineMark } from "../prosemirror/extensions/marks/markUtils.js";
|
|
22
22
|
import { HyperlinkRemovalRefusal } from "../prosemirror/hyperlinkRemoval.js";
|
|
23
23
|
import { REVISION_MARK_NAMES } from "../prosemirror/keptRangeBoundaries.js";
|
|
24
24
|
import { adoptNativeSelection, createNativeNavigationPlugin, createNativeSelectionRefreshPlugin, isCompositionKeyDown } from "../prosemirror/nativeSelection.js";
|
|
25
25
|
import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
26
|
+
import { ensureParaIdsInDoc } from "../prosemirror/paraIds.js";
|
|
26
27
|
import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
|
|
27
28
|
import { createDocumentStyleContextPlugin, createDocumentStylesPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
28
29
|
import { schema } from "../prosemirror/schema/index.js";
|
|
29
|
-
import { createTextInputPlugin } from "../prosemirror/textInput.js";
|
|
30
30
|
import { CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
31
31
|
import { readModel } from "../types/documentModel.js";
|
|
32
|
+
import { INTERNAL_CLIPBOARD_TYPE } from "../utils/clipboard.js";
|
|
32
33
|
import { NO_ANONYMIZATION_TERMS, createAnonymizationHighlights } from "./anonymizationHighlights.js";
|
|
33
34
|
import { canTriggerAutocomplete, classifyAutocompleteEdit, createAutocompleteSuggestion, nextAutocompleteWord } from "./autocompleteSuggestion.js";
|
|
34
35
|
import { prepareCanonicalPaste } from "./canonicalClipboard.js";
|
|
@@ -38,10 +39,10 @@ import { isCanonicalListParagraph, prepareCanonicalAutoformat, prepareCanonicalC
|
|
|
38
39
|
import { createHiddenEditorApi } from "./hiddenEditorApi.js";
|
|
39
40
|
import { handleReadOnlySelectionKeyDown } from "./readOnlySelection.js";
|
|
40
41
|
import { Result, TaggedError } from "better-result";
|
|
41
|
-
import { DOMParser, DOMSerializer } from "prosemirror-model";
|
|
42
|
-
import { CellSelection } from "prosemirror-tables";
|
|
43
42
|
import { OP_STORIES, documentStories, freshCommentId, sameStory } from "@stll/docx-core/ops";
|
|
44
|
-
import { EditorState, Plugin } from "prosemirror-state";
|
|
43
|
+
import { EditorState, Plugin, Selection } from "prosemirror-state";
|
|
44
|
+
import { CellSelection } from "prosemirror-tables";
|
|
45
|
+
import { DOMParser, DOMSerializer } from "prosemirror-model";
|
|
45
46
|
import { EditorView } from "prosemirror-view";
|
|
46
47
|
// src/controller/hiddenEditorManager.ts
|
|
47
48
|
/**
|
|
@@ -107,7 +108,6 @@ function createHiddenEditorState(options) {
|
|
|
107
108
|
createDocumentNumberingPlugin(document?.package.numbering),
|
|
108
109
|
createCommentRecordsPlugin(document?.package.document.comments ?? []),
|
|
109
110
|
...externalPlugins,
|
|
110
|
-
...manager?.getPlugins() ?? [createTextInputPlugin()],
|
|
111
111
|
styleResolverPlugin
|
|
112
112
|
];
|
|
113
113
|
const startedAt = performance.now();
|
|
@@ -267,12 +267,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
267
267
|
createNativeNavigationPlugin(),
|
|
268
268
|
createDocumentStyleContextPlugin(deps.getStyles() ?? document.package.styles),
|
|
269
269
|
new Plugin({ props: { clipboardTextParser: parseCanonicalClipboardText } }),
|
|
270
|
-
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) =>
|
|
271
|
-
...props.transformCopied === void 0 ? {} : { transformCopied: props.transformCopied },
|
|
272
|
-
...props.clipboardTextSerializer === void 0 ? {} : { clipboardTextSerializer: props.clipboardTextSerializer },
|
|
273
|
-
...props.transformPastedHTML === void 0 ? {} : { transformPastedHTML: props.transformPastedHTML },
|
|
274
|
-
...props.transformPasted === void 0 ? {} : { transformPasted: props.transformPasted }
|
|
275
|
-
} })]),
|
|
270
|
+
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) => clipboardTransformPlugin(props)),
|
|
276
271
|
...deps.getExternalPlugins().flatMap(({ spec }) => spec.view === void 0 ? [] : [new Plugin({ view: spec.view })])
|
|
277
272
|
]
|
|
278
273
|
});
|
|
@@ -532,6 +527,29 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
532
527
|
return publishCommit(prepared.value);
|
|
533
528
|
};
|
|
534
529
|
let clipboardDrag = { type: "idle" };
|
|
530
|
+
let clipboardCopy = { type: "none" };
|
|
531
|
+
/**
|
|
532
|
+
* Write the selection to the clipboard once, under a token minted for this
|
|
533
|
+
* copy alone, and return what was written.
|
|
534
|
+
*/
|
|
535
|
+
const writeClipboard = (pmView, data) => {
|
|
536
|
+
const serialized = pmView.serializeForClipboard(pmView.state.selection.content());
|
|
537
|
+
const html = serialized.dom.innerHTML;
|
|
538
|
+
const token = crypto.randomUUID();
|
|
539
|
+
data.setData("text/html", html);
|
|
540
|
+
data.setData("text/plain", serialized.text);
|
|
541
|
+
data.setData(INTERNAL_CLIPBOARD_TYPE, token);
|
|
542
|
+
return {
|
|
543
|
+
html,
|
|
544
|
+
token
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
/** The copied document, when the pasted clipboard is the editor's own copy. */
|
|
548
|
+
const copiedSource = (event) => {
|
|
549
|
+
const data = event.clipboardData;
|
|
550
|
+
if (clipboardCopy.type !== "copied" || data === null) return {};
|
|
551
|
+
return data.getData("application/x-stella-folio") === clipboardCopy.token && data.getData("text/html").includes(clipboardCopy.html) ? { sourceDocument: clipboardCopy.document } : {};
|
|
552
|
+
};
|
|
535
553
|
let lastInputRule;
|
|
536
554
|
const canonicalStructuralInput = {
|
|
537
555
|
command: (name) => {
|
|
@@ -717,6 +735,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
717
735
|
return true;
|
|
718
736
|
}
|
|
719
737
|
syncCanonicalMode();
|
|
738
|
+
const source = readModel(editorSession.session.document);
|
|
720
739
|
const session = editorSession.session;
|
|
721
740
|
const { from, to } = pmView.state.selection;
|
|
722
741
|
const prepared = session.prepareReplace(pmView.state, {
|
|
@@ -729,19 +748,24 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
729
748
|
refuse(prepared.error.message, prepared.error.ground);
|
|
730
749
|
return true;
|
|
731
750
|
}
|
|
751
|
+
const data = event.clipboardData;
|
|
732
752
|
const copied = Result.try({
|
|
733
|
-
try: () =>
|
|
734
|
-
const serialized = pmView.serializeForClipboard(pmView.state.selection.content());
|
|
735
|
-
event.clipboardData?.setData("text/html", serialized.dom.innerHTML);
|
|
736
|
-
event.clipboardData?.setData("text/plain", serialized.text);
|
|
737
|
-
},
|
|
753
|
+
try: () => writeClipboard(pmView, data),
|
|
738
754
|
catch: () => new CanonicalSessionRefusalError({
|
|
739
755
|
ground: { gap: CANONICAL_GAP.dispatch },
|
|
740
756
|
message: "The clipboard could not receive the cut content."
|
|
741
757
|
})
|
|
742
758
|
});
|
|
743
|
-
if (copied.isErr())
|
|
744
|
-
|
|
759
|
+
if (copied.isErr()) {
|
|
760
|
+
refuse(copied.error.message, copied.error.ground);
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
clipboardCopy = {
|
|
764
|
+
type: "copied",
|
|
765
|
+
document: source,
|
|
766
|
+
...copied.value
|
|
767
|
+
};
|
|
768
|
+
publishCommit(prepared.value);
|
|
745
769
|
return true;
|
|
746
770
|
},
|
|
747
771
|
...canonicalInputLifecycle,
|
|
@@ -837,7 +861,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
837
861
|
},
|
|
838
862
|
handleTextInput: (pmView, from, to, text) => editorSession.type === "canonical" ? input.handleTextInput(pmView, from, to, text) : false,
|
|
839
863
|
handleKeyPress: (pmView, event) => editorSession.type === "canonical" && !deps.getReadOnly() && input.handleKeyPress(pmView, event),
|
|
840
|
-
handlePaste: (pmView,
|
|
864
|
+
handlePaste: (pmView, event, slice) => {
|
|
841
865
|
if (editorSession.type !== "canonical") return false;
|
|
842
866
|
if (deps.getReadOnly()) {
|
|
843
867
|
deps.onReadOnlyEditAttempt();
|
|
@@ -847,7 +871,8 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
847
871
|
const prepared = prepareCanonicalPaste({
|
|
848
872
|
session: editorSession.session,
|
|
849
873
|
state: pmView.state,
|
|
850
|
-
slice
|
|
874
|
+
slice,
|
|
875
|
+
...copiedSource(event)
|
|
851
876
|
});
|
|
852
877
|
if (prepared.isErr()) {
|
|
853
878
|
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
@@ -906,6 +931,27 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
906
931
|
focus: () => false,
|
|
907
932
|
blur: (pmView) => editorSession.type === "canonical" ? input.handleDOMEvents.blur(pmView) : false,
|
|
908
933
|
...createHiddenEditorClipboardHandlers(deps),
|
|
934
|
+
copy: (pmView, event) => {
|
|
935
|
+
const data = event.clipboardData;
|
|
936
|
+
if (editorSession.type !== "canonical" || data === null || pmView.state.selection.empty) {
|
|
937
|
+
clipboardCopy = { type: "none" };
|
|
938
|
+
return createHiddenEditorClipboardHandlers(deps).copy();
|
|
939
|
+
}
|
|
940
|
+
const source = readModel(editorSession.session.document);
|
|
941
|
+
const written = Result.try(() => writeClipboard(pmView, data));
|
|
942
|
+
if (written.isErr()) {
|
|
943
|
+
clipboardCopy = { type: "none" };
|
|
944
|
+
return createHiddenEditorClipboardHandlers(deps).copy();
|
|
945
|
+
}
|
|
946
|
+
event.preventDefault();
|
|
947
|
+
clipboardCopy = {
|
|
948
|
+
type: "copied",
|
|
949
|
+
document: source,
|
|
950
|
+
...written.value
|
|
951
|
+
};
|
|
952
|
+
deps.onCopy?.();
|
|
953
|
+
return true;
|
|
954
|
+
},
|
|
909
955
|
compositionstart: (pmView) => editorSession.type === "canonical" ? input.handleDOMEvents.compositionstart(pmView) : false,
|
|
910
956
|
compositionend: (pmView, event) => editorSession.type === "canonical" ? input.handleDOMEvents.compositionend(pmView, event) : false,
|
|
911
957
|
input: (pmView) => editorSession.type === "canonical" ? input.handleDOMEvents.input(pmView) : false,
|
|
@@ -1272,8 +1318,18 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1272
1318
|
case "selection": {
|
|
1273
1319
|
const projection = session.projectStory(request.anchor.story);
|
|
1274
1320
|
if (projection.isErr()) return fail(projection.error.message);
|
|
1275
|
-
const
|
|
1276
|
-
const
|
|
1321
|
+
const { doc } = projection.value;
|
|
1322
|
+
const textEdge = (position, bias) => {
|
|
1323
|
+
if (position < 0 || position > doc.content.size) return position;
|
|
1324
|
+
const resolved = doc.resolve(position);
|
|
1325
|
+
if (resolved.parent.isTextblock) return position;
|
|
1326
|
+
const found = Selection.findFrom(resolved, bias, true);
|
|
1327
|
+
if (found === null) return position;
|
|
1328
|
+
return bias > 0 ? found.from : found.to;
|
|
1329
|
+
};
|
|
1330
|
+
const collapsed = request.anchor.from === request.anchor.to;
|
|
1331
|
+
const from = projection.value.addressAt(collapsed ? request.anchor.from : textEdge(request.anchor.from, 1));
|
|
1332
|
+
const to = projection.value.addressAt(collapsed ? request.anchor.to : textEdge(request.anchor.to, -1));
|
|
1277
1333
|
if (from.isErr()) return fail(from.error.message);
|
|
1278
1334
|
if (to.isErr()) return fail(to.error.message);
|
|
1279
1335
|
anchor = request.anchor.from === request.anchor.to ? {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FolioAIEditView, FolioReplacementBackground, FolioRevisionStamp, FolioWordDiffOptions } from "./ai-edits/
|
|
1
|
+
import { FolioAIEditView, FolioReplacementBackground, FolioRevisionStamp, FolioWordDiffOptions } from "./ai-edits/applyTypes.js";
|
|
2
2
|
import { FolioTableTemplates } from "./ai-edits/table-template.js";
|
|
3
3
|
import { FolioAIEditAppliedOperation, FolioAIEditApplyMode, FolioAIEditNormalization, FolioAIEditOperation, FolioAIEditPrecondition, FolioAIEditSkippedOperation, FolioAIEditSnapshot, FolioAINewListReference, FolioAITextRangeHandle } from "./ai-edits/types.js";
|
|
4
4
|
import { FolioUndefinedReferencePolicy } from "./ai-edits/undefinedReferences.js";
|
|
5
|
-
import { NumberingIdsInUse } from "./docx/numberingIds.js";
|
|
6
5
|
import { document_d_exports } from "./types/document.js";
|
|
7
6
|
import { TaggedErrorClass } from "better-result";
|
|
8
7
|
export declare const FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION: 1;
|
|
@@ -352,16 +351,4 @@ export type ApplyFolioDocumentOperationsOptions = {
|
|
|
352
351
|
* by that id follows it.
|
|
353
352
|
*/
|
|
354
353
|
export declare const withDistinctSuggestionIds: (batch: FolioDocumentOperationBatch, pending: ReadonlySet<string>) => FolioDocumentOperationBatch;
|
|
355
|
-
export declare const applyFolioDocumentOperations: (input: ApplyFolioDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
356
|
-
/**
|
|
357
|
-
* Options of a caller that holds every story of the package: the numbering
|
|
358
|
-
* ids (`w:num`, `w:abstractNum`) the other stories define. A list the batch
|
|
359
|
-
* starts takes none of them, so its id names it in every story and survives a
|
|
360
|
-
* save.
|
|
361
|
-
*/
|
|
362
|
-
type ApplyFolioDocumentOperationsInPackageOptions = ApplyFolioDocumentOperationsOptions & {
|
|
363
|
-
numberingIdsElsewhere: NumberingIdsInUse;
|
|
364
|
-
};
|
|
365
|
-
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
366
|
-
export declare const applyFolioDocumentOperationsInPackage: ({ view, snapshot, batch, story, author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }: ApplyFolioDocumentOperationsInPackageOptions) => FolioDocumentOperationResult;
|
|
367
354
|
export {};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { applyFolioAIEditOperationsInPackage, previewFolioAIEditOperationsWithResult } from "./ai-edits/apply.js";
|
|
2
1
|
import { compileMarkdownTableRows } from "./ai-edits/markdownInsertion.js";
|
|
3
|
-
import { describeModelError, findIntroducedModelErrors } from "./ai-edits/result-validation.js";
|
|
4
2
|
import { TABLE_INSERTION_MODES } from "./ai-edits/tableInsertionModes.js";
|
|
5
|
-
import { trackedBatchFidelityError } from "./ai-edits/tracked-batch-fidelity.js";
|
|
6
3
|
import { LIST_KINDS } from "./docx/listNumberingInstances.js";
|
|
7
|
-
import { NO_NUMBERING_IDS_IN_USE } from "./docx/numberingIds.js";
|
|
8
4
|
import "./docx/tableParser.js";
|
|
9
|
-
import { getSuggestions } from "./prosemirror/commands/comments.js";
|
|
10
|
-
import { completeNumberingForDoc } from "./prosemirror/listInstanceReferences.js";
|
|
11
5
|
import { outlineLevelFromAttrValue } from "./prosemirror/outlineLevelAttr.js";
|
|
12
|
-
import { getStatedDocumentNumbering } from "./prosemirror/plugins/documentNumbering.js";
|
|
13
6
|
import { HIGHLIGHT_COLOR_VALUES, LINE_SPACING_RULE_VALUES, PARAGRAPH_ALIGNMENT_VALUES } from "./types/documentEnumValues.js";
|
|
14
7
|
import { TaggedError } from "better-result";
|
|
15
8
|
import { sanitizeXmlCharacters } from "@stll/docx-core";
|
|
@@ -1386,274 +1379,4 @@ const withDistinctSuggestionIds = (batch, pending) => {
|
|
|
1386
1379
|
})
|
|
1387
1380
|
};
|
|
1388
1381
|
};
|
|
1389
|
-
|
|
1390
|
-
/** Skips reported in the order of the operations they belong to. */
|
|
1391
|
-
const inOperationOrder = (operations, skipped) => {
|
|
1392
|
-
const indexById = new Map(operations.map(({ id }, index) => [id, index]));
|
|
1393
|
-
return [...skipped].sort((left, right) => (indexById.get(left.id) ?? -1) - (indexById.get(right.id) ?? -1));
|
|
1394
|
-
};
|
|
1395
|
-
const applyFolioDocumentOperations = (input) => applyFolioDocumentOperationsInPackage({
|
|
1396
|
-
...input,
|
|
1397
|
-
numberingIdsElsewhere: NO_NUMBERING_IDS_IN_USE
|
|
1398
|
-
});
|
|
1399
|
-
/** {@link applyFolioDocumentOperations} for a caller holding every story. Internal. */
|
|
1400
|
-
const applyFolioDocumentOperationsInPackage = ({ view, snapshot, batch, story = "main", author, createCommentId, createUndoHandle, revisionStamp, wordDiff, tableTemplates, replacementBackground, undefinedReferences, pendingSuggestionIds, numberingIdsElsewhere, restagesSuggestions }) => {
|
|
1401
|
-
const validatedBatch = parseFolioDocumentOperationBatch(batch);
|
|
1402
|
-
const parsedBatch = restagesSuggestions === true ? validatedBatch : withDistinctSuggestionIds(validatedBatch, /* @__PURE__ */ new Set([...getSuggestions(view.state).map(({ suggestionId }) => suggestionId), ...pendingSuggestionIds ?? []]));
|
|
1403
|
-
const isAtomic = parsedBatch.atomic === true;
|
|
1404
|
-
const beforeDoc = view.state.doc;
|
|
1405
|
-
const packageNumbering = getStatedDocumentNumbering(view.state);
|
|
1406
|
-
const attempt = (operations, preview) => {
|
|
1407
|
-
const common = {
|
|
1408
|
-
snapshot,
|
|
1409
|
-
operations,
|
|
1410
|
-
mode: parsedBatch.mode ?? "tracked-changes",
|
|
1411
|
-
...parsedBatch.existingRevisions === "refuse-cross-author" && { refuseCrossAuthorRevisions: true },
|
|
1412
|
-
...author !== void 0 && { author },
|
|
1413
|
-
...revisionStamp !== void 0 && { revisionStamp },
|
|
1414
|
-
...wordDiff !== void 0 && { wordDiff },
|
|
1415
|
-
...tableTemplates !== void 0 && { tableTemplates },
|
|
1416
|
-
...replacementBackground !== void 0 && { replacementBackground },
|
|
1417
|
-
numberingIdsElsewhere,
|
|
1418
|
-
undefinedReferences
|
|
1419
|
-
};
|
|
1420
|
-
if (preview) return {
|
|
1421
|
-
...previewFolioAIEditOperationsWithResult({
|
|
1422
|
-
...common,
|
|
1423
|
-
view,
|
|
1424
|
-
...createCommentId !== void 0 && { createCommentId }
|
|
1425
|
-
}, parsedBatch.dryRun && common.mode === "tracked-changes" ? "bounded" : "coarse"),
|
|
1426
|
-
commit: NO_COMMIT
|
|
1427
|
-
};
|
|
1428
|
-
const held = {};
|
|
1429
|
-
const commentIds = [];
|
|
1430
|
-
return {
|
|
1431
|
-
outcome: applyFolioAIEditOperationsInPackage({
|
|
1432
|
-
...common,
|
|
1433
|
-
view: {
|
|
1434
|
-
state: view.state,
|
|
1435
|
-
dispatch: (transaction) => {
|
|
1436
|
-
held.transaction = transaction;
|
|
1437
|
-
}
|
|
1438
|
-
},
|
|
1439
|
-
...createCommentId !== void 0 && { createCommentId: (text) => {
|
|
1440
|
-
const id = createCommentId(text);
|
|
1441
|
-
commentIds.push(id);
|
|
1442
|
-
return id;
|
|
1443
|
-
} }
|
|
1444
|
-
}),
|
|
1445
|
-
doc: held.transaction?.doc ?? null,
|
|
1446
|
-
commentIds,
|
|
1447
|
-
commit: () => {
|
|
1448
|
-
if (held.transaction !== void 0) view.dispatch(held.transaction);
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
};
|
|
1452
|
-
const introducedErrors = (run) => {
|
|
1453
|
-
if (run.doc === null || run.outcome.applied.length === 0) return [];
|
|
1454
|
-
const numbering = packageNumbering === void 0 ? void 0 : completeNumberingForDoc(packageNumbering ?? void 0, run.doc) ?? null;
|
|
1455
|
-
return findIntroducedModelErrors(beforeDoc, run.doc, {
|
|
1456
|
-
numbering,
|
|
1457
|
-
createdCommentIds: run.commentIds,
|
|
1458
|
-
...author !== void 0 && { commentAuthor: author }
|
|
1459
|
-
});
|
|
1460
|
-
};
|
|
1461
|
-
/**
|
|
1462
|
-
* An attempt on the refusal path, where the applier runs on subsets of the
|
|
1463
|
-
* batch it was not asked to apply: a throw there is one more reason to
|
|
1464
|
-
* refuse, never a reason to fail a batch the first run could apply.
|
|
1465
|
-
*/
|
|
1466
|
-
const checkedAttempt = (operations, preview) => {
|
|
1467
|
-
try {
|
|
1468
|
-
const run = attempt(operations, preview);
|
|
1469
|
-
return {
|
|
1470
|
-
run,
|
|
1471
|
-
error: introducedErrors(run)[0]
|
|
1472
|
-
};
|
|
1473
|
-
} catch (error) {
|
|
1474
|
-
return {
|
|
1475
|
-
run: null,
|
|
1476
|
-
error: {
|
|
1477
|
-
path: "package.document",
|
|
1478
|
-
message: `the operation could not be applied (${error instanceof Error ? error.message : String(error)}).`,
|
|
1479
|
-
severity: "error"
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
}
|
|
1483
|
-
};
|
|
1484
|
-
/**
|
|
1485
|
-
* Which applied operations produced the unsaveable result: each one is
|
|
1486
|
-
* previewed alone against the unchanged story. When none fails alone, the
|
|
1487
|
-
* failure is their combination, and every one of them is refused.
|
|
1488
|
-
*/
|
|
1489
|
-
const refuseInvalidResult = (run, firstError) => {
|
|
1490
|
-
const operationsById = new Map(parsedBatch.operations.map((operation) => [operation.id, operation]));
|
|
1491
|
-
const refused = [];
|
|
1492
|
-
for (const { id } of run.outcome.applied) {
|
|
1493
|
-
const operation = operationsById.get(id);
|
|
1494
|
-
if (operation === void 0) continue;
|
|
1495
|
-
const alone = checkedAttempt([operation], true).error;
|
|
1496
|
-
if (alone !== void 0) refused.push({
|
|
1497
|
-
id,
|
|
1498
|
-
reason: "invalidResult",
|
|
1499
|
-
message: describeModelError(alone)
|
|
1500
|
-
});
|
|
1501
|
-
}
|
|
1502
|
-
if (refused.length > 0) return refused;
|
|
1503
|
-
return run.outcome.applied.map(({ id }) => ({
|
|
1504
|
-
id,
|
|
1505
|
-
reason: "invalidResult",
|
|
1506
|
-
message: describeModelError(firstError)
|
|
1507
|
-
}));
|
|
1508
|
-
};
|
|
1509
|
-
/**
|
|
1510
|
-
* A fidelity failure invalidates the batch. Preserve the refusal details
|
|
1511
|
-
* for operations already skipped by the applier or save-time validator.
|
|
1512
|
-
*/
|
|
1513
|
-
const refuseFidelityLoss = (run, skipped = []) => {
|
|
1514
|
-
if (run.doc === null || parsedBatch.mode === "direct" || parsedBatch.mode === "suggested") return null;
|
|
1515
|
-
const message = trackedBatchFidelityError({
|
|
1516
|
-
before: view.state,
|
|
1517
|
-
after: run.doc,
|
|
1518
|
-
createdCommentIds: run.commentIds,
|
|
1519
|
-
retiredCommentIds: run.outcome.applied.flatMap(({ retiredCommentIds }) => retiredCommentIds ?? [])
|
|
1520
|
-
});
|
|
1521
|
-
if (message === null) return null;
|
|
1522
|
-
return {
|
|
1523
|
-
fidelityRefused: true,
|
|
1524
|
-
outcome: {
|
|
1525
|
-
...run.outcome,
|
|
1526
|
-
applied: [],
|
|
1527
|
-
skipped: inOperationOrder(parsedBatch.operations, [
|
|
1528
|
-
...run.outcome.skipped,
|
|
1529
|
-
...skipped,
|
|
1530
|
-
...run.outcome.applied.map(({ id }) => ({
|
|
1531
|
-
id,
|
|
1532
|
-
reason: "invalidResult",
|
|
1533
|
-
message
|
|
1534
|
-
}))
|
|
1535
|
-
])
|
|
1536
|
-
},
|
|
1537
|
-
commit: NO_COMMIT
|
|
1538
|
-
};
|
|
1539
|
-
};
|
|
1540
|
-
/** Check the held result before dispatching any operation to the caller. */
|
|
1541
|
-
const guardedAttempt = (preview) => {
|
|
1542
|
-
const first = attempt(parsedBatch.operations, preview);
|
|
1543
|
-
const [firstError] = introducedErrors(first);
|
|
1544
|
-
if (firstError === void 0) {
|
|
1545
|
-
const fidelity = preview && !parsedBatch.dryRun ? null : refuseFidelityLoss(first);
|
|
1546
|
-
if (fidelity !== null) return fidelity;
|
|
1547
|
-
return {
|
|
1548
|
-
outcome: {
|
|
1549
|
-
...first.outcome,
|
|
1550
|
-
skipped: inOperationOrder(parsedBatch.operations, first.outcome.skipped)
|
|
1551
|
-
},
|
|
1552
|
-
commit: first.commit
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
const refused = refuseInvalidResult(first, firstError);
|
|
1556
|
-
const refusedIds = new Set(refused.map(({ id }) => id));
|
|
1557
|
-
if (isAtomic) return {
|
|
1558
|
-
outcome: {
|
|
1559
|
-
...first.outcome,
|
|
1560
|
-
applied: [],
|
|
1561
|
-
skipped: inOperationOrder(parsedBatch.operations, [...first.outcome.skipped, ...refused])
|
|
1562
|
-
},
|
|
1563
|
-
commit: NO_COMMIT
|
|
1564
|
-
};
|
|
1565
|
-
const second = checkedAttempt(parsedBatch.operations.filter(({ id }) => !refusedIds.has(id)), preview);
|
|
1566
|
-
if (second.run === null || second.error !== void 0) {
|
|
1567
|
-
const reported = second.run?.outcome ?? first.outcome;
|
|
1568
|
-
return {
|
|
1569
|
-
outcome: {
|
|
1570
|
-
...reported,
|
|
1571
|
-
applied: [],
|
|
1572
|
-
skipped: inOperationOrder(parsedBatch.operations, [
|
|
1573
|
-
...reported.skipped.filter(({ id }) => !refusedIds.has(id)),
|
|
1574
|
-
...refused,
|
|
1575
|
-
...reported.applied.filter(({ id }) => !refusedIds.has(id)).map(({ id }) => ({
|
|
1576
|
-
id,
|
|
1577
|
-
reason: "invalidResult",
|
|
1578
|
-
message: describeModelError(second.error ?? firstError)
|
|
1579
|
-
}))
|
|
1580
|
-
])
|
|
1581
|
-
},
|
|
1582
|
-
commit: NO_COMMIT
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
|
-
const fidelity = refuseFidelityLoss(second.run, refused);
|
|
1586
|
-
if (fidelity !== null) return fidelity;
|
|
1587
|
-
return {
|
|
1588
|
-
outcome: {
|
|
1589
|
-
...second.run.outcome,
|
|
1590
|
-
skipped: inOperationOrder(parsedBatch.operations, [...second.run.outcome.skipped, ...refused])
|
|
1591
|
-
},
|
|
1592
|
-
commit: second.run.commit
|
|
1593
|
-
};
|
|
1594
|
-
};
|
|
1595
|
-
const preview = () => guardedAttempt(true).outcome;
|
|
1596
|
-
const atomicResult = (previewResult, status) => {
|
|
1597
|
-
const skippedById = new Map(previewResult.skipped.map((operation) => [operation.id, operation]));
|
|
1598
|
-
const skipped = parsedBatch.operations.map(({ id }) => skippedById.get(id) ?? {
|
|
1599
|
-
id,
|
|
1600
|
-
reason: "atomicBatchRejected"
|
|
1601
|
-
});
|
|
1602
|
-
return {
|
|
1603
|
-
version: 1,
|
|
1604
|
-
status,
|
|
1605
|
-
applied: [],
|
|
1606
|
-
skipped,
|
|
1607
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, skipped),
|
|
1608
|
-
receipts: [],
|
|
1609
|
-
...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
|
|
1610
|
-
undoHandle: null,
|
|
1611
|
-
nextRevisionId: previewResult.nextRevisionId
|
|
1612
|
-
};
|
|
1613
|
-
};
|
|
1614
|
-
if (parsedBatch.dryRun === true) {
|
|
1615
|
-
const previewResult = preview();
|
|
1616
|
-
if (isAtomic && previewResult.skipped.length > 0) return atomicResult(previewResult, "previewed");
|
|
1617
|
-
return {
|
|
1618
|
-
version: 1,
|
|
1619
|
-
status: "previewed",
|
|
1620
|
-
applied: previewResult.applied.map(({ id, paragraphIdentity, retiredCommentIds }) => ({
|
|
1621
|
-
id,
|
|
1622
|
-
...paragraphIdentity === void 0 ? {} : { paragraphIdentity },
|
|
1623
|
-
...retiredCommentIds === void 0 ? {} : { retiredCommentIds }
|
|
1624
|
-
})),
|
|
1625
|
-
skipped: previewResult.skipped,
|
|
1626
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, previewResult.skipped),
|
|
1627
|
-
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
1628
|
-
operations: parsedBatch.operations,
|
|
1629
|
-
applied: previewResult.applied,
|
|
1630
|
-
story
|
|
1631
|
-
}),
|
|
1632
|
-
...previewResult.normalizations !== void 0 && { normalizations: previewResult.normalizations },
|
|
1633
|
-
undoHandle: null,
|
|
1634
|
-
nextRevisionId: previewResult.nextRevisionId
|
|
1635
|
-
};
|
|
1636
|
-
}
|
|
1637
|
-
if (isAtomic) {
|
|
1638
|
-
const previewResult = preview();
|
|
1639
|
-
if (previewResult.skipped.length > 0) return atomicResult(previewResult, "rejected");
|
|
1640
|
-
}
|
|
1641
|
-
const guarded = guardedAttempt(false);
|
|
1642
|
-
const { heldRevisionConflict, ...result } = guarded.outcome;
|
|
1643
|
-
if (heldRevisionConflict) return atomicResult(result, "rejected");
|
|
1644
|
-
if (guarded.fidelityRefused === true || isAtomic && result.skipped.some(({ reason }) => reason === "invalidResult")) return atomicResult(result, "rejected");
|
|
1645
|
-
guarded.commit();
|
|
1646
|
-
return {
|
|
1647
|
-
version: 1,
|
|
1648
|
-
status: "committed",
|
|
1649
|
-
...result,
|
|
1650
|
-
issues: getFolioDocumentOperationIssues(parsedBatch.operations, result.skipped),
|
|
1651
|
-
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
1652
|
-
operations: parsedBatch.operations,
|
|
1653
|
-
applied: result.applied,
|
|
1654
|
-
story
|
|
1655
|
-
}),
|
|
1656
|
-
undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
|
|
1657
|
-
};
|
|
1658
|
-
};
|
|
1659
|
-
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, applyFolioDocumentOperationsInPackage, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, withDistinctSuggestionIds };
|
|
1382
|
+
export { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationReceiptsForStory, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch, withDistinctSuggestionIds };
|
|
@@ -10,7 +10,7 @@ declare const CanonicalSaveDiagnosticErrorBase: TaggedErrorClass<"CanonicalSaveD
|
|
|
10
10
|
/** Forward a fidelity fallback through the adapters' existing error channel. */
|
|
11
11
|
export declare class CanonicalSaveDiagnosticError extends CanonicalSaveDiagnosticErrorBase<{
|
|
12
12
|
message: string;
|
|
13
|
-
gap: typeof CANONICAL_GAP.
|
|
13
|
+
gap: typeof CANONICAL_GAP.saveSerialization;
|
|
14
14
|
diagnostic: SaveDiagnostic;
|
|
15
15
|
}> {}
|
|
16
16
|
/** The adapters' error channel for one fidelity fallback. */
|
|
@@ -16,7 +16,7 @@ const CanonicalSaveDiagnosticErrorBase = TaggedError("CanonicalSaveDiagnosticErr
|
|
|
16
16
|
var CanonicalSaveDiagnosticError = class extends CanonicalSaveDiagnosticErrorBase {};
|
|
17
17
|
/** The adapters' error channel for one fidelity fallback. */
|
|
18
18
|
const canonicalSaveDiagnosticError = (diagnostic) => new CanonicalSaveDiagnosticError({
|
|
19
|
-
gap: CANONICAL_GAP.
|
|
19
|
+
gap: CANONICAL_GAP.saveSerialization,
|
|
20
20
|
diagnostic,
|
|
21
21
|
message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
|
|
22
22
|
});
|
|
@@ -7,8 +7,8 @@ import { keepNormalizedSourceParts } from "./normalizedSourceParts.js";
|
|
|
7
7
|
import { MalformedPackageRelationshipsError } from "./packageRelationshipsRoot.js";
|
|
8
8
|
import { parseDocx } from "./parser.js";
|
|
9
9
|
import { Result, TaggedError } from "better-result";
|
|
10
|
-
import { documentStories, idKey, packageParagraphIds, paragraphsThroughTextBoxes } from "@stll/docx-core/ops";
|
|
11
10
|
import { MalformedXmlReferenceError } from "@stll/docx-core/xml";
|
|
11
|
+
import { documentStories, idKey, packageParagraphIds, paragraphsThroughTextBoxes } from "@stll/docx-core/ops";
|
|
12
12
|
// src/docx/canonicalSessionInput.ts
|
|
13
13
|
const CanonicalDocxInputErrorBase = TaggedError("CanonicalDocxInputError");
|
|
14
14
|
var CanonicalDocxInputError = class extends CanonicalDocxInputErrorBase {};
|
|
@@ -2,8 +2,8 @@ import { TRANSITIONAL_NAMESPACE_BY_STRICT_URI } from "./strictValueEncodings.gen
|
|
|
2
2
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
3
|
import { WORDPROCESSINGML_NAMESPACE_URIS, getChildElements, getLocalName, getNamespaceUri } from "./xmlParser.js";
|
|
4
4
|
import { preservedChildGap } from "@stll/docx-core/model";
|
|
5
|
-
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
6
5
|
import { OOXML_NS } from "@stll/docx-core/xml/namespaces";
|
|
6
|
+
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
7
7
|
// src/docx/containerChildren.ts
|
|
8
8
|
/**
|
|
9
9
|
* The shared child dispatcher: one way to walk a container's children.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { DocumentPropertiesOptions } from "./rezip.js";
|
|
3
|
+
/** Create a DOCX from a document, loading the package writer on demand. */
|
|
4
|
+
export declare function createDocx(document: document_d_exports.Document, properties?: DocumentPropertiesOptions): Promise<ArrayBuffer>;
|
|
@@ -21,7 +21,7 @@ import { assignParagraphPropertySource } from "./paragraphPropertySource.js";
|
|
|
21
21
|
import { preserveInlineChild, preserveRunChild, preservedInlineCapture, withLooseFieldMarkupPreserved } from "./preservedRunContent.js";
|
|
22
22
|
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
23
23
|
import { FOLIO_REVIEW_HISTORY_NAMESPACE } from "./reviewHistoryNamespace.js";
|
|
24
|
-
import { parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, versionOneKeptMarkers } from "./reviewResolutionProvenance.js";
|
|
24
|
+
import { legacyKeptCutPiece, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, versionOneKeptMarkers } from "./reviewResolutionProvenance.js";
|
|
25
25
|
import { consolidateParagraphContent } from "./runConsolidator.js";
|
|
26
26
|
import { parseRun } from "./runParser.js";
|
|
27
27
|
import { runHoldsPayload } from "./runPayload.js";
|
|
@@ -1394,7 +1394,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
1394
1394
|
restoreEmptyMarkProperties(paragraph, node);
|
|
1395
1395
|
const rawContent = parseParagraphContents(node, styles, theme, numbering, rels, media, options?.previews ?? standalonePreviewLedger(), "default", options?.rootXmlns ?? {});
|
|
1396
1396
|
const consolidated = (content) => {
|
|
1397
|
-
const cut = paragraphKeptCutsFromChanges(content, versionOneKeptMarkers);
|
|
1397
|
+
const cut = paragraphKeptCutsFromChanges(content, versionOneKeptMarkers, legacyKeptCutPiece);
|
|
1398
1398
|
return options?.runConsolidation === "deferred" ? cut : consolidateParagraphContent(cut);
|
|
1399
1399
|
};
|
|
1400
1400
|
paragraph.content = consolidated(rawContent);
|
|
@@ -3,8 +3,8 @@ import { Comment } from "../types/content.js";
|
|
|
3
3
|
import { document_d_exports } from "../types/document.js";
|
|
4
4
|
import { ReadonlyDocument } from "../types/documentModel.js";
|
|
5
5
|
import { TaggedErrorClass } from "better-result";
|
|
6
|
-
import { Fragment, Mark, Node, NodeType } from "prosemirror-model";
|
|
7
6
|
import { Transaction } from "prosemirror-state";
|
|
7
|
+
import { Fragment, Mark, Node, NodeType } from "prosemirror-model";
|
|
8
8
|
/** Fix the facts of `paragraph`: a reader keeps them. */
|
|
9
9
|
export declare const sealParagraphFacts: (paragraph: document_d_exports.Paragraph) => void;
|
|
10
10
|
declare const paragraphPropertySourceEmissionFingerprint: unique symbol;
|
package/dist/docx/parser.js
CHANGED
|
@@ -48,9 +48,9 @@ import { renderWmfSvg } from "./wmfSvg.js";
|
|
|
48
48
|
import { getAttribute, getChildElements, getLocalName, parseXml, parseXmlDocument } from "./xmlParser.js";
|
|
49
49
|
import { TaggedError, panic } from "better-result";
|
|
50
50
|
import { PARSE_WARNING_CODES, setDocumentBodyComments } from "@stll/docx-core/model";
|
|
51
|
-
import { isCommentExhausted, orphanRootCommentIds } from "@stll/docx-core/ops";
|
|
52
51
|
import { MalformedXmlReferenceError, malformedXmlReferenceError } from "@stll/docx-core/xml";
|
|
53
52
|
import { FOLIO_XML_RESOURCE_LIMITS } from "@stll/docx-core/xml/limits";
|
|
53
|
+
import { isCommentExhausted, orphanRootCommentIds } from "@stll/docx-core/ops";
|
|
54
54
|
// src/docx/parser.ts
|
|
55
55
|
/**
|
|
56
56
|
* Main Parser Orchestrator - Unified parseDocx function
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
3
|
import { TaggedErrorClass } from "better-result";
|
|
4
|
-
import { CopyOriginAncestorList, VersionOneKept } from "@stll/docx-core/ops";
|
|
4
|
+
import { CopyOriginAncestorList, KeptCutPiece, VersionOneKept } from "@stll/docx-core/ops";
|
|
5
5
|
/**
|
|
6
6
|
* The review history version folio writes. Version 2 adds the revision a
|
|
7
7
|
* paragraph property change belongs to (`folio:resolvesWith`) and records a
|
|
@@ -30,6 +30,7 @@ export declare const parseResolutionJoins: (node: XmlElement) => ResolutionJoins
|
|
|
30
30
|
export declare const versionOneKeptMarkers: (joins: ResolutionJoins) => VersionOneKept | undefined;
|
|
31
31
|
export declare const parseBoundaryJoins: (node: XmlElement) => BoundaryJoins | undefined;
|
|
32
32
|
export declare const parseCopyOriginAncestors: (node: XmlElement) => CopyOriginAncestorList | undefined;
|
|
33
|
+
export declare const legacyKeptCutPiece: (cut: document_d_exports.KeptCut) => KeptCutPiece | undefined;
|
|
33
34
|
/** The cut a kept range marker stands in (`folio:keptCut`). */
|
|
34
35
|
export declare const parseKeptCut: (node: XmlElement) => document_d_exports.KeptCut | undefined;
|
|
35
36
|
export declare const serializeKeptCut: (value: document_d_exports.KeptCut | undefined) => string | undefined;
|
|
@@ -42,7 +43,7 @@ export declare const serializeCopyOriginAncestors: (value: CopyOriginAncestorLis
|
|
|
42
43
|
* and when the split whose cut a deleted mark holds was made. A missing
|
|
43
44
|
* attribute carries no field.
|
|
44
45
|
*/
|
|
45
|
-
export declare const parseParagraphMarkResolutionJoin: (node: XmlElement) => Pick<document_d_exports.ParagraphMarkChange, "resolutionJoin" | "survivor" | "splitDate">;
|
|
46
|
+
export declare const parseParagraphMarkResolutionJoin: (node: XmlElement) => Pick<document_d_exports.ParagraphMarkChange, "resolutionJoin" | "survivor" | "takenOverMark" | "splitDate">;
|
|
46
47
|
export declare const serializeParagraphMarkResolutionJoin: (mark: document_d_exports.ParagraphMarkChange) => string;
|
|
47
48
|
/** Captured paragraph properties compose the same envelopes into a parsed XML element. */
|
|
48
49
|
export declare const paragraphMarkResolutionJoinAttributes: (mark: document_d_exports.ParagraphMarkChange) => Record<string, string>;
|