edytor 4.0.0 → 5.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 (147) hide show
  1. package/README.md +2 -2
  2. package/dist/block/block.svelte.js +6 -21
  3. package/dist/block/inlineBlock.svelte.js +4 -6
  4. package/dist/clipboard/moveText.js +6 -8
  5. package/dist/cloudflare/DocumentRoom.d.ts +10 -3
  6. package/dist/cloudflare/index.d.ts +1 -1
  7. package/dist/cloudflare/room/access.d.ts +8 -3
  8. package/dist/cloudflare/room/access.js +44 -20
  9. package/dist/cloudflare/room/admission.js +28 -5
  10. package/dist/cloudflare/room/comments.js +28 -1
  11. package/dist/cloudflare/room/context.d.ts +115 -106
  12. package/dist/cloudflare/room/context.js +10 -3
  13. package/dist/cloudflare/room/forged.d.ts +14 -0
  14. package/dist/cloudflare/room/forged.js +30 -2
  15. package/dist/cloudflare/room/frames.d.ts +4 -0
  16. package/dist/cloudflare/room/frames.js +5 -1
  17. package/dist/cloudflare/room/purge.js +2 -1
  18. package/dist/cloudflare/room/replicas.d.ts +4 -2
  19. package/dist/cloudflare/room/replicas.js +8 -3
  20. package/dist/cloudflare/room/suggest.d.ts +7 -0
  21. package/dist/cloudflare/room/suggest.js +143 -0
  22. package/dist/cloudflare/routeDocumentSocket.d.ts +10 -1
  23. package/dist/cloudflare/routeDocumentSocket.js +5 -3
  24. package/dist/components/Content.svelte +9 -1
  25. package/dist/crdt/anchors.js +3 -2
  26. package/dist/crdt/attribution/attribution.d.ts +3 -0
  27. package/dist/crdt/attribution/attribution.js +3 -3
  28. package/dist/crdt/doc/capability.js +9 -13
  29. package/dist/crdt/doc/funnel.d.ts +1 -1
  30. package/dist/crdt/doc/funnel.js +5 -2
  31. package/dist/crdt/doc/gate.d.ts +1 -1
  32. package/dist/crdt/doc/history.d.ts +6 -0
  33. package/dist/crdt/doc/history.js +77 -56
  34. package/dist/crdt/doc/layout.js +5 -5
  35. package/dist/crdt/doc/meta.js +6 -7
  36. package/dist/crdt/doc/reads.d.ts +2 -2
  37. package/dist/crdt/doc/reads.js +18 -28
  38. package/dist/crdt/doc/steps.js +4 -4
  39. package/dist/crdt/doc/suggest.d.ts +167 -0
  40. package/dist/crdt/doc/suggest.js +579 -0
  41. package/dist/crdt/document.d.ts +10 -1
  42. package/dist/crdt/document.js +19 -11
  43. package/dist/crdt/edytor-doc.d.ts +355 -333
  44. package/dist/crdt/edytor-doc.js +125 -82
  45. package/dist/crdt/engine-api.d.ts +8 -2
  46. package/dist/crdt/engine.d.ts +2 -1
  47. package/dist/crdt/engine.js +3 -1
  48. package/dist/crdt/flow.d.ts +1 -1
  49. package/dist/crdt/flow.js +4 -10
  50. package/dist/crdt/index.d.ts +111 -105
  51. package/dist/crdt/index.js +3 -0
  52. package/dist/crdt/operations.d.ts +12 -3
  53. package/dist/crdt/parts.d.ts +43 -0
  54. package/dist/crdt/parts.js +44 -0
  55. package/dist/crdt/placement/display.d.ts +1 -1
  56. package/dist/crdt/placement/display.js +3 -3
  57. package/dist/crdt/placement/keys.d.ts +5 -0
  58. package/dist/crdt/placement/keys.js +5 -0
  59. package/dist/crdt/placement/resolve.js +2 -1
  60. package/dist/crdt/protocol.d.ts +1 -1
  61. package/dist/crdt/protocol.js +1 -1
  62. package/dist/crdt/protocols/auth.d.ts +11 -1
  63. package/dist/crdt/protocols/auth.js +17 -1
  64. package/dist/crdt/protocols/comments.d.ts +16 -1
  65. package/dist/crdt/protocols/comments.js +9 -1
  66. package/dist/crdt/providers/index.d.ts +6 -4
  67. package/dist/crdt/providers/index.js +3 -1
  68. package/dist/crdt/providers/websocket.d.ts +6 -4
  69. package/dist/crdt/providers/websocket.js +9 -4
  70. package/dist/crdt/purge.d.ts +7 -1
  71. package/dist/crdt/purge.js +32 -2
  72. package/dist/crdt/restore.d.ts +2 -1
  73. package/dist/crdt/restore.js +9 -0
  74. package/dist/crdt/schema.d.ts +9 -1
  75. package/dist/crdt/schema.js +13 -3
  76. package/dist/crdt/structs.d.ts +2 -0
  77. package/dist/crdt/structs.js +2 -0
  78. package/dist/crdt/text/index/claims.js +1 -23
  79. package/dist/crdt/text/index/layout.d.ts +2 -4
  80. package/dist/crdt/text/index/layout.js +9 -22
  81. package/dist/crdt/text/index/placement.js +21 -24
  82. package/dist/crdt/text/index/shared.js +17 -14
  83. package/dist/crdt/text/model.d.ts +10 -0
  84. package/dist/crdt/text/model.js +8 -1
  85. package/dist/crdt/text/runs.d.ts +34 -30
  86. package/dist/crdt/vendor/yjs/UPSTREAM.md +83 -0
  87. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  88. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +6 -3
  89. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +13 -2
  90. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  91. package/dist/crdt/vendor/yjs/src/structs/Item.js +44 -5
  92. package/dist/crdt/vendor/yjs/src/ynode.js +29 -7
  93. package/dist/edytor.svelte.d.ts +1 -1
  94. package/dist/edytor.svelte.js +100 -75
  95. package/dist/events/beforeInputCommands.d.ts +2 -2
  96. package/dist/events/nativeInteractiveControl.d.ts +11 -1
  97. package/dist/events/nativeInteractiveControl.js +41 -1
  98. package/dist/events/onBeforeInput.js +3 -3
  99. package/dist/events/onFocus.js +9 -11
  100. package/dist/export/forms.d.ts +25 -25
  101. package/dist/index.d.ts +4 -2
  102. package/dist/index.js +1 -1
  103. package/dist/labels.d.ts +8 -0
  104. package/dist/labels.js +6 -1
  105. package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
  106. package/dist/plugins/comments/CommentsController.svelte.js +14 -4
  107. package/dist/plugins/find/search.js +2 -2
  108. package/dist/plugins/index.d.ts +1 -0
  109. package/dist/plugins/index.js +1 -0
  110. package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
  111. package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
  112. package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
  113. package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
  114. package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
  115. package/dist/plugins/suggestions/shared.svelte.js +421 -0
  116. package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
  117. package/dist/selection/domSelection.d.ts +2 -0
  118. package/dist/selection/domSelection.js +6 -2
  119. package/dist/selection/pointer.svelte.js +75 -48
  120. package/dist/selection/replaceSelection.js +2 -6
  121. package/dist/selection/selection.svelte.d.ts +3 -3
  122. package/dist/selection/selection.svelte.js +39 -32
  123. package/dist/selection/selection.utils.d.ts +14 -0
  124. package/dist/selection/selection.utils.js +28 -3
  125. package/dist/session/commands.js +21 -11
  126. package/dist/session/composition.svelte.d.ts +5 -3
  127. package/dist/session/composition.svelte.js +21 -17
  128. package/dist/session/handles.d.ts +4 -17
  129. package/dist/session/handles.js +11 -37
  130. package/dist/session/navigation.js +6 -9
  131. package/dist/session/selection.d.ts +11 -5
  132. package/dist/session/selection.js +14 -48
  133. package/dist/session/suggestions.svelte.d.ts +38 -9
  134. package/dist/session/suggestions.svelte.js +37 -18
  135. package/dist/session/virtual.d.ts +1 -1
  136. package/dist/surface/attributes.d.ts +5 -0
  137. package/dist/surface/attributes.js +2 -2
  138. package/dist/surface/cells.d.ts +2 -26
  139. package/dist/surface/cells.js +2 -33
  140. package/dist/surface/observer.svelte.d.ts +6 -1
  141. package/dist/surface/observer.svelte.js +128 -81
  142. package/dist/surface/pin.svelte.d.ts +9 -9
  143. package/dist/surface/pin.svelte.js +15 -22
  144. package/dist/surface/projector.svelte.js +8 -14
  145. package/dist/text/text.svelte.js +14 -19
  146. package/dist/themes/notion.css +29 -0
  147. package/package.json +3 -1
@@ -28,7 +28,7 @@ export declare const crdt: {
28
28
  Awareness: typeof import("../../index.js").Awareness;
29
29
  doc: {
30
30
  SCHEMA: {
31
- readonly version: 10;
31
+ readonly version: 11;
32
32
  readonly name: "edytor-doc";
33
33
  readonly roots: {
34
34
  readonly registry: "blocks";
@@ -39,7 +39,7 @@ export declare const crdt: {
39
39
  readonly schema: "schema";
40
40
  };
41
41
  };
42
- SCHEMA_VERSION: 10;
42
+ SCHEMA_VERSION: 11;
43
43
  SCHEMA_NAME: "edytor-doc";
44
44
  META_KEY: "meta";
45
45
  init: (doc: E.EngineDoc, opts?: {
@@ -55,48 +55,36 @@ export declare const crdt: {
55
55
  assertSchema: (doc: E.EngineDoc, docName?: string) => void;
56
56
  SchemaMismatchError: typeof E.SchemaMismatchError;
57
57
  create: (doc: E.EngineDoc, config?: import("../../crdt/edytor-doc.js").EdytorDocConfig) => {
58
- prepare: {
59
- insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView) => import("../../index.js").Prepared;
60
- deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
61
- replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView) => import("../../index.js").Prepared;
62
- insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[]) => import("../../index.js").Prepared;
63
- moveBlocks: (ids: readonly import("../../index.js").BlockId[], dest: import("../../index.js").Destination) => import("../../index.js").Prepared;
64
- nestBlock: (id: import("../../index.js").BlockId, parent: import("../../index.js").BlockId) => import("../../index.js").Prepared;
65
- unNestBlock: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
66
- unNestBlocks: (ids: readonly import("../../index.js").BlockId[]) => import("../../index.js").Prepared;
67
- liftOut: (id: import("../../index.js").BlockId, kind: string, { keep, after }?: {
68
- keep?: boolean;
69
- after?: readonly import("../../index.js").BlockSpec[];
70
- }) => import("../../index.js").Prepared;
71
- placeBeside: (ids: readonly import("../../index.js").BlockId[], target: import("../../index.js").BlockId, side: "left" | "right", kind?: string) => import("../../index.js").Prepared;
72
- wrapInLayout: (ids: readonly import("../../index.js").BlockId[], kind?: string, columns?: number) => import("../../index.js").Prepared;
73
- splitBlock: (id: import("../../index.js").BlockId, offset: number, newId: import("../../index.js").BlockId, tail?: import("../../index.js").SplitTail) => import("../../index.js").Prepared;
74
- mergeBlocks: (fromId: import("../../index.js").BlockId, intoId: import("../../index.js").BlockId) => import("../../index.js").Prepared;
75
- mergeBackward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
76
- mergeForward: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
77
- deleteBlock: (id: import("../../index.js").BlockId, opts?: {
78
- keepChildren?: boolean;
79
- }) => import("../../index.js").Prepared;
80
- setBlock: (id: import("../../index.js").BlockId, value: {
81
- type?: string;
82
- data?: Record<string, unknown>;
83
- content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
84
- children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
85
- }) => import("../../index.js").Prepared;
86
- setBlockType: (id: import("../../index.js").BlockId, type: string) => import("../../index.js").Prepared;
87
- patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => import("../../index.js").Prepared;
88
- duplicateBlock: (id: import("../../index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("../../index.js").Prepared;
89
- insertText: (id: import("../../index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("../../index.js").Prepared;
90
- deleteText: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
91
- formatRange: (id: import("../../index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").Prepared;
92
- clearMarks: (id: import("../../index.js").BlockId, offset: number, length: number) => import("../../index.js").Prepared;
93
- insertInline: (id: import("../../index.js").BlockId, offset: number, atom: import("../../crdt/doc/content.js").NewInline) => import("../../index.js").Prepared;
94
- removeInline: (id: import("../../index.js").BlockId, inlineId: string) => import("../../index.js").Prepared;
95
- deleteBlocks: (ids: readonly import("../../index.js").BlockId[]) => import("../../index.js").Prepared;
96
- };
97
- apply: (p: import("../../index.js").Prepared) => import("../../index.js").OpResult;
98
- compose: (...parts: import("../../index.js").Prepared[]) => import("../../index.js").Prepared;
99
- transact: <R>(fn: () => R, origin?: unknown) => R;
58
+ init: (opts?: Parameters<(doc: E.EngineDoc, opts?: {
59
+ content?: import("../../index.js").BlockSpec[];
60
+ defaultType?: string;
61
+ }) => void>[1]) => void;
62
+ seed: (value: import("../../index.js").JSONBlock[], data?: import("../../crdt/doc/types.js").JsonObj) => void;
63
+ isInitialized: () => boolean;
64
+ schemaVersion: () => number | undefined;
65
+ checkSchema: () => E.SchemaProblem | null;
66
+ assertSchema: () => void;
67
+ dispose: () => void;
68
+ createUndoManager: (options?: import("../../crdt/doc/history.js").HistoryOptions) => import("../../crdt/doc/history.js").UndoManager;
69
+ part: import("../../crdt/doc/suggest.js").SuggestContext;
70
+ childSlots: (parent: import("../../index.js").BlockId | null) => import("../../crdt/placement/model.js").ChildSlot[];
71
+ slotOf: (id: string) => {
72
+ parent: import("../../index.js").BlockId | null;
73
+ rank: string;
74
+ } | null;
75
+ crdtId: (id: string) => string | null;
76
+ resolveBlock: (id: string) => E.EngineNode | null;
77
+ followUndo: (anchor: import("../../index.js").DocAnchor) => import("../../index.js").DocAnchor;
78
+ rolesChanged: (place?: boolean) => void;
79
+ defaultChild: (id: string | null) => string;
80
+ contentJSON: (id: string) => ({
81
+ text: string;
82
+ marks?: Record<string, unknown>;
83
+ } | {
84
+ id?: string;
85
+ type: string;
86
+ data?: unknown;
87
+ })[];
100
88
  model: {
101
89
  REGISTRY_KEY: string;
102
90
  registryOf: (doc: E.EngineDoc) => E.EngineNode;
@@ -166,64 +154,94 @@ export declare const crdt: {
166
154
  };
167
155
  };
168
156
  runsView: import("../../crdt/text/runs.js").RunView;
157
+ api: object;
158
+ } & {
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
+ nestBlock: (id: import("../../index.js").BlockId, parent: import("../../index.js").BlockId) => import("../../index.js").Prepared;
164
+ 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
+ insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[]) => import("../../index.js").Prepared;
189
+ moveBlocks: (ids: readonly import("../../index.js").BlockId[], dest: import("../../index.js").Destination) => import("../../index.js").Prepared;
190
+ unNestBlocks: (ids: readonly import("../../index.js").BlockId[]) => import("../../index.js").Prepared;
191
+ unNestBlock: (id: import("../../index.js").BlockId) => import("../../index.js").Prepared;
192
+ liftOut: (id: import("../../index.js").BlockId, kind: string, { keep, after }?: {
193
+ keep?: boolean;
194
+ after?: readonly import("../../index.js").BlockSpec[];
195
+ }) => import("../../index.js").Prepared;
196
+ duplicateBlock: (id: import("../../index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("../../index.js").Prepared;
197
+ };
198
+ apply: (p: import("../../index.js").Prepared, quiet?: boolean) => import("../../index.js").OpResult;
199
+ compose: (...parts: import("../../index.js").Prepared[]) => import("../../index.js").Prepared;
200
+ transact: <R>(fn: () => R, origin?: unknown) => R;
169
201
  version: number;
170
202
  insertFlow: (target: import("../../index.js").FlowTarget, flow: import("../../index.js").Flow, view?: import("../../index.js").FlowView | undefined) => import("../../index.js").OpResult;
171
203
  deleteRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
172
204
  replaceRange: (from: import("../../index.js").DocPosition, to: import("../../index.js").DocPosition, view?: import("../../index.js").RangeView | undefined) => import("../../index.js").OpResult;
173
- insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[]) => import("../../index.js").OpResult;
174
- moveBlocks: (ids: readonly string[], dest: import("../../index.js").Destination) => import("../../index.js").OpResult;
175
205
  nestBlock: (id: string, parent: string) => import("../../index.js").OpResult;
176
- unNestBlock: (id: string) => import("../../index.js").OpResult;
177
- unNestBlocks: (ids: readonly string[]) => import("../../index.js").OpResult;
178
- liftOut: (id: string, kind: string, args_2?: {
179
- keep?: boolean;
180
- after?: readonly import("../../index.js").BlockSpec[];
181
- } | undefined) => import("../../index.js").OpResult;
182
- placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("../../index.js").OpResult;
183
- wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("../../index.js").OpResult;
184
- splitBlock: (id: string, offset: number, newId: string, tail?: import("../../index.js").SplitTail | undefined) => import("../../index.js").OpResult;
185
- mergeBlocks: (fromId: string, intoId: string) => import("../../index.js").OpResult;
186
- mergeBackward: (id: string) => import("../../index.js").OpResult;
187
- mergeForward: (id: string) => import("../../index.js").OpResult;
188
- deleteBlock: (id: string, opts?: {
189
- keepChildren?: boolean;
190
- } | undefined) => import("../../index.js").OpResult;
206
+ 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;
191
215
  setBlock: (id: string, value: {
192
216
  type?: string;
193
217
  data?: Record<string, unknown>;
194
218
  content?: (import("../../index.js").ContentItem | import("../../index.js").JSONText | import("../../index.js").JSONInlineBlock)[];
195
219
  children?: (import("../../index.js").BlockSpec | import("../../index.js").JSONBlock)[];
196
220
  }) => import("../../index.js").OpResult;
197
- setBlockType: (id: string, type: string) => import("../../index.js").OpResult;
198
- patchData: (target: import("../../index.js").DataTarget, patches: readonly import("../../index.js").DataPatch[]) => 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
+ insertBlocks: (dest: import("../../index.js").Destination, specs: readonly (import("../../index.js").JSONBlock | import("../../index.js").BlockSpec)[]) => import("../../index.js").OpResult;
231
+ moveBlocks: (ids: readonly string[], dest: import("../../index.js").Destination) => import("../../index.js").OpResult;
232
+ unNestBlocks: (ids: readonly string[]) => import("../../index.js").OpResult;
233
+ unNestBlock: (id: string) => import("../../index.js").OpResult;
234
+ liftOut: (id: string, kind: string, args_2?: {
235
+ keep?: boolean;
236
+ after?: readonly import("../../index.js").BlockSpec[];
237
+ } | undefined) => import("../../index.js").OpResult;
199
238
  duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("../../index.js").OpResult;
200
- insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("../../index.js").OpResult;
201
- deleteText: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
202
- formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("../../index.js").OpResult;
203
- clearMarks: (id: string, offset: number, length: number) => import("../../index.js").OpResult;
204
- insertInline: (id: string, offset: number, atom: import("../../crdt/doc/content.js").NewInline) => import("../../index.js").OpResult;
205
- removeInline: (id: string, inlineId: string) => import("../../index.js").OpResult;
206
- deleteBlocks: (ids: readonly string[]) => import("../../index.js").OpResult;
207
- init: (opts?: Parameters<(doc: E.EngineDoc, opts?: {
208
- content?: import("../../index.js").BlockSpec[];
209
- defaultType?: string;
210
- }) => void>[1]) => void;
211
- seed: (value: import("../../index.js").JSONBlock[], data?: import("../../crdt/doc/types.js").JsonObj) => void;
212
- isInitialized: () => boolean;
213
- schemaVersion: () => number | undefined;
214
- checkSchema: () => E.SchemaProblem | null;
215
- assertSchema: () => void;
216
- dispose: () => void;
217
- createUndoManager: (options?: import("../../crdt/doc/history.js").HistoryOptions) => import("../../crdt/doc/history.js").UndoManager;
218
239
  project: () => import("../../index.js").ProjectedDoc;
219
- toJSON: () => JSONDoc;
240
+ toJSON: (options?: {
241
+ suggestions?: boolean;
242
+ } | undefined) => JSONDoc;
220
243
  blockJSON: (id: string) => import("../../index.js").JSONBlock;
221
244
  childrenIds: (id: string | null) => string[];
222
- childSlots: (parent: import("../../index.js").BlockId | null) => import("../../crdt/placement/model.js").ChildSlot[];
223
- slotOf: (id: string) => {
224
- parent: import("../../index.js").BlockId | null;
225
- rank: string;
226
- } | null;
227
245
  positionOf: (id: string) => import("../../index.js").Destination | null;
228
246
  pathOf: (id: string) => number[] | null;
229
247
  parentOf: (id: string) => string | null;
@@ -241,8 +259,6 @@ export declare const crdt: {
241
259
  ids: (path: readonly string[]) => string[];
242
260
  } | null;
243
261
  blockAttribution: (id: string) => import("../../index.js").BlockAttribution | undefined;
244
- crdtId: (id: string) => string | null;
245
- resolveBlock: (id: string) => E.EngineNode | null;
246
262
  displayLength: (id: string) => number;
247
263
  contentItems: (id: string) => import("../../index.js").ContentItem[];
248
264
  hasBlock: (id: string) => boolean;
@@ -256,8 +272,6 @@ export declare const crdt: {
256
272
  blockId: import("../../index.js").BlockId;
257
273
  offset: number;
258
274
  } | null;
259
- followUndo: (anchor: import("../../index.js").DocAnchor) => import("../../index.js").DocAnchor;
260
- rolesChanged: () => void;
261
275
  isVoid: (id: string) => boolean;
262
276
  isIsland: (id: string) => boolean;
263
277
  isLines: (id: string) => boolean;
@@ -289,20 +303,11 @@ export declare const crdt: {
289
303
  parent: string | null;
290
304
  levels: string[];
291
305
  };
292
- defaultChild: (id: string | null) => string;
293
306
  runs: (id: string) => readonly import("../../index.js").ContentRun[];
294
- contentJSON: (id: string) => ({
295
- text: string;
296
- marks?: Record<string, unknown>;
297
- } | {
298
- id?: string;
299
- type: string;
300
- data?: unknown;
301
- })[];
302
307
  onChange: (cb: (change: import("../../index.js").DocChange) => void) => (() => void);
303
308
  };
304
309
  newDoc: (opts?: ConstructorParameters<E.EngineApi["Doc"]>[0]) => YDoc;
305
- purge: (doc: E.EngineDoc, facade: {
310
+ purge: (doc: E.EngineDoc, facade: Partial<import("../../crdt/doc/suggest.js").SuggestFacade> & {
306
311
  model: import("../../crdt/placement/model.js").PlacementModel;
307
312
  text: import("../../crdt/text/model.js").TextEngine;
308
313
  }, horizon: import("../../crdt/purge.js").Horizon | null) => import("../index.js").PurgeReport;
@@ -530,11 +535,11 @@ export declare const crdt: {
530
535
  destroy(): void;
531
536
  disconnect(): void;
532
537
  connect(): void;
533
- emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<E.WebsocketProviderEvents[N]>): 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;
534
539
  _observers: Map<string, Set<any>>;
535
- on<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: E.WebsocketProviderEvents[NAME]): E.WebsocketProviderEvents[NAME];
536
- once<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: E.WebsocketProviderEvents[NAME]): void;
537
- off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: E.WebsocketProviderEvents[NAME]): void;
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;
538
543
  };
539
544
  };
540
545
  watchComments: (server: string | null, roomName: string, listener: (message: E.CommentMessage) => void) => (() => void);
@@ -695,6 +700,7 @@ export declare class RoomContext {
695
700
  claims: number;
696
701
  merged: number;
697
702
  released: number;
703
+ suggestions: number;
698
704
  };
699
705
  since: number;
700
706
  };
@@ -726,7 +732,10 @@ export declare class RoomContext {
726
732
  get lookups(): ReturnType<typeof lookups>;
727
733
  /** The digest of the room's block roles a client's advertised one is compared with. */
728
734
  get digest(): Record<string, string>;
729
- /** A facade over `doc` obeying the room's block roles (`semantics`). */
735
+ /**
736
+ * A facade over `doc` obeying the room's block roles (`semantics`), its
737
+ * shared suggestions built: its `toJSON()` leaves the pending ones out.
738
+ */
730
739
  facadeOf(doc: YDoc): EdytorDoc;
731
740
  /**
732
741
  * The facade over the live document. Read while the room is idle, it
@@ -11,6 +11,7 @@ import { Y } from '../../crdt/engine.js';
11
11
  import * as E from '../../crdt/protocol.js';
12
12
  import { CLOSE } from '../../crdt/providers/room.js';
13
13
  import { asEngineDoc } from '../../crdt/structs.js';
14
+ import { suggestionsOf } from '../../crdt/doc/suggest.js';
14
15
  import { defaultSemantics, facadeConfigOf, semanticsDigest } from '../../crdt/semantics.js';
15
16
  import { MAX_REFUSALS, ROOM_ORIGIN, SOCKET_TAG, noTimers } from './shared.js';
16
17
  /** The engine API the room is built on (the Worker-safe CRDT entry). */
@@ -53,7 +54,8 @@ const counters = () => ({
53
54
  records: 0,
54
55
  claims: 0,
55
56
  merged: 0,
56
- released: 0
57
+ released: 0,
58
+ suggestions: 0
57
59
  },
58
60
  since: Date.now()
59
61
  });
@@ -132,9 +134,14 @@ export class RoomContext {
132
134
  get digest() {
133
135
  return (this.#_digest ??= semanticsDigest(this.options.semantics ?? defaultSemantics));
134
136
  }
135
- /** A facade over `doc` obeying the room's block roles (`semantics`). */
137
+ /**
138
+ * A facade over `doc` obeying the room's block roles (`semantics`), its
139
+ * shared suggestions built: its `toJSON()` leaves the pending ones out.
140
+ */
136
141
  facadeOf(doc) {
137
- return crdt.doc.create(asEngineDoc(doc), this.lookups);
142
+ const facade = crdt.doc.create(asEngineDoc(doc), this.lookups);
143
+ suggestionsOf(facade);
144
+ return facade;
138
145
  }
139
146
  /**
140
147
  * The facade over the live document. Read while the room is idle, it
@@ -1,5 +1,10 @@
1
1
  import type { YDoc } from '../../crdt/index.js';
2
2
  import type { Decoded, Struct } from './context.js';
3
+ type Id = {
4
+ client: number;
5
+ clock: number;
6
+ };
7
+ export declare const isId: (value: unknown) => value is Id;
3
8
  /**
4
9
  * The clients of a frame (but `skip`) that write a per-writer block mark
5
10
  * of another writer: a struct whose key is `del.<n>` or `wd.<n>` on a
@@ -39,6 +44,14 @@ export type AttributionWrites = {
39
44
  * it again (`#bindOrphan`).
40
45
  */
41
46
  export declare const attributionWrites: (doc: YDoc, structs: Struct[], skip: Set<number>, user: string, owns: (client: number) => boolean, ownerOf: (client: number) => string | undefined) => AttributionWrites;
47
+ /**
48
+ * The suggestion writers of a frame that bind themselves to `user`: `n`
49
+ * writes a record in the suggestions' root and `c/<n>` naming `user` — a
50
+ * suggestion writer's first frame registers it as the user's
51
+ * (`sugg.writer.binding`). Any other self-bound id stays a replica's,
52
+ * claimed only by its own dial.
53
+ */
54
+ export declare const selfBound: (doc: YDoc, structs: Struct[], user: string) => Set<number>;
42
55
  /**
43
56
  * Of a frame's deletes, those of live attribution entries `user` may not
44
57
  * delete, with their keys: a binding of a replica the user does not own
@@ -48,3 +61,4 @@ export declare const forgedAttributionDeletes: (doc: YDoc, ds: Decoded["ds"], us
48
61
  ids: Decoded["ds"];
49
62
  keys: string[];
50
63
  };
64
+ export {};
@@ -7,7 +7,7 @@
7
7
  * find.
8
8
  */
9
9
  import { Y } from '../../crdt/engine.js';
10
- import { ATTRIBUTION_ROOT, DEL_PREFIX, HORIZON_ROOT, REGISTRY_KEY, WITHDRAW_PREFIX } from '../../crdt/schema.js';
10
+ import { ATTRIBUTION_ROOT, DEL_PREFIX, HORIZON_ROOT, REGISTRY_KEY, SUGGEST_ROOT, WITHDRAW_PREFIX } from '../../crdt/schema.js';
11
11
  import { heldClock, runsOf, storedStruct, structAt } from './updates.js';
12
12
  // ── Per-writer marks ──────────────────────────────────────────
13
13
  /** The writer `n` of a per-writer block mark key (`del.<n>`, `wd.<n>`), or `null`. */
@@ -22,7 +22,7 @@ const markWriter = (key) => {
22
22
  const digits = prefix === null ? '' : key.slice(prefix.length);
23
23
  return /^\d{1,16}$/.test(digits) ? Number(digits) : null;
24
24
  };
25
- const isId = (value) => typeof value === 'object' &&
25
+ export const isId = (value) => typeof value === 'object' &&
26
26
  value !== null &&
27
27
  typeof value.client === 'number' &&
28
28
  typeof value.clock === 'number' &&
@@ -198,6 +198,34 @@ export const attributionWrites = (doc, structs, skip, user, owns, ownerOf) => {
198
198
  }
199
199
  return writes;
200
200
  };
201
+ /**
202
+ * The suggestion writers of a frame that bind themselves to `user`: `n`
203
+ * writes a record in the suggestions' root and `c/<n>` naming `user` — a
204
+ * suggestion writer's first frame registers it as the user's
205
+ * (`sugg.writer.binding`). Any other self-bound id stays a replica's,
206
+ * claimed only by its own dial.
207
+ */
208
+ export const selfBound = (doc, structs, user) => {
209
+ const frame = runsOf(structs);
210
+ const records = new Set();
211
+ const bound = new Set();
212
+ for (const struct of structs) {
213
+ if (!(struct instanceof Y.Item))
214
+ continue;
215
+ const place = placeOf(doc, frame, struct.id);
216
+ if (place?.key == null)
217
+ continue;
218
+ const { parent } = place;
219
+ if (parent === SUGGEST_ROOT || (parent != null && parent === doc.share.get(SUGGEST_ROOT)))
220
+ records.add(struct.id.client);
221
+ if (!isAttribution(doc, parent))
222
+ continue;
223
+ const content = struct.content.getContent();
224
+ if (boundReplica(place.key) === struct.id.client && content[content.length - 1] === user)
225
+ bound.add(struct.id.client);
226
+ }
227
+ return new Set([...bound].filter((client) => records.has(client)));
228
+ };
201
229
  /**
202
230
  * Of a frame's deletes, those of live attribution entries `user` may not
203
231
  * delete, with their keys: a binding of a replica the user does not own
@@ -27,5 +27,9 @@ export declare const updateFrame: (update: Uint8Array) => Uint8Array;
27
27
  export declare const readOnlyFrame: () => Uint8Array;
28
28
  /** The denial of a read-only socket's write: it stays, and still syncs. */
29
29
  export declare const readOnlyDenialFrame: () => Uint8Array;
30
+ /** The denial of what a suggest-only socket may not write (stripped): it stays, and still syncs. */
31
+ export declare const suggestOnlyDenialFrame: () => Uint8Array;
32
+ /** The socket's access, at the join and at a change in place (`write`, `suggest`, `comment`, `read`). */
33
+ export declare const accessFrame: (access: string) => Uint8Array;
30
34
  /** A Step2 of what the room STORED: the engine's pending store (never stored) is left out. */
31
35
  export declare const storedStep2: (doc: YDoc, sv: Uint8Array) => Uint8Array;
@@ -4,7 +4,7 @@
4
4
  * room's.
5
5
  */
6
6
  import * as encoding from 'lib0-v14/encoding';
7
- import { READ_ONLY_DENIAL } from '../../crdt/protocols/auth.js';
7
+ import { READ_ONLY_DENIAL, SUGGEST_ONLY_DENIAL } from '../../crdt/protocols/auth.js';
8
8
  import * as E from '../../crdt/protocol.js';
9
9
  import { sync } from './context.js';
10
10
  import { withoutPending } from './updates.js';
@@ -49,5 +49,9 @@ export const updateFrame = (update) => E.frame(E.messageSync, (e) => sync.writeU
49
49
  export const readOnlyFrame = () => E.frame(E.messageAuth, (e) => E.writeReadOnly(e));
50
50
  /** The denial of a read-only socket's write: it stays, and still syncs. */
51
51
  export const readOnlyDenialFrame = () => E.frame(E.messageAuth, (e) => E.writePermissionDenied(e, READ_ONLY_DENIAL));
52
+ /** The denial of what a suggest-only socket may not write (stripped): it stays, and still syncs. */
53
+ export const suggestOnlyDenialFrame = () => E.frame(E.messageAuth, (e) => E.writePermissionDenied(e, SUGGEST_ONLY_DENIAL));
54
+ /** The socket's access, at the join and at a change in place (`write`, `suggest`, `comment`, `read`). */
55
+ export const accessFrame = (access) => E.frame(E.messageAuth, (e) => E.writeAccess(e, access));
52
56
  /** A Step2 of what the room STORED: the engine's pending store (never stored) is left out. */
53
57
  export const storedStep2 = (doc, sv) => withoutPending(doc, () => E.frame(E.messageSync, (e) => sync.writeSyncStep2(e, doc, sv)));
@@ -125,7 +125,8 @@ export class RoomPurge {
125
125
  'records',
126
126
  'claims',
127
127
  'merged',
128
- 'released'
128
+ 'released',
129
+ 'suggestions'
129
130
  ];
130
131
  // Nothing an ended session deleted was left: no compaction, no run.
131
132
  if (horizon === null && !wrote)
@@ -28,14 +28,16 @@ export declare class ReplicaRegistry {
28
28
  * stripped from its frame (the rest of the frame is applied: never
29
29
  * refused whole). Written: its user's ids, and its own replica (the
30
30
  * dialed or bound one), which claims an unowned id or a fresh one, as
31
- * `bind` would. A socket with no replica claims fresh ids it writes.
31
+ * `bind` would. A socket with no replica claims fresh ids it writes, and
32
+ * any socket a fresh id that binds itself to its user in the frame
33
+ * (`bound`: a suggestion's writer).
32
34
  * Any other id is relayed — another replica's structs, which a restore
33
35
  * from a lagging snapshot may have lost: kept, and left unowned (`''`,
34
36
  * claimable only by its own dial), when the room holds none of that id's
35
37
  * clocks and no user owns it; stripped otherwise (logged `replica`).
36
38
  * Ownership never moves to a relayer.
37
39
  */
38
- attribute({ user, replica }: Attachment, writers: Set<number>, sv: Map<number, number>, orphans: Set<number>): Set<number>;
40
+ attribute({ user, replica }: Attachment, writers: Set<number>, sv: Map<number, number>, orphans: Set<number>, bound?: Set<number>): Set<number>;
39
41
  /**
40
42
  * Bind the sender's replicas whose `c/<n>` a frame set to another actor
41
43
  * to its verified user (`room.attribution.trust`): one room write after the frame's, which
@@ -75,14 +75,16 @@ export class ReplicaRegistry {
75
75
  * stripped from its frame (the rest of the frame is applied: never
76
76
  * refused whole). Written: its user's ids, and its own replica (the
77
77
  * dialed or bound one), which claims an unowned id or a fresh one, as
78
- * `bind` would. A socket with no replica claims fresh ids it writes.
78
+ * `bind` would. A socket with no replica claims fresh ids it writes, and
79
+ * any socket a fresh id that binds itself to its user in the frame
80
+ * (`bound`: a suggestion's writer).
79
81
  * Any other id is relayed — another replica's structs, which a restore
80
82
  * from a lagging snapshot may have lost: kept, and left unowned (`''`,
81
83
  * claimable only by its own dial), when the room holds none of that id's
82
84
  * clocks and no user owns it; stripped otherwise (logged `replica`).
83
85
  * Ownership never moves to a relayer.
84
86
  */
85
- attribute({ user, replica }, writers, sv, orphans) {
87
+ attribute({ user, replica }, writers, sv, orphans, bound = new Set()) {
86
88
  const room = this.room;
87
89
  const claimed = [];
88
90
  const relayed = [];
@@ -93,7 +95,10 @@ export class ReplicaRegistry {
93
95
  continue;
94
96
  const held = (sv.get(client) ?? 0) > 0;
95
97
  const fresh = owner === undefined && !held;
96
- if (client === replica ? fresh || owner === '' : replica === null && fresh) {
98
+ // A fresh id the frame binds to its user by itself (a suggestion's writer) is the user's.
99
+ if (client === replica
100
+ ? fresh || owner === ''
101
+ : (replica === null || bound.has(client)) && fresh) {
97
102
  claimed.push({ replica: client, user });
98
103
  if (owner === '')
99
104
  orphans.add(client);
@@ -0,0 +1,7 @@
1
+ import type { YDoc } from '../../crdt/index.js';
2
+ import type { Decoded } from './context.js';
3
+ /** What a frame of a suggest-only socket may not write: the clients to strip, the deletes to drop. */
4
+ export declare const suggestOnly: (doc: YDoc, { structs, ds }: Decoded, skip: Set<number>, owns: (client: number) => boolean, replica: number | null) => {
5
+ strip: Set<number>;
6
+ deletes: Decoded["ds"];
7
+ };