mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-05 12:20:16 +01:00
🎨 Block data sync to Attribute View https://github.com/siyuan-note/siyuan/issues/8696
This commit is contained in:
parent
e70caed46a
commit
060d933390
3 changed files with 53 additions and 6 deletions
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/av"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -1188,7 +1189,41 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
|||
}
|
||||
}
|
||||
|
||||
// TODO 2. 更新属性视图主键内容
|
||||
// 2. 更新属性视图主键内容
|
||||
for _, updatedDefNode := range updatedDefNodes {
|
||||
avs := updatedDefNode.IALAttr(NodeAttrNameAVs)
|
||||
if "" == avs {
|
||||
continue
|
||||
}
|
||||
|
||||
avIDs := strings.Split(avs, ",")
|
||||
for _, avID := range avIDs {
|
||||
attrView, parseErr := av.ParseAttributeView(avID)
|
||||
if nil != parseErr {
|
||||
continue
|
||||
}
|
||||
|
||||
changedAv := false
|
||||
for _, row := range attrView.Rows {
|
||||
blockCell := row.GetBlockCell()
|
||||
if nil == blockCell || nil == blockCell.Value || nil == blockCell.Value.Block {
|
||||
continue
|
||||
}
|
||||
|
||||
if blockCell.Value.Block.ID == updatedDefNode.ID {
|
||||
newContent := getNodeRefText(updatedDefNode)
|
||||
if newContent != blockCell.Value.Block.Content {
|
||||
blockCell.Value.Block.Content = newContent
|
||||
changedAv = true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if changedAv {
|
||||
av.SaveAttributeView(attrView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 保存变更
|
||||
for _, tree := range changedRefTree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue