@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Result } from "better-result";
|
|
2
|
+
// src/controller/deferredDisplayListPainter.ts
|
|
3
|
+
let painter;
|
|
4
|
+
let pending;
|
|
5
|
+
const loadPainter = () => {
|
|
6
|
+
pending ??= Result.tryPromise({
|
|
7
|
+
try: async () => {
|
|
8
|
+
const { createDisplayListPagePainter } = await import("../display-list/editor/displayListPagePainter.js");
|
|
9
|
+
painter = createDisplayListPagePainter;
|
|
10
|
+
return painter;
|
|
11
|
+
},
|
|
12
|
+
catch: (cause) => new Error("Could not load the display-list painter.", { cause })
|
|
13
|
+
}).then((result) => {
|
|
14
|
+
if (result.isErr()) pending = void 0;
|
|
15
|
+
return result;
|
|
16
|
+
});
|
|
17
|
+
return pending;
|
|
18
|
+
};
|
|
19
|
+
/** Notify an editor once per in-flight load, regardless of how many layouts requested it. */
|
|
20
|
+
const createDisplayListPainterLoader = ({ onReady, onError }) => {
|
|
21
|
+
let waiting = false;
|
|
22
|
+
return () => {
|
|
23
|
+
if (painter) return painter;
|
|
24
|
+
if (!waiting) {
|
|
25
|
+
waiting = true;
|
|
26
|
+
loadPainter().then((result) => {
|
|
27
|
+
waiting = false;
|
|
28
|
+
if (result.isOk()) onReady();
|
|
29
|
+
else onError(result.error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export { createDisplayListPainterLoader };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findPageNumberAtEditorPosition } from "../layout-engine/pmPageIndex.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CANONICAL_CONDITION } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { FOLIO_DOCX_SERIALIZATION_MODE } from "../types/docxSerialization.js";
|
|
4
4
|
import { NO_ANONYMIZATION_HIGHLIGHTS } from "./anonymizationHighlights.js";
|
|
5
5
|
import { NO_AUTOCOMPLETE, delegateAutocomplete } from "./hiddenEditorApi.js";
|
|
@@ -24,7 +24,7 @@ const createFolioEditor = (deps) => {
|
|
|
24
24
|
const api = deps.getEditorApi();
|
|
25
25
|
if (!api) return {
|
|
26
26
|
status: "refused",
|
|
27
|
-
|
|
27
|
+
ground: { condition: CANONICAL_CONDITION.notReady },
|
|
28
28
|
message: "The editor is not ready for section changes."
|
|
29
29
|
};
|
|
30
30
|
return api.applyCanonicalSectionProperties(patch);
|
|
@@ -33,6 +33,8 @@ const createFolioEditor = (deps) => {
|
|
|
33
33
|
getCanonicalStorySelection: (story) => deps.getEditorApi()?.getCanonicalStorySelection(story) ?? null,
|
|
34
34
|
getCanonicalStoryProjection: (story) => deps.getEditorApi()?.getCanonicalStoryProjection(story) ?? null,
|
|
35
35
|
replaceCanonicalStoryText: (options) => deps.getEditorApi()?.replaceCanonicalStoryText(options) ?? false,
|
|
36
|
+
applyCanonicalStoryStructure: (options) => deps.getEditorApi()?.applyCanonicalStoryStructure(options) ?? false,
|
|
37
|
+
cutCanonicalStory: (options) => deps.getEditorApi()?.cutCanonicalStory(options) ?? false,
|
|
36
38
|
noteCanonicalStoryView: (options) => {
|
|
37
39
|
deps.getEditorApi()?.noteCanonicalStoryView(options);
|
|
38
40
|
},
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { CanonicalSessionError } from "../canonical/canonicalSession.js";
|
|
2
2
|
import { createNativeNavigationPlugin, createNativeSelectionRefreshPlugin } from "../prosemirror/nativeSelection.js";
|
|
3
|
-
import { noteReferenceTransactionIssue } from "../prosemirror/noteReferenceOccurrences.js";
|
|
4
3
|
import { createDocumentNumberingPlugin } from "../prosemirror/plugins/documentNumbering.js";
|
|
5
4
|
import { createDocumentStyleContextPlugin } from "../prosemirror/plugins/documentStyles.js";
|
|
6
|
-
import {
|
|
5
|
+
import { CANONICAL_CONDITION } from "../types/canonicalCapabilities.js";
|
|
7
6
|
import { readModel } from "../types/documentModel.js";
|
|
8
7
|
import { createCanonicalStoryEditor, refreshCanonicalStoryView } from "./canonicalStoryEditor.js";
|
|
9
8
|
import { OP_STORIES } from "@stll/docx-core/ops";
|
|
@@ -98,7 +97,6 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
98
97
|
},
|
|
99
98
|
getView: () => view,
|
|
100
99
|
getApi: () => deps.getCanonicalApi?.() ?? null,
|
|
101
|
-
enabled: () => true,
|
|
102
100
|
onRefusal: deps.onSessionRefusal,
|
|
103
101
|
onSelectionChange: () => deps.onTransaction?.({
|
|
104
102
|
kind: part.kind,
|
|
@@ -131,19 +129,7 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
131
129
|
}),
|
|
132
130
|
dispatchTransaction(transaction) {
|
|
133
131
|
if ((deps.getReadOnly?.() ?? false) && transaction.docChanged) return;
|
|
134
|
-
|
|
135
|
-
const nextState = view.state.apply(transaction);
|
|
136
|
-
const docChanged = !nextState.doc.eq(view.state.doc);
|
|
137
|
-
const noteIssue = noteReferenceTransactionIssue(transaction);
|
|
138
|
-
if (noteIssue) deps.onSessionRefusal?.(noteIssue.message, { gap: CANONICAL_GAP.dispatch }, noteIssue);
|
|
139
|
-
view.updateState(nextState);
|
|
140
|
-
deps.onTransaction?.({
|
|
141
|
-
docChanged,
|
|
142
|
-
kind: part.kind,
|
|
143
|
-
rId: part.rId,
|
|
144
|
-
selectionChanged: transaction.selectionSet,
|
|
145
|
-
view
|
|
146
|
-
});
|
|
132
|
+
canonical.dispatch(transaction);
|
|
147
133
|
}
|
|
148
134
|
});
|
|
149
135
|
mounted.set(part.rId, {
|
|
@@ -165,7 +151,7 @@ const createHeaderFooterEditorManager = (deps) => {
|
|
|
165
151
|
const canonical = deps.getCanonicalApi?.()?.getCanonicalDocument();
|
|
166
152
|
if (canonical) return canonical;
|
|
167
153
|
throw new CanonicalSessionError({
|
|
168
|
-
ground: {
|
|
154
|
+
ground: { condition: CANONICAL_CONDITION.notReady },
|
|
169
155
|
reason: "refused",
|
|
170
156
|
message: "Canonical story snapshot is unavailable."
|
|
171
157
|
});
|
|
@@ -19,7 +19,7 @@ import { ReadonlyDocument } from "../types/documentModel.js";
|
|
|
19
19
|
import { FolioDocxSerializationPath } from "../types/docxSerialization.js";
|
|
20
20
|
import { FolioFieldInsertion } from "../types/fields.js";
|
|
21
21
|
import { AnonymizationHighlightsView } from "./anonymizationHighlights.js";
|
|
22
|
-
import { createCanonicalInputBoundary } from "./canonicalInput.js";
|
|
22
|
+
import { CanonicalStructureInput, createCanonicalInputBoundary } from "./canonicalInput.js";
|
|
23
23
|
import { Command, EditorState, Transaction } from "prosemirror-state";
|
|
24
24
|
import { Node } from "prosemirror-model";
|
|
25
25
|
import { DocumentOp, FormattingPatch, OpStory, TextPosition } from "@stll/docx-core/ops";
|
|
@@ -47,6 +47,16 @@ type CanonicalStoryTextOptions = {
|
|
|
47
47
|
story: OpStory;
|
|
48
48
|
intent: Parameters<Parameters<typeof createCanonicalInputBoundary>[0]["replace"]>[0];
|
|
49
49
|
};
|
|
50
|
+
type CanonicalStoryStructureOptions = {
|
|
51
|
+
view: EditorView;
|
|
52
|
+
story: OpStory;
|
|
53
|
+
type: CanonicalStructureInput;
|
|
54
|
+
};
|
|
55
|
+
type CanonicalStoryCutOptions = {
|
|
56
|
+
view: EditorView;
|
|
57
|
+
story: OpStory;
|
|
58
|
+
event: ClipboardEvent;
|
|
59
|
+
};
|
|
50
60
|
/** The package a canonical save wrote, and whether it patched its baseline. */
|
|
51
61
|
export type CanonicalSavedPackage = {
|
|
52
62
|
buffer: ArrayBuffer;
|
|
@@ -99,7 +109,7 @@ export type HiddenEditorApi = {
|
|
|
99
109
|
applyCanonicalStoryHistory: (options: CanonicalStoryHistoryOptions) => boolean;
|
|
100
110
|
applyCanonicalOperations: (ops: readonly DocumentOp[]) => boolean;
|
|
101
111
|
applyCanonicalComment: (request: CanonicalCommentRequest) => CanonicalCommentResult | null;
|
|
102
|
-
/** Apply a final-section patch
|
|
112
|
+
/** Apply a final-section patch to the canonical session. */
|
|
103
113
|
applyCanonicalSectionProperties: (patch: FormattingPatch<document_d_exports.SectionProperties>) => CanonicalSectionPropertiesResult | null;
|
|
104
114
|
/**
|
|
105
115
|
* Where the editor of a header, footer or note shows its text selection in
|
|
@@ -113,6 +123,17 @@ export type HiddenEditorApi = {
|
|
|
113
123
|
} | null;
|
|
114
124
|
getCanonicalStoryProjection: (story: OpStory) => Node | null;
|
|
115
125
|
replaceCanonicalStoryText: (options: CanonicalStoryTextOptions) => boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Make the structure edit a key asks for in the editor of a header, footer
|
|
128
|
+
* or note, as the body's editor makes it: one journalled change.
|
|
129
|
+
*/
|
|
130
|
+
applyCanonicalStoryStructure: (options: CanonicalStoryStructureOptions) => boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Cut the selection of a header, footer or note editor: the clipboard takes
|
|
133
|
+
* it and the story loses it, as one journalled change. True when the editor
|
|
134
|
+
* handled the event.
|
|
135
|
+
*/
|
|
136
|
+
cutCanonicalStory: (options: CanonicalStoryCutOptions) => boolean;
|
|
116
137
|
/**
|
|
117
138
|
* The editor a person is working in for `story`: public operations on that
|
|
118
139
|
* story read its state, so its selection maps through them, and publish to
|
|
@@ -193,7 +214,7 @@ export type HiddenEditorApiDeps = {
|
|
|
193
214
|
resolveCanonicalSuggestion?: HiddenEditorApi["resolveCanonicalSuggestion"];
|
|
194
215
|
executeCanonicalCommand?: (command: Command) => boolean | undefined;
|
|
195
216
|
getCanonicalHistory?: () => Pick<HiddenEditorApi, "undo" | "redo" | "canUndo" | "canRedo"> | null;
|
|
196
|
-
canonicalOperations?: Pick<HiddenEditorApi, "updateCanonicalInputLifecycle" | "applyCanonicalOperations" | "applyCanonicalComment" | "applyCanonicalSectionProperties" | "getCanonicalStoryProjection" | "replaceCanonicalStoryText" | "noteCanonicalStoryView" | "applyCanonicalStoryHistory" | "getCanonicalStorySelection" | "applyCanonicalDocumentOperations" | "undoCanonicalDocumentOperations">;
|
|
217
|
+
canonicalOperations?: Pick<HiddenEditorApi, "updateCanonicalInputLifecycle" | "applyCanonicalOperations" | "applyCanonicalComment" | "applyCanonicalSectionProperties" | "getCanonicalStoryProjection" | "replaceCanonicalStoryText" | "applyCanonicalStoryStructure" | "cutCanonicalStory" | "noteCanonicalStoryView" | "applyCanonicalStoryHistory" | "getCanonicalStorySelection" | "applyCanonicalDocumentOperations" | "undoCanonicalDocumentOperations">;
|
|
197
218
|
isDestroying: () => boolean;
|
|
198
219
|
ensureView: () => void;
|
|
199
220
|
isViewRequested: () => boolean;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { cloneDocumentWithParagraphPropertySources } from "../docx/paragraphPropertySource.js";
|
|
2
|
-
import { fromProseDoc } from "../prosemirror/conversion/fromProseDoc.js";
|
|
3
|
-
import { readModel } from "../types/documentModel.js";
|
|
4
2
|
import { NO_ANONYMIZATION_HIGHLIGHTS } from "./anonymizationHighlights.js";
|
|
5
3
|
import { IDLE_AUTOCOMPLETE } from "./autocompleteSuggestion.js";
|
|
6
4
|
import { legacyEditorPositionAt } from "./textPositionLookup.js";
|
|
7
|
-
import { CellSelection } from "prosemirror-tables";
|
|
8
5
|
import { NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
6
|
+
import { CellSelection } from "prosemirror-tables";
|
|
9
7
|
import { redo, undo } from "prosemirror-history";
|
|
10
8
|
// src/controller/hiddenEditorApi.ts
|
|
11
9
|
/** No editor: nothing to suggest in. */
|
|
@@ -30,13 +28,6 @@ const delegateAutocomplete = (current) => ({
|
|
|
30
28
|
get: () => current().get(),
|
|
31
29
|
canTrigger: () => current().canTrigger()
|
|
32
30
|
});
|
|
33
|
-
/**
|
|
34
|
-
* Convert PM state to Document
|
|
35
|
-
*/
|
|
36
|
-
const stateToDocument = (state, originalDoc) => {
|
|
37
|
-
if (!originalDoc) return null;
|
|
38
|
-
return fromProseDoc(state.doc, readModel(originalDoc), { stylesheetSource: { type: "package" } });
|
|
39
|
-
};
|
|
40
31
|
const createHiddenEditorApi = (deps) => {
|
|
41
32
|
const dispatchTr = (view, tr) => {
|
|
42
33
|
if (!deps.isDestroying()) view.dispatch(tr);
|
|
@@ -82,13 +73,7 @@ const createHiddenEditorApi = (deps) => {
|
|
|
82
73
|
getAnonymizationHighlights: () => deps.getAnonymizationHighlights?.() ?? NO_ANONYMIZATION_HIGHLIGHTS,
|
|
83
74
|
insertField: (field) => deps.insertField?.(field) ?? false,
|
|
84
75
|
autocomplete: deps.autocomplete ?? NO_AUTOCOMPLETE,
|
|
85
|
-
getDocument: () =>
|
|
86
|
-
const canonical = deps.getCanonicalDocument?.();
|
|
87
|
-
if (canonical) return canonical;
|
|
88
|
-
const view = deps.getView();
|
|
89
|
-
if (!view) return null;
|
|
90
|
-
return stateToDocument(view.state, deps.getDocumentContext());
|
|
91
|
-
},
|
|
76
|
+
getDocument: () => deps.getCanonicalDocument?.() ?? deps.getDocumentContext(),
|
|
92
77
|
updateCanonicalInputLifecycle: (action) => deps.canonicalOperations?.updateCanonicalInputLifecycle(action) ?? false,
|
|
93
78
|
applyCanonicalStoryHistory: (options) => deps.canonicalOperations?.applyCanonicalStoryHistory(options) ?? false,
|
|
94
79
|
applyCanonicalComment: (request) => deps.canonicalOperations?.applyCanonicalComment(request) ?? null,
|
|
@@ -97,6 +82,8 @@ const createHiddenEditorApi = (deps) => {
|
|
|
97
82
|
getCanonicalStorySelection: (story) => deps.canonicalOperations?.getCanonicalStorySelection(story) ?? null,
|
|
98
83
|
getCanonicalStoryProjection: (story) => deps.canonicalOperations?.getCanonicalStoryProjection(story) ?? null,
|
|
99
84
|
replaceCanonicalStoryText: (options) => deps.canonicalOperations?.replaceCanonicalStoryText(options) ?? false,
|
|
85
|
+
applyCanonicalStoryStructure: (options) => deps.canonicalOperations?.applyCanonicalStoryStructure(options) ?? false,
|
|
86
|
+
cutCanonicalStory: (options) => deps.canonicalOperations?.cutCanonicalStory(options) ?? false,
|
|
100
87
|
noteCanonicalStoryView: (options) => {
|
|
101
88
|
deps.canonicalOperations?.noteCanonicalStoryView(options);
|
|
102
89
|
},
|