@rapidmx/web-client 0.19.0 → 0.20.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.
Files changed (131) hide show
  1. package/README.md +381 -381
  2. package/apps/admin/branding/index.tsx +39 -39
  3. package/apps/admin/data-requests/index.tsx +482 -482
  4. package/apps/admin/domains/[uid].tsx +166 -166
  5. package/apps/admin/escrow-scopes/[uid].tsx +350 -350
  6. package/apps/admin/index.tsx +129 -129
  7. package/apps/admin/mailboxes/[uid].tsx +271 -271
  8. package/apps/admin/mailboxes/new/index.tsx +30 -30
  9. package/apps/admin/plugins/index.tsx +15 -15
  10. package/apps/admin/retention-policy/index.tsx +39 -39
  11. package/apps/admin/signing-certificates/index.tsx +343 -343
  12. package/apps/escrow/audit-log/index.tsx +196 -196
  13. package/apps/escrow/matters/[uid].tsx +621 -621
  14. package/apps/shared/auth/adminAccess.ts +99 -99
  15. package/apps/shared/components/admin/diagnostics/HostCard.tsx +2 -0
  16. package/apps/shared/components/admin/diagnostics/PressureTiles.tsx +108 -0
  17. package/apps/shared/components/admin/diagnostics/PvcTable.tsx +20 -6
  18. package/apps/shared/components/admin/diagnostics/diagnosticsApi.ts +21 -2
  19. package/apps/shared/components/admin/layout/AdminShell.tsx +384 -384
  20. package/apps/shared/components/admin/mailboxes/EraseLeftoverDataDialog.tsx +238 -238
  21. package/apps/shared/components/admin/mailboxes/EscrowScopeCard.tsx +152 -152
  22. package/apps/shared/components/admin/mailboxes/LeftoverMailboxesSection.tsx +194 -194
  23. package/apps/shared/components/admin/settings/BrandingForm.tsx +423 -423
  24. package/apps/shared/components/admin/settings/EncryptionPolicyForm.tsx +119 -119
  25. package/apps/shared/components/admin/settings/MailboxPolicyForm.tsx +198 -198
  26. package/apps/shared/components/admin/settings/PluginsManager.tsx +2093 -1620
  27. package/apps/shared/components/admin/settings/RetentionPolicyForm.tsx +182 -182
  28. package/apps/shared/components/admin/settings/pluginPreferences.ts +34 -0
  29. package/apps/shared/components/admin/setup/EscrowSetupStep.tsx +288 -288
  30. package/apps/shared/components/admin/setup/SetupWizard.tsx +446 -446
  31. package/apps/shared/components/admin/usePagedList.tsx +129 -129
  32. package/apps/shared/components/calendar/EventModal.tsx +206 -206
  33. package/apps/shared/components/calendar/MonthView.tsx +185 -185
  34. package/apps/shared/components/calendar/RecurrenceEditor.tsx +227 -227
  35. package/apps/shared/components/calendar/SplitDayView.tsx +144 -144
  36. package/apps/shared/components/calendar/TimeGridView.tsx +246 -246
  37. package/apps/shared/components/calendar/allDay.ts +124 -124
  38. package/apps/shared/components/contacts/ContactForm.tsx +383 -383
  39. package/apps/shared/components/contacts/ContactsToolbar.tsx +103 -103
  40. package/apps/shared/components/escrow/layout/EscrowShell.tsx +155 -155
  41. package/apps/shared/components/layout/AppShell.tsx +461 -461
  42. package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -398
  43. package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -168
  44. package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -315
  45. package/apps/shared/components/layout/ThemeSwitch.tsx +84 -84
  46. package/apps/shared/components/layout/UserMenu.tsx +439 -439
  47. package/apps/shared/components/mail/ConversationList.tsx +332 -323
  48. package/apps/shared/components/mail/ConversationThreadPane.tsx +613 -613
  49. package/apps/shared/components/mail/MailSelectionBar.tsx +240 -240
  50. package/apps/shared/components/mail/MenuButton.tsx +404 -404
  51. package/apps/shared/components/mail/MessageDetailPane.tsx +1757 -1757
  52. package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -312
  53. package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -422
  54. package/apps/shared/components/mail/compose/ComposeWindow.tsx +1681 -1681
  55. package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -147
  56. package/apps/shared/components/mail/compose/composeFlushRegistry.ts +60 -60
  57. package/apps/shared/components/mail/compose/quotedBody.ts +161 -161
  58. package/apps/shared/components/mail/listPreferences.ts +3 -3
  59. package/apps/shared/components/mail/reading/MessageMoreMenu.tsx +258 -258
  60. package/apps/shared/components/mail/reading/MessageSourceDialog.tsx +79 -79
  61. package/apps/shared/components/mail/reading/messageExport.ts +59 -59
  62. package/apps/shared/components/mail/reading/printMessage.ts +99 -99
  63. package/apps/shared/components/mail/reading/useMessageActions.ts +443 -443
  64. package/apps/shared/components/mail/verificationSeals.ts +125 -125
  65. package/apps/shared/components/rules/RuleBuilder.tsx +311 -311
  66. package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -344
  67. package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -51
  68. package/apps/shared/keyboard/ShortcutProvider.tsx +62 -62
  69. package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -84
  70. package/apps/shared/keyboard/dispatch.ts +124 -124
  71. package/apps/shared/keyboard/format.ts +89 -89
  72. package/apps/shared/keyboard/keymap.ts +114 -114
  73. package/apps/shared/keyboard/registry.ts +65 -65
  74. package/apps/shared/keyboard/targets.ts +79 -79
  75. package/apps/shared/mail/folderOfType.ts +49 -49
  76. package/apps/shared/mail/folderTree.ts +143 -143
  77. package/apps/shared/mail/listAllPages.ts +39 -39
  78. package/apps/shared/mail/newMailNotifications.ts +171 -171
  79. package/apps/shared/mail/outbox/sendJob.ts +445 -445
  80. package/apps/shared/mail/outbox/sendOutcomes.ts +155 -155
  81. package/apps/shared/mail/reportNotices.ts +66 -66
  82. package/apps/shared/mail/senderBlocking.ts +141 -141
  83. package/apps/shared/mail/useMailConnection.ts +205 -205
  84. package/apps/shared/mail/useMailLiveUpdates.ts +277 -277
  85. package/apps/shared/mail/useMailboxUpdateAccess.ts +60 -60
  86. package/apps/shared/mail/useMarkMessageRead.ts +47 -47
  87. package/apps/shared/mail/useNewMailNotifications.ts +178 -178
  88. package/apps/shared/notifications/store.ts +560 -560
  89. package/apps/shared/search/LocalIndexLifecycle.tsx +114 -114
  90. package/apps/shared/search/localIndexBuilder.ts +481 -481
  91. package/apps/shared/signing/enrollmentStorage.ts +33 -33
  92. package/apps/shared/signing/enrollmentTracker.ts +385 -385
  93. package/apps/shared/signing/enrollmentView.ts +251 -251
  94. package/apps/shared/signing/useNow.ts +19 -19
  95. package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -90
  96. package/apps/shared/styles/app.css +396 -396
  97. package/apps/www/calendar/index.tsx +581 -581
  98. package/apps/www/contacts/[uid].tsx +112 -112
  99. package/apps/www/index.tsx +3012 -2962
  100. package/apps/www/messages/[uid].tsx +139 -139
  101. package/apps/www/settings/auto-reply/index.tsx +136 -136
  102. package/apps/www/settings/blocked-senders/index.tsx +303 -303
  103. package/apps/www/settings/encryption/index.tsx +1290 -1290
  104. package/apps/www/settings/filters/[uid].tsx +179 -179
  105. package/apps/www/settings/filters/index.tsx +105 -105
  106. package/apps/www/settings/filters/new/index.tsx +165 -165
  107. package/apps/www/settings/labels/index.tsx +207 -207
  108. package/apps/www/settings/privacy/index.tsx +495 -495
  109. package/apps/www/settings/profile/index.tsx +251 -251
  110. package/apps/www/settings/read-receipts/index.tsx +150 -150
  111. package/apps/www/settings/sharing/index.tsx +259 -259
  112. package/apps/www/settings/signatures/[uid].tsx +175 -175
  113. package/apps/www/settings/signatures/index.tsx +91 -91
  114. package/apps/www/settings/signatures/new/index.tsx +138 -138
  115. package/apps/www/tasks/index.tsx +654 -654
  116. package/dist/apps/shared/components/admin/diagnostics/HostCard.js +2 -1
  117. package/dist/apps/shared/components/admin/diagnostics/PressureTiles.d.ts +22 -0
  118. package/dist/apps/shared/components/admin/diagnostics/PressureTiles.js +52 -0
  119. package/dist/apps/shared/components/admin/diagnostics/PvcTable.js +9 -4
  120. package/dist/apps/shared/components/admin/diagnostics/diagnosticsApi.d.ts +35 -2
  121. package/dist/apps/shared/components/admin/settings/BrandingForm.js +3 -3
  122. package/dist/apps/shared/components/admin/settings/PluginsManager.js +267 -35
  123. package/dist/apps/shared/components/admin/settings/pluginPreferences.d.ts +2 -0
  124. package/dist/apps/shared/components/admin/settings/pluginPreferences.js +35 -0
  125. package/dist/apps/shared/components/mail/ConversationList.d.ts +10 -3
  126. package/dist/apps/shared/components/mail/ConversationList.js +9 -5
  127. package/dist/apps/shared/components/mail/listPreferences.d.ts +1 -1
  128. package/dist/apps/shared/components/mail/reading/printMessage.js +11 -11
  129. package/dist/apps/shared/styles/app.css +396 -396
  130. package/dist/apps/www/index.js +51 -10
  131. package/package.json +2 -2
@@ -1,124 +1,124 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import type { ShortcutScope } from "./keymap.js";
6
- import { matchesEvent } from "./match.js";
7
- import { ParsedSpec, resolveModifiers } from "./parse.js";
8
- import type { KeyEnvironment } from "./platform.js";
9
- import type { Registration, ShortcutRegistry } from "./registry.js";
10
- import { isActivatable, isInPopoverDialog, isInWidget, isModalOpen, isPopupOpenAt, isTextEntry, regionScopeOf } from "./targets.js";
11
-
12
- /** The keys of the four view scopes: only the mounted view has registrations, so precedence among them is moot. */
13
- const VIEW_SCOPES: readonly ShortcutScope[] = ["mail", "calendar", "contacts", "tasks"];
14
-
15
- /** Keys that move the caret or delete text, which a text field owns even with Ctrl or Alt held (word jumps, delete-word). */
16
- const EDITING_KEYS = new Set(["arrowup", "arrowdown", "arrowleft", "arrowright", "home", "end", "pageup", "pagedown", "backspace", "delete"]);
17
-
18
- /** The Copy / Cut / Paste / Select all / Undo / Redo / Find chords: never a shortcut, anywhere - they act on the page's selection, not on a view. */
19
- function isReservedChord(parsed: ParsedSpec, env: KeyEnvironment): boolean {
20
- const modifiers = resolveModifiers(parsed, env);
21
- return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && !modifiers.shift && ["a", "c", "v", "x", "z", "y", "f"].includes(parsed.key);
22
- }
23
-
24
- /** Paste as plain text (Ctrl+Shift+V) and Redo (Ctrl+Shift+Z): text-editing chords in a field, free everywhere else (Ctrl+Shift+V is Move to). */
25
- function isShiftedEditingChord(parsed: ParsedSpec, env: KeyEnvironment): boolean {
26
- const modifiers = resolveModifiers(parsed, env);
27
- return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && modifiers.shift && ["z", "v"].includes(parsed.key);
28
- }
29
-
30
- /**
31
- * Whether `parsed` may fire with the event on this target.
32
- *
33
- * A text field (input, textarea, select, contenteditable - the rich-text editor) keeps everything that types or edits: bare keys
34
- * (`j`, `?`, Delete), the caret keys with any modifier, and paste-as-plain-text and redo. A chord with Ctrl/Cmd/Alt works from one (that is how Ctrl+Enter sends from
35
- * the body), except that Option on a Mac and Ctrl+Alt (AltGr) elsewhere type characters, so those don't. Escape works from a field unless a
36
- * popup it owns is open (or it is in a popover dialog of its own). Outside a field, a bare key still isn't taken from a widget that reads keys itself (an open menu, a list box), and
37
- * Enter/Space are left to the button or link that has the focus - unless the shortcut asked for them.
38
- */
39
- function allowedOnTarget(registration: Registration, parsed: ParsedSpec, target: EventTarget | null, env: KeyEnvironment): boolean {
40
- const modifiers = resolveModifiers(parsed, env);
41
- const command = modifiers.ctrl || modifiers.meta || modifiers.alt;
42
- if (parsed.key === "escape" && (isPopupOpenAt(target) || isInPopoverDialog(target))) {
43
- return false;
44
- }
45
- if (isTextEntry(target)) {
46
- if (parsed.key === "escape") {
47
- return true;
48
- }
49
- if (!command || EDITING_KEYS.has(parsed.key) || isShiftedEditingChord(parsed, env)) {
50
- return false;
51
- }
52
- return !(modifiers.alt && !modifiers.meta && (env.mac || modifiers.ctrl));
53
- }
54
- if (!command) {
55
- if (isInWidget(target)) {
56
- return false;
57
- }
58
- if ((parsed.key === "enter" || parsed.key === " ") && !registration.shortcut.allowOnActivatable && isActivatable(target)) {
59
- return false;
60
- }
61
- }
62
- return true;
63
- }
64
-
65
- /** The scopes that may act on this event, highest precedence first. */
66
- function activeScopes(event: KeyboardEvent, doc: Document): readonly ShortcutScope[] {
67
- if (isModalOpen(doc)) {
68
- return ["dialog"];
69
- }
70
- if (regionScopeOf(event.target) === "compose") {
71
- return ["compose", "global"];
72
- }
73
- return [...VIEW_SCOPES, "global"];
74
- }
75
-
76
- /** Whether the registration applies to where the event happened (a compose window's shortcuts only inside it). */
77
- function inContainer(registration: Registration, event: KeyboardEvent): boolean {
78
- if (!registration.container) {
79
- return true;
80
- }
81
- return !!registration.container.current?.contains(event.target as Node | null);
82
- }
83
-
84
- /**
85
- * Handles one `keydown`: finds the registered shortcut it is, and runs its handler. Returns whether a handler ran - and only then is the
86
- * event's default prevented and its propagation stopped, so a key nobody claims (or a handler that declines) behaves exactly as if this layer
87
- * did not exist.
88
- *
89
- * Skipped outright: an event some other handler already `defaultPrevented` (a menu, the rich-text editor's own bindings), one from an IME
90
- * composition, a bare modifier key, and the Copy/Cut/Paste/Select all/Undo/Redo/Find chords. A held key repeats: an action that is not
91
- * marked `repeat` runs on the first press only, and the repeats are swallowed (so a browser doesn't reload on a held Ctrl+R) without running it.
92
- *
93
- * Which registration wins: the dialog scope alone while a modal is open; else, inside a compose window, `compose` then `global`; else
94
- * whichever view is mounted, then `global`. Within a scope the most recently mounted registration goes first, and one that returns
95
- * `false` passes the key on to the next.
96
- */
97
- export function dispatchKeyEvent(registry: ShortcutRegistry, event: KeyboardEvent, env: KeyEnvironment, doc: Document): boolean {
98
- if (event.defaultPrevented || event.isComposing || event.key === "Process" || ["Control", "Shift", "Alt", "Meta"].includes(event.key)) {
99
- return false;
100
- }
101
- const scopes = activeScopes(event, doc);
102
- const candidates = registry
103
- .getSnapshot()
104
- .filter((registration) => scopes.includes(registration.scope) && inContainer(registration, event))
105
- .sort((a, b) => scopes.indexOf(a.scope) - scopes.indexOf(b.scope) || b.order - a.order);
106
- for (const registration of candidates) {
107
- const specs = env.electron ? [...registration.keys, ...registration.electronKeys] : registration.keys;
108
- const parsed = specs.find((spec) => matchesEvent(spec, event, env));
109
- if (!parsed || isReservedChord(parsed, env) || !allowedOnTarget(registration, parsed, event.target, env)) {
110
- continue;
111
- }
112
- if (event.repeat && !registration.shortcut.repeat) {
113
- event.preventDefault();
114
- event.stopPropagation();
115
- return true;
116
- }
117
- if (registration.run(event) !== false) {
118
- event.preventDefault();
119
- event.stopPropagation();
120
- return true;
121
- }
122
- }
123
- return false;
124
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import type { ShortcutScope } from "./keymap.js";
6
+ import { matchesEvent } from "./match.js";
7
+ import { ParsedSpec, resolveModifiers } from "./parse.js";
8
+ import type { KeyEnvironment } from "./platform.js";
9
+ import type { Registration, ShortcutRegistry } from "./registry.js";
10
+ import { isActivatable, isInPopoverDialog, isInWidget, isModalOpen, isPopupOpenAt, isTextEntry, regionScopeOf } from "./targets.js";
11
+
12
+ /** The keys of the four view scopes: only the mounted view has registrations, so precedence among them is moot. */
13
+ const VIEW_SCOPES: readonly ShortcutScope[] = ["mail", "calendar", "contacts", "tasks"];
14
+
15
+ /** Keys that move the caret or delete text, which a text field owns even with Ctrl or Alt held (word jumps, delete-word). */
16
+ const EDITING_KEYS = new Set(["arrowup", "arrowdown", "arrowleft", "arrowright", "home", "end", "pageup", "pagedown", "backspace", "delete"]);
17
+
18
+ /** The Copy / Cut / Paste / Select all / Undo / Redo / Find chords: never a shortcut, anywhere - they act on the page's selection, not on a view. */
19
+ function isReservedChord(parsed: ParsedSpec, env: KeyEnvironment): boolean {
20
+ const modifiers = resolveModifiers(parsed, env);
21
+ return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && !modifiers.shift && ["a", "c", "v", "x", "z", "y", "f"].includes(parsed.key);
22
+ }
23
+
24
+ /** Paste as plain text (Ctrl+Shift+V) and Redo (Ctrl+Shift+Z): text-editing chords in a field, free everywhere else (Ctrl+Shift+V is Move to). */
25
+ function isShiftedEditingChord(parsed: ParsedSpec, env: KeyEnvironment): boolean {
26
+ const modifiers = resolveModifiers(parsed, env);
27
+ return (modifiers.ctrl || modifiers.meta) && !modifiers.alt && modifiers.shift && ["z", "v"].includes(parsed.key);
28
+ }
29
+
30
+ /**
31
+ * Whether `parsed` may fire with the event on this target.
32
+ *
33
+ * A text field (input, textarea, select, contenteditable - the rich-text editor) keeps everything that types or edits: bare keys
34
+ * (`j`, `?`, Delete), the caret keys with any modifier, and paste-as-plain-text and redo. A chord with Ctrl/Cmd/Alt works from one (that is how Ctrl+Enter sends from
35
+ * the body), except that Option on a Mac and Ctrl+Alt (AltGr) elsewhere type characters, so those don't. Escape works from a field unless a
36
+ * popup it owns is open (or it is in a popover dialog of its own). Outside a field, a bare key still isn't taken from a widget that reads keys itself (an open menu, a list box), and
37
+ * Enter/Space are left to the button or link that has the focus - unless the shortcut asked for them.
38
+ */
39
+ function allowedOnTarget(registration: Registration, parsed: ParsedSpec, target: EventTarget | null, env: KeyEnvironment): boolean {
40
+ const modifiers = resolveModifiers(parsed, env);
41
+ const command = modifiers.ctrl || modifiers.meta || modifiers.alt;
42
+ if (parsed.key === "escape" && (isPopupOpenAt(target) || isInPopoverDialog(target))) {
43
+ return false;
44
+ }
45
+ if (isTextEntry(target)) {
46
+ if (parsed.key === "escape") {
47
+ return true;
48
+ }
49
+ if (!command || EDITING_KEYS.has(parsed.key) || isShiftedEditingChord(parsed, env)) {
50
+ return false;
51
+ }
52
+ return !(modifiers.alt && !modifiers.meta && (env.mac || modifiers.ctrl));
53
+ }
54
+ if (!command) {
55
+ if (isInWidget(target)) {
56
+ return false;
57
+ }
58
+ if ((parsed.key === "enter" || parsed.key === " ") && !registration.shortcut.allowOnActivatable && isActivatable(target)) {
59
+ return false;
60
+ }
61
+ }
62
+ return true;
63
+ }
64
+
65
+ /** The scopes that may act on this event, highest precedence first. */
66
+ function activeScopes(event: KeyboardEvent, doc: Document): readonly ShortcutScope[] {
67
+ if (isModalOpen(doc)) {
68
+ return ["dialog"];
69
+ }
70
+ if (regionScopeOf(event.target) === "compose") {
71
+ return ["compose", "global"];
72
+ }
73
+ return [...VIEW_SCOPES, "global"];
74
+ }
75
+
76
+ /** Whether the registration applies to where the event happened (a compose window's shortcuts only inside it). */
77
+ function inContainer(registration: Registration, event: KeyboardEvent): boolean {
78
+ if (!registration.container) {
79
+ return true;
80
+ }
81
+ return !!registration.container.current?.contains(event.target as Node | null);
82
+ }
83
+
84
+ /**
85
+ * Handles one `keydown`: finds the registered shortcut it is, and runs its handler. Returns whether a handler ran - and only then is the
86
+ * event's default prevented and its propagation stopped, so a key nobody claims (or a handler that declines) behaves exactly as if this layer
87
+ * did not exist.
88
+ *
89
+ * Skipped outright: an event some other handler already `defaultPrevented` (a menu, the rich-text editor's own bindings), one from an IME
90
+ * composition, a bare modifier key, and the Copy/Cut/Paste/Select all/Undo/Redo/Find chords. A held key repeats: an action that is not
91
+ * marked `repeat` runs on the first press only, and the repeats are swallowed (so a browser doesn't reload on a held Ctrl+R) without running it.
92
+ *
93
+ * Which registration wins: the dialog scope alone while a modal is open; else, inside a compose window, `compose` then `global`; else
94
+ * whichever view is mounted, then `global`. Within a scope the most recently mounted registration goes first, and one that returns
95
+ * `false` passes the key on to the next.
96
+ */
97
+ export function dispatchKeyEvent(registry: ShortcutRegistry, event: KeyboardEvent, env: KeyEnvironment, doc: Document): boolean {
98
+ if (event.defaultPrevented || event.isComposing || event.key === "Process" || ["Control", "Shift", "Alt", "Meta"].includes(event.key)) {
99
+ return false;
100
+ }
101
+ const scopes = activeScopes(event, doc);
102
+ const candidates = registry
103
+ .getSnapshot()
104
+ .filter((registration) => scopes.includes(registration.scope) && inContainer(registration, event))
105
+ .sort((a, b) => scopes.indexOf(a.scope) - scopes.indexOf(b.scope) || b.order - a.order);
106
+ for (const registration of candidates) {
107
+ const specs = env.electron ? [...registration.keys, ...registration.electronKeys] : registration.keys;
108
+ const parsed = specs.find((spec) => matchesEvent(spec, event, env));
109
+ if (!parsed || isReservedChord(parsed, env) || !allowedOnTarget(registration, parsed, event.target, env)) {
110
+ continue;
111
+ }
112
+ if (event.repeat && !registration.shortcut.repeat) {
113
+ event.preventDefault();
114
+ event.stopPropagation();
115
+ return true;
116
+ }
117
+ if (registration.run(event) !== false) {
118
+ event.preventDefault();
119
+ event.stopPropagation();
120
+ return true;
121
+ }
122
+ }
123
+ return false;
124
+ }
@@ -1,89 +1,89 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import type { ShortcutDef } from "./keymap.js";
6
- import { parseSpec, resolveModifiers } from "./parse.js";
7
- import type { KeyEnvironment } from "./platform.js";
8
-
9
- const KEY_NAMES: Record<string, string> = {
10
- escape: "Esc",
11
- enter: "Enter",
12
- tab: "Tab",
13
- backspace: "Backspace",
14
- delete: "Delete",
15
- insert: "Insert",
16
- home: "Home",
17
- end: "End",
18
- pageup: "Page Up",
19
- pagedown: "Page Down",
20
- arrowup: "↑",
21
- arrowdown: "↓",
22
- arrowleft: "←",
23
- arrowright: "→",
24
- " ": "Space",
25
- };
26
-
27
- const MAC_KEY_NAMES: Record<string, string> = { ...KEY_NAMES, enter: "↩", backspace: "⌫", delete: "⌦" };
28
-
29
- /** The key as it is printed on a key cap: `R`, `F5`, `Enter`, an arrow. */
30
- function keyLabel(key: string, mac: boolean): string {
31
- return (mac ? MAC_KEY_NAMES : KEY_NAMES)[key] ?? key.toUpperCase();
32
- }
33
-
34
- /** A spec as a person reads it: `Ctrl+Shift+R`, or `⌃⇧R`-style glyphs on a Mac (`⌘` for Cmd, `⌥` for Option). */
35
- export function formatSpec(spec: string, env: KeyEnvironment): string {
36
- const parsed = parseSpec(spec);
37
- const modifiers = resolveModifiers(parsed, env);
38
- if (env.mac) {
39
- return [modifiers.ctrl && "⌃", modifiers.alt && "⌥", modifiers.shift && "⇧", modifiers.meta && "⌘", keyLabel(parsed.key, true)]
40
- .filter(Boolean)
41
- .join("");
42
- }
43
- return [modifiers.ctrl && "Ctrl", modifiers.shift && "Shift", modifiers.alt && "Alt", modifiers.meta && "Meta", keyLabel(parsed.key, false)]
44
- .filter(Boolean)
45
- .join("+");
46
- }
47
-
48
- const ARIA_NAMED_KEYS: Record<string, string> = {
49
- escape: "Escape",
50
- enter: "Enter",
51
- tab: "Tab",
52
- backspace: "Backspace",
53
- delete: "Delete",
54
- insert: "Insert",
55
- home: "Home",
56
- end: "End",
57
- pageup: "PageUp",
58
- pagedown: "PageDown",
59
- arrowup: "ArrowUp",
60
- arrowdown: "ArrowDown",
61
- arrowleft: "ArrowLeft",
62
- arrowright: "ArrowRight",
63
- " ": "Space",
64
- };
65
-
66
- /** A spec in `aria-keyshortcuts` syntax: `Control+Shift+R`, `Meta+R`. */
67
- export function ariaSpec(spec: string, env: KeyEnvironment): string {
68
- const parsed = parseSpec(spec);
69
- const modifiers = resolveModifiers(parsed, env);
70
- const key = ARIA_NAMED_KEYS[parsed.key] ?? parsed.key.toUpperCase();
71
- return [modifiers.ctrl && "Control", modifiers.alt && "Alt", modifiers.shift && "Shift", modifiers.meta && "Meta", key].filter(Boolean).join("+");
72
- }
73
-
74
- /** Every spec that triggers a shortcut here: its keys, and in the desktop client also its desktop-only ones. */
75
- export function specsFor(shortcut: ShortcutDef, env: KeyEnvironment): string[] {
76
- return env.electron && shortcut.electronKeys ? [...shortcut.keys, ...shortcut.electronKeys] : [...shortcut.keys];
77
- }
78
-
79
- /** The `aria-keyshortcuts` value for a control that runs a shortcut: every alternative, space separated. */
80
- export function ariaKeyShortcuts(shortcut: ShortcutDef, env: KeyEnvironment): string {
81
- return specsFor(shortcut, env)
82
- .map((spec) => ariaSpec(spec, env))
83
- .join(" ");
84
- }
85
-
86
- /** A tooltip/name suffix such as `Reply (Ctrl+R)`: the label with the shortcut's first key. */
87
- export function withHint(label: string, shortcut: ShortcutDef, env: KeyEnvironment): string {
88
- return `${label} (${formatSpec(shortcut.keys[0], env)})`;
89
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import type { ShortcutDef } from "./keymap.js";
6
+ import { parseSpec, resolveModifiers } from "./parse.js";
7
+ import type { KeyEnvironment } from "./platform.js";
8
+
9
+ const KEY_NAMES: Record<string, string> = {
10
+ escape: "Esc",
11
+ enter: "Enter",
12
+ tab: "Tab",
13
+ backspace: "Backspace",
14
+ delete: "Delete",
15
+ insert: "Insert",
16
+ home: "Home",
17
+ end: "End",
18
+ pageup: "Page Up",
19
+ pagedown: "Page Down",
20
+ arrowup: "↑",
21
+ arrowdown: "↓",
22
+ arrowleft: "←",
23
+ arrowright: "→",
24
+ " ": "Space",
25
+ };
26
+
27
+ const MAC_KEY_NAMES: Record<string, string> = { ...KEY_NAMES, enter: "↩", backspace: "⌫", delete: "⌦" };
28
+
29
+ /** The key as it is printed on a key cap: `R`, `F5`, `Enter`, an arrow. */
30
+ function keyLabel(key: string, mac: boolean): string {
31
+ return (mac ? MAC_KEY_NAMES : KEY_NAMES)[key] ?? key.toUpperCase();
32
+ }
33
+
34
+ /** A spec as a person reads it: `Ctrl+Shift+R`, or `⌃⇧R`-style glyphs on a Mac (`⌘` for Cmd, `⌥` for Option). */
35
+ export function formatSpec(spec: string, env: KeyEnvironment): string {
36
+ const parsed = parseSpec(spec);
37
+ const modifiers = resolveModifiers(parsed, env);
38
+ if (env.mac) {
39
+ return [modifiers.ctrl && "⌃", modifiers.alt && "⌥", modifiers.shift && "⇧", modifiers.meta && "⌘", keyLabel(parsed.key, true)]
40
+ .filter(Boolean)
41
+ .join("");
42
+ }
43
+ return [modifiers.ctrl && "Ctrl", modifiers.shift && "Shift", modifiers.alt && "Alt", modifiers.meta && "Meta", keyLabel(parsed.key, false)]
44
+ .filter(Boolean)
45
+ .join("+");
46
+ }
47
+
48
+ const ARIA_NAMED_KEYS: Record<string, string> = {
49
+ escape: "Escape",
50
+ enter: "Enter",
51
+ tab: "Tab",
52
+ backspace: "Backspace",
53
+ delete: "Delete",
54
+ insert: "Insert",
55
+ home: "Home",
56
+ end: "End",
57
+ pageup: "PageUp",
58
+ pagedown: "PageDown",
59
+ arrowup: "ArrowUp",
60
+ arrowdown: "ArrowDown",
61
+ arrowleft: "ArrowLeft",
62
+ arrowright: "ArrowRight",
63
+ " ": "Space",
64
+ };
65
+
66
+ /** A spec in `aria-keyshortcuts` syntax: `Control+Shift+R`, `Meta+R`. */
67
+ export function ariaSpec(spec: string, env: KeyEnvironment): string {
68
+ const parsed = parseSpec(spec);
69
+ const modifiers = resolveModifiers(parsed, env);
70
+ const key = ARIA_NAMED_KEYS[parsed.key] ?? parsed.key.toUpperCase();
71
+ return [modifiers.ctrl && "Control", modifiers.alt && "Alt", modifiers.shift && "Shift", modifiers.meta && "Meta", key].filter(Boolean).join("+");
72
+ }
73
+
74
+ /** Every spec that triggers a shortcut here: its keys, and in the desktop client also its desktop-only ones. */
75
+ export function specsFor(shortcut: ShortcutDef, env: KeyEnvironment): string[] {
76
+ return env.electron && shortcut.electronKeys ? [...shortcut.keys, ...shortcut.electronKeys] : [...shortcut.keys];
77
+ }
78
+
79
+ /** The `aria-keyshortcuts` value for a control that runs a shortcut: every alternative, space separated. */
80
+ export function ariaKeyShortcuts(shortcut: ShortcutDef, env: KeyEnvironment): string {
81
+ return specsFor(shortcut, env)
82
+ .map((spec) => ariaSpec(spec, env))
83
+ .join(" ");
84
+ }
85
+
86
+ /** A tooltip/name suffix such as `Reply (Ctrl+R)`: the label with the shortcut's first key. */
87
+ export function withHint(label: string, shortcut: ShortcutDef, env: KeyEnvironment): string {
88
+ return `${label} (${formatSpec(shortcut.keys[0], env)})`;
89
+ }