@stll/folio-core 0.75.0 → 0.77.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.d.ts +8 -5
- package/dist/ai-edits/headless.js +49 -26
- package/dist/ai-edits/pending-suggestions.d.ts +9 -0
- package/dist/ai-edits/pending-suggestions.js +13 -3
- package/dist/ai-edits/read.js +33 -4
- package/dist/ai-edits/table-geometry.js +12 -4
- package/dist/ai-edits/types.d.ts +9 -4
- package/dist/canonical/batchCommentReferences.js +2 -1
- package/dist/canonical/canonicalBatchReview.js +5 -8
- package/dist/canonical/canonicalComments.js +8 -2
- package/dist/canonical/canonicalCompilerRefusal.d.ts +2 -4
- package/dist/canonical/canonicalCompilerRefusal.js +20 -14
- package/dist/canonical/canonicalInlineProjection.d.ts +2 -2
- package/dist/canonical/canonicalInlineProjection.js +2 -2
- package/dist/canonical/canonicalProjectionBlocks.d.ts +10 -1
- package/dist/canonical/canonicalPublicOperations.js +214 -107
- package/dist/canonical/canonicalSeedContent.d.ts +18 -3
- package/dist/canonical/canonicalSeedContent.js +28 -15
- package/dist/canonical/canonicalSession.d.ts +22 -12
- package/dist/canonical/canonicalSession.js +181 -187
- package/dist/controller/canonicalClipboard.d.ts +3 -2
- package/dist/controller/canonicalClipboard.js +377 -58
- package/dist/controller/canonicalComposition.js +67 -14
- package/dist/controller/canonicalContentControlValue.js +7 -7
- package/dist/controller/canonicalReview.d.ts +21 -0
- package/dist/controller/canonicalReview.js +44 -9
- package/dist/controller/canonicalStoryEditor.js +2 -0
- package/dist/controller/canonicalStructure.d.ts +1 -2
- package/dist/controller/canonicalStructure.js +51 -24
- package/dist/controller/fontReadiness.js +50 -23
- package/dist/controller/hiddenEditorManager.js +7 -20
- package/dist/docx/bulletMarkers.d.ts +8 -0
- package/dist/docx/bulletMarkers.js +9 -1
- package/dist/docx/canonicalSessionInput.js +25 -11
- package/dist/docx/ensureParaIds.d.ts +31 -0
- package/dist/docx/ensureParaIds.js +57 -32
- package/dist/docx/ensureUniqueControlIds.d.ts +13 -0
- package/dist/docx/ensureUniqueControlIds.js +47 -29
- package/dist/docx/ensureUniqueRevisionIds.d.ts +13 -0
- package/dist/docx/ensureUniqueRevisionIds.js +52 -29
- package/dist/docx/importedIdCollisions.js +29 -4
- package/dist/docx/server/templatePlan/apply.js +108 -9
- package/dist/docx/server/templatePlan/blocks.d.ts +77 -5
- package/dist/docx/server/templatePlan/blocks.js +281 -14
- package/dist/docx/server/templatePlan/builders.d.ts +22 -1
- package/dist/docx/server/templatePlan/builders.js +37 -3
- package/dist/docx/server/templatePlan/effects.d.ts +27 -0
- package/dist/docx/server/templatePlan/effects.js +188 -0
- package/dist/docx/server/templatePlan/emit.d.ts +4 -1
- package/dist/docx/server/templatePlan/emit.js +152 -8
- package/dist/docx/server/templatePlan/inspect.js +21 -1
- package/dist/docx/server/templatePlan/labels.js +16 -1
- package/dist/docx/server/templatePlan/plan.d.ts +35 -3
- package/dist/docx/server/templatePlan/plan.js +197 -20
- package/dist/docx/server/templatePlan/planShape.js +58 -22
- package/dist/docx/server/templatePlan/revisions.d.ts +101 -0
- package/dist/docx/server/templatePlan/revisions.js +681 -0
- package/dist/docx/server/templatePlan/story.d.ts +61 -2
- package/dist/docx/server/templatePlan/story.js +175 -13
- package/dist/docx/server/templatePlan/types.d.ts +313 -1
- package/dist/docx/server/templatePlan/verify.js +175 -12
- package/dist/docx/server/templatePlan/xml.d.ts +3 -0
- package/dist/docx/server/templatePlan/xml.js +4 -1
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
- package/dist/docx/tableGridXml.d.ts +3 -7
- package/dist/docx/tableGridXml.js +5 -13
- package/dist/layout-bridge/convert/footnoteLayout.js +34 -8
- package/dist/prosemirror/canonicalMarkupDocument.d.ts +20 -0
- package/dist/prosemirror/canonicalMarkupDocument.js +73 -0
- package/dist/prosemirror/canonicalTableCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -3
- package/dist/prosemirror/commands/comments.d.ts +6 -234
- package/dist/prosemirror/commands/comments.js +5 -2464
- package/dist/prosemirror/commands/index.d.ts +4 -2
- package/dist/prosemirror/commands/index.js +4 -2
- package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
- package/dist/prosemirror/conversion/markupViewSource.js +11 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +3 -0
- package/dist/prosemirror/conversion/toProseDoc.js +31 -14
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +6 -8
- package/dist/prosemirror/hyperlinkRemoval.d.ts +11 -8
- package/dist/prosemirror/hyperlinkRemoval.js +24 -15
- package/dist/prosemirror/independentMarkupProjection.d.ts +27 -0
- package/dist/prosemirror/independentMarkupProjection.js +147 -0
- package/dist/prosemirror/markupViewNotes.d.ts +1 -1
- package/dist/prosemirror/markupViewNotes.js +24 -27
- package/dist/prosemirror/markupViewPositionMap.d.ts +16 -0
- package/dist/prosemirror/markupViewPositionMap.js +316 -0
- package/dist/prosemirror/markupViewProjection.d.ts +3 -46
- package/dist/prosemirror/markupViewProjection.js +90 -17
- package/dist/prosemirror/paraIds.d.ts +1 -14
- package/dist/prosemirror/paraIds.js +1 -14
- package/dist/prosemirror/paragraphMarkJoin.d.ts +0 -16
- package/dist/prosemirror/paragraphMarkJoin.js +3 -46
- package/dist/prosemirror/projectionReview.d.ts +49 -0
- package/dist/prosemirror/projectionReview.js +292 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -13
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +1 -16
- package/dist/prosemirror/replacedAnnotations.d.ts +6 -83
- package/dist/prosemirror/replacedAnnotations.js +11 -203
- package/dist/prosemirror/revisionCarriers.d.ts +9 -1
- package/dist/prosemirror/revisionCarriers.js +15 -1
- package/dist/prosemirror/revisionRangeQueries.d.ts +32 -0
- package/dist/prosemirror/revisionRangeQueries.js +76 -0
- package/dist/prosemirror/runFormattingMarkNames.d.ts +1 -1
- package/dist/prosemirror/runFormattingMarkNames.js +1 -1
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
- package/dist/prosemirror/styles/styleResolver.js +4 -1
- package/dist/prosemirror/suggestionQueries.d.ts +114 -0
- package/dist/prosemirror/suggestionQueries.js +320 -0
- package/dist/prosemirror/tableGridMutation.d.ts +1 -16
- package/dist/prosemirror/tableGridMutation.js +1 -78
- package/dist/prosemirror/tableRowRevisionOwnership.d.ts +18 -0
- package/dist/prosemirror/tableRowRevisionOwnership.js +7 -0
- package/dist/prosemirror/utils/extractTrackedChanges.js +14 -4
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +4 -35
- package/dist/types/canonicalCapabilities.js +4 -33
- package/package.json +2 -2
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +0 -3
- package/dist/internal/headlessRevisionResolutionGuard.js +0 -18
- package/dist/internal/revisionResolutionEdits.d.ts +0 -11
- package/dist/internal/revisionResolutionEdits.js +0 -18
- package/dist/internal/revisionResolutionInline.d.ts +0 -24
- package/dist/internal/revisionResolutionInline.js +0 -302
- package/dist/internal/revisionResolutionStep.d.ts +0 -32
- package/dist/internal/revisionResolutionStep.js +0 -282
- package/dist/internal/revisionResolutionTracking.d.ts +0 -9
- package/dist/internal/revisionResolutionTracking.js +0 -124
- package/dist/internal/wholeStoryRevisionResolution.d.ts +0 -56
- package/dist/internal/wholeStoryRevisionResolution.js +0 -783
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +0 -38
- package/dist/prosemirror/commands/resolveAllTableChanges.js +0 -642
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +0 -13
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +0 -45
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -18
- package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -207
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +0 -60
- package/dist/prosemirror/commands/tableMergeFoldDecisions.js +0 -78
- package/dist/prosemirror/rejoinRunCarriers.d.ts +0 -42
- package/dist/prosemirror/rejoinRunCarriers.js +0 -65
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +0 -15
- package/dist/prosemirror/runPropertyChangeResolution.js +0 -34
|
@@ -12,10 +12,11 @@ import { canonicalOperationStagingAccess } from "../internal/canonicalOperationS
|
|
|
12
12
|
import { recordCanonicalTyping } from "../internal/canonicalTyping.js";
|
|
13
13
|
import { canonicalCellSelectionRanges, canonicalContentPosition, canonicalSelectionRange } from "../prosemirror/canonicalSelectionRange.js";
|
|
14
14
|
import { expectCommentRangeBoundaryAttrs } from "../prosemirror/commentRangeBoundaryAttrs.js";
|
|
15
|
+
import { markupViewSources, markupViewStateSources } from "../prosemirror/conversion/markupViewSource.js";
|
|
15
16
|
import { storyConversionOptions } from "../prosemirror/conversion/storyConversionOptions.js";
|
|
16
17
|
import { ProjectionBlockCache, collectPairedBookmarkIds, footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
18
|
+
import "../prosemirror/extensions/nodes/CommentRangeBoundaryExtension.js";
|
|
17
19
|
import { heldUnreferencedNotes } from "../prosemirror/noteReferenceReview.js";
|
|
18
|
-
import { preservesReplacementCommentAlignment, splitAtKeptCommentBoundaries } from "../prosemirror/replacedAnnotations.js";
|
|
19
20
|
import { runFormattingPatchFromMarks } from "../prosemirror/runFormattingFromMarks.js";
|
|
20
21
|
import { CANONICAL_CONDITION, CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
21
22
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
@@ -37,7 +38,7 @@ import { ownedSourceCopies, preservePropertySources, preservePropertySourcesWhol
|
|
|
37
38
|
import { Result, TaggedError, panic } from "better-result";
|
|
38
39
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
39
40
|
import { lockedControlMessage } from "@stll/docx-core/model";
|
|
40
|
-
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, ID_LEASE_KINDS, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, combineRecordedRevisions, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, formatParaId, freshLeasedIds, inverseMeetingDocument, isBlockBoundary, normalizeForOps, packageParagraphIds, paragraphIdsIn, paragraphsThroughTextBoxes,
|
|
41
|
+
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, ID_LEASE_KINDS, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, combineRecordedRevisions, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, formatParaId, freshLeasedIds, inverseMeetingDocument, isBlockBoundary, normalizeForOps, packageParagraphIds, paragraphIdsIn, paragraphsThroughTextBoxes, sameStory, suggestedCommentIds, suggestionRevisionInfos, survivingComments, validateOpsDocument, withParagraphCopies } from "@stll/docx-core/ops";
|
|
41
42
|
import { AllSelection, NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
42
43
|
import { CellSelection } from "prosemirror-tables";
|
|
43
44
|
import { Fragment } from "prosemirror-model";
|
|
@@ -50,6 +51,32 @@ const INTERNAL = { condition: CANONICAL_CONDITION.internal };
|
|
|
50
51
|
const COMPOSING = { condition: CANONICAL_CONDITION.composing };
|
|
51
52
|
const ID_SPACE = { condition: CANONICAL_CONDITION.idSpace };
|
|
52
53
|
const HOST_TRANSACTION = { condition: CANONICAL_CONDITION.hostTransaction };
|
|
54
|
+
/**
|
|
55
|
+
* The ground of an edit whose result the session cannot hold. Comments and
|
|
56
|
+
* anchors that are no valid set, and a story left with no block, are a
|
|
57
|
+
* request the document does not allow. Content no operation writes (an
|
|
58
|
+
* unstructured field character, text holding a tab or a line feed, a block
|
|
59
|
+
* of no kind the model has) can come only from an operation the session
|
|
60
|
+
* applied wrongly: the operations refuse such text and write fields whole.
|
|
61
|
+
*/
|
|
62
|
+
const editIssueGround = (issue) => issue.kind === "content" ? INTERNAL : INVALID_REQUEST;
|
|
63
|
+
/** The ids of the comments whose range or reference lies in a story. */
|
|
64
|
+
const commentIdsAnchoredIn = (document, story) => {
|
|
65
|
+
const ids = /* @__PURE__ */ new Set();
|
|
66
|
+
const visit = (value) => {
|
|
67
|
+
if (typeof value !== "object" || value === null) return;
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
for (const item of value) visit(item);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const record = value;
|
|
73
|
+
const id = record["id"];
|
|
74
|
+
if ((record["type"] === "commentRangeStart" || record["type"] === "commentRangeEnd" || record["type"] === "commentReference") && typeof id === "number") ids.add(id);
|
|
75
|
+
for (const child of Object.values(record)) visit(child);
|
|
76
|
+
};
|
|
77
|
+
visit(findStoryBody(document, story)?.content);
|
|
78
|
+
return ids;
|
|
79
|
+
};
|
|
53
80
|
/** A refusal under the gap, rule or condition it belongs to. */
|
|
54
81
|
const refuse = (message, ground) => Result.err(new CanonicalSessionError({
|
|
55
82
|
ground,
|
|
@@ -258,21 +285,32 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
258
285
|
addresses: this.addresses
|
|
259
286
|
});
|
|
260
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* A paragraph's address, its text and gaps aligned on the first address:
|
|
290
|
+
* refused when its source and its editor node do not align.
|
|
291
|
+
*/
|
|
261
292
|
addressOf(block, paragraph) {
|
|
262
293
|
const entry = this.blocks[block]?.paragraphs[paragraph] ?? panic("Missing canonical paragraph");
|
|
263
294
|
const known = this.addresses.get(entry.blockId);
|
|
264
|
-
if (known !== void 0) return known;
|
|
295
|
+
if (known !== void 0) return Result.ok(known);
|
|
296
|
+
const inline = entry.inline();
|
|
297
|
+
if (inline.isErr()) return Result.err(inlineRefusal(inline.error));
|
|
265
298
|
const address = {
|
|
266
299
|
blockId: entry.blockId,
|
|
267
300
|
container: entry.container ?? this.content,
|
|
268
301
|
start: (this.starts[block] ?? panic("Missing block start")) + entry.offset,
|
|
269
|
-
text:
|
|
270
|
-
gaps:
|
|
302
|
+
text: inline.value.text,
|
|
303
|
+
gaps: inline.value.gaps,
|
|
271
304
|
node: entry.node,
|
|
272
305
|
source: entry.source
|
|
273
306
|
};
|
|
274
307
|
this.addresses.set(entry.blockId, address);
|
|
275
|
-
return address;
|
|
308
|
+
return Result.ok(address);
|
|
309
|
+
}
|
|
310
|
+
/** {@link addressOf}, none for a paragraph it refuses. */
|
|
311
|
+
alignedAddressOf(block, paragraph) {
|
|
312
|
+
const address = this.addressOf(block, paragraph);
|
|
313
|
+
return address.isOk() ? address.value : void 0;
|
|
276
314
|
}
|
|
277
315
|
/**
|
|
278
316
|
* The paragraph whose content holds `position`, its ends included: a
|
|
@@ -280,6 +318,11 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
280
318
|
* projection lists after its host as the story's own.
|
|
281
319
|
*/
|
|
282
320
|
paragraphAround(position) {
|
|
321
|
+
const slot = this.slotAround(position);
|
|
322
|
+
return slot === void 0 ? void 0 : this.alignedAddressOf(slot.block, slot.paragraph);
|
|
323
|
+
}
|
|
324
|
+
/** Where {@link paragraphAround}'s paragraph stands. */
|
|
325
|
+
slotAround(position) {
|
|
283
326
|
let low = 0;
|
|
284
327
|
let high = this.starts.length - 1;
|
|
285
328
|
let block = -1;
|
|
@@ -305,14 +348,20 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
305
348
|
}
|
|
306
349
|
const paragraph = paragraphs[found];
|
|
307
350
|
if (paragraph === void 0 || relative > paragraph.offset + paragraph.node.content.size) return void 0;
|
|
308
|
-
return
|
|
351
|
+
return {
|
|
352
|
+
block,
|
|
353
|
+
paragraph: found
|
|
354
|
+
};
|
|
309
355
|
}
|
|
310
356
|
addressAt(position, edge = "caret") {
|
|
311
357
|
const unaddressed = (message) => refuse(message, { condition: CANONICAL_CONDITION.invalidRequest });
|
|
312
358
|
if (!Number.isInteger(position)) return unaddressed("The input position is not an integer.");
|
|
313
359
|
position = canonicalContentPosition(this.doc, position);
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
360
|
+
const slot = this.slotAround(position);
|
|
361
|
+
if (slot === void 0) return unaddressed("The input is outside a plain paragraph.");
|
|
362
|
+
const address = this.addressOf(slot.block, slot.paragraph);
|
|
363
|
+
if (address.isErr()) return address;
|
|
364
|
+
const paragraph = address.value;
|
|
316
365
|
const relative = position - paragraph.start;
|
|
317
366
|
const offset = paragraph.gaps.offsetOf(relative);
|
|
318
367
|
if (offset < 0) return unaddressed("The input splits an indivisible inline element.");
|
|
@@ -363,7 +412,13 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
363
412
|
return destination === position ? address : this.addressAt(destination, edge);
|
|
364
413
|
}
|
|
365
414
|
positionAt(address) {
|
|
366
|
-
const
|
|
415
|
+
const slot = sameStory(address.story, this.story) ? this.index.get(address.blockId) : void 0;
|
|
416
|
+
let paragraph;
|
|
417
|
+
if (slot !== void 0 && slot.paragraph >= 0) {
|
|
418
|
+
const aligned = this.addressOf(slot.block, slot.paragraph);
|
|
419
|
+
if (aligned.isErr()) return Result.err(aligned.error);
|
|
420
|
+
paragraph = aligned.value;
|
|
421
|
+
}
|
|
367
422
|
if (!sameStory(address.story, this.story) || paragraph === void 0 || !Number.isInteger(address.offset) || address.offset < 0 || address.offset > paragraph.text.length || splitsSurrogatePair(paragraph.text, address.offset)) return refuse("The canonical selection is outside a plain paragraph.", INVALID_REQUEST);
|
|
368
423
|
const gaps = paragraph.gaps.at(address.offset) ?? panic("Missing canonical boundary");
|
|
369
424
|
const lastOrdinal = (gaps.at(-1) ?? panic("Missing canonical seam")).last;
|
|
@@ -403,12 +458,13 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
403
458
|
/** The first paragraph the projection addresses, in document order. */
|
|
404
459
|
get firstParagraph() {
|
|
405
460
|
const block = this.blocks.findIndex(({ paragraphs }) => paragraphs.length > 0);
|
|
406
|
-
return block < 0 ? void 0 : this.
|
|
461
|
+
return block < 0 ? void 0 : this.alignedAddressOf(block, 0);
|
|
407
462
|
}
|
|
463
|
+
/** A paragraph's address; none for one the projection cannot align. */
|
|
408
464
|
paragraph(blockId) {
|
|
409
465
|
const slot = this.index.get(blockId);
|
|
410
466
|
if (slot === void 0 || slot.paragraph < 0) return void 0;
|
|
411
|
-
return this.
|
|
467
|
+
return this.alignedAddressOf(slot.block, slot.paragraph);
|
|
412
468
|
}
|
|
413
469
|
/** The paragraph whose node starts at `before`. */
|
|
414
470
|
paragraphStartingAt(before) {
|
|
@@ -418,7 +474,8 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
418
474
|
nextParagraphInContainer(blockId) {
|
|
419
475
|
const slot = this.index.get(blockId);
|
|
420
476
|
if (slot === void 0 || slot.paragraph < 0) return void 0;
|
|
421
|
-
const paragraph = this.
|
|
477
|
+
const paragraph = this.alignedAddressOf(slot.block, slot.paragraph);
|
|
478
|
+
if (paragraph === void 0) return void 0;
|
|
422
479
|
const index = paragraph.container.indexOf(paragraph.source);
|
|
423
480
|
if (index >= 0) {
|
|
424
481
|
let at = index + 1;
|
|
@@ -435,8 +492,8 @@ var CanonicalProjection = class CanonicalProjection {
|
|
|
435
492
|
next = 0;
|
|
436
493
|
}
|
|
437
494
|
if (block >= this.blocks.length) return void 0;
|
|
438
|
-
const following = this.
|
|
439
|
-
return paragraph.container === following
|
|
495
|
+
const following = this.alignedAddressOf(block, next);
|
|
496
|
+
return paragraph.container === following?.container ? following : void 0;
|
|
440
497
|
}
|
|
441
498
|
};
|
|
442
499
|
/** Immutable operations retain content identities for every untouched story. */
|
|
@@ -518,8 +575,13 @@ const placeShownSelection = (transaction, projection) => {
|
|
|
518
575
|
const read = projection.selectionAt(transaction);
|
|
519
576
|
return read.isOk() ? read.value : void 0;
|
|
520
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* A projected paragraph the document does not hold, or holds once for two:
|
|
580
|
+
* the projection and the document it was made from are out of step, a defect
|
|
581
|
+
* of the session.
|
|
582
|
+
*/
|
|
521
583
|
const structureRefusal = () => new CanonicalSessionError({
|
|
522
|
-
ground:
|
|
584
|
+
ground: INTERNAL,
|
|
523
585
|
reason: "refused",
|
|
524
586
|
message: "The projection changed paragraph structure."
|
|
525
587
|
});
|
|
@@ -621,6 +683,56 @@ var OpenComments = class {
|
|
|
621
683
|
return this.kept;
|
|
622
684
|
}
|
|
623
685
|
};
|
|
686
|
+
const NO_OPEN_COMMENTS = /* @__PURE__ */ new Set();
|
|
687
|
+
/**
|
|
688
|
+
* The refusal of a paragraph whose source the projection cannot align with
|
|
689
|
+
* its node. Every inline item the document holds has a projection policy, so
|
|
690
|
+
* such a paragraph is a projection out of step with the document.
|
|
691
|
+
*/
|
|
692
|
+
const inlineRefusal = (message) => new CanonicalSessionError({
|
|
693
|
+
ground: INTERNAL,
|
|
694
|
+
reason: "refused",
|
|
695
|
+
message
|
|
696
|
+
});
|
|
697
|
+
/** Whether a paragraph's editor node shows a comment's mark or boundary. */
|
|
698
|
+
const showsComments = (paragraph) => {
|
|
699
|
+
let shows = false;
|
|
700
|
+
paragraph.descendants((node) => {
|
|
701
|
+
if (node.type.name === "commentRangeBoundary" || node.marks.some((mark) => mark.type.name === "comment")) shows = true;
|
|
702
|
+
return !shows;
|
|
703
|
+
});
|
|
704
|
+
return shows;
|
|
705
|
+
};
|
|
706
|
+
/**
|
|
707
|
+
* A paragraph's text and gaps for a block walk. A walk that defers them
|
|
708
|
+
* still refuses now what the paragraph's editor node alone refuses (an
|
|
709
|
+
* inline construct canonical editing cannot place), and projects now a
|
|
710
|
+
* paragraph comments run through or mark, in its source or its node, with
|
|
711
|
+
* the ranges open at its start; any other paragraph's source is aligned
|
|
712
|
+
* with its node when it is first addressed, as it would have been now.
|
|
713
|
+
*/
|
|
714
|
+
const walkInline = (args, walk) => {
|
|
715
|
+
const project = (projected) => {
|
|
716
|
+
const inline = walk.inline === void 0 ? projectCanonicalInline(projected) : walk.inline.project(projected);
|
|
717
|
+
return inline.isOk() ? Result.ok(inline.value) : Result.err(inline.error.message);
|
|
718
|
+
};
|
|
719
|
+
if (!walk.deferInline || args.commentContext.openIds.size > 0 || walk.markersOf(args.source).length > 0 || showsComments(args.paragraph)) {
|
|
720
|
+
const inline = project(args);
|
|
721
|
+
if (inline.isErr()) return inline;
|
|
722
|
+
return Result.ok(() => inline);
|
|
723
|
+
}
|
|
724
|
+
const native = canonicalNativeCells(args.paragraph);
|
|
725
|
+
if (native.isErr()) return Result.err(native.error.message);
|
|
726
|
+
const deferred = {
|
|
727
|
+
...args,
|
|
728
|
+
commentContext: {
|
|
729
|
+
...args.commentContext,
|
|
730
|
+
openIds: NO_OPEN_COMMENTS
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
let inline;
|
|
734
|
+
return Result.ok(() => inline ??= project(deferred));
|
|
735
|
+
};
|
|
624
736
|
/**
|
|
625
737
|
* The paragraphs of a text box's editor node, addressed as its story's
|
|
626
738
|
* paragraphs. A paragraph the session cannot place in the box's source (one
|
|
@@ -639,13 +751,12 @@ const projectTextBoxParagraphs = ({ box, offset, walk, paragraphs }) => {
|
|
|
639
751
|
const paraId = node.attrs["paraId"];
|
|
640
752
|
const located = typeof paraId === "string" ? walk.locateBoxed(paraId) : void 0;
|
|
641
753
|
if (typeof paraId !== "string" || located === void 0 || !walk.takeBoxed(located.source)) return false;
|
|
642
|
-
const
|
|
754
|
+
const inline = walkInline({
|
|
643
755
|
source: located.source,
|
|
644
756
|
paragraph: node,
|
|
645
757
|
pairedBookmarkIds: walk.facts.pairedBookmarkIds,
|
|
646
758
|
commentContext
|
|
647
|
-
};
|
|
648
|
-
const inline = walk.inline === void 0 ? projectCanonicalInline(inlineArgs) : walk.inline.project(inlineArgs);
|
|
759
|
+
}, walk);
|
|
649
760
|
if (inline.isOk()) paragraphs.push({
|
|
650
761
|
blockId: paraId,
|
|
651
762
|
container: located.container,
|
|
@@ -705,19 +816,14 @@ const projectBlock = (top, index, walk) => {
|
|
|
705
816
|
}
|
|
706
817
|
if (located.top !== index) local = false;
|
|
707
818
|
passCommentMarkers(walk.positionedComments.before.get(source), walk.open);
|
|
708
|
-
const
|
|
819
|
+
const inline = walkInline({
|
|
709
820
|
source,
|
|
710
821
|
paragraph: node,
|
|
711
822
|
pairedBookmarkIds: walk.facts.pairedBookmarkIds,
|
|
712
823
|
commentContext
|
|
713
|
-
};
|
|
714
|
-
const inline = walk.inline === void 0 ? projectCanonicalInline(inlineArgs) : walk.inline.project(inlineArgs);
|
|
824
|
+
}, walk);
|
|
715
825
|
if (inline.isErr()) {
|
|
716
|
-
failure =
|
|
717
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
718
|
-
reason: "refused",
|
|
719
|
-
message: inline.error.message
|
|
720
|
-
});
|
|
826
|
+
failure = inlineRefusal(inline.error);
|
|
721
827
|
return false;
|
|
722
828
|
}
|
|
723
829
|
paragraphs.push({
|
|
@@ -748,7 +854,7 @@ const passCommentMarkers = (markers, open) => {
|
|
|
748
854
|
/** Opens and closes the ranges a paragraph's markers start and end. */
|
|
749
855
|
const commentPasser = (markersOf, open) => (paragraph) => passCommentMarkers(markersOf(paragraph), open);
|
|
750
856
|
/** Every paragraph's address, walking every top-level node. */
|
|
751
|
-
const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
857
|
+
const projectEveryBlock = ({ doc, content, story, markersOf, inline, deferInline }) => {
|
|
752
858
|
const pairedBookmarkIds = collectPairedBookmarkIds(content);
|
|
753
859
|
const rangedIds = /* @__PURE__ */ new Set();
|
|
754
860
|
const referencedIds = /* @__PURE__ */ new Set();
|
|
@@ -815,7 +921,8 @@ const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
|
815
921
|
},
|
|
816
922
|
passComments,
|
|
817
923
|
positionedComments,
|
|
818
|
-
inline
|
|
924
|
+
inline,
|
|
925
|
+
deferInline
|
|
819
926
|
};
|
|
820
927
|
const blocks = [];
|
|
821
928
|
for (let index = 0; index < doc.childCount; index += 1) {
|
|
@@ -894,7 +1001,8 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
894
1001
|
},
|
|
895
1002
|
passComments: commentPasser(markersOf, open),
|
|
896
1003
|
positionedComments: positionedCommentGaps(content.slice(start, newEnd), continuationSources),
|
|
897
|
-
inline
|
|
1004
|
+
inline,
|
|
1005
|
+
deferInline: false
|
|
898
1006
|
};
|
|
899
1007
|
const window = [];
|
|
900
1008
|
for (let index = start; index < newEnd; index += 1) {
|
|
@@ -935,7 +1043,7 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
935
1043
|
reusable: true
|
|
936
1044
|
});
|
|
937
1045
|
};
|
|
938
|
-
const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous }) => {
|
|
1046
|
+
const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous, deferInline }) => {
|
|
939
1047
|
const body = findStoryBody(document, story);
|
|
940
1048
|
if (!body) return refuse("The canonical story no longer exists.", STALE);
|
|
941
1049
|
const currentStyles = Object.hasOwn(document.package, "styles") ? document.package.styles : styles;
|
|
@@ -965,10 +1073,17 @@ const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous }
|
|
|
965
1073
|
content: body.content,
|
|
966
1074
|
story,
|
|
967
1075
|
markersOf: caches?.comments.read ?? paragraphCommentMarkers,
|
|
968
|
-
inline: caches?.inline
|
|
1076
|
+
inline: caches?.inline,
|
|
1077
|
+
deferInline: deferInline === true && previous === void 0
|
|
969
1078
|
};
|
|
970
1079
|
const kept = previous === void 0 ? void 0 : projectChangedBlocks(previous, walk);
|
|
971
|
-
|
|
1080
|
+
const result = kept === void 0 ? projectEveryBlock(walk) : Result.ok(kept);
|
|
1081
|
+
if (result.isOk() && !markupViewSources.has(result.value.doc)) markupViewSources.set(result.value.doc, {
|
|
1082
|
+
document,
|
|
1083
|
+
story,
|
|
1084
|
+
options
|
|
1085
|
+
});
|
|
1086
|
+
return result;
|
|
972
1087
|
};
|
|
973
1088
|
const intentStory = (intent) => {
|
|
974
1089
|
switch (intent.type) {
|
|
@@ -978,6 +1093,7 @@ const intentStory = (intent) => {
|
|
|
978
1093
|
case "replaceFragment":
|
|
979
1094
|
case "pasteBlocks":
|
|
980
1095
|
case "moveFragment":
|
|
1096
|
+
case "moveBlocks":
|
|
981
1097
|
case "replaceText":
|
|
982
1098
|
case "formatRun":
|
|
983
1099
|
case "insertAtom": return intent.from.story;
|
|
@@ -1015,11 +1131,12 @@ const continuesGroup = (previous, next) => {
|
|
|
1015
1131
|
}
|
|
1016
1132
|
};
|
|
1017
1133
|
const authorizedProjections = /* @__PURE__ */ new WeakMap();
|
|
1018
|
-
|
|
1019
|
-
const isCanonicalProjectionTransaction = (transaction, session) => {
|
|
1134
|
+
const canonicalProjectionAuthorization = (transaction, session) => {
|
|
1020
1135
|
const authorization = authorizedProjections.get(transaction);
|
|
1021
|
-
|
|
1136
|
+
if (authorization?.session === session && authorization.version === session.version && transaction.doc.eq(authorization.doc)) return authorization;
|
|
1022
1137
|
};
|
|
1138
|
+
/** Metadata is descriptive; transaction identity and session version authorize mutations. */
|
|
1139
|
+
const isCanonicalProjectionTransaction = (transaction, session) => canonicalProjectionAuthorization(transaction, session) !== void 0;
|
|
1023
1140
|
/** A node's shape without its text, for a refusal that names a change. */
|
|
1024
1141
|
const nodeShapeOf = (node) => JSON.stringify({
|
|
1025
1142
|
type: node.type.name,
|
|
@@ -1043,7 +1160,8 @@ const projectionChangeOf = (projected, published) => {
|
|
|
1043
1160
|
};
|
|
1044
1161
|
/** The model publishes only after PM and every plugin accept its exact projection. */
|
|
1045
1162
|
const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
1046
|
-
|
|
1163
|
+
const authorization = canonicalProjectionAuthorization(commit.transaction, session);
|
|
1164
|
+
if (authorization === void 0) return refuse("The staged canonical projection is unauthorized.", INTERNAL);
|
|
1047
1165
|
const applied = Result.try({
|
|
1048
1166
|
try: () => state.applyTransaction(commit.transaction),
|
|
1049
1167
|
catch: (cause) => new CanonicalSessionError({
|
|
@@ -1058,6 +1176,12 @@ const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
|
1058
1176
|
if (!staged.state.doc.eq(commit.projection.doc) || staged.transactions.some((transaction) => transaction.docChanged && !isCanonicalProjectionTransaction(transaction, session))) return refuse(`A plugin refused or changed the canonical projection: ${projectionChangeOf(commit.projection.doc, staged.state.doc)}.`, HOST_TRANSACTION);
|
|
1059
1177
|
const published = commit.publish();
|
|
1060
1178
|
if (published.isErr()) return published;
|
|
1179
|
+
const source = markupViewSources.get(authorization.doc);
|
|
1180
|
+
markupViewStateSources.set(staged.state, {
|
|
1181
|
+
...source,
|
|
1182
|
+
document: commit.document,
|
|
1183
|
+
story: commit.projection.story
|
|
1184
|
+
});
|
|
1061
1185
|
return Result.ok(staged);
|
|
1062
1186
|
};
|
|
1063
1187
|
/**
|
|
@@ -1219,76 +1343,6 @@ var CanonicalSession = class {
|
|
|
1219
1343
|
hasStyle(styleId) {
|
|
1220
1344
|
return (this.styles ?? this.currentDocument.package.styles)?.styles.some((style) => style.styleId === styleId) ?? false;
|
|
1221
1345
|
}
|
|
1222
|
-
/** How a replacement in the current mode removes the words it changes. */
|
|
1223
|
-
/**
|
|
1224
|
-
* A replacement cut into pieces at the comment boundaries it keeps, within
|
|
1225
|
-
* one paragraph: the last piece takes the text, the others are cleared, and
|
|
1226
|
-
* each is compiled after the ones behind it, so no earlier address moves.
|
|
1227
|
-
* The caret follows the new text, moved back by what the pieces before it
|
|
1228
|
-
* cleared.
|
|
1229
|
-
*/
|
|
1230
|
-
compileReplacementPieces({ projection, pieces, start, end, intent }) {
|
|
1231
|
-
const refused = (message) => refuse(message, { gap: CANONICAL_GAP.commentReplacementAlignment });
|
|
1232
|
-
const addressed = [];
|
|
1233
|
-
for (const [index, piece] of pieces.entries()) {
|
|
1234
|
-
const from = index === 0 ? Result.ok(start) : projection.inputAddressAt(piece.from, "afterMarkers");
|
|
1235
|
-
const to = index === pieces.length - 1 ? Result.ok(end) : projection.inputAddressAt(piece.to, "beforeMarkers");
|
|
1236
|
-
if (from.isErr() || to.isErr()) return refused("A replacement piece has no address.");
|
|
1237
|
-
if (from.value.blockId !== start.blockId || to.value.blockId !== start.blockId) return refused("A replacement cut at comment boundaries stays in one paragraph.");
|
|
1238
|
-
addressed.push({
|
|
1239
|
-
from: from.value,
|
|
1240
|
-
to: to.value,
|
|
1241
|
-
text: piece.text
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
let document = this.currentDocument;
|
|
1245
|
-
const ops = [];
|
|
1246
|
-
let caret;
|
|
1247
|
-
let cleared = 0;
|
|
1248
|
-
const { inside, ...shared } = intent;
|
|
1249
|
-
for (const [index, piece] of [...addressed.entries()].reverse()) {
|
|
1250
|
-
const last = index === addressed.length - 1;
|
|
1251
|
-
const step = {
|
|
1252
|
-
...shared,
|
|
1253
|
-
from: piece.from,
|
|
1254
|
-
to: piece.to,
|
|
1255
|
-
text: piece.text,
|
|
1256
|
-
...last && inside?.end === true ? { inside: { end: true } } : {}
|
|
1257
|
-
};
|
|
1258
|
-
const compiled = compileEditorIntent(document, {
|
|
1259
|
-
intent: step,
|
|
1260
|
-
mode: this.intentMode(document, step)
|
|
1261
|
-
});
|
|
1262
|
-
if (compiled.isErr()) return refused(compiled.error.message);
|
|
1263
|
-
const applied = compiled.value.applied === void 0 ? applyDocumentOps(document, compiled.value.ops) : Result.ok(compiled.value.applied);
|
|
1264
|
-
if (applied.isErr()) return refused(applied.error.message);
|
|
1265
|
-
document = applied.value.document;
|
|
1266
|
-
ops.push(...compiled.value.ops);
|
|
1267
|
-
if (last) caret = compiled.value.selection;
|
|
1268
|
-
else cleared += piece.to.offset - piece.from.offset;
|
|
1269
|
-
}
|
|
1270
|
-
if (caret === void 0) return refused("A replacement cut at comment boundaries lost its text.");
|
|
1271
|
-
return Result.ok({
|
|
1272
|
-
ops,
|
|
1273
|
-
selection: {
|
|
1274
|
-
...caret,
|
|
1275
|
-
offset: caret.offset - cleared
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
replacementRemoval() {
|
|
1280
|
-
switch (this.mode.type) {
|
|
1281
|
-
case "editing": return {
|
|
1282
|
-
type: "direct",
|
|
1283
|
-
comments: this.currentDocument.package.document.comments ?? []
|
|
1284
|
-
};
|
|
1285
|
-
case "suggesting": return { type: "tracked" };
|
|
1286
|
-
default: {
|
|
1287
|
-
const unhandled = this.mode;
|
|
1288
|
-
return panic(`Unknown canonical session mode ${String(unhandled)}`);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
1346
|
advanceBlockId() {
|
|
1293
1347
|
while (this.allocatedBlockIds.has(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase())) this.nextBlockId += 1;
|
|
1294
1348
|
}
|
|
@@ -1374,7 +1428,8 @@ var CanonicalSession = class {
|
|
|
1374
1428
|
case "insertHyperlink":
|
|
1375
1429
|
case "replaceFragment":
|
|
1376
1430
|
case "pasteBlocks":
|
|
1377
|
-
case "moveFragment":
|
|
1431
|
+
case "moveFragment":
|
|
1432
|
+
case "moveBlocks": return true;
|
|
1378
1433
|
case "replaceText":
|
|
1379
1434
|
case "insertAtom":
|
|
1380
1435
|
case "formatRun":
|
|
@@ -1661,11 +1716,8 @@ var CanonicalSession = class {
|
|
|
1661
1716
|
if (state.selection instanceof CellSelection) {
|
|
1662
1717
|
if (from !== state.selection.from || to !== state.selection.to) return refuse("A replacement range cannot partially address a cell selection.", INVALID_REQUEST);
|
|
1663
1718
|
const ranges = canonicalCellSelectionRanges(state.selection);
|
|
1664
|
-
|
|
1665
|
-
const lastRange = ranges.at(-1);
|
|
1666
|
-
if (firstRange === void 0 || lastRange === void 0) return refuse("The selected cells contain no editable text.", INVALID_REQUEST);
|
|
1719
|
+
if (ranges.length === 0) return refuse("The selected cells contain no editable text.", INVALID_REQUEST);
|
|
1667
1720
|
const intents = [];
|
|
1668
|
-
const commentChanges = [];
|
|
1669
1721
|
let first = true;
|
|
1670
1722
|
for (const range of ranges) {
|
|
1671
1723
|
const edges = projection.rangeEdgesAt(range.from, range.to);
|
|
@@ -1679,23 +1731,8 @@ var CanonicalSession = class {
|
|
|
1679
1731
|
to: cellTo.value,
|
|
1680
1732
|
text: first ? text : ""
|
|
1681
1733
|
});
|
|
1682
|
-
commentChanges.push({
|
|
1683
|
-
from: range.from,
|
|
1684
|
-
to: range.to,
|
|
1685
|
-
text: first ? text : "",
|
|
1686
|
-
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1687
|
-
});
|
|
1688
1734
|
first = false;
|
|
1689
1735
|
}
|
|
1690
|
-
if (text !== "" && !preservesReplacementCommentAlignment({
|
|
1691
|
-
doc: state.doc,
|
|
1692
|
-
source: {
|
|
1693
|
-
from: firstRange.from,
|
|
1694
|
-
to: lastRange.to
|
|
1695
|
-
},
|
|
1696
|
-
changes: commentChanges,
|
|
1697
|
-
removal: this.replacementRemoval()
|
|
1698
|
-
})) return refuse("Canonical replacement cannot preserve the aligned comment ranges.", { gap: CANONICAL_GAP.commentReplacementAlignment });
|
|
1699
1736
|
return this.prepareIntents(state, {
|
|
1700
1737
|
intents,
|
|
1701
1738
|
semantic
|
|
@@ -1713,43 +1750,6 @@ var CanonicalSession = class {
|
|
|
1713
1750
|
if (start.isErr()) return start;
|
|
1714
1751
|
const end = inputFrom === inputTo && editCaret !== void 0 ? Result.ok(editCaret) : projection.inputAddressAt(inputTo, edges.end);
|
|
1715
1752
|
if (end.isErr()) return end;
|
|
1716
|
-
let pieces = [];
|
|
1717
|
-
if (inputFrom < inputTo && text !== "") {
|
|
1718
|
-
const retirement = planWholeParagraphReplacement({
|
|
1719
|
-
document: this.currentDocument,
|
|
1720
|
-
from: start.value,
|
|
1721
|
-
to: end.value,
|
|
1722
|
-
suggesting: this.mode.type === "suggesting" ? { author: this.mode.author } : void 0
|
|
1723
|
-
});
|
|
1724
|
-
if (retirement.isErr()) return refuseOp(retirement.error);
|
|
1725
|
-
const removal = this.replacementRemoval();
|
|
1726
|
-
const whole = [{
|
|
1727
|
-
from: inputFrom,
|
|
1728
|
-
to: inputTo,
|
|
1729
|
-
text,
|
|
1730
|
-
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1731
|
-
}];
|
|
1732
|
-
const aligned = (changes, retiredCommentIds) => preservesReplacementCommentAlignment({
|
|
1733
|
-
doc: state.doc,
|
|
1734
|
-
retiredCommentIds,
|
|
1735
|
-
removal,
|
|
1736
|
-
source: {
|
|
1737
|
-
from: inputFrom,
|
|
1738
|
-
to: inputTo
|
|
1739
|
-
},
|
|
1740
|
-
changes
|
|
1741
|
-
});
|
|
1742
|
-
if (!aligned(whole, retirement.value?.commentIds)) {
|
|
1743
|
-
const split = removal.type === "direct" ? splitAtKeptCommentBoundaries({
|
|
1744
|
-
doc: state.doc,
|
|
1745
|
-
changes: whole,
|
|
1746
|
-
comments: removal.comments
|
|
1747
|
-
}) : void 0;
|
|
1748
|
-
const retired = /* @__PURE__ */ new Set([...retirement.value?.commentIds ?? [], ...split?.retiredCommentIds ?? []]);
|
|
1749
|
-
if (split === void 0 || split.changes.length < 2 || !aligned(split.changes, retired)) return refuse("Canonical replacement cannot preserve the aligned comment ranges.", { gap: CANONICAL_GAP.commentReplacementAlignment });
|
|
1750
|
-
pieces = split.changes;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
1753
|
const preSelection = projection.selectionAt(state);
|
|
1754
1754
|
if (preSelection.isErr()) return preSelection;
|
|
1755
1755
|
const inside = controlEdgesAt(state.doc, inputFrom, inputTo);
|
|
@@ -1761,20 +1761,11 @@ var CanonicalSession = class {
|
|
|
1761
1761
|
...Object.keys(inside).length === 0 ? {} : { inside },
|
|
1762
1762
|
...state.storedMarks === null ? {} : { runPropsPatch: runFormattingPatchFromMarks(state.selection.$from.marks(), state.storedMarks) }
|
|
1763
1763
|
};
|
|
1764
|
-
const compiled =
|
|
1765
|
-
projection,
|
|
1766
|
-
pieces,
|
|
1767
|
-
start: start.value,
|
|
1768
|
-
end: end.value,
|
|
1769
|
-
intent
|
|
1770
|
-
}) : compileEditorIntent(this.currentDocument, {
|
|
1764
|
+
const compiled = compileEditorIntent(this.currentDocument, {
|
|
1771
1765
|
intent,
|
|
1772
1766
|
mode: this.intentMode(this.currentDocument, intent)
|
|
1773
1767
|
});
|
|
1774
|
-
if (compiled.isErr())
|
|
1775
|
-
if (compiled.error instanceof CanonicalSessionError) return Result.err(compiled.error);
|
|
1776
|
-
return compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(compiled.error.message) : refuseOp(compiled.error);
|
|
1777
|
-
}
|
|
1768
|
+
if (compiled.isErr()) return compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(compiled.error.message) : refuseOp(compiled.error);
|
|
1778
1769
|
const { ops, selection: caret } = compiled.value;
|
|
1779
1770
|
const postSelection = {
|
|
1780
1771
|
type: "text",
|
|
@@ -2229,13 +2220,18 @@ var CanonicalSession = class {
|
|
|
2229
2220
|
* revisions as ordinary tracked changes by `author`, keeping their ids, as
|
|
2230
2221
|
* the editor does: the change then waits for review like any other. Its
|
|
2231
2222
|
* comments stay as ordinary comments.
|
|
2223
|
+
*
|
|
2224
|
+
* With `story`, only the suggestion's part in that story resolves: its
|
|
2225
|
+
* revisions there and the comments it anchors there. Its records in other
|
|
2226
|
+
* stories stay pending, and resolve later the same way or whole.
|
|
2232
2227
|
*/
|
|
2233
|
-
prepareSuggestion(state, { suggestionId, resolution, author, date }) {
|
|
2234
|
-
const revisions = documentStories(this.currentDocument).map((story) => ({
|
|
2228
|
+
prepareSuggestion(state, { suggestionId, resolution, author, date, story: only }) {
|
|
2229
|
+
const revisions = documentStories(this.currentDocument).filter((story) => only === void 0 || sameStory(story, only)).map((story) => ({
|
|
2235
2230
|
story,
|
|
2236
2231
|
infos: suggestionRevisionInfos(this.currentDocument, story, suggestionId)
|
|
2237
2232
|
})).filter(({ infos }) => infos.length > 0);
|
|
2238
|
-
const
|
|
2233
|
+
const anchored = only === void 0 ? void 0 : commentIdsAnchoredIn(this.currentDocument, only);
|
|
2234
|
+
const commentIds = suggestedCommentIds(this.currentDocument, suggestionId).filter((id) => anchored === void 0 || anchored.has(id));
|
|
2239
2235
|
if (revisions.length === 0 && commentIds.length === 0) return noChange(`No pending suggestion ${suggestionId}.`);
|
|
2240
2236
|
if (resolution === "reject") return this.prepareResolve(state, {
|
|
2241
2237
|
revisionIds: [],
|
|
@@ -2645,15 +2641,12 @@ var CanonicalSession = class {
|
|
|
2645
2641
|
document: applied.value.document,
|
|
2646
2642
|
previous: this.currentDocument
|
|
2647
2643
|
});
|
|
2648
|
-
|
|
2644
|
+
const unsupported = unsupportedEditReason({
|
|
2649
2645
|
previous: this.currentDocument,
|
|
2650
2646
|
document: applied.value.document,
|
|
2651
2647
|
stories: changed
|
|
2652
|
-
})
|
|
2653
|
-
|
|
2654
|
-
reason: "refused",
|
|
2655
|
-
message: "The operations produce unsupported canonical story content."
|
|
2656
|
-
}));
|
|
2648
|
+
});
|
|
2649
|
+
if (unsupported !== null) return refuse("The operations produce unsupported canonical story content.", editIssueGround(unsupported));
|
|
2657
2650
|
applied.value.document = preservePropertySources({
|
|
2658
2651
|
target: applied.value.document,
|
|
2659
2652
|
source: this.currentDocument,
|
|
@@ -2834,7 +2827,7 @@ const createCanonicalSession = (document, styles, { idLease, newOpId } = {}) =>
|
|
|
2834
2827
|
const owned = cloneDocumentWithParagraphPropertySources(document);
|
|
2835
2828
|
const source = normalizeCanonicalSource(owned);
|
|
2836
2829
|
const unsupported = unsupportedSeedReason(source.document);
|
|
2837
|
-
if (unsupported !== null) return refuse(unsupported,
|
|
2830
|
+
if (unsupported !== null) return refuse(unsupported.message, INVALID_REQUEST);
|
|
2838
2831
|
const identified = preservePropertySourcesWholeStories({
|
|
2839
2832
|
target: normalizeForOps(source.document),
|
|
2840
2833
|
source: owned
|
|
@@ -2849,7 +2842,8 @@ const createCanonicalSession = (document, styles, { idLease, newOpId } = {}) =>
|
|
|
2849
2842
|
const projected = project({
|
|
2850
2843
|
document: normalized,
|
|
2851
2844
|
styles,
|
|
2852
|
-
caches
|
|
2845
|
+
caches,
|
|
2846
|
+
deferInline: true
|
|
2853
2847
|
});
|
|
2854
2848
|
if (projected.isErr()) return projected;
|
|
2855
2849
|
return Result.ok(new CanonicalSession({
|
|
@@ -2889,7 +2883,7 @@ const visibleDeletionContext = (state) => {
|
|
|
2889
2883
|
const native = canonicalNativeCells(paragraph);
|
|
2890
2884
|
if (native.isErr()) {
|
|
2891
2885
|
issue = new CanonicalSessionError({
|
|
2892
|
-
ground:
|
|
2886
|
+
ground: INTERNAL,
|
|
2893
2887
|
reason: "refused",
|
|
2894
2888
|
message: native.error.message
|
|
2895
2889
|
});
|
|
@@ -12,7 +12,8 @@ type ClipboardAnnotationsOptions = {
|
|
|
12
12
|
* The notes and comments the clipboard's references and markers name, read
|
|
13
13
|
* from the document they were copied from; the paste copies each under a
|
|
14
14
|
* fresh id. Without that document the ids could name the destination's own
|
|
15
|
-
* notes and comments
|
|
15
|
+
* notes and comments: the paste keeps the text and leaves the markers and
|
|
16
|
+
* references out, as a copy made outside the editor holds no comment or note.
|
|
16
17
|
*/
|
|
17
18
|
export declare const clipboardAnnotations: ({ paragraphs, source }: ClipboardAnnotationsOptions) => Result<PasteAnnotations | undefined, CanonicalSessionError>;
|
|
18
19
|
/** Clipboard slices are input payloads; their paragraph identities and private captures are not owners. */
|
|
@@ -29,5 +30,5 @@ type PrepareCanonicalPasteOptions = {
|
|
|
29
30
|
to: number;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
|
-
export declare const prepareCanonicalPaste: ({ session, state, slice, plain, moveTarget, pasteTarget, sourceDocument, moveSource }: PrepareCanonicalPasteOptions) => Result<CanonicalCommit, CanonicalSessionError>;
|
|
33
|
+
export declare const prepareCanonicalPaste: ({ session, state, slice: copied, plain, moveTarget, pasteTarget, sourceDocument, moveSource }: PrepareCanonicalPasteOptions) => Result<CanonicalCommit, CanonicalSessionError>;
|
|
33
34
|
export {};
|