Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
7
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
8
import { ICodeEditor } from '../../../browser/editorBrowser.js';
9
import { EditorCommand, EditorContributionInstantiation, ServicesAccessor, registerEditorCommand, registerEditorContribution } from '../../../browser/editorExtensions.js';
10
import { registerEditorFeature } from '../../../common/editorFeatures.js';
11
import { DefaultDropProvidersFeature } from './defaultProviders.js';
12
import { DropIntoEditorController, changeDropTypeCommandId, dropWidgetVisibleCtx } from './dropIntoEditorController.js';
13
14
registerEditorContribution(DropIntoEditorController.ID, DropIntoEditorController, EditorContributionInstantiation.BeforeFirstInteraction);
15
registerEditorFeature(DefaultDropProvidersFeature);
16
17
registerEditorCommand(new class extends EditorCommand {
18
constructor() {
19
super({
20
id: changeDropTypeCommandId,
21
precondition: dropWidgetVisibleCtx,
22
kbOpts: {
23
weight: KeybindingWeight.EditorContrib,
24
primary: KeyMod.CtrlCmd | KeyCode.Period,
25
}
26
});
27
}
28
29
public override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, _args: any) {
30
DropIntoEditorController.get(editor)?.changeDropType();
31
}
32
});
33
34
registerEditorCommand(new class extends EditorCommand {
35
constructor() {
36
super({
37
id: 'editor.hideDropWidget',
38
precondition: dropWidgetVisibleCtx,
39
kbOpts: {
40
weight: KeybindingWeight.EditorContrib,
41
primary: KeyCode.Escape,
42
}
43
});
44
}
45
46
public override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, _args: any) {
47
DropIntoEditorController.get(editor)?.clearWidgets();
48
}
49
});
50
51
export type PreferredDropConfiguration = string;
52
53
54