mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve query embed block auto refresh https://github.com/siyuan-note/siyuan/issues/14370
This commit is contained in:
parent
244d360ef0
commit
771ab2b87f
3 changed files with 14 additions and 1 deletions
|
@ -233,8 +233,15 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
||||||
|
|
||||||
// 推送动态锚文本节点刷新
|
// 推送动态锚文本节点刷新
|
||||||
for _, defNode := range changedDefNodes {
|
for _, defNode := range changedDefNodes {
|
||||||
if "ref-d" == defNode.refType {
|
switch defNode.refType {
|
||||||
|
case "ref-d":
|
||||||
task.AppendAsyncTaskWithDelay(task.SetRefDynamicText, 200*time.Millisecond, util.PushSetRefDynamicText, refTreeID, n.ID, defNode.id, defNode.refText)
|
task.AppendAsyncTaskWithDelay(task.SetRefDynamicText, 200*time.Millisecond, util.PushSetRefDynamicText, refTreeID, n.ID, defNode.id, defNode.refText)
|
||||||
|
case "embed":
|
||||||
|
go func() {
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
sql.FlushQueue()
|
||||||
|
task.AppendAsyncTaskWithDelay(task.ReloadEmbedBlock, 200*time.Millisecond, util.PushReloadEmbedBlock, refTreeID, n.ID)
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
|
|
|
@ -138,6 +138,7 @@ const (
|
||||||
ReloadProtyle = "task.reload.protyle" // 重新加载编辑器
|
ReloadProtyle = "task.reload.protyle" // 重新加载编辑器
|
||||||
SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本
|
SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本
|
||||||
SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数
|
SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数
|
||||||
|
ReloadEmbedBlock = "task.ref.reloadEmbedBlock" // 重新加载嵌入块
|
||||||
UpdateIDs = "task.update.ids" // 更新 ID
|
UpdateIDs = "task.update.ids" // 更新 ID
|
||||||
PushMsg = "task.push.msg" // 推送消息
|
PushMsg = "task.push.msg" // 推送消息
|
||||||
)
|
)
|
||||||
|
@ -158,6 +159,7 @@ var uniqueActions = []string{
|
||||||
ReloadProtyle,
|
ReloadProtyle,
|
||||||
SetRefDynamicText,
|
SetRefDynamicText,
|
||||||
SetDefRefCount,
|
SetDefRefCount,
|
||||||
|
ReloadEmbedBlock,
|
||||||
UpdateIDs,
|
UpdateIDs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,10 @@ func PushSetDefRefCount(rootID, blockID string, defIDs []string, refCount, rootR
|
||||||
BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "defIDs": defIDs})
|
BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "defIDs": defIDs})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PushReloadEmbedBlock(rootID, embedBlockID string) {
|
||||||
|
BroadcastByType("main", "reloadEmbedBlock", 0, "", map[string]interface{}{"rootID": rootID, "embedBlockID": embedBlockID})
|
||||||
|
}
|
||||||
|
|
||||||
func PushProtyleLoading(rootID, msg string) {
|
func PushProtyleLoading(rootID, msg string) {
|
||||||
BroadcastByType("protyle", "addLoading", 0, msg, rootID)
|
BroadcastByType("protyle", "addLoading", 0, msg, rootID)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue