@stll/folio-core 0.73.0 → 0.74.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 -5
- package/dist/ai-edits/pendingJoin.js +6 -1
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/snapshot.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.js +1 -1
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +6 -28
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +70 -27
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.js +14 -21
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.js +2 -2
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInput.js +1 -1
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStructure.js +1 -1
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/hiddenEditorApi.js +2 -17
- package/dist/controller/hiddenEditorManager.js +4 -8
- package/dist/document-operations.js +1 -1
- package/dist/docx/canonicalSave.d.ts +1 -1
- package/dist/docx/canonicalSave.js +1 -1
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/modelValidation.js +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +1 -1
- package/dist/docx/rezip.d.ts +1 -1
- package/dist/docx/rezip.js +2 -2
- package/dist/docx/serializer/borderSerializer.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +3 -3
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +1 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
- package/dist/docx/server/templatePlan/apply.js +69 -11
- package/dist/docx/server/templatePlan/inspect.js +88 -35
- package/dist/docx/server/templatePlan/labels.d.ts +10 -1
- package/dist/docx/server/templatePlan/labels.js +31 -2
- package/dist/docx/server/templatePlan/plan.d.ts +2 -0
- package/dist/docx/server/templatePlan/plan.js +41 -7
- package/dist/docx/server/templatePlan/planShape.js +22 -3
- package/dist/docx/server/templatePlan/types.d.ts +38 -2
- package/dist/docx/server/templatePlan/types.js +1 -0
- package/dist/docx/server/templatePlan/verify.js +11 -3
- package/dist/docx/server/templatePlan/xml.d.ts +5 -0
- package/dist/docx/server/templatePlan/xml.js +7 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/xmlParser.js +1 -1
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/paragraphFormattingSerialization.js +1 -1
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +2 -2
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -1
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/pastedCommentCopies.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/types/canonicalCapabilities.d.ts +6 -52
- package/dist/types/canonicalCapabilities.js +6 -52
- package/package.json +2 -2
- package/dist/ai-edits/apply.d.ts +0 -94
- package/dist/ai-edits/apply.js +0 -6637
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/document-operations-apply.d.ts +0 -15
- package/dist/document-operations-apply.js +0 -280
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
|
@@ -56,11 +56,8 @@ import { EditorState, Selection, TextSelection } from "prosemirror-state";
|
|
|
56
56
|
* reviewed `.docx` back out — the server-side counterpart to the React
|
|
57
57
|
* editor's live apply flow.
|
|
58
58
|
*
|
|
59
|
-
* The
|
|
60
|
-
*
|
|
61
|
-
* headless `EditorState` satisfies via `state.apply(tr)`. The React editor and
|
|
62
|
-
* this reviewer therefore run byte-for-byte the same anchor resolution,
|
|
63
|
-
* word-diff redlines, and tracked-change bookkeeping.
|
|
59
|
+
* The editor and reviewer share the canonical operation compiler and document
|
|
60
|
+
* session for anchor resolution, tracked changes, and save snapshots.
|
|
64
61
|
*
|
|
65
62
|
* Save mirrors the editor's own path: a selective patch of only the changed
|
|
66
63
|
* paragraphs in `document.xml` (leaving every untouched part byte-exact), with
|
|
@@ -8,6 +8,11 @@ import { buildCleanBlockText } from "./clean-text.js";
|
|
|
8
8
|
// src/ai-edits/pendingJoin.ts
|
|
9
9
|
/** A paragraph mark that is a pending deletion, or a relocation's source. */
|
|
10
10
|
const isDeletedPPrMark = (value) => typeof value === "object" && value !== null && "kind" in value && (value.kind === "del" || value.kind === "moveFrom");
|
|
11
|
+
/**
|
|
12
|
+
* A paragraph mark accepting removes: a deleted one, or an added one another
|
|
13
|
+
* author deleted after (`deletion`), as docx-core's `markGoes` reads it.
|
|
14
|
+
*/
|
|
15
|
+
const markGoesWhenAccepted = (value) => isDeletedPPrMark(value) || typeof value === "object" && value !== null && "deletion" in value && value.deletion !== void 0 && value.deletion !== null;
|
|
11
16
|
/** A table row's or cell's revision record. */
|
|
12
17
|
const hasRevisionMarker = (value) => typeof value === "object" && value !== null && "revisionId" in value;
|
|
13
18
|
/** Whether a table cell is pending deletion. */
|
|
@@ -28,7 +33,7 @@ const isDeletedCell = (cell) => {
|
|
|
28
33
|
* rejecting the deletion, which is the reviewer's call, not a side effect.
|
|
29
34
|
*/
|
|
30
35
|
const isPendingDeletion = (doc, blockFrom, paragraph, cleanText) => {
|
|
31
|
-
if (cleanText.length === 0 &&
|
|
36
|
+
if (cleanText.length === 0 && markGoesWhenAccepted(paragraph.attrs["pPrMark"])) return true;
|
|
32
37
|
const $block = doc.resolve(blockFrom);
|
|
33
38
|
for (let depth = $block.depth; depth > 0; depth -= 1) {
|
|
34
39
|
const ancestor = $block.node(depth);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { proseDocToBlocks } from "../prosemirror/conversion/fromProseDoc.js";
|
|
2
2
|
import { sectionPropertiesOf } from "../prosemirror/sectionCarrier.js";
|
|
3
3
|
import { anchoredCommentIdsInProseDoc } from "./comment-lifecycle.js";
|
|
4
|
-
import { Fragment } from "prosemirror-model";
|
|
5
4
|
import { validateDocumentModel } from "@stll/docx-core";
|
|
5
|
+
import { Fragment } from "prosemirror-model";
|
|
6
6
|
// src/ai-edits/result-validation.ts
|
|
7
7
|
/**
|
|
8
8
|
* The check an operation batch's result passes before it is committed.
|
|
@@ -21,8 +21,8 @@ import { splitsSurrogatePair } from "./character-boundaries.js";
|
|
|
21
21
|
import { buildCleanBlockText } from "./clean-text.js";
|
|
22
22
|
import { createNoteReferenceLabeler } from "./note-references.js";
|
|
23
23
|
import { panic } from "better-result";
|
|
24
|
-
import { Fragment } from "prosemirror-model";
|
|
25
24
|
import { TableMap } from "prosemirror-tables";
|
|
25
|
+
import { Fragment } from "prosemirror-model";
|
|
26
26
|
// src/ai-edits/snapshot.ts
|
|
27
27
|
const metadataBySnapshot = /* @__PURE__ */ new WeakMap();
|
|
28
28
|
const metadataOf = (snapshot) => metadataBySnapshot.get(snapshot) ?? panic("Metadata was requested for a snapshot that did not record it");
|
|
@@ -7,8 +7,8 @@ import { removeRowsWithoutCells } from "../prosemirror/tableGridMutation.js";
|
|
|
7
7
|
import { tableRectanglesEqual } from "./table-mutation-plan.js";
|
|
8
8
|
import { tableRectangleCutsMergedCell } from "./table-targets.js";
|
|
9
9
|
import { Result } from "better-result";
|
|
10
|
-
import { Fragment } from "prosemirror-model";
|
|
11
10
|
import { TableMap } from "prosemirror-tables";
|
|
11
|
+
import { Fragment } from "prosemirror-model";
|
|
12
12
|
// src/ai-edits/table-cell-mutations.ts
|
|
13
13
|
const mergeTableRectangle = ({ tr, tablePosition, table, rectangle }) => {
|
|
14
14
|
const map = TableMap.get(table);
|
|
@@ -13,9 +13,9 @@ import { commentAnchorIdsForNode, ownCommentAnchorIds } from "./comment-lifecycl
|
|
|
13
13
|
import { comparisonApplying, noteReferenceOf } from "./note-references.js";
|
|
14
14
|
import { changedTopLevelWindow } from "./result-validation.js";
|
|
15
15
|
import { Result } from "better-result";
|
|
16
|
-
import { Fragment } from "prosemirror-model";
|
|
17
16
|
import { mergeRunContent } from "@stll/docx-core/ops";
|
|
18
17
|
import { EditorState } from "prosemirror-state";
|
|
18
|
+
import { Fragment } from "prosemirror-model";
|
|
19
19
|
// src/ai-edits/tracked-batch-fidelity.ts
|
|
20
20
|
const copyRange = (doc, from, to) => {
|
|
21
21
|
if (from === 0 && to === doc.childCount) return doc;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The source gaps of one paragraph's logical text, by offset.
|
|
3
|
+
*
|
|
4
|
+
* Each offset of the text (`0` to `text.length`) has one or more gaps: an
|
|
5
|
+
* editor position, relative to the paragraph, that stands for it, the
|
|
6
|
+
* zero-width source ordinal that position names, and the ordinals its seam
|
|
7
|
+
* covers (`first` to `last`). Gaps at one offset keep the order they were
|
|
8
|
+
* added in.
|
|
9
|
+
*
|
|
10
|
+
* Nearly every offset has exactly one gap, so the first gap of each offset is
|
|
11
|
+
* held flat, four integers per offset in one `Int32Array`, and only the rare
|
|
12
|
+
* further gaps (zero-width markers at one offset that several editor positions
|
|
13
|
+
* reach) go to a side map. A paragraph's gaps then cost about sixteen bytes
|
|
14
|
+
* per character, not two arrays and two objects per character; a canonical
|
|
15
|
+
* session keeps them for every paragraph of the story.
|
|
16
|
+
*/
|
|
17
|
+
/** An editor position (relative to its paragraph) and the source ordinal it names. */
|
|
18
|
+
export type CanonicalInlineGap = {
|
|
19
|
+
position: number;
|
|
20
|
+
zeroWidthBefore: number;
|
|
21
|
+
};
|
|
22
|
+
/** The source ordinals one editor position stands for: from `first` to `last`. */
|
|
23
|
+
export type CanonicalSeamExtent = {
|
|
24
|
+
first: number;
|
|
25
|
+
last: number;
|
|
26
|
+
};
|
|
27
|
+
/** One gap with its seam. */
|
|
28
|
+
export type CanonicalGapEntry = CanonicalInlineGap & CanonicalSeamExtent;
|
|
29
|
+
export declare class CanonicalInlineGaps {
|
|
30
|
+
/** The first gap of each offset: position, zeroWidthBefore, first, last. */
|
|
31
|
+
private readonly flat;
|
|
32
|
+
/** The second and later gaps of an offset, in the order they were added. */
|
|
33
|
+
private readonly more;
|
|
34
|
+
/** Room for `offsets` offsets (`text.length + 1`), none holding a gap yet. */
|
|
35
|
+
constructor(offsets: number);
|
|
36
|
+
/** How many offsets the table holds: the text's length plus one. */
|
|
37
|
+
get offsets(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Record a gap at `offset`. A gap at an editor position the offset already
|
|
40
|
+
* has widens that gap's seam to the ordinal, and the gap then names the
|
|
41
|
+
* ordinal of the two that is nearer to `preferred()` (asked only then); a
|
|
42
|
+
* tie keeps the earlier one. Returns false when the offset is outside the
|
|
43
|
+
* text.
|
|
44
|
+
*/
|
|
45
|
+
add(offset: number, position: number, zeroWidthBefore: number, preferred: () => number): boolean;
|
|
46
|
+
/** Whether some offset has no gap. */
|
|
47
|
+
hasEmptyOffset(): boolean;
|
|
48
|
+
/** The gaps at `offset` with their seams, in order; undefined outside the text. */
|
|
49
|
+
at(offset: number): readonly CanonicalGapEntry[] | undefined;
|
|
50
|
+
/** The first offset with a gap at editor `position`, or -1. */
|
|
51
|
+
offsetOf(position: number): number;
|
|
52
|
+
/** Every offset's gaps, without their seams. */
|
|
53
|
+
toBoundaries(): CanonicalInlineGap[][];
|
|
54
|
+
/** Every offset's seams, parallel to {@link toBoundaries}. */
|
|
55
|
+
toSeams(): CanonicalSeamExtent[][];
|
|
56
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// src/canonical/canonicalInlineGaps.ts
|
|
2
|
+
const SLOTS = 4;
|
|
3
|
+
const POSITION = 0;
|
|
4
|
+
const ZERO_WIDTH_BEFORE = 1;
|
|
5
|
+
const FIRST = 2;
|
|
6
|
+
const LAST = 3;
|
|
7
|
+
/** No gap at this offset yet. Positions are never negative. */
|
|
8
|
+
const EMPTY = -1;
|
|
9
|
+
var CanonicalInlineGaps = class {
|
|
10
|
+
/** The first gap of each offset: position, zeroWidthBefore, first, last. */
|
|
11
|
+
flat;
|
|
12
|
+
/** The second and later gaps of an offset, in the order they were added. */
|
|
13
|
+
more = /* @__PURE__ */ new Map();
|
|
14
|
+
/** Room for `offsets` offsets (`text.length + 1`), none holding a gap yet. */
|
|
15
|
+
constructor(offsets) {
|
|
16
|
+
this.flat = new Int32Array(offsets * SLOTS).fill(EMPTY);
|
|
17
|
+
}
|
|
18
|
+
/** How many offsets the table holds: the text's length plus one. */
|
|
19
|
+
get offsets() {
|
|
20
|
+
return this.flat.length / SLOTS;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Record a gap at `offset`. A gap at an editor position the offset already
|
|
24
|
+
* has widens that gap's seam to the ordinal, and the gap then names the
|
|
25
|
+
* ordinal of the two that is nearer to `preferred()` (asked only then); a
|
|
26
|
+
* tie keeps the earlier one. Returns false when the offset is outside the
|
|
27
|
+
* text.
|
|
28
|
+
*/
|
|
29
|
+
add(offset, position, zeroWidthBefore, preferred) {
|
|
30
|
+
if (!Number.isInteger(offset) || offset < 0 || offset >= this.offsets) return false;
|
|
31
|
+
const at = offset * SLOTS;
|
|
32
|
+
const flat = this.flat;
|
|
33
|
+
if (flat[at + POSITION] === EMPTY) {
|
|
34
|
+
flat[at + POSITION] = position;
|
|
35
|
+
flat[at + ZERO_WIDTH_BEFORE] = zeroWidthBefore;
|
|
36
|
+
flat[at + FIRST] = zeroWidthBefore;
|
|
37
|
+
flat[at + LAST] = zeroWidthBefore;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
if (flat[at + POSITION] === position) {
|
|
41
|
+
flat[at + FIRST] = Math.min(flat[at + FIRST] ?? 0, zeroWidthBefore);
|
|
42
|
+
flat[at + LAST] = Math.max(flat[at + LAST] ?? 0, zeroWidthBefore);
|
|
43
|
+
const kept = flat[at + ZERO_WIDTH_BEFORE] ?? 0;
|
|
44
|
+
const target = preferred();
|
|
45
|
+
if (Math.abs(zeroWidthBefore - target) < Math.abs(kept - target)) flat[at + ZERO_WIDTH_BEFORE] = zeroWidthBefore;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
const more = this.more.get(offset);
|
|
49
|
+
const known = more?.find((entry) => entry.position === position);
|
|
50
|
+
if (known === void 0) {
|
|
51
|
+
const entry = {
|
|
52
|
+
position,
|
|
53
|
+
zeroWidthBefore,
|
|
54
|
+
first: zeroWidthBefore,
|
|
55
|
+
last: zeroWidthBefore
|
|
56
|
+
};
|
|
57
|
+
if (more === void 0) this.more.set(offset, [entry]);
|
|
58
|
+
else more.push(entry);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
known.first = Math.min(known.first, zeroWidthBefore);
|
|
62
|
+
known.last = Math.max(known.last, zeroWidthBefore);
|
|
63
|
+
const target = preferred();
|
|
64
|
+
if (Math.abs(zeroWidthBefore - target) < Math.abs(known.zeroWidthBefore - target)) known.zeroWidthBefore = zeroWidthBefore;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/** Whether some offset has no gap. */
|
|
68
|
+
hasEmptyOffset() {
|
|
69
|
+
for (let offset = 0; offset < this.offsets; offset += 1) if (this.flat[offset * SLOTS + POSITION] === EMPTY) return true;
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/** The gaps at `offset` with their seams, in order; undefined outside the text. */
|
|
73
|
+
at(offset) {
|
|
74
|
+
if (!Number.isInteger(offset) || offset < 0 || offset >= this.offsets) return void 0;
|
|
75
|
+
const at = offset * SLOTS;
|
|
76
|
+
const flat = this.flat;
|
|
77
|
+
const position = flat[at + POSITION] ?? EMPTY;
|
|
78
|
+
if (position === EMPTY) return [];
|
|
79
|
+
const head = {
|
|
80
|
+
position,
|
|
81
|
+
zeroWidthBefore: flat[at + ZERO_WIDTH_BEFORE] ?? 0,
|
|
82
|
+
first: flat[at + FIRST] ?? 0,
|
|
83
|
+
last: flat[at + LAST] ?? 0
|
|
84
|
+
};
|
|
85
|
+
const more = this.more.get(offset);
|
|
86
|
+
return more === void 0 ? [head] : [head, ...more.map((entry) => ({
|
|
87
|
+
position: entry.position,
|
|
88
|
+
zeroWidthBefore: entry.zeroWidthBefore,
|
|
89
|
+
first: entry.first,
|
|
90
|
+
last: entry.last
|
|
91
|
+
}))];
|
|
92
|
+
}
|
|
93
|
+
/** The first offset with a gap at editor `position`, or -1. */
|
|
94
|
+
offsetOf(position) {
|
|
95
|
+
const flat = this.flat;
|
|
96
|
+
const hasMore = this.more.size > 0;
|
|
97
|
+
for (let offset = 0; offset < this.offsets; offset += 1) {
|
|
98
|
+
if (flat[offset * SLOTS + POSITION] === position) return offset;
|
|
99
|
+
if (hasMore && this.more.get(offset)?.some((entry) => entry.position === position)) return offset;
|
|
100
|
+
}
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
/** Every offset's gaps, without their seams. */
|
|
104
|
+
toBoundaries() {
|
|
105
|
+
return Array.from({ length: this.offsets }, (_, offset) => (this.at(offset) ?? []).map(({ position, zeroWidthBefore }) => ({
|
|
106
|
+
position,
|
|
107
|
+
zeroWidthBefore
|
|
108
|
+
})));
|
|
109
|
+
}
|
|
110
|
+
/** Every offset's seams, parallel to {@link toBoundaries}. */
|
|
111
|
+
toSeams() {
|
|
112
|
+
return Array.from({ length: this.offsets }, (_, offset) => (this.at(offset) ?? []).map(({ first, last }) => ({
|
|
113
|
+
first,
|
|
114
|
+
last
|
|
115
|
+
})));
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export { CanonicalInlineGaps };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { CanonicalGapEntry, CanonicalInlineGap, CanonicalInlineGaps, CanonicalSeamExtent } from "./canonicalInlineGaps.js";
|
|
2
3
|
import { Result, TaggedErrorClass } from "better-result";
|
|
3
4
|
import { Node } from "prosemirror-model";
|
|
4
5
|
export declare const CANONICAL_SOURCE_INLINE_POLICIES: {
|
|
@@ -94,20 +95,10 @@ type NativeCell = {
|
|
|
94
95
|
};
|
|
95
96
|
/** Native positions and deletion geometry read the same inline-cell classification. */
|
|
96
97
|
export declare const canonicalNativeCells: (paragraph: Node) => Result<NativeCell[], InlineProjectionError>;
|
|
97
|
-
export type CanonicalInlineGap = {
|
|
98
|
-
position: number;
|
|
99
|
-
zeroWidthBefore: number;
|
|
100
|
-
};
|
|
101
|
-
/** The source ordinals one editor position stands for: from `first` to `last`. */
|
|
102
|
-
export type CanonicalSeamExtent = {
|
|
103
|
-
first: number;
|
|
104
|
-
last: number;
|
|
105
|
-
};
|
|
106
98
|
type InlineProjection = {
|
|
107
99
|
text: string;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
seams: CanonicalSeamExtent[][];
|
|
100
|
+
/** Each offset's editor positions and the seams they stand for. */
|
|
101
|
+
gaps: CanonicalInlineGaps;
|
|
111
102
|
};
|
|
112
103
|
/** Whether a story holds an id: all a paragraph's projection asks of a story id set. */
|
|
113
104
|
export type StoryIdMembership = Pick<ReadonlySet<number>, "has">;
|
|
@@ -139,4 +130,4 @@ export declare class InlineProjectionCache {
|
|
|
139
130
|
private paragraphs;
|
|
140
131
|
project(args: CanonicalInlineProjectionArgs): Result<InlineProjection, InlineProjectionError>;
|
|
141
132
|
}
|
|
142
|
-
export {};
|
|
133
|
+
export type { CanonicalGapEntry, CanonicalInlineGap, CanonicalSeamExtent };
|
|
@@ -10,9 +10,10 @@ import { readMoveRangeBoundaryAttrs } from "../prosemirror/moveRangeBoundaryAttr
|
|
|
10
10
|
import { readRangeAnchorAttrs } from "../prosemirror/rangeAnchorAttrs.js";
|
|
11
11
|
import { PRESERVED_XML_LEVELS } from "../prosemirror/schema/nodes.js";
|
|
12
12
|
import { itemBefore } from "../utils/listItems.js";
|
|
13
|
+
import { CanonicalInlineGaps } from "./canonicalInlineGaps.js";
|
|
13
14
|
import { Result, TaggedError, panic } from "better-result";
|
|
14
|
-
import { defaultInsertionGap, inlineLeafSpans, paragraphLogicalText } from "@stll/docx-core/ops";
|
|
15
15
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
16
|
+
import { defaultInsertionGap, inlineLeafSpans, paragraphLogicalText } from "@stll/docx-core/ops";
|
|
16
17
|
// src/canonical/canonicalInlineProjection.ts
|
|
17
18
|
const CANONICAL_SOURCE_INLINE_POLICIES = {
|
|
18
19
|
run: "container",
|
|
@@ -450,7 +451,7 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
450
451
|
if (!(offsets?.start !== void 0 && offsets.end !== void 0 && offsets.start === offsets.end) && markedCommentIds.has(node.id) && !explicitCommentIds.has(node.id)) erasedCommentMarkers.add(node);
|
|
451
452
|
}
|
|
452
453
|
const text = paragraphLogicalText(source);
|
|
453
|
-
const
|
|
454
|
+
const gaps = new CanonicalInlineGaps(text.length + 1);
|
|
454
455
|
let index = 0;
|
|
455
456
|
let consumed = 0;
|
|
456
457
|
const insertionOrdinals = /* @__PURE__ */ new Map();
|
|
@@ -461,30 +462,8 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
461
462
|
insertionOrdinals.set(offset, ordinal);
|
|
462
463
|
return ordinal;
|
|
463
464
|
};
|
|
464
|
-
const seams = Array.from({ length: text.length + 1 }, () => []);
|
|
465
465
|
const addGap = (position, gap) => {
|
|
466
|
-
|
|
467
|
-
const extents = seams.at(gap.offset);
|
|
468
|
-
if (!gaps || !extents) panic(`Source leaf offset ${gap.offset} exceeds paragraph ${source.paraId}.`);
|
|
469
|
-
const existing = gaps.findIndex((entry) => entry.position === position);
|
|
470
|
-
const entry = {
|
|
471
|
-
position,
|
|
472
|
-
zeroWidthBefore: gap.zeroWidthBefore
|
|
473
|
-
};
|
|
474
|
-
if (existing < 0) {
|
|
475
|
-
gaps.push(entry);
|
|
476
|
-
extents.push({
|
|
477
|
-
first: gap.zeroWidthBefore,
|
|
478
|
-
last: gap.zeroWidthBefore
|
|
479
|
-
});
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
const extent = extents[existing] ?? panic("Missing canonical seam extent");
|
|
483
|
-
extent.first = Math.min(extent.first, gap.zeroWidthBefore);
|
|
484
|
-
extent.last = Math.max(extent.last, gap.zeroWidthBefore);
|
|
485
|
-
const preferred = insertionOrdinalAt(gap.offset);
|
|
486
|
-
const kept = gaps[existing] ?? panic("Missing canonical seam gap");
|
|
487
|
-
if (Math.abs(entry.zeroWidthBefore - preferred) < Math.abs(kept.zeroWidthBefore - preferred)) gaps[existing] = entry;
|
|
466
|
+
if (!gaps.add(gap.offset, position, gap.zeroWidthBefore, () => insertionOrdinalAt(gap.offset))) panic(`Source leaf offset ${gap.offset} exceeds paragraph ${source.paraId}.`);
|
|
488
467
|
};
|
|
489
468
|
const consumeErasedLeaves = (position) => {
|
|
490
469
|
while (consumed === 0) {
|
|
@@ -586,11 +565,10 @@ const projectCanonicalInline = ({ source, paragraph, pairedBookmarkIds, commentC
|
|
|
586
565
|
if ([...comments.value.values()].some(({ starts, ends }) => starts.size > 0 || ends.size > 0)) return refuse("Canonical editing cannot attribute a comment mark transition to its source.");
|
|
587
566
|
const missing = spans.at(index);
|
|
588
567
|
if (missing || consumed !== 0) return refuse(`Canonical editing cannot display the source positions of ${missing?.node.type ?? "incomplete text"}.`);
|
|
589
|
-
if (
|
|
568
|
+
if (gaps.hasEmptyOffset()) return refuse("Canonical editing lost a source character boundary.");
|
|
590
569
|
return Result.ok({
|
|
591
570
|
text,
|
|
592
|
-
|
|
593
|
-
seams
|
|
571
|
+
gaps
|
|
594
572
|
});
|
|
595
573
|
};
|
|
596
574
|
/** A membership whose answers one paragraph's projection read, recorded to check later. */
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { ParagraphCommentMarkers } from "../docx/commentAnchorIndex.js";
|
|
12
12
|
import { document_d_exports } from "../types/document.js";
|
|
13
|
-
import {
|
|
13
|
+
import { CanonicalInlineGaps } from "./canonicalInlineGaps.js";
|
|
14
14
|
import { Node } from "prosemirror-model";
|
|
15
15
|
export type ParagraphAddress = {
|
|
16
16
|
blockId: string;
|
|
17
17
|
container: readonly document_d_exports.BlockContent[];
|
|
18
18
|
start: number;
|
|
19
19
|
text: string;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/** Each offset's editor positions and the seams they stand for. */
|
|
21
|
+
gaps: CanonicalInlineGaps;
|
|
22
22
|
node: Node;
|
|
23
23
|
source: document_d_exports.Paragraph;
|
|
24
24
|
};
|
|
@@ -29,7 +29,7 @@ export type BlockParagraph = {
|
|
|
29
29
|
container: readonly document_d_exports.BlockContent[] | undefined;
|
|
30
30
|
/** From the start of the top-level node holding it. */
|
|
31
31
|
offset: number;
|
|
32
|
-
inline: Pick<ParagraphAddress, "text" | "
|
|
32
|
+
inline: Pick<ParagraphAddress, "text" | "gaps">;
|
|
33
33
|
node: Node;
|
|
34
34
|
source: document_d_exports.Paragraph;
|
|
35
35
|
};
|
|
@@ -34,7 +34,7 @@ import { forEachAnnotationIdInDoc } from "../prosemirror/plugins/revisionIds.js"
|
|
|
34
34
|
import { preservesReplacementCommentAlignment, splitAtKeptCommentBoundaries, surveyAcceptedReplacedAnnotations } from "../prosemirror/replacedAnnotations.js";
|
|
35
35
|
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
36
36
|
import { insertedColumnWidth, omittedSlotTakingColumn } from "../prosemirror/tableGridMutation.js";
|
|
37
|
-
import { paragraphGoes } from "../prosemirror/tableRunIn.js";
|
|
37
|
+
import { paragraphGoes, tableGoes } from "../prosemirror/tableRunIn.js";
|
|
38
38
|
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
39
39
|
import { readModel } from "../types/documentModel.js";
|
|
40
40
|
import { batchCommentReferenceShift, mapIntentPositions } from "./batchCommentReferences.js";
|
|
@@ -53,12 +53,12 @@ import { controlEdgesAt } from "./controlEdges.js";
|
|
|
53
53
|
import { indentationAsRead, spacingSidesAsRead } from "./paragraphPatchAsRead.js";
|
|
54
54
|
import { replacementRunSources } from "./replacementRunSources.js";
|
|
55
55
|
import { Result, TaggedError, panic } from "better-result";
|
|
56
|
-
import {
|
|
57
|
-
import { TableMap } from "prosemirror-tables";
|
|
56
|
+
import { commentAuthorIssue, trackedChangeAuthorIssue } from "@stll/docx-core";
|
|
58
57
|
import { CONTENT_CONTROL_LOCK, MAX_REVISION_ID, lockedControlMessage, paragraphNumberingReference } from "@stll/docx-core/model";
|
|
59
58
|
import { BATCH_ANNOTATION_KINDS, DOCUMENT_OP_TYPES, ID_KIND_LIMITS, ID_LEASE_KINDS, OP_STORIES, SPLIT_HALVES, TYPED_TEXT_FORMATTING, applyDocumentOps, combineRecordedRevisions, compileEditorIntent, contentRank, createEditorIntentIdAllocator, deletionRemovesBlock, documentStories, finalBreakCarrier, findStoryBody, formatParaId, freshCommentId, groupInsertionRuns, idKey, introducedDocumentIds, isBlockBoundary, isCommentAnchorCarrierType, joinPropertyChangeLink, leasedIdCensus, locateParagraphThroughTextBoxes, noteDeletionOps, orderAddressingBeforeRemoval, orderBatchOperations, packageResourcesOpOf, paragraphHoldsContent, paragraphHoldsContentOnceAccepted, paragraphLength, paragraphsThroughTextBoxes, pendingSuggestionIdsIn, revisionSpan } from "@stll/docx-core/ops";
|
|
60
|
-
import { commentAuthorIssue, trackedChangeAuthorIssue } from "@stll/docx-core";
|
|
61
59
|
import { EditorState } from "prosemirror-state";
|
|
60
|
+
import { TableMap } from "prosemirror-tables";
|
|
61
|
+
import { Mark } from "prosemirror-model";
|
|
62
62
|
// src/canonical/canonicalPublicOperations.ts
|
|
63
63
|
/** Public batches compile against the read projection; only the canonical journal publishes. */
|
|
64
64
|
const tableLineRemovalKey = ({ axis, tablePosition, index }) => `${axis}:${tablePosition}:${index}`;
|
|
@@ -423,7 +423,25 @@ const removedTableParagraphs = (doc, type, block) => {
|
|
|
423
423
|
return blocks;
|
|
424
424
|
};
|
|
425
425
|
const orderCanonicalBatch = ({ items, doc, mode }) => {
|
|
426
|
-
const deletionOf = new Map(
|
|
426
|
+
const deletionOf = /* @__PURE__ */ new Map();
|
|
427
|
+
const directTableDeletionOf = /* @__PURE__ */ new Map();
|
|
428
|
+
for (const item of items) {
|
|
429
|
+
const { claim, block } = item.plan;
|
|
430
|
+
if (claim.type === "deleteBlock") deletionOf.set(block, item);
|
|
431
|
+
if (mode === "direct" && claim.type === "tableRemoval" && claim.axis === "table") directTableDeletionOf.set(claim.table, item);
|
|
432
|
+
}
|
|
433
|
+
const precedingTableDeletionOf = /* @__PURE__ */ new Map();
|
|
434
|
+
if (directTableDeletionOf.size > 0) for (const item of deletionOf.values()) {
|
|
435
|
+
if (!item.removesParagraphBeforeBlock) continue;
|
|
436
|
+
const at = doc.resolve(item.plan.block);
|
|
437
|
+
let position = at.pos;
|
|
438
|
+
for (let index = at.index() - 1; index >= 0; index--) {
|
|
439
|
+
position -= at.parent.child(index).nodeSize;
|
|
440
|
+
const tableDeletion = directTableDeletionOf.get(position);
|
|
441
|
+
if (tableDeletion === void 0) break;
|
|
442
|
+
precedingTableDeletionOf.set(item, tableDeletion);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
427
445
|
const deleted = new Set(deletionOf.keys());
|
|
428
446
|
const joinedAway = new Set(items.flatMap(({ plan }) => plan.claim.type === "merge" && plan.claim.joinsNow ? [plan.block] : []));
|
|
429
447
|
const deletedSplits = new Set(items.flatMap(({ operation, plan }) => {
|
|
@@ -476,6 +494,8 @@ const orderCanonicalBatch = ({ items, doc, mode }) => {
|
|
|
476
494
|
rank: before.rank + steps
|
|
477
495
|
} : planned;
|
|
478
496
|
};
|
|
497
|
+
const precedingTableDeletion = precedingTableDeletionOf.get(item);
|
|
498
|
+
if (precedingTableDeletion !== void 0) return following(precedingTableDeletion, 1);
|
|
479
499
|
const deletion = plan.claim.type === "merge" && plan.claim.joinsNow ? deletionOf.get(plan.claim.next) : void 0;
|
|
480
500
|
if (deletion !== void 0) return following(deletion, 2);
|
|
481
501
|
const run = operation.type === "deleteBlock" ? deletedRunBeforeBlock(plan.block, item.retiresRunBreak !== void 0) : void 0;
|
|
@@ -731,12 +751,12 @@ const lastPutAfterIsTable = (placed) => {
|
|
|
731
751
|
const last = placed.findLast((operation) => placementSide(operation) === "after");
|
|
732
752
|
return last !== void 0 && placesTable(last);
|
|
733
753
|
};
|
|
734
|
-
const deletedParagraphPlacement = ({ beside, tableBefore,
|
|
754
|
+
const deletedParagraphPlacement = ({ beside, tableBefore, tableAfter, after }) => {
|
|
735
755
|
const before = beside.filter((operation) => placementSide(operation) === "before");
|
|
736
756
|
const last = before.at(-1);
|
|
737
757
|
const firstAfter = beside.find((operation) => placementSide(operation) === "after");
|
|
738
758
|
const precededByTable = last === void 0 ? tableBefore : placesTable(last);
|
|
739
|
-
const followedByTable = firstAfter === void 0 ?
|
|
759
|
+
const followedByTable = firstAfter === void 0 ? tableAfter : placesTable(firstAfter);
|
|
740
760
|
if (precededByTable && followedByTable) return { type: "keepsTablesApart" };
|
|
741
761
|
if (after === null || after.type.name === "paragraph") return { type: "inPlace" };
|
|
742
762
|
const firstParagraph = before.findIndex((operation) => operation.type === "insertBeforeBlock");
|
|
@@ -3812,17 +3832,17 @@ var CanonicalPublicOperations = class {
|
|
|
3812
3832
|
})]
|
|
3813
3833
|
};
|
|
3814
3834
|
}
|
|
3815
|
-
const
|
|
3816
|
-
if (
|
|
3835
|
+
const declinedLayoutChanges = new Set(batch.atomic ? [] : batch.operations.flatMap((operation) => placesBlock(operation) && declinedAsRun.has(operation.id) || operation.type === "deleteTable" && !appliedById.has(operation.id) && besideDeletions.deleted.size > 0 ? [operation.id] : []));
|
|
3836
|
+
if (declinedLayoutChanges.size > 0 && batch.operations.some(({ type }) => type === "deleteBlock" || type === "mergeBlockWithNext")) {
|
|
3817
3837
|
const rest = this.apply({
|
|
3818
3838
|
...options,
|
|
3819
3839
|
batch: {
|
|
3820
3840
|
...batch,
|
|
3821
|
-
operations: batch.operations.filter(({ id }) => !
|
|
3841
|
+
operations: batch.operations.filter(({ id }) => !declinedLayoutChanges.has(id))
|
|
3822
3842
|
}
|
|
3823
3843
|
});
|
|
3824
3844
|
const declinedSkips = skipped.flatMap((failure) => {
|
|
3825
|
-
if (!
|
|
3845
|
+
if (!declinedLayoutChanges.has(failure.id)) return [];
|
|
3826
3846
|
const canonicalRefusal = refusals.get(failure.id);
|
|
3827
3847
|
return [canonicalRefusal ? {
|
|
3828
3848
|
...failure,
|
|
@@ -3996,7 +4016,7 @@ var CanonicalPublicOperations = class {
|
|
|
3996
4016
|
* paragraph before it, whose mark then ends the list. Tracked, the text and
|
|
3997
4017
|
* the mark are marked deleted.
|
|
3998
4018
|
*/
|
|
3999
|
-
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, deletesJoinedWords, gainsFollower, keepsTablesApart, followsInsertedTable, precedesInsertedTable,
|
|
4019
|
+
resolveBlockDeletion({ operation, paragraph, projection, projectionStory, doc, tracked, deletesJoinedWords, gainsFollower, keepsTablesApart, followsInsertedTable, precedesInsertedTable, bordersRemovedTable, previousGainsFollower, tableBeforeGainsFollower, endsOnceAccepted, deletedRun, deletedByBatch, refusal }) {
|
|
4000
4020
|
if (operation.comment !== void 0 && !tracked) return refusal("unsupportedBlock");
|
|
4001
4021
|
if (tracked && goesWholeOnAcceptance(paragraph.node)) return refusal("noopOperation");
|
|
4002
4022
|
const end = paragraph.start + paragraph.node.content.size;
|
|
@@ -4079,7 +4099,7 @@ var CanonicalPublicOperations = class {
|
|
|
4079
4099
|
}
|
|
4080
4100
|
let range;
|
|
4081
4101
|
if (!tracked) {
|
|
4082
|
-
if (after !== null && !followsInsertedTable && (before === null || (before.type.name === "paragraph" ||
|
|
4102
|
+
if (after !== null && !followsInsertedTable && (before === null || (before.type.name === "paragraph" || bordersRemovedTable) && paragraph.node.attrs["_sectionProperties"] == null)) return tracking({
|
|
4083
4103
|
intents: [{
|
|
4084
4104
|
type: "deleteParagraphs",
|
|
4085
4105
|
story: projectionStory,
|
|
@@ -4364,12 +4384,32 @@ var CanonicalPublicOperations = class {
|
|
|
4364
4384
|
const followed = blockAfter?.type.name === "paragraph";
|
|
4365
4385
|
const blockBefore = state.doc.resolve(paragraph.start - 1).nodeBefore;
|
|
4366
4386
|
const previousId = blockBefore?.type.name === "paragraph" ? blockBefore.attrs["paraId"] : void 0;
|
|
4367
|
-
const
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4387
|
+
const batchRemovesTable = (block) => besideDeletions.tables.deleted.size > 0 && tableParagraphIds(block).some((id) => besideDeletions.tables.deleted.has(id));
|
|
4388
|
+
const tableWillBeRemoved = (block) => block.type.name === "table" && (tracked && tableGoes(block, "accept") || batchRemovesTable(block));
|
|
4389
|
+
const resolveDeletedPlacement = () => {
|
|
4390
|
+
let beforePos = paragraph.start - 1;
|
|
4391
|
+
let afterPos = beforePos + paragraph.node.nodeSize;
|
|
4392
|
+
let before = blockBefore;
|
|
4393
|
+
let after = blockAfter;
|
|
4394
|
+
while (before !== null && tableWillBeRemoved(before)) {
|
|
4395
|
+
beforePos -= before.nodeSize;
|
|
4396
|
+
before = state.doc.resolve(beforePos).nodeBefore;
|
|
4397
|
+
}
|
|
4398
|
+
while (after !== null && tableWillBeRemoved(after)) {
|
|
4399
|
+
const beyond = state.doc.resolve(afterPos + after.nodeSize).nodeAfter;
|
|
4400
|
+
if (!batchRemovesTable(after) && beyond?.type.name === "paragraph" && typeof beyond.attrs["paraId"] === "string" && besideDeletions.deleted.has(beyond.attrs["paraId"])) break;
|
|
4401
|
+
afterPos += after.nodeSize;
|
|
4402
|
+
after = beyond;
|
|
4403
|
+
}
|
|
4404
|
+
const precedingId = before?.type.name === "paragraph" ? before.attrs["paraId"] : void 0;
|
|
4405
|
+
return deletedParagraphPlacement({
|
|
4406
|
+
beside: besideDeletions.placedBeside(blockId),
|
|
4407
|
+
tableBefore: before?.type.name === "table" || typeof precedingId === "string" && lastPutAfterIsTable(besideDeletions.placedBeside(precedingId)),
|
|
4408
|
+
tableAfter: after?.type.name === "table",
|
|
4409
|
+
after: blockAfter
|
|
4410
|
+
});
|
|
4411
|
+
};
|
|
4412
|
+
const besideDeleted = besideDeletions.deleted.has(blockId) ? resolveDeletedPlacement() : void 0;
|
|
4373
4413
|
const keepsTablesApart = besideDeleted?.type === "keepsTablesApart";
|
|
4374
4414
|
if (isTableStructureOperation(operation)) return resolveTableStructure({
|
|
4375
4415
|
operation,
|
|
@@ -4486,7 +4526,7 @@ var CanonicalPublicOperations = class {
|
|
|
4486
4526
|
keepsTablesApart,
|
|
4487
4527
|
followsInsertedTable,
|
|
4488
4528
|
precedesInsertedTable: besideDeletions.tables.after.has(blockId) && !besideDeletions.paragraphsAfter.has(blockId),
|
|
4489
|
-
|
|
4529
|
+
bordersRemovedTable: before !== null && tableWillBeRemoved(before) || after !== null && tableWillBeRemoved(after),
|
|
4490
4530
|
previousGainsFollower: (!followed || endsOnceAccepted) && typeof previousId === "string" && (besideDeletions.paragraphsAfter.has(previousId) || besideDeletions.deleted.has(previousId)),
|
|
4491
4531
|
tableBeforeGainsFollower,
|
|
4492
4532
|
endsOnceAccepted,
|
|
@@ -4587,13 +4627,16 @@ var CanonicalPublicOperations = class {
|
|
|
4587
4627
|
from: from.value,
|
|
4588
4628
|
to: to.value
|
|
4589
4629
|
});
|
|
4590
|
-
if (operation.type === "commentOnBlock" || operation.type === "commentOnRange")
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4630
|
+
if (operation.type === "commentOnBlock" || operation.type === "commentOnRange") {
|
|
4631
|
+
if (options.batch.mode === "suggested" && start === end) return refusal("emptyOperation", "A proposed comment needs words of the paragraph to cover.");
|
|
4632
|
+
return Result.ok({
|
|
4633
|
+
...resolvedComment,
|
|
4634
|
+
intents: [],
|
|
4635
|
+
normalizations: [],
|
|
4636
|
+
from: range.from,
|
|
4637
|
+
to: range.to
|
|
4638
|
+
});
|
|
4639
|
+
}
|
|
4597
4640
|
const restyle = restyles && operation.type === "replaceBlock" && operation.styleId !== void 0 ? statedPropertiesIntents({
|
|
4598
4641
|
story,
|
|
4599
4642
|
blockId: paragraph.blockId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { panic } from "better-result";
|
|
2
|
-
import { CellSelection } from "prosemirror-tables";
|
|
3
2
|
import { AllSelection, NodeSelection, TextSelection } from "prosemirror-state";
|
|
3
|
+
import { CellSelection } from "prosemirror-tables";
|
|
4
4
|
// src/canonical/canonicalSelection.ts
|
|
5
5
|
/** Restore the admitted selection kind after a canonical projection changes. */
|
|
6
6
|
const restoreCanonicalSelection = ({ transaction, projection, selection, unavailable }) => {
|