Javascript 我是如何获得动作键绑定标签的
我使用摩纳哥编辑器,我的问题是如何获得InternalEditorAction键绑定标签文本。 就像在上下文菜单中一样: 采取行动Javascript 我是如何获得动作键绑定标签的,javascript,visual-studio-code,monaco-editor,Javascript,Visual Studio Code,Monaco Editor,我使用摩纳哥编辑器,我的问题是如何获得InternalEditorAction键绑定标签文本。 就像在上下文菜单中一样: 采取行动 var editor = monaco.editor.create(document.getElementById("container"), { value: [ '', 'class Example {', '\tprivate m:number;', '',
var editor = monaco.editor.create(document.getElementById("container"), {
value: [
'',
'class Example {',
'\tprivate m:number;',
'',
'\tpublic met(): string {',
'\t\treturn "Hello world!";',
'\t}',
'}'
].join('\n'),
language: "typescript"
});
editor.addAction({
// An unique identifier of the contributed action.
id: 'my-unique-id',
// A label of the action that will be presented to the user.
label: 'My Label!!!',
// An optional array of keybindings for the action.
keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10,
],
// A precondition for this action.
precondition: null,
// A rule to evaluate on top of the precondition in order to dispatch the keybindings.
keybindingContext: null,
contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5,
// Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience
run: function (ed) {
const actions = ed.getActions();
console.log(actions[0])
return null;
}
});