@@ -120,12 +120,13 @@ export function findStartIndex(num: number, nums: number[]) {
120
120
return startIndex ;
121
121
}
122
122
123
- const getShortcutWithPrefix = ( key : string ) => {
124
- if ( typeof navigator !== 'undefined' && / M a c / . test ( navigator . platform ) ) {
125
- return 'Cmd-' + key ;
126
- } else {
127
- return 'Ctrl-' + key ;
128
- }
123
+ const getShortcutWithPrefix = ( key : string , shift = false ) => {
124
+ const shiftPrefix = shift ? 'Shift-' : '' ;
125
+ const CmdPrefix =
126
+ typeof navigator !== 'undefined' && / M a c / . test ( navigator . platform )
127
+ ? 'Cmd-'
128
+ : 'Ctrl-' ;
129
+ return shiftPrefix + CmdPrefix + key ;
129
130
} ;
130
131
131
132
export function getBuiltinActions (
@@ -165,11 +166,11 @@ export function getBuiltinActions(
165
166
cheatsheet : `**${ locale . action . boldText } **` ,
166
167
handler : {
167
168
type : 'action' ,
169
+ shortcut : getShortcutWithPrefix ( 'B' ) ,
168
170
click ( { wrapText, editor } ) {
169
171
wrapText ( '**' ) ;
170
172
editor . focus ( ) ;
171
173
} ,
172
- shortcut : getShortcutWithPrefix ( 'B' ) ,
173
174
} ,
174
175
} ,
175
176
{
@@ -178,11 +179,11 @@ export function getBuiltinActions(
178
179
cheatsheet : `*${ locale . action . italicText } *` ,
179
180
handler : {
180
181
type : 'action' ,
182
+ shortcut : getShortcutWithPrefix ( 'I' ) ,
181
183
click ( { wrapText, editor } ) {
182
184
wrapText ( '*' ) ;
183
185
editor . focus ( ) ;
184
186
} ,
185
- shortcut : getShortcutWithPrefix ( 'I' ) ,
186
187
} ,
187
188
} ,
188
189
{
@@ -203,6 +204,7 @@ export function getBuiltinActions(
203
204
cheatsheet : `[${ locale . action . linkText } ](url)` ,
204
205
handler : {
205
206
type : 'action' ,
207
+ shortcut : getShortcutWithPrefix ( 'K' ) ,
206
208
click ( { editor, wrapText } ) {
207
209
wrapText ( '[' , '](url)' ) ;
208
210
const cursor = editor . getCursor ( ) ;
@@ -212,7 +214,6 @@ export function getBuiltinActions(
212
214
) ;
213
215
editor . focus ( ) ;
214
216
} ,
215
- shortcut : getShortcutWithPrefix ( 'K' ) ,
216
217
} ,
217
218
} ,
218
219
{
@@ -222,6 +223,7 @@ export function getBuiltinActions(
222
223
handler : uploadImages
223
224
? {
224
225
type : 'action' ,
226
+ shortcut : getShortcutWithPrefix ( 'I' , true ) ,
225
227
async click ( { appendBlock, selectFiles, editor } ) {
226
228
const fileList = await selectFiles ( {
227
229
accept : 'image/*' ,
@@ -252,6 +254,7 @@ export function getBuiltinActions(
252
254
cheatsheet : '`' + locale . action . codeText + '`' ,
253
255
handler : {
254
256
type : 'action' ,
257
+ shortcut : getShortcutWithPrefix ( 'K' , true ) ,
255
258
click ( { wrapText, editor } ) {
256
259
wrapText ( '`' ) ;
257
260
editor . focus ( ) ;
@@ -264,6 +267,7 @@ export function getBuiltinActions(
264
267
cheatsheet : '```' + locale . action . codeLang + '↵' ,
265
268
handler : {
266
269
type : 'action' ,
270
+ shortcut : getShortcutWithPrefix ( 'C' , true ) ,
267
271
click ( { editor, appendBlock } ) {
268
272
const { line } = appendBlock ( '```js\n```' ) ;
269
273
editor . setSelection ( { line, ch : 3 } , { line, ch : 5 } ) ;
@@ -277,6 +281,7 @@ export function getBuiltinActions(
277
281
cheatsheet : `- ${ locale . action . ulItem } ` ,
278
282
handler : {
279
283
type : 'action' ,
284
+ shortcut : getShortcutWithPrefix ( 'U' , true ) ,
280
285
click ( { replaceLines, editor } ) {
281
286
replaceLines ( ( line ) => '- ' + line ) ;
282
287
editor . focus ( ) ;
@@ -289,6 +294,7 @@ export function getBuiltinActions(
289
294
cheatsheet : `1. ${ locale . action . olItem } ` ,
290
295
handler : {
291
296
type : 'action' ,
297
+ shortcut : getShortcutWithPrefix ( 'O' , true ) ,
292
298
click ( { replaceLines, editor } ) {
293
299
replaceLines ( ( line , i ) => `${ i + 1 } . ${ line } ` ) ;
294
300
editor . focus ( ) ;
0 commit comments