🎨 数据历史文档支持只读可视化预览 https://github.com/siyuan-note/siyuan/issues/5735

This commit is contained in:
Liang Ding 2022-08-31 11:41:38 +08:00
parent 06cacf1311
commit 379e27aefe
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 52 additions and 47 deletions

View file

@ -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)",
"34": "This operation is not supported in read-only mode",
"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",
"38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
"39": "Deleting index %s",

View file

@ -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)",
"34": "Esta operación no es compatible con el modo de sólo lectura",
"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",
"38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
"39": "Eliminando índice %s",

View file

@ -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) ",
"34": "Cette opération n'est pas supportée en mode lecture seule.",
"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",
"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",

View file

@ -810,7 +810,7 @@
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
"34": "唯讀模式下不支援該操作",
"35": "正在重建索引,請稍等...",
"36": "TODO",
"36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示",
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
"39": "正在刪除索引 %s",

View file

@ -811,7 +811,7 @@
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
"34": "只读模式下不支持该操作",
"35": "正在重建索引,请稍等...",
"36": "TODO",
"36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示",
"37": "云端同步目录的名称请勿包含空格和特殊符号",
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
"39": "正在删除索引 %s",

View file

@ -161,62 +161,67 @@ func GetDocHistoryContent(historyPath, keyword string) (content string, isLargeD
return
}
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
keywords := search.SplitKeyword(keyword)
if !isLargeDoc {
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
keyword = strings.Join(strings.Split(keyword, " "), search.TermSep)
keywords := search.SplitKeyword(keyword)
var unlinks []*ast.Node
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
var unlinks []*ast.Node
ast.Walk(historyTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
if ast.NodeBlockRef == n.Type {
appendRefTextRenderResultForBlockRef(n)
return ast.WalkSkipChildren
}
if ast.NodeBlockRef == n.Type {
appendRefTextRenderResultForBlockRef(n)
return ast.WalkSkipChildren
}
if ast.NodeText == n.Type {
if 0 < len(keywords) {
// 搜索高亮
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
n.Tokens = gulu.Str.ToBytes(text)
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\">"))
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
var children []*ast.Node
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
children = append(children, c)
if ast.NodeText == n.Type {
if 0 < len(keywords) {
// 搜索高亮
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, "<span data-type=\"search-mark\">", "</span>", false)
n.Tokens = gulu.Str.ToBytes(text)
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\">"))
linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
var children []*ast.Node
for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
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 {
unlink.Unlink()
}
var appends []*ast.Node
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
for n := historyTree.Root.FirstChild; nil != n; n = n.Next {
appends = append(appends, n)
}
for _, n := range appends {
renderTree.Root.AppendChild(n)
historyTree = renderTree
}
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())
} else {
content = luteEngine.Tree2BlockDOM(renderTree, luteEngine.RenderOptions)
content = luteEngine.Tree2BlockDOM(historyTree, luteEngine.RenderOptions)
}
return
}