mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-07 01:08:49 +01:00
This commit is contained in:
parent
afc792b476
commit
68ef3770a9
6 changed files with 69 additions and 26 deletions
2
app/stage/protyle/js/lute/lute.min.js
vendored
2
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -18,18 +18,18 @@ package av
|
|||
|
||||
type Cell interface {
|
||||
|
||||
// Resolve 根据参数解析单元格的值。
|
||||
Resolve(input interface{}) string
|
||||
// Value 返回单元格的值。
|
||||
Value() string
|
||||
}
|
||||
|
||||
type CellBlock struct {
|
||||
Value string `json:"value"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func NewCellBlock(blockID string) *CellBlock {
|
||||
return &CellBlock{Value: blockID}
|
||||
return &CellBlock{ID: blockID}
|
||||
}
|
||||
|
||||
func (c *CellBlock) Resolve(blockID interface{}) string {
|
||||
return blockID.(string)
|
||||
func (c *CellBlock) Value() string {
|
||||
return c.ID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/88250/clipboard v0.1.5
|
||||
github.com/88250/css v0.1.2
|
||||
github.com/88250/gulu v1.2.3-0.20230223100136-26e5f16ac3c0
|
||||
github.com/88250/lute v1.7.6-0.20230302100714-e505dedd054f
|
||||
github.com/88250/lute v1.7.6-0.20230302102529-4dd94587d7da
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230224021324-e51076eb6390
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20230220142845-f237b6348b3e
|
||||
|
|
|
|||
|
|
@ -8,12 +8,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20230223100136-26e5f16ac3c0 h1:hZn2F/kNKcxoK41JhfoTfJ5BYHoWG3fSYk/BlOPYqLo=
|
||||
github.com/88250/gulu v1.2.3-0.20230223100136-26e5f16ac3c0/go.mod h1:pTWnjt+6qUqNnP9xltswsJxgCBVu3C7eW09u48LWX0k=
|
||||
github.com/88250/lute v1.7.6-0.20230302032323-586a55d69a1f h1:UWGqVKI40xJ0iNTHQIh99jQAI/KI9SMYxVQf4bPJ/Bg=
|
||||
github.com/88250/lute v1.7.6-0.20230302032323-586a55d69a1f/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
|
||||
github.com/88250/lute v1.7.6-0.20230302100344-66da223b6234 h1:25W24btbUj/X1JgN/8pRoUNYcuziTtIGmL65/9ciqdY=
|
||||
github.com/88250/lute v1.7.6-0.20230302100344-66da223b6234/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
|
||||
github.com/88250/lute v1.7.6-0.20230302100714-e505dedd054f h1:7iSlEgkltVzdui48yb1qtcBhriNTDtZeH7mkLxa/G7s=
|
||||
github.com/88250/lute v1.7.6-0.20230302100714-e505dedd054f/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
|
||||
github.com/88250/lute v1.7.6-0.20230302102529-4dd94587d7da h1:HPz4B8anvSVxuJGCKADZ3uYKdDeO6HfHPT0jhHwjHlc=
|
||||
github.com/88250/lute v1.7.6-0.20230302102529-4dd94587d7da/go.mod h1:+wUqx/1kdFDbWtxn9LYJlaCOAeol2pjSO6w+WJTVQsg=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230224021324-e51076eb6390 h1:q2AR33VoQ87WYtvZ4pEvwj5gZkv22HK/yMlPWwF1oyc=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230224021324-e51076eb6390/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
|||
|
|
@ -27,6 +27,42 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
)
|
||||
|
||||
func (tx *Transaction) doInsertAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
firstSrcID := operation.SrcIDs[0]
|
||||
tree, err := tx.loadTree(firstSrcID)
|
||||
if nil != err {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", firstSrcID, err)
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, id: firstSrcID}
|
||||
}
|
||||
|
||||
avID := operation.ParentID
|
||||
for _, id := range operation.SrcIDs {
|
||||
if err = addAttributeViewBlock(id, avID, tree); nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: avID}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doRemoveAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
firstSrcID := operation.SrcIDs[0]
|
||||
tree, err := tx.loadTree(firstSrcID)
|
||||
if nil != err {
|
||||
logging.LogErrorf("load tree [%s] failed: %s", firstSrcID, err)
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, id: firstSrcID}
|
||||
}
|
||||
|
||||
avID := operation.ParentID
|
||||
for _, id := range operation.SrcIDs {
|
||||
if err = removeAttributeViewBlock(id, avID, tree); nil != err {
|
||||
return &TxErr{code: TxErrWriteAttributeView, id: avID}
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func AddAttributeViewColumn(name string, typ string, columnIndex int, avID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
|
|
@ -47,12 +83,30 @@ func AddAttributeViewColumn(name string, typ string, columnIndex int, avID strin
|
|||
return
|
||||
}
|
||||
|
||||
func AddAttributeViewBlock(blockID, avID string) (err error) {
|
||||
tree, err := loadTreeByBlockID(blockID)
|
||||
func removeAttributeViewBlock(blockID, avID string, tree *parse.Tree) (err error) {
|
||||
node := treenode.GetNodeInTree(tree, blockID)
|
||||
if nil == node {
|
||||
err = ErrBlockNotFound
|
||||
return
|
||||
}
|
||||
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
for i, row := range attrView.Rows {
|
||||
if row[0].Value() == blockID {
|
||||
attrView.Rows = append(attrView.Rows[:i], attrView.Rows[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = av.SaveAttributeView(attrView)
|
||||
return
|
||||
}
|
||||
|
||||
func addAttributeViewBlock(blockID, avID string, tree *parse.Tree) (err error) {
|
||||
node := treenode.GetNodeInTree(tree, blockID)
|
||||
if nil == node {
|
||||
err = ErrBlockNotFound
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ const (
|
|||
TxErrCodeBlockNotFound = 0
|
||||
TxErrCodeUnableAccessFile = 1
|
||||
TxErrCodeWriteTree = 2
|
||||
TxErrWriteAttributeView = 3
|
||||
)
|
||||
|
||||
type TxErr struct {
|
||||
|
|
@ -214,9 +215,9 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
case "setAttrs":
|
||||
ret = tx.setAttrs(op)
|
||||
case "insertAttrViewBlock":
|
||||
ret = tx.insertAttrViewBlock(op)
|
||||
ret = tx.doInsertAttrViewBlock(op)
|
||||
case "removeAttrViewBlock":
|
||||
ret = tx.removeAttrViewBlock(op)
|
||||
ret = tx.doRemoveAttrViewBlock(op)
|
||||
}
|
||||
|
||||
if nil != ret {
|
||||
|
|
@ -236,14 +237,6 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) insertAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) removeAttrViewBlock(operation *Operation) (ret *TxErr) {
|
||||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||
var err error
|
||||
id := operation.ID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue