mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Update av
This commit is contained in:
parent
c18697aad6
commit
3c40f31ec9
1 changed files with 18 additions and 3 deletions
|
|
@ -19,6 +19,9 @@ package model
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
"github.com/88250/lute/parse"
|
"github.com/88250/lute/parse"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
|
|
@ -112,7 +115,7 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {
|
||||||
|
|
||||||
c.Value, c.RenderValue = parseCellData(operation)
|
c.Value, c.RenderValue = parseCellData(operation)
|
||||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||||
attrs[NodeAttrNamePrefixAvCol+c.ID] = c.Value
|
attrs[NodeAttrNamePrefixAvCol+avID+"-"+c.ID] = c.Value
|
||||||
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -310,10 +313,19 @@ func addAttributeViewBlock(blockID, previousRowID, avID string, tree *parse.Tree
|
||||||
if 1 < len(ret.Columns) {
|
if 1 < len(ret.Columns) {
|
||||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||||
for _, col := range ret.Columns[1:] {
|
for _, col := range ret.Columns[1:] {
|
||||||
attrs[NodeAttrNamePrefixAvCol+col.ID] = "" // 将列作为属性添加到块中
|
attrs[NodeAttrNamePrefixAvCol+avID+"-"+col.ID] = "" // 将列作为属性添加到块中
|
||||||
row.Cells = append(row.Cells, av.NewCell(col.Type))
|
row.Cells = append(row.Cells, av.NewCell(col.Type))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if "" == attrs[NodeAttrNameAVs] {
|
||||||
|
attrs[NodeAttrNameAVs] = avID
|
||||||
|
} else {
|
||||||
|
avIDs := strings.Split(attrs[NodeAttrNameAVs], ",")
|
||||||
|
avIDs = append(avIDs, avID)
|
||||||
|
avIDs = gulu.Str.RemoveDuplicatedElem(avIDs)
|
||||||
|
attrs[NodeAttrNameAVs] = strings.Join(avIDs, ",")
|
||||||
|
}
|
||||||
|
|
||||||
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
if err = setNodeAttrsWithTx(tx, node, tree, attrs); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -346,4 +358,7 @@ func parseCellData(operation *Operation) (val, renderVal string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const NodeAttrNamePrefixAvCol = "av-col-"
|
const (
|
||||||
|
NodeAttrNameAVs = "avs"
|
||||||
|
NodeAttrNamePrefixAvCol = "av-col-"
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue