-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(slide-preview): 添加键盘导航和缩略图自动滚动功能 #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
GinirohikoCha
commented
Feb 2, 2026
- 为缩略图添加引用以便精确滚动定位
- 添加键盘事件监听器支持方向键切换幻灯片
- 实现切换幻灯片时滚动条自动滚动到当前选中项
- 为缩略图添加引用以便精确滚动定位 - 添加键盘事件监听器支持方向键切换幻灯片 - 实现切换幻灯片时滚动条自动滚动到当前选中项
Summary of ChangesHello @GinirohikoCha, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在增强幻灯片预览页面的用户体验,通过引入键盘导航功能,用户可以更便捷地浏览幻灯片。同时,为了配合键盘导航,还实现了缩略图列表的自动滚动功能,确保用户在切换幻灯片时能够直观地看到当前选中的缩略图,从而提升了交互的流畅性和可用性。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
你好,感谢你的贡献!这次的 PR 实现了键盘导航和缩略图自动滚动功能,整体实现得很好。我注意到一个小问题,全局键盘事件监听器可能会在用户输入文本时意外触发幻灯片切换。我提供了一个建议来修复这个问题。此外,代码中有很多纯粹的格式化更改(例如,删除空行),建议在未来的提交中将功能性更改和格式化更改分开,以便于审查。总的来说,这是一次很棒的功能增强!
| const handleKeyDown = (e: KeyboardEvent) => { | ||
| if (!currentProject || currentProject.pages.length === 0) return; | ||
|
|
||
| switch (e.key) { | ||
| case 'ArrowLeft': | ||
| case 'ArrowUp': | ||
| e.preventDefault(); | ||
| setSelectedIndex((prev) => Math.max(0, prev - 1)); | ||
| break; | ||
| case 'ArrowRight': | ||
| case 'ArrowDown': | ||
| e.preventDefault(); | ||
| setSelectedIndex((prev) => Math.min(currentProject.pages.length - 1, prev + 1)); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全局键盘事件监听器没有检查当前焦点是否在输入框内。当用户在文本框(如编辑弹窗中的输入框)中使用方向键移动光标时,会意外地触发幻灯片切换,影响用户体验。建议在处理键盘事件前,先判断活动元素是否为输入控件。
const handleKeyDown = (e: KeyboardEvent) => {
const activeElement = document.activeElement as HTMLElement;
if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA' || activeElement.isContentEditable)) {
return;
}
if (!currentProject || currentProject.pages.length === 0) return;
switch (e.key) {
case 'ArrowLeft':
case 'ArrowUp':
e.preventDefault();
setSelectedIndex((prev) => Math.max(0, prev - 1));
break;
case 'ArrowRight':
case 'ArrowDown':
e.preventDefault();
setSelectedIndex((prev) => Math.min(currentProject.pages.length - 1, prev + 1));
break;
default:
break;
}
};