edytor 5.0.0 → 6.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.
Files changed (75) hide show
  1. package/README.md +2 -2
  2. package/dist/cloudflare/room/context.d.ts +62 -74
  3. package/dist/crdt/doc/history.js +2 -3
  4. package/dist/crdt/doc/ops.d.ts +81 -0
  5. package/dist/crdt/doc/ops.js +1898 -0
  6. package/dist/crdt/edytor-doc.d.ts +156 -156
  7. package/dist/crdt/edytor-doc.js +14 -42
  8. package/dist/crdt/flow.d.ts +4 -46
  9. package/dist/crdt/flow.js +2 -262
  10. package/dist/crdt/index.d.ts +62 -74
  11. package/dist/crdt/operations.d.ts +1 -1
  12. package/dist/crdt/placement/resolve.d.ts +1 -1
  13. package/dist/crdt/protocols/awareness.js +46 -81
  14. package/dist/crdt/providers/index.d.ts +10 -22
  15. package/dist/crdt/providers/indexeddb.d.ts +6 -10
  16. package/dist/crdt/providers/indexeddb.js +10 -16
  17. package/dist/crdt/providers/room.d.ts +11 -0
  18. package/dist/crdt/providers/room.js +26 -12
  19. package/dist/crdt/providers/websocket.d.ts +6 -12
  20. package/dist/crdt/providers/websocket.js +8 -15
  21. package/dist/crdt/rangeDelete.d.ts +2 -47
  22. package/dist/crdt/rangeDelete.js +1 -169
  23. package/dist/crdt/text/index/build.d.ts +125 -0
  24. package/dist/crdt/text/index/build.js +2895 -0
  25. package/dist/crdt/text/index/shared.d.ts +2 -6
  26. package/dist/crdt/text/index/shared.js +2 -5
  27. package/dist/crdt/text/model.js +2 -3
  28. package/dist/crdt/text/runs.d.ts +9 -12
  29. package/dist/crdt/text/runs.js +2 -165
  30. package/dist/events/domTextOffset.d.ts +2 -0
  31. package/dist/events/domTextOffset.js +8 -0
  32. package/dist/export/forms.d.ts +50 -50
  33. package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
  34. package/dist/plugins/richtext/richTextOperations.js +26 -32
  35. package/dist/selection/selection.utils.js +5 -8
  36. package/dist/session/handles.js +3 -7
  37. package/dist/surface/observer.svelte.js +15 -30
  38. package/dist/surface/projector.svelte.js +2 -2
  39. package/dist/utils.d.ts +5 -0
  40. package/dist/utils.js +7 -0
  41. package/package.json +1 -1
  42. package/dist/crdt/doc/capability.d.ts +0 -56
  43. package/dist/crdt/doc/capability.js +0 -207
  44. package/dist/crdt/doc/content.d.ts +0 -16
  45. package/dist/crdt/doc/content.js +0 -77
  46. package/dist/crdt/doc/delete.d.ts +0 -15
  47. package/dist/crdt/doc/delete.js +0 -84
  48. package/dist/crdt/doc/layout.d.ts +0 -9
  49. package/dist/crdt/doc/layout.js +0 -178
  50. package/dist/crdt/doc/meta.d.ts +0 -19
  51. package/dist/crdt/doc/meta.js +0 -198
  52. package/dist/crdt/doc/moves.d.ts +0 -21
  53. package/dist/crdt/doc/moves.js +0 -274
  54. package/dist/crdt/doc/split-merge.d.ts +0 -10
  55. package/dist/crdt/doc/split-merge.js +0 -179
  56. package/dist/crdt/doc/steps.d.ts +0 -65
  57. package/dist/crdt/doc/steps.js +0 -311
  58. package/dist/crdt/text/index/cache.d.ts +0 -16
  59. package/dist/crdt/text/index/cache.js +0 -175
  60. package/dist/crdt/text/index/claims.d.ts +0 -18
  61. package/dist/crdt/text/index/claims.js +0 -203
  62. package/dist/crdt/text/index/fold.d.ts +0 -21
  63. package/dist/crdt/text/index/fold.js +0 -656
  64. package/dist/crdt/text/index/layout.d.ts +0 -22
  65. package/dist/crdt/text/index/layout.js +0 -258
  66. package/dist/crdt/text/index/placement.d.ts +0 -47
  67. package/dist/crdt/text/index/placement.js +0 -738
  68. package/dist/crdt/text/index/records.d.ts +0 -13
  69. package/dist/crdt/text/index/records.js +0 -139
  70. package/dist/crdt/text/index/report.d.ts +0 -18
  71. package/dist/crdt/text/index/report.js +0 -337
  72. package/dist/crdt/text/index/state.d.ts +0 -197
  73. package/dist/crdt/text/index/state.js +0 -116
  74. package/dist/crdt/text/index/streams.d.ts +0 -25
  75. package/dist/crdt/text/index/streams.js +0 -248
package/dist/crdt/flow.js CHANGED
@@ -1,9 +1,5 @@
1
- import { ref } from './doc/plan.js';
2
- import { id as freshId } from '../utils.js';
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
- };
@@ -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;
@@ -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
- _storeUpdate: (update: Uint8Array, origin: unknown) => void;
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" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: N, args: Parameters<{
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" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
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" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
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" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
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;
@@ -566,14 +561,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
566
561
  _resync: ReturnType<typeof setInterval> | undefined;
567
562
  _connectTimer: ReturnType<typeof setTimeout> | undefined;
568
563
  _checkInterval: ReturnType<typeof setInterval>;
569
- _updateHandler: (update: Uint8Array, origin: unknown, doc?: unknown, transaction?: {
570
- local: boolean;
571
- }) => void;
572
- _awarenessUpdateHandler: (updates: {
573
- added: number[];
574
- updated: number[];
575
- removed: number[];
576
- }, origin: unknown) => void;
564
+ _unlisten: () => void;
577
565
  get url(): string;
578
566
  get unsaved(): number;
579
567
  get saved(): boolean;
@@ -583,11 +571,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
583
571
  destroy(): void;
584
572
  disconnect(): void;
585
573
  connect(): void;
586
- emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
574
+ 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
575
  _observers: Map<string, Set<any>>;
588
- on<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "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];
589
- once<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
590
- off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
576
+ 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];
577
+ 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;
578
+ 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
579
  };
592
580
  };
593
581
  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/content.js';
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/placement.ts` `settle`). Pure over
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';