mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-30 20:25:17 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
c4dc81137d
9 changed files with 97 additions and 77 deletions
|
|
@ -389,11 +389,11 @@
|
|||
"previous": "Previous",
|
||||
"next": "Next",
|
||||
"lockFile0": "Unable to access data",
|
||||
"lockFile1": "The data file has been locked by another program. (If a third-party sync disk is used, please check the sync status)",
|
||||
"lockFile2": "If the problem still occurs frequently in subsequent use, please report it via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>, thank you!",
|
||||
"lockFile1": "The data file has been locked by another program",
|
||||
"lockFile2": "If the problem still occurs frequently in subsequent use, please report it via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>",
|
||||
"kernelFault0": "Kernel connection interrupted...",
|
||||
"kernelFault1": "If the dialog do not disappear automatically after 7 seconds, please close the window and restart.",
|
||||
"kernelFault2": "If the problem still occurs after restarting, please report it via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>, thank you!",
|
||||
"kernelFault1": "Please check if the network connection and kernel process is normal",
|
||||
"kernelFault2": "If the problem still occurs after restarting, please report it via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>",
|
||||
"fontSize": "Font Size",
|
||||
"fontSizeTip": "The default font size is 16px, this setting only affects the font size display in the editor",
|
||||
"font1": "This setting only affects the font family display in the editor, choose <code class='fn__code'>Default</code> to use the theme's font family",
|
||||
|
|
|
|||
|
|
@ -389,11 +389,11 @@
|
|||
"previous": "Anterior",
|
||||
"next": "Siguiente",
|
||||
"lockFile0": "No se puede acceder a los datos",
|
||||
"lockFile1": "El archivo de datos ha sido bloqueado por otro programa. (Si se utiliza un disco de sincronización de terceros, compruebe el estado de la sincronización)",
|
||||
"lockFile2": "Si el problema sigue ocurriendo con frecuencia en el uso posterior, infórmelo a través de <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">Problemas en GitHub</a>, gracias!",
|
||||
"lockFile1": "El archivo de datos ha sido bloqueado por otro programa",
|
||||
"lockFile2": "Si el problema sigue ocurriendo con frecuencia en el uso posterior, infórmelo a través de <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">Problemas en GitHub</a>",
|
||||
"kernelFault0": "Conexión del kernel interrumpida...",
|
||||
"kernelFault1": "Si el diálogo no desaparece automáticamente después de 7 segundos, por favor cierre la ventana y reinicie",
|
||||
"kernelFault2": "Si el problema sigue produciéndose después de reiniciar, comuníquelo a través de <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">Problemas en GitHub</a>, gracias!",
|
||||
"kernelFault1": "Verifique si la conexión de red y los procesos del kernel son normales",
|
||||
"kernelFault2": "Si el problema sigue produciéndose después de reiniciar, comuníquelo a través de <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">Problemas en GitHub</a>",
|
||||
"fontSize": "Tamaño de la fuente",
|
||||
"fontSizeTip": "El tamaño de la fuente por defecto es de 16px, este ajuste sólo afecta a la visualización del tamaño de la fuente en el editor",
|
||||
"font1": "Este ajuste sólo afecta a la visualización de la familia de fuentes en el editor, elija <code class='fn__code'>Por defecto</code> para utilizar la familia de fuentes del tema",
|
||||
|
|
|
|||
|
|
@ -389,11 +389,11 @@
|
|||
"previous": "Précédent",
|
||||
"next": "Prochain",
|
||||
"lockFile0": "Impossible d'accéder aux données",
|
||||
"lockFile1": "Le fichier de données a été verrouillé par un autre programme. (Si un disque de synchronisation tiers est utilisé, veuillez vérifier le statut de synchronisation).",
|
||||
"lockFile2": "Si le problème se produit encore fréquemment lors d'une utilisation ultérieure, veuillez le signaler via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>, merci!",
|
||||
"lockFile1": "Le fichier de données a été verrouillé par un autre programme",
|
||||
"lockFile2": "Si le problème se produit encore fréquemment lors d'une utilisation ultérieure, veuillez le signaler via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>",
|
||||
"kernelFault0": "Connexion au noyau interrompue...",
|
||||
"kernelFault1": "Si le dialogue ne disparaît pas automatiquement après 7 secondes, veuillez fermer la fenêtre et redémarrer.",
|
||||
"kernelFault2": "Si le problème persiste après le redémarrage, veuillez le signaler via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>, merci!",
|
||||
"kernelFault1": "Veuillez vérifier si la connexion réseau et les processus du noyau sont normaux",
|
||||
"kernelFault2": "Si le problème persiste après le redémarrage, veuillez le signaler via <a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>",
|
||||
"fontSize": "Taille de la police",
|
||||
"fontSizeTip": "La taille de la police par défaut est de 16px, ce paramètre n'affecte que la taille de la police affichée dans l'éditeur.",
|
||||
"font1": "Ce paramètre n'affecte que l'affichage de la famille de polices dans l'éditeur, choisissez <code class='fn__code'>Default</code> pour utiliser la famille de polices du thème.",
|
||||
|
|
|
|||
|
|
@ -389,11 +389,11 @@
|
|||
"previous": "上一個",
|
||||
"next": "下一個",
|
||||
"lockFile0": "無法存取資料",
|
||||
"lockFile1": "資料檔案已被其他程式鎖定。(如果使用了協力廠商同步碟,請檢查同步狀態)",
|
||||
"lockFile2": "如果後續使用仍然頻繁出現該問題,請通過<a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>回饋,謝謝!",
|
||||
"lockFile1": "資料檔案已被其他程式鎖定",
|
||||
"lockFile2": "如果後續使用仍然頻繁出現該問題,請通過<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">這裡反饋</a>",
|
||||
"kernelFault0": "kernel連接中斷...",
|
||||
"kernelFault1": "如果 7 秒後該對話方塊沒有自動消失,請關閉視窗後重新開機。",
|
||||
"kernelFault2": "如果重啟後仍然出現該問題,請通過<a href=\"https://github.com/siyuan-note/siyuan/issues\" target=\"_blank\">GitHub Issues</a>回饋,謝謝!",
|
||||
"kernelFault1": "請檢查網絡連接和內核進程是否正常",
|
||||
"kernelFault2": "如果重啟後仍然出現該問題,請通過<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">這裡反饋</a>",
|
||||
"fontSize": "字型大小",
|
||||
"fontSizeTip": "字型大小預設為 16px,該設置僅影響編輯器內字體大小顯示",
|
||||
"font1": "該設置僅影響編輯器內字體顯示,選擇 <code class='fn__code'>預設</code> 則使用主題自帶字體",
|
||||
|
|
|
|||
|
|
@ -389,11 +389,11 @@
|
|||
"previous": "上一个",
|
||||
"next": "下一个",
|
||||
"lockFile0": "无法存取数据",
|
||||
"lockFile1": "数据文件已被其他程序锁定。(如果使用了第三方同步盘,请检查同步状态)",
|
||||
"lockFile2": "如果后续使用仍然频繁出现该问题,请通过<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">社区</a>进行反馈,谢谢!",
|
||||
"lockFile1": "数据文件已被其他程序锁定",
|
||||
"lockFile2": "如果后续使用仍然频繁出现该问题,请通过<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">这里反馈</a>",
|
||||
"kernelFault0": "内核连接中断...",
|
||||
"kernelFault1": "如果 7 秒后该对话框没有自动消失,请关闭窗口后重新启动。",
|
||||
"kernelFault2": "如果重启后仍然出现该问题,请通过<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">社区</a>进行反馈,谢谢!",
|
||||
"kernelFault1": "请检查网络连接和内核进程是否正常",
|
||||
"kernelFault2": "如果重启后仍然出现该问题,请通过<a href=\"https://ld246.com/article/1649901726096\" target=\"_blank\">这里反馈</a>",
|
||||
"fontSize": "字号",
|
||||
"fontSizeTip": "字号默认为 16px,该设置仅影响编辑器内字体大小显示",
|
||||
"font1": "该设置仅影响编辑器内字体显示,选择 <code class='fn__code'>默认</code> 则使用主题自带字体",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {hideMessage, showMessage} from "../../dialog/message";
|
||||
import {Constants} from "../../constants";
|
||||
/// #if !BROWSER
|
||||
import {OpenDialogReturnValue, ipcRenderer} from "electron";
|
||||
import {ipcRenderer, OpenDialogReturnValue} from "electron";
|
||||
import {BrowserWindow, dialog} from "@electron/remote";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
|
@ -63,9 +63,7 @@ export const saveExport = (option: { type: string, id: string }) => {
|
|||
|
||||
/// #if !BROWSER
|
||||
const destroyWin = (win: Electron.BrowserWindow) => {
|
||||
setTimeout(() => {
|
||||
win.destroy();
|
||||
}, 1000);
|
||||
win.destroy();
|
||||
};
|
||||
|
||||
const renderPDF = (id: string) => {
|
||||
|
|
@ -99,7 +97,12 @@ const renderPDF = (id: string) => {
|
|||
title: window.siyuan.languages.export + " PDF",
|
||||
properties: ["createDirectory", "openDirectory"],
|
||||
}).then((result: OpenDialogReturnValue) => {
|
||||
if (!result.canceled) {
|
||||
if (result.canceled) {
|
||||
destroyWin(win);
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||
const filePath = result.filePaths[0].endsWith(ipcData.rootTitle) ? result.filePaths[0] : path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle));
|
||||
localStorage.setItem(Constants.LOCAL_EXPORTPDF, JSON.stringify(Object.assign(ipcData.pdfOptions, {removeAssets: ipcData.removeAssets})));
|
||||
|
|
@ -113,6 +116,7 @@ const renderPDF = (id: string) => {
|
|||
}, () => {
|
||||
const pdfFilePath = path.join(filePath, path.basename(filePath) + ".pdf");
|
||||
fs.writeFileSync(pdfFilePath, pdfData);
|
||||
destroyWin(win);
|
||||
fetchPost("/api/export/addPDFOutline", {
|
||||
id: ipcData.rootId,
|
||||
path: pdfFilePath
|
||||
|
|
@ -142,18 +146,15 @@ const renderPDF = (id: string) => {
|
|||
}
|
||||
});
|
||||
});
|
||||
destroyWin(win);
|
||||
}).catch((error: string) => {
|
||||
showMessage("Export PDF error:" + error, 0, "error", msgId);
|
||||
destroyWin(win);
|
||||
});
|
||||
} catch (e) {
|
||||
showMessage("Export PDF error:" + e + ". Export HTML and use Chrome's printing function to convert to PDF", 0, "error", msgId);
|
||||
showMessage("Export PDF failed: " + e, 0, "error", msgId);
|
||||
destroyWin(win);
|
||||
}
|
||||
} else {
|
||||
destroyWin(win);
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
});
|
||||
fetchPost("/api/export/exportPreviewHTML", {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export const fetchPost = (url: string, data?: any, cb?: (response: IWebSocketDat
|
|||
}
|
||||
}).catch((e) => {
|
||||
console.warn("fetch post error", e);
|
||||
if (url === "/api/transactions" && e.message === "Failed to fetch") {
|
||||
if (url === "/api/transactions" && (e.message === "Failed to fetch" || e.message === "Unexpected end of JSON input")) {
|
||||
kernelError();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,9 @@ func SearchAssetsByName(keyword string) (ret []*cache.Asset) {
|
|||
|
||||
func GetAssetAbsPath(relativePath string) (absPath string, err error) {
|
||||
relativePath = strings.TrimSpace(relativePath)
|
||||
if strings.Contains(relativePath, "?") {
|
||||
relativePath = relativePath[:strings.Index(relativePath, "?")]
|
||||
}
|
||||
notebooks, err := ListNotebooks()
|
||||
if nil != err {
|
||||
err = errors.New(Conf.Language(0))
|
||||
|
|
|
|||
|
|
@ -1083,6 +1083,11 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.T
|
|||
if n.IsTextMarkType("inline-math") {
|
||||
n.TextMarkInlineMathContent = strings.TrimSpace(n.TextMarkInlineMathContent)
|
||||
return ast.WalkContinue
|
||||
} else if n.IsTextMarkType("file-annotation-ref") {
|
||||
refID := n.TextMarkFileAnnotationRefID
|
||||
status := processFileAnnotationRef(refID, n)
|
||||
unlinks = append(unlinks, n)
|
||||
return status
|
||||
}
|
||||
case ast.NodeFileAnnotationRef:
|
||||
refIDNode := n.ChildByType(ast.NodeFileAnnotationRefID)
|
||||
|
|
@ -1090,53 +1095,9 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.T
|
|||
return ast.WalkSkipChildren
|
||||
}
|
||||
refID := refIDNode.TokensStr()
|
||||
p := refID[:strings.LastIndex(refID, "/")]
|
||||
absPath, err := GetAssetAbsPath(p)
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path by rel path [%s] failed: %s", p, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
sya := absPath + ".sya"
|
||||
syaData, err := os.ReadFile(sya)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read file [%s] failed: %s", sya, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
syaJSON := map[string]interface{}{}
|
||||
if err = gulu.JSON.UnmarshalJSON(syaData, &syaJSON); nil != err {
|
||||
logging.LogErrorf("unmarshal file [%s] failed: %s", sya, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
annotationID := refID[strings.LastIndex(refID, "/")+1:]
|
||||
annotationData := syaJSON[annotationID]
|
||||
if nil == annotationData {
|
||||
logging.LogErrorf("not found annotation [%s] in .sya", annotationID)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
pages := annotationData.(map[string]interface{})["pages"].([]interface{})
|
||||
page := int(pages[0].(map[string]interface{})["index"].(float64)) + 1
|
||||
pageStr := strconv.Itoa(page)
|
||||
refTextNode := n.ChildByType(ast.NodeFileAnnotationRefText)
|
||||
if nil == refTextNode {
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
refText := refTextNode.TokensStr()
|
||||
ext := filepath.Ext(p)
|
||||
file := p[7:len(p)-23-len(ext)] + ext
|
||||
fileAnnotationRefLink := &ast.Node{Type: ast.NodeLink}
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
|
||||
if 0 == Conf.Export.FileAnnotationRefMode {
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(file + " - p" + pageStr + " - " + refText)})
|
||||
} else {
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(refText)})
|
||||
}
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeOpenParen})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: []byte(p + "?p=" + pageStr)})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
|
||||
n.InsertBefore(fileAnnotationRefLink)
|
||||
status := processFileAnnotationRef(refID, n)
|
||||
unlinks = append(unlinks, n)
|
||||
return ast.WalkSkipChildren
|
||||
return status
|
||||
}
|
||||
|
||||
if !treenode.IsBlockRef(n) {
|
||||
|
|
@ -1498,3 +1459,58 @@ func exportRefTrees0(tree *parse.Tree, retTrees *map[string]*parse.Tree) {
|
|||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
|
||||
func processFileAnnotationRef(refID string, n *ast.Node) ast.WalkStatus {
|
||||
p := refID[:strings.LastIndex(refID, "/")]
|
||||
absPath, err := GetAssetAbsPath(p)
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path by rel path [%s] failed: %s", p, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
sya := absPath + ".sya"
|
||||
syaData, err := os.ReadFile(sya)
|
||||
if nil != err {
|
||||
logging.LogErrorf("read file [%s] failed: %s", sya, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
syaJSON := map[string]interface{}{}
|
||||
if err = gulu.JSON.UnmarshalJSON(syaData, &syaJSON); nil != err {
|
||||
logging.LogErrorf("unmarshal file [%s] failed: %s", sya, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
annotationID := refID[strings.LastIndex(refID, "/")+1:]
|
||||
annotationData := syaJSON[annotationID]
|
||||
if nil == annotationData {
|
||||
logging.LogErrorf("not found annotation [%s] in .sya", annotationID)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
pages := annotationData.(map[string]interface{})["pages"].([]interface{})
|
||||
page := int(pages[0].(map[string]interface{})["index"].(float64)) + 1
|
||||
pageStr := strconv.Itoa(page)
|
||||
|
||||
var refText string
|
||||
if ast.NodeTextMark == n.Type {
|
||||
refText = n.TextMarkTextContent
|
||||
} else {
|
||||
refTextNode := n.ChildByType(ast.NodeFileAnnotationRefText)
|
||||
if nil == refTextNode {
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
refText = refTextNode.TokensStr()
|
||||
}
|
||||
ext := filepath.Ext(p)
|
||||
file := p[7:len(p)-23-len(ext)] + ext
|
||||
fileAnnotationRefLink := &ast.Node{Type: ast.NodeLink}
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
|
||||
if 0 == Conf.Export.FileAnnotationRefMode {
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(file + " - p" + pageStr + " - " + refText)})
|
||||
} else {
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(refText)})
|
||||
}
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeOpenParen})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeLinkDest, Tokens: []byte(p + "?p=" + pageStr)})
|
||||
fileAnnotationRefLink.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
|
||||
n.InsertBefore(fileAnnotationRefLink)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue