🎨 Improve rollback doc to avoid ID duplication https://github.com/siyuan-note/siyuan/issues/14358

This commit is contained in:
Daniel 2025-03-15 12:43:38 +08:00
parent d348ad0383
commit 6407791fbb
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 25 additions and 16 deletions

View file

@ -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