@opensumi/ide-keymaps 2.21.6 → 2.21.7-next-1670485458.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/package.json +11 -10
- package/src/browser/index.ts +18 -0
- package/src/browser/keymaps-parser.ts +116 -0
- package/src/browser/keymaps.contribution.ts +202 -0
- package/src/browser/keymaps.module.less +409 -0
- package/src/browser/keymaps.service.ts +763 -0
- package/src/browser/keymaps.view.tsx +426 -0
- package/src/common/const.ts +3 -0
- package/src/common/index.ts +2 -0
- package/src/common/keymaps.ts +113 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import cls from 'classnames';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Input, ValidateInput, VALIDATE_TYPE, ValidateMessage } from '@opensumi/ide-components';
|
|
5
|
+
import { RecycleList } from '@opensumi/ide-components';
|
|
6
|
+
import {
|
|
7
|
+
localize,
|
|
8
|
+
useInjectable,
|
|
9
|
+
KeybindingScope,
|
|
10
|
+
NO_KEYBINDING_NAME,
|
|
11
|
+
KeyCode,
|
|
12
|
+
Key,
|
|
13
|
+
formatLocalize,
|
|
14
|
+
} from '@opensumi/ide-core-browser';
|
|
15
|
+
import { getIcon } from '@opensumi/ide-core-browser';
|
|
16
|
+
import { ReactEditorComponent } from '@opensumi/ide-editor/lib/browser';
|
|
17
|
+
|
|
18
|
+
import { IKeymapService, KeybindingItem } from '../common';
|
|
19
|
+
|
|
20
|
+
import styles from './keymaps.module.less';
|
|
21
|
+
import { KeymapService } from './keymaps.service';
|
|
22
|
+
|
|
23
|
+
export const KeymapsView: ReactEditorComponent<null> = () => {
|
|
24
|
+
const {
|
|
25
|
+
keybindings: defaultKeybindings,
|
|
26
|
+
searchKeybindings,
|
|
27
|
+
validateKeybinding,
|
|
28
|
+
detectKeybindings,
|
|
29
|
+
setKeybinding,
|
|
30
|
+
resetKeybinding,
|
|
31
|
+
getRaw,
|
|
32
|
+
getScope,
|
|
33
|
+
covert,
|
|
34
|
+
clearCovert,
|
|
35
|
+
fixed,
|
|
36
|
+
onDidKeymapChanges,
|
|
37
|
+
}: KeymapService = useInjectable(IKeymapService);
|
|
38
|
+
const [activeKeyboardSearch, setActiveKeyboardSearch] = React.useState<boolean>(false);
|
|
39
|
+
|
|
40
|
+
const [search, setSearch] = React.useState<string>('');
|
|
41
|
+
const [keybindings, setKeybindings] = React.useState<KeybindingItem[]>(defaultKeybindings);
|
|
42
|
+
|
|
43
|
+
const template = ({ data, index }) => {
|
|
44
|
+
const { id, command, when, source, keybinding }: KeybindingItem = data;
|
|
45
|
+
const [isEditing, setIsEditing] = React.useState<boolean>(false);
|
|
46
|
+
const [value, setValue] = React.useState<string>(keybinding || '');
|
|
47
|
+
const [isDirty, setIsDirty] = React.useState<boolean>(false);
|
|
48
|
+
const [validateMessage, setValidateMessage] = React.useState<ValidateMessage>();
|
|
49
|
+
const [detectiveKeybindings, setDetectiveKeybindings] = React.useState<KeybindingItem[]>([]);
|
|
50
|
+
const clickHandler = () => {
|
|
51
|
+
// 修改时固定设置页面
|
|
52
|
+
if (!isDirty) {
|
|
53
|
+
fixed();
|
|
54
|
+
setIsDirty(true);
|
|
55
|
+
}
|
|
56
|
+
clearCovert();
|
|
57
|
+
// 每次keybinding编辑的时候还原快捷键文本
|
|
58
|
+
setValue(getRaw(keybinding));
|
|
59
|
+
setIsEditing(true);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const updateKeybinding = (value: string) => {
|
|
63
|
+
const validateMessage = validateKeybinding(data, value);
|
|
64
|
+
if (validateMessage) {
|
|
65
|
+
// ' ' 表示快捷键未修改
|
|
66
|
+
if (validateMessage !== ' ') {
|
|
67
|
+
setValidateMessage({
|
|
68
|
+
message: validateMessage,
|
|
69
|
+
type: VALIDATE_TYPE.ERROR,
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
setIsEditing(false);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
setKeybinding(
|
|
76
|
+
{
|
|
77
|
+
command: getRaw(id),
|
|
78
|
+
when: getRaw(when) || '',
|
|
79
|
+
keybinding: getRaw(keybinding),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
command: getRaw(id),
|
|
83
|
+
when: getRaw(when) || '',
|
|
84
|
+
keybinding: value,
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
setIsEditing(false);
|
|
88
|
+
clearCovert();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const blurHandler = () => {
|
|
93
|
+
setIsEditing(false);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const keydownHandler = (event: React.KeyboardEvent) => {
|
|
97
|
+
event.stopPropagation();
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
const { key } = KeyCode.createKeyCode(event.nativeEvent);
|
|
100
|
+
const hasModifyKey =
|
|
101
|
+
event.nativeEvent.shiftKey ||
|
|
102
|
+
event.nativeEvent.metaKey ||
|
|
103
|
+
event.nativeEvent.altKey ||
|
|
104
|
+
event.nativeEvent.ctrlKey;
|
|
105
|
+
if (key && Key.ENTER.keyCode === key.keyCode && !hasModifyKey) {
|
|
106
|
+
if (value) {
|
|
107
|
+
updateKeybinding(value);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
setValue(covert(event.nativeEvent));
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const renderOptionalActions = () => {
|
|
115
|
+
const clear = () => {
|
|
116
|
+
setValidateMessage(undefined);
|
|
117
|
+
if (value) {
|
|
118
|
+
setValue('');
|
|
119
|
+
}
|
|
120
|
+
clearCovert();
|
|
121
|
+
};
|
|
122
|
+
const preventMouseDown = (event) => {
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
};
|
|
126
|
+
return (
|
|
127
|
+
<div className={styles.keybinding_optional_actions} onMouseDown={preventMouseDown}>
|
|
128
|
+
<span
|
|
129
|
+
className={cls(getIcon('close-circle-fill'), styles.keybinding_optional_action)}
|
|
130
|
+
onClick={clear}
|
|
131
|
+
title={localize('keymaps.action.clear')}
|
|
132
|
+
></span>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const renderPlaceholder = () => <div className={styles.keybinding_key_input_placeholder}>⏎</div>;
|
|
138
|
+
|
|
139
|
+
const renderReset = (source?: string) => {
|
|
140
|
+
const reset = (event) => {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
// 修改时固定设置页面
|
|
143
|
+
if (!isDirty) {
|
|
144
|
+
fixed();
|
|
145
|
+
setIsDirty(true);
|
|
146
|
+
}
|
|
147
|
+
resetKeybinding({
|
|
148
|
+
command: getRaw(id),
|
|
149
|
+
when: getRaw(when) || '',
|
|
150
|
+
keybinding: value,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
// 重置快捷键作用域
|
|
154
|
+
if (source && getRaw(source) === getScope(KeybindingScope.USER)) {
|
|
155
|
+
return (
|
|
156
|
+
<span
|
|
157
|
+
className={cls(getIcon('rollback'), styles.keybinding_inline_action)}
|
|
158
|
+
onClick={reset}
|
|
159
|
+
title={localize('keymaps.action.reset')}
|
|
160
|
+
></span>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const renderDetectiveKeybindings = () => {
|
|
166
|
+
if (!validateMessage && detectiveKeybindings.length > 0) {
|
|
167
|
+
return (
|
|
168
|
+
<div className={styles.keybinding_detective_messages}>
|
|
169
|
+
<div className={styles.keybinding_detective_messages_label}>
|
|
170
|
+
{formatLocalize('keymaps.keybinding.duplicate', detectiveKeybindings.length)}
|
|
171
|
+
</div>
|
|
172
|
+
<ul className={styles.keybinding_detective_messages_container}>
|
|
173
|
+
{detectiveKeybindings.map((keybinding: KeybindingItem, index: number) => (
|
|
174
|
+
<li
|
|
175
|
+
className={styles.keybinding_detective_messages_item}
|
|
176
|
+
key={`${keybinding.id}_${index}`}
|
|
177
|
+
title={`${keybinding.command}-${keybinding.when}`}
|
|
178
|
+
>
|
|
179
|
+
<div className={styles.title}>
|
|
180
|
+
{localize('keymaps.header.command.title')}: {getRaw(keybinding.command) || '-'}
|
|
181
|
+
</div>
|
|
182
|
+
<div className={styles.description}>
|
|
183
|
+
<div style={{ marginRight: 4 }}>
|
|
184
|
+
{localize('keymaps.header.source.title')}: {getRaw(keybinding.source) || '-'}
|
|
185
|
+
</div>
|
|
186
|
+
<div>
|
|
187
|
+
{localize('keymaps.header.when.title')}: {getRaw(keybinding.when) || '—'}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</li>
|
|
191
|
+
))}
|
|
192
|
+
</ul>
|
|
193
|
+
</div>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const renderKeybinding = () => {
|
|
199
|
+
if (isEditing) {
|
|
200
|
+
return (
|
|
201
|
+
<div className={styles.keybinding_key_input_container}>
|
|
202
|
+
{renderOptionalActions()}
|
|
203
|
+
<ValidateInput
|
|
204
|
+
placeholder={localize('keymaps.edit.placeholder')}
|
|
205
|
+
validateMessage={validateMessage}
|
|
206
|
+
className={styles.keybinding_key_input}
|
|
207
|
+
size='small'
|
|
208
|
+
autoFocus={true}
|
|
209
|
+
name={NO_KEYBINDING_NAME}
|
|
210
|
+
value={value}
|
|
211
|
+
onKeyDown={keydownHandler}
|
|
212
|
+
onBlur={blurHandler}
|
|
213
|
+
/>
|
|
214
|
+
{renderPlaceholder()}
|
|
215
|
+
{renderDetectiveKeybindings()}
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
} else {
|
|
219
|
+
const keyBlocks = keybinding?.split(' ');
|
|
220
|
+
return (
|
|
221
|
+
<div className={styles.keybinding_key} title={getRaw(keybinding)} onDoubleClick={clickHandler}>
|
|
222
|
+
<div className={styles.keybinding_action} onClick={clickHandler}>
|
|
223
|
+
<span
|
|
224
|
+
className={cls(keybinding ? getIcon('edit') : getIcon('plus'), styles.keybinding_inline_action)}
|
|
225
|
+
title={keybinding ? localize('keymaps.action.edit') : localize('keymaps.action.add')}
|
|
226
|
+
></span>
|
|
227
|
+
{renderReset(source)}
|
|
228
|
+
</div>
|
|
229
|
+
{keyBlocks && !!keyBlocks[0]
|
|
230
|
+
? keyBlocks.map((block, index) => {
|
|
231
|
+
const keys = block.split('+');
|
|
232
|
+
return (
|
|
233
|
+
<div className={styles.keybinding_key_block} key={`${block}_${index}`}>
|
|
234
|
+
{keys.map((key, index) => (
|
|
235
|
+
<div
|
|
236
|
+
className={styles.keybinding_key_item}
|
|
237
|
+
key={`${key}_${index}`}
|
|
238
|
+
dangerouslySetInnerHTML={{ __html: key || '' }}
|
|
239
|
+
></div>
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
})
|
|
244
|
+
: '—'}
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
// 当值变化时清空错误信息
|
|
252
|
+
if (validateMessage) {
|
|
253
|
+
setValidateMessage(undefined);
|
|
254
|
+
}
|
|
255
|
+
// 根据快捷键查当前绑定的命令
|
|
256
|
+
if (value && isEditing) {
|
|
257
|
+
setDetectiveKeybindings(detectKeybindings(data, value));
|
|
258
|
+
} else {
|
|
259
|
+
setDetectiveKeybindings([]);
|
|
260
|
+
}
|
|
261
|
+
}, [value]);
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div className={cls(styles.keybinding_list_item, index % 2 === 1 && styles.odd)}>
|
|
265
|
+
<div className={cls(styles.keybinding_list_item_box, styles.keybinding_command)}>
|
|
266
|
+
<div
|
|
267
|
+
className={styles.command_name}
|
|
268
|
+
title={getRaw(command)}
|
|
269
|
+
dangerouslySetInnerHTML={{ __html: command }}
|
|
270
|
+
></div>
|
|
271
|
+
<div
|
|
272
|
+
className={cls(styles.limit_warp, styles.command_id)}
|
|
273
|
+
title={getRaw(id)}
|
|
274
|
+
dangerouslySetInnerHTML={{ __html: formatLocalize('keymaps.commandId.title', id) }}
|
|
275
|
+
></div>
|
|
276
|
+
</div>
|
|
277
|
+
<div className={cls(styles.keybinding_list_item_box)}>{renderKeybinding()}</div>
|
|
278
|
+
<div className={styles.keybinding_list_item_box}>
|
|
279
|
+
<div
|
|
280
|
+
className={styles.limit_warp}
|
|
281
|
+
title={getRaw(when || '—')}
|
|
282
|
+
dangerouslySetInnerHTML={{ __html: when || '—' }}
|
|
283
|
+
></div>
|
|
284
|
+
</div>
|
|
285
|
+
<div className={styles.keybinding_list_item_box}>
|
|
286
|
+
<div title={getRaw(source)} dangerouslySetInnerHTML={{ __html: source || '' }}></div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const renderInputPlaceholder = () => {
|
|
293
|
+
const activeKeyboard = () => {
|
|
294
|
+
setActiveKeyboardSearch(!activeKeyboardSearch);
|
|
295
|
+
};
|
|
296
|
+
return (
|
|
297
|
+
<div className={styles.search_inline_action}>
|
|
298
|
+
<span
|
|
299
|
+
className={cls(getIcon('keyboard'), styles.search_inline_action_icon, activeKeyboardSearch && styles.active)}
|
|
300
|
+
onClick={activeKeyboard}
|
|
301
|
+
></span>
|
|
302
|
+
</div>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const handleSearchChange = useCallback(
|
|
307
|
+
(value: string) => {
|
|
308
|
+
setSearch(value);
|
|
309
|
+
searchKeybindings(value);
|
|
310
|
+
},
|
|
311
|
+
[search],
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
const onChangeHandler = (event) => {
|
|
315
|
+
if (!activeKeyboardSearch) {
|
|
316
|
+
const value = event.target && event.target.value ? event.target.value.toLocaleLowerCase() : '';
|
|
317
|
+
handleSearchChange(value);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const onKeyDownHandler = (event) => {
|
|
322
|
+
if (activeKeyboardSearch) {
|
|
323
|
+
event.stopPropagation();
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
const { key } = KeyCode.createKeyCode(event.nativeEvent);
|
|
326
|
+
if (key && Key.ENTER.keyCode === key.keyCode) {
|
|
327
|
+
// 屏蔽回车键作为快捷键搜索
|
|
328
|
+
return;
|
|
329
|
+
} else {
|
|
330
|
+
handleSearchChange(covert(event.nativeEvent));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const clearSearch = () => {
|
|
336
|
+
if (search) {
|
|
337
|
+
setSearch('');
|
|
338
|
+
searchKeybindings('');
|
|
339
|
+
}
|
|
340
|
+
clearCovert();
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const renderOptionalActions = () => (
|
|
344
|
+
<div className={styles.keybinding_optional_actions}>
|
|
345
|
+
<span
|
|
346
|
+
className={cls(getIcon('close-circle-fill'), styles.keybinding_optional_action)}
|
|
347
|
+
onClick={clearSearch}
|
|
348
|
+
title={localize('keymaps.action.reset')}
|
|
349
|
+
></span>
|
|
350
|
+
</div>
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const renderSearchInput = () => (
|
|
354
|
+
<div className={styles.search_container}>
|
|
355
|
+
<Input
|
|
356
|
+
className={styles.search_input}
|
|
357
|
+
placeholder={localize(
|
|
358
|
+
activeKeyboardSearch ? 'keymaps.search.keyboard.placeholder' : 'keymaps.search.placeholder',
|
|
359
|
+
)}
|
|
360
|
+
type='text'
|
|
361
|
+
value={search}
|
|
362
|
+
name={NO_KEYBINDING_NAME}
|
|
363
|
+
onChange={onChangeHandler}
|
|
364
|
+
onKeyDown={onKeyDownHandler}
|
|
365
|
+
addonBefore={renderInputPlaceholder()}
|
|
366
|
+
/>
|
|
367
|
+
{renderOptionalActions()}
|
|
368
|
+
</div>
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
const KeybindingHeader = useMemo(() => {
|
|
372
|
+
const headers = [
|
|
373
|
+
{
|
|
374
|
+
title: localize('keymaps.header.command.title'),
|
|
375
|
+
classname: styles.keybinding_header_item,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
title: localize('keymaps.header.keybinding.title'),
|
|
379
|
+
classname: styles.keybinding_header_item,
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
title: localize('keymaps.header.when.title'),
|
|
383
|
+
classname: styles.keybinding_header_item,
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
title: localize('keymaps.header.source.title'),
|
|
387
|
+
classname: styles.keybinding_header_item,
|
|
388
|
+
},
|
|
389
|
+
];
|
|
390
|
+
return (
|
|
391
|
+
<div className={styles.keybinding_header}>
|
|
392
|
+
{headers.map((h, index) => (
|
|
393
|
+
<div className={h.classname} key={`${h.title}_${index}`}>
|
|
394
|
+
{h.title}
|
|
395
|
+
</div>
|
|
396
|
+
))}
|
|
397
|
+
</div>
|
|
398
|
+
);
|
|
399
|
+
}, []);
|
|
400
|
+
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
const dispose = onDidKeymapChanges((kbs) => {
|
|
403
|
+
setKeybindings(kbs);
|
|
404
|
+
});
|
|
405
|
+
return () => {
|
|
406
|
+
dispose.dispose();
|
|
407
|
+
};
|
|
408
|
+
}, []);
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<div className={styles.keybinding_container}>
|
|
412
|
+
<div className={styles.keybinding_searchbar}>{renderSearchInput()}</div>
|
|
413
|
+
<div className={styles.keybinding_body}>
|
|
414
|
+
{KeybindingHeader}
|
|
415
|
+
<div className={styles.keybinding_list}>
|
|
416
|
+
<RecycleList
|
|
417
|
+
itemHeight={40}
|
|
418
|
+
data={keybindings}
|
|
419
|
+
template={template}
|
|
420
|
+
className={styles.keybinding_list_container}
|
|
421
|
+
/>
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
);
|
|
426
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// 快捷键相关功能为纯前端模块,这里直接从browser引入定义
|
|
2
|
+
import { Keybinding, IDisposable } from '@opensumi/ide-core-browser';
|
|
3
|
+
|
|
4
|
+
export const IKeymapService = Symbol('IKeymapService');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 从 keymap.json 读取的值
|
|
8
|
+
*/
|
|
9
|
+
export interface KeymapItem {
|
|
10
|
+
/**
|
|
11
|
+
* 快捷键
|
|
12
|
+
*/
|
|
13
|
+
key: string;
|
|
14
|
+
/**
|
|
15
|
+
* 快捷键
|
|
16
|
+
* @deprecated 为了兼容老格式,这个字段还保留
|
|
17
|
+
*/
|
|
18
|
+
keybinding?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 命令 id
|
|
21
|
+
*/
|
|
22
|
+
command: string;
|
|
23
|
+
/**
|
|
24
|
+
* When条件语句
|
|
25
|
+
*/
|
|
26
|
+
when?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Context条件语句
|
|
29
|
+
*/
|
|
30
|
+
context?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 命令参数
|
|
33
|
+
*/
|
|
34
|
+
args?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface KeybindingItem extends Omit<KeymapItem, 'key'> {
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* 快捷键
|
|
41
|
+
*/
|
|
42
|
+
keybinding?: string;
|
|
43
|
+
/**
|
|
44
|
+
* 作用域
|
|
45
|
+
*/
|
|
46
|
+
source?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 判断快捷键是否带有command label
|
|
49
|
+
*/
|
|
50
|
+
hasCommandLabel?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IKeymapService {
|
|
54
|
+
/**
|
|
55
|
+
* 快捷键是否初始化完成
|
|
56
|
+
*/
|
|
57
|
+
whenReady: Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* 初始化快捷键注册信息
|
|
60
|
+
*/
|
|
61
|
+
init(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* 设置快捷键
|
|
64
|
+
* @param {Keybinding} rawKeybinding
|
|
65
|
+
* @param {Keybinding} keybinding
|
|
66
|
+
* @returns {Promise<void>}
|
|
67
|
+
* @memberof KeymapsService
|
|
68
|
+
*/
|
|
69
|
+
setKeybinding(rawKeybinding: Keybinding, keybinding: Keybinding): Promise<void>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 移除给定ID的快捷键绑定
|
|
73
|
+
* @param {Keybinding} keybinding
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
* @memberof KeymapsService
|
|
76
|
+
*/
|
|
77
|
+
resetKeybinding(keybinding: Keybinding): Promise<void>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 从keymaps.json获取快捷键列表
|
|
81
|
+
* @returns {Promise<KeybindingJson[]>}
|
|
82
|
+
* @memberof KeymapsService
|
|
83
|
+
*/
|
|
84
|
+
getKeybindings(): Promise<Keybinding[]>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 打开快捷键面板
|
|
88
|
+
* @returns {Promise<void>}
|
|
89
|
+
* @memberof IKeymapService
|
|
90
|
+
*/
|
|
91
|
+
open(): Promise<void>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 固定快捷键面板
|
|
95
|
+
* @returns {Promise<void>}
|
|
96
|
+
* @memberof IKeymapService
|
|
97
|
+
*/
|
|
98
|
+
fixed(): Promise<void>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 打开快捷键源文件 keymaps.json
|
|
102
|
+
* @returns {Promise<void>}
|
|
103
|
+
* @memberof IKeymapService
|
|
104
|
+
*/
|
|
105
|
+
openResource(): Promise<void>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 监听快捷键改变完成后事件
|
|
109
|
+
* @returns {void}
|
|
110
|
+
* @memberof IKeymapService
|
|
111
|
+
*/
|
|
112
|
+
onDidKeymapChanges(listener: () => any): IDisposable;
|
|
113
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common';
|