edytor 0.1.0-next.26 → 0.1.0-next.27
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
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
|
|
17
17
|
|
|
18
|
-
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.
|
|
18
|
+
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.27`, `edytor@next` on npm) and not ready for production; the API changes between releases without a compatibility layer. The untagged `edytor@0.0.11` on npm predates the current API. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
@@ -88,6 +88,9 @@ export class InlineBlock {
|
|
|
88
88
|
return selection.setAtTextOffset(after, 0);
|
|
89
89
|
selection.selectInlineBlock(this);
|
|
90
90
|
clearDomSelection(this.edytor.node);
|
|
91
|
+
// The atom took the press: the caret the browser still leaves for it
|
|
92
|
+
// (Chromium parks one at the host's start before the release) is its own.
|
|
93
|
+
this.edytor.projector.parked();
|
|
91
94
|
};
|
|
92
95
|
node.addEventListener('pointerdown', selectInlineBlock);
|
|
93
96
|
return {
|
|
@@ -35,7 +35,8 @@ export declare class Projector {
|
|
|
35
35
|
* - drift: no gesture since the last observation, and a render since it
|
|
36
36
|
* (a flush the DOM selection was not observed after, or DOM records the
|
|
37
37
|
* observer has not reconciled), or one of the two named signatures,
|
|
38
|
-
* or the caret a browser parks for the editor's own focus
|
|
38
|
+
* or the caret a browser parks for the editor's own focus, a refused key
|
|
39
|
+
* or an atom's press (`parked`);
|
|
39
40
|
* - intent: a gesture since the last observation, or a pointer drag;
|
|
40
41
|
* - foreign: no gesture and no render (host code, assistive tech, O1).
|
|
41
42
|
*/
|
|
@@ -44,9 +45,13 @@ export declare class Projector {
|
|
|
44
45
|
* The browser parks a caret of its own, at the host's start: the editor
|
|
45
46
|
* focused its own host (`takeKeys`: the keys after a gesture on its
|
|
46
47
|
* chrome), or a key the attempt refused for want of a target
|
|
47
|
-
* (`targetless`: Chromium places a caret for it)
|
|
48
|
-
*
|
|
49
|
-
*
|
|
48
|
+
* (`targetless`: Chromium places a caret for it), or an atom took a press
|
|
49
|
+
* (`InlineBlock.attach`: Chromium parks one for it before the release).
|
|
50
|
+
* Until the next gesture that caret is drift, displayed over by the value —
|
|
51
|
+
* a block selection, an atom or none shows no DOM range — never adopted;
|
|
52
|
+
* under none or an atom, until a press inside or a focus from outside
|
|
53
|
+
* (`pressed`), an adopted move or our own display, whatever key or release
|
|
54
|
+
* came since.
|
|
50
55
|
*/
|
|
51
56
|
parked: () => void;
|
|
52
57
|
/**
|
|
@@ -193,7 +193,8 @@ export class Projector {
|
|
|
193
193
|
* - drift: no gesture since the last observation, and a render since it
|
|
194
194
|
* (a flush the DOM selection was not observed after, or DOM records the
|
|
195
195
|
* observer has not reconciled), or one of the two named signatures,
|
|
196
|
-
* or the caret a browser parks for the editor's own focus
|
|
196
|
+
* or the caret a browser parks for the editor's own focus, a refused key
|
|
197
|
+
* or an atom's press (`parked`);
|
|
197
198
|
* - intent: a gesture since the last observation, or a pointer drag;
|
|
198
199
|
* - foreign: no gesture and no render (host code, assistive tech, O1).
|
|
199
200
|
*/
|
|
@@ -216,8 +217,10 @@ export class Projector {
|
|
|
216
217
|
if (this.#parked === edytor.intentSerial)
|
|
217
218
|
return 'drift';
|
|
218
219
|
// With no value, a caret no press placed stays the browser's, whatever key
|
|
219
|
-
// came since (Mod+Z, Escape: Chromium parks one at the host's start)
|
|
220
|
-
|
|
220
|
+
// came since (Mod+Z, Escape: Chromium parks one at the host's start); over
|
|
221
|
+
// an atom a press selected, so does the one the browser parks for that
|
|
222
|
+
// press, whatever its release marked (`parked`).
|
|
223
|
+
if (this.#parking && (selection.value.kind === 'none' || selection.value.kind === 'atom'))
|
|
221
224
|
return 'drift';
|
|
222
225
|
if (edytor.intentSerial === this.#serial && (this.#snapBack(dom) || this.#jump()))
|
|
223
226
|
return 'drift';
|
|
@@ -231,9 +234,13 @@ export class Projector {
|
|
|
231
234
|
* The browser parks a caret of its own, at the host's start: the editor
|
|
232
235
|
* focused its own host (`takeKeys`: the keys after a gesture on its
|
|
233
236
|
* chrome), or a key the attempt refused for want of a target
|
|
234
|
-
* (`targetless`: Chromium places a caret for it)
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
+
* (`targetless`: Chromium places a caret for it), or an atom took a press
|
|
238
|
+
* (`InlineBlock.attach`: Chromium parks one for it before the release).
|
|
239
|
+
* Until the next gesture that caret is drift, displayed over by the value —
|
|
240
|
+
* a block selection, an atom or none shows no DOM range — never adopted;
|
|
241
|
+
* under none or an atom, until a press inside or a focus from outside
|
|
242
|
+
* (`pressed`), an adopted move or our own display, whatever key or release
|
|
243
|
+
* came since.
|
|
237
244
|
*/
|
|
238
245
|
parked = () => {
|
|
239
246
|
this.#parked = this.edytor.intentSerial;
|
|
@@ -369,7 +376,9 @@ export class Projector {
|
|
|
369
376
|
// A block set or an atom shows as selected elements, not a range.
|
|
370
377
|
// Displayed even when the DOM already holds no range (the atom's
|
|
371
378
|
// own pointerdown cleared it): a caret the browser parks later
|
|
372
|
-
// without a gesture (focusing the host) is then drift, not intent
|
|
379
|
+
// without a gesture (focusing the host) is then drift, not intent;
|
|
380
|
+
// the one it parks for the atom's press is drift through its release
|
|
381
|
+
// (`parked`).
|
|
373
382
|
const inside = Boolean(dom.anchorNode && node.contains(dom.anchorNode));
|
|
374
383
|
if ((inside || dom.rangeCount === 0) && this.#ours(requested)) {
|
|
375
384
|
if (inside)
|