This commit is contained in:
parent
504032f285
commit
86fbb759ed
2 changed files with 20 additions and 7 deletions
|
@ -17,6 +17,7 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/siyuan/kernel/av"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
@ -45,11 +46,18 @@ func AddBlockToAttributeView(blockID, avID string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||
var row []av.Cell
|
||||
row = append(row, av.NewCellBlock(block.ID))
|
||||
for _, col := range attrView.Columns[1:] {
|
||||
// TODO 为块添加列对应的属性
|
||||
_ = col
|
||||
if 1 < len(attrView.Columns) {
|
||||
for _, col := range attrView.Columns[1:] {
|
||||
colName := col.Name()
|
||||
attrs[colName] = ""
|
||||
}
|
||||
|
||||
if err = setNodeAttrs(node, tree, attrs); nil != err {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
attrView.Rows = append(attrView.Rows, row)
|
||||
|
|
|
@ -19,13 +19,13 @@ package model
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/88250/lute/parse"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/88250/lute/lex"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/araddon/dateparse"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
@ -105,12 +105,17 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|||
return errors.New(fmt.Sprintf(Conf.Language(15), id))
|
||||
}
|
||||
|
||||
err = setNodeAttrs(node, tree, nameValues)
|
||||
return
|
||||
}
|
||||
|
||||
func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string) (err error) {
|
||||
oldAttrs := parse.IAL2Map(node.KramdownIAL)
|
||||
|
||||
for name := range nameValues {
|
||||
for i := 0; i < len(name); i++ {
|
||||
if !lex.IsASCIILetterNumHyphen(name[i]) {
|
||||
return errors.New(fmt.Sprintf(Conf.Language(25), id))
|
||||
return errors.New(fmt.Sprintf(Conf.Language(25), node.ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,10 +140,10 @@ func SetBlockAttrs(id string, nameValues map[string]string) (err error) {
|
|||
}
|
||||
|
||||
IncSync()
|
||||
cache.PutBlockIAL(id, parse.IAL2Map(node.KramdownIAL))
|
||||
cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))
|
||||
|
||||
newAttrs := parse.IAL2Map(node.KramdownIAL)
|
||||
doOp := &Operation{Action: "updateAttrs", Data: map[string]interface{}{"old": oldAttrs, "new": newAttrs}, ID: id}
|
||||
doOp := &Operation{Action: "updateAttrs", Data: map[string]interface{}{"old": oldAttrs, "new": newAttrs}, ID: node.ID}
|
||||
trans := []*Transaction{{
|
||||
DoOperations: []*Operation{doOp},
|
||||
UndoOperations: []*Operation{},
|
||||
|
|
Loading…
Add table
Reference in a new issue