mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
c29238e8e0
9 changed files with 86 additions and 22 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
|
|
@ -278,6 +278,15 @@ func parseJSON2Tree(boxID, p string, jsonData []byte, luteEngine *lute.Lute) (re
|
|||
needFix = true
|
||||
logging.LogInfof("migrated tree [%s] from spec [%s] to [%s]", filePath, oldSpec, ret.Root.Spec)
|
||||
}
|
||||
|
||||
if pathID := util.GetTreeID(p); pathID != ret.Root.ID {
|
||||
needFix = true
|
||||
logging.LogInfof("reset tree id from [%s] to [%s]", ret.Root.ID, pathID)
|
||||
ret.Root.ID = pathID
|
||||
ret.ID = pathID
|
||||
ret.Root.SetIALAttr("id", ret.ID)
|
||||
}
|
||||
|
||||
if needFix {
|
||||
renderer := render.NewJSONRenderer(ret, luteEngine.RenderOptions)
|
||||
data := renderer.Render()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,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.20250227144607-7f4570b0d689
|
||||
github.com/88250/lute v1.7.7-0.20250311111757-77ff1f87fd18
|
||||
github.com/88250/lute v1.7.7-0.20250315023516-51571fa9286c
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
github.com/ConradIrwin/font v0.2.1
|
||||
|
|
|
|||
|
|
@ -14,8 +14,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.20250227144607-7f4570b0d689 h1:39y5g7vnFAIcXhTN3IXPk7h2xBhC4a9hBTykDhHJqRY=
|
||||
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=
|
||||
github.com/88250/lute v1.7.7-0.20250311111757-77ff1f87fd18 h1:KqpnL5yMxE0macmJwAb0g9uC0sMOwcKa1Rd5u629Hbo=
|
||||
github.com/88250/lute v1.7.7-0.20250311111757-77ff1f87fd18/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/lute v1.7.7-0.20250315023516-51571fa9286c h1:LoEjyEq5YbjpzCqmgDOs3FsNMGksIHJhSHv6U57f2jk=
|
||||
github.com/88250/lute v1.7.7-0.20250315023516-51571fa9286c/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01 h1:AcFe63RXjIh1XtX/dc4Es3U8bYKjlEkvavHd1nFBOHM=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|||
return
|
||||
}
|
||||
|
||||
// 生成文档历史 https://github.com/siyuan-note/siyuan/issues/14359
|
||||
generateOpTypeHistory(srcTree, HistoryOpUpdate)
|
||||
|
||||
// 移动前先删除引用 https://github.com/siyuan-note/siyuan/issues/7819
|
||||
sql.DeleteRefsTreeQueue(srcTree)
|
||||
sql.DeleteRefsTreeQueue(targetTree)
|
||||
|
|
|
|||
|
|
@ -237,9 +237,9 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||
|
||||
srcPath := historyPath
|
||||
var destPath, parentHPath string
|
||||
id := util.GetTreeID(historyPath)
|
||||
workingDoc := treenode.GetBlockTree(id)
|
||||
if nil != workingDoc {
|
||||
rootID := util.GetTreeID(historyPath)
|
||||
workingDoc := treenode.GetBlockTree(rootID)
|
||||
if nil != workingDoc && "d" == workingDoc.Type {
|
||||
if err = filelock.Remove(filepath.Join(util.DataDir, boxID, workingDoc.Path)); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -250,10 +250,6 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = filelock.CopyNewtimes(srcPath, destPath); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var avIDs []string
|
||||
tree, _ := loadTree(srcPath, util.NewLute())
|
||||
if nil != tree {
|
||||
|
|
@ -283,14 +279,47 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||
tree.Path = filepath.ToSlash(strings.TrimPrefix(destPath, util.DataDir+string(os.PathSeparator)+boxID))
|
||||
tree.HPath = parentHPath + "/" + tree.Root.IALAttr("title")
|
||||
|
||||
// 重置重复的块 ID https://github.com/siyuan-note/siyuan/issues/14358
|
||||
if nil != workingDoc {
|
||||
treenode.RemoveBlockTreesByRootID(rootID)
|
||||
}
|
||||
nodes := map[string]*ast.Node{}
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
nodes[n.ID] = n
|
||||
return ast.WalkContinue
|
||||
})
|
||||
var ids []string
|
||||
for nodeID, _ := range nodes {
|
||||
ids = append(ids, nodeID)
|
||||
}
|
||||
idMap := treenode.ExistBlockTrees(ids)
|
||||
var duplicatedIDs []string
|
||||
for nodeID, exist := range idMap {
|
||||
if exist {
|
||||
duplicatedIDs = append(duplicatedIDs, nodeID)
|
||||
}
|
||||
}
|
||||
for _, nodeID := range duplicatedIDs {
|
||||
node := nodes[nodeID]
|
||||
treenode.ResetNodeID(node)
|
||||
if ast.NodeDocument == node.Type {
|
||||
tree.ID = node.ID
|
||||
tree.Path = tree.Path[:strings.LastIndex(tree.Path, "/")] + "/" + node.ID + ".sy"
|
||||
}
|
||||
}
|
||||
|
||||
// 仅重新索引该文档,不进行全量索引
|
||||
// Reindex only the current document after rolling back the document https://github.com/siyuan-note/siyuan/issues/12320
|
||||
treenode.RemoveBlockTree(id)
|
||||
treenode.IndexBlockTree(tree)
|
||||
sql.RemoveTreeQueue(id)
|
||||
sql.IndexTreeQueue(tree)
|
||||
sql.RemoveTreeQueue(rootID)
|
||||
if writeErr := indexWriteTreeIndexQueue(tree); nil != writeErr {
|
||||
return
|
||||
}
|
||||
util.PushReloadFiletree()
|
||||
util.PushReloadProtyle(id)
|
||||
util.PushReloadProtyle(rootID)
|
||||
util.PushMsg(Conf.Language(102), 3000)
|
||||
|
||||
IncSync()
|
||||
|
|
@ -303,12 +332,12 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||
go func() {
|
||||
sql.FlushQueue()
|
||||
|
||||
tree, _ = LoadTreeByBlockID(id)
|
||||
tree, _ = LoadTreeByBlockID(rootID)
|
||||
if nil == tree {
|
||||
return
|
||||
}
|
||||
|
||||
refreshProtyle(id)
|
||||
refreshProtyle(rootID)
|
||||
|
||||
// 刷新页签名
|
||||
refText := getNodeRefText(tree.Root)
|
||||
|
|
|
|||
|
|
@ -204,8 +204,7 @@ func resetDuplicateBlocksOnFileSys() {
|
|||
|
||||
if "" == n.ID {
|
||||
needOverwrite = true
|
||||
n.ID = ast.NewNodeID()
|
||||
n.SetIALAttr("id", n.ID)
|
||||
treenode.ResetNodeID(n)
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
|
|
@ -225,8 +224,7 @@ func resetDuplicateBlocksOnFileSys() {
|
|||
|
||||
// 其他情况,重置节点 ID
|
||||
needOverwrite = true
|
||||
n.ID = ast.NewNodeID()
|
||||
n.SetIALAttr("id", n.ID)
|
||||
treenode.ResetNodeID(n)
|
||||
needRefreshUI = true
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
|
|
|||
|
|
@ -308,6 +308,9 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||
}
|
||||
|
||||
// 生成文档历史 https://github.com/siyuan-note/siyuan/issues/14359
|
||||
generateOpTypeHistory(srcTree, HistoryOpUpdate)
|
||||
|
||||
var headingChildren []*ast.Node
|
||||
if isMovingFoldHeading := ast.NodeHeading == srcNode.Type && "1" == srcNode.IALAttr("fold"); isMovingFoldHeading {
|
||||
headingChildren = treenode.HeadingChildren(srcNode)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,28 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func ResetNodeID(node *ast.Node) {
|
||||
if nil == node {
|
||||
return
|
||||
}
|
||||
|
||||
node.ID = ast.NewNodeID()
|
||||
node.SetIALAttr("id", node.ID)
|
||||
resetUpdatedByID(node)
|
||||
}
|
||||
|
||||
func resetUpdatedByID(node *ast.Node) {
|
||||
created := util.TimeFromID(node.ID)
|
||||
updated := node.IALAttr("updated")
|
||||
if "" == updated {
|
||||
updated = created
|
||||
}
|
||||
if updated < created {
|
||||
updated = created
|
||||
}
|
||||
node.SetIALAttr("updated", updated)
|
||||
}
|
||||
|
||||
func GetEmbedBlockRef(embedNode *ast.Node) (blockRefID string) {
|
||||
if nil == embedNode || ast.NodeBlockQueryEmbed != embedNode.Type {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue