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
|
@@ -117,9 +117,11 @@ export class Composition {
|
|
|
117
117
|
// With no target, the caret the browser parked for the IME.
|
|
118
118
|
const parked = targetless && dom?.anchorNode;
|
|
119
119
|
const point = parked ? this.edytor.ports.surface.pointAt(parked, dom.anchorOffset) : null;
|
|
120
|
+
// With no target the value is `none`: nothing to replace.
|
|
121
|
+
const replaced = shown === 'blocks' || shown === 'atom' || blocks;
|
|
120
122
|
const at = targetless
|
|
121
123
|
? point && { text: point.text, from: point.offset, to: point.offset }
|
|
122
|
-
:
|
|
124
|
+
: replaced
|
|
123
125
|
? this.#rangeless()
|
|
124
126
|
: startText && {
|
|
125
127
|
text: startText,
|
|
@@ -127,7 +129,7 @@ export class Composition {
|
|
|
127
129
|
to: endText === startText ? yEnd : startText.length
|
|
128
130
|
};
|
|
129
131
|
if (at)
|
|
130
|
-
this.#pin(at.text, at.from, at.to);
|
|
132
|
+
this.#pin(at.text, at.from, at.to, replaced);
|
|
131
133
|
this.host = at?.text ?? null;
|
|
132
134
|
this.#where = this.#place();
|
|
133
135
|
};
|
|
@@ -291,8 +293,8 @@ export class Composition {
|
|
|
291
293
|
* and remove the render's anchors between them before the change renders
|
|
292
294
|
* (Firefox, `ime.range.blocks`). Its start target is replaced now (blocks:
|
|
293
295
|
* `flow.slot`, one empty block in their place; an atom: removed; a range:
|
|
294
|
-
* its blocks merged around the caret)
|
|
295
|
-
* caret
|
|
296
|
+
* its blocks merged around the caret) and the change rendered; `#pin`
|
|
297
|
+
* parks the DOM caret where the preview goes before the IME writes
|
|
296
298
|
* (`projector.park`, the DOM-selection writer). When the replacement is
|
|
297
299
|
* refused, the IME writes where Escape leaves for (`selectedBlocksExit`;
|
|
298
300
|
* an atom or a range: before it) and the tail restores it: nothing is
|
|
@@ -310,7 +312,6 @@ export class Composition {
|
|
|
310
312
|
flushSync();
|
|
311
313
|
if (!at.text.node)
|
|
312
314
|
return null;
|
|
313
|
-
edytor.ports.surface.park(at.text, at.offset);
|
|
314
315
|
return { text: at.text, from: at.offset, to: at.offset };
|
|
315
316
|
}
|
|
316
317
|
/**
|
|
@@ -402,14 +403,25 @@ export class Composition {
|
|
|
402
403
|
this.edytor.facade.deleteText(blockId, offset, length);
|
|
403
404
|
this.#own.clear();
|
|
404
405
|
}
|
|
405
|
-
/**
|
|
406
|
-
|
|
406
|
+
/**
|
|
407
|
+
* Pin the host's cell and segment: the renderer never rewrites the IME's
|
|
408
|
+
* node (`surface/pin`). The DOM caret is parked where the preview goes
|
|
409
|
+
* when the start target was `replaced` (`#rangeless`), and in an empty
|
|
410
|
+
* host, which shows its filler text node from now on, not the `<br>` of
|
|
411
|
+
* an empty line: the IME composes into a node the render owns
|
|
412
|
+
* (`ime.empty.filler`).
|
|
413
|
+
*/
|
|
414
|
+
#pin(host, from, to, replaced) {
|
|
407
415
|
const { edytor } = this;
|
|
408
416
|
const at = edytor.segmentOf(host);
|
|
409
417
|
if (!at)
|
|
410
418
|
return;
|
|
411
419
|
const transform = edytor.definitionOf(at.cell.type).transformText;
|
|
412
420
|
edytor.pin.acquire(at.cell, at.segment, transform, from, to, host.node ?? null);
|
|
421
|
+
if (!replaced && at.segment.text)
|
|
422
|
+
return;
|
|
423
|
+
flushSync();
|
|
424
|
+
edytor.ports.surface.park(host, from);
|
|
413
425
|
}
|
|
414
426
|
/** A mechanical tracked write: the region holds `value`. */
|
|
415
427
|
#write(value) {
|
|
@@ -32,12 +32,12 @@ export type Kind = 'block' | 'text' | 'mark' | 'atom' | 'anchor' | 'preview';
|
|
|
32
32
|
* moves the caret by its paragraph's direction, never an inline run's.
|
|
33
33
|
*/
|
|
34
34
|
export declare const blockDir: (text: string) => "rtl" | "ltr" | null;
|
|
35
|
-
/** The text a cell's runs show
|
|
36
|
-
export declare const ownText: (runs: readonly ContentRun[]) => string;
|
|
35
|
+
/** The text a cell's runs show, each atom as `atom` (left out: what `blockDir` reads). */
|
|
36
|
+
export declare const ownText: (runs: readonly ContentRun[], atom?: string) => string;
|
|
37
37
|
/** A text inside a void block is its own editing host (the core sets it at attach). */
|
|
38
38
|
export declare const insideVoid: (edytor: Edytor, block: string) => boolean;
|
|
39
39
|
/** What the table owns on `element` (the root, or a registered element). */
|
|
40
|
-
export declare const ownedOf: (edytor: Edytor, element: Element, entry
|
|
40
|
+
export declare const ownedOf: (edytor: Edytor, element: Element, entry?: {
|
|
41
41
|
kind: Kind;
|
|
42
42
|
block: string;
|
|
43
43
|
name?: string;
|
|
@@ -20,8 +20,8 @@ export const blockDir = (text) => {
|
|
|
20
20
|
const strong = STRONG.exec(text)?.[0];
|
|
21
21
|
return strong === undefined ? null : RTL.test(strong) ? 'rtl' : 'ltr';
|
|
22
22
|
};
|
|
23
|
-
/** The text a cell's runs show
|
|
24
|
-
export const ownText = (runs) => runs.map((run) => (run.kind === 'text' ? run.text :
|
|
23
|
+
/** The text a cell's runs show, each atom as `atom` (left out: what `blockDir` reads). */
|
|
24
|
+
export const ownText = (runs, atom = '') => runs.map((run) => (run.kind === 'text' ? run.text : atom)).join('');
|
|
25
25
|
/** A text inside a void block is its own editing host (the core sets it at attach). */
|
|
26
26
|
export const insideVoid = (edytor, block) => {
|
|
27
27
|
for (let id = block; id; id = edytor.facade.parentOf(id))
|
package/dist/surface/cells.d.ts
CHANGED
|
@@ -57,6 +57,13 @@ export type RenderDelta = {
|
|
|
57
57
|
/** Mark entries in nesting order (the first run's order when runs merge). */
|
|
58
58
|
readonly marks: readonly (readonly [string, unknown])[];
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* The text node an empty text renders where a `<br>` would break its line
|
|
62
|
+
* (beside an atom or a suggestion), or where the IME composes (`Pin.shown`):
|
|
63
|
+
* a zero-width space. An empty text alone in its block renders a `<br>`, so
|
|
64
|
+
* a phone's keyboard finds nothing before the caret and capitalizes.
|
|
65
|
+
*/
|
|
66
|
+
export declare const FILLER: readonly RenderDelta[];
|
|
60
67
|
/** One delta per maximal stretch of equal marks; empty runs render nothing. */
|
|
61
68
|
export declare const renderDeltas: (items: readonly {
|
|
62
69
|
text: string;
|
package/dist/surface/cells.js
CHANGED
|
@@ -145,6 +145,13 @@ export const rendersMark = (marks, name) => {
|
|
|
145
145
|
const mark = marks.get(name);
|
|
146
146
|
return Boolean(mark?.tag || mark?.snippet);
|
|
147
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* The text node an empty text renders where a `<br>` would break its line
|
|
150
|
+
* (beside an atom or a suggestion), or where the IME composes (`Pin.shown`):
|
|
151
|
+
* a zero-width space. An empty text alone in its block renders a `<br>`, so
|
|
152
|
+
* a phone's keyboard finds nothing before the caret and capitalizes.
|
|
153
|
+
*/
|
|
154
|
+
export const FILLER = [{ text: '\u200B', marks: [] }];
|
|
148
155
|
/** Mark payloads compare by canonical value: key-sorted, `undefined` values dropped. */
|
|
149
156
|
const marksKey = (marks) => marks
|
|
150
157
|
? JSON.stringify(Object.entries(marks)
|
|
@@ -31,12 +31,12 @@ export declare class SurfaceObserver {
|
|
|
31
31
|
* editing host inside a void).
|
|
32
32
|
*/
|
|
33
33
|
register: (node: Element, kind: Kind, block: string, name?: string, owned?: () => Owned, handle?: Text | InlineBlock) => () => void;
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A view-only element the core renders in the host, never compared: the
|
|
36
|
+
* render anchor (`Edytor.svelte`, a registered child of the strict root),
|
|
37
|
+
* or with its suggestion's `id`, a preview group (`components/Suggestion`).
|
|
38
|
+
*/
|
|
39
|
+
own: (node: HTMLElement, id?: string) => {
|
|
40
40
|
destroy: () => void;
|
|
41
41
|
};
|
|
42
42
|
/** Extension view state rendered into the host, or a re-display request: an epoch bump. */
|
|
@@ -71,4 +71,4 @@ export declare class SurfaceObserver {
|
|
|
71
71
|
* The caret lands where the browser put it (`domCaret`), else, for an
|
|
72
72
|
* attempt, where the change ends — unless a gesture came since.
|
|
73
73
|
*/
|
|
74
|
-
export declare const adopt: (edytor: Edytor, text: Text, dom: string, domCaret?: number, prefer?: number) => Promise<
|
|
74
|
+
export declare const adopt: (edytor: Edytor, text: Text, dom: string, domCaret?: number, prefer?: number) => Promise<void>;
|