From 3edafdd21f43305d3c75fce882757e7f96d4aa1d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 5 Sep 2022 11:59:22 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=8C=82=E4=BB=B6=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=88=96=E8=AE=BE=E7=BD=AE=E5=A4=A7=E5=B0=8F=E5=90=8E=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E4=B8=A2=E5=A4=B1=20Fix=20https://github.com/siyuan-n?= =?UTF-8?q?ote/siyuan/issues/4885?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/transaction.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 54e182a8d..8bc11b866 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -904,6 +904,17 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) { treenode.MoveFoldHeading(updatedNode, oldNode) } + // 挂件移动或设置大小后属性丢失 https://github.com/siyuan-note/siyuan/issues/4885 + // 这里需要把旧节点的属性复制到新节点上,避免属性丢失 + oldIAL := parse.IAL2Map(oldNode.KramdownIAL) + newIAL := parse.IAL2Map(updatedNode.KramdownIAL) + for oldIALKey, oldIALVal := range oldIAL { + if strings.HasPrefix(oldIALKey, "custom-") { + newIAL[oldIALKey] = oldIALVal + } + } + updatedNode.KramdownIAL = parse.Map2IAL(newIAL) + cache.PutBlockIAL(updatedNode.ID, parse.IAL2Map(updatedNode.KramdownIAL)) // 替换为新节点