@stll/folio-core 0.73.0 → 0.75.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/clean-text.d.ts +4 -1
- package/dist/ai-edits/clean-text.js +21 -7
- package/dist/ai-edits/headless.d.ts +5 -2
- package/dist/ai-edits/headless.js +20 -14
- package/dist/ai-edits/note-references.d.ts +1 -1
- package/dist/ai-edits/note-references.js +1 -1
- package/dist/ai-edits/pending-suggestions.d.ts +9 -7
- package/dist/ai-edits/pending-suggestions.js +134 -88
- package/dist/ai-edits/pendingJoin.d.ts +5 -1
- package/dist/ai-edits/pendingJoin.js +12 -3
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +2 -2
- package/dist/ai-edits/retired-comment-receipts.js +3 -18
- package/dist/ai-edits/snapshot.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +6 -10
- package/dist/ai-edits/tracked-batch-fidelity.js +3 -182
- package/dist/canonical/canonicalBatchReview.d.ts +4 -1
- package/dist/canonical/canonicalBatchReview.js +32 -14
- package/dist/canonical/canonicalComments.d.ts +6 -2
- package/dist/canonical/canonicalComments.js +8 -4
- 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 +6 -28
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +99 -36
- package/dist/canonical/canonicalRefusalGrounds.d.ts +4 -0
- package/dist/canonical/canonicalRefusalGrounds.js +56 -0
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +12 -6
- package/dist/canonical/canonicalSession.js +129 -141
- package/dist/canonical/canonicalTrackedBatchFidelity.js +3 -3
- package/dist/compare/inline-atoms.d.ts +35 -41
- package/dist/compare/inline-atoms.js +2 -465
- package/dist/compare/section-boundary-properties.d.ts +3 -30
- package/dist/compare/section-boundary-properties.js +4 -72
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.js +45 -44
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +6 -6
- package/dist/controller/canonicalInput.d.ts +4 -2
- package/dist/controller/canonicalInput.js +34 -17
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStoryEditor.d.ts +2 -3
- package/dist/controller/canonicalStoryEditor.js +43 -25
- package/dist/controller/canonicalStructure.d.ts +19 -2
- package/dist/controller/canonicalStructure.js +140 -43
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/deferredDisplayListPainter.d.ts +8 -0
- package/dist/controller/deferredDisplayListPainter.js +34 -0
- package/dist/controller/folioEditor.js +4 -2
- package/dist/controller/headerFooterEditorManager.js +3 -17
- package/dist/controller/hiddenEditorApi.d.ts +24 -3
- package/dist/controller/hiddenEditorApi.js +4 -17
- package/dist/controller/hiddenEditorManager.js +136 -197
- package/dist/controller/layoutPipeline.d.ts +4 -86
- package/dist/controller/layoutPipeline.js +8 -727
- package/dist/controller/layoutPipelineExecution.d.ts +94 -0
- package/dist/controller/layoutPipelineExecution.js +730 -0
- package/dist/controller/noteEditorManager.js +3 -16
- package/dist/document-operations.js +1 -1
- package/dist/docx/blockContentParser.d.ts +1 -3
- package/dist/docx/blockContentParser.js +3 -10
- package/dist/docx/canonicalSave.d.ts +4 -3
- package/dist/docx/canonicalSave.js +4 -3
- 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/listMarkerComputation.d.ts +24 -17
- package/dist/docx/listMarkerComputation.js +31 -60
- package/dist/docx/listModelNormalization.js +8 -15
- package/dist/docx/modelValidation.js +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +1 -1
- package/dist/docx/rezip.d.ts +16 -3
- package/dist/docx/rezip.js +36 -10
- package/dist/docx/selectiveSave.js +13 -5
- package/dist/docx/serializer/borderSerializer.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +3 -3
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +1 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
- package/dist/docx/server/templatePlan/apply.js +107 -14
- package/dist/docx/server/templatePlan/blocks.d.ts +16 -1
- package/dist/docx/server/templatePlan/blocks.js +93 -7
- package/dist/docx/server/templatePlan/builders.d.ts +37 -2
- package/dist/docx/server/templatePlan/builders.js +196 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +2 -0
- package/dist/docx/server/templatePlan/inspect.js +81 -61
- package/dist/docx/server/templatePlan/labels.d.ts +16 -2
- package/dist/docx/server/templatePlan/labels.js +131 -20
- package/dist/docx/server/templatePlan/plan.d.ts +15 -1
- package/dist/docx/server/templatePlan/plan.js +62 -13
- package/dist/docx/server/templatePlan/planShape.js +52 -4
- package/dist/docx/server/templatePlan/story.d.ts +8 -0
- package/dist/docx/server/templatePlan/story.js +11 -1
- package/dist/docx/server/templatePlan/types.d.ts +176 -18
- package/dist/docx/server/templatePlan/types.js +1 -0
- package/dist/docx/server/templatePlan/verify.js +60 -11
- package/dist/docx/server/templatePlan/xml.d.ts +5 -0
- package/dist/docx/server/templatePlan/xml.js +7 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/xmlParser.js +1 -1
- 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/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- 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/paragraphFormattingSerialization.js +1 -1
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +0 -12
- package/dist/layout-bridge/convert/topLevelConversion.js +1 -10
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -1
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- 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/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 +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listMarker.d.ts +1 -6
- package/dist/prosemirror/listMarker.js +4 -56
- package/dist/prosemirror/listNumbering.js +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/pastedCommentCopies.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +42 -93
- package/dist/types/canonicalCapabilities.js +53 -91
- package/dist/types/canonicalComments.d.ts +2 -2
- package/dist/types/canonicalSections.d.ts +2 -2
- package/dist/utils/clipboard.d.ts +2 -28
- package/dist/utils/clipboard.js +1 -96
- package/dist/utils/clipboardFiles.d.ts +27 -0
- package/dist/utils/clipboardFiles.js +98 -0
- package/dist/utils/rulerControl.d.ts +1 -0
- package/dist/utils/rulerControl.js +2 -1
- package/package.json +2 -2
- package/dist/ai-edits/apply.d.ts +0 -94
- package/dist/ai-edits/apply.js +0 -6637
- 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/document-operations-apply.d.ts +0 -15
- package/dist/document-operations-apply.js +0 -280
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
- 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";
|
|
@@ -21,27 +22,27 @@ import { toggleMarkForAllScripts, toggleUnderlineMark } from "../prosemirror/ext
|
|
|
21
22
|
import { HyperlinkRemovalRefusal } from "../prosemirror/hyperlinkRemoval.js";
|
|
22
23
|
import { REVISION_MARK_NAMES } from "../prosemirror/keptRangeBoundaries.js";
|
|
23
24
|
import { adoptNativeSelection, createNativeNavigationPlugin, createNativeSelectionRefreshPlugin, isCompositionKeyDown } from "../prosemirror/nativeSelection.js";
|
|
24
|
-
import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
25
|
+
import { NoteReferenceReplayDefect, noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
25
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 { CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
30
|
+
import { CANONICAL_CONDITION, CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
30
31
|
import { readModel } from "../types/documentModel.js";
|
|
31
|
-
import { INTERNAL_CLIPBOARD_TYPE } from "../utils/
|
|
32
|
+
import { INTERNAL_CLIPBOARD_TYPE } from "../utils/clipboardFiles.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";
|
|
35
36
|
import { createCanonicalInputBoundary, unclassifiedMutationMessage } from "./canonicalInput.js";
|
|
36
37
|
import { openCanonicalRoomEditor } from "./canonicalRoomEditor.js";
|
|
37
|
-
import {
|
|
38
|
+
import { prepareCanonicalAutoformat, prepareCanonicalCommands, prepareCanonicalStructure } from "./canonicalStructure.js";
|
|
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
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
|
/**
|
|
@@ -185,7 +186,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
185
186
|
author: deps.getSuggestionAuthor?.() ?? "User"
|
|
186
187
|
} : { type: "editing" }));
|
|
187
188
|
};
|
|
188
|
-
const refuse = (reason, ground
|
|
189
|
+
const refuse = (reason, ground) => {
|
|
189
190
|
const message = reason;
|
|
190
191
|
if (deps.onSessionRefusal) deps.onSessionRefusal(message, ground);
|
|
191
192
|
else throw new CanonicalSessionRefusalError({
|
|
@@ -216,7 +217,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
216
217
|
reason,
|
|
217
218
|
documentIdentity
|
|
218
219
|
};
|
|
219
|
-
refuse(reason, {
|
|
220
|
+
refuse(reason, { condition: CANONICAL_CONDITION.notReady });
|
|
220
221
|
return false;
|
|
221
222
|
}
|
|
222
223
|
const result = createCanonicalSession(document, deps.getStyles());
|
|
@@ -266,12 +267,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
266
267
|
createNativeNavigationPlugin(),
|
|
267
268
|
createDocumentStyleContextPlugin(deps.getStyles() ?? document.package.styles),
|
|
268
269
|
new Plugin({ props: { clipboardTextParser: parseCanonicalClipboardText } }),
|
|
269
|
-
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) =>
|
|
270
|
-
...props.transformCopied === void 0 ? {} : { transformCopied: props.transformCopied },
|
|
271
|
-
...props.clipboardTextSerializer === void 0 ? {} : { clipboardTextSerializer: props.clipboardTextSerializer },
|
|
272
|
-
...props.transformPastedHTML === void 0 ? {} : { transformPastedHTML: props.transformPastedHTML },
|
|
273
|
-
...props.transformPasted === void 0 ? {} : { transformPasted: props.transformPasted }
|
|
274
|
-
} })]),
|
|
270
|
+
...[...deps.getExtensionManager()?.getPlugins() ?? [], ...deps.getExternalPlugins()].flatMap(({ props }) => clipboardTransformPlugin(props)),
|
|
275
271
|
...deps.getExternalPlugins().flatMap(({ spec }) => spec.view === void 0 ? [] : [new Plugin({ view: spec.view })])
|
|
276
272
|
]
|
|
277
273
|
});
|
|
@@ -339,7 +335,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
339
335
|
const { state } = view;
|
|
340
336
|
const { session } = editorSession;
|
|
341
337
|
if (state.selection instanceof CellSelection) {
|
|
342
|
-
refuse("A field goes in at a text selection, not over cells.");
|
|
338
|
+
refuse("A field goes in at a text selection, not over cells.", { condition: CANONICAL_CONDITION.invalidRequest });
|
|
343
339
|
return false;
|
|
344
340
|
}
|
|
345
341
|
const range = canonicalSelectionRange(state);
|
|
@@ -377,7 +373,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
377
373
|
*/
|
|
378
374
|
const publishRemote = (session, commit) => {
|
|
379
375
|
if (!view || isDestroying || editorSession.type !== "canonical" || editorSession.session !== session) return Result.err(new CanonicalSessionError({
|
|
380
|
-
ground: {
|
|
376
|
+
ground: { condition: CANONICAL_CONDITION.notReady },
|
|
381
377
|
message: "The editor showing the room is closed.",
|
|
382
378
|
reason: "refused"
|
|
383
379
|
}));
|
|
@@ -498,7 +494,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
498
494
|
const direction = getCanonicalHistoryDirection(command);
|
|
499
495
|
if (direction !== void 0) return history(direction);
|
|
500
496
|
if (editorSession.session.isComposing) {
|
|
501
|
-
refuse("Composition must finish before formatting.");
|
|
497
|
+
refuse("Composition must finish before formatting.", { condition: CANONICAL_CONDITION.composing });
|
|
502
498
|
return false;
|
|
503
499
|
}
|
|
504
500
|
const commandState = view.state;
|
|
@@ -548,6 +544,58 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
548
544
|
token
|
|
549
545
|
};
|
|
550
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* Cut the selection of the editor showing `story`: the clipboard takes it
|
|
549
|
+
* first, and the story loses it only once the clipboard holds it.
|
|
550
|
+
*/
|
|
551
|
+
const cutCanonical = (pmView, event, story) => {
|
|
552
|
+
event.preventDefault();
|
|
553
|
+
if (deps.getReadOnly()) {
|
|
554
|
+
deps.onReadOnlyEditAttempt();
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
deps.onCut?.();
|
|
558
|
+
if (editorSession.type !== "canonical" || pmView.state.selection.empty) return true;
|
|
559
|
+
if (event.clipboardData === null) {
|
|
560
|
+
refuse("The clipboard cannot receive the cut content.", { condition: CANONICAL_CONDITION.invalidRequest });
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
syncCanonicalMode();
|
|
564
|
+
const source = readModel(editorSession.session.document);
|
|
565
|
+
const session = editorSession.session;
|
|
566
|
+
const { from, to } = pmView.state.selection;
|
|
567
|
+
const prepared = session.prepareReplace(pmView.state, {
|
|
568
|
+
from,
|
|
569
|
+
to,
|
|
570
|
+
text: "",
|
|
571
|
+
semantic: "replacement",
|
|
572
|
+
story
|
|
573
|
+
});
|
|
574
|
+
if (prepared.isErr()) {
|
|
575
|
+
refuse(prepared.error.message, prepared.error.ground);
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
const data = event.clipboardData;
|
|
579
|
+
const copied = Result.try({
|
|
580
|
+
try: () => writeClipboard(pmView, data),
|
|
581
|
+
catch: () => new CanonicalSessionRefusalError({
|
|
582
|
+
ground: { condition: CANONICAL_CONDITION.invalidRequest },
|
|
583
|
+
message: "The clipboard could not receive the cut content."
|
|
584
|
+
})
|
|
585
|
+
});
|
|
586
|
+
if (copied.isErr()) {
|
|
587
|
+
refuse(copied.error.message, copied.error.ground);
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
clipboardCopy = {
|
|
591
|
+
type: "copied",
|
|
592
|
+
document: source,
|
|
593
|
+
...copied.value
|
|
594
|
+
};
|
|
595
|
+
if (story === OP_STORIES.MAIN) publishCommit(prepared.value);
|
|
596
|
+
else publishStoryCommit(pmView, prepared.value);
|
|
597
|
+
return true;
|
|
598
|
+
};
|
|
551
599
|
/** The copied document, when the pasted clipboard is the editor's own copy. */
|
|
552
600
|
const copiedSource = (event) => {
|
|
553
601
|
const data = event.clipboardData;
|
|
@@ -584,110 +632,12 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
584
632
|
}
|
|
585
633
|
const session = editorSession.session;
|
|
586
634
|
const state = view.state;
|
|
587
|
-
if (
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
from: at,
|
|
591
|
-
to: at,
|
|
592
|
-
paragraphs: [{
|
|
593
|
-
type: "paragraph",
|
|
594
|
-
content: []
|
|
595
|
-
}, {
|
|
596
|
-
type: "paragraph",
|
|
597
|
-
content: []
|
|
598
|
-
}],
|
|
599
|
-
openStart: 1,
|
|
600
|
-
openEnd: 1
|
|
601
|
-
} : {
|
|
602
|
-
type: "insertAtom",
|
|
603
|
-
from: at,
|
|
604
|
-
to: at,
|
|
605
|
-
atom: type === "tab" ? { type: "tab" } : {
|
|
606
|
-
type: "break",
|
|
607
|
-
breakType: type === "pageBreak" ? "page" : "textWrapping"
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
if (overCells.isErr()) {
|
|
611
|
-
if (overCells.error.reason !== "noChange") refuse(overCells.error.message, overCells.error.ground);
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
publishCommit(overCells.value);
|
|
635
|
+
if (type === "joinBackward" && lastInputRule?.session === session && lastInputRule.version === session.version && lastInputRule.caret === state.selection.head) {
|
|
636
|
+
lastInputRule = void 0;
|
|
637
|
+
history("undo");
|
|
615
638
|
return;
|
|
616
639
|
}
|
|
617
|
-
const
|
|
618
|
-
if (selection.isErr()) {
|
|
619
|
-
refuse(selection.error.message, selection.error.ground);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
let prepared;
|
|
623
|
-
switch (type) {
|
|
624
|
-
case "split": {
|
|
625
|
-
const source = session.projection.paragraph(selection.value.head.blockId)?.source;
|
|
626
|
-
prepared = isCanonicalListParagraph(source) && state.selection.$from.parent.content.size === 0 ? prepareCanonicalCommands(session, state, [{ type: "removeList" }]) : session.prepareSplit(state);
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
case "joinBackward": {
|
|
630
|
-
if (lastInputRule?.session === session && lastInputRule.version === session.version && lastInputRule.caret === state.selection.head) {
|
|
631
|
-
lastInputRule = void 0;
|
|
632
|
-
history("undo");
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
const paragraph = session.projection.paragraph(selection.value.head.blockId)?.source;
|
|
636
|
-
if (isCanonicalListParagraph(paragraph)) {
|
|
637
|
-
prepared = prepareCanonicalCommands(session, state, [{ type: "removeList" }]);
|
|
638
|
-
break;
|
|
639
|
-
}
|
|
640
|
-
if ((paragraph?.formatting?.indentLeft ?? 0) > 0 || (paragraph?.formatting?.indentFirstLine ?? 0) > 0) {
|
|
641
|
-
prepared = session.prepareIntent(state, {
|
|
642
|
-
type: "formatParagraph",
|
|
643
|
-
at: selection.value.head,
|
|
644
|
-
patch: {
|
|
645
|
-
indentLeft: null,
|
|
646
|
-
indentFirstLine: null,
|
|
647
|
-
hangingIndent: null
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
break;
|
|
651
|
-
}
|
|
652
|
-
prepared = session.prepareJoin(state, "backward");
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
case "joinForward":
|
|
656
|
-
prepared = session.prepareJoin(state, "forward");
|
|
657
|
-
break;
|
|
658
|
-
case "indent":
|
|
659
|
-
case "outdent":
|
|
660
|
-
prepared = prepareCanonicalCommands(session, state, [{
|
|
661
|
-
type: "changeListLevel",
|
|
662
|
-
direction: type === "indent" ? "increase" : "decrease"
|
|
663
|
-
}]);
|
|
664
|
-
break;
|
|
665
|
-
case "tab":
|
|
666
|
-
case "lineBreak":
|
|
667
|
-
case "pageBreak": {
|
|
668
|
-
const from = session.projection.addressAt(state.selection.from);
|
|
669
|
-
const to = session.projection.addressAt(state.selection.to);
|
|
670
|
-
if (from.isErr()) {
|
|
671
|
-
refuse(from.error.message, from.error.ground);
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
if (to.isErr()) {
|
|
675
|
-
refuse(to.error.message, to.error.ground);
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
prepared = session.prepareIntent(state, {
|
|
679
|
-
type: "insertAtom",
|
|
680
|
-
from: from.value,
|
|
681
|
-
to: to.value,
|
|
682
|
-
atom: type === "tab" ? { type: "tab" } : {
|
|
683
|
-
type: "break",
|
|
684
|
-
breakType: type === "pageBreak" ? "page" : "textWrapping"
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
break;
|
|
688
|
-
}
|
|
689
|
-
default: return type;
|
|
690
|
-
}
|
|
640
|
+
const prepared = prepareCanonicalStructure(session, state, OP_STORIES.MAIN, type);
|
|
691
641
|
if (prepared.isErr()) {
|
|
692
642
|
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
693
643
|
return;
|
|
@@ -726,52 +676,7 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
726
676
|
}
|
|
727
677
|
pasteWithoutFormatting(pmView.state, (transaction) => pmView.dispatch(transaction), pmView);
|
|
728
678
|
},
|
|
729
|
-
cut: (pmView, event) =>
|
|
730
|
-
event.preventDefault();
|
|
731
|
-
if (deps.getReadOnly()) {
|
|
732
|
-
deps.onReadOnlyEditAttempt();
|
|
733
|
-
return true;
|
|
734
|
-
}
|
|
735
|
-
deps.onCut?.();
|
|
736
|
-
if (editorSession.type !== "canonical" || pmView.state.selection.empty) return true;
|
|
737
|
-
if (event.clipboardData === null) {
|
|
738
|
-
refuse("The clipboard cannot receive the cut content.");
|
|
739
|
-
return true;
|
|
740
|
-
}
|
|
741
|
-
syncCanonicalMode();
|
|
742
|
-
const source = readModel(editorSession.session.document);
|
|
743
|
-
const session = editorSession.session;
|
|
744
|
-
const { from, to } = pmView.state.selection;
|
|
745
|
-
const prepared = session.prepareReplace(pmView.state, {
|
|
746
|
-
from,
|
|
747
|
-
to,
|
|
748
|
-
text: "",
|
|
749
|
-
semantic: "replacement"
|
|
750
|
-
});
|
|
751
|
-
if (prepared.isErr()) {
|
|
752
|
-
refuse(prepared.error.message, prepared.error.ground);
|
|
753
|
-
return true;
|
|
754
|
-
}
|
|
755
|
-
const data = event.clipboardData;
|
|
756
|
-
const copied = Result.try({
|
|
757
|
-
try: () => writeClipboard(pmView, data),
|
|
758
|
-
catch: () => new CanonicalSessionRefusalError({
|
|
759
|
-
ground: { gap: CANONICAL_GAP.dispatch },
|
|
760
|
-
message: "The clipboard could not receive the cut content."
|
|
761
|
-
})
|
|
762
|
-
});
|
|
763
|
-
if (copied.isErr()) {
|
|
764
|
-
refuse(copied.error.message, copied.error.ground);
|
|
765
|
-
return true;
|
|
766
|
-
}
|
|
767
|
-
clipboardCopy = {
|
|
768
|
-
type: "copied",
|
|
769
|
-
document: source,
|
|
770
|
-
...copied.value
|
|
771
|
-
};
|
|
772
|
-
publishCommit(prepared.value);
|
|
773
|
-
return true;
|
|
774
|
-
},
|
|
679
|
+
cut: (pmView, event) => cutCanonical(pmView, event, OP_STORIES.MAIN),
|
|
775
680
|
...canonicalInputLifecycle,
|
|
776
681
|
...canonicalStructuralInput,
|
|
777
682
|
replace: (intent) => {
|
|
@@ -836,9 +741,9 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
836
741
|
}
|
|
837
742
|
const applied = view.state.applyTransaction(transaction);
|
|
838
743
|
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
839
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, {
|
|
744
|
+
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { condition: noteIssue instanceof NoteReferenceReplayDefect ? CANONICAL_CONDITION.internal : CANONICAL_CONDITION.invalidRequest }, noteIssue);
|
|
840
745
|
if (!applied.state.doc.eq(view.state.doc)) {
|
|
841
|
-
refuse(unclassifiedMutationMessage(applied.transactions, "A plugin attempted an unclassified canonical document mutation."));
|
|
746
|
+
refuse(unclassifiedMutationMessage(applied.transactions, "A plugin attempted an unclassified canonical document mutation."), { condition: CANONICAL_CONDITION.hostTransaction });
|
|
842
747
|
return;
|
|
843
748
|
}
|
|
844
749
|
const documentEdits = applied.transactions.filter((appliedTransaction) => appliedTransaction.docChanged && !isCommentRecordsSync(appliedTransaction));
|
|
@@ -894,13 +799,13 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
894
799
|
top: event.clientY
|
|
895
800
|
})?.pos;
|
|
896
801
|
if (target === void 0) {
|
|
897
|
-
refuse("The drop has no document destination.");
|
|
802
|
+
refuse("The drop has no document destination.", { condition: CANONICAL_CONDITION.invalidRequest });
|
|
898
803
|
return true;
|
|
899
804
|
}
|
|
900
805
|
const captured = clipboardDrag;
|
|
901
806
|
clipboardDrag = { type: "idle" };
|
|
902
807
|
if (moved && (captured.type !== "dragging" || captured.session !== editorSession.session || captured.version !== editorSession.session.version)) {
|
|
903
|
-
refuse("The dragged content changed or has no captured source.");
|
|
808
|
+
refuse("The dragged content changed or has no captured source.", { condition: CANONICAL_CONDITION.stale });
|
|
904
809
|
return true;
|
|
905
810
|
}
|
|
906
811
|
const source = captured.type === "dragging" ? {
|
|
@@ -1100,14 +1005,14 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1100
1005
|
selection: commit.selection,
|
|
1101
1006
|
unavailable: { type: "refuse" }
|
|
1102
1007
|
})) {
|
|
1103
|
-
refuse("The canonical body history selection is unavailable.");
|
|
1008
|
+
refuse("The canonical body history selection is unavailable.", { condition: CANONICAL_CONDITION.internal });
|
|
1104
1009
|
return false;
|
|
1105
1010
|
}
|
|
1106
1011
|
}
|
|
1107
1012
|
bodyTransaction.setMeta("addToHistory", false);
|
|
1108
1013
|
const bodyStaged = Result.try(() => view?.state.applyTransaction(bodyTransaction));
|
|
1109
1014
|
if (bodyStaged.isErr() || !bodyStaged.value || !bodyStaged.value.transactions.includes(bodyTransaction) || !bodyStaged.value.state.doc.eq(commit.bodyProjection.doc) || bodyStaged.value.transactions.some((transaction) => transaction !== bodyTransaction && transaction.docChanged)) {
|
|
1110
|
-
refuse("A plugin refused or changed the canonical body projection.");
|
|
1015
|
+
refuse("A plugin refused or changed the canonical body projection.", { condition: CANONICAL_CONDITION.hostTransaction });
|
|
1111
1016
|
return false;
|
|
1112
1017
|
}
|
|
1113
1018
|
const staged = publishCanonicalProjection({
|
|
@@ -1273,25 +1178,30 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1273
1178
|
canonicalOperations: {
|
|
1274
1179
|
applyCanonicalSectionProperties: (patch) => {
|
|
1275
1180
|
ensureView();
|
|
1276
|
-
const fail = (message) => {
|
|
1277
|
-
refuse(message,
|
|
1181
|
+
const fail = (message, ground) => {
|
|
1182
|
+
refuse(message, ground);
|
|
1278
1183
|
return {
|
|
1279
1184
|
status: "refused",
|
|
1280
|
-
|
|
1185
|
+
ground,
|
|
1281
1186
|
message
|
|
1282
1187
|
};
|
|
1283
1188
|
};
|
|
1284
|
-
if (editorSession.type
|
|
1285
|
-
if (
|
|
1286
|
-
if (!view || deps.getReadOnly() || isDestroying) return fail("The document is not editable.");
|
|
1189
|
+
if (editorSession.type !== "canonical") return fail(editorSession.type === "refused" ? editorSession.reason : "The document is not ready for section changes.", { condition: CANONICAL_CONDITION.notReady });
|
|
1190
|
+
if (!view || deps.getReadOnly() || isDestroying) return fail("The document is not editable.", { condition: CANONICAL_CONDITION.notEditable });
|
|
1287
1191
|
const session = editorSession.session;
|
|
1288
|
-
if (session.isComposing) return fail("Section properties cannot change during composition.");
|
|
1192
|
+
if (session.isComposing) return fail("Section properties cannot change during composition.", { condition: CANONICAL_CONDITION.composing });
|
|
1289
1193
|
const prepared = session.prepareOperations(view.state, [createCanonicalSectionPropertiesOperation(readModel(session.document), patch)]);
|
|
1290
|
-
if (prepared.isErr()) return fail(prepared.error.message);
|
|
1291
|
-
let
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}
|
|
1194
|
+
if (prepared.isErr()) return fail(prepared.error.message, prepared.error.ground);
|
|
1195
|
+
let failure = {
|
|
1196
|
+
message: "The section projection could not publish.",
|
|
1197
|
+
ground: { condition: CANONICAL_CONDITION.notReady }
|
|
1198
|
+
};
|
|
1199
|
+
if (!publishCommit(prepared.value, (message, ground) => {
|
|
1200
|
+
failure = {
|
|
1201
|
+
message,
|
|
1202
|
+
ground: ground ?? failure.ground
|
|
1203
|
+
};
|
|
1204
|
+
})) return fail(failure.message, failure.ground);
|
|
1295
1205
|
return {
|
|
1296
1206
|
status: "applied",
|
|
1297
1207
|
version: session.version
|
|
@@ -1299,29 +1209,28 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1299
1209
|
},
|
|
1300
1210
|
applyCanonicalComment: (request) => {
|
|
1301
1211
|
ensureView();
|
|
1302
|
-
const fail = (message, retry = "never") => {
|
|
1303
|
-
if (retry === "never") refuse(message,
|
|
1212
|
+
const fail = (message, ground, retry = "never") => {
|
|
1213
|
+
if (retry === "never") refuse(message, ground);
|
|
1304
1214
|
return {
|
|
1305
1215
|
status: "refused",
|
|
1306
|
-
|
|
1216
|
+
ground,
|
|
1307
1217
|
message,
|
|
1308
1218
|
retry
|
|
1309
1219
|
};
|
|
1310
1220
|
};
|
|
1311
|
-
if (editorSession.type
|
|
1312
|
-
if (
|
|
1313
|
-
if (!view || deps.getReadOnly()) return fail("The document is not editable.");
|
|
1221
|
+
if (editorSession.type !== "canonical") return fail(editorSession.type === "refused" ? editorSession.reason : "The document is not ready for comment changes.", { condition: CANONICAL_CONDITION.notReady });
|
|
1222
|
+
if (!view || deps.getReadOnly()) return fail("The document is not editable.", { condition: CANONICAL_CONDITION.notEditable });
|
|
1314
1223
|
const session = editorSession.session;
|
|
1315
|
-
if (session.isComposing) return fail("Comments cannot change during composition.", "afterComposition");
|
|
1224
|
+
if (session.isComposing) return fail("Comments cannot change during composition.", { condition: CANONICAL_CONDITION.composing }, "afterComposition");
|
|
1316
1225
|
let command;
|
|
1317
1226
|
if (request.type === "create") {
|
|
1318
1227
|
const id = freshCommentId(readModel(session.document), session.idLease);
|
|
1319
|
-
if (id.isErr()) return fail(id.
|
|
1228
|
+
if (id.isErr()) return fail("No comment id is free.", { condition: CANONICAL_CONDITION.idSpace });
|
|
1320
1229
|
let anchor;
|
|
1321
1230
|
switch (request.anchor.kind) {
|
|
1322
1231
|
case "selection": {
|
|
1323
1232
|
const projection = session.projectStory(request.anchor.story);
|
|
1324
|
-
if (projection.isErr()) return fail(projection.error.message);
|
|
1233
|
+
if (projection.isErr()) return fail(projection.error.message, projection.error.ground);
|
|
1325
1234
|
const { doc } = projection.value;
|
|
1326
1235
|
const textEdge = (position, bias) => {
|
|
1327
1236
|
if (position < 0 || position > doc.content.size) return position;
|
|
@@ -1334,8 +1243,8 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1334
1243
|
const collapsed = request.anchor.from === request.anchor.to;
|
|
1335
1244
|
const from = projection.value.addressAt(collapsed ? request.anchor.from : textEdge(request.anchor.from, 1));
|
|
1336
1245
|
const to = projection.value.addressAt(collapsed ? request.anchor.to : textEdge(request.anchor.to, -1));
|
|
1337
|
-
if (from.isErr()) return fail(from.error.message);
|
|
1338
|
-
if (to.isErr()) return fail(to.error.message);
|
|
1246
|
+
if (from.isErr()) return fail(from.error.message, from.error.ground);
|
|
1247
|
+
if (to.isErr()) return fail(to.error.message, to.error.ground);
|
|
1339
1248
|
anchor = request.anchor.from === request.anchor.to ? {
|
|
1340
1249
|
kind: "point",
|
|
1341
1250
|
at: from.value
|
|
@@ -1378,11 +1287,20 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1378
1287
|
command,
|
|
1379
1288
|
idLease: session.idLease
|
|
1380
1289
|
});
|
|
1381
|
-
if (compiled.isErr()) return fail(compiled.error.message);
|
|
1290
|
+
if (compiled.isErr()) return fail(compiled.error.message, compiled.error.ground);
|
|
1382
1291
|
if (compiled.value.ops.length > 0) {
|
|
1383
1292
|
const prepared = session.prepareOperations(view.state, compiled.value.ops);
|
|
1384
|
-
if (prepared.isErr()) return fail(prepared.error.message);
|
|
1385
|
-
|
|
1293
|
+
if (prepared.isErr()) return fail(prepared.error.message, prepared.error.ground);
|
|
1294
|
+
let failure = {
|
|
1295
|
+
message: "The comment projection could not publish.",
|
|
1296
|
+
ground: { condition: CANONICAL_CONDITION.notReady }
|
|
1297
|
+
};
|
|
1298
|
+
if (!publishCommit(prepared.value, (message, ground) => {
|
|
1299
|
+
failure = {
|
|
1300
|
+
message,
|
|
1301
|
+
ground: ground ?? failure.ground
|
|
1302
|
+
};
|
|
1303
|
+
})) return fail(failure.message, failure.ground);
|
|
1386
1304
|
}
|
|
1387
1305
|
return {
|
|
1388
1306
|
status: "applied",
|
|
@@ -1464,6 +1382,27 @@ const createHiddenEditorManager = (hostDeps) => {
|
|
|
1464
1382
|
});
|
|
1465
1383
|
if (editorSession.type === "canonical") editorSession.session.recordStorySelection(storyView.state, story);
|
|
1466
1384
|
},
|
|
1385
|
+
applyCanonicalStoryStructure: ({ view: storyView, story, type }) => {
|
|
1386
|
+
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1387
|
+
syncCanonicalMode();
|
|
1388
|
+
const session = editorSession.session;
|
|
1389
|
+
let prepared;
|
|
1390
|
+
if (type === "deleteTable") {
|
|
1391
|
+
const command = deps.getExtensionManager()?.getCommand("deleteTable")?.();
|
|
1392
|
+
const intents = command === void 0 ? void 0 : getCanonicalCommandIntents(command, storyView.state);
|
|
1393
|
+
if (intents === void 0) {
|
|
1394
|
+
refuse("Deleting the table is unavailable.", { gap: CANONICAL_GAP.commands });
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
prepared = prepareCanonicalCommands(session, storyView.state, intents, story);
|
|
1398
|
+
} else prepared = prepareCanonicalStructure(session, storyView.state, story, type);
|
|
1399
|
+
if (prepared.isErr()) {
|
|
1400
|
+
if (prepared.error.reason !== "noChange") refuse(prepared.error.message, prepared.error.ground);
|
|
1401
|
+
return false;
|
|
1402
|
+
}
|
|
1403
|
+
return publishStoryCommit(storyView, prepared.value);
|
|
1404
|
+
},
|
|
1405
|
+
cutCanonicalStory: ({ view: storyView, story, event }) => cutCanonical(storyView, event, story),
|
|
1467
1406
|
replaceCanonicalStoryText: ({ view: storyView, story, intent }) => {
|
|
1468
1407
|
if (!view || editorSession.type !== "canonical" || deps.getReadOnly()) return false;
|
|
1469
1408
|
syncCanonicalMode();
|
|
@@ -1,88 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConvertHeaderFooterOptions, HeaderFooterMetrics } from "../layout-bridge/convert/headerFooterLayout.js";
|
|
3
|
-
import "../layout-engine/index.js";
|
|
4
|
-
import { ColumnLayout, FlowBlock, FootnoteContent, HeaderFooterContent, Layout, Measure, PageHeaderFooterRefs, PageMargins } from "../layout-engine/types.js";
|
|
5
|
-
import { BlockLookup, LayoutPainter } from "../layout-painter/index.js";
|
|
6
|
-
import { FootnoteRenderItem } from "../layout-painter/renderPage.js";
|
|
7
|
-
import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
8
|
-
import { LayoutSelectionGate } from "../paged-layout/LayoutSelectionGate.js";
|
|
9
|
-
import { TemplatePreviewEntry, TemplatePreviewHiddenRange } from "../prosemirror/plugins/templatePreviewValues.js";
|
|
10
|
-
import { document_d_exports } from "../types/document.js";
|
|
11
|
-
import { DeepReadonly, ReadonlyDocument } from "../types/documentModel.js";
|
|
12
|
-
import { HyphenationReadiness } from "./hyphenationReadiness.js";
|
|
1
|
+
import { LayoutOutcome, LayoutPipelineDeps } from "./layoutPipelineExecution.js";
|
|
13
2
|
import { LayoutRunOptions } from "./layoutRunOptions.js";
|
|
14
|
-
import { LayoutSession } from "./layoutSession.js";
|
|
15
3
|
import { EditorState } from "prosemirror-state";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
layout?: Layout;
|
|
20
|
-
blockLookup?: BlockLookup;
|
|
21
|
-
};
|
|
22
|
-
export type LayoutPipelineDeps<THfPMs> = {
|
|
23
|
-
contentWidth: number;
|
|
24
|
-
columns: ColumnLayout | undefined;
|
|
25
|
-
pageSize: {
|
|
26
|
-
w: number;
|
|
27
|
-
h: number;
|
|
28
|
-
};
|
|
29
|
-
margins: PageMargins;
|
|
30
|
-
pageGap: number;
|
|
31
|
-
showMarginGuides: boolean;
|
|
32
|
-
marginGuideColor: string | undefined;
|
|
33
|
-
syncCoordinator: LayoutSelectionGate;
|
|
34
|
-
headerContent: document_d_exports.HeaderFooter | null | undefined;
|
|
35
|
-
footerContent: document_d_exports.HeaderFooter | null | undefined;
|
|
36
|
-
firstPageHeaderContent: document_d_exports.HeaderFooter | null | undefined;
|
|
37
|
-
firstPageFooterContent: document_d_exports.HeaderFooter | null | undefined;
|
|
38
|
-
headerContentRId: string | null | undefined;
|
|
39
|
-
footerContentRId: string | null | undefined;
|
|
40
|
-
firstPageHeaderContentRId: string | null | undefined;
|
|
41
|
-
firstPageFooterContentRId: string | null | undefined;
|
|
42
|
-
sectionHeaderFooterRefs: PageHeaderFooterRefs[] | undefined;
|
|
43
|
-
theme: DeepReadonly<document_d_exports.Theme> | null | undefined;
|
|
44
|
-
sectionProperties: document_d_exports.SectionProperties | null | undefined;
|
|
45
|
-
/** The model; the pipeline reads it through `readModel`. */
|
|
46
|
-
document: ReadonlyDocument | null;
|
|
47
|
-
defaultTabStop: number | undefined;
|
|
48
|
-
mirrorMargins: boolean;
|
|
49
|
-
styles: DeepReadonly<document_d_exports.StyleDefinitions> | null | undefined;
|
|
50
|
-
layout: Layout | null;
|
|
51
|
-
hfPMs: THfPMs;
|
|
52
|
-
painter: LayoutPainter | null;
|
|
53
|
-
pagesContainer: HTMLDivElement | null;
|
|
54
|
-
session: LayoutSession;
|
|
55
|
-
renderHfFromContentOrPm: (hf: document_d_exports.HeaderFooter | null | undefined, rId: string | null | undefined, hfPMs: THfPMs, contentWidth: number, metrics: HeaderFooterMetrics, options: ConvertHeaderFooterOptions) => HeaderFooterContent | undefined;
|
|
56
|
-
renderHeaderFooterContentByRId: (source: Map<string, document_d_exports.HeaderFooter> | undefined, hfPMs: THfPMs, contentWidth: number, metrics: HeaderFooterMetrics, options: ConvertHeaderFooterOptions) => Map<string, HeaderFooterContent> | undefined;
|
|
57
|
-
/** Names the faces measurement can use now (`fontReadiness.readFontSetSignature`). */
|
|
58
|
-
readFontSetSignature: () => string;
|
|
59
|
-
buildFootnoteRenderItems: (pageFootnoteMap: Map<number, number[]>, footnoteContentMap: Map<number, FootnoteContent>, doc: document_d_exports.Document | null) => Map<number, FootnoteRenderItem[]>;
|
|
60
|
-
describeInvalidHighlightMarks: (doc: EditorState["doc"]) => string;
|
|
61
|
-
/**
|
|
62
|
-
* Which renderer paints the pages. `"legacy"` is the painter that has always
|
|
63
|
-
* painted them; `"display-list"` builds the painter-neutral paint IR from
|
|
64
|
-
* this layout and paints the pages from it, so the editor and an export draw
|
|
65
|
-
* from one structure.
|
|
66
|
-
*
|
|
67
|
-
* Only the *painting* is swapped. Page shells, virtualization, the
|
|
68
|
-
* fingerprint comparison that skips an unchanged page and the painted event
|
|
69
|
-
* are page-container concerns and stay shared, because a second copy of them
|
|
70
|
-
* is how incremental repaint would quietly stop working on long documents.
|
|
71
|
-
*/
|
|
72
|
-
pageRenderer?: PageRendererName;
|
|
73
|
-
emptyTemplatePreviewEntries: readonly TemplatePreviewEntry[];
|
|
74
|
-
emptyTemplatePreviewHidden: readonly TemplatePreviewHiddenRange[];
|
|
75
|
-
/** Follows up on the hyphenation dictionaries a run lacked (relayout or error). */
|
|
76
|
-
hyphenationReadiness: HyphenationReadiness;
|
|
77
|
-
/**
|
|
78
|
-
* The review view the body is laid out for. A view other than All Markup
|
|
79
|
-
* lays out the text it shows (every revision accepted or rejected), not the
|
|
80
|
-
* authored text with runs hidden afterwards.
|
|
81
|
-
*/
|
|
82
|
-
markupView: DisplayMode;
|
|
83
|
-
/** Independent highlight visibility in All Markup; resolved views always hide comments. */
|
|
84
|
-
showCommentHighlights?: boolean;
|
|
85
|
-
/** Localised text for a `w:altChunk` that has no text of its own to show. */
|
|
86
|
-
altChunkMarkerText?: string;
|
|
87
|
-
};
|
|
88
|
-
export declare function runLayoutPipeline<THfPMs>(deps: LayoutPipelineDeps<THfPMs>, state: EditorState, options?: LayoutRunOptions): LayoutOutcome;
|
|
4
|
+
/** Run a synchronous layout pass for consumers of the core pipeline. */
|
|
5
|
+
export declare function runLayoutPipeline<THfPMs>(deps: LayoutPipelineDeps<THfPMs>, state: EditorState, options?: LayoutRunOptions): LayoutOutcome;
|
|
6
|
+
export type { LayoutOutcome, LayoutPipelineDeps };
|