简体   繁体   English

获取 Monaco 命令/操作 ID 的列表?

[英]Get a list of Monaco Commands/Actions IDs?

Is there a way to get a list of Monaco's available commands/actions and their IDs, like editor.action.formatDocument ?有没有办法获取 Monaco 的可用命令/操作及其 ID 的列表,例如editor.action.formatDocument

There doesn't seem to be anything in the documentation and I'm struggling to find registered actions and commands in the VS Code repository.文档中似乎没有任何内容,我正在努力在 VS Code 存储库中查找已注册的操作和命令。 The Command Palette shows most of them, but there's no indication of their IDs if you want to manually call them with executeCommand .命令面板显示了其中的大部分,但如果您想使用executeCommand手动调用它们,则不会显示它们的 ID。

editor.getSupportedActions() is what I was looking for. editor.getSupportedActions()正是我要找的。

You can use it like this to get a list of action IDs:您可以像这样使用它来获取操作 ID 列表:

let actions = editor.getSupportedActions().map((a) => a.id);
console.log(actions);

Which returns a list like this in my current Monaco setup:在我当前的摩纳哥设置中返​​回这样的列表:

[
  "actions.find",
  "actions.findWithSelection",
  "cursorRedo",
  "cursorUndo",
  "deleteAllLeft",
  "deleteAllRight",
  "editor.action.addCommentLine",
  "editor.action.addCursorsToBottom",
  "editor.action.addCursorsToTop",
  "editor.action.addSelectionToNextFindMatch",
  "editor.action.addSelectionToPreviousFindMatch",
  "editor.action.blockComment",
  "editor.action.clipboardCopyWithSyntaxHighlightingAction",
  "editor.action.commentLine",
  "editor.action.copyLinesDownAction",
  "editor.action.copyLinesUpAction",
  "editor.action.deleteLines",
  "editor.action.detectIndentation",
  "editor.action.duplicateSelection",
  "editor.action.fontZoomIn",
  "editor.action.fontZoomOut",
  "editor.action.fontZoomReset",
  "editor.action.formatDocument",
  "editor.action.formatSelection",
  "editor.action.gotoLine",
  "editor.action.goToReferences",
  "editor.action.indentationToSpaces",
  "editor.action.indentationToTabs",
  "editor.action.indentLines",
  "editor.action.indentUsingSpaces",
  "editor.action.indentUsingTabs",
  "editor.action.inPlaceReplace.down",
  "editor.action.inPlaceReplace.up",
  "editor.action.insertCursorAbove",
  "editor.action.insertCursorAtEndOfEachLineSelected",
  "editor.action.insertCursorBelow",
  "editor.action.insertLineAfter",
  "editor.action.insertLineBefore",
  "editor.action.inspectTokens",
  "editor.action.joinLines",
  "editor.action.jumpToBracket",
  "editor.action.marker.next",
  "editor.action.marker.nextInFiles",
  "editor.action.marker.prev",
  "editor.action.marker.prevInFiles",
  "editor.action.moveCarretLeftAction",
  "editor.action.moveCarretRightAction",
  "editor.action.moveLinesDownAction",
  "editor.action.moveLinesUpAction",
  "editor.action.moveSelectionToNextFindMatch",
  "editor.action.moveSelectionToPreviousFindMatch",
  "editor.action.nextMatchFindAction",
  "editor.action.nextSelectionMatchFindAction",
  "editor.action.onTypeRename",
  "editor.action.openLink",
  "editor.action.outdentLines",
  "editor.action.peekDefinition",
  "editor.action.previousMatchFindAction",
  "editor.action.previousSelectionMatchFindAction",
  "editor.action.quickCommand",
  "editor.action.quickFix",
  "editor.action.quickOutline",
  "editor.action.refactor",
  "editor.action.referenceSearch.trigger",
  "editor.action.reindentlines",
  "editor.action.reindentselectedlines",
  "editor.action.removeCommentLine",
  "editor.action.rename",
  "editor.action.revealDefinition",
  "editor.action.revealDefinitionAside",
  "editor.action.selectHighlights",
  "editor.action.selectToBracket",
  "editor.action.setSelectionAnchor",
  "editor.action.showAccessibilityHelp",
  "editor.action.showContextMenu",
  "editor.action.showDefinitionPreviewHover",
  "editor.action.showHover",
  "editor.action.smartSelect.expand",
  "editor.action.smartSelect.shrink",
  "editor.action.sortLinesAscending",
  "editor.action.sortLinesDescending",
  "editor.action.sourceAction",
  "editor.action.startFindReplaceAction",
  "editor.action.toggleHighContrast",
  "editor.action.toggleTabFocusMode",
  "editor.action.transformToLowercase",
  "editor.action.transformToTitlecase",
  "editor.action.transformToUppercase",
  "editor.action.transpose",
  "editor.action.transposeLetters",
  "editor.action.triggerParameterHints",
  "editor.action.triggerSuggest",
  "editor.action.trimTrailingWhitespace",
  "editor.action.wordHighlight.trigger",
  "editor.fold",
  "editor.foldAll",
  "editor.foldAllBlockComments",
  "editor.foldAllMarkerRegions",
  "editor.foldLevel1",
  "editor.foldLevel2",
  "editor.foldLevel3",
  "editor.foldLevel4",
  "editor.foldLevel5",
  "editor.foldLevel6",
  "editor.foldLevel7",
  "editor.foldRecursively",
  "editor.toggleFold",
  "editor.unfold",
  "editor.unfoldAll",
  "editor.unfoldAllMarkerRegions",
  "editor.unfoldRecursively"
]

Or you can use:或者您可以使用:

let actions = editor.getActions();
console.log(actions);

let actions = editor._actions;
console.log(actions);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM