This commit is contained in:
Vanessa 2022-10-08 15:23:56 +08:00
parent 331368ce78
commit 3c8c66fbdd
5 changed files with 12 additions and 13 deletions

View file

@ -129,7 +129,7 @@ export const initStatus = () => {
/// #endif /// #endif
}; };
let countRootId: string let countRootId: string;
export const countSelectWord = (range: Range, rootID?: string) => { export const countSelectWord = (range: Range, rootID?: string) => {
/// #if !MOBILE /// #if !MOBILE
if (document.getElementById("status").classList.contains("fn__none")) { if (document.getElementById("status").classList.contains("fn__none")) {
@ -140,7 +140,7 @@ export const countSelectWord = (range: Range, rootID?: string) => {
fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => { fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => {
renderStatusbarCounter(response.data); renderStatusbarCounter(response.data);
}); });
countRootId = "" countRootId = "";
} else if (rootID && rootID !== countRootId) { } else if (rootID && rootID !== countRootId) {
countRootId = rootID; countRootId = rootID;
fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => { fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => {
@ -156,15 +156,15 @@ export const countBlockWord = (ids: string[], rootID?: string, clearCache = fals
return; return;
} }
if (clearCache) { if (clearCache) {
countRootId = "" countRootId = "";
} }
if (ids.length > 0) { if (ids.length > 0) {
fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => { fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => {
renderStatusbarCounter(response.data); renderStatusbarCounter(response.data);
}); });
countRootId = "" countRootId = "";
} else if (rootID && rootID !== countRootId) { } else if (rootID && rootID !== countRootId) {
countRootId = rootID countRootId = rootID;
fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => { fetchPost("/api/block/getTreeStat", {id: rootID}, (response) => {
renderStatusbarCounter(response.data); renderStatusbarCounter(response.data);
}); });
@ -173,7 +173,7 @@ export const countBlockWord = (ids: string[], rootID?: string, clearCache = fals
}; };
export const clearCounter = () => { export const clearCounter = () => {
countRootId = "" countRootId = "";
document.querySelector("#status .status__counter").innerHTML = ""; document.querySelector("#status .status__counter").innerHTML = "";
}; };

View file

@ -78,7 +78,7 @@ export const initKeyboardToolbar = () => {
return; return;
} }
if (type === "down") { if (type === "down") {
moveToDown(protyle, nodeElement, range) moveToDown(protyle, nodeElement, range);
focusByRange(range); focusByRange(range);
return; return;
} }

View file

@ -18,7 +18,7 @@ export const readText = async () => {
return window.JSAndroid.readClipboard(); return window.JSAndroid.readClipboard();
} }
return navigator.clipboard.readText(); return navigator.clipboard.readText();
} };
export const writeText = async (text: string) => { export const writeText = async (text: string) => {
let range: Range; let range: Range;

View file

@ -32,12 +32,12 @@ import {matchHotKey} from "../util/hotKey";
import {enter} from "./enter"; import {enter} from "./enter";
import {fixTable} from "../util/table"; import {fixTable} from "../util/table";
import { import {
transaction, turnsIntoOneTransaction, turnsIntoTransaction, turnsIntoOneTransaction, turnsIntoTransaction,
updateBatchTransaction, updateBatchTransaction,
updateTransaction updateTransaction
} from "./transaction"; } from "./transaction";
import {fontEvent} from "../toolbar/Font"; import {fontEvent} from "../toolbar/Font";
import {listIndent, listOutdent, updateListOrder} from "./list"; import {listIndent, listOutdent} from "./list";
import {newFileBySelect, newFileContentBySelect, rename, replaceFileName} from "../../editor/rename"; import {newFileBySelect, newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";
import {insertEmptyBlock, jumpToParentNext} from "../../block/util"; import {insertEmptyBlock, jumpToParentNext} from "../../block/util";
import {isLocalPath} from "../../util/pathName"; import {isLocalPath} from "../../util/pathName";
@ -49,7 +49,6 @@ import {linkMenu, refMenu, setFold, zoomOut} from "../../menus/protyle";
import {removeEmbed} from "./removeEmbed"; import {removeEmbed} from "./removeEmbed";
import {openAttr} from "../../menus/commonMenuItem"; import {openAttr} from "../../menus/commonMenuItem";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {preventScroll} from "../scroll/preventScroll";
import {bindMenuKeydown} from "../../menus/Menu"; import {bindMenuKeydown} from "../../menus/Menu";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {onGet} from "../util/onGet"; import {onGet} from "../util/onGet";

View file

@ -93,7 +93,7 @@ export const moveToUp = (protyle:IProtyle, nodeElement:HTMLElement, range:Range
} }
preventScroll(protyle); preventScroll(protyle);
scrollCenter(protyle); scrollCenter(protyle);
} };
export const moveToDown = (protyle:IProtyle, nodeElement:HTMLElement, range:Range) => { export const moveToDown = (protyle:IProtyle, nodeElement:HTMLElement, range:Range) => {
let nextElement: Element; let nextElement: Element;
@ -180,4 +180,4 @@ export const moveToDown = (protyle:IProtyle, nodeElement:HTMLElement, range:Ran
} }
preventScroll(protyle); preventScroll(protyle);
scrollCenter(protyle); scrollCenter(protyle);
} };