@stll/folio-core 0.54.2 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +22 -1
- package/dist/ai-edits/headless.js +1 -0
- package/dist/compare/content-types.d.ts +3 -15
- package/dist/controller/canonicalComposition.d.ts +36 -0
- package/dist/controller/canonicalComposition.js +168 -0
- package/dist/controller/canonicalInput.d.ts +45 -0
- package/dist/controller/canonicalInput.js +338 -0
- package/dist/controller/canonicalOperations.d.ts +22 -0
- package/dist/controller/canonicalOperations.js +85 -0
- package/dist/controller/canonicalReview.d.ts +12 -0
- package/dist/controller/canonicalReview.js +19 -0
- package/dist/controller/canonicalSession.d.ts +149 -0
- package/dist/controller/canonicalSession.js +1038 -0
- package/dist/controller/canonicalStoryEditor.d.ts +34 -0
- package/dist/controller/canonicalStoryEditor.js +82 -0
- package/dist/controller/canonicalStructure.d.ts +16 -0
- package/dist/controller/canonicalStructure.js +269 -0
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/folioEditor.js +9 -0
- package/dist/controller/headerFooterEditorManager.d.ts +4 -0
- package/dist/controller/headerFooterEditorManager.js +71 -3
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +25 -8
- package/dist/controller/hiddenEditorManager.d.ts +11 -2
- package/dist/controller/hiddenEditorManager.js +456 -30
- package/dist/controller/layoutPipeline.d.ts +1 -1
- package/dist/controller/layoutPipeline.js +2 -0
- package/dist/controller/noteEditorManager.d.ts +4 -0
- package/dist/controller/noteEditorManager.js +113 -15
- package/dist/docx/attributeRemainder.js +1 -0
- package/dist/docx/canonicalSessionInput.d.ts +11 -0
- package/dist/docx/canonicalSessionInput.js +27 -0
- package/dist/docx/canonicalStoryRepack.d.ts +10 -0
- package/dist/docx/canonicalStoryRepack.js +41 -0
- package/dist/docx/contentTypeRegistry.d.ts +8 -0
- package/dist/docx/contentTypeRegistry.js +64 -0
- package/dist/docx/ensureParaIds.d.ts +7 -1
- package/dist/docx/ensureParaIds.js +163 -211
- package/dist/docx/foldedListNumberFields.d.ts +85 -0
- package/dist/docx/foldedListNumberFields.js +267 -0
- package/dist/docx/headerFooterVerbatim.d.ts +14 -1
- package/dist/docx/headerFooterVerbatim.js +95 -2
- package/dist/docx/noteIds.d.ts +5 -0
- package/dist/docx/noteIds.js +6 -2
- package/dist/docx/noteReferenceMark.d.ts +3 -1
- package/dist/docx/noteReferenceMark.js +15 -14
- package/dist/docx/numberingParser.d.ts +3 -1
- package/dist/docx/numberingParser.js +17 -3
- package/dist/docx/packageParts.d.ts +3 -1
- package/dist/docx/packageParts.js +65 -16
- package/dist/docx/paragraphMarkPropertyPresence.d.ts +9 -0
- package/dist/docx/paragraphMarkPropertyPresence.js +21 -0
- package/dist/docx/paragraphParser.js +101 -53
- package/dist/docx/paragraphPropertySource.d.ts +15 -1
- package/dist/docx/paragraphPropertySource.js +76 -22
- package/dist/docx/parser.js +2 -1
- package/dist/docx/reviewHistoryNamespace.d.ts +4 -0
- package/dist/docx/reviewHistoryNamespace.js +4 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +25 -0
- package/dist/docx/reviewResolutionProvenance.js +153 -0
- package/dist/docx/rezip.d.ts +7 -3
- package/dist/docx/rezip.js +107 -45
- package/dist/docx/runConsolidator.d.ts +2 -58
- package/dist/docx/runConsolidator.js +3 -175
- package/dist/docx/runParser.d.ts +2 -1
- package/dist/docx/runParser.js +156 -116
- package/dist/docx/saveDiagnostics.d.ts +11 -0
- package/dist/docx/saveDiagnostics.js +0 -0
- package/dist/docx/selectiveSave.d.ts +2 -1
- package/dist/docx/selectiveSave.js +4 -1
- package/dist/docx/selectiveXmlPatch.d.ts +16 -8
- package/dist/docx/selectiveXmlPatch.js +74 -2
- package/dist/docx/serializer/headerFooterSerializer.d.ts +5 -1
- package/dist/docx/serializer/headerFooterSerializer.js +19 -11
- package/dist/docx/serializer/noteSerializer.d.ts +2 -2
- package/dist/docx/serializer/noteSerializer.js +24 -8
- package/dist/docx/serializer/paragraphSerializer.js +41 -4
- package/dist/docx/serializer/partNamespaces.js +2 -1
- package/dist/docx/serializer/runSerializer.js +3 -1
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +5 -0
- package/dist/docx/settingsHeaderFooterUpdate.js +90 -0
- package/dist/docx/settingsParser.d.ts +1 -2
- package/dist/docx/settingsParser.js +5 -6
- package/dist/docx/storyBlockReplay.d.ts +11 -0
- package/dist/docx/storyBlockReplay.js +367 -0
- package/dist/docx/streamingXmlParser.d.ts +22 -1
- package/dist/docx/streamingXmlParser.js +49 -3
- package/dist/docx/structuralXmlPatch.js +8 -1
- package/dist/docx/verbatimCapture.d.ts +3 -1
- package/dist/docx/verbatimCapture.js +49 -6
- package/dist/i18n/messages/ar.gen.d.ts +5 -0
- package/dist/i18n/messages/ar.gen.js +656 -0
- package/dist/i18n/messages/cs.gen.d.ts +5 -0
- package/dist/i18n/messages/cs.gen.js +656 -0
- package/dist/i18n/messages/de.gen.d.ts +5 -0
- package/dist/i18n/messages/de.gen.js +656 -0
- package/dist/i18n/messages/en.gen.d.ts +5 -0
- package/dist/i18n/messages/en.gen.js +656 -0
- package/dist/i18n/messages/es.gen.d.ts +5 -0
- package/dist/i18n/messages/es.gen.js +656 -0
- package/dist/i18n/messages/et.gen.d.ts +5 -0
- package/dist/i18n/messages/et.gen.js +656 -0
- package/dist/i18n/messages/fr.gen.d.ts +5 -0
- package/dist/i18n/messages/fr.gen.js +656 -0
- package/dist/i18n/messages/he.gen.d.ts +5 -0
- package/dist/i18n/messages/he.gen.js +656 -0
- package/dist/i18n/messages/hi.gen.d.ts +5 -0
- package/dist/i18n/messages/hi.gen.js +656 -0
- package/dist/i18n/messages/hu.gen.d.ts +5 -0
- package/dist/i18n/messages/hu.gen.js +656 -0
- package/dist/i18n/messages/locales.d.ts +5 -0
- package/dist/i18n/messages/locales.js +22 -0
- package/dist/i18n/messages/lt.gen.d.ts +5 -0
- package/dist/i18n/messages/lt.gen.js +656 -0
- package/dist/i18n/messages/lv.gen.d.ts +5 -0
- package/dist/i18n/messages/lv.gen.js +656 -0
- package/dist/i18n/messages/pl.gen.d.ts +5 -0
- package/dist/i18n/messages/pl.gen.js +656 -0
- package/dist/i18n/messages/pt-BR.gen.d.ts +5 -0
- package/dist/i18n/messages/pt-BR.gen.js +656 -0
- package/dist/i18n/messages/sk.gen.d.ts +5 -0
- package/dist/i18n/messages/sk.gen.js +656 -0
- package/dist/i18n/messages/tr.gen.d.ts +5 -0
- package/dist/i18n/messages/tr.gen.js +656 -0
- package/dist/i18n/messages/zh-CN.gen.d.ts +5 -0
- package/dist/i18n/messages/zh-CN.gen.js +656 -0
- package/dist/i18n/messages.d.ts +2 -3
- package/dist/i18n/messages.js +1 -19
- package/dist/internal/noteMarkerAttrs.d.ts +8 -0
- package/dist/internal/noteMarkerAttrs.js +16 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +1 -0
- package/dist/internal/prosemirrorAttrBoundary.d.ts +21 -0
- package/dist/internal/prosemirrorAttrBoundary.js +50 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +1 -0
- package/dist/layout-bridge/convert/noteReferences.d.ts +1 -3
- package/dist/layout-bridge/convert/noteReferences.js +1 -6
- package/dist/layout-bridge/convert/paragraphRuns.js +2 -4
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +2 -2
- package/dist/managers/DocumentLoaderManager.d.ts +1 -0
- package/dist/managers/DocumentLoaderManager.js +8 -1
- package/dist/markdown/renderBlock.js +15 -1
- package/dist/markdown/renderParagraph.js +9 -13
- package/dist/markdown/renderRuns.js +3 -2
- package/dist/markdown/renderTable.js +2 -0
- package/dist/markdown/types.d.ts +3 -9
- package/dist/prosemirror/attrs/index.d.ts +2 -12
- package/dist/prosemirror/attrs/index.js +22 -48
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +2 -1
- package/dist/prosemirror/canonicalCommands.d.ts +97 -0
- package/dist/prosemirror/canonicalCommands.js +28 -0
- package/dist/prosemirror/commands/pageBreak.js +15 -1
- package/dist/prosemirror/commentReferenceAttrs.d.ts +2 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +91 -19
- package/dist/prosemirror/conversion/listRenderingDefinition.d.ts +6 -0
- package/dist/prosemirror/conversion/listRenderingDefinition.js +97 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -3
- package/dist/prosemirror/conversion/toProseDoc.js +51 -11
- package/dist/prosemirror/executeEditorCommand.d.ts +11 -0
- package/dist/prosemirror/executeEditorCommand.js +26 -0
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +50 -19
- package/dist/prosemirror/extensions/features/ListExtension.js +18 -5
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +5 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +13 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +3 -2
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +70 -8
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/NoteMarkerExtension.js +36 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +4 -2
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +16 -7
- package/dist/prosemirror/listNumbering.js +26 -5
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/markupViewNotes.js +3 -2
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +2 -1
- package/dist/prosemirror/noteReferenceReview.js +5 -3
- package/dist/prosemirror/plugins/suggestionMode.js +50 -2
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +2 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +4 -1
- package/dist/prosemirror/runFormattingFromMarks.js +15 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +4 -1
- package/dist/prosemirror/schema/marks.d.ts +2 -0
- package/dist/prosemirror/schema/nodes.d.ts +10 -2
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +2 -1
- package/dist/prosemirror/textInput.js +5 -1
- package/dist/prosemirror/trackedRevisionPath.js +2 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +1 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +1 -0
- package/dist/prosemirror/validation.js +4 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +2 -2
- package/package.json +14 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { visitDocxParagraphs } from "../docx/paragraphTraversal.js";
|
|
2
|
+
import { generateHexId, isValidHexId } from "../utils/hexId.js";
|
|
3
|
+
import { DOCUMENT_OP_TYPES, DOCUMENT_OP_TYPES as DOCUMENT_OP_TYPES$1 } from "@stll/docx-core/ops";
|
|
4
|
+
//#region src/controller/canonicalOperations.ts
|
|
5
|
+
/** Adapter command boundaries allocate identities; journaled operations remain deterministic. */
|
|
6
|
+
const canonicalFinalSectionIndex = (document) => document.package.document.content.filter((block) => block.type === "paragraph" && block.sectionProperties !== void 0).length;
|
|
7
|
+
const withCanonicalParagraphIds = (content, document) => {
|
|
8
|
+
const taken = /* @__PURE__ */ new Set();
|
|
9
|
+
const { document: documentBody, headers, footers, footnotes, endnotes } = document.package;
|
|
10
|
+
visitDocxParagraphs({
|
|
11
|
+
documentBody,
|
|
12
|
+
headers,
|
|
13
|
+
footers,
|
|
14
|
+
footnotes,
|
|
15
|
+
endnotes
|
|
16
|
+
}, (paragraph) => {
|
|
17
|
+
if (paragraph.paraId) taken.add(paragraph.paraId.toUpperCase());
|
|
18
|
+
});
|
|
19
|
+
const owned = structuredClone(content);
|
|
20
|
+
visitDocxParagraphs({ documentBody: { content: owned } }, (paragraph) => {
|
|
21
|
+
if (paragraph.paraId && isValidHexId(paragraph.paraId) && Number.parseInt(paragraph.paraId, 16) > 0 && Number.parseInt(paragraph.paraId, 16) < 2147483647 && !taken.has(paragraph.paraId.toUpperCase())) {
|
|
22
|
+
taken.add(paragraph.paraId.toUpperCase());
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let paraId = generateHexId();
|
|
26
|
+
while (taken.has(paraId)) paraId = generateHexId();
|
|
27
|
+
taken.add(paraId);
|
|
28
|
+
paragraph.paraId = paraId;
|
|
29
|
+
});
|
|
30
|
+
return owned;
|
|
31
|
+
};
|
|
32
|
+
const createCanonicalHeaderFooterOperation = ({ document, position, referenceType, sectionIndex = canonicalFinalSectionIndex(document) }) => {
|
|
33
|
+
const occupied = /* @__PURE__ */ new Set([
|
|
34
|
+
...document.package.headers?.keys() ?? [],
|
|
35
|
+
...document.package.footers?.keys() ?? [],
|
|
36
|
+
...document.package.relationships?.keys() ?? []
|
|
37
|
+
]);
|
|
38
|
+
const base = `rId_new_${position}_${referenceType}`;
|
|
39
|
+
let rId = base;
|
|
40
|
+
let suffix = 2;
|
|
41
|
+
while (occupied.has(rId)) rId = `${base}_${suffix++}`;
|
|
42
|
+
return {
|
|
43
|
+
type: DOCUMENT_OP_TYPES$1.CREATE_HEADER_FOOTER,
|
|
44
|
+
sectionIndex,
|
|
45
|
+
story: {
|
|
46
|
+
kind: position,
|
|
47
|
+
rId
|
|
48
|
+
},
|
|
49
|
+
referenceType,
|
|
50
|
+
content: withCanonicalParagraphIds([{
|
|
51
|
+
type: "paragraph",
|
|
52
|
+
content: []
|
|
53
|
+
}], document)
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** Remove each explicit binding, leaving inherited sections to inherit the remaining parts. */
|
|
57
|
+
const removeCanonicalHeaderFooterOperations = ({ document, position, rId }) => {
|
|
58
|
+
const properties = [];
|
|
59
|
+
for (const block of document.package.document.content) if (block.type === "paragraph" && block.sectionProperties) properties.push(block.sectionProperties);
|
|
60
|
+
properties.push(document.package.document.finalSectionProperties ?? {});
|
|
61
|
+
const operations = [];
|
|
62
|
+
for (const [sectionIndex, section] of properties.entries()) {
|
|
63
|
+
const references = position === "header" ? section.headerReferences : section.footerReferences;
|
|
64
|
+
for (const reference of references ?? []) {
|
|
65
|
+
if (reference.rId !== rId) continue;
|
|
66
|
+
operations.push({
|
|
67
|
+
type: DOCUMENT_OP_TYPES$1.REMOVE_HEADER_FOOTER,
|
|
68
|
+
sectionIndex,
|
|
69
|
+
story: {
|
|
70
|
+
kind: position,
|
|
71
|
+
rId
|
|
72
|
+
},
|
|
73
|
+
referenceType: reference.type
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return operations;
|
|
78
|
+
};
|
|
79
|
+
const createCanonicalSectionPropertiesOperation = (document, patch) => ({
|
|
80
|
+
type: DOCUMENT_OP_TYPES$1.SET_SECTION_PROPS,
|
|
81
|
+
sectionIndex: canonicalFinalSectionIndex(document),
|
|
82
|
+
patch
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { DOCUMENT_OP_TYPES, canonicalFinalSectionIndex, createCanonicalHeaderFooterOperation, createCanonicalSectionPropertiesOperation, removeCanonicalHeaderFooterOperations, withCanonicalParagraphIds };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FolioEditor } from "./folioEditor.js";
|
|
2
|
+
//#region src/controller/canonicalReview.d.ts
|
|
3
|
+
type ResolveCanonicalReviewRangeOptions = {
|
|
4
|
+
editor: Pick<FolioEditor, "getCanonicalDocument" | "getState" | "resolveCanonicalRevisions"> | null | undefined;
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
resolution: "accept" | "reject";
|
|
8
|
+
};
|
|
9
|
+
/** Null delegates to the default session's ProseMirror review commands. */
|
|
10
|
+
declare const resolveCanonicalReviewRange: ({ editor, from, to, resolution }: ResolveCanonicalReviewRangeOptions) => boolean | null;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { resolveCanonicalReviewRange };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getTrackedChangeGroupIdsFromDoc, getTrackedChangesFromDoc } from "../ai-edits/read.js";
|
|
2
|
+
import { findAIEditRevisionRange } from "../prosemirror/commands/comments.js";
|
|
3
|
+
//#region src/controller/canonicalReview.ts
|
|
4
|
+
/** Null delegates to the default session's ProseMirror review commands. */
|
|
5
|
+
const resolveCanonicalReviewRange = ({ editor, from, to, resolution }) => {
|
|
6
|
+
if (!editor?.getCanonicalDocument()) return null;
|
|
7
|
+
const state = editor.getState();
|
|
8
|
+
if (!state) return false;
|
|
9
|
+
const ids = /* @__PURE__ */ new Set();
|
|
10
|
+
for (const change of getTrackedChangesFromDoc(state.doc)) {
|
|
11
|
+
const groupIds = getTrackedChangeGroupIdsFromDoc(state.doc, change.id);
|
|
12
|
+
const range = findAIEditRevisionRange(state, groupIds);
|
|
13
|
+
if (!range) continue;
|
|
14
|
+
if (from === to ? range.from <= from && range.to >= to : range.from < to && range.to > from) for (const id of groupIds) ids.add(id);
|
|
15
|
+
}
|
|
16
|
+
return ids.size > 0 && editor.resolveCanonicalRevisions([...ids], resolution);
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { resolveCanonicalReviewRange };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { EditorState, Transaction } from "prosemirror-state";
|
|
4
|
+
import { Result } from "better-result";
|
|
5
|
+
import { DocumentOp, EditorIntent, OpStory, TextPosition, TouchedBlocks } from "@stll/docx-core/ops";
|
|
6
|
+
//#region src/controller/canonicalSession.d.ts
|
|
7
|
+
declare const CanonicalSessionError_base: import("better-result").TaggedErrorClass<"CanonicalSessionError">;
|
|
8
|
+
declare class CanonicalSessionError extends CanonicalSessionError_base<{
|
|
9
|
+
message: string;
|
|
10
|
+
reason: "refused" | "noChange";
|
|
11
|
+
}> {}
|
|
12
|
+
type CanonicalSelection = {
|
|
13
|
+
anchor: TextPosition;
|
|
14
|
+
head: TextPosition;
|
|
15
|
+
};
|
|
16
|
+
type CanonicalOrigin = "input" | "undo" | "redo";
|
|
17
|
+
type CanonicalSessionMode = {
|
|
18
|
+
type: "editing";
|
|
19
|
+
} | {
|
|
20
|
+
type: "suggesting";
|
|
21
|
+
author: string;
|
|
22
|
+
};
|
|
23
|
+
declare const CANONICAL_PROJECTION_META = "folioCanonicalProjection";
|
|
24
|
+
type ParagraphAddress = {
|
|
25
|
+
blockId: string;
|
|
26
|
+
start: number;
|
|
27
|
+
text: string;
|
|
28
|
+
boundaries: readonly (readonly number[])[];
|
|
29
|
+
node: Node;
|
|
30
|
+
source: document_d_exports.Paragraph;
|
|
31
|
+
};
|
|
32
|
+
type CanonicalProjectionOptions = {
|
|
33
|
+
doc: Node;
|
|
34
|
+
paragraphs: readonly ParagraphAddress[];
|
|
35
|
+
story: OpStory;
|
|
36
|
+
};
|
|
37
|
+
/** Paragraph gaps map logical UTF-16 units and zero-width note marks to PM positions. */
|
|
38
|
+
declare class CanonicalProjection {
|
|
39
|
+
readonly doc: Node;
|
|
40
|
+
readonly story: OpStory;
|
|
41
|
+
private readonly paragraphs;
|
|
42
|
+
private readonly paragraphsById;
|
|
43
|
+
constructor({ doc, paragraphs, story }: CanonicalProjectionOptions);
|
|
44
|
+
addressAt(position: number): Result<TextPosition, CanonicalSessionError>;
|
|
45
|
+
inputAddressAt(position: number): Result<TextPosition, CanonicalSessionError>;
|
|
46
|
+
positionAt(address: TextPosition): Result<number, CanonicalSessionError>;
|
|
47
|
+
selectionAt(state: EditorState): Result<CanonicalSelection, CanonicalSessionError>;
|
|
48
|
+
paragraph(blockId: string): ParagraphAddress | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Input intent, never projection-step adjacency, determines the journal partition. */
|
|
51
|
+
type CanonicalInputSemantic = "typing" | "deleteBackward" | "deleteForward" | "paste" | "composition" | "replacement" | "structure";
|
|
52
|
+
type CanonicalCommit = {
|
|
53
|
+
transaction: Transaction;
|
|
54
|
+
document: document_d_exports.Document;
|
|
55
|
+
projection: CanonicalProjection;
|
|
56
|
+
bodyProjection: CanonicalProjection;
|
|
57
|
+
touched: TouchedBlocks;
|
|
58
|
+
version: number;
|
|
59
|
+
origin: CanonicalOrigin;
|
|
60
|
+
/** Publish only after every projection/plugin transaction has been accepted. */
|
|
61
|
+
publish: () => Result<void, CanonicalSessionError>;
|
|
62
|
+
};
|
|
63
|
+
/** Metadata is descriptive; transaction identity and session version authorize mutations. */
|
|
64
|
+
declare const isCanonicalProjectionTransaction: (transaction: Transaction, session: CanonicalSession) => boolean;
|
|
65
|
+
type PublishCanonicalProjectionOptions = {
|
|
66
|
+
state: EditorState;
|
|
67
|
+
commit: CanonicalCommit;
|
|
68
|
+
session: CanonicalSession;
|
|
69
|
+
};
|
|
70
|
+
/** The model publishes only after PM and every plugin accept its exact projection. */
|
|
71
|
+
declare const publishCanonicalProjection: ({ state, commit, session }: PublishCanonicalProjectionOptions) => import("better-result").Err<never, CanonicalSessionError> | import("better-result").Ok<{
|
|
72
|
+
state: EditorState;
|
|
73
|
+
transactions: readonly Transaction[];
|
|
74
|
+
}, never>;
|
|
75
|
+
type CanonicalSessionSeedOptions = {
|
|
76
|
+
document: document_d_exports.Document;
|
|
77
|
+
projection: CanonicalProjection;
|
|
78
|
+
styles: document_d_exports.StyleDefinitions | null | undefined;
|
|
79
|
+
};
|
|
80
|
+
type CanonicalReplaceTextInput = {
|
|
81
|
+
from: number;
|
|
82
|
+
to: number;
|
|
83
|
+
text: string;
|
|
84
|
+
story?: OpStory;
|
|
85
|
+
semantic?: CanonicalInputSemantic;
|
|
86
|
+
time?: number;
|
|
87
|
+
};
|
|
88
|
+
/** Immutable model authority with a journal staged independently of the PM view. */
|
|
89
|
+
declare class CanonicalSession {
|
|
90
|
+
private currentDocument;
|
|
91
|
+
private currentProjection;
|
|
92
|
+
private currentVersion;
|
|
93
|
+
private readonly allocateIntentIds;
|
|
94
|
+
private mode;
|
|
95
|
+
private readonly allocatedBlockIds;
|
|
96
|
+
private nextBlockId;
|
|
97
|
+
private readonly sourceOwners;
|
|
98
|
+
private readonly storyProjections;
|
|
99
|
+
private currentSelection;
|
|
100
|
+
private readonly applied;
|
|
101
|
+
private groupingBoundary;
|
|
102
|
+
private lifecycle;
|
|
103
|
+
private readonly undone;
|
|
104
|
+
private readonly styles;
|
|
105
|
+
constructor({ document, projection, styles }: CanonicalSessionSeedOptions);
|
|
106
|
+
setMode(mode: CanonicalSessionMode): void;
|
|
107
|
+
hasStyle(styleId: string): boolean;
|
|
108
|
+
private advanceBlockId;
|
|
109
|
+
private freshBlockId;
|
|
110
|
+
private intentMode;
|
|
111
|
+
private intentNeedsIdentityIds;
|
|
112
|
+
private rememberSources;
|
|
113
|
+
get document(): document_d_exports.Document;
|
|
114
|
+
get projection(): CanonicalProjection;
|
|
115
|
+
get selection(): CanonicalSelection | null;
|
|
116
|
+
get version(): number;
|
|
117
|
+
get canUndo(): boolean;
|
|
118
|
+
get canRedo(): boolean;
|
|
119
|
+
get isComposing(): boolean;
|
|
120
|
+
breakUndoGroup(): void;
|
|
121
|
+
beginComposition(): Result<void, CanonicalSessionError>;
|
|
122
|
+
endComposition(): void;
|
|
123
|
+
private checkState;
|
|
124
|
+
prepareReplace(state: EditorState, { from, to, text, story, semantic, time }: CanonicalReplaceTextInput): Result<CanonicalCommit, CanonicalSessionError>;
|
|
125
|
+
prepareIntent(state: EditorState, intent: EditorIntent): Result<CanonicalCommit, CanonicalSessionError>;
|
|
126
|
+
prepareIntents(state: EditorState, intents: readonly EditorIntent[]): Result<CanonicalCommit, CanonicalSessionError>;
|
|
127
|
+
prepareOps(state: EditorState, ops: readonly DocumentOp[], postSelection: CanonicalSelection): Result<CanonicalCommit, CanonicalSessionError>;
|
|
128
|
+
private prepareJournalledOps;
|
|
129
|
+
prepareSplit(state: EditorState): Result<CanonicalCommit, CanonicalSessionError>;
|
|
130
|
+
prepareJoin(state: EditorState, direction: "backward" | "forward"): Result<CanonicalCommit, CanonicalSessionError>;
|
|
131
|
+
prepareResolve(state: EditorState, { revisionIds, resolution }: {
|
|
132
|
+
revisionIds: readonly number[];
|
|
133
|
+
resolution: "accept" | "reject";
|
|
134
|
+
}): Result<CanonicalCommit, CanonicalSessionError>;
|
|
135
|
+
projectStory(story: OpStory): Result<CanonicalProjection, CanonicalSessionError>;
|
|
136
|
+
prepareOperations(state: EditorState, ops: readonly DocumentOp[]): Result<CanonicalCommit, CanonicalSessionError>;
|
|
137
|
+
prepareUndo(state: EditorState, story?: OpStory): Result<CanonicalCommit, CanonicalSessionError>;
|
|
138
|
+
prepareRedo(state: EditorState, story?: OpStory): Result<CanonicalCommit, CanonicalSessionError>;
|
|
139
|
+
private stage;
|
|
140
|
+
}
|
|
141
|
+
declare const createCanonicalSession: (document: document_d_exports.Document, styles?: document_d_exports.StyleDefinitions | null) => Result<CanonicalSession, CanonicalSessionError>;
|
|
142
|
+
declare const isCanonicalJoinBoundary: (state: EditorState, direction: "backward" | "forward") => boolean;
|
|
143
|
+
/** Native character deletion consumes one whole visible grapheme. */
|
|
144
|
+
declare const deletionRange: (state: EditorState, direction: "backward" | "forward") => Result<{
|
|
145
|
+
from: number;
|
|
146
|
+
to: number;
|
|
147
|
+
}, CanonicalSessionError>;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { CANONICAL_PROJECTION_META, CanonicalCommit, CanonicalInputSemantic, CanonicalOrigin, type CanonicalProjection, CanonicalSelection, type CanonicalSession, CanonicalSessionError, CanonicalSessionMode, createCanonicalSession, deletionRange, isCanonicalJoinBoundary, isCanonicalProjectionTransaction, publishCanonicalProjection };
|