mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 数据历史文档支持只读可视化预览 https://github.com/siyuan-note/siyuan/issues/5735
This commit is contained in:
parent
06cacf1311
commit
379e27aefe
6 changed files with 52 additions and 47 deletions
|
|
@ -810,7 +810,7 @@
|
||||||
"33": "Insufficient permissions to read and write files or access to the network, please check the permissions of the workspace folder and the settings of the anti-virus software/firewall. If you have run SiYuan as an administrator before, please consider switching to a new workspace directory, and do not run it as an administrator in the future (the current workspace directory may no longer be accessible by ordinary users)",
|
"33": "Insufficient permissions to read and write files or access to the network, please check the permissions of the workspace folder and the settings of the anti-virus software/firewall. If you have run SiYuan as an administrator before, please consider switching to a new workspace directory, and do not run it as an administrator in the future (the current workspace directory may no longer be accessible by ordinary users)",
|
||||||
"34": "This operation is not supported in read-only mode",
|
"34": "This operation is not supported in read-only mode",
|
||||||
"35": "Rebuilding index, please wait...",
|
"35": "Rebuilding index, please wait...",
|
||||||
"36": "TODO",
|
"36": "There is too much content in the historical document, in order not to affect performance, it has been switched to plain text display",
|
||||||
"37": "Do not include spaces and special symbols in the name of the cloud sync directory",
|
"37": "Do not include spaces and special symbols in the name of the cloud sync directory",
|
||||||
"38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
|
"38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
|
||||||
"39": "Deleting index %s",
|
"39": "Deleting index %s",
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@
|
||||||
"33": "Permisos insuficientes para leer y escribir archivos o acceso a la red, por favor comprueba los permisos de la carpeta del espacio de trabajo y la configuración del software antivirus/firewall. Si has ejecutado SiYuan como administrador antes, por favor considera cambiar a un nuevo directorio de espacio de trabajo, y no lo ejecutes como administrador en el futuro (el directorio de espacio de trabajo actual puede que ya no sea accesible por los usuarios ordinarios)",
|
"33": "Permisos insuficientes para leer y escribir archivos o acceso a la red, por favor comprueba los permisos de la carpeta del espacio de trabajo y la configuración del software antivirus/firewall. Si has ejecutado SiYuan como administrador antes, por favor considera cambiar a un nuevo directorio de espacio de trabajo, y no lo ejecutes como administrador en el futuro (el directorio de espacio de trabajo actual puede que ya no sea accesible por los usuarios ordinarios)",
|
||||||
"34": "Esta operación no es compatible con el modo de sólo lectura",
|
"34": "Esta operación no es compatible con el modo de sólo lectura",
|
||||||
"35": "Reconstruyendo el índice, por favor espere...",
|
"35": "Reconstruyendo el índice, por favor espere...",
|
||||||
"36": "TODO",
|
"36": "Hay demasiado contenido en el documento historico, para no afectar el rendimiento, se ha cambiado a visualizacion de texto sin formato",
|
||||||
"37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube",
|
"37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube",
|
||||||
"38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
|
"38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
|
||||||
"39": "Eliminando índice %s",
|
"39": "Eliminando índice %s",
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@
|
||||||
"33": "Autorisations insuffisantes pour lire et écrire des fichiers ou accéder au réseau, veuillez vérifier les autorisations du dossier de l'espace de travail et les paramètres du logiciel anti-virus/pare-feu. Si vous avez déjà exécuté SiYuan en tant qu'administrateur, envisagez de passer à un nouveau répertoire d'espace de travail et ne l'exécutez plus en tant qu'administrateur à l'avenir (le répertoire d'espace de travail actuel peut ne plus être accessible aux utilisateurs ordinaires) ",
|
"33": "Autorisations insuffisantes pour lire et écrire des fichiers ou accéder au réseau, veuillez vérifier les autorisations du dossier de l'espace de travail et les paramètres du logiciel anti-virus/pare-feu. Si vous avez déjà exécuté SiYuan en tant qu'administrateur, envisagez de passer à un nouveau répertoire d'espace de travail et ne l'exécutez plus en tant qu'administrateur à l'avenir (le répertoire d'espace de travail actuel peut ne plus être accessible aux utilisateurs ordinaires) ",
|
||||||
"34": "Cette opération n'est pas supportée en mode lecture seule.",
|
"34": "Cette opération n'est pas supportée en mode lecture seule.",
|
||||||
"35": "Recréation de l'index, veuillez patienter...",
|
"35": "Recréation de l'index, veuillez patienter...",
|
||||||
"36": "TODO",
|
"36": "Il y a trop de contenu dans le document historique, afin de ne pas affecter les performances, il a été basculé sur l'affichage en texte brut",
|
||||||
"37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud",
|
"37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud",
|
||||||
"38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés",
|
"38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés",
|
||||||
"39": "Suppression de l'index %s",
|
"39": "Suppression de l'index %s",
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@
|
||||||
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
|
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
|
||||||
"34": "唯讀模式下不支援該操作",
|
"34": "唯讀模式下不支援該操作",
|
||||||
"35": "正在重建索引,請稍等...",
|
"35": "正在重建索引,請稍等...",
|
||||||
"36": "TODO",
|
"36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示",
|
||||||
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
|
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
|
||||||
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
|
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
|
||||||
"39": "正在刪除索引 %s",
|
"39": "正在刪除索引 %s",
|
||||||
|
|
|
||||||
|
|
@ -811,7 +811,7 @@
|
||||||
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
|
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
|
||||||
"34": "只读模式下不支持该操作",
|
"34": "只读模式下不支持该操作",
|
||||||
"35": "正在重建索引,请稍等...",
|
"35": "正在重建索引,请稍等...",
|
||||||
"36": "TODO",
|
"36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示",
|
||||||
"37": "云端同步目录的名称请勿包含空格和特殊符号",
|
"37": "云端同步目录的名称请勿包含空格和特殊符号",
|
||||||
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
|
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
|
||||||
"39": "正在删除索引 %s",
|
"39": "正在删除索引 %s",
|
||||||
|
|
|
||||||
|
|
@ -161,62 +161,67 @@ func GetDocHistoryContent(historyPath, keyword string) (content string, isLargeD
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
if !isLargeDoc {
|
||||||
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
|
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
||||||
keywords := search.SplitKeyword(keyword)
|
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
|
||||||
|
keywords := search.SplitKeyword(keyword)
|
||||||
|
|
||||||
var unlinks []*ast.Node
|
var unlinks []*ast.Node
|
||||||
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if !entering {
|
if !entering {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ast.NodeBlockRef == n.Type {
|
if ast.NodeBlockRef == n.Type {
|
||||||
appendRefTextRenderResultForBlockRef(n)
|
appendRefTextRenderResultForBlockRef(n)
|
||||||
return ast.WalkSkipChildren
|
return ast.WalkSkipChildren
|
||||||
}
|
}
|
||||||
|
|
||||||
if ast.NodeText == n.Type {
|
if ast.NodeText == n.Type {
|
||||||
if 0 < len(keywords) {
|
if 0 < len(keywords) {
|
||||||
// 搜索高亮
|
// 搜索高亮
|
||||||
text := string(n.Tokens)
|
text := string(n.Tokens)
|
||||||
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
|
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
|
||||||
n.Tokens = gulu.Str.ToBytes(text)
|
n.Tokens = gulu.Str.ToBytes(text)
|
||||||
if bytes.Contains(n.Tokens, []byte("search-mark")) {
|
if bytes.Contains(n.Tokens, []byte("search-mark")) {
|
||||||
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\<span data-type=\"search-mark\">"), []byte("\\\\<span data-type=\"search-mark\">"))
|
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\<span data-type=\"search-mark\">"), []byte("\\\\<span data-type=\"search-mark\">"))
|
||||||
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
|
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
|
||||||
var children []*ast.Node
|
var children []*ast.Node
|
||||||
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
|
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
|
||||||
children = append(children, c)
|
children = append(children, c)
|
||||||
|
}
|
||||||
|
for _, c := range children {
|
||||||
|
n.InsertBefore(c)
|
||||||
|
}
|
||||||
|
unlinks = append(unlinks, n)
|
||||||
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
for _, c := range children {
|
|
||||||
n.InsertBefore(c)
|
|
||||||
}
|
|
||||||
unlinks = append(unlinks, n)
|
|
||||||
return ast.WalkContinue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ast.WalkContinue
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, unlink := range unlinks {
|
||||||
|
unlink.Unlink()
|
||||||
}
|
}
|
||||||
return ast.WalkContinue
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, unlink := range unlinks {
|
var appends []*ast.Node
|
||||||
unlink.Unlink()
|
for n := historyTree.Root.FirstChild; nil != n; n = n.Next {
|
||||||
}
|
appends = append(appends, n)
|
||||||
|
}
|
||||||
|
for _, n := range appends {
|
||||||
|
renderTree.Root.AppendChild(n)
|
||||||
|
}
|
||||||
|
|
||||||
var appends []*ast.Node
|
historyTree = renderTree
|
||||||
for n := historyTree.Root.FirstChild; nil != n; n = n.Next {
|
|
||||||
appends = append(appends, n)
|
|
||||||
}
|
|
||||||
for _, n := range appends {
|
|
||||||
renderTree.Root.AppendChild(n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if isLargeDoc {
|
if isLargeDoc {
|
||||||
formatRenderer := render.NewFormatRenderer(renderTree, luteEngine.RenderOptions)
|
util.PushMsg(Conf.Language(36), 3000)
|
||||||
|
formatRenderer := render.NewFormatRenderer(historyTree, luteEngine.RenderOptions)
|
||||||
content = gulu.Str.FromBytes(formatRenderer.Render())
|
content = gulu.Str.FromBytes(formatRenderer.Render())
|
||||||
} else {
|
} else {
|
||||||
content = luteEngine.Tree2BlockDOM(renderTree, luteEngine.RenderOptions)
|
content = luteEngine.Tree2BlockDOM(historyTree, luteEngine.RenderOptions)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue