mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 支持合并子文档导出 Word/PDF https://github.com/siyuan-note/siyuan/issues/3219
This commit is contained in:
parent
872b341d11
commit
c2d1686164
4 changed files with 16 additions and 3 deletions
|
|
@ -391,6 +391,7 @@ const initWindow = () => {
|
|||
destroyPrintWindow();
|
||||
fetchPost("/api/export/addPDFOutline", {
|
||||
id: ipcData.rootId,
|
||||
merge: ipcData.mergeSubdocs,
|
||||
path: pdfFilePath
|
||||
}, () => {
|
||||
afterExport(pdfFilePath, msgId);
|
||||
|
|
|
|||
|
|
@ -290,7 +290,11 @@ func addPDFOutline(c *gin.Context) {
|
|||
|
||||
id := arg["id"].(string)
|
||||
path := arg["path"].(string)
|
||||
err := model.AddPDFOutline(id, path)
|
||||
merge := false
|
||||
if nil != arg["merge"] {
|
||||
merge = arg["merge"].(bool)
|
||||
}
|
||||
err := model.AddPDFOutline(id, path, merge)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ func processIFrame(tree *parse.Tree) {
|
|||
}
|
||||
}
|
||||
|
||||
func AddPDFOutline(id, p string) (err error) {
|
||||
func AddPDFOutline(id, p string, merge bool) (err error) {
|
||||
inFile := p
|
||||
links, err := api.ListToCLinks(inFile)
|
||||
if nil != err {
|
||||
|
|
@ -527,6 +527,14 @@ func AddPDFOutline(id, p string) (err error) {
|
|||
if nil == tree {
|
||||
return
|
||||
}
|
||||
if merge {
|
||||
var mergeErr error
|
||||
tree, mergeErr = mergeSubDocs(tree)
|
||||
if nil != mergeErr {
|
||||
logging.LogErrorf("merge sub docs failed: %s", mergeErr)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var headings []*ast.Node
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func loadTreeNodes(box string, p string, level int) (ret []*ast.Node, err error)
|
|||
hLevel = 6
|
||||
}
|
||||
|
||||
heading := &ast.Node{Type: ast.NodeHeading, HeadingLevel: hLevel}
|
||||
heading := &ast.Node{ID: tree.Root.ID, Type: ast.NodeHeading, HeadingLevel: hLevel}
|
||||
heading.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(tree.Root.IALAttr("title"))})
|
||||
tree.Root.PrependChild(heading)
|
||||
for c := tree.Root.FirstChild; nil != c; c = c.Next {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue