Skip to content

挂件移动或设置大小后属性丢失 #4885

Closed

Activity

changed the title [-]改变挂件大小导致挂件属性丢失[/-] [+]挂件属性丢失[/+] on Jul 25, 2022
Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Aug 3, 2022

@Zuoqiu-Yingyi
Contributor

@88250 刚刚又发现了一个问题, 当 /api/attr/setBlockAttrs API 中如果存在属性值设置为 null 时, 不会更新任何属性, 且响应体中 code 也为 0

希望对其进行兼容处理, 属性值设置为 null"" 等效

beetaa

beetaa commented on Sep 5, 2022

@beetaa

@88250 我还以为这个是少数的情况,但再使用过程中,挂件属性丢失几乎是确定会发生的:(1)第一次运行保存属性后的重新加载;(2)挂件移动或刷新。这样的话,挂件的是实用性和可靠性就成了大问题。建议:(1)属性数据设置后,立即保存于数据库中;(2)属性加载时,根据挂件 id 读取数据库内容,并赋值给 iframe 的全局变量;(3)挂件可以直接读取 iframe 全局变量获取属性数据,而无需通过 api。

88250

88250 commented on Sep 5, 2022

@88250
MemberAuthor

@beetaa 感谢反馈,这问题的原因应该是因为移动/设置大小等操作会使用挂件 DOM 作为最新数据入库,而实际上最新数据是前面挂件通过 API 写入的,所以被覆盖了。

可能需要调整为界面上操作时忽略自定义属性入库,近期版本我们会改进了试试。

added this to the 2.1.13 milestone on Sep 5, 2022
changed the title [-]挂件属性丢失[/-] [+]移动或设置大小后挂件属性丢失[/+] on Sep 5, 2022
changed the title [-]移动或设置大小后挂件属性丢失[/-] [+]挂件移动或设置大小后属性丢失[/+] on Sep 5, 2022
added a commit that references this issue on Sep 7, 2022
terwer

terwer commented on Sep 9, 2022

@terwer
Contributor

这是个很好的修复,可大大提升挂件的使用体验。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Vanessa219@terwer@beetaa@Zuoqiu-Yingyi

      Issue actions

        挂件移动或设置大小后属性丢失 · Issue #4885 · siyuan-note/siyuan