mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve //!js query embed block result sorting https://github.com/siyuan-note/siyuan/issues/9977
This commit is contained in:
parent
1618758b11
commit
679870bd01
1 changed files with 10 additions and 0 deletions
|
|
@ -83,6 +83,16 @@ func GetEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, br
|
||||||
func getEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
func getEmbedBlock(embedBlockID string, includeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
|
||||||
stmt := "SELECT * FROM `blocks` WHERE `id` IN ('" + strings.Join(includeIDs, "','") + "')"
|
stmt := "SELECT * FROM `blocks` WHERE `id` IN ('" + strings.Join(includeIDs, "','") + "')"
|
||||||
sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 1024)
|
sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 1024)
|
||||||
|
|
||||||
|
// 根据 includeIDs 的顺序排序 Improve `//!js` query embed block result sorting https://github.com/siyuan-note/siyuan/issues/9977
|
||||||
|
m := map[string]int{}
|
||||||
|
for i, id := range includeIDs {
|
||||||
|
m[id] = i
|
||||||
|
}
|
||||||
|
sort.Slice(sqlBlocks, func(i, j int) bool {
|
||||||
|
return m[sqlBlocks[i].ID] < m[sqlBlocks[j].ID]
|
||||||
|
})
|
||||||
|
|
||||||
ret = buildEmbedBlock(embedBlockID, []string{}, headingMode, breadcrumb, sqlBlocks)
|
ret = buildEmbedBlock(embedBlockID, []string{}, headingMode, breadcrumb, sqlBlocks)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue