Path: blob/main/src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';6import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';7import { ICodeEditor } from '../../../browser/editorBrowser.js';8import { EditorCommand, EditorContributionInstantiation, ServicesAccessor, registerEditorCommand, registerEditorContribution } from '../../../browser/editorExtensions.js';9import { registerEditorFeature } from '../../../common/editorFeatures.js';10import { DefaultDropProvidersFeature } from './defaultProviders.js';11import { DropIntoEditorController, changeDropTypeCommandId, dropWidgetVisibleCtx } from './dropIntoEditorController.js';1213registerEditorContribution(DropIntoEditorController.ID, DropIntoEditorController, EditorContributionInstantiation.BeforeFirstInteraction);14registerEditorFeature(DefaultDropProvidersFeature);1516registerEditorCommand(new class extends EditorCommand {17constructor() {18super({19id: changeDropTypeCommandId,20precondition: dropWidgetVisibleCtx,21kbOpts: {22weight: KeybindingWeight.EditorContrib,23primary: KeyMod.CtrlCmd | KeyCode.Period,24}25});26}2728public override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, _args: any) {29DropIntoEditorController.get(editor)?.changeDropType();30}31});3233registerEditorCommand(new class extends EditorCommand {34constructor() {35super({36id: 'editor.hideDropWidget',37precondition: dropWidgetVisibleCtx,38kbOpts: {39weight: KeybindingWeight.EditorContrib,40primary: KeyCode.Escape,41}42});43}4445public override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, _args: any) {46DropIntoEditorController.get(editor)?.clearWidgets();47}48});4950export type PreferredDropConfiguration = string;51525354