@aionbuilders/nabu 0.1.0-alpha.9 → 0.1.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/CHANGELOG.md +523 -0
- package/LICENSE +21 -0
- package/README.md +82 -144
- package/dist/behaviors/text/RichText.svelte +25 -2
- package/dist/behaviors/text/index.d.ts +2 -0
- package/dist/behaviors/text/index.js +2 -0
- package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +5 -0
- package/dist/behaviors/text/markdown-shortcuts.extension.js +79 -0
- package/dist/behaviors/text/markdown-syntax.d.ts +42 -0
- package/dist/behaviors/text/markdown-syntax.js +81 -0
- package/dist/behaviors/text/rich-text.extension.d.ts +3 -0
- package/dist/behaviors/text/rich-text.extension.js +135 -53
- package/dist/behaviors/text/text.behavior.svelte.d.ts +217 -42
- package/dist/behaviors/text/text.behavior.svelte.js +657 -55
- package/dist/behaviors/text/typography.extension.d.ts +7 -0
- package/dist/behaviors/text/typography.extension.js +25 -0
- package/dist/blocks/Block.svelte +5 -2
- package/dist/blocks/BlockList.svelte +48 -0
- package/dist/blocks/BlockList.svelte.d.ts +17 -0
- package/dist/blocks/Nabu.svelte +180 -14
- package/dist/blocks/Nabu.svelte.d.ts +13 -0
- package/dist/blocks/block.extension.d.ts +3 -0
- package/dist/blocks/block.extension.js +8 -9
- package/dist/blocks/block.svelte.d.ts +356 -68
- package/dist/blocks/block.svelte.js +388 -42
- package/dist/blocks/blockquote/Blockquote.svelte +39 -0
- package/dist/blocks/blockquote/Blockquote.svelte.d.ts +11 -0
- package/dist/blocks/blockquote/blockquote.extension.d.ts +4 -0
- package/dist/blocks/blockquote/blockquote.extension.js +80 -0
- package/dist/blocks/blockquote/blockquote.svelte.d.ts +63 -0
- package/dist/blocks/blockquote/blockquote.svelte.js +136 -0
- package/dist/blocks/blockquote/index.d.ts +3 -0
- package/dist/blocks/blockquote/index.js +3 -0
- package/dist/blocks/callout/Callout.svelte +67 -0
- package/dist/blocks/callout/Callout.svelte.d.ts +11 -0
- package/dist/blocks/callout/callout.extension.d.ts +4 -0
- package/dist/blocks/callout/callout.extension.js +84 -0
- package/dist/blocks/callout/callout.svelte.d.ts +80 -0
- package/dist/blocks/callout/callout.svelte.js +189 -0
- package/dist/blocks/callout/index.d.ts +3 -0
- package/dist/blocks/callout/index.js +3 -0
- package/dist/blocks/chunks.d.ts +49 -0
- package/dist/blocks/chunks.js +90 -0
- package/dist/blocks/code/Code.svelte +84 -0
- package/dist/blocks/code/Code.svelte.d.ts +11 -0
- package/dist/blocks/code/code.extension.d.ts +4 -0
- package/dist/blocks/code/code.extension.js +88 -0
- package/dist/blocks/code/code.svelte.d.ts +68 -0
- package/dist/blocks/code/code.svelte.js +245 -0
- package/dist/blocks/code/index.d.ts +3 -0
- package/dist/blocks/code/index.js +3 -0
- package/dist/blocks/container.utils.d.ts +85 -13
- package/dist/blocks/container.utils.js +338 -178
- package/dist/blocks/dialogue/Dialogue.svelte +8 -2
- package/dist/blocks/dialogue/dialogue.svelte.d.ts +36 -23
- package/dist/blocks/dialogue/dialogue.svelte.js +51 -45
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +2 -2
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +6 -4
- package/dist/blocks/dialogue/index.d.ts +12 -1
- package/dist/blocks/dialogue/index.js +51 -35
- package/dist/blocks/divider/Divider.svelte +28 -0
- package/dist/blocks/divider/Divider.svelte.d.ts +11 -0
- package/dist/blocks/divider/divider.extension.d.ts +23 -0
- package/dist/blocks/divider/divider.extension.js +153 -0
- package/dist/blocks/divider/divider.svelte.d.ts +54 -0
- package/dist/blocks/divider/divider.svelte.js +89 -0
- package/dist/blocks/divider/index.d.ts +3 -0
- package/dist/blocks/divider/index.js +3 -0
- package/dist/blocks/file/File.svelte +56 -0
- package/dist/blocks/file/File.svelte.d.ts +11 -0
- package/dist/blocks/file/file.extension.d.ts +4 -0
- package/dist/blocks/file/file.extension.js +27 -0
- package/dist/blocks/file/file.svelte.d.ts +29 -0
- package/dist/blocks/file/file.svelte.js +77 -0
- package/dist/blocks/file/index.d.ts +3 -0
- package/dist/blocks/file/index.js +3 -0
- package/dist/blocks/heading/Heading.svelte +2 -1
- package/dist/blocks/heading/heading.svelte.d.ts +27 -34
- package/dist/blocks/heading/heading.svelte.js +72 -60
- package/dist/blocks/heading/hooks/onBeforeInput.hook.js +7 -5
- package/dist/blocks/heading/index.d.ts +2 -2
- package/dist/blocks/heading/index.js +33 -8
- package/dist/blocks/image/Image.svelte +41 -0
- package/dist/blocks/image/Image.svelte.d.ts +11 -0
- package/dist/blocks/image/image.extension.d.ts +5 -0
- package/dist/blocks/image/image.extension.js +34 -0
- package/dist/blocks/image/image.svelte.d.ts +61 -0
- package/dist/blocks/image/image.svelte.js +114 -0
- package/dist/blocks/image/index.d.ts +3 -0
- package/dist/blocks/image/index.js +3 -0
- package/dist/blocks/index.d.ts +11 -1
- package/dist/blocks/index.js +11 -1
- package/dist/blocks/list/List.svelte +9 -2
- package/dist/blocks/list/ListItem.svelte +44 -7
- package/dist/blocks/list/convert.d.ts +20 -0
- package/dist/blocks/list/convert.js +92 -0
- package/dist/blocks/list/hooks/onBeforeInput.hook.js +60 -26
- package/dist/blocks/list/html-flat.d.ts +78 -0
- package/dist/blocks/list/html-flat.js +244 -0
- package/dist/blocks/list/indent.d.ts +86 -0
- package/dist/blocks/list/indent.js +205 -0
- package/dist/blocks/list/index.d.ts +7 -3
- package/dist/blocks/list/index.js +43 -31
- package/dist/blocks/list/list-item.svelte.d.ts +43 -17
- package/dist/blocks/list/list-item.svelte.js +143 -93
- package/dist/blocks/list/list.behavior.svelte.d.ts +7 -4
- package/dist/blocks/list/list.behavior.svelte.js +10 -5
- package/dist/blocks/list/list.svelte.d.ts +101 -23
- package/dist/blocks/list/list.svelte.js +136 -114
- package/dist/blocks/list/markdown.d.ts +149 -0
- package/dist/blocks/list/markdown.js +442 -0
- package/dist/blocks/list/normalize.d.ts +11 -0
- package/dist/blocks/list/normalize.js +396 -0
- package/dist/blocks/list/paste.d.ts +45 -0
- package/dist/blocks/list/paste.js +242 -0
- package/dist/blocks/list/step-back.d.ts +24 -0
- package/dist/blocks/list/step-back.js +87 -0
- package/dist/blocks/list/to-list.d.ts +7 -0
- package/dist/blocks/list/to-list.js +44 -0
- package/dist/blocks/list/todos-toggle.d.ts +20 -0
- package/dist/blocks/list/todos-toggle.js +48 -0
- package/dist/blocks/list/todos.svelte.d.ts +35 -0
- package/dist/blocks/list/todos.svelte.js +76 -0
- package/dist/blocks/media/index.d.ts +2 -0
- package/dist/blocks/media/index.js +2 -0
- package/dist/blocks/media/markdown.d.ts +12 -0
- package/dist/blocks/media/markdown.js +26 -0
- package/dist/blocks/media/media-block.svelte.d.ts +107 -0
- package/dist/blocks/media/media-block.svelte.js +181 -0
- package/dist/blocks/media/media.helpers.d.ts +24 -0
- package/dist/blocks/media/media.helpers.js +88 -0
- package/dist/blocks/megablock.svelte.d.ts +50 -19
- package/dist/blocks/megablock.svelte.js +115 -74
- package/dist/blocks/move.d.ts +23 -0
- package/dist/blocks/move.js +92 -0
- package/dist/blocks/nabu.svelte.d.ts +846 -75
- package/dist/blocks/nabu.svelte.js +1990 -182
- package/dist/blocks/paragraph/Paragraph.svelte +1 -0
- package/dist/blocks/paragraph/index.d.ts +2 -2
- package/dist/blocks/paragraph/index.js +35 -16
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +49 -35
- package/dist/blocks/paragraph/paragraph.svelte.js +81 -69
- package/dist/blocks/paragraph/table.html.d.ts +9 -0
- package/dist/blocks/paragraph/table.html.js +111 -0
- package/dist/blocks/paragraph/table.markdown.d.ts +32 -0
- package/dist/blocks/paragraph/table.markdown.js +90 -0
- package/dist/blocks/region/Region.svelte +264 -0
- package/dist/blocks/region/Region.svelte.d.ts +11 -0
- package/dist/blocks/region/actions.d.ts +135 -0
- package/dist/blocks/region/actions.js +402 -0
- package/dist/blocks/region/close.d.ts +35 -0
- package/dist/blocks/region/close.js +130 -0
- package/dist/blocks/region/commands.d.ts +6 -0
- package/dist/blocks/region/commands.js +277 -0
- package/dist/blocks/region/create.d.ts +72 -0
- package/dist/blocks/region/create.js +208 -0
- package/dist/blocks/region/end-marker.d.ts +35 -0
- package/dist/blocks/region/end-marker.js +51 -0
- package/dist/blocks/region/facts.d.ts +69 -0
- package/dist/blocks/region/facts.js +152 -0
- package/dist/blocks/region/format.d.ts +91 -0
- package/dist/blocks/region/format.js +260 -0
- package/dist/blocks/region/index.d.ts +14 -0
- package/dist/blocks/region/index.js +14 -0
- package/dist/blocks/region/insert.d.ts +59 -0
- package/dist/blocks/region/insert.js +102 -0
- package/dist/blocks/region/messages.d.ts +254 -0
- package/dist/blocks/region/messages.js +131 -0
- package/dist/blocks/region/normalize.d.ts +7 -0
- package/dist/blocks/region/normalize.js +170 -0
- package/dist/blocks/region/region.extension.d.ts +58 -0
- package/dist/blocks/region/region.extension.js +119 -0
- package/dist/blocks/region/region.svelte.d.ts +221 -0
- package/dist/blocks/region/region.svelte.js +582 -0
- package/dist/blocks/region/regions.svelte.d.ts +141 -0
- package/dist/blocks/region/regions.svelte.js +276 -0
- package/dist/blocks/region/serialize.d.ts +57 -0
- package/dist/blocks/region/serialize.js +112 -0
- package/dist/blocks/region/types.d.ts +255 -0
- package/dist/blocks/region/types.js +204 -0
- package/dist/blocks/selection.svelte.d.ts +106 -8
- package/dist/blocks/selection.svelte.js +632 -74
- package/dist/blocks/subthread.d.ts +80 -0
- package/dist/blocks/subthread.js +167 -0
- package/dist/blocks/text-block.svelte.d.ts +70 -0
- package/dist/blocks/text-block.svelte.js +108 -0
- package/dist/blocks/toggle/Toggle.svelte +73 -0
- package/dist/blocks/toggle/Toggle.svelte.d.ts +11 -0
- package/dist/blocks/toggle/index.d.ts +3 -0
- package/dist/blocks/toggle/index.js +3 -0
- package/dist/blocks/toggle/markdown.d.ts +20 -0
- package/dist/blocks/toggle/markdown.js +112 -0
- package/dist/blocks/toggle/toggle.extension.d.ts +4 -0
- package/dist/blocks/toggle/toggle.extension.js +18 -0
- package/dist/blocks/toggle/toggle.svelte.d.ts +135 -0
- package/dist/blocks/toggle/toggle.svelte.js +352 -0
- package/dist/blocks/undo-selection.d.ts +175 -0
- package/dist/blocks/undo-selection.js +360 -0
- package/dist/blocks/video/Video.svelte +42 -0
- package/dist/blocks/video/Video.svelte.d.ts +11 -0
- package/dist/blocks/video/index.d.ts +3 -0
- package/dist/blocks/video/index.js +3 -0
- package/dist/blocks/video/video.extension.d.ts +4 -0
- package/dist/blocks/video/video.extension.js +27 -0
- package/dist/blocks/video/video.svelte.d.ts +29 -0
- package/dist/blocks/video/video.svelte.js +80 -0
- package/dist/extend.d.ts +55 -0
- package/dist/extend.js +88 -0
- package/dist/files/assets.clipboard.d.ts +77 -0
- package/dist/files/assets.clipboard.js +152 -0
- package/dist/files/files.svelte.d.ts +363 -0
- package/dist/files/files.svelte.js +897 -0
- package/dist/files/index.d.ts +3 -0
- package/dist/files/index.js +3 -0
- package/dist/files/outbox.d.ts +69 -0
- package/dist/files/outbox.js +48 -0
- package/dist/files/status.d.ts +65 -0
- package/dist/files/status.js +87 -0
- package/dist/files/store.d.ts +97 -0
- package/dist/files/store.js +65 -0
- package/dist/files/uploads.svelte.d.ts +174 -0
- package/dist/files/uploads.svelte.js +504 -0
- package/dist/index.d.ts +68 -6
- package/dist/index.js +117 -7
- package/dist/nabu-theme.css +112 -0
- package/dist/paste/html.paste.d.ts +74 -3
- package/dist/paste/html.paste.js +555 -83
- package/dist/paste/markdown-inline.d.ts +86 -0
- package/dist/paste/markdown-inline.js +528 -0
- package/dist/paste/markdown.paste.d.ts +2 -8
- package/dist/paste/markdown.paste.js +78 -94
- package/dist/paste/nabu.paste.d.ts +3 -0
- package/dist/paste/nabu.paste.js +29 -3
- package/dist/paste/plain-text.paste.d.ts +2 -2
- package/dist/paste/plain-text.paste.js +3 -3
- package/dist/persistence/asset-store.d.ts +51 -0
- package/dist/persistence/asset-store.js +103 -0
- package/dist/persistence/autosave.d.ts +53 -0
- package/dist/persistence/autosave.js +62 -0
- package/dist/persistence/compact.d.ts +162 -0
- package/dist/persistence/compact.js +141 -0
- package/dist/persistence/history.d.ts +77 -0
- package/dist/persistence/history.js +176 -0
- package/dist/persistence/indexeddb.d.ts +190 -4
- package/dist/persistence/indexeddb.js +333 -29
- package/dist/persistence/merge.d.ts +38 -0
- package/dist/persistence/merge.js +36 -0
- package/dist/persistence/outbox.d.ts +25 -0
- package/dist/persistence/outbox.js +40 -0
- package/dist/persistence/persistence.d.ts +70 -9
- package/dist/persistence/persistence.js +507 -35
- package/dist/persistence/recovery.d.ts +79 -0
- package/dist/persistence/recovery.js +79 -0
- package/dist/persistence/release.d.ts +34 -0
- package/dist/persistence/release.js +64 -0
- package/dist/persistence/state.svelte.d.ts +53 -0
- package/dist/persistence/state.svelte.js +48 -0
- package/dist/persistence/sync.d.ts +39 -0
- package/dist/persistence/sync.js +138 -0
- package/dist/persistence/tail.d.ts +42 -0
- package/dist/persistence/tail.js +103 -0
- package/dist/presets.d.ts +29 -24
- package/dist/presets.js +51 -14
- package/dist/themes/atelier.css +318 -0
- package/dist/ui/CommandChooser.svelte +153 -0
- package/dist/ui/CommandChooser.svelte.d.ts +13 -0
- package/dist/ui/CommandInvite.svelte +99 -0
- package/dist/ui/CommandInvite.svelte.d.ts +12 -0
- package/dist/ui/DragHandle.svelte +217 -0
- package/dist/ui/DragHandle.svelte.d.ts +11 -0
- package/dist/ui/FloatingToolbar.svelte +165 -0
- package/dist/ui/FloatingToolbar.svelte.d.ts +27 -0
- package/dist/ui/SlashMenu.svelte +215 -0
- package/dist/ui/SlashMenu.svelte.d.ts +33 -0
- package/dist/ui/anchor.d.ts +112 -0
- package/dist/ui/anchor.js +136 -0
- package/dist/ui/index.d.ts +10 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/slash-menu.svelte.d.ts +112 -0
- package/dist/ui/slash-menu.svelte.js +150 -0
- package/dist/utils/command-confirm.svelte.d.ts +349 -0
- package/dist/utils/command-confirm.svelte.js +673 -0
- package/dist/utils/commands.d.ts +328 -0
- package/dist/utils/commands.js +416 -0
- package/dist/utils/dom-scope.d.ts +14 -0
- package/dist/utils/dom-scope.js +20 -0
- package/dist/utils/drop.d.ts +160 -0
- package/dist/utils/drop.js +305 -0
- package/dist/utils/extensions.d.ts +488 -40
- package/dist/utils/extensions.js +300 -19
- package/dist/utils/html.d.ts +44 -0
- package/dist/utils/html.js +183 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/keys.d.ts +120 -0
- package/dist/utils/keys.js +248 -0
- package/dist/utils/links.d.ts +22 -0
- package/dist/utils/links.js +34 -0
- package/dist/utils/placeholders.d.ts +88 -0
- package/dist/utils/placeholders.js +91 -0
- package/dist/utils/selection.svelte.d.ts +47 -19
- package/dist/utils/selection.svelte.js +60 -10
- package/dist/utils/spellcheck.d.ts +9 -0
- package/dist/utils/spellcheck.js +17 -0
- package/dist/utils/tab.d.ts +31 -0
- package/dist/utils/tab.js +117 -0
- package/dist/utils/words.d.ts +7 -0
- package/dist/utils/words.js +62 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +34 -0
- package/package.json +61 -22
- package/dist/blocks/zone/Zone.svelte +0 -258
- package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
- package/dist/blocks/zone/index.d.ts +0 -2
- package/dist/blocks/zone/index.js +0 -2
- package/dist/blocks/zone/zone.extension.d.ts +0 -2
- package/dist/blocks/zone/zone.extension.js +0 -221
- package/dist/blocks/zone/zone.svelte.d.ts +0 -112
- package/dist/blocks/zone/zone.svelte.js +0 -321
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The known groups of the slash menu, in display order. A group is a free string: an unknown one is listed after these (in the
|
|
3
|
+
* order its first entry is met), and an entry without a group comes last.
|
|
4
|
+
* @type {readonly string[]}
|
|
5
|
+
*/
|
|
6
|
+
export const SLASH_GROUP_ORDER = ['text', 'lists', 'blocks', 'media', 'structure'];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} SlashCommand
|
|
10
|
+
* An entry of the slash menu: a title, optional subtitle, icon and aliases to filter on, a group and order for sorting, an optional
|
|
11
|
+
* `when` to limit where it is offered, and the action to run. Extensions contribute theirs with `slashCommands`.
|
|
12
|
+
* @property {string} title
|
|
13
|
+
* @property {string} [subtitle]
|
|
14
|
+
* @property {string} [icon] A short text glyph (no emoji in the library's own entries). A theme or an integrator overrides an
|
|
15
|
+
* entry's icon by providing its own entry (`commands` of `SlashMenu`, or `slashCommands` of an extension).
|
|
16
|
+
* @property {string[]} [aliases]
|
|
17
|
+
* @property {'text' | 'lists' | 'blocks' | 'media' | 'structure' | (string & {})} [group] Where the entry is listed. Known
|
|
18
|
+
* groups, in display order: `text`, `lists`, `blocks`, `media`, `structure`; any other string is a group of its own listed
|
|
19
|
+
* after them; no group = last.
|
|
20
|
+
* @property {number} [order] Position inside the group (ascending, default 0); ties keep the declaration order. The menu's
|
|
21
|
+
* order never depends on the load order of the extensions.
|
|
22
|
+
* @property {(engine: import('../blocks/nabu.svelte.js').Nabu, block: any) => boolean} [when]
|
|
23
|
+
* Where the entry applies; `block` is the block holding the caret. Without it the entry is always offered.
|
|
24
|
+
* @property {(engine: import('../blocks/nabu.svelte.js').Nabu) => void} run
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stable sort of slash entries: group (known order, then other groups by first appearance, then ungrouped), then `order`, then
|
|
29
|
+
* declaration order. Returns a new array.
|
|
30
|
+
* @param {SlashCommand[]} commands
|
|
31
|
+
* @returns {SlashCommand[]}
|
|
32
|
+
*/
|
|
33
|
+
export function sortSlashCommands(commands) {
|
|
34
|
+
/** @type {Map<string, number>} */
|
|
35
|
+
const rank = new Map(SLASH_GROUP_ORDER.map((g, i) => [g, i]));
|
|
36
|
+
const groupRank = (/** @type {SlashCommand} */ c) => {
|
|
37
|
+
if (!c.group) return Infinity;
|
|
38
|
+
if (!rank.has(c.group)) rank.set(c.group, rank.size);
|
|
39
|
+
return /** @type {number} */ (rank.get(c.group));
|
|
40
|
+
};
|
|
41
|
+
return commands
|
|
42
|
+
.map((c, i) => ({ c, i, g: groupRank(c) }))
|
|
43
|
+
.sort((a, b) => (a.g === b.g ? 0 : a.g < b.g ? -1 : 1) || (a.c.order ?? 0) - (b.c.order ?? 0) || a.i - b.i)
|
|
44
|
+
.map((x) => x.c);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Filter slash commands by a query. Titles match by SUBSTRING (`/head` -> "Heading 1"), aliases
|
|
49
|
+
* by PREFIX (`/bul` -> "Bulleted list" via "bullet"); a substring alias match would make `/ul`
|
|
50
|
+
* also hit Divider through its "r-ul-e" alias. Case-insensitive; an empty query keeps everything.
|
|
51
|
+
* @param {SlashCommand[]} commands @param {string} query
|
|
52
|
+
* @returns {SlashCommand[]}
|
|
53
|
+
*/
|
|
54
|
+
export function filterSlashCommands(commands, query) {
|
|
55
|
+
const q = query.toLowerCase();
|
|
56
|
+
if (!q) return commands;
|
|
57
|
+
return commands.filter(c =>
|
|
58
|
+
c.title.toLowerCase().includes(q) ||
|
|
59
|
+
(c.aliases || []).some(a => a.toLowerCase().startsWith(q)));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The state of the "/" menu for one editor: whether it is open, the query typed after the slash, the filtered and sorted entries
|
|
64
|
+
* and the selected one. `SlashMenu` is its default rendering; use it directly to build your own menu.
|
|
65
|
+
*/
|
|
66
|
+
export class SlashMenuController {
|
|
67
|
+
/** @type {import('../blocks/nabu.svelte.js').Nabu} */
|
|
68
|
+
#engine;
|
|
69
|
+
/**
|
|
70
|
+
* @param {import('../blocks/nabu.svelte.js').Nabu} engine
|
|
71
|
+
* @param {SlashCommand[]} [commands] EXTRA entries of the integrator, added to the ones the loaded extensions contribute
|
|
72
|
+
* (`Extension#slashCommands`, collected in `engine.slashCommands`) and sorted with them. The menu has no entry of its own.
|
|
73
|
+
*/
|
|
74
|
+
constructor(engine, commands) { this.#engine = engine; this.commands = commands ?? []; }
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The pending slash trigger at the caret: its block, where the slash starts, the caret and the query typed after it; `null` when there is none.
|
|
78
|
+
* @type {{ block: any, slashStart: number, cursor: number, query: string } | null}
|
|
79
|
+
*/
|
|
80
|
+
match = $derived.by(() => {
|
|
81
|
+
const sel = this.#engine.selection;
|
|
82
|
+
const block = sel?.anchorBlock;
|
|
83
|
+
if (!block) return null;
|
|
84
|
+
const beh = block.behaviors?.get('text');
|
|
85
|
+
const bsel = beh?.selection;
|
|
86
|
+
if (!beh || !bsel || !bsel.isCollapsed) return null;
|
|
87
|
+
const before = beh.text.slice(0, bsel.from);
|
|
88
|
+
// "/" at block start OR after whitespace, then non-space chars = the query
|
|
89
|
+
const m = before.match(/(?:^|\s)\/(\S*)$/);
|
|
90
|
+
if (!m) return null;
|
|
91
|
+
const query = m[1];
|
|
92
|
+
return { block, slashStart: bsel.from - query.length - 1, cursor: bsel.from, query };
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/** The text typed after the slash (empty when no trigger). */
|
|
96
|
+
query = $derived(this.match?.query ?? '');
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The entries of the loaded extensions plus the integrator's extras that apply at the caret (`when`), in the documented
|
|
100
|
+
* order (group, `order`, declaration order).
|
|
101
|
+
*/
|
|
102
|
+
available = $derived.by(() => {
|
|
103
|
+
const block = this.match?.block;
|
|
104
|
+
const applies = (/** @type {SlashCommand} */ c) => {
|
|
105
|
+
if (typeof c.when !== 'function') return true;
|
|
106
|
+
try { return !!block && !!c.when(this.#engine, block); } catch { return false; }
|
|
107
|
+
};
|
|
108
|
+
return sortSlashCommands([...(this.#engine.slashCommands ?? []), ...this.commands].filter(applies));
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/** The available entries matching the query: titles by substring, aliases by prefix. */
|
|
112
|
+
filteredItems = $derived.by(() => {
|
|
113
|
+
if (!this.match) return [];
|
|
114
|
+
return filterSlashCommands(this.available, this.query);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/** @type {number | null} slashStart of a dismissed (Escape) trigger */
|
|
118
|
+
#dismissedKey = $state(null);
|
|
119
|
+
|
|
120
|
+
/** Whether the menu should be shown: a trigger at the caret, at least one match, not dismissed, not read-only. */
|
|
121
|
+
open = $derived.by(() => !this.#engine.readonly && !!this.match && this.filteredItems.length > 0 && this.match.slashStart !== this.#dismissedKey);
|
|
122
|
+
|
|
123
|
+
/** Index of the highlighted entry in `filteredItems`. */
|
|
124
|
+
selectedIndex = $state(0);
|
|
125
|
+
|
|
126
|
+
/** Move the highlight by `delta` entries, wrapping around. @param {number} delta */
|
|
127
|
+
moveSelection(delta) {
|
|
128
|
+
const n = this.filteredItems.length;
|
|
129
|
+
if (!n) return;
|
|
130
|
+
this.selectedIndex = (this.selectedIndex + delta + n) % n;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Run the command at the given index (default: the selected one). @param {number} [index] */
|
|
134
|
+
async select(index) {
|
|
135
|
+
const item = this.filteredItems[index ?? this.selectedIndex];
|
|
136
|
+
const m = this.match;
|
|
137
|
+
if (!item || !m) return;
|
|
138
|
+
const beh = m.block.behaviors?.get('text');
|
|
139
|
+
if (beh) beh.delete({ index: m.slashStart, length: m.cursor - m.slashStart });
|
|
140
|
+
await this.#engine.commit();
|
|
141
|
+
this.#engine.selection.setCursor(m.block, m.slashStart);
|
|
142
|
+
// The command reads selection.anchorBlock: don't wait for the async `selectionchange`.
|
|
143
|
+
this.#engine.selection.sync?.();
|
|
144
|
+
this.close();
|
|
145
|
+
item.run(this.#engine);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Dismiss the menu for the current trigger position (Escape). */
|
|
149
|
+
close() { this.#dismissedKey = this.match?.slashStart ?? null; }
|
|
150
|
+
}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DOM element standing for a confirmation target: a block (its `element`) or an element. `null` when it has none (yet).
|
|
3
|
+
* @param {any} target
|
|
4
|
+
* @returns {HTMLElement | null}
|
|
5
|
+
*/
|
|
6
|
+
export function commandTargetElement(target: any): HTMLElement | null;
|
|
7
|
+
/** Default duration of a `hold`, in milliseconds. */
|
|
8
|
+
export const DEFAULT_HOLD_MS: 700;
|
|
9
|
+
/** Default time an `invite` waits for its second press, in milliseconds. */
|
|
10
|
+
export const DEFAULT_INVITE_MS: 5000;
|
|
11
|
+
/**
|
|
12
|
+
* Time source of the controller (injectable, so that tests drive a fake clock).
|
|
13
|
+
* @typedef {Object} ConfirmClock
|
|
14
|
+
* @property {() => number} now monotonic milliseconds
|
|
15
|
+
* @property {(fn: () => void, ms: number) => () => void} timeout run `fn` once after `ms`; returns the canceller
|
|
16
|
+
* @property {(fn: () => void) => () => void} frame run `fn` before the next paint (animation frame); returns the canceller
|
|
17
|
+
*/
|
|
18
|
+
/** @type {ConfirmClock} */
|
|
19
|
+
export const REAL_CLOCK: ConfirmClock;
|
|
20
|
+
/**
|
|
21
|
+
* What is waiting for the user, as `nabu.pendingCommand`. The reference changes when a confirmation starts or ends; `progress`
|
|
22
|
+
* and `selectedIndex` are reactive fields of it.
|
|
23
|
+
*
|
|
24
|
+
* @typedef {Object} PendingOption
|
|
25
|
+
* @property {string} id the command id (a tie) or the variant id (explicit `choose`)
|
|
26
|
+
* @property {string} label
|
|
27
|
+
* @property {string} display shortcut (a tie) or hint (explicit `choose`) to show next to the label; may be empty
|
|
28
|
+
* @property {string} [group] explicit `choose` only: the title of the group the option belongs to. Consecutive options with the
|
|
29
|
+
* same `group` are shown under one small header; options without one stay ungrouped.
|
|
30
|
+
* @property {string} [detail] explicit `choose` only: a short muted text shown right-aligned in the option (a number, a hint)
|
|
31
|
+
*/
|
|
32
|
+
export class PendingCommand {
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} init
|
|
35
|
+
* @param {string} init.id
|
|
36
|
+
* @param {'hold' | 'invite' | 'choose'} init.strategy
|
|
37
|
+
* @param {string} init.label
|
|
38
|
+
* @param {string} init.display
|
|
39
|
+
* @param {string} init.message
|
|
40
|
+
* @param {any} [init.target]
|
|
41
|
+
* @param {PendingOption[]} [init.options]
|
|
42
|
+
* @param {string} [init.footer]
|
|
43
|
+
*/
|
|
44
|
+
constructor({ id, strategy, label, display, message, target, options, footer }: {
|
|
45
|
+
id: string;
|
|
46
|
+
strategy: "hold" | "invite" | "choose";
|
|
47
|
+
label: string;
|
|
48
|
+
display: string;
|
|
49
|
+
message: string;
|
|
50
|
+
target?: any;
|
|
51
|
+
options?: PendingOption[] | undefined;
|
|
52
|
+
footer?: string | undefined;
|
|
53
|
+
});
|
|
54
|
+
/** command id (`choose:<chord>` for a tie) */
|
|
55
|
+
id: string;
|
|
56
|
+
strategy: "hold" | "invite" | "choose";
|
|
57
|
+
/** label of the command (resolved with the context of the key press) */
|
|
58
|
+
label: string;
|
|
59
|
+
/** the shortcut that started it, formatted for the platform (`'Ctrl+Shift+Backspace'`, `'⇧⌘⌫'`) */
|
|
60
|
+
display: string;
|
|
61
|
+
/** the prompt, i18n-resolved: the text of the live region and of the default hint */
|
|
62
|
+
message: string;
|
|
63
|
+
/** what the confirmation is about (`hold`: `confirm.target(ctx)`, usually a block); `undefined` when none */
|
|
64
|
+
target: any;
|
|
65
|
+
/** `choose` only */
|
|
66
|
+
options: PendingOption[] | undefined;
|
|
67
|
+
/** `choose` only: a short hint shown under the options (`confirm.footer`); empty when none */
|
|
68
|
+
footer: string;
|
|
69
|
+
/** `hold`: 0 → 1 over `holdMs` */
|
|
70
|
+
progress: number;
|
|
71
|
+
/** `choose`: the highlighted option */
|
|
72
|
+
selectedIndex: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Texts of the prompts and the outcomes. Each value is a string or a function of the given parameters; override them for all
|
|
76
|
+
* commands with the `commandConfirm.messages` init option, or per command with `confirm.messages` (partial objects).
|
|
77
|
+
* @typedef {Object} ConfirmMessages
|
|
78
|
+
* @property {string | ((p: { keys: string, label: string }) => string)} [hold] prompt of a hold
|
|
79
|
+
* @property {string | ((p: { keys: string, label: string }) => string)} [invite] prompt of an invite
|
|
80
|
+
* @property {string | ((p: { keys: string, label: string, options: PendingOption[] }) => string)} [choose] prompt of a chooser
|
|
81
|
+
* @property {string | ((p: { option: PendingOption, index: number, count: number }) => string)} [option] the highlighted option
|
|
82
|
+
* @property {string | ((p: { label: string }) => string)} [done] after the command ran
|
|
83
|
+
* @property {string | ((p: { label: string }) => string)} [cancelled] after a release / Escape / timeout
|
|
84
|
+
*/
|
|
85
|
+
/** @type {Required<ConfirmMessages>} */
|
|
86
|
+
export const DEFAULT_MESSAGES: Required<ConfirmMessages>;
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {Object} Session
|
|
89
|
+
* @property {PendingCommand} pending
|
|
90
|
+
* @property {'hold' | 'invite' | 'choose'} strategy
|
|
91
|
+
* @property {CommandEntry | null} entry the command (a tie / `choose` with variants: the explicit command or `null`)
|
|
92
|
+
* @property {CommandContext} ctx context of the key press that started it
|
|
93
|
+
* @property {string} chord canonical id of the chord that started it
|
|
94
|
+
* @property {ReturnType<typeof eventChord>} chordInfo
|
|
95
|
+
* @property {string} code physical key of the press (`event.code`)
|
|
96
|
+
* @property {boolean} [waiting] `hold` opened from code: nobody holds the key yet; the count starts at the user's press
|
|
97
|
+
* @property {number} startedAt
|
|
98
|
+
* @property {number} ms `hold`: duration; `invite`: timeout
|
|
99
|
+
* @property {(() => void) | null} stopTimer
|
|
100
|
+
* @property {Array<{ id: string, label: string, display: string, group?: string, detail?: string, run: () => void }>} [choices] `choose`
|
|
101
|
+
* @property {{ selection: [Node | null, number, Node | null, number] } | null} dom selection when it started
|
|
102
|
+
*/
|
|
103
|
+
export class CommandConfirmation {
|
|
104
|
+
/** @param {Nabu} nabu @param {CommandConfirmOptions} [options] */
|
|
105
|
+
constructor(nabu: Nabu, { holdMs, inviteMs, messages, clock }?: CommandConfirmOptions);
|
|
106
|
+
/** What is waiting for the user (`nabu.pendingCommand`), reactive; `null` when nothing is. @returns {PendingCommand | null} */
|
|
107
|
+
get pending(): PendingCommand | null;
|
|
108
|
+
/** Whether the keys must go through {@link CommandConfirmation#handleKeydown}: something is pending, or the key of a completed hold is still down. */
|
|
109
|
+
get busy(): boolean;
|
|
110
|
+
/** The text of the polite live region: the last prompt or outcome (reactive). */
|
|
111
|
+
get announcement(): string;
|
|
112
|
+
/** The pending confirmation when it is about `target` (reactive), else `null`. @param {any} target @returns {PendingCommand | null} */
|
|
113
|
+
pendingOn(target: any): PendingCommand | null;
|
|
114
|
+
/**
|
|
115
|
+
* A key press selected `entry`, which has a `confirm` strategy. Returns whether the key was consumed (it always is, unless
|
|
116
|
+
* the strategy cannot start). The registry has already checked `when`.
|
|
117
|
+
* @param {CommandEntry} entry
|
|
118
|
+
* @param {CommandContext} ctx
|
|
119
|
+
* @param {KeyboardEvent} event
|
|
120
|
+
* @returns {boolean}
|
|
121
|
+
*/
|
|
122
|
+
begin(entry: CommandEntry, ctx: CommandContext, event: KeyboardEvent): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Several commands apply to the key: let the user pick (§3.4c).
|
|
125
|
+
* @param {CommandEntry[]} ties
|
|
126
|
+
* @param {CommandContext} ctx
|
|
127
|
+
* @param {KeyboardEvent} event
|
|
128
|
+
* @returns {boolean}
|
|
129
|
+
*/
|
|
130
|
+
beginTie(ties: CommandEntry[], ctx: CommandContext, event: KeyboardEvent): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Open the confirmation of a command WITHOUT a key press (a typed trigger, a menu, a button, an input rule): the same
|
|
133
|
+
* prompt a key would open (`nabu.pendingCommand`, the `CommandInvite` / `CommandChooser` components, the keyboard handling,
|
|
134
|
+
* the cancellations). The command's `when` is checked. Prefer the public `nabu.commands.offer(id)`, which also runs a command
|
|
135
|
+
* that has no confirmation.
|
|
136
|
+
*
|
|
137
|
+
* - `choose`: the options come from `confirm.options(ctx)`, the choice runs `run(nabu, ctx, option)`;
|
|
138
|
+
* - `invite`: asks to press the command's first key again (`invite` timeout);
|
|
139
|
+
* - `hold`: asks to hold the command's first key; the count starts at the user's press and the confirmation lapses after the
|
|
140
|
+
* `invite` timeout when no key comes.
|
|
141
|
+
*
|
|
142
|
+
* `hold` and `invite` need a key to confirm with: a command with no key (disabled by the `keymap`) opens nothing.
|
|
143
|
+
* Returns false (nothing opens) when the command does not exist, has no confirmation, does not apply, or offers no option.
|
|
144
|
+
* @param {string} id command id
|
|
145
|
+
* @param {CommandContext} [context] default: the current context
|
|
146
|
+
* @returns {boolean}
|
|
147
|
+
*/
|
|
148
|
+
offer(id: string, context?: CommandContext): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Every key press goes through here before the command resolution, while a confirmation is pending (or the key of a completed
|
|
151
|
+
* hold is still down). Returns `true` when the key is consumed (`preventDefault` already called); `false` lets the registry go
|
|
152
|
+
* on, which is what an unrelated key must get after it cancelled the confirmation ("the key acts normally").
|
|
153
|
+
* @param {KeyboardEvent} event
|
|
154
|
+
* @returns {boolean}
|
|
155
|
+
*/
|
|
156
|
+
handleKeydown(event: KeyboardEvent): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Move the highlight of a pending `choose` (the chooser component calls it on hover).
|
|
159
|
+
* @param {number} index
|
|
160
|
+
*/
|
|
161
|
+
highlight(index: number): void;
|
|
162
|
+
/**
|
|
163
|
+
* Run option `index` of a pending `choose` (Enter, a digit, a click).
|
|
164
|
+
* @param {number} index
|
|
165
|
+
* @returns {boolean} whether something ran
|
|
166
|
+
*/
|
|
167
|
+
choose(index: number): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Cancel what is pending (`nabu.cancelPendingCommand()`): nothing runs, no undo step exists. No-op when nothing is pending.
|
|
170
|
+
* @param {string} [reason] `'api'` (default), `'release'`, `'escape'`, `'key'`, `'selection'`, `'click'`, `'blur'`, `'timeout'`
|
|
171
|
+
*/
|
|
172
|
+
cancel(reason?: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* The key of the chord went up: a hold that is not finished is cancelled; the key of a completed hold is free again.
|
|
175
|
+
* Releasing a modifier of the chord counts like releasing its key.
|
|
176
|
+
* @param {KeyboardEvent} event
|
|
177
|
+
*/
|
|
178
|
+
onKeyup(event: KeyboardEvent): void;
|
|
179
|
+
/** The DOM selection moved away from where the confirmation started. */
|
|
180
|
+
onSelectionChange(): void;
|
|
181
|
+
/** A click outside the confirmation's own UI cancels it. @param {Event} event */
|
|
182
|
+
onPointerDown(event: Event): void;
|
|
183
|
+
/** Focus left the editor (window blur, tab switch, a click elsewhere): nothing can be confirmed any more. */
|
|
184
|
+
onBlur(): void;
|
|
185
|
+
/** Attach the document listeners (the editor component calls it through `nabu.systems`). Idempotent. */
|
|
186
|
+
start(): void;
|
|
187
|
+
/** Detach the listeners and drop what is pending. */
|
|
188
|
+
stop(): void;
|
|
189
|
+
#private;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Time source of the controller (injectable, so that tests drive a fake clock).
|
|
193
|
+
*/
|
|
194
|
+
export type ConfirmClock = {
|
|
195
|
+
/**
|
|
196
|
+
* monotonic milliseconds
|
|
197
|
+
*/
|
|
198
|
+
now: () => number;
|
|
199
|
+
/**
|
|
200
|
+
* run `fn` once after `ms`; returns the canceller
|
|
201
|
+
*/
|
|
202
|
+
timeout: (fn: () => void, ms: number) => () => void;
|
|
203
|
+
/**
|
|
204
|
+
* run `fn` before the next paint (animation frame); returns the canceller
|
|
205
|
+
*/
|
|
206
|
+
frame: (fn: () => void) => () => void;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* What is waiting for the user, as `nabu.pendingCommand`. The reference changes when a confirmation starts or ends; `progress`
|
|
210
|
+
* and `selectedIndex` are reactive fields of it.
|
|
211
|
+
*/
|
|
212
|
+
export type PendingOption = {
|
|
213
|
+
/**
|
|
214
|
+
* the command id (a tie) or the variant id (explicit `choose`)
|
|
215
|
+
*/
|
|
216
|
+
id: string;
|
|
217
|
+
label: string;
|
|
218
|
+
/**
|
|
219
|
+
* shortcut (a tie) or hint (explicit `choose`) to show next to the label; may be empty
|
|
220
|
+
*/
|
|
221
|
+
display: string;
|
|
222
|
+
/**
|
|
223
|
+
* explicit `choose` only: the title of the group the option belongs to. Consecutive options with the
|
|
224
|
+
* same `group` are shown under one small header; options without one stay ungrouped.
|
|
225
|
+
*/
|
|
226
|
+
group?: string | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* explicit `choose` only: a short muted text shown right-aligned in the option (a number, a hint)
|
|
229
|
+
*/
|
|
230
|
+
detail?: string | undefined;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Texts of the prompts and the outcomes. Each value is a string or a function of the given parameters; override them for all
|
|
234
|
+
* commands with the `commandConfirm.messages` init option, or per command with `confirm.messages` (partial objects).
|
|
235
|
+
*/
|
|
236
|
+
export type ConfirmMessages = {
|
|
237
|
+
/**
|
|
238
|
+
* prompt of a hold
|
|
239
|
+
*/
|
|
240
|
+
hold?: string | ((p: {
|
|
241
|
+
keys: string;
|
|
242
|
+
label: string;
|
|
243
|
+
}) => string) | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* prompt of an invite
|
|
246
|
+
*/
|
|
247
|
+
invite?: string | ((p: {
|
|
248
|
+
keys: string;
|
|
249
|
+
label: string;
|
|
250
|
+
}) => string) | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* prompt of a chooser
|
|
253
|
+
*/
|
|
254
|
+
choose?: string | ((p: {
|
|
255
|
+
keys: string;
|
|
256
|
+
label: string;
|
|
257
|
+
options: PendingOption[];
|
|
258
|
+
}) => string) | undefined;
|
|
259
|
+
/**
|
|
260
|
+
* the highlighted option
|
|
261
|
+
*/
|
|
262
|
+
option?: string | ((p: {
|
|
263
|
+
option: PendingOption;
|
|
264
|
+
index: number;
|
|
265
|
+
count: number;
|
|
266
|
+
}) => string) | undefined;
|
|
267
|
+
/**
|
|
268
|
+
* after the command ran
|
|
269
|
+
*/
|
|
270
|
+
done?: string | ((p: {
|
|
271
|
+
label: string;
|
|
272
|
+
}) => string) | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* after a release / Escape / timeout
|
|
275
|
+
*/
|
|
276
|
+
cancelled?: string | ((p: {
|
|
277
|
+
label: string;
|
|
278
|
+
}) => string) | undefined;
|
|
279
|
+
};
|
|
280
|
+
export type CommandConfirmOptions = {
|
|
281
|
+
/**
|
|
282
|
+
* default duration of a `hold` (700)
|
|
283
|
+
*/
|
|
284
|
+
holdMs?: number | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* default time an `invite` waits (5000)
|
|
287
|
+
*/
|
|
288
|
+
inviteMs?: number | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* texts, see {@link ConfirmMessages}
|
|
291
|
+
*/
|
|
292
|
+
messages?: ConfirmMessages | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* time source (tests)
|
|
295
|
+
*/
|
|
296
|
+
clock?: ConfirmClock | undefined;
|
|
297
|
+
};
|
|
298
|
+
export type Session = {
|
|
299
|
+
pending: PendingCommand;
|
|
300
|
+
strategy: "hold" | "invite" | "choose";
|
|
301
|
+
/**
|
|
302
|
+
* the command (a tie / `choose` with variants: the explicit command or `null`)
|
|
303
|
+
*/
|
|
304
|
+
entry: CommandEntry | null;
|
|
305
|
+
/**
|
|
306
|
+
* context of the key press that started it
|
|
307
|
+
*/
|
|
308
|
+
ctx: CommandContext;
|
|
309
|
+
/**
|
|
310
|
+
* canonical id of the chord that started it
|
|
311
|
+
*/
|
|
312
|
+
chord: string;
|
|
313
|
+
chordInfo: ReturnType<typeof eventChord>;
|
|
314
|
+
/**
|
|
315
|
+
* physical key of the press (`event.code`)
|
|
316
|
+
*/
|
|
317
|
+
code: string;
|
|
318
|
+
/**
|
|
319
|
+
* `hold` opened from code: nobody holds the key yet; the count starts at the user's press
|
|
320
|
+
*/
|
|
321
|
+
waiting?: boolean | undefined;
|
|
322
|
+
startedAt: number;
|
|
323
|
+
/**
|
|
324
|
+
* `hold`: duration; `invite`: timeout
|
|
325
|
+
*/
|
|
326
|
+
ms: number;
|
|
327
|
+
stopTimer: (() => void) | null;
|
|
328
|
+
/**
|
|
329
|
+
* `choose`
|
|
330
|
+
*/
|
|
331
|
+
choices?: {
|
|
332
|
+
id: string;
|
|
333
|
+
label: string;
|
|
334
|
+
display: string;
|
|
335
|
+
group?: string;
|
|
336
|
+
detail?: string;
|
|
337
|
+
run: () => void;
|
|
338
|
+
}[] | undefined;
|
|
339
|
+
/**
|
|
340
|
+
* selection when it started
|
|
341
|
+
*/
|
|
342
|
+
dom: {
|
|
343
|
+
selection: [Node | null, number, Node | null, number];
|
|
344
|
+
} | null;
|
|
345
|
+
};
|
|
346
|
+
import type { CommandEntry } from './commands.js';
|
|
347
|
+
import type { CommandContext } from './commands.js';
|
|
348
|
+
import type { Nabu } from '../blocks/nabu.svelte.js';
|
|
349
|
+
import { eventChord } from './keys.js';
|