@theia/keymaps 1.45.0 → 1.46.0-next.72
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 +61 -61
- package/lib/browser/index.d.ts +3 -3
- package/lib/browser/index.js +30 -30
- package/lib/browser/keybinding-schema-updater.d.ts +85 -85
- package/lib/browser/keybinding-schema-updater.js +116 -116
- package/lib/browser/keybindings-widget.d.ts +275 -275
- package/lib/browser/keybindings-widget.js +824 -824
- package/lib/browser/keymaps-frontend-contribution.d.ts +37 -37
- package/lib/browser/keymaps-frontend-contribution.js +294 -294
- package/lib/browser/keymaps-frontend-module.d.ts +5 -5
- package/lib/browser/keymaps-frontend-module.js +44 -44
- package/lib/browser/keymaps-monaco-contribution.d.ts +1 -1
- package/lib/browser/keymaps-monaco-contribution.js +27 -27
- package/lib/browser/keymaps-service.d.ts +61 -61
- package/lib/browser/keymaps-service.js +231 -231
- package/lib/package.spec.js +25 -25
- package/package.json +8 -8
- package/src/browser/index.ts +19 -19
- package/src/browser/keybinding-schema-updater.ts +95 -95
- package/src/browser/keybindings-widget.tsx +953 -953
- package/src/browser/keymaps-frontend-contribution.ts +296 -296
- package/src/browser/keymaps-frontend-module.ts +44 -44
- package/src/browser/keymaps-monaco-contribution.ts +26 -26
- package/src/browser/keymaps-service.ts +214 -214
- package/src/browser/style/index.css +182 -182
- package/src/package.spec.ts +28 -28
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { nls, CommandRegistry, InMemoryResources, deepClone } from '@theia/core/lib/common';
|
|
18
|
-
import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
|
|
19
|
-
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
20
|
-
import URI from '@theia/core/lib/common/uri';
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
export class KeybindingSchemaUpdater implements JsonSchemaContribution {
|
|
24
|
-
protected readonly uri = new URI(keybindingSchemaId);
|
|
25
|
-
@inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
|
|
26
|
-
@inject(InMemoryResources) protected readonly inMemoryResources: InMemoryResources;
|
|
27
|
-
|
|
28
|
-
@postConstruct()
|
|
29
|
-
protected init(): void {
|
|
30
|
-
this.inMemoryResources.add(new URI(keybindingSchemaId), '');
|
|
31
|
-
this.updateSchema();
|
|
32
|
-
this.commandRegistry.onCommandsChanged(() => this.updateSchema());
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
registerSchemas(store: JsonSchemaRegisterContext): void {
|
|
36
|
-
store.registerSchema({
|
|
37
|
-
fileMatch: ['keybindings.json', 'keymaps.json'],
|
|
38
|
-
url: this.uri.toString(),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected updateSchema(): void {
|
|
43
|
-
const schema = deepClone(keybindingSchema);
|
|
44
|
-
const enumValues = schema.items.allOf[0].properties!.command.anyOf[1].enum!;
|
|
45
|
-
const enumDescriptions = schema.items.allOf[0].properties!.command.anyOf[1].enumDescriptions!;
|
|
46
|
-
for (const command of this.commandRegistry.getAllCommands()) {
|
|
47
|
-
if (command.handlers.length > 0 && !command.id.startsWith('_')) {
|
|
48
|
-
enumValues.push(command.id);
|
|
49
|
-
enumDescriptions.push(command.label ?? '');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
this.inMemoryResources.update(this.uri, JSON.stringify(schema));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const keybindingSchemaId = 'vscode://schemas/keybindings';
|
|
57
|
-
export const keybindingSchema = {
|
|
58
|
-
$id: keybindingSchemaId,
|
|
59
|
-
type: 'array',
|
|
60
|
-
title: 'Keybinding Configuration File',
|
|
61
|
-
default: [],
|
|
62
|
-
definitions: {
|
|
63
|
-
key: { type: 'string', description: nls.localizeByDefault('Key or key sequence (separated by space)') },
|
|
64
|
-
},
|
|
65
|
-
items: {
|
|
66
|
-
type: 'object',
|
|
67
|
-
defaultSnippets: [{ body: { key: '$1', command: '$2', when: '$3' } }],
|
|
68
|
-
allOf: [
|
|
69
|
-
{
|
|
70
|
-
required: ['command'],
|
|
71
|
-
properties: {
|
|
72
|
-
command: {
|
|
73
|
-
anyOf: [{ type: 'string' }, { enum: <string[]>[], enumDescriptions: <string[]>[] }], description: nls.localizeByDefault('Name of the command to execute')
|
|
74
|
-
},
|
|
75
|
-
when: { type: 'string', description: nls.localizeByDefault('Condition when the key is active.') },
|
|
76
|
-
args: { description: nls.localizeByDefault('Arguments to pass to the command to execute.') },
|
|
77
|
-
context: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
description: nls.localizeByDefault('Condition when the key is active.'),
|
|
80
|
-
deprecationMessage: nls.localize('theia/keybinding-schema-updater/deprecation', 'Use `when` clause instead.')
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
anyOf: [
|
|
86
|
-
{ required: ['key'], properties: { key: { $ref: '#/definitions/key' }, } },
|
|
87
|
-
{ required: ['keybinding'], properties: { keybinding: { $ref: '#/definitions/key' } } }
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
allowComments: true,
|
|
93
|
-
allowTrailingCommas: true,
|
|
94
|
-
};
|
|
95
|
-
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { nls, CommandRegistry, InMemoryResources, deepClone } from '@theia/core/lib/common';
|
|
18
|
+
import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
|
|
19
|
+
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
20
|
+
import URI from '@theia/core/lib/common/uri';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class KeybindingSchemaUpdater implements JsonSchemaContribution {
|
|
24
|
+
protected readonly uri = new URI(keybindingSchemaId);
|
|
25
|
+
@inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
|
|
26
|
+
@inject(InMemoryResources) protected readonly inMemoryResources: InMemoryResources;
|
|
27
|
+
|
|
28
|
+
@postConstruct()
|
|
29
|
+
protected init(): void {
|
|
30
|
+
this.inMemoryResources.add(new URI(keybindingSchemaId), '');
|
|
31
|
+
this.updateSchema();
|
|
32
|
+
this.commandRegistry.onCommandsChanged(() => this.updateSchema());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
registerSchemas(store: JsonSchemaRegisterContext): void {
|
|
36
|
+
store.registerSchema({
|
|
37
|
+
fileMatch: ['keybindings.json', 'keymaps.json'],
|
|
38
|
+
url: this.uri.toString(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected updateSchema(): void {
|
|
43
|
+
const schema = deepClone(keybindingSchema);
|
|
44
|
+
const enumValues = schema.items.allOf[0].properties!.command.anyOf[1].enum!;
|
|
45
|
+
const enumDescriptions = schema.items.allOf[0].properties!.command.anyOf[1].enumDescriptions!;
|
|
46
|
+
for (const command of this.commandRegistry.getAllCommands()) {
|
|
47
|
+
if (command.handlers.length > 0 && !command.id.startsWith('_')) {
|
|
48
|
+
enumValues.push(command.id);
|
|
49
|
+
enumDescriptions.push(command.label ?? '');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.inMemoryResources.update(this.uri, JSON.stringify(schema));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const keybindingSchemaId = 'vscode://schemas/keybindings';
|
|
57
|
+
export const keybindingSchema = {
|
|
58
|
+
$id: keybindingSchemaId,
|
|
59
|
+
type: 'array',
|
|
60
|
+
title: 'Keybinding Configuration File',
|
|
61
|
+
default: [],
|
|
62
|
+
definitions: {
|
|
63
|
+
key: { type: 'string', description: nls.localizeByDefault('Key or key sequence (separated by space)') },
|
|
64
|
+
},
|
|
65
|
+
items: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
defaultSnippets: [{ body: { key: '$1', command: '$2', when: '$3' } }],
|
|
68
|
+
allOf: [
|
|
69
|
+
{
|
|
70
|
+
required: ['command'],
|
|
71
|
+
properties: {
|
|
72
|
+
command: {
|
|
73
|
+
anyOf: [{ type: 'string' }, { enum: <string[]>[], enumDescriptions: <string[]>[] }], description: nls.localizeByDefault('Name of the command to execute')
|
|
74
|
+
},
|
|
75
|
+
when: { type: 'string', description: nls.localizeByDefault('Condition when the key is active.') },
|
|
76
|
+
args: { description: nls.localizeByDefault('Arguments to pass to the command to execute.') },
|
|
77
|
+
context: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: nls.localizeByDefault('Condition when the key is active.'),
|
|
80
|
+
deprecationMessage: nls.localize('theia/keybinding-schema-updater/deprecation', 'Use `when` clause instead.')
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
anyOf: [
|
|
86
|
+
{ required: ['key'], properties: { key: { $ref: '#/definitions/key' }, } },
|
|
87
|
+
{ required: ['keybinding'], properties: { keybinding: { $ref: '#/definitions/key' } } }
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
allowComments: true,
|
|
93
|
+
allowTrailingCommas: true,
|
|
94
|
+
};
|
|
95
|
+
|