Skip to content

fix(extension): 优化框选插件,解决默认情况下框选开启后无法对画布做其他操作的问题 #2127

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

Merged
merged 5 commits into from
Apr 17, 2025

Conversation

DymoneLewis
Copy link
Collaborator

@DymoneLewis DymoneLewis commented Apr 16, 2025

重新调整了一下 #2090 的实现
主要做了几个事情(主要需要CR packages目录下的改动,文档和example感兴趣的话可以看一下

  1. 还原了之前ToolOverlay对CanvasOverlay的引用,通信的话目前我们比较推崇通过eventCenter来做通信,加上后面对框选插件做了改动,已经不用加引用逻辑了
  2. 把之前开启框选后隔离事件的逻辑加了个开关控制,默认开关不开,效果建下面的视频👇🏻
    框选插件优化后效果

@ZivvW 朋友可以一起CRCR😄,看看在你的场景下使用有没有什么问题

  1. 更新了一下相关demo和文档说明

Copy link

changeset-bot bot commented Apr 16, 2025

⚠️ No Changeset found

Latest commit: 40fa244

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

sites/docs/docs/tutorial/extension/selection.zh.md:114

  • The method name 'setleExclusiveMode' appears to contain a typo; consider renaming it to 'setExclusiveMode' for consistency with the implementation and the English documentation.
### setleExclusiveMode

packages/extension/src/components/selection-select/index.ts:219

  • [nitpick] Consider refactoring the repeated wrapper cleanup logic into a dedicated helper function to improve code clarity and reduce duplication.
if (this.wrapper && this.startPoint && this.endPoint) {

Copy link
Collaborator

@boyongjiong boyongjiong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see see

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些文档为什么变动这么多,是用什么工具重写了一下吗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,我用cursor批量「参考中文文档内容补充对应英文文档」了😄

@@ -53,24 +52,10 @@ export class ToolOverlay extends Component<IProps> {
lf.components = [] // 保证extension组件的render只执行一次
}

zoomHandler = (e: WheelEvent) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当时这儿加这个 zoomHandler 的背景是什么?我没太看懂作用,是为了在 ToolOverlay 中操作 Canvas 呗?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

差不多是这个诉求,当时是想开启框选之后禁用zoom之外的事件,所以在ToolOverlay里单独加了zoomHandler,实现缩放ToolOverlay的时候触发CanvasOverlay的缩放

    removeSelectByElementId => deselectByElementId
    defaultExclusiveMode => exclusiveMode
Copy link
Collaborator

@boyongjiong boyongjiong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

优秀

@boyongjiong boyongjiong merged commit e8148b1 into master Apr 17, 2025
1 check passed
@ZivvW
Copy link
Contributor

ZivvW commented Apr 18, 2025

大佬牛逼 👍

发现个问题:现在独占模式下好像没法点击空白处取消框选了

@DymoneLewis
Copy link
Collaborator Author

大佬牛逼 👍

发现个问题:现在独占模式下好像没法点击空白处取消框选了

我看看

@DymoneLewis
Copy link
Collaborator Author

DymoneLewis commented Apr 18, 2025

大佬牛逼 👍

发现个问题:现在独占模式下好像没法点击空白处取消框选了

确实有这个问题,刚刚改完一版 #2129 ,可以一起再看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants