edytor 6.0.0 → 7.0.1

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 (93) hide show
  1. package/README.md +3 -3
  2. package/dist/cloudflare/DocumentRoom.d.ts +77 -2
  3. package/dist/cloudflare/DocumentRoom.js +37 -1
  4. package/dist/cloudflare/index.d.ts +1 -1
  5. package/dist/cloudflare/index.js +1 -1
  6. package/dist/cloudflare/room/access.d.ts +6 -1
  7. package/dist/cloudflare/room/access.js +30 -4
  8. package/dist/cloudflare/room/admission.d.ts +11 -0
  9. package/dist/cloudflare/room/admission.js +43 -10
  10. package/dist/cloudflare/room/context.d.ts +11 -2
  11. package/dist/cloudflare/room/context.js +17 -6
  12. package/dist/cloudflare/room/forged.d.ts +1 -1
  13. package/dist/cloudflare/room/forged.js +11 -9
  14. package/dist/cloudflare/room/frames.d.ts +2 -0
  15. package/dist/cloudflare/room/frames.js +2 -0
  16. package/dist/cloudflare/room/presence.js +1 -4
  17. package/dist/cloudflare/room/reseed.d.ts +93 -0
  18. package/dist/cloudflare/room/reseed.js +500 -0
  19. package/dist/cloudflare/room/scheduler.d.ts +1 -1
  20. package/dist/cloudflare/room/scheduler.js +9 -1
  21. package/dist/cloudflare/room/shared.d.ts +10 -0
  22. package/dist/cloudflare/room/shared.js +10 -0
  23. package/dist/cloudflare/room/storage.d.ts +7 -0
  24. package/dist/cloudflare/room/storage.js +33 -1
  25. package/dist/components/Content.svelte +7 -16
  26. package/dist/components/Edytor.svelte +32 -8
  27. package/dist/components/Edytor.svelte.d.ts +10 -1
  28. package/dist/components/EdytorRoot.svelte +17 -0
  29. package/dist/components/EdytorRoot.svelte.d.ts +4 -0
  30. package/dist/components/Suggestion.svelte +1 -1
  31. package/dist/components/Text.svelte +36 -33
  32. package/dist/components/Text.svelte.d.ts +2 -1
  33. package/dist/crdt/attribution/block.d.ts +3 -0
  34. package/dist/crdt/attribution/block.js +3 -2
  35. package/dist/crdt/doc/suggest.d.ts +6 -2
  36. package/dist/crdt/doc/suggest.js +6 -5
  37. package/dist/crdt/edytor-doc.d.ts +1 -1
  38. package/dist/crdt/edytor-doc.js +1 -1
  39. package/dist/crdt/engine-room.d.ts +4 -0
  40. package/dist/crdt/engine-room.js +6 -0
  41. package/dist/crdt/index.d.ts +2 -1
  42. package/dist/crdt/protocol.d.ts +2 -2
  43. package/dist/crdt/protocol.js +2 -2
  44. package/dist/crdt/protocols/auth.d.ts +8 -1
  45. package/dist/crdt/protocols/auth.js +14 -1
  46. package/dist/crdt/providers/index.d.ts +1 -0
  47. package/dist/crdt/providers/index.js +22 -3
  48. package/dist/crdt/providers/room.d.ts +15 -0
  49. package/dist/crdt/providers/room.js +16 -1
  50. package/dist/crdt/providers/websocket.d.ts +4 -2
  51. package/dist/crdt/providers/websocket.js +36 -9
  52. package/dist/crdt/reseed.d.ts +127 -0
  53. package/dist/crdt/reseed.js +533 -0
  54. package/dist/crdt/restore.d.ts +13 -1
  55. package/dist/crdt/restore.js +8 -3
  56. package/dist/crdt/schema.d.ts +6 -0
  57. package/dist/crdt/schema.js +6 -0
  58. package/dist/crdt/structs.d.ts +8 -11
  59. package/dist/crdt/structs.js +25 -44
  60. package/dist/crdt/text/index/build.d.ts +3 -9
  61. package/dist/crdt/text/index/build.js +87 -181
  62. package/dist/crdt/vendor/yjs/UPSTREAM.md +101 -5
  63. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  64. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +10 -10
  65. package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +1 -0
  66. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  67. package/dist/crdt/vendor/yjs/src/structs/Item.js +24 -13
  68. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +12 -10
  69. package/dist/crdt/vendor/yjs/src/utils/encoding.js +42 -1
  70. package/dist/edytor.svelte.js +1 -1
  71. package/dist/events/onBeforeInput.js +7 -0
  72. package/dist/events/onKeyDown.js +3 -2
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +1 -1
  75. package/dist/plugins/blockHandles/BlockHandles.svelte +32 -5
  76. package/dist/selection/selection.svelte.d.ts +1 -1
  77. package/dist/selection/selection.svelte.js +87 -106
  78. package/dist/session/attempt.d.ts +6 -0
  79. package/dist/session/attempt.js +6 -0
  80. package/dist/session/commands.js +49 -51
  81. package/dist/session/composition.svelte.js +19 -7
  82. package/dist/surface/attributes.d.ts +3 -3
  83. package/dist/surface/attributes.js +2 -2
  84. package/dist/surface/cells.d.ts +7 -0
  85. package/dist/surface/cells.js +7 -0
  86. package/dist/surface/observer.svelte.d.ts +7 -7
  87. package/dist/surface/observer.svelte.js +225 -313
  88. package/dist/surface/pin.svelte.d.ts +7 -10
  89. package/dist/surface/pin.svelte.js +12 -15
  90. package/dist/surface/projector.svelte.d.ts +6 -3
  91. package/dist/surface/projector.svelte.js +20 -12
  92. package/dist/themes/notion.css +7 -0
  93. package/package.json +1 -1
@@ -38,16 +38,13 @@ export declare class Pin {
38
38
  owns: (node: Node | null | undefined) => boolean;
39
39
  /** The segment list `cell` renders: frozen while it hosts the pin. */
40
40
  parts: (cell: Cell) => readonly Part[];
41
- /** The pinned render of segment `key` of `block`, or null when it is not the host. */
42
- render: (block: BlockId, key: string) => {
43
- deltas: RenderDelta[];
44
- empty: boolean;
45
- } | null;
46
- /** The render of `segment` of `cell`: pinned while it hosts the IME, else its kind's (`segmentDeltas`). */
47
- shown: (cell: Cell, segment: Segment, transform: TextTransform | undefined) => {
48
- deltas: RenderDelta[];
49
- empty: boolean;
50
- };
41
+ /**
42
+ * The render of `segment` of `cell`: its kind's (`segmentDeltas`), or the
43
+ * pinned one while it hosts the IME, an empty host's the filler text node
44
+ * (never the `<br>` of an empty line): the IME composes into a node the
45
+ * render owns.
46
+ */
47
+ shown: (cell: Cell, segment: Segment, transform: TextTransform | undefined) => readonly RenderDelta[];
51
48
  /** What follows the pinned segment `key` of `block` in its own element (`merge`). */
52
49
  rest: (block: BlockId, key: string) => RenderDelta[];
53
50
  /**
@@ -1,4 +1,4 @@
1
- import { partsOf, renderDeltas, segmentDeltas } from './cells.js';
1
+ import { FILLER, partsOf, renderDeltas, segmentDeltas } from './cells.js';
2
2
  const textOf = (items) => items.map((item) => item.text).join('');
3
3
  /** The items of `deltas` before and after unit `at`. */
4
4
  const cut = (deltas, at) => {
@@ -25,7 +25,6 @@ export class Pin {
25
25
  key: segment.key,
26
26
  parts: partsOf(cell.runs),
27
27
  frozen,
28
- empty: segment.text === '',
29
28
  head: cut(frozen, from)[0],
30
29
  tail: cut(frozen, Math.max(from, to))[1],
31
30
  merged: [],
@@ -62,21 +61,19 @@ export class Pin {
62
61
  owns = (node) => Boolean(node && this.#held?.element?.contains(node));
63
62
  /** The segment list `cell` renders: frozen while it hosts the pin. */
64
63
  parts = (cell) => this.#held?.block === cell.id ? this.#held.parts : partsOf(cell.runs);
65
- /** The pinned render of segment `key` of `block`, or null when it is not the host. */
66
- render = (block, key) => {
64
+ /**
65
+ * The render of `segment` of `cell`: its kind's (`segmentDeltas`), or the
66
+ * pinned one while it hosts the IME, an empty host's the filler text node
67
+ * (never the `<br>` of an empty line): the IME composes into a node the
68
+ * render owns.
69
+ */
70
+ shown = (cell, segment, transform) => {
67
71
  const held = this.#held;
68
- if (!held || held.block !== block || held.key !== key)
69
- return null;
72
+ if (held?.block !== cell.id || held.key !== segment.key)
73
+ return segmentDeltas(cell, segment, transform);
70
74
  const { preview, head, tail } = held;
71
- if (!preview || preview.native)
72
- return { deltas: [...held.frozen], empty: held.empty };
73
- const items = [...head, preview, ...tail];
74
- return { deltas: renderDeltas(items), empty: !textOf(items) };
75
- };
76
- /** The render of `segment` of `cell`: pinned while it hosts the IME, else its kind's (`segmentDeltas`). */
77
- shown = (cell, segment, transform) => this.render(cell.id, segment.key) ?? {
78
- deltas: segmentDeltas(cell, segment, transform),
79
- empty: segment.text === ''
75
+ const deltas = !preview || preview.native ? held.frozen : renderDeltas([...head, preview, ...tail]);
76
+ return deltas.length ? deltas : FILLER;
80
77
  };
81
78
  /** What follows the pinned segment `key` of `block` in its own element (`merge`). */
82
79
  rest = (block, key) => {
@@ -80,9 +80,12 @@ export declare class Projector {
80
80
  */
81
81
  pressed: () => void;
82
82
  /**
83
- * A press placed a DOM caret the model has not observed yet: its
84
- * `selectionchange` is still queued (`sel.key.before-adoption`; Chromium
85
- * runs input ahead of it on a busy main thread). A key reads the DOM first.
83
+ * The DOM selection moved since the last observation, its
84
+ * `selectionchange` still queued (`sel.key.before-adoption`; Chromium
85
+ * runs input ahead of it on a busy main thread): a press placed a caret,
86
+ * or the browser moved it for a key of its own (an arrow, Shift+arrow:
87
+ * Mod+B right after Shift+→ held down acts on the whole extension). A key
88
+ * reads the DOM first.
86
89
  */
87
90
  unobserved: () => boolean;
88
91
  /**
@@ -218,17 +218,22 @@ export class Projector {
218
218
  #unreported = () => {
219
219
  const { edytor } = this;
220
220
  const { selection } = edytor;
221
- const at = this.#at;
222
- const node = edytor.node;
223
- if (!at || !node || selection.value.kind !== 'text' || edytor.intentSerial !== this.#serial)
221
+ if (selection.value.kind !== 'text' || edytor.intentSerial !== this.#serial)
224
222
  return false;
225
223
  if (selection.request !== this.#request || selection.dragging || edytor.composition.live)
226
224
  return false;
227
- const dom = getDomSelection(node);
228
- if (!dom || !isOwnPoint(node, dom.anchorNode))
229
- return false;
230
- return !(samePoint(at.anchor, dom.anchorNode, dom.anchorOffset) &&
231
- samePoint(at.focus, dom.focusNode, dom.focusOffset));
225
+ return this.#moved();
226
+ };
227
+ /** The DOM selection in the host is no longer where the last observation found it. */
228
+ #moved = () => {
229
+ const at = this.#at;
230
+ const node = this.edytor.node;
231
+ const dom = node && getDomSelection(node);
232
+ return (!!at &&
233
+ !!dom &&
234
+ isOwnPoint(node, dom.anchorNode) &&
235
+ !(samePoint(at.anchor, dom.anchorNode, dom.anchorOffset) &&
236
+ samePoint(at.focus, dom.focusNode, dom.focusOffset)));
232
237
  };
233
238
  /**
234
239
  * Classify a `selectionchange` by comparing the DOM selection with the
@@ -302,11 +307,14 @@ export class Projector {
302
307
  this.#press = this.edytor.intentSerial;
303
308
  };
304
309
  /**
305
- * A press placed a DOM caret the model has not observed yet: its
306
- * `selectionchange` is still queued (`sel.key.before-adoption`; Chromium
307
- * runs input ahead of it on a busy main thread). A key reads the DOM first.
310
+ * The DOM selection moved since the last observation, its
311
+ * `selectionchange` still queued (`sel.key.before-adoption`; Chromium
312
+ * runs input ahead of it on a busy main thread): a press placed a caret,
313
+ * or the browser moved it for a key of its own (an arrow, Shift+arrow:
314
+ * Mod+B right after Shift+→ held down acts on the whole extension). A key
315
+ * reads the DOM first.
308
316
  */
309
- unobserved = () => this.#press > this.#serial;
317
+ unobserved = () => this.#press > this.#serial || this.#moved();
310
318
  /**
311
319
  * Whether the host holds a DOM caret a gesture may have placed: a range
312
320
  * inside it that is not the browser's parked one (`parked`; a key such as
@@ -369,6 +369,13 @@
369
369
  .edytor-notion button[data-edytor-callout-icon][data-empty]:focus-visible::before {
370
370
  opacity: 1;
371
371
  }
372
+ /* A touch screen shows it: a touch that revealed it would cost the tap (iOS
373
+ * Safari takes it for a hover and sends no click). */
374
+ @media (hover: none) {
375
+ .edytor-notion button[data-edytor-callout-icon][data-empty]::before {
376
+ opacity: 1;
377
+ }
378
+ }
372
379
  /* No icon in a readonly view: the text starts at the panel's edge. */
373
380
  .edytor-notion [data-edytor-type='callout']:not(:has(> [data-edytor-callout-icon])) {
374
381
  grid-template-columns: minmax(0, 1fr);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "edytor",
3
3
  "license": "MIT",
4
- "version": "6.0.0",
4
+ "version": "7.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/beynar/edytor.git"