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/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
19
19
 
20
- > **5.0.** Edytor `5.0.0` is on npm as `edytor`: its API follows semantic versioning, and every change is listed in the changelog. It has no production track record yet: read the [limitations](https://edytor.dev/docs/reference/limitations) before you build on it. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
20
+ > **6.0.** Edytor `6.0.0` is on npm as `edytor`: its API follows semantic versioning, and every change is listed in the changelog. It has no production track record yet: read the [limitations](https://edytor.dev/docs/reference/limitations) before you build on it. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
21
21
 
22
22
  ## Features
23
23
 
@@ -40,7 +40,7 @@ Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable
40
40
 
41
41
  ## Install
42
42
 
43
- Edytor `5.0.0` is on npm under `latest`:
43
+ Edytor `6.0.0` is on npm under `latest`:
44
44
 
45
45
  ```bash
46
46
  pnpm add edytor
@@ -157,34 +157,8 @@ export declare const crdt: {
157
157
  api: object;
158
158
  } & {
159
159
  prepare: {
160
- insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView) => import("../../index.js").Prepared;
161
- deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
162
- replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
163
160
  nestBlock: (id: import("../../index.js").BlockId, parent: import("../../index.js").BlockId) => import("../../index.js").Prepared;
164
161
  deleteBlocks: (ids: readonly import("../../index.js").BlockId[]) => import("../../index.js").Prepared;
165
- insertText: (id: import("../../index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("../../index.js").Prepared;
166
- deleteText: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
167
- formatRange: (id: import("../../index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").Prepared;
168
- clearMarks: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
169
- insertInline: (id: import("../../index.js").BlockId, offset: number, atom: import("../../crdt/doc/content.js").NewInline) => import("../../index.js").Prepared;
170
- removeInline: (id: import("../../index.js").BlockId, inlineId: string) => import("../../index.js").Prepared;
171
- setBlockType: (id: import("../../index.js").BlockId, type: string) => import("../../index.js").Prepared;
172
- patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => import("../../index.js").Prepared;
173
- setBlock: (id: import("../../index.js").BlockId, value: {
174
- type?: string;
175
- data?: Record<string, unknown>;
176
- content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
177
- children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
178
- }) => import("../../index.js").Prepared;
179
- deleteBlock: (id: import("../../index.js").BlockId, opts?: {
180
- keepChildren?: boolean;
181
- }) => import("../../index.js").Prepared;
182
- splitBlock: (id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail?: import("../../index.js").SplitTail) => import("../../index.js").Prepared;
183
- mergeBlocks: (fromId: import("../../index.js").BlockId, intoId: import("../../index.js").BlockId) => import("../../index.js").Prepared;
184
- mergeBackward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
185
- mergeForward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
186
- placeBeside: (ids: readonly import("../../index.js").BlockId[], target: import("../../index.js").BlockId, side: "left" | "right", kind?: string) => import("../../index.js").Prepared;
187
- wrapInLayout: (ids: readonly import("../../index.js").BlockId[], kind?: string, columns?: number) => import("../../index.js").Prepared;
188
162
  insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[]) => import("../../index.js").Prepared;
189
163
  moveBlocks: (ids: readonly import("../../index.js").BlockId[], dest: import("../../index.js").Destination) => import("../../index.js").Prepared;
190
164
  unNestBlocks: (ids: readonly import("../../index.js").BlockId[]) => import("../../index.js").Prepared;
@@ -194,39 +168,39 @@ export declare const crdt: {
194
168
  after?: readonly import("../../index.js").BlockSpec[];
195
169
  }) => import("../../index.js").Prepared;
196
170
  duplicateBlock: (id: import("../../index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("../../index.js").Prepared;
171
+ placeBeside: (ids: readonly import("../../index.js").BlockId[], target: import("../../index.js").BlockId, side: "left" | "right", kind?: string) => import("../../index.js").Prepared;
172
+ wrapInLayout: (ids: readonly import("../../index.js").BlockId[], kind?: string, columns?: number) => import("../../index.js").Prepared;
173
+ splitBlock: (id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail?: import("../../index.js").SplitTail) => import("../../index.js").Prepared;
174
+ mergeBlocks: (fromId: import("../../index.js").BlockId, intoId: import("../../index.js").BlockId) => import("../../index.js").Prepared;
175
+ mergeBackward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
176
+ mergeForward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
177
+ deleteBlock: (id: import("../../index.js").BlockId, opts?: {
178
+ keepChildren?: boolean;
179
+ }) => import("../../index.js").Prepared;
180
+ setBlockType: (id: import("../../index.js").BlockId, type: string) => import("../../index.js").Prepared;
181
+ patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => import("../../index.js").Prepared;
182
+ setBlock: (id: import("../../index.js").BlockId, value: {
183
+ type?: string;
184
+ data?: Record<string, unknown>;
185
+ content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
186
+ children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
187
+ }) => import("../../index.js").Prepared;
188
+ insertText: (id: import("../../index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("../../index.js").Prepared;
189
+ deleteText: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
190
+ formatRange: (id: import("../../index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").Prepared;
191
+ clearMarks: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
192
+ insertInline: (id: import("../../index.js").BlockId, offset: number, atom: import("../../crdt/doc/ops.js").NewInline) => import("../../index.js").Prepared;
193
+ removeInline: (id: import("../../index.js").BlockId, inlineId: string) => import("../../index.js").Prepared;
194
+ insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView) => import("../../index.js").Prepared;
195
+ deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
196
+ replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
197
197
  };
198
198
  apply: (p: import("../../index.js").Prepared, quiet?: boolean) => import("../../index.js").OpResult;
199
199
  compose: (...parts: import("../../index.js").Prepared[]) => import("../../index.js").Prepared;
200
200
  transact: <R>(fn: () => R, origin?: unknown) => R;
201
201
  version: number;
202
- insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView | undefined) => import("../../index.js").OpResult;
203
- deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
204
- replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
205
202
  nestBlock: (id: string, parent: string) => import("../../index.js").OpResult;
206
203
  deleteBlocks: (ids: readonly string[]) => import("../../index.js").OpResult;
207
- insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("../../index.js").OpResult;
208
- deleteText: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
209
- formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").OpResult;
210
- clearMarks: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
211
- insertInline: (id: string, offset: number, atom: import("../../crdt/doc/content.js").NewInline) => import("../../index.js").OpResult;
212
- removeInline: (id: string, inlineId: string) => import("../../index.js").OpResult;
213
- setBlockType: (id: string, type: string) => import("../../index.js").OpResult;
214
- patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => import("../../index.js").OpResult;
215
- setBlock: (id: string, value: {
216
- type?: string;
217
- data?: Record<string, unknown>;
218
- content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
219
- children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
220
- }) => import("../../index.js").OpResult;
221
- deleteBlock: (id: string, opts?: {
222
- keepChildren?: boolean;
223
- } | undefined) => import("../../index.js").OpResult;
224
- splitBlock: (id: string, offset: number, newId: string, tail?: import("../../index.js").SplitTail | undefined) => import("../../index.js").OpResult;
225
- mergeBlocks: (fromId: string, intoId: string) => import("../../index.js").OpResult;
226
- mergeBackward: (id: string) => import("../../index.js").OpResult;
227
- mergeForward: (id: string) => import("../../index.js").OpResult;
228
- placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("../../index.js").OpResult;
229
- wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("../../index.js").OpResult;
230
204
  insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").JSONBlock | import("../../index.js").BlockSpec)[]) => import("../../index.js").OpResult;
231
205
  moveBlocks: (ids: readonly string[], dest: import("../../index.js").Destination) => import("../../index.js").OpResult;
232
206
  unNestBlocks: (ids: readonly string[]) => import("../../index.js").OpResult;
@@ -236,6 +210,32 @@ export declare const crdt: {
236
210
  after?: readonly import("../../index.js").BlockSpec[];
237
211
  } | undefined) => import("../../index.js").OpResult;
238
212
  duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("../../index.js").OpResult;
213
+ placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("../../index.js").OpResult;
214
+ wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("../../index.js").OpResult;
215
+ splitBlock: (id: string, offset: number, newId: string, tail?: import("../../index.js").SplitTail | undefined) => import("../../index.js").OpResult;
216
+ mergeBlocks: (fromId: string, intoId: string) => import("../../index.js").OpResult;
217
+ mergeBackward: (id: string) => import("../../index.js").OpResult;
218
+ mergeForward: (id: string) => import("../../index.js").OpResult;
219
+ deleteBlock: (id: string, opts?: {
220
+ keepChildren?: boolean;
221
+ } | undefined) => import("../../index.js").OpResult;
222
+ setBlockType: (id: string, type: string) => import("../../index.js").OpResult;
223
+ patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => import("../../index.js").OpResult;
224
+ setBlock: (id: string, value: {
225
+ type?: string;
226
+ data?: Record<string, unknown>;
227
+ content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
228
+ children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
229
+ }) => import("../../index.js").OpResult;
230
+ insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("../../index.js").OpResult;
231
+ deleteText: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
232
+ formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").OpResult;
233
+ clearMarks: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
234
+ insertInline: (id: string, offset: number, atom: import("../../crdt/doc/ops.js").NewInline) => import("../../index.js").OpResult;
235
+ removeInline: (id: string, inlineId: string) => import("../../index.js").OpResult;
236
+ insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView | undefined) => import("../../index.js").OpResult;
237
+ deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
238
+ replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
239
239
  project: () => import("../../index.js").ProjectedDoc;
240
240
  toJSON: (options?: {
241
241
  suggestions?: boolean;
@@ -407,17 +407,12 @@ export declare const crdt: {
407
407
  loadError: unknown;
408
408
  _storeTimeout: number;
409
409
  _storeTimeoutId: ReturnType<typeof setTimeout> | null;
410
- _storeUpdate: (update: Uint8Array, origin: unknown) => void;
410
+ _unlisten: () => void;
411
411
  awareness: import("../../index.js").Awareness;
412
412
  bcconnected: boolean;
413
413
  disableBc: boolean;
414
414
  _ownsAwareness: boolean;
415
415
  _bcSubscriber: (data: ArrayBuffer | Uint8Array, origin: unknown) => void;
416
- _awarenessUpdateHandler: (updates: {
417
- added: number[];
418
- updated: number[];
419
- removed: number[];
420
- }, origin: unknown) => void;
421
416
  get synced(): boolean;
422
417
  messageHandlers: Record<number, import("../../crdt/providers/room.js").RoomMessageHandler</*elided*/ any>>;
423
418
  readMessage: (buf: Uint8Array, emitSynced: boolean) => E.Encoder;
@@ -425,7 +420,7 @@ export declare const crdt: {
425
420
  connectBc(): void;
426
421
  disconnectBc(): void;
427
422
  destroy(): Promise<void>;
428
- emit<N extends "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: N, args: Parameters<{
423
+ emit<N extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: N, args: Parameters<{
429
424
  synced: (provider: /*elided*/ any) => void;
430
425
  'protocol-mismatch': (mismatch: E.ProtocolMismatch, provider: /*elided*/ any) => void;
431
426
  'load-error': (error: unknown, provider: /*elided*/ any) => void;
@@ -434,7 +429,7 @@ export declare const crdt: {
434
429
  failed: (error: unknown, provider: /*elided*/ any) => void;
435
430
  }[N]>): void;
436
431
  _observers: Map<string, Set<any>>;
437
- on<NAME extends "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
432
+ on<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
438
433
  synced: (provider: /*elided*/ any) => void;
439
434
  'protocol-mismatch': (mismatch: E.ProtocolMismatch, provider: /*elided*/ any) => void;
440
435
  'load-error': (error: unknown, provider: /*elided*/ any) => void;
@@ -449,7 +444,7 @@ export declare const crdt: {
449
444
  'schema-mismatch': (detail: E.SchemaMismatchDetail, provider: /*elided*/ any) => void;
450
445
  failed: (error: unknown, provider: /*elided*/ any) => void;
451
446
  }[NAME];
452
- once<NAME extends "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
447
+ once<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
453
448
  synced: (provider: /*elided*/ any) => void;
454
449
  'protocol-mismatch': (mismatch: E.ProtocolMismatch, provider: /*elided*/ any) => void;
455
450
  'load-error': (error: unknown, provider: /*elided*/ any) => void;
@@ -457,7 +452,7 @@ export declare const crdt: {
457
452
  'schema-mismatch': (detail: E.SchemaMismatchDetail, provider: /*elided*/ any) => void;
458
453
  failed: (error: unknown, provider: /*elided*/ any) => void;
459
454
  }[NAME]): void;
460
- off<NAME extends "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
455
+ off<NAME extends "failed" | "message-error" | "schema-mismatch" | "protocol-mismatch" | "synced" | "load-error">(name: NAME, f: {
461
456
  synced: (provider: /*elided*/ any) => void;
462
457
  'protocol-mismatch': (mismatch: E.ProtocolMismatch, provider: /*elided*/ any) => void;
463
458
  'load-error': (error: unknown, provider: /*elided*/ any) => void;
@@ -518,14 +513,7 @@ export declare const crdt: {
518
513
  _resync: ReturnType<typeof setInterval> | undefined;
519
514
  _connectTimer: ReturnType<typeof setTimeout> | undefined;
520
515
  _checkInterval: ReturnType<typeof setInterval>;
521
- _updateHandler: (update: Uint8Array, origin: unknown, doc?: unknown, transaction?: {
522
- local: boolean;
523
- }) => void;
524
- _awarenessUpdateHandler: (updates: {
525
- added: number[];
526
- updated: number[];
527
- removed: number[];
528
- }, origin: unknown) => void;
516
+ _unlisten: () => void;
529
517
  get url(): string;
530
518
  get unsaved(): number;
531
519
  get saved(): boolean;
@@ -535,11 +523,11 @@ export declare const crdt: {
535
523
  destroy(): void;
536
524
  disconnect(): void;
537
525
  connect(): void;
538
- 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<E.WebsocketProviderEvents[N]>): void;
526
+ 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<E.WebsocketProviderEvents[N]>): void;
539
527
  _observers: Map<string, Set<any>>;
540
- 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: E.WebsocketProviderEvents[NAME]): E.WebsocketProviderEvents[NAME];
541
- 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: E.WebsocketProviderEvents[NAME]): void;
542
- 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: E.WebsocketProviderEvents[NAME]): void;
528
+ 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: E.WebsocketProviderEvents[NAME]): E.WebsocketProviderEvents[NAME];
529
+ 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: E.WebsocketProviderEvents[NAME]): void;
530
+ 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: E.WebsocketProviderEvents[NAME]): void;
543
531
  };
544
532
  };
545
533
  watchComments: (server: string | null, roomName: string, listener: (message: E.CommentMessage) => void) => (() => void);
@@ -20,6 +20,7 @@ import { changedUnder, collectable, collectNow, collects, dropSearchMarkers, eng
20
20
  import { isInitialized } from './gate.js';
21
21
  import { DocumentDestroyedError } from './funnel.js';
22
22
  import { registryOf, withdrawOnUndo } from '../placement/model.js';
23
+ import { getOr } from '../../utils.js';
23
24
  /** The undo steps a document's history keeps by default: older ones are released. */
24
25
  export const DEFAULT_HISTORY_LIMIT = 200;
25
26
  /** The origin of the transaction that releases a dropped history step's content. */
@@ -465,9 +466,7 @@ export const historyRules = (Y, doc) => {
465
466
  if (step.inserts.has(s.id.client, s.id.clock))
466
467
  return;
467
468
  const values = s.content;
468
- let attrs = lost.get(node);
469
- if (attrs === undefined)
470
- lost.set(node, (attrs = new Map()));
469
+ const attrs = getOr(lost, node, () => new Map());
471
470
  attrs.set(key, values.getContent().at(-1));
472
471
  });
473
472
  for (const [node, attrs] of lost) {
@@ -0,0 +1,81 @@
1
+ import { type JSONBlock, type JSONInlineBlock, type JSONText } from '../../utils/json.js';
2
+ import { type DataPatch } from '../data.js';
3
+ import { type BlockId, type BlockSpec, type ContentItem, type Destination, type InlineSpec, type SplitTail } from '../placement/model.js';
4
+ import type { DataTarget, Plan, PlanStep, Prepared } from './types.js';
5
+ import type { DocBase, DocReads } from './reads.js';
6
+ import type { DocPosition, RangeView } from '../rangeDelete.js';
7
+ import { type Flow, type FlowTarget, type FlowView } from '../flow.js';
8
+ /**
9
+ * A record's order among the records standing at one block, for the
10
+ * engine's sort of two records at one origin (fork patch YP22): what a split
11
+ * of a list around a block writes there — a new head list holding the items
12
+ * before it (`head`), new blocks placed after the items before it, which
13
+ * stay (`kept`), a head holding those items and the block (`with`), the
14
+ * block itself leaving (`self`), new blocks after it (`after`) — in the
15
+ * order every serial run of the gestures gives (`del.merge.container`).
16
+ */
17
+ export declare const PART: {
18
+ readonly head: 0;
19
+ readonly kept: 1;
20
+ readonly with: 2;
21
+ readonly self: 3;
22
+ readonly after: 4;
23
+ };
24
+ /** An inline atom to insert: its id is minted when it names none. */
25
+ export type NewInline = Omit<InlineSpec, 'id'> & {
26
+ id?: string;
27
+ };
28
+ /** The prepared ops of one facade over its reads. */
29
+ export declare const docOps: (c: DocBase & DocReads) => {
30
+ plan: (ids: readonly BlockId[], writes: PlanStep[], at?: DocPosition) => Plan;
31
+ canPlace: (ids: readonly BlockId[], parent?: BlockId | null, kindOf?: (id: BlockId) => string | undefined) => boolean;
32
+ fits: (parent: BlockId | null, kind: string | undefined) => boolean;
33
+ nestParent: (ids: readonly BlockId[], parent: BlockId) => BlockId;
34
+ canMerge: (fromId: BlockId, intoId: BlockId) => boolean;
35
+ defaultChild: (parent: BlockId | null) => string;
36
+ landingOf: (id: BlockId, kind: string, after?: boolean) => {
37
+ parent: string | null;
38
+ levels: string[];
39
+ };
40
+ besideAt: (target: BlockId, kind?: string) => BlockId;
41
+ /** Every op of the families, prepared. */
42
+ prepare: {
43
+ insertBlocks: (dest: Destination, specs: readonly (BlockSpec | JSONBlock)[]) => Prepared;
44
+ moveBlocks: (ids: readonly BlockId[], dest: Destination) => Prepared;
45
+ unNestBlocks: (ids: readonly BlockId[]) => Prepared;
46
+ unNestBlock: (id: BlockId) => Prepared;
47
+ liftOut: (id: BlockId, kind: string, { keep, after }?: {
48
+ keep?: boolean;
49
+ after?: readonly BlockSpec[];
50
+ }) => Prepared;
51
+ duplicateBlock: (id: BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => Prepared;
52
+ placeBeside: (ids: readonly BlockId[], target: BlockId, side: "left" | "right", kind?: string) => Prepared;
53
+ wrapInLayout: (ids: readonly BlockId[], kind?: string, columns?: number) => Prepared;
54
+ splitBlock: (id: BlockId, offset: number, newId: BlockId, tail?: SplitTail) => Prepared;
55
+ mergeBlocks: (fromId: BlockId, intoId: BlockId) => Prepared;
56
+ mergeBackward: (id: BlockId) => Prepared;
57
+ mergeForward: (id: BlockId) => Prepared;
58
+ deleteBlocks: (ids: readonly BlockId[], subtree?: boolean, filled?: BlockId | null) => Prepared;
59
+ deleteBlock: (id: BlockId, opts?: {
60
+ keepChildren?: boolean;
61
+ }) => Prepared;
62
+ setBlockType: (id: BlockId, type: string) => Prepared;
63
+ patchData: (target: DataTarget, patches: readonly DataPatch[]) => Prepared;
64
+ setBlock: (id: BlockId, value: {
65
+ type?: string;
66
+ data?: Record<string, unknown>;
67
+ content?: (ContentItem | JSONText | JSONInlineBlock)[];
68
+ children?: (BlockSpec | JSONBlock)[];
69
+ }) => Prepared;
70
+ insertText: (id: BlockId, offset: number, text: string, marks?: Record<string, unknown>) => Prepared;
71
+ deleteText: (id: BlockId, offset: number, length: number) => Prepared;
72
+ formatRange: (id: BlockId, offset: number, length: number, marks: Record<string, unknown>) => Prepared;
73
+ clearMarks: (id: BlockId, offset: number, length: number) => Prepared;
74
+ insertInline: (id: BlockId, offset: number, atom: NewInline) => Prepared;
75
+ removeInline: (id: BlockId, inlineId: string) => Prepared;
76
+ insertFlow: (target: FlowTarget, flow: Flow, view?: FlowView) => Prepared;
77
+ deleteRange: (from: DocPosition, to: DocPosition, view?: RangeView) => Prepared;
78
+ replaceRange: (from: DocPosition, to: DocPosition, view?: RangeView) => Prepared;
79
+ };
80
+ };
81
+ export type DocOps = ReturnType<typeof docOps>;