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

node-editor 的gettext settext写字符串,该如何在修改前校验 #3709

Open
TalentJY opened this issue Jun 25, 2023 · 3 comments
Open
Labels
type: feature 新功能 Feature/enhancement requests

Comments

@TalentJY
Copy link

问题描述

为了序列化所以使用字符串的形式写gettext等,但是我想要实现 在修改前校验一下数据 比如有没有重复的,或限制长度以及执行其他代码等操作,该如何实现

重现链接

暂无

重现步骤

暂无

预期行为

想要实现 能序列化的同时, 在修改前校验一下数据 比如有没有重复的,或限制长度以及执行其他代码等操作

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox ...]
  • X6 版本: [2.11.1 ...]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@NewByVector
Copy link
Contributor

如果要实现你的需求,一种思路是在设置值之前增加校验,但是这样同样会存在不能序列化的问题,如果你们没有序列化的需求,可以基于 CellEditor 来自定义自己的节点编辑工具。另外一种思路是监听节点文本的修改,修改后增加判断,如果判断不通过,再将文本恢复之前的值。

@NewByVector NewByVector added the type: discussion 讨论 Usage questions, guidance, and other discussions label Jun 26, 2023
@TalentJY
Copy link
Author

如果要实现你的需求,一种思路是在设置值之前增加校验,但是这样同样会存在不能序列化的问题,如果你们没有序列化的需求,可以基于 CellEditor 来自定义自己的节点编辑工具。另外一种思路是监听节点文本的修改,修改后增加判断,如果判断不通过,再将文本恢复之前的值。

试了下有几个问题。。。 我用cell:change:attrs监听,触发双击编辑的那一刻,会触发这个监听,options.propertyValue传一个空的值,按理说不应该触发吧。其次 编辑之后 会触发两次监听,第一次options.propertyValue的值是修改后的值,第二次options.propertyValue的值是原先的值

@NewByVector
Copy link
Contributor

NewByVector commented Jun 28, 2023

之前确实没有考虑到修改校验的需求,这个需求给我们的 node-editor 的设计带来了新的思路:
带有函数配置的工具需要采用延迟创建模式,也就是在事件触发之后再动态添加工具。

@NewByVector NewByVector added type: feature 新功能 Feature/enhancement requests and removed type: discussion 讨论 Usage questions, guidance, and other discussions labels Jun 28, 2023
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

2 participants