mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-28 18:00:15 +01:00
This commit is contained in:
parent
9b0fe3613c
commit
72a671ab78
2 changed files with 12 additions and 3 deletions
|
|
@ -129,6 +129,7 @@ export const initStatus = () => {
|
|||
/// #endif
|
||||
};
|
||||
|
||||
let countRootId: string
|
||||
export const countSelectWord = (range: Range, rootID?: string) => {
|
||||
/// #if !MOBILE
|
||||
if (document.getElementById("status").classList.contains("fn__none")) {
|
||||
|
|
@ -139,7 +140,9 @@ export const countSelectWord = (range: Range, rootID?: string) => {
|
|||
fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => {
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
} else if (rootID) {
|
||||
countRootId = ""
|
||||
} else if (rootID && rootID !== countRootId) {
|
||||
countRootId = rootID;
|
||||
fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => {
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
|
|
@ -156,7 +159,9 @@ export const countBlockWord = (ids: string[], rootID?: string) => {
|
|||
fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => {
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
} else if (rootID) {
|
||||
countRootId = ""
|
||||
} else if (rootID && rootID !== countRootId) {
|
||||
countRootId = rootID
|
||||
fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => {
|
||||
renderStatusbarCounter(response.data);
|
||||
});
|
||||
|
|
@ -165,6 +170,7 @@ export const countBlockWord = (ids: string[], rootID?: string) => {
|
|||
};
|
||||
|
||||
export const clearCounter = () => {
|
||||
countRootId = ""
|
||||
document.querySelector("#status .status__counter").innerHTML = "";
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1381,6 +1381,9 @@ export class WYSIWYG {
|
|||
const nodeElement = hasClosestBlock(range.startContainer);
|
||||
if (nodeElement) {
|
||||
this.setEmptyOutline(protyle, nodeElement);
|
||||
if (range.toString() === "") {
|
||||
countSelectWord(range, protyle.block.rootID);
|
||||
}
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
|
@ -1807,7 +1810,7 @@ export class WYSIWYG {
|
|||
hideElements(["toolbar"], protyle);
|
||||
}
|
||||
if (!protyle.wysiwyg.element.querySelector(".protyle-wysiwyg--select")) {
|
||||
countSelectWord(newRange);
|
||||
countSelectWord(newRange, protyle.block.rootID);
|
||||
}
|
||||
if (getSelection().rangeCount === 0) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/5901
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue