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.
- package/README.md +3 -3
- package/dist/cloudflare/DocumentRoom.d.ts +77 -2
- package/dist/cloudflare/DocumentRoom.js +37 -1
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/room/access.d.ts +6 -1
- package/dist/cloudflare/room/access.js +30 -4
- package/dist/cloudflare/room/admission.d.ts +11 -0
- package/dist/cloudflare/room/admission.js +43 -10
- package/dist/cloudflare/room/context.d.ts +11 -2
- package/dist/cloudflare/room/context.js +17 -6
- package/dist/cloudflare/room/forged.d.ts +1 -1
- package/dist/cloudflare/room/forged.js +11 -9
- package/dist/cloudflare/room/frames.d.ts +2 -0
- package/dist/cloudflare/room/frames.js +2 -0
- package/dist/cloudflare/room/presence.js +1 -4
- package/dist/cloudflare/room/reseed.d.ts +93 -0
- package/dist/cloudflare/room/reseed.js +500 -0
- package/dist/cloudflare/room/scheduler.d.ts +1 -1
- package/dist/cloudflare/room/scheduler.js +9 -1
- package/dist/cloudflare/room/shared.d.ts +10 -0
- package/dist/cloudflare/room/shared.js +10 -0
- package/dist/cloudflare/room/storage.d.ts +7 -0
- package/dist/cloudflare/room/storage.js +33 -1
- package/dist/components/Content.svelte +7 -16
- package/dist/components/Edytor.svelte +32 -8
- package/dist/components/Edytor.svelte.d.ts +10 -1
- package/dist/components/EdytorRoot.svelte +17 -0
- package/dist/components/EdytorRoot.svelte.d.ts +4 -0
- package/dist/components/Suggestion.svelte +1 -1
- package/dist/components/Text.svelte +36 -33
- package/dist/components/Text.svelte.d.ts +2 -1
- package/dist/crdt/attribution/block.d.ts +3 -0
- package/dist/crdt/attribution/block.js +3 -2
- package/dist/crdt/doc/suggest.d.ts +6 -2
- package/dist/crdt/doc/suggest.js +6 -5
- package/dist/crdt/edytor-doc.d.ts +1 -1
- package/dist/crdt/edytor-doc.js +1 -1
- package/dist/crdt/engine-room.d.ts +4 -0
- package/dist/crdt/engine-room.js +6 -0
- package/dist/crdt/index.d.ts +2 -1
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/protocols/auth.d.ts +8 -1
- package/dist/crdt/protocols/auth.js +14 -1
- package/dist/crdt/providers/index.d.ts +1 -0
- package/dist/crdt/providers/index.js +22 -3
- package/dist/crdt/providers/room.d.ts +15 -0
- package/dist/crdt/providers/room.js +16 -1
- package/dist/crdt/providers/websocket.d.ts +4 -2
- package/dist/crdt/providers/websocket.js +36 -9
- package/dist/crdt/reseed.d.ts +127 -0
- package/dist/crdt/reseed.js +533 -0
- package/dist/crdt/restore.d.ts +13 -1
- package/dist/crdt/restore.js +8 -3
- package/dist/crdt/schema.d.ts +6 -0
- package/dist/crdt/schema.js +6 -0
- package/dist/crdt/structs.d.ts +8 -11
- package/dist/crdt/structs.js +25 -44
- package/dist/crdt/text/index/build.d.ts +3 -9
- package/dist/crdt/text/index/build.js +87 -181
- package/dist/crdt/vendor/yjs/UPSTREAM.md +101 -5
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +10 -10
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +1 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/Item.js +24 -13
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +12 -10
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +42 -1
- package/dist/edytor.svelte.js +1 -1
- package/dist/events/onBeforeInput.js +7 -0
- package/dist/events/onKeyDown.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/blockHandles/BlockHandles.svelte +32 -5
- package/dist/selection/selection.svelte.d.ts +1 -1
- package/dist/selection/selection.svelte.js +87 -106
- package/dist/session/attempt.d.ts +6 -0
- package/dist/session/attempt.js +6 -0
- package/dist/session/commands.js +49 -51
- package/dist/session/composition.svelte.js +19 -7
- package/dist/surface/attributes.d.ts +3 -3
- package/dist/surface/attributes.js +2 -2
- package/dist/surface/cells.d.ts +7 -0
- package/dist/surface/cells.js +7 -0
- package/dist/surface/observer.svelte.d.ts +7 -7
- package/dist/surface/observer.svelte.js +225 -313
- package/dist/surface/pin.svelte.d.ts +7 -10
- package/dist/surface/pin.svelte.js +12 -15
- package/dist/surface/projector.svelte.d.ts +6 -3
- package/dist/surface/projector.svelte.js +20 -12
- package/dist/themes/notion.css +7 -0
- 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
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
/**
|
|
66
|
-
|
|
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 (
|
|
69
|
-
return
|
|
72
|
+
if (held?.block !== cell.id || held.key !== segment.key)
|
|
73
|
+
return segmentDeltas(cell, segment, transform);
|
|
70
74
|
const { preview, head, tail } = held;
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
*
|
|
84
|
-
* `selectionchange`
|
|
85
|
-
* runs input ahead of it on a busy main thread)
|
|
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
|
-
|
|
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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
*
|
|
306
|
-
* `selectionchange`
|
|
307
|
-
* runs input ahead of it on a busy main thread)
|
|
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
|
package/dist/themes/notion.css
CHANGED
|
@@ -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);
|