Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-12-11 23:24:55 +08:00
commit eba36f4baa
7 changed files with 50 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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