mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
🎨 API setBlockAttrs 中如果存在属性值设置为 null 时移除该属性 Fix https://github.com/siyuan-note/siyuan/issues/5577
This commit is contained in:
parent
283ae61fad
commit
3d1e6d5fed
1 changed files with 5 additions and 1 deletions
|
|
@ -58,7 +58,11 @@ func setBlockAttrs(c *gin.Context) {
|
||||||
attrs := arg["attrs"].(map[string]interface{})
|
attrs := arg["attrs"].(map[string]interface{})
|
||||||
nameValues := map[string]string{}
|
nameValues := map[string]string{}
|
||||||
for name, value := range attrs {
|
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)
|
err := model.SetBlockAttrs(id, nameValues)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue