mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-06 21:30:53 +08:00
🎨 Improve kernel API /api/block/appendBlock
https://github.com/siyuan-note/siyuan/issues/9955
This commit is contained in:
parent
f5ff8f74c2
commit
d9b5110ea5
@ -577,7 +577,24 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {
|
|||||||
for i := 0; i < len(toInserts); i++ {
|
for i := 0; i < len(toInserts); i++ {
|
||||||
toInsert := toInserts[i]
|
toInsert := toInserts[i]
|
||||||
if isContainer {
|
if isContainer {
|
||||||
if ast.NodeSuperBlock == node.Type {
|
if ast.NodeList == node.Type {
|
||||||
|
// 列表下只能挂列表项,所以这里需要分情况处理 https://github.com/siyuan-note/siyuan/issues/9955
|
||||||
|
if ast.NodeList == toInsert.Type {
|
||||||
|
var childLis []*ast.Node
|
||||||
|
for childLi := toInsert.FirstChild; nil != childLi; childLi = childLi.Next {
|
||||||
|
childLis = append(childLis, childLi)
|
||||||
|
}
|
||||||
|
for _, childLi := range childLis {
|
||||||
|
node.AppendChild(childLi)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newLiID := ast.NewNodeID()
|
||||||
|
newLi := &ast.Node{ID: newLiID, Type: ast.NodeListItem, ListData: &ast.ListData{Typ: node.ListData.Typ}}
|
||||||
|
newLi.SetIALAttr("id", newLiID)
|
||||||
|
node.AppendChild(newLi)
|
||||||
|
newLi.AppendChild(toInsert)
|
||||||
|
}
|
||||||
|
} else if ast.NodeSuperBlock == node.Type {
|
||||||
node.LastChild.InsertBefore(toInsert)
|
node.LastChild.InsertBefore(toInsert)
|
||||||
} else {
|
} else {
|
||||||
node.AppendChild(toInsert)
|
node.AppendChild(toInsert)
|
||||||
|
Loading…
Reference in New Issue
Block a user