Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
872b341d11
11 changed files with 38 additions and 26 deletions
|
@ -459,7 +459,7 @@
|
|||
"newNameFile": "The name of the new document is",
|
||||
"newContentFile": "The content of the new document is",
|
||||
"exporting": "Exporting, please wait...",
|
||||
"exported": "Export complete: ",
|
||||
"exported": "Export complete",
|
||||
"refExpired": "Search content block does not exist",
|
||||
"emptyContent": "No related content",
|
||||
"useBrowserView": "View in the browser",
|
||||
|
|
|
@ -458,7 +458,7 @@
|
|||
"newNameFile": "El nombre del nuevo documento es",
|
||||
"newContentFile": "El contenido del nuevo documento es",
|
||||
"exporting": "Exportando, por favor espere...",
|
||||
"exported": "Exportación completada: ",
|
||||
"exported": "Exportación completada",
|
||||
"refExpired": "El bloque de contenido de búsqueda no existe",
|
||||
"emptyContent": "No hay contenido relacionado",
|
||||
"useBrowserView": "Ver en el navegador",
|
||||
|
|
|
@ -459,7 +459,7 @@
|
|||
"newNameFile": "Le nom du nouveau document est",
|
||||
"newContentFile": "Le contenu du nouveau document est",
|
||||
"exporting": "En cours d'exportation, veuillez patienter...",
|
||||
"exported": "Exportation terminée: ",
|
||||
"exported": "Exportation terminée",
|
||||
"refExpired": "Le bloc de contenu de recherche n'existe pas",
|
||||
"emptyContent": "Aucun contenu pertinent pour le moment",
|
||||
"useBrowserView": "Afficher dans le navigateur",
|
||||
|
|
|
@ -459,7 +459,7 @@
|
|||
"newNameFile": "新建文檔名為",
|
||||
"newContentFile": "新建文檔內容為",
|
||||
"exporting": "正在匯出,請稍等...",
|
||||
"exported": "匯出完成:",
|
||||
"exported": "匯出完成",
|
||||
"refExpired": "不存在符合條件的內容塊",
|
||||
"emptyContent": "暫無相關內容",
|
||||
"useBrowserView": "在瀏覽器中查看",
|
||||
|
|
|
@ -459,7 +459,7 @@
|
|||
"newNameFile": "新建文档名为",
|
||||
"newContentFile": "新建文档内容为",
|
||||
"exporting": "正在导出,请稍等...",
|
||||
"exported": "导出完成:",
|
||||
"exported": "导出完成",
|
||||
"refExpired": "不存在符合条件的内容块",
|
||||
"emptyContent": "暂无相关内容",
|
||||
"useBrowserView": "在浏览器中查看",
|
||||
|
|
|
@ -15,7 +15,7 @@ import {openByMobile} from "../util/compatibility";
|
|||
|
||||
export const afterExport = (exportPath: string, msgId: string) => {
|
||||
/// #if !BROWSER
|
||||
showMessage(`${window.siyuan.languages.exported}${escapeHtml(exportPath)}
|
||||
showMessage(`${window.siyuan.languages.exported} ${escapeHtml(exportPath)}
|
||||
<div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--white">${window.siyuan.languages.showInFolder}</button>`, 6000, "info", msgId);
|
||||
document.querySelector(`#message [data-id="${msgId}"] button`).addEventListener("click", () => {
|
||||
|
|
|
@ -383,6 +383,7 @@ const initWindow = () => {
|
|||
id: ipcData.rootId,
|
||||
pdf: true,
|
||||
removeAssets: ipcData.removeAssets,
|
||||
merge: ipcData.mergeSubdocs,
|
||||
savePath: result.filePaths[0]
|
||||
}, () => {
|
||||
const pdfFilePath = path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf");
|
||||
|
|
|
@ -341,6 +341,16 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||
func ExportHTML(id, savePath string, pdf, keepFold, merge bool) (name, dom string) {
|
||||
savePath = strings.TrimSpace(savePath)
|
||||
tree, _ := loadTreeByBlockID(id)
|
||||
|
||||
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
|
||||
if pdf { // 导出 PDF 需要标记目录书签
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
|
@ -363,14 +373,6 @@ func ExportHTML(id, savePath string, pdf, keepFold, merge bool) (name, dom strin
|
|||
}
|
||||
}
|
||||
|
||||
if merge {
|
||||
var mergeErr error
|
||||
tree, mergeErr = mergeSubDocs(tree)
|
||||
if nil != mergeErr {
|
||||
logging.LogErrorf("merge sub docs failed: %s", mergeErr)
|
||||
return
|
||||
}
|
||||
}
|
||||
tree = exportTree(tree, true, true, keepFold)
|
||||
name = path.Base(tree.HPath)
|
||||
name = util.FilterFileName(name) // 导出 PDF、HTML 和 Word 时未移除不支持的文件名符号 https://github.com/siyuan-note/siyuan/issues/5614
|
||||
|
@ -502,8 +504,12 @@ func AddPDFOutline(id, p string) (err error) {
|
|||
footnotes := map[string]*pdfcpu.Bookmark{}
|
||||
for _, link := range links {
|
||||
linkID := link.URI[strings.LastIndex(link.URI, "/")+1:]
|
||||
|
||||
title := sql.GetBlock(linkID).Content
|
||||
b := sql.GetBlock(linkID)
|
||||
if nil == b {
|
||||
logging.LogWarnf("pdf outline block [%s] not found", linkID)
|
||||
continue
|
||||
}
|
||||
title := b.Content
|
||||
title, _ = url.QueryUnescape(title)
|
||||
bm := &pdfcpu.Bookmark{
|
||||
Title: title,
|
||||
|
|
|
@ -29,12 +29,22 @@ 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 {
|
||||
if nil != insertPoint.FirstChild {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
i := 0
|
||||
if err = walkBlock(insertPoint, rootBlock, i); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
if nil == rootBlock.Children {
|
||||
break
|
||||
}
|
||||
|
@ -44,13 +54,12 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
|
||||
func walkBlock(insertPoint *ast.Node, block *Block, level int) (err error) {
|
||||
level++
|
||||
for _, c := range block.Children {
|
||||
for i := len(block.Children) - 1; i >= 0; i-- {
|
||||
c := block.Children[i]
|
||||
if err = walkBlock(insertPoint, c, level); nil != err {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, c := range block.Children {
|
||||
nodes, loadErr := loadTreeNodes(c.Box, c.Path, level)
|
||||
if nil != loadErr {
|
||||
return
|
||||
|
|
|
@ -660,7 +660,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size
|
|||
luteEngine.RenderOptions.NodeIndexStart = index
|
||||
dom = luteEngine.Tree2BlockDOM(subTree, luteEngine.RenderOptions)
|
||||
|
||||
SetRecentDocByTree(id, tree)
|
||||
SetRecentDocByTree(tree)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,8 @@ import (
|
|||
|
||||
type RecentDoc struct {
|
||||
RootID string `json:"rootID"`
|
||||
ID string `json:"id"`
|
||||
Icon string `json:"icon"`
|
||||
Title string `json:"title"`
|
||||
Mode string `json:"mode"`
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
var recentDocLock = sync.Mutex{}
|
||||
|
@ -63,10 +60,9 @@ func RemoveRecentDoc(ids []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func SetRecentDocByTree(id string, tree *parse.Tree) {
|
||||
func SetRecentDocByTree(tree *parse.Tree) {
|
||||
recentDoc := &RecentDoc{
|
||||
RootID: tree.Root.ID,
|
||||
ID: id,
|
||||
Icon: tree.Root.IALAttr("icon"),
|
||||
Title: tree.Root.IALAttr("title"),
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue