Use same lock values as mobile clients
[ProtonMail-WebClient.git] / packages / shared / lib / shortcuts / mail.ts
blob6292bc8c1ca1c74d62c9145541648a890fac1b18
1 import { c } from 'ttag';
3 import isTruthy from '@proton/utils/isTruthy';
5 import { altKey, isSafari as checkIsSafari, metaKey, shiftKey } from '../helpers/browser';
6 import type { KeyboardKeyType } from '../interfaces';
8 export const editorShortcuts: Record<string, KeyboardKeyType[]> = {
9     addAttachment: ['Meta', 'Shift', 'A'],
10     addEncryption: ['Meta', 'Shift', 'E'],
11     addExpiration: ['Meta', 'Shift', 'X'],
12     addLink: ['Meta', 'K'],
13     close: ['Escape'],
14     deleteDraft: ['Meta', 'Alt', 'Backspace'],
15     maximize: ['Meta', 'Shift', 'M'],
16     minimize: ['Meta', 'M'],
17     save: ['Meta', 'S'],
18     send: ['Meta', 'Enter'],
19     emojiPicker: ['Meta', 'E'] as KeyboardKeyType[],
22 export const getShortcuts = () => {
23     const isSafari = checkIsSafari();
25     return [
26         {
27             name: c('Keyboard shortcut section name').t`Basic navigation`,
28             alwaysActive: true,
29             shortcuts: [
30                 {
31                     name: c('Keyboard shortcut name').t`Move up`,
32                     keys: '↑',
33                 },
34                 {
35                     name: c('Keyboard shortcut name').t`Jump to first`,
36                     keys: `${metaKey} + ↑`,
37                 },
38                 {
39                     name: c('Keyboard shortcut name').t`Move down`,
40                     keys: '↓',
41                 },
42                 {
43                     name: c('Keyboard shortcut name').t`Jump to last`,
44                     keys: `${metaKey} + ↓`,
45                 },
46                 {
47                     name: c('Keyboard shortcut name').t`Move right / expand`,
48                     keys: '→',
49                 },
50                 {
51                     name: c('Keyboard shortcut name').t`Move left / collapse`,
52                     keys: '←',
53                 },
54             ],
55         },
56         {
57             name: c('Keyboard shortcut section name').t`Basic actions`,
58             alwaysActive: true,
59             shortcuts: [
60                 {
61                     name: c('Keyboard shortcut name').t`Apply / open`,
62                     keys: 'Enter',
63                 },
64                 {
65                     name: c('Keyboard shortcut name').t`Cancel / close`,
66                     keys: 'Escape',
67                 },
68                 {
69                     name: c('Keyboard shortcut name').t`Open this modal`,
70                     keys: '?',
71                 },
72                 {
73                     name: c('Keyboard shortcut name').t`Select / unselect`,
74                     keys: 'Space',
75                 },
76                 {
77                     name: c('Keyboard shortcut name').t`Open command panel`,
78                     keys: `${metaKey} + K`,
79                 },
80             ],
81         },
82         {
83             name: c('Keyboard shortcut section name').t`Folder shortcuts`,
84             shortcuts: [
85                 {
86                     name: c('Keyboard shortcut name').t`Go to Inbox`,
87                     keys: ['G', 'I'],
88                 },
89                 {
90                     name: c('Keyboard shortcut name').t`Go to Archive`,
91                     keys: ['G', 'A'],
92                 },
93                 {
94                     name: c('Keyboard shortcut name').t`Go to Sent`,
95                     keys: ['G', 'E'],
96                 },
97                 {
98                     name: c('Keyboard shortcut name').t`Go to Starred`,
99                     keys: ['G', '*'],
100                 },
101                 {
102                     name: c('Keyboard shortcut name').t`Go to Drafts`,
103                     keys: ['G', 'D'],
104                 },
105                 {
106                     name: c('Keyboard shortcut name').t`Go to Trash`,
107                     keys: ['G', 'T'],
108                 },
109                 {
110                     name: c('Keyboard shortcut name').t`Go to Spam`,
111                     keys: ['G', 'S'],
112                 },
113                 {
114                     name: c('Keyboard shortcut name').t`Go to All Mail`,
115                     keys: ['G', 'M'],
116                 },
117             ],
118         },
119         {
120             name: c('Keyboard shortcut section name').t`Composer shortcuts`,
121             shortcuts: [
122                 {
123                     name: c('Keyboard shortcut name').t`Save draft`,
124                     keys: `${metaKey} + S`,
125                 },
126                 {
127                     name: c('Keyboard shortcut name').t`Send email`,
128                     keys: `${metaKey} + Enter`,
129                 },
130                 {
131                     name: c('Keyboard shortcut name').t`Close draft`,
132                     keys: `Escape`,
133                 },
134                 !isSafari && {
135                     name: c('Keyboard shortcut name').t`Minimize / maximize composer`,
136                     keys: `${metaKey} + M`,
137                 },
138                 !isSafari && {
139                     name: c('Keyboard shortcut name').t`Expand / contract composer`,
140                     keys: `${metaKey} + ${shiftKey} + M`,
141                 },
142                 {
143                     name: c('Keyboard shortcut name').t`Attach file`,
144                     keys: `${metaKey} + ${shiftKey} + A`,
145                 },
146                 {
147                     name: c('Keyboard shortcut name').t`Add expiration time`,
148                     keys: `${metaKey} + ${shiftKey} + X`,
149                 },
150                 {
151                     name: c('Keyboard shortcut name').t`Add encryption`,
152                     keys: `${metaKey} + ${shiftKey} + E`,
153                 },
154                 {
155                     name: c('Keyboard shortcut name').t`Insert link`,
156                     keys: `${metaKey} + K`,
157                 },
158                 {
159                     name: c('Keyboard shortcut name').t`Discard draft`,
160                     keys: `${metaKey} + ${altKey} + Backspace`,
161                 },
162             ].filter(isTruthy),
163         },
164         {
165             name: c('Keyboard shortcut section name').t`List shortcuts`,
166             shortcuts: [
167                 {
168                     name: c('Keyboard shortcut name').t`Open previous message`,
169                     keys: 'K',
170                 },
171                 {
172                     name: c('Keyboard shortcut name').t`Open next message`,
173                     keys: 'J',
174                 },
175                 {
176                     name: c('Keyboard shortcut name').t`Select / unselect`,
177                     keys: 'X',
178                 },
179                 {
180                     name: c('Keyboard shortcut name').t`Show unread emails`,
181                     keys: `${shiftKey} + U`,
182                 },
183                 {
184                     name: c('Keyboard shortcut name').t`Show all emails`,
185                     keys: `${shiftKey} + A`,
186                 },
187                 {
188                     name: c('Keyboard shortcut name').t`Select / unselect all`,
189                     keys: `${metaKey} + A`,
190                 },
191                 {
192                     name: c('Keyboard shortcut name').t`Search`,
193                     keys: '/',
194                 },
195             ],
196         },
197         {
198             name: c('Keyboard shortcut section name').t`Action shortcuts`,
199             shortcuts: [
200                 {
201                     name: c('Keyboard shortcut name').t`New message`,
202                     keys: 'N',
203                 },
204                 {
205                     name: c('Keyboard shortcut name').t`Star`,
206                     keys: '*',
207                 },
208                 {
209                     name: c('Keyboard shortcut name').t`Mark as unread`,
210                     keys: 'U',
211                 },
212                 {
213                     name: c('Keyboard shortcut name').t`Mark as read`,
214                     keys: 'R',
215                 },
216                 {
217                     name: c('Keyboard shortcut name').t`Label as...`,
218                     keys: 'L',
219                 },
220                 {
221                     name: c('Keyboard shortcut name').t`Filter`,
222                     keys: 'F',
223                 },
224                 {
225                     name: c('Keyboard shortcut name').t`Move to...`,
226                     keys: 'M',
227                 },
228                 {
229                     name: c('Keyboard shortcut name').t`Move to Inbox`,
230                     keys: 'I',
231                 },
232                 {
233                     name: c('Keyboard shortcut name').t`Move to Archive`,
234                     keys: 'A',
235                 },
236                 {
237                     name: c('Keyboard shortcut name').t`Move to Spam`,
238                     keys: 'S',
239                 },
240                 {
241                     name: c('Keyboard shortcut name').t`Move to Trash`,
242                     keys: 'T',
243                 },
244                 {
245                     name: c('Keyboard shortcut name').t`Delete permanently`,
246                     keys: `${metaKey} + Backspace`,
247                 },
248             ],
249         },
250         {
251             name: c('Keyboard shortcut section name').t`Message shortcuts`,
252             shortcuts: [
253                 {
254                     name: c('Keyboard shortcut name').t`Reply`,
255                     keys: 'R',
256                 },
257                 {
258                     name: c('Keyboard shortcut name').t`Reply all`,
259                     keys: `${shiftKey} + R`,
260                 },
261                 {
262                     name: c('Keyboard shortcut name').t`Forward`,
263                     keys: `${shiftKey} + F`,
264                 },
265                 {
266                     name: c('Keyboard shortcut name').t`Load remote content`,
267                     keys: `${shiftKey} + C`,
268                 },
269                 {
270                     name: c('Keyboard shortcut name').t`Load embedded images`,
271                     keys: `${shiftKey} + E`,
272                 },
273                 {
274                     name: c('Keyboard shortcut name').t`Show original message`,
275                     keys: 'O',
276                 },
277             ],
278         },
279     ];