@quillmark/svelte 0.35.1 → 0.36.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.
- package/README.md +21 -13
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/field.d.ts +30 -7
- package/dist/core/codec/field.js +67 -4
- package/dist/core/codec/index.d.ts +6 -3
- package/dist/core/codec/index.js +2 -3
- package/dist/core/codec/prose.css +11 -77
- package/dist/core/codec/review.d.ts +27 -21
- package/dist/core/codec/review.js +87 -148
- package/dist/core/codec/shortcuts.d.ts +3 -3
- package/dist/core/codec/shortcuts.js +7 -7
- package/dist/core/codec/value-diff.d.ts +21 -0
- package/dist/core/codec/value-diff.js +83 -0
- package/dist/core/codec/value-plan.d.ts +29 -0
- package/dist/core/codec/value-plan.js +157 -0
- package/dist/core/theme.css +7 -2
- package/dist/visual/ArrayField.svelte +191 -17
- package/dist/visual/Card.svelte +12 -1
- package/dist/visual/Card.svelte.d.ts +3 -0
- package/dist/visual/EnumField.svelte +14 -4
- package/dist/visual/EnumField.svelte.d.ts +3 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +1 -0
- package/dist/visual/FormatPopover.svelte +1 -0
- package/dist/visual/MatrixField.svelte +43 -5
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +112 -3
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +54 -16
- package/dist/visual/ProseField.svelte +16 -3
- package/dist/visual/ProseField.svelte.d.ts +3 -0
- package/dist/visual/ProseValue.svelte +38 -2
- package/dist/visual/ProseValue.svelte.d.ts +3 -0
- package/dist/visual/ReviewCard.svelte +347 -0
- package/dist/visual/ReviewCard.svelte.d.ts +19 -0
- package/dist/visual/ReviewProposal.svelte +104 -138
- package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
- package/dist/visual/ReviewRows.svelte +6 -25
- package/dist/visual/ReviewRows.svelte.d.ts +1 -3
- package/dist/visual/SlashMenu.svelte +1 -0
- package/dist/visual/VariantField.svelte +44 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +16 -7
- package/dist/visual/VisualEditor.svelte.d.ts +3 -0
- package/dist/visual/VisualEditorInner.svelte +840 -115
- package/dist/visual/VisualEditorInner.svelte.d.ts +3 -0
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +13 -22
- package/dist/visual/proposals.js +69 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review.d.ts +68 -3
- package/dist/visual/review.js +36 -1
- package/dist/visual/review.svelte.d.ts +55 -15
- package/dist/visual/review.svelte.js +156 -42
- package/dist/visual/strings.d.ts +23 -6
- package/dist/visual/strings.js +10 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- package/package.json +1 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
// The editor's review state: the host's list split by where each item draws, and the one
|
|
2
|
-
//
|
|
1
|
+
// The editor's review state: the host's list split by where each item draws, and the one current
|
|
2
|
+
// item, which the answer card and the review keys answer.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// pointer
|
|
4
|
+
// The current item is sticky: a step, a reveal, a click, the caret arriving in an item, or the
|
|
5
|
+
// pointer resting on one names it, and it stays until another is named or it is answered. The
|
|
6
|
+
// pointer names one only after a dwell, and never while it is over the answer card, so a pointer
|
|
7
|
+
// crossing the text on its way to the card does not move the card from under it.
|
|
7
8
|
//
|
|
8
9
|
// An answered item is drawn no more, from the answer and not from the host's next list: the
|
|
9
10
|
// reader's press shows at once however long the host takes to hand over a list without it.
|
|
10
11
|
import { getContext, setContext } from 'svelte';
|
|
11
12
|
import { SvelteMap } from 'svelte/reactivity';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import { asContent, planValue } from '../core/codec/index.js';
|
|
14
|
+
import { byBlocks, byCard, locate, onField, sameValue, textProposal, valueIn, writesProposed } from './review.js';
|
|
15
|
+
/** How long the pointer rests on an item before it is current, in ms. */
|
|
16
|
+
export const DWELL_MS = 160;
|
|
15
17
|
export function createReview(source) {
|
|
16
18
|
/** The ids answered, each until a list arrives without it. */
|
|
17
19
|
const answered = new Set();
|
|
@@ -44,9 +46,53 @@ export function createReview(source) {
|
|
|
44
46
|
}
|
|
45
47
|
return own;
|
|
46
48
|
});
|
|
49
|
+
/** The card each accepted `add` wrote, by item id. */
|
|
50
|
+
const written = new SvelteMap();
|
|
51
|
+
const cards = $derived.by(() => {
|
|
52
|
+
const listed = source.listedCards();
|
|
53
|
+
const live = source.liveCards();
|
|
54
|
+
const standing = new Set(live);
|
|
55
|
+
const all = source.items() ?? [];
|
|
56
|
+
const adds = new Map();
|
|
57
|
+
const removes = new Map();
|
|
58
|
+
const undrawn = [];
|
|
59
|
+
const open = new Set(items.map((item) => item.id));
|
|
60
|
+
for (const [at, item] of all.entries()) {
|
|
61
|
+
if (!byCard(item) || !open.has(item.id))
|
|
62
|
+
continue;
|
|
63
|
+
if ('remove' in item) {
|
|
64
|
+
const key = listed[item.remove];
|
|
65
|
+
if (key !== undefined && standing.has(key))
|
|
66
|
+
removes.set(key, item);
|
|
67
|
+
else
|
|
68
|
+
undrawn.push({ id: item.id, reason: 'applied' });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const lead = leadOf(all, at, listed, standing);
|
|
72
|
+
adds.set(lead, [...(adds.get(lead) ?? []), item]);
|
|
73
|
+
}
|
|
74
|
+
return { adds, removes, undrawn };
|
|
75
|
+
});
|
|
76
|
+
/** Where the `add` at `at` of `all` stands: after the card the nearest earlier add of the same
|
|
77
|
+
* place wrote, else after the card it names, the head, or the end where that card is gone. */
|
|
78
|
+
function leadOf(all, at, listed, standing) {
|
|
79
|
+
const item = all[at];
|
|
80
|
+
for (let k = at - 1; k >= 0; k--) {
|
|
81
|
+
const before = all[k];
|
|
82
|
+
if (!byCard(before) || !('add' in before) || before.after !== item.after)
|
|
83
|
+
continue;
|
|
84
|
+
const key = written.get(before.id);
|
|
85
|
+
if (key !== undefined && standing.has(key))
|
|
86
|
+
return key;
|
|
87
|
+
}
|
|
88
|
+
if (item.after === undefined || item.after < 0)
|
|
89
|
+
return 'head';
|
|
90
|
+
const key = listed[item.after];
|
|
91
|
+
return key !== undefined && standing.has(key) ? key : 'end';
|
|
92
|
+
}
|
|
47
93
|
const placed = $derived.by(() => {
|
|
48
94
|
const out = new Map();
|
|
49
|
-
const undrawn = [];
|
|
95
|
+
const undrawn = [...cards.undrawn];
|
|
50
96
|
/** The nested proposals whose `before` the field no longer holds. */
|
|
51
97
|
const moved = new Set();
|
|
52
98
|
const claims = new Map();
|
|
@@ -94,7 +140,10 @@ export function createReview(source) {
|
|
|
94
140
|
return { fields: out, undrawn, moved };
|
|
95
141
|
});
|
|
96
142
|
const fields = $derived(placed.fields);
|
|
97
|
-
|
|
143
|
+
/** Each proposal of words a leaf draws, by id: how it stands against what the leaf holds. */
|
|
144
|
+
const carried = new SvelteMap();
|
|
145
|
+
// A proposal made from a value the field no longer holds would write over the reader's. One a
|
|
146
|
+
// leaf of words carries is outdated only where the reader's writing meets it.
|
|
98
147
|
const outdated = $derived.by(() => {
|
|
99
148
|
const out = new Set(placed.moved);
|
|
100
149
|
for (const { proposed } of fields.values())
|
|
@@ -102,22 +151,38 @@ export function createReview(source) {
|
|
|
102
151
|
'before' in proposed &&
|
|
103
152
|
!sameValue(source.valueAt(proposed.field), proposed.before))
|
|
104
153
|
out.add(proposed.id);
|
|
154
|
+
for (const [id, state] of carried)
|
|
155
|
+
if (state === 'outdated')
|
|
156
|
+
out.add(id);
|
|
157
|
+
else
|
|
158
|
+
out.delete(id);
|
|
105
159
|
return out;
|
|
106
160
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
161
|
+
/** The field items no control draws, those a leaf already reads as proposed among them. */
|
|
162
|
+
const undrawnFields = $derived.by(() => {
|
|
163
|
+
const applied = [...carried].filter(([, state]) => state === 'applied');
|
|
164
|
+
if (!applied.length)
|
|
165
|
+
return placed.undrawn;
|
|
166
|
+
return [...placed.undrawn, ...applied.map(([id]) => ({ id, reason: 'applied' }))];
|
|
167
|
+
});
|
|
168
|
+
let current = $state();
|
|
169
|
+
let dwell;
|
|
170
|
+
let overCard = false;
|
|
171
|
+
const lit = $derived(current !== undefined && byId.has(current) ? current : undefined);
|
|
172
|
+
const name = (id) => {
|
|
173
|
+
clearTimeout(dwell);
|
|
174
|
+
current = id;
|
|
175
|
+
};
|
|
176
|
+
const answering = (id, action) => {
|
|
114
177
|
if (action === 'reopen')
|
|
115
178
|
answered.delete(id);
|
|
116
179
|
else
|
|
117
180
|
answered.add(id);
|
|
118
181
|
answers++;
|
|
119
|
-
if (
|
|
120
|
-
|
|
182
|
+
if (action === 'reopen')
|
|
183
|
+
name(id);
|
|
184
|
+
else
|
|
185
|
+
source.answered?.(id, current === id);
|
|
121
186
|
};
|
|
122
187
|
const self = {
|
|
123
188
|
get items() {
|
|
@@ -128,7 +193,7 @@ export function createReview(source) {
|
|
|
128
193
|
return drawn;
|
|
129
194
|
},
|
|
130
195
|
get fieldUndrawn() {
|
|
131
|
-
return
|
|
196
|
+
return undrawnFields;
|
|
132
197
|
},
|
|
133
198
|
get fieldOutdated() {
|
|
134
199
|
return outdated;
|
|
@@ -136,11 +201,26 @@ export function createReview(source) {
|
|
|
136
201
|
get lit() {
|
|
137
202
|
return lit;
|
|
138
203
|
},
|
|
204
|
+
get cards() {
|
|
205
|
+
return cards;
|
|
206
|
+
},
|
|
207
|
+
wrote(id, key) {
|
|
208
|
+
if (key === undefined)
|
|
209
|
+
written.delete(id);
|
|
210
|
+
else
|
|
211
|
+
written.set(id, key);
|
|
212
|
+
},
|
|
213
|
+
current(item) {
|
|
214
|
+
if (source.exact(item.field))
|
|
215
|
+
return source.valueAt(item.field);
|
|
216
|
+
const place = source.nested(item.field);
|
|
217
|
+
return place && valueIn(place.value, place.steps);
|
|
218
|
+
},
|
|
139
219
|
at: (key) => fields.get(key) ?? {},
|
|
140
220
|
marks: (key) => fields.has(key) || !!drawn.get(key)?.ids.length,
|
|
141
221
|
keyOf(id) {
|
|
142
222
|
const item = byId.get(id);
|
|
143
|
-
if (!item)
|
|
223
|
+
if (!item || byCard(item))
|
|
144
224
|
return undefined;
|
|
145
225
|
if (byBlocks(item)) {
|
|
146
226
|
const key = source.leafFor(item.field);
|
|
@@ -159,40 +239,67 @@ export function createReview(source) {
|
|
|
159
239
|
else
|
|
160
240
|
drawn.delete(key);
|
|
161
241
|
},
|
|
162
|
-
point(id, via
|
|
163
|
-
if (via === '
|
|
164
|
-
|
|
242
|
+
point(id, via) {
|
|
243
|
+
if (via === 'caret') {
|
|
244
|
+
if (id !== undefined)
|
|
245
|
+
name(id);
|
|
165
246
|
return;
|
|
166
247
|
}
|
|
167
|
-
|
|
248
|
+
clearTimeout(dwell);
|
|
249
|
+
if (id === undefined || id === current)
|
|
168
250
|
return;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
251
|
+
dwell = setTimeout(() => {
|
|
252
|
+
if (!overCard && byId.has(id))
|
|
253
|
+
current = id;
|
|
254
|
+
}, DWELL_MS);
|
|
173
255
|
},
|
|
174
|
-
act(id, action
|
|
256
|
+
act(id, action) {
|
|
175
257
|
const item = byId.get(id);
|
|
176
258
|
if (!item || !source.answer(id, item, action))
|
|
177
259
|
return false;
|
|
178
|
-
answering(id, action
|
|
260
|
+
answering(id, action);
|
|
179
261
|
return true;
|
|
180
262
|
},
|
|
263
|
+
answerWith(id, value) {
|
|
264
|
+
const item = byId.get(id);
|
|
265
|
+
if (!item || !onField(item))
|
|
266
|
+
return false;
|
|
267
|
+
const action = writesProposed(value, item.after) ? 'accept' : 'dismiss';
|
|
268
|
+
const write = action === 'dismiss' ? { value } : undefined;
|
|
269
|
+
if (!source.answer(id, item, action, undefined, write))
|
|
270
|
+
return false;
|
|
271
|
+
answering(id, action);
|
|
272
|
+
return true;
|
|
273
|
+
},
|
|
274
|
+
planned(id, state) {
|
|
275
|
+
if (state === undefined)
|
|
276
|
+
carried.delete(id);
|
|
277
|
+
else if (carried.get(id) !== state)
|
|
278
|
+
carried.set(id, state);
|
|
279
|
+
},
|
|
280
|
+
writes(item, value) {
|
|
281
|
+
const text = carried.has(item.id) ? textProposal(item) : undefined;
|
|
282
|
+
const live = asContent(value);
|
|
283
|
+
if (!text?.before || !live || item.after === undefined)
|
|
284
|
+
return item.after;
|
|
285
|
+
const { merged } = planValue(text.before, live, text.after);
|
|
286
|
+
if (merged === text.after)
|
|
287
|
+
return item.after;
|
|
288
|
+
return typeof item.after === 'string' ? merged.text : merged;
|
|
289
|
+
},
|
|
181
290
|
writing: (on) => source.writing?.(on),
|
|
182
|
-
heard(id, action, key
|
|
291
|
+
heard(id, action, key) {
|
|
183
292
|
if (source.answer(id, byId.get(id), action, key))
|
|
184
|
-
answering(id, action
|
|
293
|
+
answering(id, action);
|
|
185
294
|
},
|
|
186
|
-
reveal
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
revealed = undefined;
|
|
192
|
-
}, REVEAL_MS);
|
|
295
|
+
reveal: name,
|
|
296
|
+
hoverCard(on) {
|
|
297
|
+
overCard = on;
|
|
298
|
+
if (on)
|
|
299
|
+
clearTimeout(dwell);
|
|
193
300
|
},
|
|
194
301
|
dispose() {
|
|
195
|
-
clearTimeout(
|
|
302
|
+
clearTimeout(dwell);
|
|
196
303
|
}
|
|
197
304
|
};
|
|
198
305
|
return self;
|
|
@@ -210,15 +317,22 @@ const NO_REVIEW = {
|
|
|
210
317
|
fieldUndrawn: [],
|
|
211
318
|
fieldOutdated: new Set(),
|
|
212
319
|
lit: undefined,
|
|
320
|
+
cards: { adds: new Map(), removes: new Map() },
|
|
321
|
+
wrote() { },
|
|
213
322
|
at: () => ({}),
|
|
214
323
|
marks: () => false,
|
|
215
324
|
keyOf: () => undefined,
|
|
216
325
|
drew() { },
|
|
217
326
|
point() { },
|
|
218
327
|
act: () => false,
|
|
328
|
+
answerWith: () => false,
|
|
329
|
+
planned() { },
|
|
330
|
+
current: () => undefined,
|
|
331
|
+
writes: (item) => item.after,
|
|
219
332
|
heard() { },
|
|
220
333
|
writing() { },
|
|
221
|
-
reveal() { }
|
|
334
|
+
reveal() { },
|
|
335
|
+
hoverCard() { }
|
|
222
336
|
};
|
|
223
337
|
/** The editor's review state, or {@link NO_REVIEW} off-tree. */
|
|
224
338
|
export function review() {
|
package/dist/visual/strings.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Diagnostic } from '@quillmark/wasm';
|
|
2
|
-
import { type LeaveStrings, type
|
|
2
|
+
import { type LeaveStrings, type ShortcutStrings, type SlashStrings, type TableChromeStrings } from '../core/codec/index.js';
|
|
3
3
|
import type { BodyPlaceholder } from './structure.js';
|
|
4
4
|
/**
|
|
5
|
-
* The island, the insert menu, the shortcut list and the
|
|
5
|
+
* The island, the insert menu, the shortcut list and the leave hint's keys come from the
|
|
6
6
|
* codec, which owns all four models (a NodeView inside the leaf, the trigger the leaf's keymap
|
|
7
|
-
* drives, the keymaps' own tables, and the
|
|
7
|
+
* drives, the keymaps' own tables, and the plugin that names the way out). Extending
|
|
8
8
|
* rather than restating them is what keeps one English list: a consumer overrides an
|
|
9
9
|
* island handle's name beside the card controls' and the codec still has a default
|
|
10
10
|
* for a leaf mounted directly.
|
|
11
11
|
*/
|
|
12
|
-
export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings, LeaveStrings
|
|
12
|
+
export interface VisualStrings extends TableChromeStrings, SlashStrings, ShortcutStrings, LeaveStrings {
|
|
13
13
|
cardMoveUp: string;
|
|
14
14
|
cardMoveDown: string;
|
|
15
15
|
cardDelete: string;
|
|
@@ -26,10 +26,27 @@ export interface VisualStrings extends TableChromeStrings, SlashStrings, Shortcu
|
|
|
26
26
|
groupFlagged: string;
|
|
27
27
|
/** The same header where a field inside holds an item of review. */
|
|
28
28
|
groupReviewed: string;
|
|
29
|
-
/** The
|
|
30
|
-
|
|
29
|
+
/** The answer card's two buttons. */
|
|
30
|
+
reviewAccept: string;
|
|
31
|
+
reviewDismiss: string;
|
|
32
|
+
/** The answer card's accessible name. */
|
|
33
|
+
reviewProposal: string;
|
|
34
|
+
/** The answer card's note on a change whose place no longer holds what its writer read. */
|
|
35
|
+
reviewOutdated: string;
|
|
36
|
+
/** Where the current change stands in the review and what it is to, for a screen reader:
|
|
37
|
+
* `Change 2 of 5, Subtitle`. `name` is the field's label, the body's, or the card's title
|
|
38
|
+
* after its tag, and empty where nothing names it. */
|
|
39
|
+
reviewPosition: (at: number, of: number, name: string) => string;
|
|
40
|
+
/** The tag on a card proposed new, and the mark on one proposed taken out. */
|
|
41
|
+
reviewNewCard: string;
|
|
42
|
+
reviewRemoveCard: string;
|
|
31
43
|
/** A value that was, or would be, nothing. */
|
|
32
44
|
reviewEmpty: string;
|
|
45
|
+
/** Where a proposal adds a list member past the last, on the answer card. */
|
|
46
|
+
reviewNewItem: string;
|
|
47
|
+
/** A control under a proposal, described to assistive tech beside its name: the value it
|
|
48
|
+
* shows is the proposed one, and `current` the value the field holds now. */
|
|
49
|
+
reviewCurrently: (current: string) => string;
|
|
33
50
|
/** A switch's two values, as a row words them. */
|
|
34
51
|
reviewOn: string;
|
|
35
52
|
reviewOff: string;
|
package/dist/visual/strings.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// would put a `strings` prop on every component between the root and each leaf,
|
|
19
19
|
// which is a prop that means nothing to any of them.
|
|
20
20
|
import { getContext, setContext } from 'svelte';
|
|
21
|
-
import { DEFAULT_LEAVE_STRINGS,
|
|
21
|
+
import { DEFAULT_LEAVE_STRINGS, DEFAULT_SHORTCUT_STRINGS, DEFAULT_SLASH_STRINGS, DEFAULT_TABLE_STRINGS } from '../core/codec/index.js';
|
|
22
22
|
/**
|
|
23
23
|
* A `Mod` chord as the writer's platform prints it: `⌘B` on Apple's, `Ctrl+B`
|
|
24
24
|
* elsewhere, and `Shift-7` as `⇧⌘7` or `Ctrl+Shift+7`. The platform test is the one
|
|
@@ -49,11 +49,16 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
49
49
|
cardAction: (action, card) => `${action}, ${card}`,
|
|
50
50
|
groupFlagged: ', has an issue',
|
|
51
51
|
groupReviewed: ', has changes to review',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
reviewAccept: 'Accept',
|
|
53
|
+
reviewDismiss: 'Dismiss',
|
|
54
|
+
reviewProposal: 'Proposed change',
|
|
55
|
+
reviewOutdated: 'Changed since proposed',
|
|
56
|
+
reviewPosition: (at, of, name) => `Change ${at} of ${of}${name ? `, ${name}` : ''}`,
|
|
57
|
+
reviewNewCard: 'New card',
|
|
58
|
+
reviewRemoveCard: 'Proposed removal',
|
|
56
59
|
reviewEmpty: 'Empty',
|
|
60
|
+
reviewNewItem: 'New item',
|
|
61
|
+
reviewCurrently: (current) => `Proposed change, currently ${current}`,
|
|
57
62
|
reviewOn: 'On',
|
|
58
63
|
reviewOff: 'Off',
|
|
59
64
|
undoRemoved: (what) => `${what} removed`,
|
|
@@ -46,7 +46,9 @@ export interface StructuralUndo {
|
|
|
46
46
|
* edit has landed since, and the target is the page's body, where a removal under the
|
|
47
47
|
* pointer leaves the focus, when this editor offered last on the page; the handed
|
|
48
48
|
* control; or a control under `root` that keeps no history of its own. A text control
|
|
49
|
-
* that is not the handed one keeps its key from a removal and gives it to a standing step.
|
|
49
|
+
* that is not the handed one keeps its key from a removal and gives it to a standing step.
|
|
50
|
+
* The answers' step is the key's too at any target outside `root` but a text control, when
|
|
51
|
+
* this editor offered last. */
|
|
50
52
|
accepts(target: EventTarget | null, root: Element | undefined): boolean;
|
|
51
53
|
/** Hold the lapse while the toast is under the pointer or the focus, and let it run again. */
|
|
52
54
|
pause(): void;
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
//
|
|
29
29
|
// The key listens on the document, not on the surface: a removal by the pointer takes the
|
|
30
30
|
// pressed button with it and leaves the focus on the page's body, which no keydown on the
|
|
31
|
-
// surface hears.
|
|
31
|
+
// surface hears. An answer is given from wherever the focus is, a host's panel beside the
|
|
32
|
+
// editor included, so the answers' step is the key's from anywhere on the page but a text
|
|
33
|
+
// control outside the editor, which keeps its own.
|
|
32
34
|
import { getContext, setContext } from 'svelte';
|
|
33
35
|
/** How long an offer stands, in ms. Long enough to read the toast and reach its button;
|
|
34
36
|
* short enough that the toast is gone before the user has moved on to something else. */
|
|
@@ -84,7 +86,7 @@ export function createStructuralUndo() {
|
|
|
84
86
|
if (keptAs !== undefined)
|
|
85
87
|
kept = [...kept, { label: keptAs, restore }];
|
|
86
88
|
if (standing || keptAs !== undefined)
|
|
87
|
-
last = { offer, standing, under };
|
|
89
|
+
last = { offer, standing, answer, under };
|
|
88
90
|
latest = self;
|
|
89
91
|
if (quiet)
|
|
90
92
|
return offer;
|
|
@@ -118,7 +120,9 @@ export function createStructuralUndo() {
|
|
|
118
120
|
return latest === self;
|
|
119
121
|
if (target === handed)
|
|
120
122
|
return true;
|
|
121
|
-
|
|
123
|
+
if (root?.contains(target))
|
|
124
|
+
return !!last?.standing || !target.closest(EDITABLE);
|
|
125
|
+
return (!!last?.answer && last.offer === live() && latest === self && !target.closest(EDITABLE));
|
|
122
126
|
},
|
|
123
127
|
pause() {
|
|
124
128
|
if (!current || paused)
|