Repository navigation
feat: add ResetViewBox plugin - #192
Conversation
Summary of ChangesHello @xxMudCloudxx, 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! This pull request introduces a new 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
|
|
原来Draft PR也会触发CI/CR |
|
/gemini review |
There was a problem hiding this comment.
Code Review
这个 PR 引入了 ResetViewBox 插件,并重构了滚轮缩放功能以解决 undo/redo 栈污染问题,做得很好。通过将缩放时的状态更新直接交由 state.updateOptions 处理,避免了为每一次缩放步长都创建命令,然后在缩放结束后(通过监听 keyup 事件)创建单个命令记录到历史记录中,这个实现非常巧妙。
不过,在 StateManager 的实现中存在一些问题。将自定义的 applyOptionUpdates 函数替换为 lodash.merge 导致了部分重要功能的回归,例如无法通过传入 undefined 来删除属性。此外,viewBox 和 padding 的更新逻辑也存在缺陷。我还对新的 ResetViewBox 插件的样式实现提出了一些改进建议。请查看具体的审查评论。
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
==========================================
+ Coverage 45.22% 45.57% +0.34%
==========================================
Files 334 335 +1
Lines 26635 26820 +185
Branches 2115 2151 +36
==========================================
+ Hits 12046 12222 +176
- Misses 14579 14588 +9
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@Aarebecca 我把原来的undefine视为删除的业务逻辑加回来了,同时先前的 StateManager承担了两个职责:
我做了以下重构:
但 DOM 同步逻辑目前还是静态地实现在 |
|
@xxMudCloudxx 效果不错🎉 |
功能
提供“重置视图”的UI插件。当用户对画布进行缩放(Zoom)或平移(Pan)操作导致视图发生变化时,该插件会在画布右下角显示一个浮动的重置按钮。点击该按钮可将视图恢复到最佳适配(Fit View)状态或初始状态。
功能特性
viewBox:change事件,仅在视图偏离初始状态时显示按钮。resize事件,自动调整初始状态基准和按钮位置。UpdateOptionsCommand,因此该操作支持撤销/重做(Undo/Redo)。配置项
stylePartial<CSSStyleDeclaration>classNamestringgetContainerHTMLElement | (() => HTMLElement)document.body。样式
默认样式包含在 constant
RESET_BUTTON_CLASS中,样式 ID 为RESET_BUTTON_STYLE_ID。自定义配置项使用示例
已解决的问题
TODO / Dependencies
预览