From 3d1e6d5fed08691752cd09e7f68c808a74fd2229 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 5 Aug 2022 13:29:36 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20API=20`setBlockAttrs`=20=E4=B8=AD?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=AD=98=E5=9C=A8=E5=B1=9E=E6=80=A7=E5=80=BC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=20`null`=20=E6=97=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E8=AF=A5=E5=B1=9E=E6=80=A7=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/5577?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/attr.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/api/attr.go b/kernel/api/attr.go index af996f660..0c1d2dbcc 100644 --- a/kernel/api/attr.go +++ b/kernel/api/attr.go @@ -58,7 +58,11 @@ func setBlockAttrs(c *gin.Context) { attrs := arg["attrs"].(map[string]interface{}) nameValues := map[string]string{} for name, value := range attrs { - nameValues[name] = value.(string) + if nil == value { // API `setBlockAttrs` 中如果存在属性值设置为 `null` 时移除该属性 https://github.com/siyuan-note/siyuan/issues/5577 + nameValues[name] = "" + } else { + nameValues[name] = value.(string) + } } err := model.SetBlockAttrs(id, nameValues) if nil != err {