monaco-editor-core
Version:
A browser based code editor
81 lines (80 loc) • 4.42 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
import { Registry } from '../../../../platform/registry/common/platform.js';
import { Extensions } from '../../../../platform/quickinput/common/quickAccess.js';
import { QuickCommandNLS } from '../../../common/standaloneStrings.js';
import { ICodeEditorService } from '../../../browser/services/codeEditorService.js';
import { AbstractEditorCommandsQuickAccessProvider } from '../../../contrib/quickAccess/browser/commandsQuickAccess.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
import { EditorAction, registerEditorAction } from '../../../browser/editorExtensions.js';
import { EditorContextKeys } from '../../../common/editorContextKeys.js';
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
let StandaloneCommandsQuickAccessProvider = class StandaloneCommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {
get activeTextEditorControl() { return this.codeEditorService.getFocusedCodeEditor() ?? undefined; }
constructor(instantiationService, codeEditorService, keybindingService, commandService, telemetryService, dialogService) {
super({ showAlias: false }, instantiationService, keybindingService, commandService, telemetryService, dialogService);
this.codeEditorService = codeEditorService;
}
async getCommandPicks() {
return this.getCodeEditorCommandPicks();
}
hasAdditionalCommandPicks() {
return false;
}
async getAdditionalCommandPicks() {
return [];
}
};
StandaloneCommandsQuickAccessProvider = __decorate([
__param(0, IInstantiationService),
__param(1, ICodeEditorService),
__param(2, IKeybindingService),
__param(3, ICommandService),
__param(4, ITelemetryService),
__param(5, IDialogService)
], StandaloneCommandsQuickAccessProvider);
export { StandaloneCommandsQuickAccessProvider };
export class GotoLineAction extends EditorAction {
static { this.ID = 'editor.action.quickCommand'; }
constructor() {
super({
id: GotoLineAction.ID,
label: QuickCommandNLS.quickCommandActionLabel,
alias: 'Command Palette',
precondition: undefined,
kbOpts: {
kbExpr: EditorContextKeys.focus,
primary: 59 /* KeyCode.F1 */,
weight: 100 /* KeybindingWeight.EditorContrib */
},
contextMenuOpts: {
group: 'z_commands',
order: 1
}
});
}
run(accessor) {
accessor.get(IQuickInputService).quickAccess.show(StandaloneCommandsQuickAccessProvider.PREFIX);
}
}
registerEditorAction(GotoLineAction);
Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
ctor: StandaloneCommandsQuickAccessProvider,
prefix: StandaloneCommandsQuickAccessProvider.PREFIX,
helpEntries: [{ description: QuickCommandNLS.quickCommandHelp, commandId: GotoLineAction.ID }]
});