Skip to content

feat: support keybinding via extensions#198

Merged
wewoor merged 8 commits intomainfrom
feat/keybinding
Jun 25, 2021
Merged

feat: support keybinding via extensions#198
wewoor merged 8 commits intomainfrom
feat/keybinding

Conversation

@mortalYoung
Copy link
Copy Markdown
Collaborator

@mortalYoung mortalYoung commented Jun 23, 2021

简介

  • 支持通过 keybinding 注册键盘快捷方式

主要变更

  • 移除在 ProviderinitWorkbenchActions 的方法,改成通过 extension 的方式注册
  • extensionService 中新增 registerAction 方法,用户通过该方法注册 Action
activate(extensionCtx: IExtensionService) {
       extensionCtx.registerAction(ActionClass);
}
  • 新增 keybindingHelper ,提供 query 和 convert 方法
    • query 主要用来根据 id 查找对应的全局命令,目前判断是否是全局的方式是通过是否有 when 属性判断,如果无则代表无时无刻都可以执行的命令,则理解为全局命令
    • convert 方法通过传入 query 的结果,可以将 ISimplyKeybinding 类型转为字符串以供展示
  • 优化全局的 4 个命令的 id,因为 query 要通过 id 来查找注册的全局命令,这就使得如果注册的 id 和 menu id 如果不保持一致的话,会导致找不到命令,所以有一个强制要求,就是 menuid 需要和注册的全局事件的 id 保持一致
  • components/menu 仅负责渲染,所以要求传入的数据是处理好的数据,已经带有 keybinding。故在 activityBar 和 menuBar 中对 data 进行转化,使得 barData => menuData
  • ExtensionService 不再对外暴露,用户要想使用 ExtensionService 需要通过 activate(extensionCtx){} 拿到 extensionCtx

Related Issues

Closed #162

@wewoor wewoor self-requested a review June 24, 2021 02:02
@wewoor wewoor added the enhancement New feature or request label Jun 24, 2021
@wewoor wewoor added this to the 0.9.0-alpha.3 milestone Jun 24, 2021
Comment thread src/extensions/keybinding/index.ts Outdated
Comment thread src/workbench/activityBar/activityBar.tsx Outdated
Comment thread src/workbench/activityBar/activityBarItem.tsx Outdated
@wewoor wewoor merged commit fb3c370 into main Jun 25, 2021
@wewoor wewoor deleted the feat/keybinding branch June 25, 2021 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dispaly the Keybinding info in MenuItem

2 participants