diff --git a/kernel/model/block.go b/kernel/model/block.go index bf0bd7a20..671ccf9be 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -547,6 +547,22 @@ func GetHeadingChildrenDOM(id string) (ret string) { nodes := append([]*ast.Node{}, heading) children := treenode.HeadingChildren(heading) nodes = append(nodes, children...) + + // 取消折叠 https://github.com/siyuan-note/siyuan/issues/13232#issuecomment-2535955152 + for _, child := range children { + ast.Walk(child, func(n *ast.Node, entering bool) ast.WalkStatus { + if !entering { + return ast.WalkContinue + } + + n.RemoveIALAttr("heading-fold") + n.RemoveIALAttr("fold") + return ast.WalkContinue + }) + } + heading.RemoveIALAttr("fold") + heading.RemoveIALAttr("heading-fold") + luteEngine := util.NewLute() ret = renderBlockDOMByNodes(nodes, luteEngine) return diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go index 8af83a689..d5f3db007 100644 --- a/kernel/model/blockial.go +++ b/kernel/model/blockial.go @@ -215,6 +215,22 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string) (oldAttrs map[s } } + if tag, ok := nameValues["tags"]; ok { + var tags []string + tmp := strings.Split(tag, ",") + for _, t := range tmp { + t = util.RemoveInvalid(t) + t = strings.TrimSpace(t) + if "" != t { + tags = append(tags, t) + } + } + tags = gulu.Str.RemoveDuplicatedElem(tags) + if 0 < len(tags) { + nameValues["tags"] = strings.Join(tags, ",") + } + } + for name, value := range nameValues { value = util.RemoveInvalid(value) value = strings.TrimSpace(value) diff --git a/kernel/model/heading.go b/kernel/model/heading.go index 85219079d..f5ecd7ffa 100644 --- a/kernel/model/heading.go +++ b/kernel/model/heading.go @@ -22,6 +22,7 @@ import ( "path" "path/filepath" "strings" + "sync" "github.com/88250/gulu" "github.com/88250/lute/ast" @@ -117,12 +118,16 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) { return } +var docConvertLock = sync.Mutex{} + func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) { if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) { return } FlushTxQueue() + docConvertLock.Lock() + defer docConvertLock.Unlock() srcTree, _ := LoadTreeByBlockID(srcID) if nil == srcTree { @@ -277,6 +282,8 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st func Heading2Doc(srcHeadingID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) { FlushTxQueue() + docConvertLock.Lock() + defer docConvertLock.Unlock() srcTree, _ := LoadTreeByBlockID(srcHeadingID) if nil == srcTree { diff --git a/kernel/model/import.go b/kernel/model/import.go index 1745c6d0d..7a587d5ce 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -49,6 +49,7 @@ import ( "github.com/siyuan-note/siyuan/kernel/av" "github.com/siyuan-note/siyuan/kernel/filesys" "github.com/siyuan-note/siyuan/kernel/sql" + "github.com/siyuan-note/siyuan/kernel/task" "github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/util" ) @@ -612,6 +613,8 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { } IncSync() + + task.AppendTask(task.UpdateIDs, util.PushUpdateIDs, blockIDs) return } diff --git a/kernel/model/listitem.go b/kernel/model/listitem.go index e2f97b27b..8e2acb59e 100644 --- a/kernel/model/listitem.go +++ b/kernel/model/listitem.go @@ -29,6 +29,8 @@ import ( func ListItem2Doc(srcListItemID, targetBoxID, targetPath, previousPath string) (srcRootBlockID, newTargetPath string, err error) { FlushTxQueue() + docConvertLock.Lock() + defer docConvertLock.Unlock() srcTree, _ := LoadTreeByBlockID(srcListItemID) if nil == srcTree { diff --git a/kernel/task/queue.go b/kernel/task/queue.go index 30f47ca59..02f8197ba 100644 --- a/kernel/task/queue.go +++ b/kernel/task/queue.go @@ -138,6 +138,7 @@ const ( ReloadProtyle = "task.reload.protyle" // 重新加载编辑器 SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本 SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数 + UpdateIDs = "task.update.ids" // 更新 ID PushMsg = "task.push.msg" // 推送消息 ) @@ -157,6 +158,7 @@ var uniqueActions = []string{ ReloadProtyle, SetRefDynamicText, SetDefRefCount, + UpdateIDs, } func ContainIndexTask() bool { diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go index cf43e9344..b01f007fc 100644 --- a/kernel/util/websocket.go +++ b/kernel/util/websocket.go @@ -241,6 +241,10 @@ func PushClearProgress() { BroadcastByType("main", "cprogress", 0, "", nil) } +func PushUpdateIDs(ids map[string]string) { + BroadcastByType("main", "updateids", 0, "", ids) +} + func PushReloadDoc(rootID string) { BroadcastByType("main", "reloaddoc", 0, "", rootID) }