mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Add statistics on selected blocks and total blocks https://github.com/siyuan-note/siyuan/issues/13235
This commit is contained in:
parent
adb942b4d5
commit
14bb85017f
15 changed files with 33 additions and 7 deletions
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Links",
|
"linkCount": "Links",
|
||||||
"imgCount": "Bilder",
|
"imgCount": "Bilder",
|
||||||
"refCount": "Referenzen",
|
"refCount": "Referenzen",
|
||||||
|
"blockCount": "Blöcke",
|
||||||
"kbd": "Tastatur",
|
"kbd": "Tastatur",
|
||||||
"errorStyle": "Fehlerstil",
|
"errorStyle": "Fehlerstil",
|
||||||
"successStyle": "Erfolg-Stil",
|
"successStyle": "Erfolg-Stil",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Links",
|
"linkCount": "Links",
|
||||||
"imgCount": "Images",
|
"imgCount": "Images",
|
||||||
"refCount": "Refs",
|
"refCount": "Refs",
|
||||||
|
"blockCount": "Blocks",
|
||||||
"kbd": "Keyboard",
|
"kbd": "Keyboard",
|
||||||
"errorStyle": "Error Style",
|
"errorStyle": "Error Style",
|
||||||
"successStyle": "Success Style",
|
"successStyle": "Success Style",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Enlaces",
|
"linkCount": "Enlaces",
|
||||||
"imgCount": "Imágenes",
|
"imgCount": "Imágenes",
|
||||||
"refCount": "Referencias",
|
"refCount": "Referencias",
|
||||||
|
"blockCount": "Bloques",
|
||||||
"kbd": "Teclado",
|
"kbd": "Teclado",
|
||||||
"errorStyle": "Estilo de error",
|
"errorStyle": "Estilo de error",
|
||||||
"successStyle": "Estilo de éxito",
|
"successStyle": "Estilo de éxito",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Liens",
|
"linkCount": "Liens",
|
||||||
"imgCount": "Images",
|
"imgCount": "Images",
|
||||||
"refCount": "Réfs",
|
"refCount": "Réfs",
|
||||||
|
"blockCount": "Blocs",
|
||||||
"kbd": "Clavier",
|
"kbd": "Clavier",
|
||||||
"errorStyle": "Style d'Erreur",
|
"errorStyle": "Style d'Erreur",
|
||||||
"successStyle": "Style de Réussite",
|
"successStyle": "Style de Réussite",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "קישורים",
|
"linkCount": "קישורים",
|
||||||
"imgCount": "תמונות",
|
"imgCount": "תמונות",
|
||||||
"refCount": "יחוסים",
|
"refCount": "יחוסים",
|
||||||
|
"blockCount": "בלוקים",
|
||||||
"kbd": "מקלדת",
|
"kbd": "מקלדת",
|
||||||
"errorStyle": "סגנון שגיאה",
|
"errorStyle": "סגנון שגיאה",
|
||||||
"successStyle": "סגנון הצלחה",
|
"successStyle": "סגנון הצלחה",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Link",
|
"linkCount": "Link",
|
||||||
"imgCount": "Immagini",
|
"imgCount": "Immagini",
|
||||||
"refCount": "Riferimenti",
|
"refCount": "Riferimenti",
|
||||||
|
"blockCount": "Blocchi",
|
||||||
"kbd": "Tastiera",
|
"kbd": "Tastiera",
|
||||||
"errorStyle": "Stile Errore",
|
"errorStyle": "Stile Errore",
|
||||||
"successStyle": "Stile Successo",
|
"successStyle": "Stile Successo",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "リンク数",
|
"linkCount": "リンク数",
|
||||||
"imgCount": "画像数",
|
"imgCount": "画像数",
|
||||||
"refCount": "参照数",
|
"refCount": "参照数",
|
||||||
|
"blockCount": "ブロック",
|
||||||
"kbd": "キーボード",
|
"kbd": "キーボード",
|
||||||
"errorStyle": "エラースタイル",
|
"errorStyle": "エラースタイル",
|
||||||
"successStyle": "成功スタイル",
|
"successStyle": "成功スタイル",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Linki",
|
"linkCount": "Linki",
|
||||||
"imgCount": "Obrazy",
|
"imgCount": "Obrazy",
|
||||||
"refCount": "Refs",
|
"refCount": "Refs",
|
||||||
|
"blockCount": "bloki",
|
||||||
"kbd": "Klawiatura",
|
"kbd": "Klawiatura",
|
||||||
"errorStyle": "Styl błędu",
|
"errorStyle": "Styl błędu",
|
||||||
"successStyle": "Styl sukcesu",
|
"successStyle": "Styl sukcesu",
|
||||||
|
|
|
||||||
|
|
@ -805,6 +805,7 @@
|
||||||
"linkCount": "Ссылки",
|
"linkCount": "Ссылки",
|
||||||
"imgCount": "Изображения",
|
"imgCount": "Изображения",
|
||||||
"refCount": "Ссылки",
|
"refCount": "Ссылки",
|
||||||
|
"blockCount": "блоки",
|
||||||
"kbd": "Клавиатура",
|
"kbd": "Клавиатура",
|
||||||
"errorStyle": "Стиль ошибки",
|
"errorStyle": "Стиль ошибки",
|
||||||
"successStyle": "Стиль успеха",
|
"successStyle": "Стиль успеха",
|
||||||
|
|
|
||||||
|
|
@ -800,11 +800,12 @@
|
||||||
"vLayout": "垂直佈局",
|
"vLayout": "垂直佈局",
|
||||||
"hLayout": "水平佈局",
|
"hLayout": "水平佈局",
|
||||||
"merge": "合併",
|
"merge": "合併",
|
||||||
"wordCount": "字數",
|
"wordCount": "字",
|
||||||
"runeCount": "字符數",
|
"runeCount": "字符",
|
||||||
"linkCount": "連結",
|
"linkCount": "連結",
|
||||||
"imgCount": "圖片",
|
"imgCount": "圖片",
|
||||||
"refCount": "引用",
|
"refCount": "引用",
|
||||||
|
"blockCount": "塊",
|
||||||
"kbd": "鍵盤",
|
"kbd": "鍵盤",
|
||||||
"errorStyle": "錯誤樣式",
|
"errorStyle": "錯誤樣式",
|
||||||
"successStyle": "成功樣式",
|
"successStyle": "成功樣式",
|
||||||
|
|
|
||||||
|
|
@ -800,11 +800,12 @@
|
||||||
"vLayout": "垂直布局",
|
"vLayout": "垂直布局",
|
||||||
"hLayout": "水平布局",
|
"hLayout": "水平布局",
|
||||||
"merge": "合并",
|
"merge": "合并",
|
||||||
"wordCount": "字数",
|
"wordCount": "字",
|
||||||
"runeCount": "字符数",
|
"runeCount": "字符",
|
||||||
"linkCount": "链接",
|
"linkCount": "链接",
|
||||||
"imgCount": "图片",
|
"imgCount": "图片",
|
||||||
"refCount": "引用",
|
"refCount": "引用",
|
||||||
|
"blockCount": "块",
|
||||||
"kbd": "键盘",
|
"kbd": "键盘",
|
||||||
"errorStyle": "错误样式",
|
"errorStyle": "错误样式",
|
||||||
"successStyle": "成功样式",
|
"successStyle": "成功样式",
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,8 @@ export const renderStatusbarCounter = (stat: {
|
||||||
wordCount: number,
|
wordCount: number,
|
||||||
linkCount: number,
|
linkCount: number,
|
||||||
imageCount: number,
|
imageCount: number,
|
||||||
refCount: number
|
refCount: number,
|
||||||
|
blockCount: number,
|
||||||
}) => {
|
}) => {
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -209,6 +210,8 @@ export const renderStatusbarCounter = (stat: {
|
||||||
}
|
}
|
||||||
if (0 < stat.refCount) {
|
if (0 < stat.refCount) {
|
||||||
html += `<span class="ft__on-surface">${window.siyuan.languages.refCount}</span> ${stat.refCount}<span class="fn__space"></span>`;
|
html += `<span class="ft__on-surface">${window.siyuan.languages.refCount}</span> ${stat.refCount}<span class="fn__space"></span>`;
|
||||||
|
}if (0 < stat.blockCount) {
|
||||||
|
html += `<span class="ft__on-surface">${window.siyuan.languages.blockCount}</span> ${stat.blockCount}<span class="fn__space"></span>`;
|
||||||
}
|
}
|
||||||
document.querySelector("#status .status__counter").innerHTML = html;
|
document.querySelector("#status .status__counter").innerHTML = html;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -576,7 +576,7 @@ ${padHTML}
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
type: "readonly",
|
type: "readonly",
|
||||||
// 不能换行,否则移动端间距过大
|
// 不能换行,否则移动端间距过大
|
||||||
label: `<div class="fn__flex">${window.siyuan.languages.runeCount}<span class="fn__space fn__flex-1"></span>${response.data.runeCount}</div><div class="fn__flex">${window.siyuan.languages.wordCount}<span class="fn__space fn__flex-1"></span>${response.data.wordCount}</div><div class="fn__flex">${window.siyuan.languages.linkCount}<span class="fn__space fn__flex-1"></span>${response.data.linkCount}</div><div class="fn__flex">${window.siyuan.languages.imgCount}<span class="fn__space fn__flex-1"></span>${response.data.imageCount}</div><div class="fn__flex">${window.siyuan.languages.refCount}<span class="fn__space fn__flex-1"></span>${response.data.refCount}</div>`,
|
label: `<div class="fn__flex">${window.siyuan.languages.runeCount}<span class="fn__space fn__flex-1"></span>${response.data.runeCount}</div><div class="fn__flex">${window.siyuan.languages.wordCount}<span class="fn__space fn__flex-1"></span>${response.data.wordCount}</div><div class="fn__flex">${window.siyuan.languages.linkCount}<span class="fn__space fn__flex-1"></span>${response.data.linkCount}</div><div class="fn__flex">${window.siyuan.languages.imgCount}<span class="fn__space fn__flex-1"></span>${response.data.imageCount}</div><div class="fn__flex">${window.siyuan.languages.refCount}<span class="fn__space fn__flex-1"></span>${response.data.refCount}</div><div class="fn__flex">${window.siyuan.languages.blockCount}<span class="fn__space fn__flex-1"></span>${response.data.blockCount}</div>`,
|
||||||
}).element);
|
}).element);
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
window.siyuan.menus.menu.fullscreen();
|
window.siyuan.menus.menu.fullscreen();
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,7 @@ func BlocksWordCount(ids []string) (ret *util.BlockStatResult) {
|
||||||
ret.ImageCount += imgCnt
|
ret.ImageCount += imgCnt
|
||||||
ret.RefCount += refCnt
|
ret.RefCount += refCnt
|
||||||
}
|
}
|
||||||
|
ret.BlockCount = len(ids)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -491,9 +492,18 @@ func StatTree(id string) (ret *util.BlockStatResult) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockCount := 0
|
||||||
var databaseBlockNodes []*ast.Node
|
var databaseBlockNodes []*ast.Node
|
||||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if !entering || ast.NodeAttributeView != n.Type {
|
if !entering {
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.IsBlock() {
|
||||||
|
blockCount++
|
||||||
|
}
|
||||||
|
|
||||||
|
if ast.NodeAttributeView != n.Type {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -585,6 +595,7 @@ func StatTree(id string) (ret *util.BlockStatResult) {
|
||||||
LinkCount: linkCnt,
|
LinkCount: linkCnt,
|
||||||
ImageCount: imgCnt,
|
ImageCount: imgCnt,
|
||||||
RefCount: refCnt,
|
RefCount: refCnt,
|
||||||
|
BlockCount: blockCount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,7 @@ type BlockStatResult struct {
|
||||||
LinkCount int `json:"linkCount"`
|
LinkCount int `json:"linkCount"`
|
||||||
ImageCount int `json:"imageCount"`
|
ImageCount int `json:"imageCount"`
|
||||||
RefCount int `json:"refCount"`
|
RefCount int `json:"refCount"`
|
||||||
|
BlockCount int `json:"blockCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContextPushMsg(context map[string]interface{}, msg string) {
|
func ContextPushMsg(context map[string]interface{}, msg string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue