@stll/folio-core 0.68.0 → 0.69.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/headless.js +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/controller/canonicalClipboard.js +2 -2
- package/dist/controller/canonicalComposition.js +34 -5
- package/dist/controller/canonicalInput.js +4 -6
- package/dist/controller/canonicalLockGuard.d.ts +17 -2
- package/dist/controller/canonicalLockGuard.js +46 -1
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.js +476 -100
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +53 -21
- package/dist/controller/canonicalSession.js +489 -210
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +1 -1
- package/dist/controller/canonicalStoryEditor.js +16 -12
- package/dist/controller/folioEditor.js +3 -0
- package/dist/controller/headerFooterEditorManager.d.ts +5 -0
- package/dist/controller/headerFooterEditorManager.js +7 -2
- package/dist/controller/hiddenEditorApi.d.ts +11 -2
- package/dist/controller/hiddenEditorApi.js +3 -0
- package/dist/controller/hiddenEditorManager.d.ts +7 -0
- package/dist/controller/hiddenEditorManager.js +66 -11
- package/dist/controller/layoutPipeline.js +2 -1
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +5 -0
- package/dist/controller/noteEditorManager.js +7 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +9 -7
- package/dist/document-operations.d.ts +1 -1
- package/dist/docx/canonicalSave.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +19 -0
- package/dist/docx/commentAnchorIndex.js +55 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/hostCommentThreads.d.ts +11 -1
- package/dist/docx/hostCommentThreads.js +25 -2
- package/dist/docx/listModelNormalization.js +4 -5
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphPropertySource.d.ts +22 -0
- package/dist/docx/paragraphPropertySource.js +85 -16
- package/dist/docx/parser.js +2 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +72 -19
- package/dist/docx/serializer/documentSerializer.js +2 -1
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/storyBlockReplay.js +15 -2
- package/dist/docx/structuralXmlPatch.js +25 -4
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- 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/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +6 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.js +8 -29
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +9 -12
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/paged-layout/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- package/dist/paged-layout/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/commands/comments.d.ts +5 -2
- package/dist/prosemirror/commands/comments.js +88 -8
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +9 -3
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +13 -4
- package/dist/prosemirror/conversion/toProseDoc.js +126 -38
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/marks/CommentExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/index.d.ts +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +33 -14
- package/dist/prosemirror/plugins/suggestionMode.js +13 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/schema/marks.d.ts +7 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +78 -5
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/types/canonicalCapabilities.d.ts +12 -11
- package/dist/types/canonicalCapabilities.js +12 -13
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/package.json +2 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
/**
|
|
3
|
+
* Why the session cannot hold these stories of `document`, or `null`: the
|
|
4
|
+
* first block it cannot hold, else the first paragraph whose content it
|
|
5
|
+
* cannot hold, in each story in turn.
|
|
6
|
+
*/
|
|
7
|
+
export declare const unsupportedSeedReason: (document: document_d_exports.Document, stories?: import("@stll/docx-core/ops").OpStory[]) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The same verdict from one walk of every story, judging nothing once: the
|
|
10
|
+
* reference the block judgments above must equal.
|
|
11
|
+
*/
|
|
12
|
+
export declare const unsupportedSeedReasonWholeDocument: (document: document_d_exports.Document, stories?: import("@stll/docx-core/ops").OpStory[]) => string | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { canonicalInlineSourceIssue } from "./canonicalInlineProjection.js";
|
|
2
|
+
import { OP_STORIES, commentDocumentIssue, documentStories, findStoryBody } from "@stll/docx-core/ops";
|
|
3
|
+
// src/controller/canonicalSeedContent.ts
|
|
4
|
+
const STRUCTURE_ISSUE = "Canonical sessions currently require paragraphs, tables and supported inline atoms.";
|
|
5
|
+
const REVIEW_CARRIER_ISSUE = "Canonical sessions currently require plain paragraphs and supported inline atoms.";
|
|
6
|
+
/** Range markers may open or close between blocks; they hold no text. */
|
|
7
|
+
const BETWEEN_BLOCK_MARKERS = /* @__PURE__ */ new Set([
|
|
8
|
+
"commentRangeStart",
|
|
9
|
+
"commentRangeEnd",
|
|
10
|
+
"bookmarkStart",
|
|
11
|
+
"bookmarkEnd",
|
|
12
|
+
"moveFromRangeStart",
|
|
13
|
+
"moveFromRangeEnd",
|
|
14
|
+
"moveToRangeStart",
|
|
15
|
+
"moveToRangeEnd"
|
|
16
|
+
]);
|
|
17
|
+
const issuesIn = (block) => {
|
|
18
|
+
const paragraphs = [];
|
|
19
|
+
const collect = (blocks) => {
|
|
20
|
+
for (const child of blocks) {
|
|
21
|
+
if (child.type === "paragraph") {
|
|
22
|
+
paragraphs.push(child);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (BETWEEN_BLOCK_MARKERS.has(child.type)) continue;
|
|
26
|
+
if (child.type === "preservedBlock") continue;
|
|
27
|
+
if (child.type === "blockSdt") {
|
|
28
|
+
const issue = collect(child.content);
|
|
29
|
+
if (issue !== null) return issue;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (child.type !== "table") return STRUCTURE_ISSUE;
|
|
33
|
+
for (const row of child.rows) for (const cell of row.cells) {
|
|
34
|
+
const issue = collect(cell.content);
|
|
35
|
+
if (issue !== null) return issue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
40
|
+
const structure = collect([block]);
|
|
41
|
+
let paragraph = null;
|
|
42
|
+
for (const candidate of paragraphs) {
|
|
43
|
+
paragraph = candidate.reviewCarrier === void 0 ? canonicalInlineSourceIssue(candidate.content) : REVIEW_CARRIER_ISSUE;
|
|
44
|
+
if (paragraph !== null) break;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
structure,
|
|
48
|
+
paragraph
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const blockIssues = /* @__PURE__ */ new WeakMap();
|
|
52
|
+
const issuesOf = (block) => {
|
|
53
|
+
let issues = blockIssues.get(block);
|
|
54
|
+
if (issues === void 0) {
|
|
55
|
+
issues = issuesIn(block);
|
|
56
|
+
blockIssues.set(block, issues);
|
|
57
|
+
}
|
|
58
|
+
return issues;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Why the session cannot hold these stories of `document`, or `null`: the
|
|
62
|
+
* first block it cannot hold, else the first paragraph whose content it
|
|
63
|
+
* cannot hold, in each story in turn.
|
|
64
|
+
*/
|
|
65
|
+
const unsupportedSeedReason = (document, stories = documentStories(document)) => {
|
|
66
|
+
const commentIssue = commentDocumentIssue(document, "all");
|
|
67
|
+
if (commentIssue !== void 0) return commentIssue;
|
|
68
|
+
for (const story of stories) {
|
|
69
|
+
const body = findStoryBody(document, story);
|
|
70
|
+
if (story !== OP_STORIES.MAIN && (story.kind === "footnote" || story.kind === "endnote")) {
|
|
71
|
+
const note = (story.kind === "footnote" ? document.package.footnotes : document.package.endnotes)?.find(({ id }) => id === story.id);
|
|
72
|
+
if (note?.noteType !== void 0 && note.noteType !== "normal") continue;
|
|
73
|
+
}
|
|
74
|
+
const content = body?.content;
|
|
75
|
+
if (!content || content.length === 0) return "Canonical sessions require a nonempty paragraph story.";
|
|
76
|
+
const issues = content.map(issuesOf);
|
|
77
|
+
const structure = issues.find((issue) => issue.structure !== null);
|
|
78
|
+
if (structure !== void 0) return structure.structure;
|
|
79
|
+
const paragraph = issues.find((issue) => issue.paragraph !== null);
|
|
80
|
+
if (paragraph !== void 0) return paragraph.paragraph;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The same verdict from one walk of every story, judging nothing once: the
|
|
86
|
+
* reference the block judgments above must equal.
|
|
87
|
+
*/
|
|
88
|
+
const unsupportedSeedReasonWholeDocument = (document, stories = documentStories(document)) => {
|
|
89
|
+
const commentIssue = commentDocumentIssue(document, "all");
|
|
90
|
+
if (commentIssue !== void 0) return commentIssue;
|
|
91
|
+
for (const story of stories) {
|
|
92
|
+
const body = findStoryBody(document, story);
|
|
93
|
+
if (story !== OP_STORIES.MAIN && (story.kind === "footnote" || story.kind === "endnote")) {
|
|
94
|
+
const note = (story.kind === "footnote" ? document.package.footnotes : document.package.endnotes)?.find(({ id }) => id === story.id);
|
|
95
|
+
if (note?.noteType !== void 0 && note.noteType !== "normal") continue;
|
|
96
|
+
}
|
|
97
|
+
const content = body?.content;
|
|
98
|
+
if (!content || content.length === 0) return "Canonical sessions require a nonempty paragraph story.";
|
|
99
|
+
const paragraphs = [];
|
|
100
|
+
const collect = (blocks) => {
|
|
101
|
+
for (const block of blocks) {
|
|
102
|
+
if (block.type === "paragraph") {
|
|
103
|
+
paragraphs.push(block);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (block.type === "commentRangeStart" || block.type === "commentRangeEnd" || block.type === "bookmarkStart" || block.type === "bookmarkEnd" || block.type === "moveFromRangeStart" || block.type === "moveFromRangeEnd" || block.type === "moveToRangeStart" || block.type === "moveToRangeEnd") continue;
|
|
107
|
+
if (block.type === "preservedBlock") continue;
|
|
108
|
+
if (block.type === "blockSdt") {
|
|
109
|
+
const issue = collect(block.content);
|
|
110
|
+
if (issue !== null) return issue;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (block.type !== "table") return "Canonical sessions currently require paragraphs, tables and supported inline atoms.";
|
|
114
|
+
for (const row of block.rows) for (const cell of row.cells) {
|
|
115
|
+
const issue = collect(cell.content);
|
|
116
|
+
if (issue !== null) return issue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
const blockIssue = collect(content);
|
|
122
|
+
if (blockIssue !== null) return blockIssue;
|
|
123
|
+
for (const paragraph of paragraphs) {
|
|
124
|
+
if (paragraph.reviewCarrier !== void 0) return "Canonical sessions currently require plain paragraphs and supported inline atoms.";
|
|
125
|
+
const issue = canonicalInlineSourceIssue(paragraph.content);
|
|
126
|
+
if (issue !== null) return issue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
};
|
|
131
|
+
export { unsupportedSeedReason, unsupportedSeedReasonWholeDocument };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
|
+
import { CommentMarkerCache } from "../docx/commentAnchorIndex.js";
|
|
3
4
|
import { ListNormalizationCache } from "../docx/listModelNormalization.js";
|
|
4
5
|
import { ProjectionBlockCache } from "../prosemirror/conversion/toProseDoc.js";
|
|
5
6
|
import { CanonicalSaveSnapshot } from "../types/canonicalSave.js";
|
|
6
|
-
import {
|
|
7
|
+
import { InlineProjectionCache } from "./canonicalInlineProjection.js";
|
|
8
|
+
import { ParagraphAddress, ParagraphIdIndex, ProjectedBlock, StoryProjectionFacts } from "./canonicalProjectionBlocks.js";
|
|
9
|
+
import { CanonicalSourceRestore } from "./canonicalSourceNormalization.js";
|
|
7
10
|
import { Node } from "prosemirror-model";
|
|
8
11
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
9
12
|
import { Err, Ok, Result, TaggedErrorClass } from "better-result";
|
|
@@ -27,16 +30,6 @@ export type CanonicalSessionMode = {
|
|
|
27
30
|
author: string;
|
|
28
31
|
};
|
|
29
32
|
export declare const CANONICAL_PROJECTION_META = "folioCanonicalProjection";
|
|
30
|
-
type ParagraphAddress = {
|
|
31
|
-
blockId: string;
|
|
32
|
-
container: readonly document_d_exports.BlockContent[];
|
|
33
|
-
start: number;
|
|
34
|
-
text: string;
|
|
35
|
-
boundaries: readonly (readonly CanonicalInlineGap[])[];
|
|
36
|
-
seams: readonly (readonly CanonicalSeamExtent[])[];
|
|
37
|
-
node: Node;
|
|
38
|
-
source: document_d_exports.Paragraph;
|
|
39
|
-
};
|
|
40
33
|
/**
|
|
41
34
|
* Which source gap an editor position names where invisible markers (comment
|
|
42
35
|
* ranges, bookmarks, permission ranges, proofing marks) share it: a caret
|
|
@@ -46,16 +39,38 @@ type ParagraphAddress = {
|
|
|
46
39
|
export type CanonicalAddressEdge = "caret" | "afterMarkers" | "beforeMarkers";
|
|
47
40
|
type CanonicalProjectionOptions = {
|
|
48
41
|
doc: Node;
|
|
49
|
-
paragraphs: readonly ParagraphAddress[];
|
|
50
42
|
story: OpStory;
|
|
43
|
+
/** The story's blocks the projection was made from. */
|
|
44
|
+
content: readonly document_d_exports.BlockContent[];
|
|
45
|
+
/** One per top-level node of `doc`, in order. */
|
|
46
|
+
blocks: readonly ProjectedBlock[];
|
|
47
|
+
index: ParagraphIdIndex;
|
|
48
|
+
facts: StoryProjectionFacts;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the next projection may keep this one's blocks: each top-level
|
|
51
|
+
* node was projected from the story block at its index alone, and no two
|
|
52
|
+
* source paragraphs share an id.
|
|
53
|
+
*/
|
|
54
|
+
reusable: boolean;
|
|
51
55
|
};
|
|
52
56
|
/** Paragraph gaps bind logical units and source zero-width ordinals to PM positions. */
|
|
53
57
|
declare class CanonicalProjection {
|
|
54
58
|
readonly doc: Node;
|
|
55
59
|
readonly story: OpStory;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
readonly content: readonly document_d_exports.BlockContent[];
|
|
61
|
+
readonly blocks: readonly ProjectedBlock[];
|
|
62
|
+
readonly index: ParagraphIdIndex;
|
|
63
|
+
readonly facts: StoryProjectionFacts;
|
|
64
|
+
readonly reusable: boolean;
|
|
65
|
+
/** Where each top-level node starts. */
|
|
66
|
+
private readonly starts;
|
|
67
|
+
private readonly addresses;
|
|
68
|
+
constructor(options: CanonicalProjectionOptions,
|
|
69
|
+
/** What a projection of an equal document already worked out. */
|
|
70
|
+
held?: {
|
|
71
|
+
starts: readonly number[];
|
|
72
|
+
addresses: Map<string, ParagraphAddress>;
|
|
73
|
+
});
|
|
59
74
|
/**
|
|
60
75
|
* The same projection held as `doc`, a document equal to this one's. A
|
|
61
76
|
* commit's transaction ends on a document equal to the projection it staged,
|
|
@@ -63,6 +78,9 @@ declare class CanonicalProjection {
|
|
|
63
78
|
* the state it was given is the projection without comparing every node.
|
|
64
79
|
*/
|
|
65
80
|
heldAs(doc: Node): CanonicalProjection;
|
|
81
|
+
private addressOf;
|
|
82
|
+
/** The paragraph whose content holds `position`, its ends included. */
|
|
83
|
+
private paragraphAround;
|
|
66
84
|
addressAt(position: number, edge?: CanonicalAddressEdge): Result<TextPosition, CanonicalSessionError>;
|
|
67
85
|
/**
|
|
68
86
|
* The source gaps a selection from `from` to `to` replaces between. Its
|
|
@@ -85,6 +103,8 @@ declare class CanonicalProjection {
|
|
|
85
103
|
/** The first paragraph the projection addresses, in document order. */
|
|
86
104
|
get firstParagraph(): ParagraphAddress | undefined;
|
|
87
105
|
paragraph(blockId: string): ParagraphAddress | undefined;
|
|
106
|
+
/** The paragraph whose node starts at `before`. */
|
|
107
|
+
paragraphStartingAt(before: number): ParagraphAddress | undefined;
|
|
88
108
|
nextParagraphInContainer(blockId: string): ParagraphAddress | undefined;
|
|
89
109
|
}
|
|
90
110
|
/** A session's projection pieces, reused by every projection of its stories. */
|
|
@@ -95,6 +115,8 @@ type StoryProjectionCaches = {
|
|
|
95
115
|
inline: InlineProjectionCache;
|
|
96
116
|
/** Each story's normalized list rendering, by block and the counters before it. */
|
|
97
117
|
lists: ListNormalizationCache;
|
|
118
|
+
/** Each paragraph's comment markers, by its source. */
|
|
119
|
+
comments: CommentMarkerCache;
|
|
98
120
|
};
|
|
99
121
|
export declare const newStoryProjectionCaches: () => StoryProjectionCaches;
|
|
100
122
|
type ProjectStoryOptions = {
|
|
@@ -103,8 +125,10 @@ type ProjectStoryOptions = {
|
|
|
103
125
|
story?: OpStory;
|
|
104
126
|
/** What earlier projections converted, kept by its session. */
|
|
105
127
|
caches?: StoryProjectionCaches;
|
|
128
|
+
/** A projection of the story whose top-level blocks this one may keep. */
|
|
129
|
+
previous?: CanonicalProjection;
|
|
106
130
|
};
|
|
107
|
-
declare const project: ({ document, styles, story, caches }: ProjectStoryOptions) => Result<CanonicalProjection, CanonicalSessionError>;
|
|
131
|
+
declare const project: ({ document, styles, story, caches, previous }: ProjectStoryOptions) => Result<CanonicalProjection, CanonicalSessionError>;
|
|
108
132
|
/** Input intent, never projection-step adjacency, determines the journal partition. */
|
|
109
133
|
export type CanonicalInputSemantic = "typing" | "deleteBackward" | "deleteForward" | "paste" | "composition" | "replacement" | "structure";
|
|
110
134
|
export type CanonicalCommit = {
|
|
@@ -137,6 +161,8 @@ type CanonicalSessionSeedOptions = {
|
|
|
137
161
|
document: document_d_exports.Document;
|
|
138
162
|
projection: CanonicalProjection;
|
|
139
163
|
styles: document_d_exports.StyleDefinitions | null | undefined;
|
|
164
|
+
/** Stories the session reads in its own spelling, given back as read while unedited. */
|
|
165
|
+
sourceRestores?: readonly CanonicalSourceRestore[];
|
|
140
166
|
caches: StoryProjectionCaches;
|
|
141
167
|
};
|
|
142
168
|
type CanonicalReplaceTextInput = {
|
|
@@ -172,9 +198,10 @@ declare class CanonicalSession {
|
|
|
172
198
|
private lifecycle;
|
|
173
199
|
private readonly undone;
|
|
174
200
|
private readonly styles;
|
|
201
|
+
private readonly sourceRestores;
|
|
175
202
|
/** What earlier projections converted, reused by every later one. */
|
|
176
203
|
private readonly caches;
|
|
177
|
-
constructor({ document, projection, styles, caches }: CanonicalSessionSeedOptions);
|
|
204
|
+
constructor({ document, projection, styles, sourceRestores, caches }: CanonicalSessionSeedOptions);
|
|
178
205
|
/** Render only the committed comment projection while provisional IME blocks document snapshots. */
|
|
179
206
|
getCommittedComments(): document_d_exports.Comment[];
|
|
180
207
|
setMode(mode: CanonicalSessionMode): void;
|
|
@@ -196,6 +223,8 @@ declare class CanonicalSession {
|
|
|
196
223
|
/** The caret the last published edit returned, when the editor shows it at `position`. */
|
|
197
224
|
private editCaretAt;
|
|
198
225
|
get selection(): CanonicalSelection | null;
|
|
226
|
+
/** Every paragraph identity this session has read or minted, live or retired. */
|
|
227
|
+
get reservedBlockIds(): ReadonlySet<string>;
|
|
199
228
|
get version(): number;
|
|
200
229
|
get canUndo(): boolean;
|
|
201
230
|
get canRedo(): boolean;
|
|
@@ -224,15 +253,18 @@ declare class CanonicalSession {
|
|
|
224
253
|
private prepareJournalledOps;
|
|
225
254
|
prepareSplit(state: EditorState): Result<CanonicalCommit, CanonicalSessionError>;
|
|
226
255
|
prepareJoin(state: EditorState, direction: "backward" | "forward"): Result<CanonicalCommit, CanonicalSessionError>;
|
|
227
|
-
prepareResolve(state: EditorState, { revisionIds, resolution }: {
|
|
256
|
+
prepareResolve(state: EditorState, { revisionIds, resolution, before }: {
|
|
228
257
|
revisionIds: readonly number[];
|
|
229
258
|
resolution: "accept" | "reject";
|
|
259
|
+
/** Operations applied ahead of the resolution, in the same commit. */
|
|
260
|
+
before?: readonly DocumentOp[];
|
|
230
261
|
}): Result<CanonicalCommit, CanonicalSessionError>;
|
|
231
262
|
/**
|
|
232
263
|
* Accept or reject one pending suggestion. Rejecting it rejects its
|
|
233
|
-
* revisions
|
|
234
|
-
* `author`, keeping their ids, as
|
|
235
|
-
* for review like any other.
|
|
264
|
+
* revisions and removes the comments it proposes. Accepting it adopts its
|
|
265
|
+
* revisions as ordinary tracked changes by `author`, keeping their ids, as
|
|
266
|
+
* the editor does: the change then waits for review like any other. Its
|
|
267
|
+
* comments stay as ordinary comments.
|
|
236
268
|
*/
|
|
237
269
|
prepareSuggestion(state: EditorState, { suggestionId, resolution, author, date }: {
|
|
238
270
|
suggestionId: string;
|