edytor 4.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 (193) 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 +106 -109
  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/funnel.d.ts +1 -1
  29. package/dist/crdt/doc/funnel.js +5 -2
  30. package/dist/crdt/doc/gate.d.ts +1 -1
  31. package/dist/crdt/doc/history.d.ts +6 -0
  32. package/dist/crdt/doc/history.js +79 -59
  33. package/dist/crdt/doc/ops.d.ts +81 -0
  34. package/dist/crdt/doc/ops.js +1898 -0
  35. package/dist/crdt/doc/reads.d.ts +2 -2
  36. package/dist/crdt/doc/reads.js +18 -28
  37. package/dist/crdt/doc/suggest.d.ts +167 -0
  38. package/dist/crdt/doc/suggest.js +579 -0
  39. package/dist/crdt/document.d.ts +10 -1
  40. package/dist/crdt/document.js +19 -11
  41. package/dist/crdt/edytor-doc.d.ts +294 -272
  42. package/dist/crdt/edytor-doc.js +123 -108
  43. package/dist/crdt/engine-api.d.ts +8 -2
  44. package/dist/crdt/engine.d.ts +2 -1
  45. package/dist/crdt/engine.js +3 -1
  46. package/dist/crdt/flow.d.ts +5 -47
  47. package/dist/crdt/flow.js +3 -269
  48. package/dist/crdt/index.d.ts +102 -108
  49. package/dist/crdt/index.js +3 -0
  50. package/dist/crdt/operations.d.ts +13 -4
  51. package/dist/crdt/parts.d.ts +43 -0
  52. package/dist/crdt/parts.js +44 -0
  53. package/dist/crdt/placement/display.d.ts +1 -1
  54. package/dist/crdt/placement/display.js +3 -3
  55. package/dist/crdt/placement/keys.d.ts +5 -0
  56. package/dist/crdt/placement/keys.js +5 -0
  57. package/dist/crdt/placement/resolve.d.ts +1 -1
  58. package/dist/crdt/placement/resolve.js +2 -1
  59. package/dist/crdt/protocol.d.ts +1 -1
  60. package/dist/crdt/protocol.js +1 -1
  61. package/dist/crdt/protocols/auth.d.ts +11 -1
  62. package/dist/crdt/protocols/auth.js +17 -1
  63. package/dist/crdt/protocols/awareness.js +46 -81
  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 +12 -22
  67. package/dist/crdt/providers/index.js +3 -1
  68. package/dist/crdt/providers/indexeddb.d.ts +6 -10
  69. package/dist/crdt/providers/indexeddb.js +10 -16
  70. package/dist/crdt/providers/room.d.ts +11 -0
  71. package/dist/crdt/providers/room.js +26 -12
  72. package/dist/crdt/providers/websocket.d.ts +8 -12
  73. package/dist/crdt/providers/websocket.js +17 -19
  74. package/dist/crdt/purge.d.ts +7 -1
  75. package/dist/crdt/purge.js +32 -2
  76. package/dist/crdt/rangeDelete.d.ts +2 -47
  77. package/dist/crdt/rangeDelete.js +1 -169
  78. package/dist/crdt/restore.d.ts +2 -1
  79. package/dist/crdt/restore.js +9 -0
  80. package/dist/crdt/schema.d.ts +9 -1
  81. package/dist/crdt/schema.js +13 -3
  82. package/dist/crdt/structs.d.ts +2 -0
  83. package/dist/crdt/structs.js +2 -0
  84. package/dist/crdt/text/index/build.d.ts +125 -0
  85. package/dist/crdt/text/index/build.js +2895 -0
  86. package/dist/crdt/text/index/shared.d.ts +2 -6
  87. package/dist/crdt/text/index/shared.js +19 -19
  88. package/dist/crdt/text/model.d.ts +10 -0
  89. package/dist/crdt/text/model.js +10 -4
  90. package/dist/crdt/text/runs.d.ts +43 -42
  91. package/dist/crdt/text/runs.js +2 -165
  92. package/dist/crdt/vendor/yjs/UPSTREAM.md +83 -0
  93. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  94. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +6 -3
  95. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +13 -2
  96. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  97. package/dist/crdt/vendor/yjs/src/structs/Item.js +44 -5
  98. package/dist/crdt/vendor/yjs/src/ynode.js +29 -7
  99. package/dist/edytor.svelte.d.ts +1 -1
  100. package/dist/edytor.svelte.js +100 -75
  101. package/dist/events/beforeInputCommands.d.ts +2 -2
  102. package/dist/events/domTextOffset.d.ts +2 -0
  103. package/dist/events/domTextOffset.js +8 -0
  104. package/dist/events/nativeInteractiveControl.d.ts +11 -1
  105. package/dist/events/nativeInteractiveControl.js +41 -1
  106. package/dist/events/onBeforeInput.js +3 -3
  107. package/dist/events/onFocus.js +9 -11
  108. package/dist/export/forms.d.ts +75 -75
  109. package/dist/index.d.ts +4 -2
  110. package/dist/index.js +1 -1
  111. package/dist/labels.d.ts +8 -0
  112. package/dist/labels.js +6 -1
  113. package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
  114. package/dist/plugins/comments/CommentsController.svelte.js +14 -4
  115. package/dist/plugins/find/search.js +2 -2
  116. package/dist/plugins/index.d.ts +1 -0
  117. package/dist/plugins/index.js +1 -0
  118. package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
  119. package/dist/plugins/richtext/richTextOperations.js +26 -32
  120. package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
  121. package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
  122. package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
  123. package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
  124. package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
  125. package/dist/plugins/suggestions/shared.svelte.js +421 -0
  126. package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
  127. package/dist/selection/domSelection.d.ts +2 -0
  128. package/dist/selection/domSelection.js +6 -2
  129. package/dist/selection/pointer.svelte.js +75 -48
  130. package/dist/selection/replaceSelection.js +2 -6
  131. package/dist/selection/selection.svelte.d.ts +3 -3
  132. package/dist/selection/selection.svelte.js +39 -32
  133. package/dist/selection/selection.utils.d.ts +14 -0
  134. package/dist/selection/selection.utils.js +33 -11
  135. package/dist/session/commands.js +21 -11
  136. package/dist/session/composition.svelte.d.ts +5 -3
  137. package/dist/session/composition.svelte.js +21 -17
  138. package/dist/session/handles.d.ts +4 -17
  139. package/dist/session/handles.js +14 -44
  140. package/dist/session/navigation.js +6 -9
  141. package/dist/session/selection.d.ts +11 -5
  142. package/dist/session/selection.js +14 -48
  143. package/dist/session/suggestions.svelte.d.ts +38 -9
  144. package/dist/session/suggestions.svelte.js +37 -18
  145. package/dist/session/virtual.d.ts +1 -1
  146. package/dist/surface/attributes.d.ts +5 -0
  147. package/dist/surface/attributes.js +2 -2
  148. package/dist/surface/cells.d.ts +2 -26
  149. package/dist/surface/cells.js +2 -33
  150. package/dist/surface/observer.svelte.d.ts +6 -1
  151. package/dist/surface/observer.svelte.js +143 -111
  152. package/dist/surface/pin.svelte.d.ts +9 -9
  153. package/dist/surface/pin.svelte.js +15 -22
  154. package/dist/surface/projector.svelte.js +10 -16
  155. package/dist/text/text.svelte.js +14 -19
  156. package/dist/themes/notion.css +29 -0
  157. package/dist/utils.d.ts +5 -0
  158. package/dist/utils.js +7 -0
  159. package/package.json +3 -1
  160. package/dist/crdt/doc/capability.d.ts +0 -56
  161. package/dist/crdt/doc/capability.js +0 -211
  162. package/dist/crdt/doc/content.d.ts +0 -16
  163. package/dist/crdt/doc/content.js +0 -77
  164. package/dist/crdt/doc/delete.d.ts +0 -15
  165. package/dist/crdt/doc/delete.js +0 -84
  166. package/dist/crdt/doc/layout.d.ts +0 -9
  167. package/dist/crdt/doc/layout.js +0 -178
  168. package/dist/crdt/doc/meta.d.ts +0 -19
  169. package/dist/crdt/doc/meta.js +0 -199
  170. package/dist/crdt/doc/moves.d.ts +0 -21
  171. package/dist/crdt/doc/moves.js +0 -274
  172. package/dist/crdt/doc/split-merge.d.ts +0 -10
  173. package/dist/crdt/doc/split-merge.js +0 -179
  174. package/dist/crdt/doc/steps.d.ts +0 -65
  175. package/dist/crdt/doc/steps.js +0 -311
  176. package/dist/crdt/text/index/cache.d.ts +0 -16
  177. package/dist/crdt/text/index/cache.js +0 -175
  178. package/dist/crdt/text/index/claims.d.ts +0 -18
  179. package/dist/crdt/text/index/claims.js +0 -225
  180. package/dist/crdt/text/index/fold.d.ts +0 -21
  181. package/dist/crdt/text/index/fold.js +0 -656
  182. package/dist/crdt/text/index/layout.d.ts +0 -24
  183. package/dist/crdt/text/index/layout.js +0 -271
  184. package/dist/crdt/text/index/placement.d.ts +0 -47
  185. package/dist/crdt/text/index/placement.js +0 -741
  186. package/dist/crdt/text/index/records.d.ts +0 -13
  187. package/dist/crdt/text/index/records.js +0 -139
  188. package/dist/crdt/text/index/report.d.ts +0 -18
  189. package/dist/crdt/text/index/report.js +0 -337
  190. package/dist/crdt/text/index/state.d.ts +0 -197
  191. package/dist/crdt/text/index/state.js +0 -116
  192. package/dist/crdt/text/index/streams.d.ts +0 -25
  193. package/dist/crdt/text/index/streams.js +0 -248
@@ -1,225 +0,0 @@
1
- import { DEAD, claimGraph, cmpStamp } from '../model.js';
2
- import { addTo, dropFrom } from './shared.js';
3
- /** The claim graph of one doc's index, over its state. */
4
- export const indexClaims = (ix) => {
5
- const { blocks, listConsumers, displaysMap, ownerSeeds, ownerChanged } = ix;
6
- // ── the claim graph (maintained) ─────────────────────────────
7
- // `top(m)` is the max-stamp claim on `m` held by a live block; each
8
- // block's owner follows `top` up (`claimGraph`). A structural change
9
- // of a block (its claims, its delete mark, its record) re-decides the
10
- // `top` of the blocks it claims (before and after) and the owners of
11
- // those blocks and of every block whose `top` chain reaches them —
12
- // never the whole graph.
13
- const owners = new Map();
14
- const topOf = new Map();
15
- /** Claimer → the blocks it tops. */
16
- const topInv = new Map();
17
- /** Claimed block → the blocks whose claims list names it (live or not). */
18
- const claimersOf = new Map();
19
- let ownersBuilt = false;
20
- /** The max-stamp claim on `m` held by a live block. */
21
- const topClaim = (m) => {
22
- let best;
23
- for (const holder of claimersOf.get(m) ?? []) {
24
- const rec = blocks.get(holder);
25
- if (rec === undefined || rec.deleted)
26
- continue;
27
- for (const c of rec.claims)
28
- if (c.m === m && (best === undefined || cmpStamp(c.stamp, best.stamp) > 0))
29
- best = { claimer: holder, stamp: c.stamp };
30
- }
31
- return best;
32
- };
33
- const setTop = (m, t) => {
34
- const old = topOf.get(m);
35
- if (old?.claimer === t?.claimer && (old === undefined || cmpStamp(old.stamp, t.stamp) === 0))
36
- return false;
37
- if (old !== undefined)
38
- dropFrom(topInv, old.claimer, m);
39
- if (t === undefined)
40
- topOf.delete(m);
41
- else {
42
- topOf.set(m, t);
43
- addTo(topInv, t.claimer, m);
44
- }
45
- return true;
46
- };
47
- /** `owner(b)` along `top` (`claimGraph`'s walk), memoized into `owners`. */
48
- const walkOwner = (b) => {
49
- const path = [];
50
- let cur = b;
51
- let result;
52
- for (;;) {
53
- const known = owners.get(cur);
54
- if (known !== undefined) {
55
- result = known;
56
- break;
57
- }
58
- const rec = blocks.get(cur);
59
- if (!rec || rec.deleted) {
60
- result = DEAD;
61
- break;
62
- }
63
- const at = path.indexOf(cur);
64
- if (at >= 0) {
65
- let best = topOf.get(path[at]);
66
- for (const member of path.slice(at)) {
67
- const t = topOf.get(member);
68
- if (cmpStamp(t.stamp, best.stamp) > 0)
69
- best = t;
70
- }
71
- result = best.claimer;
72
- break;
73
- }
74
- const t = topOf.get(cur);
75
- if (t === undefined) {
76
- result = cur;
77
- break;
78
- }
79
- path.push(cur);
80
- cur = t.claimer;
81
- }
82
- if (blocks.has(cur))
83
- owners.set(cur, result);
84
- for (const x of path)
85
- owners.set(x, result);
86
- };
87
- const setDisplay = (b, from, to) => {
88
- if (typeof from === 'string')
89
- dropFrom(displaysMap, from, b);
90
- if (typeof to === 'string')
91
- addTo(displaysMap, to, b);
92
- };
93
- const ensureOwners = () => {
94
- if (!ownersBuilt) {
95
- ownersBuilt = true;
96
- ownerSeeds.clear();
97
- const graph = claimGraph(blocks);
98
- owners.clear();
99
- for (const [b, o] of graph.owners)
100
- if (blocks.has(b))
101
- owners.set(b, o);
102
- topOf.clear();
103
- topInv.clear();
104
- claimersOf.clear();
105
- for (const [holder, rec] of blocks)
106
- for (const c of rec.claims)
107
- addTo(claimersOf, c.m, holder);
108
- for (const m of claimersOf.keys())
109
- setTop(m, topClaim(m));
110
- displaysMap.clear();
111
- for (const b of blocks.keys())
112
- setDisplay(b, undefined, owners.get(b));
113
- return;
114
- }
115
- if (ownerSeeds.size === 0)
116
- return;
117
- // The tops a seed's claims (now, and those it dropped: noted in `claimersOf` changes) decide.
118
- const affected = new Set();
119
- const stack = [];
120
- const seeds = [...ownerSeeds];
121
- for (const x of ownerSeeds) {
122
- stack.push(x);
123
- for (const m of claimTargets.get(x) ?? [])
124
- if (setTop(m, topClaim(m)))
125
- stack.push(m);
126
- for (const c of blocks.get(x)?.claims ?? [])
127
- if (setTop(c.m, topClaim(c.m)))
128
- stack.push(c.m);
129
- }
130
- ownerSeeds.clear();
131
- claimTargets.clear();
132
- for (let x = stack.pop(); x !== undefined; x = stack.pop()) {
133
- if (affected.has(x))
134
- continue;
135
- affected.add(x);
136
- for (const m of topInv.get(x) ?? [])
137
- stack.push(m);
138
- }
139
- const before = new Map();
140
- for (const x of affected) {
141
- before.set(x, owners.get(x));
142
- owners.delete(x);
143
- }
144
- for (const x of affected)
145
- if (blocks.has(x))
146
- walkOwner(x);
147
- for (const [x, was] of before) {
148
- const now = owners.get(x);
149
- if (now === was)
150
- continue;
151
- setDisplay(x, was, now);
152
- ownerChanged.add(x);
153
- }
154
- // A holder whose claims changed re-slots what shows through them: their
155
- // order among its claims is the key of the blocks shown under it
156
- // (`claimedRank`) — under its owner when it is itself merged away.
157
- for (const x of seeds) {
158
- if (!blocks.has(x))
159
- continue;
160
- ownerChanged.add(x);
161
- const o = owners.get(x);
162
- if (typeof o === 'string' && o !== x)
163
- ownerChanged.add(o);
164
- }
165
- };
166
- /** The claims each seed held before its record changed (their tops are re-decided too). */
167
- const claimTargets = new Map();
168
- const ownerOf = (b) => {
169
- ensureOwners();
170
- return owners.get(b) ?? DEAD;
171
- };
172
- /** The live claimer of the max-stamp claim on `m` (`DisplayOwnership.top`). */
173
- const top = (m) => {
174
- ensureOwners();
175
- return topOf.get(m)?.claimer;
176
- };
177
- /** The blocks `owner` displays (the delete step's marks). */
178
- const displays = (owner) => {
179
- ensureOwners();
180
- return [...(displaysMap.get(owner) ?? [])];
181
- };
182
- /** Union-ever claim targets per holder (never shrinks: a dropped claim still invalidates). */
183
- const effects = new Map();
184
- const noteEffects = (id, claims) => {
185
- let fx = effects.get(id);
186
- if (fx === undefined)
187
- effects.set(id, (fx = new Set()));
188
- for (const c of claims)
189
- fx.add(c.m);
190
- };
191
- /** `id`'s claims went from `before` to `after`: its claim facts follow. */
192
- const noteClaims = (id, before, after) => {
193
- noteEffects(id, after);
194
- const was = new Set(before.map((c) => c.m));
195
- const now = new Set(after.map((c) => c.m));
196
- for (const m of was)
197
- if (!now.has(m)) {
198
- dropFrom(claimersOf, m, id);
199
- addTo(claimTargets, id, m);
200
- }
201
- for (const m of now)
202
- if (!was.has(m))
203
- addTo(claimersOf, m, id);
204
- ownerSeeds.add(id);
205
- };
206
- /** A structural change of `id`: its readers, and the blocks it claims, re-read. */
207
- const invalidateBlock = (id, ctx, claimsBefore = []) => {
208
- ctx.invalidated.add(id);
209
- for (const c of listConsumers.get(id) ?? [])
210
- ctx.invalidated.add(c);
211
- for (const m of new Set([...(effects.get(id) ?? []), ...claimsBefore.map((c) => c.m)])) {
212
- ctx.invalidated.add(m);
213
- for (const c of listConsumers.get(m) ?? [])
214
- ctx.invalidated.add(c);
215
- }
216
- };
217
- return {
218
- ensureOwners,
219
- ownerOf,
220
- top,
221
- displays,
222
- noteClaims,
223
- invalidateBlock
224
- };
225
- };
@@ -1,21 +0,0 @@
1
- import type { BlockId } from '../../placement/model.js';
2
- import type { ContentRun } from '../runs.js';
3
- import type { IndexCache } from './cache.js';
4
- import type { IndexClaims } from './claims.js';
5
- import type { IndexPlacement } from './placement.js';
6
- import type { IndexRecords } from './records.js';
7
- import type { FoldCtx, IndexState, Tx } from './state.js';
8
- import type { IndexStreams } from './streams.js';
9
- import type { IndexLayout } from './layout.js';
10
- /** The fold of one doc's index, over every part it folds into. */
11
- export declare const indexFold: (ix: IndexState & IndexClaims & IndexStreams & IndexLayout & IndexPlacement & IndexRecords & IndexCache) => {
12
- runs: (b: BlockId) => readonly ContentRun[];
13
- settle: (affected: Iterable<BlockId>, ctx: FoldCtx | null) => void;
14
- syncPending: (tr: Tx | null | undefined) => boolean;
15
- openTx: () => Tx | null | undefined;
16
- syncAll: () => void;
17
- unfolded: () => boolean;
18
- onCommit: (tr: Tx) => void;
19
- committed: WeakSet<Tx>;
20
- };
21
- export type IndexFold = ReturnType<typeof indexFold>;