mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 11:50:15 +01:00
🎨 文档信息统计增加超链接数、图片数、引用数和大小 https://github.com/siyuan-note/siyuan/issues/6037
This commit is contained in:
parent
a772b47287
commit
5e09d72fab
16 changed files with 86 additions and 86 deletions
|
|
@ -189,7 +189,7 @@ export const progressStatus = (data: IWebSocketData) => {
|
|||
};
|
||||
|
||||
export const handleStatusbarCounter = (data: IWebSocketData) => {
|
||||
renderStatusbarCounter(data.data.runeCount, data.data.wordCount);
|
||||
renderStatusbarCounter(data.data);
|
||||
};
|
||||
|
||||
export const progressLoading = (data: IWebSocketData) => {
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ export const countSelectWord = (range: Range) => {
|
|||
const selectText = range.toString();
|
||||
if (selectText) {
|
||||
fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => {
|
||||
renderStatusbarCounter(response.data.runeCount, response.data.wordCount);
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
} else {
|
||||
document.querySelector("#status .status__counter").innerHTML = "";
|
||||
|
|
@ -152,7 +152,7 @@ export const countBlockWord = (ids: string[]) => {
|
|||
}
|
||||
if (ids.length > 0) {
|
||||
fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => {
|
||||
renderStatusbarCounter(response.data.runeCount, response.data.wordCount);
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
} else {
|
||||
document.querySelector("#status .status__counter").innerHTML = "";
|
||||
|
|
@ -160,10 +160,17 @@ export const countBlockWord = (ids: string[]) => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
export const renderStatusbarCounter = (runeCount: number, wordCount: number) => {
|
||||
document.querySelector("#status .status__counter").innerHTML = `<span class="ft__on-surface">${window.siyuan.languages.runeCount}</span>
|
||||
${runeCount}
|
||||
<span class="fn__space"></span>
|
||||
<span class="ft__on-surface">${window.siyuan.languages.wordCount}</span>
|
||||
${wordCount}<span class="fn__space"></span>`;
|
||||
export const renderStatusbarCounter = (stat: { runeCount: number, wordCount: number, linkCount: number, imageCount: number, refCount: number }) => {
|
||||
let html = `<span class="ft__on-surface">${window.siyuan.languages.runeCount}</span> ${stat.runeCount}<span class="fn__space"></span>
|
||||
<span class="ft__on-surface">${window.siyuan.languages.wordCount}</span> ${stat.wordCount}<span class="fn__space"></span>`
|
||||
if (0 < stat.linkCount) {
|
||||
html += `<span class="ft__on-surface">${window.siyuan.languages.link}</span> ${stat.linkCount}<span class="fn__space"></span>`
|
||||
}
|
||||
if (0 < stat.imageCount) {
|
||||
html += `<span class="ft__on-surface">${window.siyuan.languages.image}</span> ${stat.imageCount}<span class="fn__space"></span>`
|
||||
}
|
||||
if (0 < stat.refCount) {
|
||||
html += `<span class="ft__on-surface">${window.siyuan.languages.ref}</span> ${stat.refCount}<span class="fn__space"></span>`
|
||||
}
|
||||
document.querySelector("#status .status__counter").innerHTML = html;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export class Breadcrumb {
|
|||
if (cursorNodeElement) {
|
||||
id = cursorNodeElement.getAttribute("data-node-id");
|
||||
}
|
||||
fetchPost("/api/block/getBlockWordCount", {id: id || protyle.block.id}, (response) => {
|
||||
fetchPost("/api/block/getTreeStat", {id: id || protyle.block.id}, (response) => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
|
||||
if (!protyle.contentElement.classList.contains("fn__none")) {
|
||||
|
|
@ -327,10 +327,11 @@ export class Breadcrumb {
|
|||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
type: "readonly",
|
||||
label: `<div class="fn__flex">${window.siyuan.languages.docRuneCount}<span class="fn__space fn__flex-1"></span>${response.data.rootBlockRuneCount}</div>
|
||||
<div class="fn__flex">${window.siyuan.languages.docWordCount}<span class="fn__space fn__flex-1"></span>${response.data.rootBlockWordCount}</div>
|
||||
<div class="fn__flex">${window.siyuan.languages.blockRuneCount}<span class="fn__space fn__flex-1"></span>${response.data.blockRuneCount}</div>
|
||||
<div class="fn__flex">${window.siyuan.languages.blockWordCount}<span class="fn__space fn__flex-1"></span>${response.data.blockWordCount}</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.link}<span class="fn__space fn__flex-1"></span>${response.data.linkCount}</div>
|
||||
<div class="fn__flex">${window.siyuan.languages.image}<span class="fn__space fn__flex-1"></span>${response.data.imageCount}</div>
|
||||
<div class="fn__flex">${window.siyuan.languages.ref}<span class="fn__space fn__flex-1"></span>${response.data.refCount}</div>`,
|
||||
}).element);
|
||||
window.siyuan.menus.menu.popup(position);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue