@quillmark/svelte 0.32.0 → 0.34.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 +73 -1
- package/THEMING.md +11 -10
- package/dist/core/codec/anchor.d.ts +12 -0
- package/dist/core/codec/anchor.js +39 -0
- package/dist/core/codec/drag-move.d.ts +11 -0
- package/dist/core/codec/drag-move.js +143 -0
- package/dist/core/codec/encode.d.ts +2 -1
- package/dist/core/codec/encode.js +16 -6
- package/dist/core/codec/field.d.ts +47 -1
- package/dist/core/codec/field.js +201 -37
- package/dist/core/codec/index.d.ts +8 -2
- package/dist/core/codec/index.js +9 -2
- package/dist/core/codec/islands.d.ts +4 -1
- package/dist/core/codec/islands.js +6 -0
- package/dist/core/codec/keymap.d.ts +3 -0
- package/dist/core/codec/keymap.js +13 -12
- package/dist/core/codec/leave.d.ts +17 -0
- package/dist/core/codec/leave.js +78 -0
- package/dist/core/codec/prose.css +217 -0
- package/dist/core/codec/review-diff.d.ts +12 -0
- package/dist/core/codec/review-diff.js +131 -0
- package/dist/core/codec/review.d.ts +131 -0
- package/dist/core/codec/review.js +1077 -0
- package/dist/core/codec/shortcuts.d.ts +20 -4
- package/dist/core/codec/shortcuts.js +27 -7
- package/dist/core/codec/slash.d.ts +3 -0
- package/dist/core/codec/slash.js +2 -1
- package/dist/core/codec/table-view.js +163 -25
- package/dist/core/codec/undo.d.ts +6 -0
- package/dist/core/codec/undo.js +25 -2
- package/dist/core/dragfollow.d.ts +18 -0
- package/dist/core/dragfollow.js +63 -0
- package/dist/core/theme.css +36 -7
- package/dist/preview/controller.js +16 -0
- package/dist/preview/strings.d.ts +4 -0
- package/dist/preview/strings.js +3 -1
- package/dist/visual/ArrayField.svelte +363 -57
- package/dist/visual/ArrayField.svelte.d.ts +5 -0
- package/dist/visual/BooleanField.svelte +60 -5
- package/dist/visual/BooleanField.svelte.d.ts +2 -1
- package/dist/visual/Card.svelte +27 -17
- package/dist/visual/CardControls.svelte +17 -7
- package/dist/visual/CardControls.svelte.d.ts +2 -0
- package/dist/visual/DateField.svelte +90 -39
- package/dist/visual/DateField.svelte.d.ts +2 -2
- package/dist/visual/Field.svelte +126 -6
- package/dist/visual/FieldHint.svelte +24 -9
- package/dist/visual/FieldLabel.svelte +128 -22
- package/dist/visual/FieldLabel.svelte.d.ts +9 -0
- package/dist/visual/FormatPopover.svelte +125 -20
- package/dist/visual/MatrixAdd.svelte +13 -6
- package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
- package/dist/visual/MatrixField.svelte +36 -8
- package/dist/visual/NumberField.svelte +27 -6
- package/dist/visual/NumberField.svelte.d.ts +3 -0
- package/dist/visual/ObjectField.svelte +25 -1
- package/dist/visual/ObjectField.svelte.d.ts +6 -0
- package/dist/visual/ProseField.svelte +23 -0
- package/dist/visual/ProseField.svelte.d.ts +3 -0
- package/dist/visual/ProseValue.svelte +107 -17
- package/dist/visual/ProseValue.svelte.d.ts +18 -4
- package/dist/visual/ReviewPopover.svelte +179 -0
- package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
- package/dist/visual/ReviewProposal.svelte +149 -0
- package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
- package/dist/visual/ReviewRows.svelte +68 -0
- package/dist/visual/ReviewRows.svelte.d.ts +11 -0
- package/dist/visual/SlashMenu.svelte +13 -1
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/VisualEditor.svelte +23 -0
- package/dist/visual/VisualEditor.svelte.d.ts +7 -0
- package/dist/visual/VisualEditorInner.svelte +671 -22
- package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
- package/dist/visual/controls.css +17 -2
- package/dist/visual/guidance.d.ts +12 -0
- package/dist/visual/guidance.js +37 -2
- package/dist/visual/icons/nodes.d.ts +14 -2
- package/dist/visual/icons/nodes.js +12 -1
- package/dist/visual/index.d.ts +6 -0
- package/dist/visual/index.js +2 -0
- package/dist/visual/listhistory.d.ts +36 -0
- package/dist/visual/listhistory.js +53 -0
- package/dist/visual/proposals.d.ts +40 -0
- package/dist/visual/proposals.js +219 -0
- package/dist/visual/props.d.ts +35 -0
- package/dist/visual/removed.d.ts +20 -0
- package/dist/visual/removed.js +30 -0
- package/dist/visual/review.d.ts +170 -0
- package/dist/visual/review.js +269 -0
- package/dist/visual/review.svelte.d.ts +106 -0
- package/dist/visual/review.svelte.js +356 -0
- package/dist/visual/rowdrag.svelte.js +44 -55
- package/dist/visual/strings.d.ts +48 -7
- package/dist/visual/strings.js +32 -7
- package/dist/visual/structure.d.ts +5 -0
- package/dist/visual/structure.js +1 -1
- package/dist/visual/undo.svelte.d.ts +40 -7
- package/dist/visual/undo.svelte.js +98 -25
- package/package.json +1 -1
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_SHORTCUT_STRINGS, DEFAULT_SLASH_STRINGS, DEFAULT_TABLE_STRINGS } from '../core/codec/index.js';
|
|
21
|
+
import { DEFAULT_LEAVE_STRINGS, DEFAULT_REVIEW_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
|
|
@@ -31,22 +31,45 @@ export function chord(key, platform = typeof navigator === 'undefined' ? '' : na
|
|
|
31
31
|
return `${shift ? '⇧' : ''}⌘${bare}`;
|
|
32
32
|
return `Ctrl+${shift ? 'Shift+' : ''}${bare}`;
|
|
33
33
|
}
|
|
34
|
+
/** An `Alt` chord as the writer's platform prints it: `⌥↑` on Apple's, `Alt+↑` elsewhere,
|
|
35
|
+
* on the test {@link chord} reads. */
|
|
36
|
+
export function alt(key, platform = typeof navigator === 'undefined' ? '' : navigator.platform) {
|
|
37
|
+
return /Mac|iP(hone|[oa]d)/.test(platform) ? `⌥${key}` : `Alt+${key}`;
|
|
38
|
+
}
|
|
34
39
|
/** The package's English. Every key, so the merge below is total. */
|
|
35
40
|
export const DEFAULT_VISUAL_STRINGS = {
|
|
36
41
|
...DEFAULT_TABLE_STRINGS,
|
|
37
42
|
...DEFAULT_SLASH_STRINGS,
|
|
38
43
|
...DEFAULT_SHORTCUT_STRINGS,
|
|
44
|
+
...DEFAULT_LEAVE_STRINGS,
|
|
39
45
|
cardMoveUp: 'Move up',
|
|
40
46
|
cardMoveDown: 'Move down',
|
|
41
47
|
cardDelete: 'Delete card',
|
|
42
48
|
cardTitle: 'Card title',
|
|
49
|
+
cardAction: (action, card) => `${action}, ${card}`,
|
|
43
50
|
groupFlagged: ', has an issue',
|
|
51
|
+
groupReviewed: ', has changes to review',
|
|
52
|
+
...DEFAULT_REVIEW_STRINGS,
|
|
53
|
+
reviewAcceptTitle: `Accept (${chord('↵')})`,
|
|
54
|
+
reviewDismissTitle: `Dismiss (${chord('.')})`,
|
|
55
|
+
reviewUndo: 'Undo',
|
|
56
|
+
reviewUndoTitle: `Undo (${chord('.')})`,
|
|
57
|
+
reviewChange: 'Change',
|
|
58
|
+
reviewAccepted: 'Change accepted',
|
|
59
|
+
reviewWas: 'Was',
|
|
60
|
+
reviewAdded: 'Added',
|
|
61
|
+
reviewRemoved: 'Removed',
|
|
62
|
+
reviewEmpty: 'Empty',
|
|
63
|
+
reviewOn: 'On',
|
|
64
|
+
reviewOff: 'Off',
|
|
44
65
|
undoRemoved: (what) => `${what} removed`,
|
|
45
66
|
undoAction: 'Undo',
|
|
46
|
-
|
|
67
|
+
undoRestore: (what) => `Restore ${what}`,
|
|
68
|
+
addCard: 'Add card',
|
|
47
69
|
arrayAdd: '+ Add',
|
|
48
70
|
arrayRemove: 'Remove',
|
|
49
|
-
arrayDrag:
|
|
71
|
+
arrayDrag: `Drag to move (${alt('↑/↓')})`,
|
|
72
|
+
arrayStanding: 'Add an item…',
|
|
50
73
|
arrayRowAction: (action, row) => `${action} ${row}`,
|
|
51
74
|
arrayCount: (count, max) => `${count} / ${max}`,
|
|
52
75
|
textCount: (count, max) => `${count} / ${max}`,
|
|
@@ -60,20 +83,22 @@ export const DEFAULT_VISUAL_STRINGS = {
|
|
|
60
83
|
? 'Needs a number, like 12.'
|
|
61
84
|
: `Needs a ${expected} value.`,
|
|
62
85
|
diagFormatViolation: (format) => format === 'date'
|
|
63
|
-
? 'Not a real date.
|
|
86
|
+
? 'Not a real date. Check the day and month, or press Today.'
|
|
64
87
|
: format === 'datetime'
|
|
65
|
-
? 'Not a real date and time.
|
|
88
|
+
? 'Not a real date and time. Check the day, month and time.'
|
|
66
89
|
: `Doesn't match the ${format} format.`,
|
|
90
|
+
fieldDefault: 'Default',
|
|
91
|
+
fieldReset: 'Reset',
|
|
67
92
|
enumUnsetTag: 'Default',
|
|
68
93
|
enumReset: 'Reset to default',
|
|
69
94
|
enumClear: 'Clear',
|
|
70
|
-
matrixHeld: (held, total) => `${held} of ${total}
|
|
95
|
+
matrixHeld: (held, total) => `${held} of ${total} selected`,
|
|
71
96
|
matrixAdd: (list) => (list ? `Add to ${list}…` : 'Add…'),
|
|
72
97
|
matrixItemTitle: (list, index) => `${list ? `${list} item` : 'Item'} ${index}`,
|
|
73
98
|
matrixRemove: (title) => `Remove ${title}`,
|
|
74
99
|
dateToday: 'Today',
|
|
75
100
|
optionalGhost: 'None',
|
|
76
|
-
proseHeld:
|
|
101
|
+
proseHeld: "This field has formatting it can't edit here. It is kept as it is.",
|
|
77
102
|
formatGroup: 'Formatting',
|
|
78
103
|
formatBold: `Bold (${chord('B')})`,
|
|
79
104
|
formatEmphasis: `Italic (${chord('I')})`,
|
|
@@ -252,6 +252,11 @@ export declare function schemaAt(field: QuillFieldSchema, steps: readonly PathSt
|
|
|
252
252
|
* Whether a cell is one line tall by declaration: what a table column can hold.
|
|
253
253
|
*/
|
|
254
254
|
export declare function shortCell(sub: QuillFieldSchema): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* The words of the first one-line `text` or `richtext` cell in declaration order, picked by schema
|
|
257
|
+
* alone so one cell names an instance whatever the others hold.
|
|
258
|
+
*/
|
|
259
|
+
export declare function firstShortText(cells: Record<string, QuillFieldSchema> | undefined, values: Record<string, unknown>): string | undefined;
|
|
255
260
|
/** How an `array` draws its elements. */
|
|
256
261
|
export type ArrayLayout = 'list' | 'table';
|
|
257
262
|
/**
|
package/dist/visual/structure.js
CHANGED
|
@@ -375,7 +375,7 @@ export function shortCell(sub) {
|
|
|
375
375
|
* The words of the first one-line `text` or `richtext` cell in declaration order, picked by schema
|
|
376
376
|
* alone so one cell names an instance whatever the others hold.
|
|
377
377
|
*/
|
|
378
|
-
function firstShortText(cells, values) {
|
|
378
|
+
export function firstShortText(cells, values) {
|
|
379
379
|
const named = Object.entries(cells ?? {}).find(([, sub]) => {
|
|
380
380
|
const kind = controlKind(sub);
|
|
381
381
|
return kind === 'text' || (kind === 'prose' && shortCell(sub));
|
|
@@ -7,25 +7,58 @@ export interface UndoOffer {
|
|
|
7
7
|
/** Put back what the removal took. Runs at most once. */
|
|
8
8
|
readonly restore: () => void;
|
|
9
9
|
}
|
|
10
|
+
/** A removal whose step is kept for the session. */
|
|
11
|
+
export interface KeptStep {
|
|
12
|
+
/** What the standing control says, already worded: `Restore Findings`. */
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** Put back what the removal took. Runs at most once. */
|
|
15
|
+
readonly restore: () => void;
|
|
16
|
+
}
|
|
17
|
+
/** How a step is held past its toast. */
|
|
18
|
+
export interface Hold {
|
|
19
|
+
/** A standing step: the key is its in a text control too, and the next edit drops it. */
|
|
20
|
+
readonly standing?: boolean;
|
|
21
|
+
/** A card's step: kept under this label, whatever lands after. */
|
|
22
|
+
readonly keptAs?: string;
|
|
23
|
+
/** Held for the key alone, with no toast: a standing step whose way back is the key. */
|
|
24
|
+
readonly quiet?: boolean;
|
|
25
|
+
/** A review answer's step, standing: an answer is no edit, so it holds the card's step it
|
|
26
|
+
* was offered over, which is the key's again once the answer is taken back. */
|
|
27
|
+
readonly answer?: boolean;
|
|
28
|
+
}
|
|
10
29
|
export interface StructuralUndo {
|
|
11
30
|
/** The offer on show, if any. */
|
|
12
31
|
readonly current: UndoOffer | undefined;
|
|
13
|
-
/**
|
|
14
|
-
|
|
32
|
+
/** The newest kept step, if any. */
|
|
33
|
+
readonly kept: KeptStep | undefined;
|
|
34
|
+
/** Offer `restore` as the undo of the step just made, replacing any standing offer. With
|
|
35
|
+
* a `hold`, the key stays the step's past its toast, until {@link settle}. Returns the
|
|
36
|
+
* offer, for {@link holds}. */
|
|
37
|
+
offer(notice: string, restore: () => void, hold?: Hold): UndoOffer;
|
|
38
|
+
/** An edit landed: a held step is no longer the last thing that happened. A standing one
|
|
39
|
+
* goes, and a kept one answers to its control alone once its offer has. */
|
|
40
|
+
settle(): void;
|
|
15
41
|
/** Name the control the removal handed the focus to. ⌘Z there is the offer's until the
|
|
16
42
|
* control takes an edit or the focus leaves it: the key that removed is the key that
|
|
17
43
|
* asks for it back, and the control has nothing of its own to undo yet. */
|
|
18
44
|
hand(el: Element | null): void;
|
|
19
|
-
/** Whether ⌘Z pressed at `target` is
|
|
20
|
-
*
|
|
21
|
-
*
|
|
45
|
+
/** Whether ⌘Z pressed at `target` is this undo's: there is an offer, or a held step no
|
|
46
|
+
* edit has landed since, and the target is the page's body, where a removal under the
|
|
47
|
+
* pointer leaves the focus, when this editor offered last on the page; the handed
|
|
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. */
|
|
22
50
|
accepts(target: EventTarget | null, root: Element | undefined): boolean;
|
|
23
51
|
/** Hold the lapse while the toast is under the pointer or the focus, and let it run again. */
|
|
24
52
|
pause(): void;
|
|
25
53
|
resume(): void;
|
|
26
|
-
/**
|
|
54
|
+
/** Whether `offer` is the one the key would take, on its toast or held past it. */
|
|
55
|
+
holds(offer: UndoOffer | undefined): boolean;
|
|
56
|
+
/** Run the standing offer, or with none the held step, and clear it. False when there
|
|
57
|
+
* was nothing to run. */
|
|
27
58
|
take(): boolean;
|
|
28
|
-
/**
|
|
59
|
+
/** Run the newest kept step, whatever offer stands. False when none is kept. */
|
|
60
|
+
takeKept(): boolean;
|
|
61
|
+
/** Drop the standing offer or the held step without running it, unless it is kept. */
|
|
29
62
|
withdraw(): void;
|
|
30
63
|
}
|
|
31
64
|
export declare function createStructuralUndo(): StructuralUndo & {
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
// The structural undo:
|
|
1
|
+
// The structural undo: the step back for a removal, offered on a toast.
|
|
2
2
|
//
|
|
3
3
|
// A leaf's text has its own history (`core/codec/field.ts`), so a keystroke is undone where
|
|
4
4
|
// it was typed. A removal has no leaf left to hold one: the card or the row it took is gone
|
|
5
5
|
// from the tree, and with it every history that could have restored it. So the surface keeps
|
|
6
|
-
// the step itself
|
|
6
|
+
// the step itself and offers it where the removal happened.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
8
|
+
// An offer is the latest step's, and one deep: a second replaces the first, and the toast
|
|
9
|
+
// lapses on its own after a while, the while holding as long as the toast is under the
|
|
10
|
+
// pointer or the focus. A row's step goes with its offer, its list's own history being what
|
|
11
|
+
// holds it after: the restore reinserts at the index the removal left, so any other
|
|
12
|
+
// structural edit withdraws it.
|
|
13
13
|
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// Two steps are held past their toast, each the last thing that happened to the document
|
|
15
|
+
// until the next edit lands, and ⌘Z is theirs until then.
|
|
16
|
+
//
|
|
17
|
+
// A card's step is kept for the session, because nothing else holds a card: its restore
|
|
18
|
+
// names the neighbours it left rather than an index, so no later edit unseats it, and the
|
|
19
|
+
// surface draws the newest kept step as a standing control. Past the next edit the control
|
|
20
|
+
// is the way back, so the key never brings back a card the user has since worked past.
|
|
21
|
+
//
|
|
22
|
+
// A standing step rides the same toast and the same key: the review answers since the
|
|
23
|
+
// reader's last edit, which land outside every leaf's history. ⌘Z anywhere in the editor is
|
|
24
|
+
// its, a text leaf's own included. Its restore is good against the document it was offered
|
|
25
|
+
// over and no other, so the next edit drops it, toast and all. It is made by no edit, so it
|
|
26
|
+
// holds a card's step it was offered over: taking the answer back leaves the card's the last
|
|
27
|
+
// thing that happened again.
|
|
28
|
+
//
|
|
29
|
+
// The key listens on the document, not on the surface: a removal by the pointer takes the
|
|
30
|
+
// pressed button with it and leaves the focus on the page's body, which no keydown on the
|
|
31
|
+
// surface hears.
|
|
17
32
|
import { getContext, setContext } from 'svelte';
|
|
18
33
|
/** How long an offer stands, in ms. Long enough to read the toast and reach its button;
|
|
19
34
|
* short enough that the toast is gone before the user has moved on to something else. */
|
|
@@ -23,7 +38,10 @@ const EDITABLE = 'input, textarea, select, [contenteditable="true"]';
|
|
|
23
38
|
* editors with an offer standing, the key at the body is the one that offered last's. */
|
|
24
39
|
let latest;
|
|
25
40
|
export function createStructuralUndo() {
|
|
26
|
-
let current = $state();
|
|
41
|
+
let current = $state.raw();
|
|
42
|
+
let kept = $state.raw([]);
|
|
43
|
+
/** The held step no edit has landed since: the key's, on its toast or past it. */
|
|
44
|
+
let last;
|
|
27
45
|
let handed;
|
|
28
46
|
let timer;
|
|
29
47
|
let paused = false;
|
|
@@ -32,24 +50,53 @@ export function createStructuralUndo() {
|
|
|
32
50
|
clearTimeout(timer);
|
|
33
51
|
timer = undefined;
|
|
34
52
|
};
|
|
35
|
-
const
|
|
36
|
-
timer = setTimeout(clear, OFFER_MS);
|
|
37
|
-
};
|
|
38
|
-
const clear = () => {
|
|
53
|
+
const lower = () => {
|
|
39
54
|
stop();
|
|
40
55
|
paused = false;
|
|
41
56
|
handed = undefined;
|
|
42
57
|
current = undefined;
|
|
43
58
|
};
|
|
59
|
+
const lapse = () => {
|
|
60
|
+
timer = setTimeout(lower, OFFER_MS);
|
|
61
|
+
};
|
|
62
|
+
const clear = () => {
|
|
63
|
+
lower();
|
|
64
|
+
last = undefined;
|
|
65
|
+
};
|
|
66
|
+
/** The step the key would take. */
|
|
67
|
+
const live = () => current ?? last?.offer;
|
|
68
|
+
const stepOf = (offer) => offer && kept.find((step) => step.restore === offer.restore);
|
|
69
|
+
const run = (step) => {
|
|
70
|
+
kept = kept.filter((k) => k !== step);
|
|
71
|
+
step.restore();
|
|
72
|
+
};
|
|
44
73
|
const self = {
|
|
45
74
|
get current() {
|
|
46
75
|
return current;
|
|
47
76
|
},
|
|
48
|
-
|
|
77
|
+
get kept() {
|
|
78
|
+
return kept.at(-1);
|
|
79
|
+
},
|
|
80
|
+
offer(notice, restore, { standing = false, keptAs, quiet = false, answer = false } = {}) {
|
|
81
|
+
const under = answer ? (last?.standing ? last.under : last) : undefined;
|
|
49
82
|
clear();
|
|
50
|
-
|
|
83
|
+
const offer = { notice, restore };
|
|
84
|
+
if (keptAs !== undefined)
|
|
85
|
+
kept = [...kept, { label: keptAs, restore }];
|
|
86
|
+
if (standing || keptAs !== undefined)
|
|
87
|
+
last = { offer, standing, under };
|
|
51
88
|
latest = self;
|
|
89
|
+
if (quiet)
|
|
90
|
+
return offer;
|
|
91
|
+
current = offer;
|
|
52
92
|
lapse();
|
|
93
|
+
return offer;
|
|
94
|
+
},
|
|
95
|
+
settle() {
|
|
96
|
+
if (last?.standing)
|
|
97
|
+
clear();
|
|
98
|
+
else
|
|
99
|
+
last = undefined;
|
|
53
100
|
},
|
|
54
101
|
hand(el) {
|
|
55
102
|
if (!current || !el)
|
|
@@ -65,13 +112,13 @@ export function createStructuralUndo() {
|
|
|
65
112
|
el.addEventListener('focusout', release);
|
|
66
113
|
},
|
|
67
114
|
accepts(target, root) {
|
|
68
|
-
if (!
|
|
115
|
+
if (!live() || !(target instanceof Element))
|
|
69
116
|
return false;
|
|
70
117
|
if (target === document.body)
|
|
71
118
|
return latest === self;
|
|
72
119
|
if (target === handed)
|
|
73
120
|
return true;
|
|
74
|
-
return !!root?.contains(target) && !target.closest(EDITABLE);
|
|
121
|
+
return !!root?.contains(target) && (!!last?.standing || !target.closest(EDITABLE));
|
|
75
122
|
},
|
|
76
123
|
pause() {
|
|
77
124
|
if (!current || paused)
|
|
@@ -85,16 +132,38 @@ export function createStructuralUndo() {
|
|
|
85
132
|
paused = false;
|
|
86
133
|
lapse();
|
|
87
134
|
},
|
|
135
|
+
holds: (offer) => !!offer && live() === offer,
|
|
88
136
|
take() {
|
|
89
|
-
const offer =
|
|
90
|
-
clear();
|
|
137
|
+
const offer = live();
|
|
91
138
|
if (!offer)
|
|
92
139
|
return false;
|
|
93
|
-
offer
|
|
140
|
+
const step = stepOf(offer);
|
|
141
|
+
const under = last?.standing && last.offer === offer ? last.under : undefined;
|
|
142
|
+
clear();
|
|
143
|
+
last = under && stepOf(under.offer) ? under : undefined;
|
|
144
|
+
if (step)
|
|
145
|
+
run(step);
|
|
146
|
+
else
|
|
147
|
+
offer.restore();
|
|
148
|
+
return true;
|
|
149
|
+
},
|
|
150
|
+
takeKept() {
|
|
151
|
+
const step = kept.at(-1);
|
|
152
|
+
if (!step)
|
|
153
|
+
return false;
|
|
154
|
+
if (stepOf(live()) === step)
|
|
155
|
+
clear();
|
|
156
|
+
run(step);
|
|
94
157
|
return true;
|
|
95
158
|
},
|
|
96
|
-
withdraw
|
|
97
|
-
|
|
159
|
+
withdraw() {
|
|
160
|
+
if (!stepOf(live()))
|
|
161
|
+
clear();
|
|
162
|
+
},
|
|
163
|
+
dispose() {
|
|
164
|
+
clear();
|
|
165
|
+
kept = [];
|
|
166
|
+
}
|
|
98
167
|
};
|
|
99
168
|
return self;
|
|
100
169
|
}
|
|
@@ -105,12 +174,16 @@ export function setStructuralUndo(undo) {
|
|
|
105
174
|
/** What a component rendered outside the editor gets: no offer, so it removes as it always did. */
|
|
106
175
|
const NO_UNDO = {
|
|
107
176
|
current: undefined,
|
|
108
|
-
|
|
177
|
+
kept: undefined,
|
|
178
|
+
offer: (notice, restore) => ({ notice, restore }),
|
|
179
|
+
settle() { },
|
|
109
180
|
hand() { },
|
|
110
181
|
accepts: () => false,
|
|
111
182
|
pause() { },
|
|
112
183
|
resume() { },
|
|
184
|
+
holds: () => false,
|
|
113
185
|
take: () => false,
|
|
186
|
+
takeKept: () => false,
|
|
114
187
|
withdraw() { }
|
|
115
188
|
};
|
|
116
189
|
/** The editor's undo, or {@link NO_UNDO} off-tree. */
|