mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
62efb18021
2 changed files with 13 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
)
|
||||
|
||||
func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
||||
|
|
@ -30,9 +31,6 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
}
|
||||
|
||||
insertPoint := rootTree.Root.LastChild
|
||||
if nil == insertPoint {
|
||||
insertPoint = rootTree.Root
|
||||
}
|
||||
|
||||
// 跳过空段落插入点,向上寻找非空段落
|
||||
for ; nil != insertPoint && ast.NodeParagraph == insertPoint.Type; insertPoint = insertPoint.Previous {
|
||||
|
|
@ -41,6 +39,17 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// 导出空文档 Word 和 PDF 时合并子文档失败 https://github.com/siyuan-note/siyuan/issues/7429
|
||||
if nil == insertPoint {
|
||||
// 如果找不到非空段落,则使用第一个段落作为插入点
|
||||
insertPoint = rootTree.Root.FirstChild
|
||||
if nil == insertPoint {
|
||||
// 如果文档为空,则创建一个空段落作为插入点
|
||||
insertPoint = treenode.NewParagraph()
|
||||
rootTree.Root.AppendChild(insertPoint)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
i := 0
|
||||
if err = walkBlock(insertPoint, rootBlock, i); nil != err {
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDs map[string]bool) {
|
|||
|
||||
for _, t := range trees {
|
||||
ast.Walk(t.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || !n.IsBlock() || ast.NodeDocument == n.Type {
|
||||
if !entering || !n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue