@stll/folio-core 0.76.0 → 0.78.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 +6 -4
- package/dist/ai-edits/headless.js +32 -15
- package/dist/ai-edits/pending-suggestions.d.ts +9 -0
- package/dist/ai-edits/pending-suggestions.js +11 -0
- package/dist/ai-edits/read.js +24 -1
- package/dist/ai-edits/table-geometry.js +12 -4
- package/dist/canonical/canonicalBatchReview.js +7 -6
- 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 +19 -40
- 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 +190 -194
- package/dist/compare/inline-provenance.js +8 -1
- package/dist/controller/canonicalClipboard.d.ts +2 -1
- package/dist/controller/canonicalClipboard.js +312 -47
- package/dist/controller/canonicalComposition.js +67 -14
- package/dist/controller/canonicalStoryEditor.js +2 -0
- package/dist/controller/hiddenEditorManager.js +2 -0
- package/dist/docx/importedIdCollisions.js +29 -4
- package/dist/docx/paragraphParser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +2 -0
- package/dist/docx/reviewResolutionProvenance.js +22 -2
- package/dist/docx/server/templatePlan/apply.js +47 -2
- package/dist/docx/server/templatePlan/blocks.d.ts +34 -7
- package/dist/docx/server/templatePlan/blocks.js +190 -13
- package/dist/docx/server/templatePlan/builders.d.ts +8 -1
- package/dist/docx/server/templatePlan/builders.js +21 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +108 -6
- package/dist/docx/server/templatePlan/plan.d.ts +26 -1
- package/dist/docx/server/templatePlan/plan.js +181 -21
- package/dist/docx/server/templatePlan/planShape.js +15 -3
- package/dist/docx/server/templatePlan/revisions.d.ts +55 -0
- package/dist/docx/server/templatePlan/revisions.js +276 -2
- package/dist/docx/server/templatePlan/story.d.ts +58 -1
- package/dist/docx/server/templatePlan/story.js +176 -12
- package/dist/docx/server/templatePlan/types.d.ts +153 -1
- package/dist/docx/server/templatePlan/verify.js +58 -15
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
- package/dist/docx/tableGridXml.d.ts +3 -7
- package/dist/docx/tableGridXml.js +23 -15
- package/dist/docx/tableParser.js +3 -1
- 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 +7 -9
- package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
- package/dist/prosemirror/conversion/markupViewSource.js +11 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +8 -0
- package/dist/prosemirror/conversion/toProseDoc.js +43 -19
- 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/replacedAnnotations.d.ts +4 -78
- package/dist/prosemirror/replacedAnnotations.js +11 -194
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
- package/dist/prosemirror/styles/styleResolver.js +4 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +3 -10
- package/dist/types/canonicalCapabilities.js +3 -10
- package/package.json +2 -2
- 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 -3
- package/dist/internal/revisionResolutionStep.js +0 -113
- 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 -8
- package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -56
- 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";
|
|
@@ -36,8 +37,8 @@ import { controlEdgesAt } from "./controlEdges.js";
|
|
|
36
37
|
import { ownedSourceCopies, preservePropertySources, preservePropertySourcesWholeStories } from "./propertySourcePreservation.js";
|
|
37
38
|
import { Result, TaggedError, panic } from "better-result";
|
|
38
39
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
39
|
-
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,
|
|
40
|
+
import { lockedControlMessage, tableWithPhysicalColumns } from "@stll/docx-core/model";
|
|
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
|
});
|
|
@@ -540,8 +602,9 @@ const visitBlockSources = (block, container, visit, insideSkippedContinuation) =
|
|
|
540
602
|
return;
|
|
541
603
|
}
|
|
542
604
|
if (block.type !== "table") return;
|
|
543
|
-
const
|
|
544
|
-
|
|
605
|
+
const display = tableWithPhysicalColumns(block);
|
|
606
|
+
const rowSpans = calculateRowSpans(display);
|
|
607
|
+
for (const [rowIndex, row] of display.rows.entries()) {
|
|
545
608
|
let column = row.formatting?.gridBefore ?? 0;
|
|
546
609
|
for (const cell of row.cells) {
|
|
547
610
|
const skippedContinuation = isCellMergeContinuation(cell) && (rowSpans.get(`${rowIndex}-${column}`)?.skip ?? false);
|
|
@@ -621,6 +684,56 @@ var OpenComments = class {
|
|
|
621
684
|
return this.kept;
|
|
622
685
|
}
|
|
623
686
|
};
|
|
687
|
+
const NO_OPEN_COMMENTS = /* @__PURE__ */ new Set();
|
|
688
|
+
/**
|
|
689
|
+
* The refusal of a paragraph whose source the projection cannot align with
|
|
690
|
+
* its node. Every inline item the document holds has a projection policy, so
|
|
691
|
+
* such a paragraph is a projection out of step with the document.
|
|
692
|
+
*/
|
|
693
|
+
const inlineRefusal = (message) => new CanonicalSessionError({
|
|
694
|
+
ground: INTERNAL,
|
|
695
|
+
reason: "refused",
|
|
696
|
+
message
|
|
697
|
+
});
|
|
698
|
+
/** Whether a paragraph's editor node shows a comment's mark or boundary. */
|
|
699
|
+
const showsComments = (paragraph) => {
|
|
700
|
+
let shows = false;
|
|
701
|
+
paragraph.descendants((node) => {
|
|
702
|
+
if (node.type.name === "commentRangeBoundary" || node.marks.some((mark) => mark.type.name === "comment")) shows = true;
|
|
703
|
+
return !shows;
|
|
704
|
+
});
|
|
705
|
+
return shows;
|
|
706
|
+
};
|
|
707
|
+
/**
|
|
708
|
+
* A paragraph's text and gaps for a block walk. A walk that defers them
|
|
709
|
+
* still refuses now what the paragraph's editor node alone refuses (an
|
|
710
|
+
* inline construct canonical editing cannot place), and projects now a
|
|
711
|
+
* paragraph comments run through or mark, in its source or its node, with
|
|
712
|
+
* the ranges open at its start; any other paragraph's source is aligned
|
|
713
|
+
* with its node when it is first addressed, as it would have been now.
|
|
714
|
+
*/
|
|
715
|
+
const walkInline = (args, walk) => {
|
|
716
|
+
const project = (projected) => {
|
|
717
|
+
const inline = walk.inline === void 0 ? projectCanonicalInline(projected) : walk.inline.project(projected);
|
|
718
|
+
return inline.isOk() ? Result.ok(inline.value) : Result.err(inline.error.message);
|
|
719
|
+
};
|
|
720
|
+
if (!walk.deferInline || args.commentContext.openIds.size > 0 || walk.markersOf(args.source).length > 0 || showsComments(args.paragraph)) {
|
|
721
|
+
const inline = project(args);
|
|
722
|
+
if (inline.isErr()) return inline;
|
|
723
|
+
return Result.ok(() => inline);
|
|
724
|
+
}
|
|
725
|
+
const native = canonicalNativeCells(args.paragraph);
|
|
726
|
+
if (native.isErr()) return Result.err(native.error.message);
|
|
727
|
+
const deferred = {
|
|
728
|
+
...args,
|
|
729
|
+
commentContext: {
|
|
730
|
+
...args.commentContext,
|
|
731
|
+
openIds: NO_OPEN_COMMENTS
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
let inline;
|
|
735
|
+
return Result.ok(() => inline ??= project(deferred));
|
|
736
|
+
};
|
|
624
737
|
/**
|
|
625
738
|
* The paragraphs of a text box's editor node, addressed as its story's
|
|
626
739
|
* paragraphs. A paragraph the session cannot place in the box's source (one
|
|
@@ -639,13 +752,12 @@ const projectTextBoxParagraphs = ({ box, offset, walk, paragraphs }) => {
|
|
|
639
752
|
const paraId = node.attrs["paraId"];
|
|
640
753
|
const located = typeof paraId === "string" ? walk.locateBoxed(paraId) : void 0;
|
|
641
754
|
if (typeof paraId !== "string" || located === void 0 || !walk.takeBoxed(located.source)) return false;
|
|
642
|
-
const
|
|
755
|
+
const inline = walkInline({
|
|
643
756
|
source: located.source,
|
|
644
757
|
paragraph: node,
|
|
645
758
|
pairedBookmarkIds: walk.facts.pairedBookmarkIds,
|
|
646
759
|
commentContext
|
|
647
|
-
};
|
|
648
|
-
const inline = walk.inline === void 0 ? projectCanonicalInline(inlineArgs) : walk.inline.project(inlineArgs);
|
|
760
|
+
}, walk);
|
|
649
761
|
if (inline.isOk()) paragraphs.push({
|
|
650
762
|
blockId: paraId,
|
|
651
763
|
container: located.container,
|
|
@@ -705,19 +817,14 @@ const projectBlock = (top, index, walk) => {
|
|
|
705
817
|
}
|
|
706
818
|
if (located.top !== index) local = false;
|
|
707
819
|
passCommentMarkers(walk.positionedComments.before.get(source), walk.open);
|
|
708
|
-
const
|
|
820
|
+
const inline = walkInline({
|
|
709
821
|
source,
|
|
710
822
|
paragraph: node,
|
|
711
823
|
pairedBookmarkIds: walk.facts.pairedBookmarkIds,
|
|
712
824
|
commentContext
|
|
713
|
-
};
|
|
714
|
-
const inline = walk.inline === void 0 ? projectCanonicalInline(inlineArgs) : walk.inline.project(inlineArgs);
|
|
825
|
+
}, walk);
|
|
715
826
|
if (inline.isErr()) {
|
|
716
|
-
failure =
|
|
717
|
-
ground: { gap: CANONICAL_GAP.storyContentProjection },
|
|
718
|
-
reason: "refused",
|
|
719
|
-
message: inline.error.message
|
|
720
|
-
});
|
|
827
|
+
failure = inlineRefusal(inline.error);
|
|
721
828
|
return false;
|
|
722
829
|
}
|
|
723
830
|
paragraphs.push({
|
|
@@ -748,7 +855,7 @@ const passCommentMarkers = (markers, open) => {
|
|
|
748
855
|
/** Opens and closes the ranges a paragraph's markers start and end. */
|
|
749
856
|
const commentPasser = (markersOf, open) => (paragraph) => passCommentMarkers(markersOf(paragraph), open);
|
|
750
857
|
/** Every paragraph's address, walking every top-level node. */
|
|
751
|
-
const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
858
|
+
const projectEveryBlock = ({ doc, content, story, markersOf, inline, deferInline }) => {
|
|
752
859
|
const pairedBookmarkIds = collectPairedBookmarkIds(content);
|
|
753
860
|
const rangedIds = /* @__PURE__ */ new Set();
|
|
754
861
|
const referencedIds = /* @__PURE__ */ new Set();
|
|
@@ -815,7 +922,8 @@ const projectEveryBlock = ({ doc, content, story, markersOf, inline }) => {
|
|
|
815
922
|
},
|
|
816
923
|
passComments,
|
|
817
924
|
positionedComments,
|
|
818
|
-
inline
|
|
925
|
+
inline,
|
|
926
|
+
deferInline
|
|
819
927
|
};
|
|
820
928
|
const blocks = [];
|
|
821
929
|
for (let index = 0; index < doc.childCount; index += 1) {
|
|
@@ -894,7 +1002,8 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
894
1002
|
},
|
|
895
1003
|
passComments: commentPasser(markersOf, open),
|
|
896
1004
|
positionedComments: positionedCommentGaps(content.slice(start, newEnd), continuationSources),
|
|
897
|
-
inline
|
|
1005
|
+
inline,
|
|
1006
|
+
deferInline: false
|
|
898
1007
|
};
|
|
899
1008
|
const window = [];
|
|
900
1009
|
for (let index = start; index < newEnd; index += 1) {
|
|
@@ -935,15 +1044,18 @@ const projectChangedBlocks = (previous, { doc, content, story, markersOf, inline
|
|
|
935
1044
|
reusable: true
|
|
936
1045
|
});
|
|
937
1046
|
};
|
|
938
|
-
const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous }) => {
|
|
1047
|
+
const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous, deferInline }) => {
|
|
939
1048
|
const body = findStoryBody(document, story);
|
|
940
1049
|
if (!body) return refuse("The canonical story no longer exists.", STALE);
|
|
941
1050
|
const currentStyles = Object.hasOwn(document.package, "styles") ? document.package.styles : styles;
|
|
942
|
-
const options =
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1051
|
+
const options = {
|
|
1052
|
+
...storyConversionOptions({
|
|
1053
|
+
styles: currentStyles,
|
|
1054
|
+
theme: document.package.theme,
|
|
1055
|
+
numbering: document.package.numbering
|
|
1056
|
+
}),
|
|
1057
|
+
tableReviewGeometry: "physical"
|
|
1058
|
+
};
|
|
947
1059
|
const converted = Result.try({
|
|
948
1060
|
try: () => {
|
|
949
1061
|
if (story === OP_STORIES.MAIN) return toProseDoc(document, caches === void 0 ? options : {
|
|
@@ -965,10 +1077,17 @@ const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous }
|
|
|
965
1077
|
content: body.content,
|
|
966
1078
|
story,
|
|
967
1079
|
markersOf: caches?.comments.read ?? paragraphCommentMarkers,
|
|
968
|
-
inline: caches?.inline
|
|
1080
|
+
inline: caches?.inline,
|
|
1081
|
+
deferInline: deferInline === true && previous === void 0
|
|
969
1082
|
};
|
|
970
1083
|
const kept = previous === void 0 ? void 0 : projectChangedBlocks(previous, walk);
|
|
971
|
-
|
|
1084
|
+
const result = kept === void 0 ? projectEveryBlock(walk) : Result.ok(kept);
|
|
1085
|
+
if (result.isOk() && !markupViewSources.has(result.value.doc)) markupViewSources.set(result.value.doc, {
|
|
1086
|
+
document,
|
|
1087
|
+
story,
|
|
1088
|
+
options
|
|
1089
|
+
});
|
|
1090
|
+
return result;
|
|
972
1091
|
};
|
|
973
1092
|
const intentStory = (intent) => {
|
|
974
1093
|
switch (intent.type) {
|
|
@@ -1016,11 +1135,12 @@ const continuesGroup = (previous, next) => {
|
|
|
1016
1135
|
}
|
|
1017
1136
|
};
|
|
1018
1137
|
const authorizedProjections = /* @__PURE__ */ new WeakMap();
|
|
1019
|
-
|
|
1020
|
-
const isCanonicalProjectionTransaction = (transaction, session) => {
|
|
1138
|
+
const canonicalProjectionAuthorization = (transaction, session) => {
|
|
1021
1139
|
const authorization = authorizedProjections.get(transaction);
|
|
1022
|
-
|
|
1140
|
+
if (authorization?.session === session && authorization.version === session.version && transaction.doc.eq(authorization.doc)) return authorization;
|
|
1023
1141
|
};
|
|
1142
|
+
/** Metadata is descriptive; transaction identity and session version authorize mutations. */
|
|
1143
|
+
const isCanonicalProjectionTransaction = (transaction, session) => canonicalProjectionAuthorization(transaction, session) !== void 0;
|
|
1024
1144
|
/** A node's shape without its text, for a refusal that names a change. */
|
|
1025
1145
|
const nodeShapeOf = (node) => JSON.stringify({
|
|
1026
1146
|
type: node.type.name,
|
|
@@ -1044,7 +1164,8 @@ const projectionChangeOf = (projected, published) => {
|
|
|
1044
1164
|
};
|
|
1045
1165
|
/** The model publishes only after PM and every plugin accept its exact projection. */
|
|
1046
1166
|
const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
1047
|
-
|
|
1167
|
+
const authorization = canonicalProjectionAuthorization(commit.transaction, session);
|
|
1168
|
+
if (authorization === void 0) return refuse("The staged canonical projection is unauthorized.", INTERNAL);
|
|
1048
1169
|
const applied = Result.try({
|
|
1049
1170
|
try: () => state.applyTransaction(commit.transaction),
|
|
1050
1171
|
catch: (cause) => new CanonicalSessionError({
|
|
@@ -1059,6 +1180,12 @@ const publishCanonicalProjection = ({ state, commit, session }) => {
|
|
|
1059
1180
|
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);
|
|
1060
1181
|
const published = commit.publish();
|
|
1061
1182
|
if (published.isErr()) return published;
|
|
1183
|
+
const source = markupViewSources.get(authorization.doc);
|
|
1184
|
+
markupViewStateSources.set(staged.state, {
|
|
1185
|
+
...source,
|
|
1186
|
+
document: commit.document,
|
|
1187
|
+
story: commit.projection.story
|
|
1188
|
+
});
|
|
1062
1189
|
return Result.ok(staged);
|
|
1063
1190
|
};
|
|
1064
1191
|
/**
|
|
@@ -1220,76 +1347,6 @@ var CanonicalSession = class {
|
|
|
1220
1347
|
hasStyle(styleId) {
|
|
1221
1348
|
return (this.styles ?? this.currentDocument.package.styles)?.styles.some((style) => style.styleId === styleId) ?? false;
|
|
1222
1349
|
}
|
|
1223
|
-
/** How a replacement in the current mode removes the words it changes. */
|
|
1224
|
-
/**
|
|
1225
|
-
* A replacement cut into pieces at the comment boundaries it keeps, within
|
|
1226
|
-
* one paragraph: the last piece takes the text, the others are cleared, and
|
|
1227
|
-
* each is compiled after the ones behind it, so no earlier address moves.
|
|
1228
|
-
* The caret follows the new text, moved back by what the pieces before it
|
|
1229
|
-
* cleared.
|
|
1230
|
-
*/
|
|
1231
|
-
compileReplacementPieces({ projection, pieces, start, end, intent }) {
|
|
1232
|
-
const refused = (message) => refuse(message, { gap: CANONICAL_GAP.commentReplacementAlignment });
|
|
1233
|
-
const addressed = [];
|
|
1234
|
-
for (const [index, piece] of pieces.entries()) {
|
|
1235
|
-
const from = index === 0 ? Result.ok(start) : projection.inputAddressAt(piece.from, "afterMarkers");
|
|
1236
|
-
const to = index === pieces.length - 1 ? Result.ok(end) : projection.inputAddressAt(piece.to, "beforeMarkers");
|
|
1237
|
-
if (from.isErr() || to.isErr()) return refused("A replacement piece has no address.");
|
|
1238
|
-
if (from.value.blockId !== start.blockId || to.value.blockId !== start.blockId) return refused("A replacement cut at comment boundaries stays in one paragraph.");
|
|
1239
|
-
addressed.push({
|
|
1240
|
-
from: from.value,
|
|
1241
|
-
to: to.value,
|
|
1242
|
-
text: piece.text
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
let document = this.currentDocument;
|
|
1246
|
-
const ops = [];
|
|
1247
|
-
let caret;
|
|
1248
|
-
let cleared = 0;
|
|
1249
|
-
const { inside, ...shared } = intent;
|
|
1250
|
-
for (const [index, piece] of [...addressed.entries()].reverse()) {
|
|
1251
|
-
const last = index === addressed.length - 1;
|
|
1252
|
-
const step = {
|
|
1253
|
-
...shared,
|
|
1254
|
-
from: piece.from,
|
|
1255
|
-
to: piece.to,
|
|
1256
|
-
text: piece.text,
|
|
1257
|
-
...last && inside?.end === true ? { inside: { end: true } } : {}
|
|
1258
|
-
};
|
|
1259
|
-
const compiled = compileEditorIntent(document, {
|
|
1260
|
-
intent: step,
|
|
1261
|
-
mode: this.intentMode(document, step)
|
|
1262
|
-
});
|
|
1263
|
-
if (compiled.isErr()) return refused(compiled.error.message);
|
|
1264
|
-
const applied = compiled.value.applied === void 0 ? applyDocumentOps(document, compiled.value.ops) : Result.ok(compiled.value.applied);
|
|
1265
|
-
if (applied.isErr()) return refused(applied.error.message);
|
|
1266
|
-
document = applied.value.document;
|
|
1267
|
-
ops.push(...compiled.value.ops);
|
|
1268
|
-
if (last) caret = compiled.value.selection;
|
|
1269
|
-
else cleared += piece.to.offset - piece.from.offset;
|
|
1270
|
-
}
|
|
1271
|
-
if (caret === void 0) return refused("A replacement cut at comment boundaries lost its text.");
|
|
1272
|
-
return Result.ok({
|
|
1273
|
-
ops,
|
|
1274
|
-
selection: {
|
|
1275
|
-
...caret,
|
|
1276
|
-
offset: caret.offset - cleared
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
replacementRemoval() {
|
|
1281
|
-
switch (this.mode.type) {
|
|
1282
|
-
case "editing": return {
|
|
1283
|
-
type: "direct",
|
|
1284
|
-
comments: this.currentDocument.package.document.comments ?? []
|
|
1285
|
-
};
|
|
1286
|
-
case "suggesting": return { type: "tracked" };
|
|
1287
|
-
default: {
|
|
1288
|
-
const unhandled = this.mode;
|
|
1289
|
-
return panic(`Unknown canonical session mode ${String(unhandled)}`);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
1350
|
advanceBlockId() {
|
|
1294
1351
|
while (this.allocatedBlockIds.has(this.nextBlockId.toString(16).padStart(8, "0").toUpperCase())) this.nextBlockId += 1;
|
|
1295
1352
|
}
|
|
@@ -1663,11 +1720,8 @@ var CanonicalSession = class {
|
|
|
1663
1720
|
if (state.selection instanceof CellSelection) {
|
|
1664
1721
|
if (from !== state.selection.from || to !== state.selection.to) return refuse("A replacement range cannot partially address a cell selection.", INVALID_REQUEST);
|
|
1665
1722
|
const ranges = canonicalCellSelectionRanges(state.selection);
|
|
1666
|
-
|
|
1667
|
-
const lastRange = ranges.at(-1);
|
|
1668
|
-
if (firstRange === void 0 || lastRange === void 0) return refuse("The selected cells contain no editable text.", INVALID_REQUEST);
|
|
1723
|
+
if (ranges.length === 0) return refuse("The selected cells contain no editable text.", INVALID_REQUEST);
|
|
1669
1724
|
const intents = [];
|
|
1670
|
-
const commentChanges = [];
|
|
1671
1725
|
let first = true;
|
|
1672
1726
|
for (const range of ranges) {
|
|
1673
1727
|
const edges = projection.rangeEdgesAt(range.from, range.to);
|
|
@@ -1681,23 +1735,8 @@ var CanonicalSession = class {
|
|
|
1681
1735
|
to: cellTo.value,
|
|
1682
1736
|
text: first ? text : ""
|
|
1683
1737
|
});
|
|
1684
|
-
commentChanges.push({
|
|
1685
|
-
from: range.from,
|
|
1686
|
-
to: range.to,
|
|
1687
|
-
text: first ? text : "",
|
|
1688
|
-
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1689
|
-
});
|
|
1690
1738
|
first = false;
|
|
1691
1739
|
}
|
|
1692
|
-
if (text !== "" && !preservesReplacementCommentAlignment({
|
|
1693
|
-
doc: state.doc,
|
|
1694
|
-
source: {
|
|
1695
|
-
from: firstRange.from,
|
|
1696
|
-
to: lastRange.to
|
|
1697
|
-
},
|
|
1698
|
-
changes: commentChanges,
|
|
1699
|
-
removal: this.replacementRemoval()
|
|
1700
|
-
})) return refuse("Canonical replacement cannot preserve the aligned comment ranges.", { gap: CANONICAL_GAP.commentReplacementAlignment });
|
|
1701
1740
|
return this.prepareIntents(state, {
|
|
1702
1741
|
intents,
|
|
1703
1742
|
semantic
|
|
@@ -1715,43 +1754,6 @@ var CanonicalSession = class {
|
|
|
1715
1754
|
if (start.isErr()) return start;
|
|
1716
1755
|
const end = inputFrom === inputTo && editCaret !== void 0 ? Result.ok(editCaret) : projection.inputAddressAt(inputTo, edges.end);
|
|
1717
1756
|
if (end.isErr()) return end;
|
|
1718
|
-
let pieces = [];
|
|
1719
|
-
if (inputFrom < inputTo && text !== "") {
|
|
1720
|
-
const retirement = planWholeParagraphReplacement({
|
|
1721
|
-
document: this.currentDocument,
|
|
1722
|
-
from: start.value,
|
|
1723
|
-
to: end.value,
|
|
1724
|
-
suggesting: this.mode.type === "suggesting" ? { author: this.mode.author } : void 0
|
|
1725
|
-
});
|
|
1726
|
-
if (retirement.isErr()) return refuseOp(retirement.error);
|
|
1727
|
-
const removal = this.replacementRemoval();
|
|
1728
|
-
const whole = [{
|
|
1729
|
-
from: inputFrom,
|
|
1730
|
-
to: inputTo,
|
|
1731
|
-
text,
|
|
1732
|
-
markers: edges.start === "beforeMarkers" || edges.end === "afterMarkers" ? "selected" : "retained"
|
|
1733
|
-
}];
|
|
1734
|
-
const aligned = (changes, retiredCommentIds) => preservesReplacementCommentAlignment({
|
|
1735
|
-
doc: state.doc,
|
|
1736
|
-
retiredCommentIds,
|
|
1737
|
-
removal,
|
|
1738
|
-
source: {
|
|
1739
|
-
from: inputFrom,
|
|
1740
|
-
to: inputTo
|
|
1741
|
-
},
|
|
1742
|
-
changes
|
|
1743
|
-
});
|
|
1744
|
-
if (!aligned(whole, retirement.value?.commentIds)) {
|
|
1745
|
-
const split = removal.type === "direct" ? splitAtKeptCommentBoundaries({
|
|
1746
|
-
doc: state.doc,
|
|
1747
|
-
changes: whole,
|
|
1748
|
-
comments: removal.comments
|
|
1749
|
-
}) : void 0;
|
|
1750
|
-
const retired = /* @__PURE__ */ new Set([...retirement.value?.commentIds ?? [], ...split?.retiredCommentIds ?? []]);
|
|
1751
|
-
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 });
|
|
1752
|
-
pieces = split.changes;
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
1757
|
const preSelection = projection.selectionAt(state);
|
|
1756
1758
|
if (preSelection.isErr()) return preSelection;
|
|
1757
1759
|
const inside = controlEdgesAt(state.doc, inputFrom, inputTo);
|
|
@@ -1763,20 +1765,11 @@ var CanonicalSession = class {
|
|
|
1763
1765
|
...Object.keys(inside).length === 0 ? {} : { inside },
|
|
1764
1766
|
...state.storedMarks === null ? {} : { runPropsPatch: runFormattingPatchFromMarks(state.selection.$from.marks(), state.storedMarks) }
|
|
1765
1767
|
};
|
|
1766
|
-
const compiled =
|
|
1767
|
-
projection,
|
|
1768
|
-
pieces,
|
|
1769
|
-
start: start.value,
|
|
1770
|
-
end: end.value,
|
|
1771
|
-
intent
|
|
1772
|
-
}) : compileEditorIntent(this.currentDocument, {
|
|
1768
|
+
const compiled = compileEditorIntent(this.currentDocument, {
|
|
1773
1769
|
intent,
|
|
1774
1770
|
mode: this.intentMode(this.currentDocument, intent)
|
|
1775
1771
|
});
|
|
1776
|
-
if (compiled.isErr())
|
|
1777
|
-
if (compiled.error instanceof CanonicalSessionError) return Result.err(compiled.error);
|
|
1778
|
-
return compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(compiled.error.message) : refuseOp(compiled.error);
|
|
1779
|
-
}
|
|
1772
|
+
if (compiled.isErr()) return compiled.error.reason === DOCUMENT_OP_REFUSAL_REASONS.NO_CHANGE ? noChange(compiled.error.message) : refuseOp(compiled.error);
|
|
1780
1773
|
const { ops, selection: caret } = compiled.value;
|
|
1781
1774
|
const postSelection = {
|
|
1782
1775
|
type: "text",
|
|
@@ -2231,13 +2224,18 @@ var CanonicalSession = class {
|
|
|
2231
2224
|
* revisions as ordinary tracked changes by `author`, keeping their ids, as
|
|
2232
2225
|
* the editor does: the change then waits for review like any other. Its
|
|
2233
2226
|
* comments stay as ordinary comments.
|
|
2227
|
+
*
|
|
2228
|
+
* With `story`, only the suggestion's part in that story resolves: its
|
|
2229
|
+
* revisions there and the comments it anchors there. Its records in other
|
|
2230
|
+
* stories stay pending, and resolve later the same way or whole.
|
|
2234
2231
|
*/
|
|
2235
|
-
prepareSuggestion(state, { suggestionId, resolution, author, date }) {
|
|
2236
|
-
const revisions = documentStories(this.currentDocument).map((story) => ({
|
|
2232
|
+
prepareSuggestion(state, { suggestionId, resolution, author, date, story: only }) {
|
|
2233
|
+
const revisions = documentStories(this.currentDocument).filter((story) => only === void 0 || sameStory(story, only)).map((story) => ({
|
|
2237
2234
|
story,
|
|
2238
2235
|
infos: suggestionRevisionInfos(this.currentDocument, story, suggestionId)
|
|
2239
2236
|
})).filter(({ infos }) => infos.length > 0);
|
|
2240
|
-
const
|
|
2237
|
+
const anchored = only === void 0 ? void 0 : commentIdsAnchoredIn(this.currentDocument, only);
|
|
2238
|
+
const commentIds = suggestedCommentIds(this.currentDocument, suggestionId).filter((id) => anchored === void 0 || anchored.has(id));
|
|
2241
2239
|
if (revisions.length === 0 && commentIds.length === 0) return noChange(`No pending suggestion ${suggestionId}.`);
|
|
2242
2240
|
if (resolution === "reject") return this.prepareResolve(state, {
|
|
2243
2241
|
revisionIds: [],
|
|
@@ -2647,15 +2645,12 @@ var CanonicalSession = class {
|
|
|
2647
2645
|
document: applied.value.document,
|
|
2648
2646
|
previous: this.currentDocument
|
|
2649
2647
|
});
|
|
2650
|
-
|
|
2648
|
+
const unsupported = unsupportedEditReason({
|
|
2651
2649
|
previous: this.currentDocument,
|
|
2652
2650
|
document: applied.value.document,
|
|
2653
2651
|
stories: changed
|
|
2654
|
-
})
|
|
2655
|
-
|
|
2656
|
-
reason: "refused",
|
|
2657
|
-
message: "The operations produce unsupported canonical story content."
|
|
2658
|
-
}));
|
|
2652
|
+
});
|
|
2653
|
+
if (unsupported !== null) return refuse("The operations produce unsupported canonical story content.", editIssueGround(unsupported));
|
|
2659
2654
|
applied.value.document = preservePropertySources({
|
|
2660
2655
|
target: applied.value.document,
|
|
2661
2656
|
source: this.currentDocument,
|
|
@@ -2836,7 +2831,7 @@ const createCanonicalSession = (document, styles, { idLease, newOpId } = {}) =>
|
|
|
2836
2831
|
const owned = cloneDocumentWithParagraphPropertySources(document);
|
|
2837
2832
|
const source = normalizeCanonicalSource(owned);
|
|
2838
2833
|
const unsupported = unsupportedSeedReason(source.document);
|
|
2839
|
-
if (unsupported !== null) return refuse(unsupported,
|
|
2834
|
+
if (unsupported !== null) return refuse(unsupported.message, INVALID_REQUEST);
|
|
2840
2835
|
const identified = preservePropertySourcesWholeStories({
|
|
2841
2836
|
target: normalizeForOps(source.document),
|
|
2842
2837
|
source: owned
|
|
@@ -2851,7 +2846,8 @@ const createCanonicalSession = (document, styles, { idLease, newOpId } = {}) =>
|
|
|
2851
2846
|
const projected = project({
|
|
2852
2847
|
document: normalized,
|
|
2853
2848
|
styles,
|
|
2854
|
-
caches
|
|
2849
|
+
caches,
|
|
2850
|
+
deferInline: true
|
|
2855
2851
|
});
|
|
2856
2852
|
if (projected.isErr()) return projected;
|
|
2857
2853
|
return Result.ok(new CanonicalSession({
|
|
@@ -2891,7 +2887,7 @@ const visibleDeletionContext = (state) => {
|
|
|
2891
2887
|
const native = canonicalNativeCells(paragraph);
|
|
2892
2888
|
if (native.isErr()) {
|
|
2893
2889
|
issue = new CanonicalSessionError({
|
|
2894
|
-
ground:
|
|
2890
|
+
ground: INTERNAL,
|
|
2895
2891
|
reason: "refused",
|
|
2896
2892
|
message: native.error.message
|
|
2897
2893
|
});
|