Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 9, 2023
2 parents b0653df + eb931f4 commit 7a7af86
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 19 deletions.
4 changes: 3 additions & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@
"export22": "<code class='fn__code'>%page</code> is the current page number, <code class='fn__code'>%pages</code> is the total page number, and supports Sprig template functions",
"export23": "Export Markdown with YAML front-matter",
"export24": "After enabling, add some general metadata information at the beginning of the exported Markdown file",
"export25": "Export Word .docx template path",
"export26": "The absolute path of the template used when exporting Word .docx files, that is, Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target=\"_blank \">--reference-doc</a> parameter value",
"theme11": "Use theme in light mode",
"theme12": "Use theme in dark mode",
"theme2": "Select the icons used in the user interface",
Expand Down Expand Up @@ -1254,7 +1256,7 @@
"194": "<a href=\"https://help.jianguoyun.com/?p=2064\" target=\"_blank\">There are restrictions on the Nutstore interface</a>, please use other WebDAV services",
"195": "The system time is incorrect, please calibrate the system time and try again",
"196": "Do not set the workspace under the path of a third-party sync disk, otherwise the data will be damaged (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)",
"197": "Currently the editor is in read-only mode. If you need to edit content, please switch to edit mode",
"197": "The specified Word .docx template [%s] was not found, please check [Settings - Export - Export Word .docx template path]",
"198": "This is not a valid Data archive. If the archive was exported from [Doc tree], please import it from [Doc tree]",
"199": "This is not a valid .sy.zip archive. If the archive was exported from [Settings], please import it from [Settings]",
"200": "Global search response time is slow, it is recommended to add type filtering or keywords to narrow the search scope",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@
"export22": "<code class='fn__code'>%page</code> es el número de página actual, <code class='fn__code'>%pages</code> es el número de página total y es compatible con las funciones de plantilla de Sprig ",
"export23": "Exportar descuento con YAML front-matter",
"export24": "Después de habilitar, agregue información general de metadatos al comienzo del archivo Markdown exportado",
"export25": "Exportar ruta de plantilla .docx de Word",
"export26": "La ruta absoluta de la plantilla utilizada al exportar archivos .docx de Word, es decir, Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target =\"_blank\">--reference-doc</a> valor del parámetro",
"theme11": "Usar tema en modo claro",
"theme12": "Usar tema en modo oscuro",
"theme2": "Selecciona los iconos utilizados en la interfaz de usuario",
Expand Down Expand Up @@ -1254,7 +1256,7 @@
"194": "<a href=\"https://help.jianguoyun.com/?p=2064\" target=\"_blank\">Existen restricciones en la interfaz de Nutstore</a>, utilice otros servicios WebDAV",
"195": "La hora del sistema es incorrecta, calibre la hora del sistema y vuelva a intentarlo",
"196": "No configure el espacio de trabajo bajo la ruta de un disco de sincronización de terceros, de lo contrario, los datos se dañarán (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)",
"197": "Actualmente, el editor se encuentra en modo de solo lectura. Si necesita editar contenido, cambie al modo de edición",
"197": "No se encontró la plantilla Word .docx especificada [%s]; verifique [Configuración - Exportar - Exportar ruta de la plantilla Word .docx]",
"198": "Este no es un archivo data.zip válido. Si el archivo se exportó de [Árbol de documentos], importalo de [Árbol de documentos]",
"199": "Este no es un archivo .sy.zip válido. Si el archivo se exportó desde [Configuración], impórtelo desde [Configuración]",
"200": "El tiempo de respuesta de b\u00fasqueda global es lento, se recomienda agregar filtros de tipo o palabras clave para reducir el alcance de b\u00fasqueda",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@
"export22": "<code class='fn__code'>%page</code> est le numéro de page actuel, <code class='fn__code'>%pages</code> est le numéro de page total et prend en charge les fonctions de modèle Sprig ",
"export23": "Exporter Markdown avec YAML front-matter",
"export24": "Après l'activation, ajoutez des informations générales sur les métadonnées au début du fichier Markdown exporté",
"export25": "Chemin d'exportation du modèle Word .docx",
"export26": "Le chemin absolu du modèle utilisé lors de l'exportation de fichiers Word .docx, c'est-à-dire Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target =\"_blank\">--reference-doc</a> valeur du paramètre",
"theme11": "Utiliser le thème en mode Clair",
"theme12": "Utiliser le thème en mode sombre",
"theme2": "Sélectionnez les icônes utilisées dans l'interface utilisateur",
Expand Down Expand Up @@ -1254,7 +1256,7 @@
"194": "<a href=\"https://help.jianguoyun.com/?p=2064\" target=\"_blank\">Il existe des restrictions sur l'interface Nutstore</a>, veuillez utiliser d'autres services WebDAV",
"195": "L'heure du système est incorrecte, veuillez calibrer l'heure du système et réessayer",
"196": "Ne définissez pas l'espace de travail sous le chemin d'un disque de synchronisation tiers, sinon les données seront endommagées (iCloud/OneDrive/Dropbox/Google Drive/Nutstore/Baidu Netdisk/Tencent Weiyun, etc.)",
"197": "Actuellement, l'éditeur est en mode lecture seule. Si vous devez modifier le contenu, veuillez passer en mode édition",
"197": "Le modèle Word .docx spécifié [%s] n'a pas été trouvé, veuillez vérifier [Paramètres - Exporter - Exporter le chemin du modèle Word .docx]",
"198": "Ceci n'est pas une archive data.zip valide. Si l'archive a été exportée depuis [Doc tree], veuillez l'importer depuis [Doc tree]",
"199": "Ceci n'est pas une archive .sy.zip valide. Si l'archive a été exportée depuis [Paramètres], veuillez l'importer depuis [Paramètres]",
"200": "Le temps de réponse de la recherche globale est lent, il est recommandé d'ajouter un filtrage de type ou des mots-clés pour restreindre la portée de la recherche",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@
"export22": "<code class='fn__code'>%page</code> 為當前頁碼,<code class='fn__code'>%pages</code> 為總頁碼,支持 Sprig 範本函數",
"export23": "導出 Markdown 添加 YAML front-matter",
"export24": "啟用後在導出的 Markdown 文件開頭處添加一些較為通用的元資料資訊",
"export25": "導出 Word .docx 模板路徑",
"export26": "導出 Word .docx 文件時使用的模板絕對路徑,即 Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target=\"_blank \">--reference-doc</a> 參數的值",
"theme11": "淺色模式下使用主題",
"theme12": "深色模式下使用主題",
"theme2": "選擇外觀使用的圖示",
Expand Down Expand Up @@ -1254,7 +1256,7 @@
"194": "<a href=\"https://help.jianguoyun.com/?p=2064\" target=\"_blank\">堅果雲接口存在限制</a>,請使用其他 WebDAV 服務",
"195": "系統時間不正確,請校準系統時間後再試",
"196": "請勿將工作空間設置在第三方同步硬碟路徑下,否則資料會被損壞(iCloud/OneDrive/Dropbox/Google Drive/堅果雲/百度網盤/騰訊微雲等)",
"197": "目前編輯器正處於只讀模式狀態,如果需要編輯內容,請切換到編輯模式",
"197": "未找到指定的 Word .docx 模板 [%s],請檢查 [設置 - 導出 - 導出 Word .docx 模板路徑]",
"198": "這不是一個有效的 Data 壓縮檔。如果該資料檔是從 [文檔樹] 導出的,請從 [文檔樹] 導入",
"199": "這不是一個有效的 .sy.zip 壓縮檔。如果該資料檔是從 [設置] 中導出的,請從 [設置] 中導入",
"200": "全域搜索響應時間較慢,建議增加類型過濾或者增加關鍵字以縮小搜索範圍",
Expand Down
4 changes: 3 additions & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@
"export22": "<code class='fn__code'>%page</code> 为当前页码,<code class='fn__code'>%pages</code> 为总页码,支持 Sprig 模板函数",
"export23": "导出 Markdown 添加 YAML front-matter",
"export24": "启用后在导出的 Markdown 文件开头处添加一些较为通用的元数据信息",
"export25": "导出 Word .docx 模板路径",
"export26": "导出 Word .docx 文件时使用的模板绝对路径,即 Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target=\"_blank\">--reference-doc</a> 参数的值",
"theme11": "明亮模式下使用主题",
"theme12": "暗黑模式下使用主题",
"theme2": "选择外观使用的图标",
Expand Down Expand Up @@ -1254,7 +1256,7 @@
"194": "<a href=\"https://help.jianguoyun.com/?p=2064\" target=\"_blank\">坚果云接口存在限制</a>,请使用其他 WebDAV 服务",
"195": "系统时间不正确,请校准系统时间后再试",
"196": "请勿将工作空间设置在第三方同步盘路径下,否则数据会被损坏(iCloud/OneDrive/Dropbox/Google Drive/坚果云/百度网盘/腾讯微云等)",
"197": "目前编辑器正处于只读模式状态,如果需要编辑内容,请切换到编辑模式",
"197": "未找到指定的 Word .docx 模板 [%s],请检查 [设置 - 导出 - 导出 Word .docx 模板路径]",
"198": "这不是一个有效的 Data 压缩包。如果该数据包是从 [文档树] 导出的,请从 [文档树] 导入",
"199": "这不是一个有效的 .sy.zip 压缩包。如果该数据包是从 [设置] 中导出的,请从 [设置] 中导入",
"200": "全局搜索响应时间较慢,建议增加类型过滤或者增加关键字以缩小搜索范围",
Expand Down
9 changes: 9 additions & 0 deletions app/src/config/exportConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export const exportConfig = {
</div>
<input class="b3-text-field fn__flex-center fn__size200" id="pdfFooter">
</label>
<label class="fn__flex b3-label config__item">
<div class="fn__flex-1">
${window.siyuan.languages.export25}
<div class="b3-label__text">${window.siyuan.languages.export26}</div>
</div>
<input class="b3-text-field fn__flex-center fn__size200" id="docxTemplate" placeholder="F:\\template.docx">
</label>
<label class="fn__flex b3-label config__item">
<div class="fn__flex-1">
${window.siyuan.languages.export13}
Expand Down Expand Up @@ -127,6 +134,7 @@ export const exportConfig = {
</label>`;
},
bindEvent: () => {
(exportConfig.element.querySelector("#docxTemplate") as HTMLInputElement).value = window.siyuan.config.export.docxTemplate;
(exportConfig.element.querySelector("#pdfFooter") as HTMLInputElement).value = window.siyuan.config.export.pdfFooter;
(exportConfig.element.querySelector("#blockRefTextLeft") as HTMLInputElement).value = window.siyuan.config.export.blockRefTextLeft;
(exportConfig.element.querySelector("#blockRefTextRight") as HTMLInputElement).value = window.siyuan.config.export.blockRefTextRight;
Expand All @@ -142,6 +150,7 @@ export const exportConfig = {
blockEmbedMode: parseInt((exportConfig.element.querySelector("#blockEmbedMode") as HTMLSelectElement).value, 10),
fileAnnotationRefMode: parseInt((exportConfig.element.querySelector("#fileAnnotationRefMode") as HTMLSelectElement).value, 10),
pdfFooter: (exportConfig.element.querySelector("#pdfFooter") as HTMLInputElement).value,
docxTemplate: (exportConfig.element.querySelector("#docxTemplate") as HTMLInputElement).value,
blockRefTextLeft: (exportConfig.element.querySelector("#blockRefTextLeft") as HTMLInputElement).value,
blockRefTextRight: (exportConfig.element.querySelector("#blockRefTextRight") as HTMLInputElement).value,
tagOpenMarker: (exportConfig.element.querySelector("#tagOpenMarker") as HTMLInputElement).value,
Expand Down
1 change: 1 addition & 0 deletions app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ interface IExport {
addTitle: boolean;
markdownYFM: boolean;
pdfFooter: string;
docxTemplate: string;
}

interface IEditor {
Expand Down
14 changes: 0 additions & 14 deletions kernel/api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,6 @@ func getConf(c *gin.Context) {
"conf": maskedConf,
"start": !util.IsUILoaded,
}

if !util.IsUILoaded {
go func() {
util.WaitForUILoaded()

if model.Conf.Editor.ReadOnly {
// 编辑器启用只读模式时启动后提示用户 https://github.com/siyuan-note/siyuan/issues/7700
time.Sleep(time.Second * 3)
if model.Conf.Editor.ReadOnly {
util.PushMsg(model.Conf.Language(197), 7000)
}
}
}()
}
}

func setUILayout(c *gin.Context) {
Expand Down
1 change: 1 addition & 0 deletions kernel/conf/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Export struct {
PandocBin string `json:"pandocBin"` // Pandoc 可执行文件路径
MarkdownYFM bool `json:"markdownYFM"` // Markdown 导出时是否添加 YAML Front Matter https://github.com/siyuan-note/siyuan/issues/7727
PDFFooter string `json:"pdfFooter"` // PDF 导出时页脚内容
DocxTemplate string `json:"docxTemplate"` // Docx 导出时模板文件路径
}

func NewExport() *Export {
Expand Down
13 changes: 13 additions & 0 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,19 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (err error) {
"-o", tmpDocxPath,
}

// Pandoc template for exporting docx https://github.com/siyuan-note/siyuan/issues/8740
docxTemplate := gulu.Str.RemoveInvisible(Conf.Export.DocxTemplate)
docxTemplate = strings.TrimSpace(docxTemplate)
if "" != docxTemplate {
if !gulu.File.IsExist(docxTemplate) {
logging.LogErrorf("docx template [%s] not found", docxTemplate)
msg := fmt.Sprintf(Conf.Language(197), docxTemplate)
return errors.New(msg)
}

args = append(args, "--reference-doc", docxTemplate)
}

pandoc := exec.Command(Conf.Export.PandocBin, args...)
gulu.CmdAttr(pandoc)
pandoc.Stdin = bytes.NewBufferString(content)
Expand Down

0 comments on commit 7a7af86

Please sign in to comment.