Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
be9ccb7af3
7 changed files with 57 additions and 44 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
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
|
||||
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02
|
||||
github.com/88250/lute v1.7.7-0.20240701080837-e06da478de3e
|
||||
github.com/88250/lute v1.7.7-0.20240702084201-ee02f916d4a8
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
|
|
|
@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY=
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
|
||||
github.com/88250/lute v1.7.7-0.20240701080837-e06da478de3e h1:At3xkf1bfDmxics8ulRdxsDvK2RPrVtfv1mSUblqGLw=
|
||||
github.com/88250/lute v1.7.7-0.20240701080837-e06da478de3e/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
|
||||
github.com/88250/lute v1.7.7-0.20240702084201-ee02f916d4a8 h1:ZHnfNlKIG7LY2lk0X/LbuojLShfPsdXntT8mwPhL5gM=
|
||||
github.com/88250/lute v1.7.7-0.20240702084201-ee02f916d4a8/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
@ -1652,7 +1652,7 @@ func setAttributeViewName(operation *Operation) (err error) {
|
|||
attrView.Name = strings.TrimSpace(operation.Data.(string))
|
||||
err = av.SaveAttributeView(attrView)
|
||||
|
||||
nodes := getAttrViewBoundNodes(attrView)
|
||||
_, nodes := getAttrViewBoundNodes(attrView)
|
||||
for _, node := range nodes {
|
||||
avNames := getAvNames(node.IALAttr(av.NodeAttrNameAvs))
|
||||
oldAttrs := parse.IAL2Map(node.KramdownIAL)
|
||||
|
@ -1689,7 +1689,7 @@ func getAvNames(avIDs string) (ret string) {
|
|||
return
|
||||
}
|
||||
|
||||
func getAttrViewBoundNodes(attrView *av.AttributeView) (ret []*ast.Node) {
|
||||
func getAttrViewBoundNodes(attrView *av.AttributeView) (trees []*parse.Tree, nodes []*ast.Node) {
|
||||
blockKeyValues := attrView.GetBlockKeyValues()
|
||||
treeCache := map[string]*parse.Tree{}
|
||||
for _, blockKeyValue := range blockKeyValues.Values {
|
||||
|
@ -1712,7 +1712,10 @@ func getAttrViewBoundNodes(attrView *av.AttributeView) (ret []*ast.Node) {
|
|||
continue
|
||||
}
|
||||
|
||||
ret = append(ret, node)
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
for _, tree := range treeCache {
|
||||
trees = append(trees, tree)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1638,11 +1638,8 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) {
|
|||
continue
|
||||
}
|
||||
|
||||
// 刷新文档关联的数据库 https://github.com/siyuan-note/siyuan/issues/11731
|
||||
syncDelete2AttributeView(removeTree.Root)
|
||||
|
||||
// 解绑数据库关联
|
||||
removeAvBlockRel(removeTree.Root)
|
||||
syncDelete2Block(removeTree.Root)
|
||||
}
|
||||
|
||||
if existChildren {
|
||||
|
|
|
@ -44,28 +44,6 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func IsFoldHeading(transactions *[]*Transaction) bool {
|
||||
for _, tx := range *transactions {
|
||||
for _, op := range tx.DoOperations {
|
||||
if "foldHeading" == op.Action {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsUnfoldHeading(transactions *[]*Transaction) bool {
|
||||
for _, tx := range *transactions {
|
||||
for _, op := range tx.DoOperations {
|
||||
if "unfoldHeading" == op.Action {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsMoveOutlineHeading(transactions *[]*Transaction) bool {
|
||||
for _, tx := range *transactions {
|
||||
for _, op := range tx.DoOperations {
|
||||
|
@ -797,13 +775,17 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
syncDelete2AttributeView(node)
|
||||
removeAvBlockRel(node)
|
||||
go func() {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
WaitForWritingFiles()
|
||||
syncDelete2AttributeView(node)
|
||||
syncDelete2Block(node)
|
||||
}()
|
||||
return
|
||||
}
|
||||
|
||||
func removeAvBlockRel(node *ast.Node) {
|
||||
var avIDs []string
|
||||
func syncDelete2Block(node *ast.Node) {
|
||||
var changedAvIDs []string
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
|
@ -812,13 +794,39 @@ func removeAvBlockRel(node *ast.Node) {
|
|||
if ast.NodeAttributeView == n.Type {
|
||||
avID := n.AttributeViewID
|
||||
if changed := av.RemoveBlockRel(avID, n.ID, treenode.ExistBlockTree); changed {
|
||||
avIDs = append(avIDs, avID)
|
||||
changedAvIDs = append(changedAvIDs, avID)
|
||||
}
|
||||
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
trees, nodes := getAttrViewBoundNodes(attrView)
|
||||
for _, toChangNode := range nodes {
|
||||
avs := toChangNode.IALAttr(av.NodeAttrNameAvs)
|
||||
if "" != avs {
|
||||
avIDs := strings.Split(avs, ",")
|
||||
avIDs = gulu.Str.RemoveElem(avIDs, avID)
|
||||
if 1 > len(avIDs) {
|
||||
toChangNode.RemoveIALAttr(av.NodeAttrNameAvs)
|
||||
} else {
|
||||
toChangNode.SetIALAttr(av.NodeAttrNameAvs, strings.Join(avIDs, ","))
|
||||
}
|
||||
}
|
||||
avNames := getAvNames(toChangNode.IALAttr(av.NodeAttrNameAvs))
|
||||
oldAttrs := parse.IAL2Map(toChangNode.KramdownIAL)
|
||||
toChangNode.SetIALAttr(av.NodeAttrViewNames, avNames)
|
||||
pushBroadcastAttrTransactions(oldAttrs, toChangNode)
|
||||
}
|
||||
for _, tree := range trees {
|
||||
indexWriteTreeUpsertQueue(tree)
|
||||
}
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
avIDs = gulu.Str.RemoveDuplicatedElem(avIDs)
|
||||
for _, avID := range avIDs {
|
||||
changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)
|
||||
for _, avID := range changedAvIDs {
|
||||
util.PushReloadAttrView(avID)
|
||||
}
|
||||
}
|
||||
|
@ -1318,9 +1326,6 @@ func (tx *Transaction) WaitForCommit() {
|
|||
}
|
||||
|
||||
func (tx *Transaction) begin() (err error) {
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
tx.trees = map[string]*parse.Tree{}
|
||||
tx.nodes = map[string]*ast.Node{}
|
||||
tx.luteEngine = util.NewLute()
|
||||
|
|
|
@ -146,7 +146,7 @@ func removeDatabaseFile() (err error) {
|
|||
|
||||
func GetBlockTreesByType(typ string) (ret []*BlockTree) {
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE type = ?"
|
||||
rows, err := db.Query(sqlStmt)
|
||||
rows, err := db.Query(sqlStmt, typ)
|
||||
if nil != err {
|
||||
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
|
||||
return
|
||||
|
@ -306,6 +306,10 @@ func ExistBlockTree(id string) bool {
|
|||
|
||||
func ExistBlockTrees(ids []string) (ret map[string]bool) {
|
||||
ret = map[string]bool{}
|
||||
if 1 > len(ids) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, id := range ids {
|
||||
ret[id] = false
|
||||
}
|
||||
|
@ -330,6 +334,10 @@ func ExistBlockTrees(ids []string) (ret map[string]bool) {
|
|||
|
||||
func GetBlockTrees(ids []string) (ret map[string]*BlockTree) {
|
||||
ret = map[string]*BlockTree{}
|
||||
if 1 > len(ids) {
|
||||
return
|
||||
}
|
||||
|
||||
sqlStmt := "SELECT * FROM blocktrees WHERE id IN ('" + strings.Join(ids, "','") + "')"
|
||||
rows, err := db.Query(sqlStmt)
|
||||
if nil != err {
|
||||
|
|
Loading…
Add table
Reference in a new issue