Skip to content
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

思维导图节点添加编辑工具后如何监听节点内容的改变? #3775

Open
jiash1998 opened this issue Jul 13, 2023 · 3 comments
Labels
type: feature 新功能 Feature/enhancement requests

Comments

@jiash1998
Copy link

问题描述

我的例子就是简单复用了官网中思维导图的样例,然后在增加了 节点编辑工具。但我仔细翻阅了官网的change方法,也做了各种尝试,发现无法在编辑节点时监听到值的变化。我只能在双击事件中开始一个监听,并在点击画布空白事件中关闭监听,并通过graph.toJSON()方法手动过滤并维护渲染这个思维导图的data数据,以实现前端的暂时保存。

重现链接

暂无

重现步骤

暂无

预期行为

暂无

平台

  • 操作系统: [ Windows]
  • 网页浏览器: [Google Chrome]
  • X6 版本: [2.11.1]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@NewByVector
Copy link
Contributor

现在还没有好的方式来监听文本的修改。有一个思路就是监听节点属性变化:

graph.on('node:change:attrs', ({ current }) => {
  if (current) {
    const value = current.text.text;
  }
})

不过存在一个问题,当双击节点的时候,因为会将原来节点文本清空,也会触发上面事件。

@NewByVector NewByVector added the type: feature 新功能 Feature/enhancement requests label Jul 13, 2023
@jiash1998
Copy link
Author

现在还没有好的方式来监听文本的修改。有一个思路就是监听节点属性变化:

graph.on('node:change:attrs', ({ current }) => {
  if (current) {
    const value = current.text.text;
  }
})

不过存在一个问题,当双击节点的时候,因为会将原来节点文本清空,也会触发上面事件。

好的,那就期待你们的新功能了。

@wuIsSky
Copy link

wuIsSky commented Dec 28, 2023

现在还没有好的方式来监听文本的修改。有一个思路就是监听节点属性变化:

graph.on('node:change:attrs', ({ current }) => {
  if (current) {
    const value = current.text.text;
  }
})

不过存在一个问题,当双击节点的时候,因为会将原来节点文本清空,也会触发上面事件。

现在还没有好的方式来监听文本的修改。有一个思路就是监听节点属性变化:

graph.on('node:change:attrs', ({ current }) => {
  if (current) {
    const value = current.text.text;
  }
})

不过存在一个问题,当双击节点的时候,因为会将原来节点文本清空,也会触发上面事件。

双击一个有文字的节点之后,手动把节点的文字清空,然后完成编辑,也希望能触发change事件,目前没有触发,导致监听不到文字被清空

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature 新功能 Feature/enhancement requests
Projects
None yet
Development

No branches or pull requests

3 participants