The dock shortcut keys use keymap as the only data source - #17910
Open
TCOTC wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
将 dock 快捷键的来源统一为 config.keymap(不再把 hotkey 冗余保存到布局数据里),并让在「设置 - 快捷键」修改 dock 快捷键后能立即反映到 UI 与快捷键触发逻辑中。
Changes:
- 移除布局数据与序列化中的
dockTab.hotkey字段,避免布局与 keymap 双写/不同步。 - 新增
getDockHotkey()等工具函数,在渲染(aria-label/提示)、菜单 accelerator、最近文档提示与全局 keydown 匹配中统一从 keymap 取值。 - 在快捷键设置页面保存时,直接更新 dock DOM 的 aria-label,使修改立即生效(含插件 dock)。
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/src/types/config.d.ts | 从 dock tab 类型定义中移除 hotkey,对齐“keymap 为唯一数据源”的目标 |
| app/src/plugin/loader.ts | 插件 dock 按钮生成不再传递 hotkey,交由 dock 统一从 keymap 解析 |
| app/src/menus/workspace.ts | workspace 菜单的 dock accelerator 改为动态读取 keymap |
| app/src/layout/util.ts | 导出/初始化布局时不再读写 dock hotkey,消除布局层面的冗余字段 |
| app/src/layout/dock/index.ts | 生成 dock 按钮时动态计算 hotkey,并生成 aria-label |
| app/src/layout/dock/hotkey.ts | 新增 dock hotkey 解析与 aria-label 更新工具函数 |
| app/src/config/tabs/keymapUi.ts | 保存 keymap 时同步更新 dock aria-label(内置与插件 dock) |
| app/src/business/openRecentDocs.ts | 最近文档列表中 dock hotkey 展示改为动态读取 keymap |
| app/src/boot/globalEvent/keydown.ts | dock 快捷键匹配改为动态读取 keymap |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+16
| import {updateHotkeyTip} from "../../protyle/util/compatibility"; | ||
|
|
||
| export const getDockHotkey = (dock: Config.IUILayoutDockTab): string => { | ||
| // 内置 dock 快捷键 | ||
| if (dock.hotkeyLangId) { | ||
| return window.siyuan.config.keymap.general[dock.hotkeyLangId]?.custom ?? ""; | ||
| } | ||
| // 插件 dock 快捷键 | ||
| for (const plugin of window.siyuan.ws.app.plugins) { | ||
| const keymap = window.siyuan.config.keymap.plugin[plugin.name]?.[dock.type]; | ||
| if (keymap) { | ||
| return keymap.custom ?? ""; | ||
| } | ||
| } | ||
| return ""; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description / 描述
dock 快捷键以 keymap 为唯一数据源,不再把 hotkey 保存到布局数据中、在 设置 - 快捷键 修改了 dock 快捷键之后立即生效。
Type of change / 变更类型
缺陷修复
代码重构
新功能
修改文案或增加新语言
Checklist / 检查清单
我对自己的代码进行了自我审查
我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
devbranch and has no merge conflictsPR 提交到
dev分支,并且没有合并冲突