edytor 5.0.0 → 7.0.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/README.md +3 -3
- package/dist/cloudflare/DocumentRoom.d.ts +77 -2
- package/dist/cloudflare/DocumentRoom.js +37 -1
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/room/access.d.ts +6 -1
- package/dist/cloudflare/room/access.js +30 -4
- package/dist/cloudflare/room/admission.d.ts +11 -0
- package/dist/cloudflare/room/admission.js +43 -10
- package/dist/cloudflare/room/context.d.ts +73 -76
- package/dist/cloudflare/room/context.js +17 -6
- package/dist/cloudflare/room/forged.d.ts +1 -1
- package/dist/cloudflare/room/forged.js +11 -9
- package/dist/cloudflare/room/frames.d.ts +2 -0
- package/dist/cloudflare/room/frames.js +2 -0
- package/dist/cloudflare/room/presence.js +1 -4
- package/dist/cloudflare/room/reseed.d.ts +93 -0
- package/dist/cloudflare/room/reseed.js +500 -0
- package/dist/cloudflare/room/scheduler.d.ts +1 -1
- package/dist/cloudflare/room/scheduler.js +9 -1
- package/dist/cloudflare/room/shared.d.ts +10 -0
- package/dist/cloudflare/room/shared.js +10 -0
- package/dist/cloudflare/room/storage.d.ts +7 -0
- package/dist/cloudflare/room/storage.js +33 -1
- package/dist/components/Edytor.svelte +18 -3
- package/dist/components/Edytor.svelte.d.ts +10 -1
- package/dist/components/EdytorRoot.svelte +17 -0
- package/dist/components/EdytorRoot.svelte.d.ts +4 -0
- package/dist/components/Suggestion.svelte +1 -1
- package/dist/crdt/attribution/block.d.ts +3 -0
- package/dist/crdt/attribution/block.js +3 -2
- package/dist/crdt/doc/history.js +2 -3
- package/dist/crdt/doc/ops.d.ts +81 -0
- package/dist/crdt/doc/ops.js +1898 -0
- package/dist/crdt/doc/suggest.d.ts +6 -2
- package/dist/crdt/doc/suggest.js +6 -5
- package/dist/crdt/edytor-doc.d.ts +157 -157
- package/dist/crdt/edytor-doc.js +15 -43
- package/dist/crdt/engine-room.d.ts +4 -0
- package/dist/crdt/engine-room.js +6 -0
- package/dist/crdt/flow.d.ts +4 -46
- package/dist/crdt/flow.js +2 -262
- package/dist/crdt/index.d.ts +64 -75
- package/dist/crdt/operations.d.ts +1 -1
- package/dist/crdt/placement/resolve.d.ts +1 -1
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/protocols/auth.d.ts +8 -1
- package/dist/crdt/protocols/auth.js +14 -1
- package/dist/crdt/protocols/awareness.js +46 -81
- package/dist/crdt/providers/index.d.ts +11 -22
- package/dist/crdt/providers/index.js +22 -3
- package/dist/crdt/providers/indexeddb.d.ts +6 -10
- package/dist/crdt/providers/indexeddb.js +10 -16
- package/dist/crdt/providers/room.d.ts +26 -0
- package/dist/crdt/providers/room.js +41 -12
- package/dist/crdt/providers/websocket.d.ts +10 -14
- package/dist/crdt/providers/websocket.js +43 -23
- package/dist/crdt/rangeDelete.d.ts +2 -47
- package/dist/crdt/rangeDelete.js +1 -169
- package/dist/crdt/reseed.d.ts +127 -0
- package/dist/crdt/reseed.js +533 -0
- package/dist/crdt/restore.d.ts +13 -1
- package/dist/crdt/restore.js +8 -3
- package/dist/crdt/schema.d.ts +6 -0
- package/dist/crdt/schema.js +6 -0
- package/dist/crdt/structs.d.ts +8 -11
- package/dist/crdt/structs.js +25 -44
- package/dist/crdt/text/index/build.d.ts +119 -0
- package/dist/crdt/text/index/build.js +2801 -0
- package/dist/crdt/text/index/shared.d.ts +2 -6
- package/dist/crdt/text/index/shared.js +2 -5
- package/dist/crdt/text/model.js +2 -3
- package/dist/crdt/text/runs.d.ts +9 -12
- package/dist/crdt/text/runs.js +2 -165
- package/dist/crdt/vendor/yjs/UPSTREAM.md +101 -5
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +10 -10
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +1 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +24 -13
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +12 -10
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +42 -1
- package/dist/events/domTextOffset.d.ts +2 -0
- package/dist/events/domTextOffset.js +8 -0
- package/dist/export/forms.d.ts +50 -50
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
- package/dist/plugins/richtext/richTextOperations.js +26 -32
- package/dist/selection/selection.svelte.d.ts +1 -1
- package/dist/selection/selection.svelte.js +87 -106
- package/dist/selection/selection.utils.js +5 -8
- package/dist/session/commands.js +49 -51
- package/dist/session/handles.js +3 -7
- package/dist/surface/attributes.d.ts +3 -3
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/observer.svelte.d.ts +7 -7
- package/dist/surface/observer.svelte.js +225 -336
- package/dist/surface/projector.svelte.js +2 -2
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +7 -0
- package/package.json +1 -1
- package/dist/crdt/doc/capability.d.ts +0 -56
- package/dist/crdt/doc/capability.js +0 -207
- package/dist/crdt/doc/content.d.ts +0 -16
- package/dist/crdt/doc/content.js +0 -77
- package/dist/crdt/doc/delete.d.ts +0 -15
- package/dist/crdt/doc/delete.js +0 -84
- package/dist/crdt/doc/layout.d.ts +0 -9
- package/dist/crdt/doc/layout.js +0 -178
- package/dist/crdt/doc/meta.d.ts +0 -19
- package/dist/crdt/doc/meta.js +0 -198
- package/dist/crdt/doc/moves.d.ts +0 -21
- package/dist/crdt/doc/moves.js +0 -274
- package/dist/crdt/doc/split-merge.d.ts +0 -10
- package/dist/crdt/doc/split-merge.js +0 -179
- package/dist/crdt/doc/steps.d.ts +0 -65
- package/dist/crdt/doc/steps.js +0 -311
- package/dist/crdt/text/index/cache.d.ts +0 -16
- package/dist/crdt/text/index/cache.js +0 -175
- package/dist/crdt/text/index/claims.d.ts +0 -18
- package/dist/crdt/text/index/claims.js +0 -203
- package/dist/crdt/text/index/fold.d.ts +0 -21
- package/dist/crdt/text/index/fold.js +0 -656
- package/dist/crdt/text/index/layout.d.ts +0 -22
- package/dist/crdt/text/index/layout.js +0 -258
- package/dist/crdt/text/index/placement.d.ts +0 -47
- package/dist/crdt/text/index/placement.js +0 -738
- package/dist/crdt/text/index/records.d.ts +0 -13
- package/dist/crdt/text/index/records.js +0 -139
- package/dist/crdt/text/index/report.d.ts +0 -18
- package/dist/crdt/text/index/report.js +0 -337
- package/dist/crdt/text/index/state.d.ts +0 -197
- package/dist/crdt/text/index/state.js +0 -116
- package/dist/crdt/text/index/streams.d.ts +0 -25
- package/dist/crdt/text/index/streams.js +0 -248
package/dist/crdt/flow.d.ts
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `docs/editor-delete-contract.md`:
|
|
5
|
-
*
|
|
6
|
-
* - a flow is lines with fresh ids: a kinded block, or an inline run (no
|
|
7
|
-
* `type`); an empty flow changes nothing (`flow.shape`);
|
|
8
|
-
* - one line joins the text at the position; an empty block takes a kinded
|
|
9
|
-
* line's kind (`flow.inline`);
|
|
10
|
-
* - several lines split the block: the first joins the head, the last is the
|
|
11
|
-
* tail's block and takes the text after the position and the block's
|
|
12
|
-
* children, the rest go between (`flow.split`) — children the view
|
|
13
|
-
* hides (a closed toggle's body) stay with the head, as Enter keeps them;
|
|
14
|
-
* - a line that joins no text (a list, a code block, a divider: it renders
|
|
15
|
-
* none of its own, or is a void or an island) is placed as a block, never
|
|
16
|
-
* joined; the text after the position stays in a shown line of the
|
|
17
|
-
* block's kind (`flow.apart`), and the caret ends the last pasted
|
|
18
|
-
* shown line;
|
|
19
|
-
* - in a code line (a `lines` island) the lines, nested ones included, are
|
|
20
|
-
* placed as plain lines (`flow.lines`);
|
|
21
|
-
* - a `whole` flow (a block-selection copy) goes after the block, replacing
|
|
22
|
-
* it when empty (`flow.whole`); over selected blocks the lines take their
|
|
23
|
-
* slot (`flow.slot`), and at a slot they are placed with nothing replaced
|
|
24
|
-
* (`flow.place`: an accepted suggestion), as plain inserts (`insertBlocks`: their order
|
|
25
|
-
* against a peer's split beside them is not claimed); a void
|
|
26
|
-
* takes one run (`flow.void`);
|
|
27
|
-
* - a table's cell is never split: it takes the lines a flow shows, nested
|
|
28
|
-
* ones and a pasted table's cells included, as one text joined by line
|
|
29
|
-
* breaks; a cell outside a row (cells copied out of a table) is a line of
|
|
30
|
-
* text, and a row outside a table its cells (`table.paste`);
|
|
31
|
-
* - a plain line that lands directly in a container takes its item kind
|
|
32
|
-
* (the document's `fitted`: a pasted paragraph in a list is its item),
|
|
33
|
-
* and so does a line of the list's flat item kind (the view's
|
|
34
|
-
* `itemKind`: a pasted numbered item in an `ordered-list`); any
|
|
35
|
-
* other kind keeps its kind and data (a pasted image stays an image, a
|
|
36
|
-
* bulleted item in an `ordered-list` a bulleted item).
|
|
2
|
+
* The types flow placement (`insertFlow`: the `flow.*` rows, prepared in
|
|
3
|
+
* `doc/ops.ts`) reads, and where the caret ends a placed block.
|
|
37
4
|
*/
|
|
38
5
|
import type { BlockId, BlockSpec, Destination } from './placement/model.js';
|
|
39
|
-
import type { Prepared } from './edytor-doc.js';
|
|
40
6
|
import type { DocPosition, RangeView } from './rangeDelete.js';
|
|
41
|
-
import type { OpsContext } from './doc/steps.js';
|
|
42
|
-
import type { MoveOps } from './doc/moves.js';
|
|
43
|
-
import type { DeleteOps } from './doc/delete.js';
|
|
44
|
-
import type { MetaOps } from './doc/meta.js';
|
|
45
7
|
/** One line of a flow: a kinded block, or an inline run when it has no `type`. */
|
|
46
8
|
export type FlowLine = Omit<BlockSpec, 'type'> & {
|
|
47
9
|
type?: string;
|
|
@@ -72,8 +34,8 @@ export type FlowTarget = DocPosition | {
|
|
|
72
34
|
} | {
|
|
73
35
|
slot: Destination;
|
|
74
36
|
};
|
|
75
|
-
/**
|
|
76
|
-
export
|
|
37
|
+
/** The units of a line's content (an atom counts 1). */
|
|
38
|
+
export declare const lengthOf: (l: FlowLine) => number;
|
|
77
39
|
/**
|
|
78
40
|
* Where the caret ends a placed block: its own content's end when it shows a
|
|
79
41
|
* line (renders its content, no void; a toggle's header, never its body),
|
|
@@ -85,7 +47,3 @@ export declare const placedEnd: (roleOf: (kind: string) => {
|
|
|
85
47
|
childless: boolean;
|
|
86
48
|
rendersContent: boolean;
|
|
87
49
|
}) => (s: BlockSpec) => DocPosition | undefined;
|
|
88
|
-
/** `insertFlow`, prepared. */
|
|
89
|
-
export declare const flowOps: (c: FlowContext) => {
|
|
90
|
-
insertFlow: (target: FlowTarget, flow: Flow, view?: FlowView) => Prepared;
|
|
91
|
-
};
|
package/dist/crdt/flow.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { sanitizeSpec } from '../utils/json.js';
|
|
4
|
-
import { collides } from './placement/model.js';
|
|
5
|
-
import { TYPE } from './schema.js';
|
|
6
|
-
const lengthOf = (l) => (l.content ?? []).reduce((n, i) => n + (i.kind === 'text' ? i.text.length : 1), 0);
|
|
1
|
+
/** The units of a line's content (an atom counts 1). */
|
|
2
|
+
export const lengthOf = (l) => (l.content ?? []).reduce((n, i) => n + (i.kind === 'text' ? i.text.length : 1), 0);
|
|
7
3
|
/**
|
|
8
4
|
* Where the caret ends a placed block: its own content's end when it shows a
|
|
9
5
|
* line (renders its content, no void; a toggle's header, never its body),
|
|
@@ -25,259 +21,3 @@ export const placedEnd = (roleOf) => {
|
|
|
25
21
|
};
|
|
26
22
|
return endOf;
|
|
27
23
|
};
|
|
28
|
-
/** `insertFlow`, prepared. */
|
|
29
|
-
export const flowOps = (c) => {
|
|
30
|
-
const roleOf = c.roles.of;
|
|
31
|
-
/** What a kind is in a table: the table, its row or its cell. */
|
|
32
|
-
const tableKind = (kind) => roleOf(kind).table !== undefined
|
|
33
|
-
? 'table'
|
|
34
|
-
: c.isRowKind(kind)
|
|
35
|
-
? 'row'
|
|
36
|
-
: c.isCellKind(kind)
|
|
37
|
-
? 'cell'
|
|
38
|
-
: undefined;
|
|
39
|
-
return {
|
|
40
|
-
insertFlow: (target, flow, view = {}) => {
|
|
41
|
-
// Ingress: a run carries a placeholder kind through the spec sanitizer.
|
|
42
|
-
let lines = flow.lines
|
|
43
|
-
.map((l) => sanitizeSpec({ ...l, type: l.type ?? '' }))
|
|
44
|
-
.map((s) => ({ ...s, type: s.type || undefined }));
|
|
45
|
-
if (lines.length === 0)
|
|
46
|
-
return c.plan([], []);
|
|
47
|
-
// A cell outside a row is its text, a row outside a table its cells (`table.paste`).
|
|
48
|
-
const unbare = (l, holder) => {
|
|
49
|
-
const kind = l.type ? tableKind(l.type) : undefined;
|
|
50
|
-
const kids = (next) => (l.children ?? []).flatMap((kid) => unbare(kid, next));
|
|
51
|
-
if (kind === 'cell' && holder !== 'row')
|
|
52
|
-
return [{ id: l.id, content: l.content }, ...kids(null)];
|
|
53
|
-
if (kind === 'row' && holder !== 'table')
|
|
54
|
-
return kids(null);
|
|
55
|
-
if (!l.children)
|
|
56
|
-
return [l];
|
|
57
|
-
return [{ ...l, children: kids(kind === 'cell' ? null : (kind ?? null)) }];
|
|
58
|
-
};
|
|
59
|
-
lines = lines.flatMap((l) => unbare(l, null));
|
|
60
|
-
/** A line's kind under `parent`: the list's item for its flat item kind, then `fitted`. */
|
|
61
|
-
const fit = (parent, kind) => c.fitted(parent, parent !== null && kind !== undefined && kind === view.itemKind?.(parent)
|
|
62
|
-
? c.defaultChild(parent)
|
|
63
|
-
: kind);
|
|
64
|
-
const specs = (parent, of = lines) => of.map((l) => ({ ...l, type: fit(parent, l.type) ?? c.defaultChild(parent) }));
|
|
65
|
-
const last = () => lines.at(-1);
|
|
66
|
-
/** `l` and its nested lines as runs, each line that shows its own content one run. */
|
|
67
|
-
const plain = (l) => [
|
|
68
|
-
...(!l.type || roleOf(l.type).rendersContent ? [{ id: l.id, content: l.content }] : []),
|
|
69
|
-
...(l.children ?? []).flatMap(plain)
|
|
70
|
-
];
|
|
71
|
-
const endOf = placedEnd(roleOf);
|
|
72
|
-
/**
|
|
73
|
-
* A layout line, here or nested, as its items' lines in reading order, and
|
|
74
|
-
* any other child it holds (`flow.layout`): no layout lands in an item.
|
|
75
|
-
*/
|
|
76
|
-
const unwrap = (l) => {
|
|
77
|
-
const item = l.type ? roleOf(l.type).layout : undefined;
|
|
78
|
-
if (item === undefined)
|
|
79
|
-
return [l.children ? { ...l, children: l.children.flatMap(unwrap) } : l];
|
|
80
|
-
return (l.children ?? []).flatMap((kid) => kid.type === item ? (kid.children ?? []).flatMap(unwrap) : unwrap(kid));
|
|
81
|
-
};
|
|
82
|
-
const intoItem = (parent) => {
|
|
83
|
-
if (parent !== null && c.insideItem(parent))
|
|
84
|
-
lines = lines.flatMap(unwrap);
|
|
85
|
-
};
|
|
86
|
-
/** Whole blocks at a slot, after `pre`; the caret ends the last one's shown content. */
|
|
87
|
-
const atSlot = (dest, pre) => {
|
|
88
|
-
const placed = specs(dest.parent);
|
|
89
|
-
const p = c.insertBlocks(dest, placed);
|
|
90
|
-
const at = endOf(placed.at(-1)) ?? { block: last().id, offset: lengthOf(last()) };
|
|
91
|
-
// The lines are placed while the replaced blocks still show (each step reads the
|
|
92
|
-
// display as it stands), then those go.
|
|
93
|
-
return 'writes' in p ? { ...c.plan(p.ids, [...p.writes, ...pre]), at } : p;
|
|
94
|
-
};
|
|
95
|
-
if ('replace' in target || 'slot' in target) {
|
|
96
|
-
let slot;
|
|
97
|
-
let pre = [];
|
|
98
|
-
if ('slot' in target)
|
|
99
|
-
slot = target.slot;
|
|
100
|
-
else {
|
|
101
|
-
// The lines fill the first block's slot: its parent is never emptied
|
|
102
|
-
// by the delete, so a column keeps its layout (`layout.flow-slot`).
|
|
103
|
-
const at = c.view().order.at;
|
|
104
|
-
const first = target.replace
|
|
105
|
-
.filter((id) => at.has(id))
|
|
106
|
-
.sort((a, b) => at.get(a) - at.get(b))[0];
|
|
107
|
-
const del = c.deleteBlocks(target.replace, false, first === undefined ? undefined : c.positionOf(first)?.parent);
|
|
108
|
-
if (!('writes' in del))
|
|
109
|
-
return del;
|
|
110
|
-
if (first === undefined)
|
|
111
|
-
return c.REFUSED;
|
|
112
|
-
slot = c.positionOf(first);
|
|
113
|
-
pre = [...del.writes];
|
|
114
|
-
}
|
|
115
|
-
intoItem(slot.parent);
|
|
116
|
-
if (lines.length === 0)
|
|
117
|
-
return c.plan([], []);
|
|
118
|
-
// In a code block (selected lines, a slot), the lines are plain lines too (`flow.lines`).
|
|
119
|
-
if (slot.parent !== null && c.isLines(slot.parent)) {
|
|
120
|
-
const shown = lines.flatMap(plain);
|
|
121
|
-
lines = shown.length ? shown : [{ id: lines[0].id, content: [] }];
|
|
122
|
-
}
|
|
123
|
-
return atSlot(slot, pre);
|
|
124
|
-
}
|
|
125
|
-
const B = ref(target.block);
|
|
126
|
-
if (!c.contentTarget(B) || !c.rendersContent(B))
|
|
127
|
-
return c.REFUSED;
|
|
128
|
-
const len = c.displayLength(B);
|
|
129
|
-
const o = Math.max(0, Math.min(target.offset, len));
|
|
130
|
-
const { parent, index } = c.positionOf(B);
|
|
131
|
-
intoItem(B);
|
|
132
|
-
const empty = len === 0 && c.childrenIds(B).length === 0;
|
|
133
|
-
// A line of a lines island (a code line) takes plain lines: every line the flow
|
|
134
|
-
// shows, nested ones included, in order; no block lands in the island (`flow.lines`).
|
|
135
|
-
const inLines = parent !== null && c.isLines(parent);
|
|
136
|
-
if (inLines)
|
|
137
|
-
lines = lines.flatMap(plain);
|
|
138
|
-
// A table's cell is never split: the lines it shows join its text (`table.paste`).
|
|
139
|
-
const cell = c.isTableCell(B);
|
|
140
|
-
if (cell)
|
|
141
|
-
lines = lines.flatMap(plain);
|
|
142
|
-
// A line that joins no text under `under` (`flow.apart`): its kind renders
|
|
143
|
-
// none of its own (a list, a code block), or is a void or an island.
|
|
144
|
-
const apart = (l, under) => {
|
|
145
|
-
const kind = l.type && fit(under, l.type);
|
|
146
|
-
const role = kind ? roleOf(kind) : undefined;
|
|
147
|
-
return !!role && (!role.rendersContent || role.childless || role.island);
|
|
148
|
-
};
|
|
149
|
-
// At the end of a container's header whose body shows, what follows the caret
|
|
150
|
-
// leads its children and the body stays, as Enter opens a first child
|
|
151
|
-
// (`flow.header`), unless the first line stands apart and replaces an empty
|
|
152
|
-
// one (`flow.apart`); elsewhere it follows `B` among its siblings.
|
|
153
|
-
const header = view.header?.(B);
|
|
154
|
-
// A closed header shows no children: a line it takes brings none into its hidden
|
|
155
|
-
// body; they follow it, shown (`flow.header`).
|
|
156
|
-
const shut = header === 'closed';
|
|
157
|
-
const inside = o === len && !inLines && !flow.whole && header === true && !(empty && apart(lines[0], B));
|
|
158
|
-
const home = inside ? B : parent;
|
|
159
|
-
if (lines.length === 0)
|
|
160
|
-
return { ...c.plan([B], []), at: { block: B, offset: o } };
|
|
161
|
-
if (flow.whole && !inLines && !cell)
|
|
162
|
-
return atSlot({ parent, index: index + 1 }, empty ? [c.remove(B, [])] : []);
|
|
163
|
-
// A void is never split: its caption takes the lines as one run; nor is a cell.
|
|
164
|
-
const br = { kind: 'text', text: '\n' };
|
|
165
|
-
if (c.isVoid(B) || cell) {
|
|
166
|
-
const content = lines.flatMap((l, i) => [...(i ? [br] : []), ...(l.content ?? [])]);
|
|
167
|
-
lines = [{ id: lines[0].id, content }];
|
|
168
|
-
}
|
|
169
|
-
// So a first line it joins leaves its nested lines as lines of the flow after it.
|
|
170
|
-
if (shut && lines[0].children?.length && !apart(lines[0], home))
|
|
171
|
-
lines = [{ ...lines[0], children: undefined }, ...lines[0].children, ...lines.slice(1)];
|
|
172
|
-
const first = lines[0];
|
|
173
|
-
const [joinsHead, joinsTail] = [
|
|
174
|
-
!apart(first, home),
|
|
175
|
-
lines.length > 1 && !apart(last(), home)
|
|
176
|
-
];
|
|
177
|
-
const all = specs(home);
|
|
178
|
-
const placed = all.slice(joinsHead ? 1 : 0, joinsTail ? -1 : undefined);
|
|
179
|
-
const ids = placed.map((s) => s.id);
|
|
180
|
-
if (collides(c.doc, [
|
|
181
|
-
...(joinsHead ? (first.children ?? []) : []),
|
|
182
|
-
...all.slice(joinsHead ? 1 : 0)
|
|
183
|
-
]))
|
|
184
|
-
return c.REFUSED;
|
|
185
|
-
const writes = [];
|
|
186
|
-
/** A joined line's children lead the block it joins; `moved` follow them. */
|
|
187
|
-
const kids = (to, l, moved = []) => {
|
|
188
|
-
const k = l?.children?.length ?? 0;
|
|
189
|
-
if (k)
|
|
190
|
-
writes.push({ op: 'insertBlocks', parent: to, index: 0, specs: l.children });
|
|
191
|
-
if (moved.length)
|
|
192
|
-
writes.push({ op: 'moveBlocks', ids: moved, parent: to, index: k });
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* `l` joins `B` at `at`: its content, its kind when `B` shows no text (a header
|
|
196
|
-
* keeps its own, as Enter does), its children first.
|
|
197
|
-
*/
|
|
198
|
-
const join = (l, at) => {
|
|
199
|
-
const end = c.writeContent(writes, B, at, l.content);
|
|
200
|
-
const kind = l.type && fit(parent, l.type);
|
|
201
|
-
if (len === 0 && !header && kind && kind === l.type)
|
|
202
|
-
writes.push(...c.attr(B, TYPE, kind), ...(c.dataSteps(B, c.replaceData(l.data ?? {})) ?? []));
|
|
203
|
-
if (!shut)
|
|
204
|
-
kids(B, l);
|
|
205
|
-
return end;
|
|
206
|
-
};
|
|
207
|
-
/** The placed lines at `at` under `home` (`split`: the tail of the split they come with). */
|
|
208
|
-
const place = (at, split) => {
|
|
209
|
-
if (placed.length)
|
|
210
|
-
writes.push({
|
|
211
|
-
op: 'insertBlocks',
|
|
212
|
-
parent: home,
|
|
213
|
-
index: at,
|
|
214
|
-
specs: placed,
|
|
215
|
-
...(split !== undefined && { split })
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
// Under a header, the first line's children, the placed lines and the rest, in order.
|
|
219
|
-
const k = joinsHead ? (first.children?.length ?? 0) : 0;
|
|
220
|
-
const slot = inside ? k : index + 1;
|
|
221
|
-
// Where the placed lines end the caret: after their last shown line (`flow.apart`).
|
|
222
|
-
const end = placed.length ? endOf(placed.at(-1)) : undefined;
|
|
223
|
-
// Nothing before the position and the first line stands apart: the lines go before `B`,
|
|
224
|
-
// which keeps its text and takes a joining last line, or goes when empty and not needed.
|
|
225
|
-
if (!joinsHead && o === 0 && !inside) {
|
|
226
|
-
place(index);
|
|
227
|
-
if (joinsTail) {
|
|
228
|
-
const at = join(last(), 0);
|
|
229
|
-
// A closed header's taken line's nested lines follow it, the caret ending them.
|
|
230
|
-
const after = shut ? specs(parent, last().children ?? []) : [];
|
|
231
|
-
if (after.length) {
|
|
232
|
-
const slot = index + placed.length + 1;
|
|
233
|
-
writes.push({ op: 'insertBlocks', parent, index: slot, specs: after });
|
|
234
|
-
}
|
|
235
|
-
const caret = after.length ? endOf(after.at(-1)) : undefined;
|
|
236
|
-
const touched = [...ids, B, ...after.map((s) => s.id)];
|
|
237
|
-
return { ...c.plan(touched, writes), at: caret ?? { block: B, offset: at } };
|
|
238
|
-
}
|
|
239
|
-
if (empty && end)
|
|
240
|
-
return { ...c.plan(ids, [...writes, c.remove(B, [])]), at: end };
|
|
241
|
-
return { ...c.plan([...ids, B], writes), at: end ?? { block: B, offset: 0 } };
|
|
242
|
-
}
|
|
243
|
-
const head = joinsHead ? join(first, o) : o;
|
|
244
|
-
if (lines.length === 1 && joinsHead)
|
|
245
|
-
return { ...c.plan([B], writes), at: { block: B, offset: head } };
|
|
246
|
-
const moved = inside ? [] : c.childrenIds(B).filter((id) => !view.hidden?.(id));
|
|
247
|
-
// Nothing after the position to keep, and the caret has a line: no split.
|
|
248
|
-
if (!joinsTail && o === len && moved.length === 0 && end) {
|
|
249
|
-
place(slot);
|
|
250
|
-
return { ...c.plan([B, ...ids], writes), at: end };
|
|
251
|
-
}
|
|
252
|
-
// The rest of `B` stays in a shown line: the last line's block when it joins, else
|
|
253
|
-
// a line of `B`'s kind, as Enter makes; one made only for the caret (after a
|
|
254
|
-
// divider at the end) or under a header is a fresh line of its parent's default kind.
|
|
255
|
-
const T = joinsTail ? last().id : freshId('b');
|
|
256
|
-
const lastType = joinsTail && last().type && fit(home, last().type);
|
|
257
|
-
const bare = !joinsTail && o === len && moved.length === 0;
|
|
258
|
-
const tail = lastType
|
|
259
|
-
? { type: lastType, data: last().data }
|
|
260
|
-
: bare || inside
|
|
261
|
-
? { type: c.defaultChild(home), data: {} }
|
|
262
|
-
: { type: c.kindToCopy(B), data: c.blockDataOf(B) };
|
|
263
|
-
// After `B` (under a header: after the first line's children); the placed lines go before it.
|
|
264
|
-
const length = len - o;
|
|
265
|
-
writes.push({
|
|
266
|
-
op: 'splitBlock',
|
|
267
|
-
id: B,
|
|
268
|
-
offset: head,
|
|
269
|
-
length,
|
|
270
|
-
newId: T,
|
|
271
|
-
tail,
|
|
272
|
-
parent: home,
|
|
273
|
-
index: slot
|
|
274
|
-
});
|
|
275
|
-
kids(T, joinsTail ? last() : undefined, moved);
|
|
276
|
-
place(slot, T);
|
|
277
|
-
const at = joinsTail
|
|
278
|
-
? { block: T, offset: c.writeContent(writes, T, 0, last().content) }
|
|
279
|
-
: (end ?? { block: T, offset: 0 });
|
|
280
|
-
return { ...c.plan([B, ...ids, T], writes), at };
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
};
|
package/dist/crdt/index.d.ts
CHANGED
|
@@ -205,34 +205,8 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
205
205
|
api: object;
|
|
206
206
|
} & {
|
|
207
207
|
prepare: {
|
|
208
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
|
|
209
|
-
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
210
|
-
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
211
208
|
nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
212
209
|
deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
|
|
213
|
-
insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
214
|
-
deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
215
|
-
formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
216
|
-
clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
217
|
-
insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
|
|
218
|
-
removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
|
|
219
|
-
setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
|
|
220
|
-
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
|
|
221
|
-
setBlock: (id: import("./index.js").BlockId, value: {
|
|
222
|
-
type?: string;
|
|
223
|
-
data?: Record<string, unknown>;
|
|
224
|
-
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
225
|
-
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
226
|
-
}) => import("./edytor-doc.js").Prepared;
|
|
227
|
-
deleteBlock: (id: import("./index.js").BlockId, opts?: {
|
|
228
|
-
keepChildren?: boolean;
|
|
229
|
-
}) => import("./edytor-doc.js").Prepared;
|
|
230
|
-
splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
|
|
231
|
-
mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
232
|
-
mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
233
|
-
mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
234
|
-
placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
|
|
235
|
-
wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
|
|
236
210
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
|
|
237
211
|
moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
|
|
238
212
|
unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
|
|
@@ -242,39 +216,39 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
242
216
|
after?: readonly import("./index.js").BlockSpec[];
|
|
243
217
|
}) => import("./edytor-doc.js").Prepared;
|
|
244
218
|
duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
|
|
219
|
+
placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
|
|
220
|
+
wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
|
|
221
|
+
splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
|
|
222
|
+
mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
223
|
+
mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
224
|
+
mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
|
|
225
|
+
deleteBlock: (id: import("./index.js").BlockId, opts?: {
|
|
226
|
+
keepChildren?: boolean;
|
|
227
|
+
}) => import("./edytor-doc.js").Prepared;
|
|
228
|
+
setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
|
|
229
|
+
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
|
|
230
|
+
setBlock: (id: import("./index.js").BlockId, value: {
|
|
231
|
+
type?: string;
|
|
232
|
+
data?: Record<string, unknown>;
|
|
233
|
+
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
234
|
+
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
235
|
+
}) => import("./edytor-doc.js").Prepared;
|
|
236
|
+
insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
237
|
+
deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
238
|
+
formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
|
|
239
|
+
clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
|
|
240
|
+
insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/ops.js").NewInline) => import("./edytor-doc.js").Prepared;
|
|
241
|
+
removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
|
|
242
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
|
|
243
|
+
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
244
|
+
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
|
|
245
245
|
};
|
|
246
246
|
apply: (p: import("./edytor-doc.js").Prepared, quiet?: boolean) => import("./edytor-doc.js").OpResult;
|
|
247
247
|
compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
|
|
248
248
|
transact: <R>(fn: () => R, origin?: unknown) => R;
|
|
249
249
|
version: number;
|
|
250
|
-
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
|
|
251
|
-
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
252
|
-
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
253
250
|
nestBlock: (id: string, parent: string) => import("./edytor-doc.js").OpResult;
|
|
254
251
|
deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
|
|
255
|
-
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
|
|
256
|
-
deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
257
|
-
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
|
|
258
|
-
clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
259
|
-
insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").OpResult;
|
|
260
|
-
removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
|
|
261
|
-
setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
|
|
262
|
-
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
|
|
263
|
-
setBlock: (id: string, value: {
|
|
264
|
-
type?: string;
|
|
265
|
-
data?: Record<string, unknown>;
|
|
266
|
-
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
267
|
-
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
268
|
-
}) => import("./edytor-doc.js").OpResult;
|
|
269
|
-
deleteBlock: (id: string, opts?: {
|
|
270
|
-
keepChildren?: boolean;
|
|
271
|
-
} | undefined) => import("./edytor-doc.js").OpResult;
|
|
272
|
-
splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
|
|
273
|
-
mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
|
|
274
|
-
mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
|
|
275
|
-
mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
|
|
276
|
-
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
|
|
277
|
-
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
|
|
278
252
|
insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").JSONBlock | import("./index.js").BlockSpec)[]) => import("./edytor-doc.js").OpResult;
|
|
279
253
|
moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
|
|
280
254
|
unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
|
|
@@ -284,6 +258,32 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
284
258
|
after?: readonly import("./index.js").BlockSpec[];
|
|
285
259
|
} | undefined) => import("./edytor-doc.js").OpResult;
|
|
286
260
|
duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("./edytor-doc.js").OpResult;
|
|
261
|
+
placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
|
|
262
|
+
wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
|
|
263
|
+
splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
|
|
264
|
+
mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
|
|
265
|
+
mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
|
|
266
|
+
mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
|
|
267
|
+
deleteBlock: (id: string, opts?: {
|
|
268
|
+
keepChildren?: boolean;
|
|
269
|
+
} | undefined) => import("./edytor-doc.js").OpResult;
|
|
270
|
+
setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
|
|
271
|
+
patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
|
|
272
|
+
setBlock: (id: string, value: {
|
|
273
|
+
type?: string;
|
|
274
|
+
data?: Record<string, unknown>;
|
|
275
|
+
content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
|
|
276
|
+
children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
|
|
277
|
+
}) => import("./edytor-doc.js").OpResult;
|
|
278
|
+
insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
|
|
279
|
+
deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
280
|
+
formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
|
|
281
|
+
clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
|
|
282
|
+
insertInline: (id: string, offset: number, atom: import("./doc/ops.js").NewInline) => import("./edytor-doc.js").OpResult;
|
|
283
|
+
removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
|
|
284
|
+
insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
|
|
285
|
+
deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
286
|
+
replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
|
|
287
287
|
project: () => import("./index.js").ProjectedDoc;
|
|
288
288
|
toJSON: (options?: {
|
|
289
289
|
suggestions?: boolean;
|
|
@@ -360,7 +360,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
360
360
|
text: import("./text/model.js").TextEngine;
|
|
361
361
|
}, horizon: import("./purge.js").Horizon | null) => import("./purge.js").PurgeReport;
|
|
362
362
|
horizonOf: (doc: import("./engine-api.js").EngineDoc) => import("./purge.js").Horizon | null;
|
|
363
|
-
restoreTo: <Plan>(doc: import("./engine-api.js").EngineDoc, facade: import("./restore.js").RestoreFacade<Plan>, json: import("./index.js").JSONDoc) => import("./restore.js").RestoreReport;
|
|
363
|
+
restoreTo: <Plan>(doc: import("./engine-api.js").EngineDoc, facade: import("./restore.js").RestoreFacade<Plan>, json: import("./index.js").JSONDoc, { rewrite, suggestions }?: import("./restore.js").RestoreOptions<Plan>) => import("./restore.js").RestoreReport;
|
|
364
364
|
model: {
|
|
365
365
|
REGISTRY_KEY: string;
|
|
366
366
|
registryOf: (doc: import("./engine-api.js").EngineDoc) => import("./engine-api.js").EngineNode;
|
|
@@ -455,17 +455,12 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
455
455
|
loadError: unknown;
|
|
456
456
|
_storeTimeout: number;
|
|
457
457
|
_storeTimeoutId: ReturnType<typeof setTimeout> | null;
|
|
458
|
-
|
|
458
|
+
_unlisten: () => void;
|
|
459
459
|
awareness: _Awareness;
|
|
460
460
|
bcconnected: boolean;
|
|
461
461
|
disableBc: boolean;
|
|
462
462
|
_ownsAwareness: boolean;
|
|
463
463
|
_bcSubscriber: (data: ArrayBuffer | Uint8Array, origin: unknown) => void;
|
|
464
|
-
_awarenessUpdateHandler: (updates: {
|
|
465
|
-
added: number[];
|
|
466
|
-
updated: number[];
|
|
467
|
-
removed: number[];
|
|
468
|
-
}, origin: unknown) => void;
|
|
469
464
|
get synced(): boolean;
|
|
470
465
|
messageHandlers: Record<number, import("./providers/room.js").RoomMessageHandler</*elided*/ any>>;
|
|
471
466
|
readMessage: (buf: Uint8Array, emitSynced: boolean) => import("lib0-v14/encoding").Encoder;
|
|
@@ -473,7 +468,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
473
468
|
connectBc(): void;
|
|
474
469
|
disconnectBc(): void;
|
|
475
470
|
destroy(): Promise<void>;
|
|
476
|
-
emit<N extends "failed" | "
|
|
471
|
+
emit<N extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: N, args: Parameters<{
|
|
477
472
|
synced: (provider: /*elided*/ any) => void;
|
|
478
473
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
479
474
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -482,7 +477,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
482
477
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
483
478
|
}[N]>): void;
|
|
484
479
|
_observers: Map<string, Set<any>>;
|
|
485
|
-
on<NAME extends "failed" | "
|
|
480
|
+
on<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
486
481
|
synced: (provider: /*elided*/ any) => void;
|
|
487
482
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
488
483
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -497,7 +492,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
497
492
|
'schema-mismatch': (detail: import("./protocol.js").SchemaMismatchDetail, provider: /*elided*/ any) => void;
|
|
498
493
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
499
494
|
}[NAME];
|
|
500
|
-
once<NAME extends "failed" | "
|
|
495
|
+
once<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
501
496
|
synced: (provider: /*elided*/ any) => void;
|
|
502
497
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
503
498
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -505,7 +500,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
505
500
|
'schema-mismatch': (detail: import("./protocol.js").SchemaMismatchDetail, provider: /*elided*/ any) => void;
|
|
506
501
|
failed: (error: unknown, provider: /*elided*/ any) => void;
|
|
507
502
|
}[NAME]): void;
|
|
508
|
-
off<NAME extends "failed" | "
|
|
503
|
+
off<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
|
|
509
504
|
synced: (provider: /*elided*/ any) => void;
|
|
510
505
|
'protocol-mismatch': (mismatch: import("./protocol.js").ProtocolMismatch, provider: /*elided*/ any) => void;
|
|
511
506
|
'load-error': (error: unknown, provider: /*elided*/ any) => void;
|
|
@@ -556,6 +551,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
556
551
|
deny(): void;
|
|
557
552
|
allow(): void;
|
|
558
553
|
};
|
|
554
|
+
_rebasing: boolean;
|
|
559
555
|
messageHandlers: Record<number, import("./providers/room.js").RoomMessageHandler</*elided*/ any>>;
|
|
560
556
|
hasSynced: boolean;
|
|
561
557
|
whenSynced: Promise<unknown>;
|
|
@@ -566,14 +562,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
566
562
|
_resync: ReturnType<typeof setInterval> | undefined;
|
|
567
563
|
_connectTimer: ReturnType<typeof setTimeout> | undefined;
|
|
568
564
|
_checkInterval: ReturnType<typeof setInterval>;
|
|
569
|
-
|
|
570
|
-
local: boolean;
|
|
571
|
-
}) => void;
|
|
572
|
-
_awarenessUpdateHandler: (updates: {
|
|
573
|
-
added: number[];
|
|
574
|
-
updated: number[];
|
|
575
|
-
removed: number[];
|
|
576
|
-
}, origin: unknown) => void;
|
|
565
|
+
_unlisten: () => void;
|
|
577
566
|
get url(): string;
|
|
578
567
|
get unsaved(): number;
|
|
579
568
|
get saved(): boolean;
|
|
@@ -583,11 +572,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
|
|
|
583
572
|
destroy(): void;
|
|
584
573
|
disconnect(): void;
|
|
585
574
|
connect(): void;
|
|
586
|
-
emit<N extends "refused" | "status" | "failed" | "
|
|
575
|
+
emit<N extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
|
|
587
576
|
_observers: Map<string, Set<any>>;
|
|
588
|
-
on<NAME extends "refused" | "status" | "failed" | "
|
|
589
|
-
once<NAME extends "refused" | "status" | "failed" | "
|
|
590
|
-
off<NAME extends "refused" | "status" | "failed" | "
|
|
577
|
+
on<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): import("./protocol.js").WebsocketProviderEvents[NAME];
|
|
578
|
+
once<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
|
|
579
|
+
off<NAME extends "refused" | "status" | "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
|
|
591
580
|
};
|
|
592
581
|
};
|
|
593
582
|
watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import type { BlockAttribution } from './attribution/block.js';
|
|
16
16
|
import type { AnchorAffinity, DataTarget, DocAnchor, DocChange, JsonObj, OpResult, OrderPolicy, Prepared } from './doc/types.js';
|
|
17
17
|
import type { DataPatch } from './data.js';
|
|
18
|
-
import type { NewInline } from './doc/
|
|
18
|
+
import type { NewInline } from './doc/ops.js';
|
|
19
19
|
import type { Flow, FlowTarget, FlowView } from './flow.js';
|
|
20
20
|
import type { BlockId, BlockSpec, ContentItem, Destination, ProjectedDoc, SplitTail } from './placement/model.js';
|
|
21
21
|
import type { DocPosition, RangeView } from './rangeDelete.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* slot belongs to, each block's display edges (the sequences that can show
|
|
4
4
|
* its slot: its live move records', strongest first, then its parent's), the
|
|
5
5
|
* places of every sequence, and the cycle walk. Which edge a block takes is
|
|
6
|
-
* the index's acceptance (`text/index/
|
|
6
|
+
* the index's acceptance (`text/index/build.ts` `settle`). Pure over
|
|
7
7
|
* replicated state.
|
|
8
8
|
*/
|
|
9
9
|
import type { EngineDoc, EngineNode } from '../engine-api.js';
|
package/dist/crdt/protocol.d.ts
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
export { bindCrdt, type Crdt, type EngineApi, type EngineDoc, type EngineNode, type EngineTransaction, type EngineItemRef, type YNode, type YItem, type YDoc, type YUndoManager, type YTransaction } from './index.js';
|
|
28
28
|
export { SCHEMA_VERSION, META_KEY } from './edytor-doc.js';
|
|
29
29
|
export { GENERATION, generationWord, frame, PROTOCOL_VERSION, GENERATION_RECORD, GenerationMismatchError, readProtocolVersion, type GenerationRecord } from './protocols/envelope.js';
|
|
30
|
-
export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, type ChunkReader, CLOSE } from './providers/room.js';
|
|
30
|
+
export { messageSync, messageAwareness, messageAuth, messageQueryAwareness, messageSaved, messageChunk, messageComments, messageRebase, MAX_FRAME_BYTES, chunkFrame, createChunkReader, ChunkError, type ChunkReader, CLOSE } from './providers/room.js';
|
|
31
31
|
export { messageYjsSyncStep1, messageYjsSyncStep2, messageYjsUpdate, type SyncProtocol } from './protocols/sync.js';
|
|
32
|
-
export { messageAccess, messagePermissionDenied, messageReadOnly, writeAccess, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
32
|
+
export { messageAccess, messageEpoch, messagePermissionDenied, messageReadOnly, writeAccess, writeEpoch, writePermissionDenied, writeReadOnly } from './protocols/auth.js';
|
|
33
33
|
export { commentsSubscribe, commentsSnapshot, commentsChange, writeCommentsSubscribe, writeCommentsSnapshot, writeCommentsChange, readCommentsMessage, type CommentChange, type CommentMessage, type CommentSnapshot, type CommentThread, type ThreadComment } from './protocols/comments.js';
|
|
34
34
|
export { applyAwarenessUpdate, encodeAwarenessUpdate, readAwarenessEntries, writeAwarenessEntries, type AwarenessEntry } from './protocols/awareness.js';
|
|
35
35
|
export { createDecoder, readVarUint, readVarUint8Array, type Decoder } from 'lib0-v14/decoding';
|