mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-16 20:18:06 +01:00
🎨 Improve exporting document HTML (#16219)
* 🎨 The browser-side supports exporting document HTML fix https://github.com/siyuan-note/siyuan/issues/16213 * 修复导出 HTML 时引入资源没有使用相对路径,修复文档导出 HTML/PDF 时缺失图标 fix https://github.com/siyuan-note/siyuan/issues/16217 fix https://github.com/siyuan-note/siyuan/issues/16216 01 * 修复文档导出 HTML/PDF 时冗余图标 fix https://github.com/siyuan-note/siyuan/issues/16216 02
This commit is contained in:
parent
bca1f1eda6
commit
90a447f914
6 changed files with 241 additions and 40 deletions
|
|
@ -766,7 +766,8 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||
if 1 == Conf.Appearance.Mode {
|
||||
theme = Conf.Appearance.ThemeDark
|
||||
}
|
||||
srcs = []string{"icons", "themes/" + theme}
|
||||
// 复制主题文件夹
|
||||
srcs = []string{"themes/" + theme}
|
||||
appearancePath := util.AppearancePath
|
||||
if util.IsSymlinkPath(util.AppearancePath) {
|
||||
// Support for symlinked theme folder when exporting HTML https://github.com/siyuan-note/siyuan/issues/9173
|
||||
|
|
@ -787,6 +788,35 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||
}
|
||||
}
|
||||
|
||||
// 只复制图标文件夹中的 icon.js 文件
|
||||
iconName := Conf.Appearance.Icon
|
||||
// 如果使用的不是内建图标(ant 或 material),需要复制 material 作为后备
|
||||
if iconName != "ant" && iconName != "material" && iconName != "" {
|
||||
srcIconFile := filepath.Join(appearancePath, "icons", "material", "icon.js")
|
||||
toIconDir := filepath.Join(savePath, "appearance", "icons", "material")
|
||||
if err := os.MkdirAll(toIconDir, 0755); err != nil {
|
||||
logging.LogErrorf("mkdir [%s] failed: %s", toIconDir, err)
|
||||
return
|
||||
}
|
||||
toIconFile := filepath.Join(toIconDir, "icon.js")
|
||||
if err := filelock.Copy(srcIconFile, toIconFile); err != nil {
|
||||
logging.LogWarnf("copy icon file from [%s] to [%s] failed: %s", srcIconFile, toIconFile, err)
|
||||
}
|
||||
}
|
||||
// 复制当前使用的图标文件
|
||||
if iconName != "" {
|
||||
srcIconFile := filepath.Join(appearancePath, "icons", iconName, "icon.js")
|
||||
toIconDir := filepath.Join(savePath, "appearance", "icons", iconName)
|
||||
if err := os.MkdirAll(toIconDir, 0755); err != nil {
|
||||
logging.LogErrorf("mkdir [%s] failed: %s", toIconDir, err)
|
||||
return
|
||||
}
|
||||
toIconFile := filepath.Join(toIconDir, "icon.js")
|
||||
if err := filelock.Copy(srcIconFile, toIconFile); err != nil {
|
||||
logging.LogWarnf("copy icon file from [%s] to [%s] failed: %s", srcIconFile, toIconFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
// 复制自定义表情图片
|
||||
emojis := emojisInTree(tree)
|
||||
for _, emoji := range emojis {
|
||||
|
|
@ -930,7 +960,8 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
if 1 == Conf.Appearance.Mode {
|
||||
theme = Conf.Appearance.ThemeDark
|
||||
}
|
||||
srcs = []string{"icons", "themes/" + theme}
|
||||
// 复制主题文件夹
|
||||
srcs = []string{"themes/" + theme}
|
||||
appearancePath := util.AppearancePath
|
||||
if util.IsSymlinkPath(util.AppearancePath) {
|
||||
// Support for symlinked theme folder when exporting HTML https://github.com/siyuan-note/siyuan/issues/9173
|
||||
|
|
@ -949,6 +980,35 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
}
|
||||
}
|
||||
|
||||
// 只复制图标文件夹中的 icon.js 文件
|
||||
iconName := Conf.Appearance.Icon
|
||||
// 如果使用的不是内建图标(ant 或 material),需要复制 material 作为后备
|
||||
if iconName != "ant" && iconName != "material" && iconName != "" {
|
||||
srcIconFile := filepath.Join(appearancePath, "icons", "material", "icon.js")
|
||||
toIconDir := filepath.Join(savePath, "appearance", "icons", "material")
|
||||
if err := os.MkdirAll(toIconDir, 0755); err != nil {
|
||||
logging.LogErrorf("mkdir [%s] failed: %s", toIconDir, err)
|
||||
return
|
||||
}
|
||||
toIconFile := filepath.Join(toIconDir, "icon.js")
|
||||
if err := filelock.Copy(srcIconFile, toIconFile); err != nil {
|
||||
logging.LogWarnf("copy icon file from [%s] to [%s] failed: %s", srcIconFile, toIconFile, err)
|
||||
}
|
||||
}
|
||||
// 复制当前使用的图标文件
|
||||
if iconName != "" {
|
||||
srcIconFile := filepath.Join(appearancePath, "icons", iconName, "icon.js")
|
||||
toIconDir := filepath.Join(savePath, "appearance", "icons", iconName)
|
||||
if err := os.MkdirAll(toIconDir, 0755); err != nil {
|
||||
logging.LogErrorf("mkdir [%s] failed: %s", toIconDir, err)
|
||||
return
|
||||
}
|
||||
toIconFile := filepath.Join(toIconDir, "icon.js")
|
||||
if err := filelock.Copy(srcIconFile, toIconFile); err != nil {
|
||||
logging.LogWarnf("copy icon file from [%s] to [%s] failed: %s", srcIconFile, toIconFile, err)
|
||||
}
|
||||
}
|
||||
|
||||
// 复制自定义表情图片
|
||||
emojis := emojisInTree(tree)
|
||||
for _, emoji := range emojis {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue