@pixerate/editor 0.23.0 → 0.25.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 +167 -2
- package/THIRD_PARTY_NOTICES.md +80 -0
- package/dist/agent/index.cjs +10 -8
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +4 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +4437 -411
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +934 -4
- package/dist/canvas/index.d.ts +934 -4
- package/dist/canvas/index.js +4309 -283
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-4BVP64JJ.cjs +1406 -0
- package/dist/chunk-4BVP64JJ.cjs.map +1 -0
- package/dist/chunk-664LQYFJ.js +115 -0
- package/dist/chunk-664LQYFJ.js.map +1 -0
- package/dist/chunk-7WISYZFO.cjs +740 -0
- package/dist/chunk-7WISYZFO.cjs.map +1 -0
- package/dist/chunk-AL6JMGWW.cjs +783 -0
- package/dist/chunk-AL6JMGWW.cjs.map +1 -0
- package/dist/chunk-BVP3TSLH.cjs +69 -0
- package/dist/chunk-BVP3TSLH.cjs.map +1 -0
- package/dist/{chunk-RIKBJLS2.cjs → chunk-C7P22VIP.cjs} +2001 -279
- package/dist/chunk-C7P22VIP.cjs.map +1 -0
- package/dist/chunk-D6FH2YAX.cjs +131 -0
- package/dist/chunk-D6FH2YAX.cjs.map +1 -0
- package/dist/chunk-ECCCYKGL.js +740 -0
- package/dist/chunk-ECCCYKGL.js.map +1 -0
- package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
- package/dist/chunk-FD4LPFAE.cjs.map +1 -0
- package/dist/{chunk-QBJ22YZR.js → chunk-FH6F67DN.js} +1999 -277
- package/dist/chunk-FH6F67DN.js.map +1 -0
- package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
- package/dist/chunk-FPENXAEJ.js.map +1 -0
- package/dist/chunk-HLIMTC6N.js +1 -0
- package/dist/chunk-HLIMTC6N.js.map +1 -0
- package/dist/chunk-HRMEDT2L.js +1406 -0
- package/dist/chunk-HRMEDT2L.js.map +1 -0
- package/dist/{chunk-QGHGJ56O.js → chunk-IXHSYOVY.js} +2518 -122
- package/dist/chunk-IXHSYOVY.js.map +1 -0
- package/dist/chunk-MKA3AHLV.cjs +256 -0
- package/dist/chunk-MKA3AHLV.cjs.map +1 -0
- package/dist/chunk-NAXVVS5I.js +783 -0
- package/dist/chunk-NAXVVS5I.js.map +1 -0
- package/dist/chunk-O5RYH2PG.js +69 -0
- package/dist/chunk-O5RYH2PG.js.map +1 -0
- package/dist/chunk-OXSV64JX.js +689 -0
- package/dist/chunk-OXSV64JX.js.map +1 -0
- package/dist/chunk-P3RQ5UJE.cjs +689 -0
- package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
- package/dist/chunk-P6ODPZ4W.js +256 -0
- package/dist/chunk-P6ODPZ4W.js.map +1 -0
- package/dist/chunk-PL4JB3BF.cjs +1 -0
- package/dist/chunk-PL4JB3BF.cjs.map +1 -0
- package/dist/{chunk-GVSMRPHB.cjs → chunk-PO6A6QQH.cjs} +2607 -211
- package/dist/chunk-PO6A6QQH.cjs.map +1 -0
- package/dist/{chunk-JJDLPEWL.js → chunk-QGYDWPRM.js} +2 -2
- package/dist/chunk-RR7F5GUM.js +5726 -0
- package/dist/chunk-RR7F5GUM.js.map +1 -0
- package/dist/chunk-TNNJXF46.cjs +115 -0
- package/dist/chunk-TNNJXF46.cjs.map +1 -0
- package/dist/chunk-U5HZSFCS.js +131 -0
- package/dist/chunk-U5HZSFCS.js.map +1 -0
- package/dist/{chunk-MJZBNWG7.js → chunk-UAKDG62Z.js} +309 -581
- package/dist/chunk-UAKDG62Z.js.map +1 -0
- package/dist/{chunk-CL37JGFW.cjs → chunk-V3CHHWOE.cjs} +4 -4
- package/dist/{chunk-CL37JGFW.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
- package/dist/chunk-WSQKHXW7.cjs +5726 -0
- package/dist/chunk-WSQKHXW7.cjs.map +1 -0
- package/dist/{chunk-AA4ZEVCC.cjs → chunk-X4N4WUKB.cjs} +336 -608
- package/dist/chunk-X4N4WUKB.cjs.map +1 -0
- package/dist/commands/index.cjs +74 -1
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +38 -353
- package/dist/commands/index.d.ts +38 -353
- package/dist/commands/index.js +73 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/comment-store-BEMgVlAA.d.cts +135 -0
- package/dist/comment-store-BEMgVlAA.d.ts +135 -0
- package/dist/compare/index.cjs +15 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +58 -0
- package/dist/compare/index.d.ts +58 -0
- package/dist/compare/index.js +15 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/controller-BIJiNoVs.d.cts +1842 -0
- package/dist/controller-BIJiNoVs.d.ts +1842 -0
- package/dist/documents-CHT1U5Vs.d.ts +86 -0
- package/dist/documents-Gp7wb0Me.d.cts +86 -0
- package/dist/extensions/index.cjs +100 -5
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +16 -4
- package/dist/extensions/index.d.ts +16 -4
- package/dist/extensions/index.js +100 -5
- package/dist/generation/index.cjs +2317 -0
- package/dist/generation/index.cjs.map +1 -0
- package/dist/generation/index.d.cts +1015 -0
- package/dist/generation/index.d.ts +1015 -0
- package/dist/generation/index.js +2317 -0
- package/dist/generation/index.js.map +1 -0
- package/dist/grammar/index.cjs +48 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.d.cts +322 -100
- package/dist/grammar/index.d.ts +322 -100
- package/dist/grammar/index.js +54 -9
- package/dist/image-editor/index.cjs +4392 -481
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +1249 -97
- package/dist/image-editor/index.d.ts +1249 -97
- package/dist/image-editor/index.js +4281 -370
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index-7a6bHTLy.d.ts +1754 -0
- package/dist/index-Csd5qI8u.d.cts +1754 -0
- package/dist/index.cjs +1682 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -21
- package/dist/index.d.ts +118 -21
- package/dist/index.js +1630 -47
- package/dist/index.js.map +1 -1
- package/dist/mention-text-CDnCFd3c.d.cts +53 -0
- package/dist/mention-text-CDnCFd3c.d.ts +53 -0
- package/dist/migrate-iTlm3a8h.d.cts +112 -0
- package/dist/migrate-iTlm3a8h.d.ts +112 -0
- package/dist/model-C1zApQM8.d.cts +219 -0
- package/dist/model-C1zApQM8.d.ts +219 -0
- package/dist/persistence/index.cjs +676 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +230 -0
- package/dist/persistence/index.d.ts +230 -0
- package/dist/persistence/index.js +676 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
- package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.cts} +12 -1
- package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.ts} +12 -1
- package/dist/registry-D32LpIc4.d.cts +354 -0
- package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
- package/dist/registry-evKTP4ls.d.ts +354 -0
- package/dist/schema-DYDGdYL9.d.cts +41 -0
- package/dist/schema-DYDGdYL9.d.ts +41 -0
- package/dist/serializers/index.cjs +12 -3
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +40 -12
- package/dist/serializers/index.d.ts +40 -12
- package/dist/serializers/index.js +12 -3
- package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
- package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
- package/dist/spreadsheet/index.cjs +161 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +611 -20
- package/dist/spreadsheet/index.d.ts +611 -20
- package/dist/spreadsheet/index.js +168 -10
- package/dist/storage-BpFfspHm.d.cts +120 -0
- package/dist/storage-BpFfspHm.d.ts +120 -0
- package/dist/tokens/index.cjs +115 -0
- package/dist/tokens/index.cjs.map +1 -0
- package/dist/tokens/index.d.cts +212 -0
- package/dist/tokens/index.d.ts +212 -0
- package/dist/tokens/index.js +115 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
- package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
- package/dist/{track-changes-BSF58RK0.d.cts → track-changes-D_VAPELi.d.cts} +110 -144
- package/dist/{track-changes-BSF58RK0.d.ts → track-changes-Db_fGEvx.d.ts} +110 -144
- package/package.json +21 -1
- package/dist/chunk-4SUNJZWB.cjs.map +0 -1
- package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
- package/dist/chunk-AXV2ZW34.cjs +0 -118
- package/dist/chunk-AXV2ZW34.cjs.map +0 -1
- package/dist/chunk-B2ZRLN4S.js +0 -118
- package/dist/chunk-B2ZRLN4S.js.map +0 -1
- package/dist/chunk-GVSMRPHB.cjs.map +0 -1
- package/dist/chunk-K3R5NG2D.js +0 -3100
- package/dist/chunk-K3R5NG2D.js.map +0 -1
- package/dist/chunk-MJZBNWG7.js.map +0 -1
- package/dist/chunk-OYXSKQFR.js.map +0 -1
- package/dist/chunk-QBJ22YZR.js.map +0 -1
- package/dist/chunk-QGHGJ56O.js.map +0 -1
- package/dist/chunk-RIKBJLS2.cjs.map +0 -1
- package/dist/chunk-XDMXXC4Z.cjs +0 -3100
- package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
- package/dist/controller-pePCJLT1.d.cts +0 -959
- package/dist/controller-pePCJLT1.d.ts +0 -959
- package/dist/index-CCr_z9kF.d.cts +0 -899
- package/dist/index-Ck6ajwXh.d.ts +0 -899
- /package/dist/{chunk-JJDLPEWL.js.map → chunk-QGYDWPRM.js.map} +0 -0
|
@@ -1,359 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as CommandRegistry, P as Platform, a as CommandResult, b as CommandEntry, K as KeyboardEventLike, S as ShortcutBinding, c as CommandSpec } from '../registry-D32LpIc4.cjs';
|
|
2
|
+
export { d as Chord, e as CommandErrorCode, f as CommandHistoryTarget, g as CommandListOptions, h as CommandParamsSchema, i as CommandRegistryError, j as CommandRegistryOptions, E as EffectiveChord, k as PLATFORMS, l as ShortcutConflict, m as ShortcutInput, n as ShortcutMap, o as ShortcutMapOptions, p as ShortcutMatch, q as ShortcutResolveOptions, r as chordToString, s as codeFromKey, t as codeToKeyText, u as createCommandRegistry, v as defineCommand, w as detectPlatform, x as effectiveChord, y as effectiveChordKey, z as eventCode, A as formatShortcut, B as isEditableEventTarget, D as keyToCode, F as normalizeChord, G as parseChord, H as shortcutCode, I as toShortcutBindings } from '../registry-D32LpIc4.cjs';
|
|
3
|
+
import { A as AgentToolProvider } from '../registry-DnzpgY27.cjs';
|
|
2
4
|
import { H as HistoryState } from '../types-GT5a5YAX.cjs';
|
|
3
5
|
import { C as CanvasArrangeAction, A as AlignEdge, D as DistributeAxis, a as DistributeMode, Z as ZOrderOperation } from '../arrangeShortcuts-B8O3f8-P.cjs';
|
|
6
|
+
import '../schema-DYDGdYL9.cjs';
|
|
4
7
|
import '../types-DX4Mh4SL.cjs';
|
|
5
8
|
|
|
6
|
-
/**
|
|
7
|
-
* Keyboard chords in a platform-neutral notation.
|
|
8
|
-
*
|
|
9
|
-
* | token | macOS | Windows / Linux |
|
|
10
|
-
* |---|---|---|
|
|
11
|
-
* | `Mod` | ⌘ Command | Ctrl |
|
|
12
|
-
* | `Ctrl` | ⌃ Control | Ctrl (same key as `Mod`: conflicts are reported) |
|
|
13
|
-
* | `Meta` / `Cmd` | ⌘ Command | Win / Super |
|
|
14
|
-
* | `Alt` / `Option` | ⌥ Option | Alt |
|
|
15
|
-
* | `Shift` | ⇧ Shift | Shift |
|
|
16
|
-
*
|
|
17
|
-
* Keys are stored as `KeyboardEvent.code` values (`KeyZ`, `Digit1`, `BracketRight`,
|
|
18
|
-
* `PageDown`), so Option/Alt chords work on macOS (where Option changes `event.key`).
|
|
19
|
-
*/
|
|
20
|
-
type Platform = 'mac' | 'windows' | 'linux';
|
|
21
|
-
declare const PLATFORMS: readonly Platform[];
|
|
22
|
-
/** A parsed chord. `mod` is the platform's primary modifier. */
|
|
23
|
-
interface Chord {
|
|
24
|
-
/** `KeyboardEvent.code` of the key, e.g. `KeyZ`. */
|
|
25
|
-
key: string;
|
|
26
|
-
mod?: boolean;
|
|
27
|
-
ctrl?: boolean;
|
|
28
|
-
meta?: boolean;
|
|
29
|
-
alt?: boolean;
|
|
30
|
-
shift?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/** The modifiers a chord needs on one platform (`mod` resolved to `meta` or `ctrl`). */
|
|
33
|
-
interface EffectiveChord {
|
|
34
|
-
key: string;
|
|
35
|
-
ctrl: boolean;
|
|
36
|
-
meta: boolean;
|
|
37
|
-
alt: boolean;
|
|
38
|
-
shift: boolean;
|
|
39
|
-
}
|
|
40
|
-
/** The current platform from `navigator` (`linux` when unknown, e.g. in Node). */
|
|
41
|
-
declare function detectPlatform(): Platform;
|
|
42
|
-
/** `KeyboardEvent.code` for a key token (`Z`, `1`, `]`, `PageDown`, `F5`, `KeyZ`), or `null`. */
|
|
43
|
-
declare function keyToCode(token: string): string | null;
|
|
44
|
-
/** Neutral text for a code: `KeyZ` → `Z`, `BracketRight` → `]`, `ArrowUp` → `Up`. */
|
|
45
|
-
declare function codeToKeyText(code: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* Parses chord text (`Mod+Shift+Z`, `Alt+]`, `⌥⇧⌘K`, `CmdOrCtrl+K`). Throws on unknown
|
|
48
|
-
* modifiers or keys. The last `+`-separated token is the key (`+` itself is `Plus`).
|
|
49
|
-
*/
|
|
50
|
-
declare function parseChord(text: string): Chord;
|
|
51
|
-
/** Canonical platform-neutral text: `Mod+Ctrl+Meta+Alt+Shift+<key>`. */
|
|
52
|
-
declare function chordToString(chord: Chord): string;
|
|
53
|
-
/** Canonical spelling of chord text (`shift+cmdorctrl+z` → `Mod+Shift+Z`). Throws when invalid. */
|
|
54
|
-
declare function normalizeChord(text: string): string;
|
|
55
|
-
/** The modifiers a chord needs on `platform`: `Mod` is ⌘ (meta) on macOS and Ctrl elsewhere. */
|
|
56
|
-
declare function effectiveChord(chord: string | Chord, platform: Platform): EffectiveChord;
|
|
57
|
-
/** Identity of an effective chord, for conflict detection (`Ctrl+Shift+KeyZ`). */
|
|
58
|
-
declare function effectiveChordKey(chord: string | Chord, platform: Platform): string;
|
|
59
|
-
/**
|
|
60
|
-
* Display text: `⌥⇧⌘K` on macOS, `Ctrl+Alt+Shift+K` on Windows / Linux (`Meta` shows as
|
|
61
|
-
* `Win` / `Super`). Invalid text is returned unchanged.
|
|
62
|
-
*/
|
|
63
|
-
declare function formatShortcut(chord: string | Chord, platform?: Platform): string;
|
|
64
|
-
/** Minimal keyboard event surface (DOM `KeyboardEvent` satisfies it). */
|
|
65
|
-
interface KeyboardEventLike {
|
|
66
|
-
key?: string;
|
|
67
|
-
code?: string;
|
|
68
|
-
ctrlKey?: boolean;
|
|
69
|
-
metaKey?: boolean;
|
|
70
|
-
altKey?: boolean;
|
|
71
|
-
shiftKey?: boolean;
|
|
72
|
-
target?: EventTarget | null | unknown;
|
|
73
|
-
defaultPrevented?: boolean;
|
|
74
|
-
preventDefault?: () => void;
|
|
75
|
-
}
|
|
76
|
-
/** `event.code`, or one derived from `event.key` for synthetic events without a code. */
|
|
77
|
-
declare function eventCode(event: KeyboardEventLike): string;
|
|
78
|
-
/**
|
|
79
|
-
* The key code a shortcut event is matched by: `event.code` (layout-independent, so
|
|
80
|
-
* Option/Alt chords work on macOS and punctuation chords follow the physical key),
|
|
81
|
-
* except that a letter key producing a different Latin letter without Alt (AZERTY,
|
|
82
|
-
* QWERTZ, Dvorak) uses the produced letter, as browsers and operating systems do.
|
|
83
|
-
*/
|
|
84
|
-
declare function shortcutCode(event: KeyboardEventLike): string;
|
|
85
|
-
/** The code a printable `event.key` names on a US layout (`z` → `KeyZ`, `]` → `BracketRight`). */
|
|
86
|
-
declare function codeFromKey(key: string): string | null;
|
|
87
|
-
/**
|
|
88
|
-
* Whether a keyboard event comes from a text-entry element: `<input>`, `<textarea>`,
|
|
89
|
-
* `<select>`, a `contenteditable` element (or a descendant) or a ProseMirror editor.
|
|
90
|
-
* Falls back to `document.activeElement` when the event has no element target.
|
|
91
|
-
*/
|
|
92
|
-
declare function isEditableEventTarget(event: {
|
|
93
|
-
target?: unknown;
|
|
94
|
-
}): boolean;
|
|
95
|
-
|
|
96
|
-
/** One key binding: a chord that runs `command`, optionally only in one scope / on some platforms. */
|
|
97
|
-
interface ShortcutBinding {
|
|
98
|
-
command: string;
|
|
99
|
-
/** Chord text (`Mod+Shift+Z`) or a parsed chord. */
|
|
100
|
-
chord: string | Chord;
|
|
101
|
-
/** Scope (e.g. `canvas`, `spreadsheet`); scoped bindings win over global ones. Omit for global. */
|
|
102
|
-
scope?: string;
|
|
103
|
-
/** Platforms the binding exists on (default: all). E.g. `Mod+Y` redo only off macOS. */
|
|
104
|
-
platforms?: readonly Platform[];
|
|
105
|
-
/** Also fire while focus is in an input, textarea or contenteditable (default `false`). */
|
|
106
|
-
allowInEditable?: boolean;
|
|
107
|
-
}
|
|
108
|
-
/** Shortcut declaration on a command: chord text, or an object for platform / scope specifics. */
|
|
109
|
-
type ShortcutInput = string | Omit<ShortcutBinding, 'command'> | ReadonlyArray<string | Omit<ShortcutBinding, 'command'>>;
|
|
110
|
-
/** Expands a command's `shortcut` declaration into bindings. */
|
|
111
|
-
declare function toShortcutBindings(command: string, input: ShortcutInput | undefined, scope?: string): ShortcutBinding[];
|
|
112
|
-
interface ShortcutConflict {
|
|
113
|
-
/** Scope shared by the bindings (`undefined` = global). */
|
|
114
|
-
scope?: string;
|
|
115
|
-
/** Effective chord, e.g. `Ctrl+KeyZ`. */
|
|
116
|
-
chord: string;
|
|
117
|
-
/** Commands bound to it (two or more). */
|
|
118
|
-
commands: string[];
|
|
119
|
-
}
|
|
120
|
-
interface ShortcutMatch {
|
|
121
|
-
command: string;
|
|
122
|
-
binding: ShortcutBinding;
|
|
123
|
-
}
|
|
124
|
-
interface ShortcutResolveOptions {
|
|
125
|
-
/** Active scopes, most specific first. Bindings in these scopes win over global ones. */
|
|
126
|
-
scopes?: string | readonly string[];
|
|
127
|
-
/** Resolve even when the event comes from a text input (default: per binding). */
|
|
128
|
-
allowInEditable?: boolean;
|
|
129
|
-
/** Override the map's platform. */
|
|
130
|
-
platform?: Platform;
|
|
131
|
-
}
|
|
132
|
-
interface ShortcutMapOptions {
|
|
133
|
-
/** Platform used to resolve `Mod` (default: detected from `navigator` on every resolve). */
|
|
134
|
-
platform?: Platform;
|
|
135
|
-
/**
|
|
136
|
-
* `platform` (default): `Mod` means ⌘ on macOS and Ctrl elsewhere, exactly.
|
|
137
|
-
* `either`: `Mod` (and `Ctrl` / `Meta`) match ⌘ or Ctrl on every platform.
|
|
138
|
-
*/
|
|
139
|
-
modifierMode?: 'platform' | 'either';
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Keyboard shortcuts as data: default bindings plus user overrides, resolved from
|
|
143
|
-
* `KeyboardEvent`s by `event.code` (so Option/Alt chords work on macOS), with scopes
|
|
144
|
-
* (scoped bindings win), conflict detection per platform and display formatting.
|
|
145
|
-
*/
|
|
146
|
-
declare class ShortcutMap {
|
|
147
|
-
private defaults;
|
|
148
|
-
private overrides;
|
|
149
|
-
private readonly listeners;
|
|
150
|
-
private readonly options;
|
|
151
|
-
constructor(bindings?: readonly ShortcutBinding[], options?: ShortcutMapOptions);
|
|
152
|
-
get platform(): Platform;
|
|
153
|
-
private entry;
|
|
154
|
-
private changed;
|
|
155
|
-
/** Subscribes to binding changes. Returns an unsubscribe function. */
|
|
156
|
-
subscribe(listener: () => void): () => void;
|
|
157
|
-
/** Adds default bindings (throws on invalid chord text). Returns a function removing them. */
|
|
158
|
-
bind(bindings: ShortcutBinding | readonly ShortcutBinding[]): () => void;
|
|
159
|
-
/**
|
|
160
|
-
* User override for a command: replaces all of its default bindings with `chords`
|
|
161
|
-
* (an empty list unbinds it). Throws on invalid chord text.
|
|
162
|
-
*/
|
|
163
|
-
setOverride(command: string, chords: string | Chord | ReadonlyArray<string | Chord | Omit<ShortcutBinding, 'command'>>): void;
|
|
164
|
-
/** Removes a user override (the defaults apply again). */
|
|
165
|
-
clearOverride(command: string): void;
|
|
166
|
-
/** User overrides as plain data (`{ command: ['Mod+K'] }`), e.g. to persist them. */
|
|
167
|
-
getOverrides(): Record<string, string[]>;
|
|
168
|
-
/** Restores overrides saved with `getOverrides` (replacing the current ones). */
|
|
169
|
-
setOverrides(overrides: Record<string, readonly string[]>): void;
|
|
170
|
-
private active;
|
|
171
|
-
/** Effective bindings on `platform` (defaults without overridden commands, plus overrides). */
|
|
172
|
-
bindings(platform?: Platform): ShortcutBinding[];
|
|
173
|
-
/** Canonical chord text bound to `command` on `platform` (first = primary). */
|
|
174
|
-
forCommand(command: string, platform?: Platform): string[];
|
|
175
|
-
/**
|
|
176
|
-
* The command a keydown event runs, or `null`. Events from text inputs are ignored
|
|
177
|
-
* unless the binding (or `options`) allows them. Bindings in the active scopes
|
|
178
|
-
* (in order) win over global bindings; bindings in other scopes never match.
|
|
179
|
-
* Keys are matched by `event.code`, except that a letter key producing another Latin
|
|
180
|
-
* letter (AZERTY, QWERTZ, Dvorak) matches that letter when Alt is not held, so
|
|
181
|
-
* `Mod+Z` follows the Z label (see `shortcutCode`).
|
|
182
|
-
*/
|
|
183
|
-
resolve(event: KeyboardEventLike, options?: ShortcutResolveOptions): ShortcutMatch | null;
|
|
184
|
-
private matches;
|
|
185
|
-
/**
|
|
186
|
-
* Groups of bindings that share an effective chord in one scope on `platform`
|
|
187
|
-
* (e.g. `Mod+Y` and `Ctrl+Y` collide off macOS). A scoped binding shadowing a
|
|
188
|
-
* global one is not a conflict.
|
|
189
|
-
*/
|
|
190
|
-
findConflicts(platform?: Platform): ShortcutConflict[];
|
|
191
|
-
/** Conflicts on every platform, keyed by platform (only platforms with conflicts). */
|
|
192
|
-
findAllConflicts(): Partial<Record<Platform, ShortcutConflict[]>>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** Object JSON Schema describing a command's parameters. */
|
|
196
|
-
type CommandParamsSchema = JsonSchema & {
|
|
197
|
-
type: 'object';
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Metadata and implementation of one command. Menus, shortcuts, the palette and agent
|
|
201
|
-
* tools all run commands by id, so every entry point shares enablement and validation.
|
|
202
|
-
*/
|
|
203
|
-
interface CommandSpec<TContext = any, TParams = any, TResult = unknown> {
|
|
204
|
-
/** Unique id, e.g. `history.undo` or `canvas.alignLeft`. */
|
|
205
|
-
id: string;
|
|
206
|
-
label: string;
|
|
207
|
-
/** Group / menu name shown next to the label, e.g. `Edit` or `Arrange`. */
|
|
208
|
-
group?: string;
|
|
209
|
-
/** Extra search terms for the palette. */
|
|
210
|
-
keywords?: readonly string[];
|
|
211
|
-
description?: string;
|
|
212
|
-
/** Object JSON Schema for `params`. Unknown keys are rejected unless `additionalProperties` allows them. */
|
|
213
|
-
params?: CommandParamsSchema;
|
|
214
|
-
/** Default shortcut(s): platform-neutral chord text such as `Mod+Shift+Z`. */
|
|
215
|
-
shortcut?: ShortcutInput;
|
|
216
|
-
/** Scope the command (and its shortcuts) belong to, e.g. `canvas`. Omit for global commands. */
|
|
217
|
-
scope?: string;
|
|
218
|
-
/**
|
|
219
|
-
* Whether the command can run: `true` (or `undefined`), `false`, or a reason string
|
|
220
|
-
* ("Nothing to undo"). Receives the params a caller named, so a command acting on the
|
|
221
|
-
* selection can still run on targets passed explicitly (`params` is `undefined` for menus).
|
|
222
|
-
*/
|
|
223
|
-
enabled?: (context: TContext, params: TParams | undefined) => boolean | string | undefined;
|
|
224
|
-
run: (context: TContext, params: TParams) => TResult;
|
|
225
|
-
/**
|
|
226
|
-
* Runs inside the registry's `history.batch(label, …)`, so all history entries the
|
|
227
|
-
* command records become one undo step and a throw rolls back its partial changes.
|
|
228
|
-
*/
|
|
229
|
-
undoable?: boolean;
|
|
230
|
-
/** The command only reads state (agent tools mark it read-only). */
|
|
231
|
-
readOnly?: boolean;
|
|
232
|
-
/** Hide from the palette and `list()` unless `includeHidden` (still runnable by id). */
|
|
233
|
-
hidden?: boolean;
|
|
234
|
-
}
|
|
235
|
-
type CommandErrorCode = 'unknown_command' | 'disabled' | 'invalid_params' | 'failed';
|
|
236
|
-
type CommandResult<T = unknown> = {
|
|
237
|
-
ok: true;
|
|
238
|
-
id: string;
|
|
239
|
-
result: T;
|
|
240
|
-
} | {
|
|
241
|
-
ok: false;
|
|
242
|
-
id: string;
|
|
243
|
-
code: CommandErrorCode;
|
|
244
|
-
message: string;
|
|
245
|
-
details?: SchemaValidationError[];
|
|
246
|
-
};
|
|
247
|
-
/** A command as listed for menus, palettes and agents. */
|
|
248
|
-
interface CommandEntry {
|
|
249
|
-
id: string;
|
|
250
|
-
label: string;
|
|
251
|
-
group?: string;
|
|
252
|
-
keywords?: readonly string[];
|
|
253
|
-
description?: string;
|
|
254
|
-
params?: CommandParamsSchema;
|
|
255
|
-
scope?: string;
|
|
256
|
-
/** Canonical chord text bound on the registry's platform (first = primary). */
|
|
257
|
-
shortcuts: string[];
|
|
258
|
-
enabled: boolean;
|
|
259
|
-
/** Why the command is disabled (only when `enabled` is false). */
|
|
260
|
-
disabledReason?: string;
|
|
261
|
-
undoable: boolean;
|
|
262
|
-
readOnly: boolean;
|
|
263
|
-
}
|
|
264
|
-
interface CommandListOptions<TContext = any> {
|
|
265
|
-
/** Only global commands plus commands of these scopes. */
|
|
266
|
-
scope?: string | readonly string[];
|
|
267
|
-
enabledOnly?: boolean;
|
|
268
|
-
includeHidden?: boolean;
|
|
269
|
-
/** Context for the enablement check (default: the registry's context). */
|
|
270
|
-
context?: TContext;
|
|
271
|
-
}
|
|
272
|
-
/** Minimal history surface (`HistoryManager` satisfies it). */
|
|
273
|
-
interface CommandHistoryTarget {
|
|
274
|
-
batch(name: string, fn: () => void): void;
|
|
275
|
-
}
|
|
276
|
-
interface CommandRegistryOptions<TContext = any> {
|
|
277
|
-
/** Default context passed to `enabled` / `run` (a value or a getter). */
|
|
278
|
-
context?: TContext | (() => TContext);
|
|
279
|
-
/** Wraps `undoable` commands in one history step (see `CommandSpec.undoable`). */
|
|
280
|
-
history?: CommandHistoryTarget;
|
|
281
|
-
/** Options for the registry's `ShortcutMap`. */
|
|
282
|
-
shortcuts?: ShortcutMapOptions;
|
|
283
|
-
}
|
|
284
|
-
declare class CommandRegistryError extends Error {
|
|
285
|
-
readonly code: 'duplicate_command' | 'invalid_command';
|
|
286
|
-
constructor(code: CommandRegistryError['code'], message: string);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Registry of commands: one id per action, shared by shortcuts (`shortcuts`), the
|
|
290
|
-
* command palette (`list` + `rankCommands`) and agent tools (`createCommandToolProvider`).
|
|
291
|
-
*/
|
|
292
|
-
declare class CommandRegistry<TContext = any> {
|
|
293
|
-
/** Shortcut bindings of the registered commands (plus any user overrides). */
|
|
294
|
-
readonly shortcuts: ShortcutMap;
|
|
295
|
-
private readonly commands;
|
|
296
|
-
private readonly listeners;
|
|
297
|
-
private readonly options;
|
|
298
|
-
private version;
|
|
299
|
-
private muted;
|
|
300
|
-
constructor(options?: CommandRegistryOptions<TContext>);
|
|
301
|
-
/** Monotonic counter bumped on every change (useful as a snapshot key). */
|
|
302
|
-
getVersion(): number;
|
|
303
|
-
/** The default context. */
|
|
304
|
-
get context(): TContext;
|
|
305
|
-
/**
|
|
306
|
-
* Registers a command (or several) and returns a function that unregisters it.
|
|
307
|
-
* Throws a `CommandRegistryError` for a duplicate or invalid id, or invalid chord text.
|
|
308
|
-
*/
|
|
309
|
-
register(spec: CommandSpec<TContext> | readonly CommandSpec<TContext>[]): () => void;
|
|
310
|
-
/** Removes a command by id. Returns whether it was registered. */
|
|
311
|
-
unregister(id: string): boolean;
|
|
312
|
-
private unbindQuietly;
|
|
313
|
-
has(id: string): boolean;
|
|
314
|
-
get(id: string): CommandSpec<TContext> | undefined;
|
|
315
|
-
/** Registered ids in registration order. */
|
|
316
|
-
ids(): string[];
|
|
317
|
-
/** Whether `id` can run now (`{ enabled, reason }`); `params` are the targets a caller named. */
|
|
318
|
-
isEnabled(id: string, params?: unknown, context?: TContext): {
|
|
319
|
-
enabled: boolean;
|
|
320
|
-
reason?: string;
|
|
321
|
-
};
|
|
322
|
-
/** Commands for menus, palettes and agents, with their current enablement. */
|
|
323
|
-
list(options?: CommandListOptions<TContext>): CommandEntry[];
|
|
324
|
-
private check;
|
|
325
|
-
private invoke;
|
|
326
|
-
/**
|
|
327
|
-
* Runs a command synchronously and returns a structured result; never throws.
|
|
328
|
-
* A command whose `run` returns a promise yields `{ ok: true, result: promise }`
|
|
329
|
-
* (use `executeAsync` to await it and catch its rejection).
|
|
330
|
-
*/
|
|
331
|
-
execute<T = unknown>(id: string, params?: unknown, context?: TContext): CommandResult<T>;
|
|
332
|
-
/** Like `execute`, but awaits async commands (rejections become `failed` results). */
|
|
333
|
-
executeAsync<T = unknown>(id: string, params?: unknown, context?: TContext): Promise<CommandResult<T>>;
|
|
334
|
-
/**
|
|
335
|
-
* Resolves a keydown event to a command (see `ShortcutMap.resolve`) and runs it when
|
|
336
|
-
* enabled, calling `preventDefault()`. Disabled commands leave the event alone, so the
|
|
337
|
-
* browser or a focused editor can still handle it. Returns the result, or `null`.
|
|
338
|
-
*/
|
|
339
|
-
handleKeyDown(event: KeyboardEventLike, options?: ShortcutResolveOptions & {
|
|
340
|
-
context?: TContext;
|
|
341
|
-
}): CommandResult | null;
|
|
342
|
-
/** Display-ready primary shortcut of a command (`⇧⌘Z` / `Ctrl+Shift+Z`), or `undefined`. */
|
|
343
|
-
shortcutFor(id: string, platform?: Platform): string | undefined;
|
|
344
|
-
/**
|
|
345
|
-
* Subscribes to changes: commands registered or removed, shortcut overrides, executed
|
|
346
|
-
* commands and `invalidate()` calls (e.g. when enablement inputs change).
|
|
347
|
-
*/
|
|
348
|
-
subscribe(listener: () => void): () => void;
|
|
349
|
-
/** Tells subscribers that enablement may have changed (e.g. the selection changed). */
|
|
350
|
-
invalidate(): void;
|
|
351
|
-
private notify;
|
|
352
|
-
}
|
|
353
|
-
declare function createCommandRegistry<TContext = any>(options?: CommandRegistryOptions<TContext>): CommandRegistry<TContext>;
|
|
354
|
-
/** Identity helper that types a command spec. */
|
|
355
|
-
declare function defineCommand<TContext = any, TParams = any, TResult = unknown>(spec: CommandSpec<TContext, TParams, TResult>): CommandSpec<TContext, TParams, TResult>;
|
|
356
|
-
|
|
357
9
|
/** The fields `rankCommands` searches (a `CommandEntry` satisfies it). */
|
|
358
10
|
interface RankableCommand {
|
|
359
11
|
id: string;
|
|
@@ -566,6 +218,39 @@ interface ArrangeCommandOptions {
|
|
|
566
218
|
* named ids, or the selection when none are named.
|
|
567
219
|
*/
|
|
568
220
|
declare function createArrangeCommands(controller: ArrangeCommandTarget, options?: ArrangeCommandOptions): CommandSpec[];
|
|
221
|
+
/** Shape operations surface of the arrange controller (`createCanvasArrangeController` satisfies it). */
|
|
222
|
+
interface ShapeCommandTarget {
|
|
223
|
+
combineShapes(operation: 'unite' | 'intersect' | 'subtract' | 'exclude' | 'divide', ids?: Iterable<string>): unknown;
|
|
224
|
+
canCombineShapes(ids?: Iterable<string>): boolean;
|
|
225
|
+
offsetShapes(distance: number, ids?: Iterable<string>, options?: {
|
|
226
|
+
join?: 'miter' | 'round' | 'bevel';
|
|
227
|
+
miterLimit?: number;
|
|
228
|
+
}): unknown;
|
|
229
|
+
canOffsetShapes(ids?: Iterable<string>): boolean;
|
|
230
|
+
outlineStroke(ids?: Iterable<string>, options?: {
|
|
231
|
+
join?: 'miter' | 'round' | 'bevel';
|
|
232
|
+
cap?: 'butt' | 'round' | 'square';
|
|
233
|
+
miterLimit?: number;
|
|
234
|
+
}): unknown;
|
|
235
|
+
canOutlineStroke(ids?: Iterable<string>): boolean;
|
|
236
|
+
}
|
|
237
|
+
interface ShapeCommandOptions {
|
|
238
|
+
/** Id prefix (default `canvas.`). */
|
|
239
|
+
prefix?: string;
|
|
240
|
+
group?: string;
|
|
241
|
+
/** Scope (default `canvas`). Pass `null` for global. */
|
|
242
|
+
scope?: string | null;
|
|
243
|
+
/** Offset distance used when `canvas.offsetPath` is run without one (default 10). */
|
|
244
|
+
defaultOffset?: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Palette / context-menu / agent commands for the shape operations: `canvas.unite`,
|
|
248
|
+
* `canvas.intersect`, `canvas.subtract`, `canvas.exclude`, `canvas.divide`,
|
|
249
|
+
* `canvas.offsetPath` (`{ distance, join?, miterLimit?, ids? }`) and `canvas.outlineStroke`
|
|
250
|
+
* (`{ join?, cap?, miterLimit?, ids? }`). Each is one undoable step when the controller has a
|
|
251
|
+
* history; enablement explains why a command cannot run.
|
|
252
|
+
*/
|
|
253
|
+
declare function createShapeCommands(controller: ShapeCommandTarget, options?: ShapeCommandOptions): CommandSpec[];
|
|
569
254
|
/** Spreadsheet controller surface used by `createSpreadsheetCommands`. */
|
|
570
255
|
interface SpreadsheetCommandTarget {
|
|
571
256
|
selectedRange: unknown;
|
|
@@ -589,4 +274,4 @@ interface SpreadsheetCommandOptions {
|
|
|
589
274
|
/** Palette / agent commands for common spreadsheet table actions (no default shortcuts). */
|
|
590
275
|
declare function createSpreadsheetCommands(controller: SpreadsheetCommandTarget, options?: SpreadsheetCommandOptions): CommandSpec[];
|
|
591
276
|
|
|
592
|
-
export { type ArrangeCommandOptions, type ArrangeCommandTarget,
|
|
277
|
+
export { type ArrangeCommandOptions, type ArrangeCommandTarget, CommandEntry, type CommandPaletteController, type CommandPaletteItem, type CommandPaletteOptions, type CommandPaletteState, CommandRegistry, CommandResult, CommandSpec, type CommandToolProviderOptions, DEFAULT_HISTORY_SHORTCUTS, DEFAULT_RECENT_LIMIT, type FuzzyMatch, type HistoryCommandOptions, type HistoryCommandTarget, KeyboardEventLike, Platform, type RankCommandsOptions, type RankableCommand, type RankedCommand, type ShapeCommandOptions, type ShapeCommandTarget, ShortcutBinding, type SpreadsheetCommandOptions, type SpreadsheetCommandTarget, createArrangeCommands, createCommandPaletteController, createCommandToolProvider, createHistoryCommands, createShapeCommands, createSpreadsheetCommands, exactBonus, fuzzyMatch, fuzzyScore, matchHistoryShortcut, matchPaletteHotkey, pushRecent, rankCommands };
|