diff --git a/app/src/layout/status.ts b/app/src/layout/status.ts index abc0b0544..d18a7a360 100644 --- a/app/src/layout/status.ts +++ b/app/src/layout/status.ts @@ -6,6 +6,7 @@ import {fetchPost} from "../util/fetch"; import {mountHelp} from "../util/mount"; /// #if !BROWSER import {getCurrentWindow} from "@electron/remote"; +import {isMobile} from "../util/functions"; /// #endif export const initStatus = () => { @@ -126,23 +127,29 @@ export const initStatus = () => { }; export const countSelectWord = (range: Range) => { + if (isMobile()) { + return; + } const selectText = range.toString(); if (selectText) { fetchPost("/api/block/getContentWordCount", {"content": range.toString()}, (response) => { document.querySelector("#status .status__counter").innerHTML = `${window.siyuan.languages.blockRuneCount} ${response.data.runeCount}${window.siyuan.languages.blockWordCount} ${response.data.wordCount}`; - }) + }); } else { document.querySelector("#status .status__counter").innerHTML = ""; } -} +}; export const countBlockWord = (ids: string[]) => { + if (isMobile()) { + return; + } if (ids.length > 0) { fetchPost("/api/block/getBlocksWordCount", {ids}, (response) => { document.querySelector("#status .status__counter").innerHTML = `${window.siyuan.languages.blockRuneCount} ${response.data.runeCount}${window.siyuan.languages.blockWordCount} ${response.data.wordCount}`; - }) + }); } else { document.querySelector("#status .status__counter").innerHTML = ""; } -} +}; diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index 685e68af9..dd785fbc0 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -414,7 +414,7 @@ export const resizeTabs = () => { setPadding(item.editor.protyle); if (typeof echarts !== "undefined") { item.editor.protyle.wysiwyg.element.querySelectorAll('[data-subtype="echarts"], [data-subtype="mindmap"]').forEach((chartItem: HTMLElement) => { - const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_")) + const chartInstance = echarts.getInstanceById(chartItem.firstElementChild.nextElementSibling.getAttribute("_echarts_instance_")); if (chartInstance) { chartInstance.resize(); } diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index cf805726b..f5e27b1fb 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -109,7 +109,7 @@ class Protyle { this.protyle.model.parent.updateTitle(data.data.title); } if (this.protyle.background) { - this.protyle.background.ial.title = data.data.title + this.protyle.background.ial.title = data.data.title; } } if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) { diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index c45b035d3..342492aca 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -86,9 +86,9 @@ export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range) const ids: string [] = []; Array.from(protyle.wysiwyg.element.children).forEach(item => { item.classList.add("protyle-wysiwyg--select"); - ids.push(item.getAttribute("data-node-id")) + ids.push(item.getAttribute("data-node-id")); }); - countBlockWord(ids) + countBlockWord(ids); }; export const getEditorRange = (element: Element) => { diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index f4af84b12..4780ea9f7 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -204,7 +204,7 @@ export class WYSIWYG { if (selectElements.length === 0 && range.toString() === "" && !range.cloneContents().querySelector("img") && !selectImgElement) { nodeElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([nodeElement.getAttribute("data-node-id")]) + countBlockWord([nodeElement.getAttribute("data-node-id")]); selectElements = [nodeElement]; } let html = ""; @@ -494,7 +494,7 @@ export class WYSIWYG { } }); - let mousewheelTime = 0 + let mousewheelTime = 0; this.element.addEventListener("mousewheel", (event: WheelEvent) => { // https://ld246.com/article/1648865235549 if (event.timeStamp - mousewheelTime > 6000 && @@ -885,14 +885,14 @@ export class WYSIWYG { // 只有一个 p 时不选中 protyle.selectElement.style.backgroundColor = "transparent"; } else { - const ids: string[] = [] + const ids: string[] = []; selectElements.forEach(item => { if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) { item.classList.add("protyle-wysiwyg--select"); - ids.push(item.getAttribute("data-node-id")) + ids.push(item.getAttribute("data-node-id")); } }); - countBlockWord(ids) + countBlockWord(ids); protyle.selectElement.style.backgroundColor = ""; } }; @@ -1280,7 +1280,7 @@ export class WYSIWYG { if (nodeElement) { if (isNotEditBlock(nodeElement) && !this.element.querySelector(".protyle-wysiwyg--select")) { nodeElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([nodeElement.getAttribute("data-node-id")]) + countBlockWord([nodeElement.getAttribute("data-node-id")]); } else if (!nodeElement.classList.contains("protyle-wysiwyg--select")) { countSelectWord(range); } @@ -1791,10 +1791,10 @@ export class WYSIWYG { // 单个 p 不选中 shiftStartElement = undefined; } else { - const ids: string[] = [] + const ids: string[] = []; selectElements.forEach(item => { item.classList.add("protyle-wysiwyg--select"); - ids.push(item.getAttribute("data-node-id")) + ids.push(item.getAttribute("data-node-id")); }); countBlockWord(ids); if (toDown) { @@ -1828,9 +1828,9 @@ export class WYSIWYG { if (ctrlParentElement && !ctrlElement.isSameNode(ctrlParentElement)) { ctrlParentElement.classList.remove("protyle-wysiwyg--select"); } - const ids: string[] = [] + const ids: string[] = []; protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => { - ids.push(item.getAttribute("data-node-id")) + ids.push(item.getAttribute("data-node-id")); }); countBlockWord(ids); } diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 354dc22bd..aef4a3e12 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -153,7 +153,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } nextElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([nextElement.getAttribute("data-node-id")]) + countBlockWord([nextElement.getAttribute("data-node-id")]); const bottom = nextElement.getBoundingClientRect().bottom - protyle.contentElement.getBoundingClientRect().bottom; if (bottom > 0) { protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + bottom; @@ -190,7 +190,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } if (previousElement) { previousElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([previousElement.getAttribute("data-node-id")]) + countBlockWord([previousElement.getAttribute("data-node-id")]); const top = previousElement.getBoundingClientRect().top - protyle.contentElement.getBoundingClientRect().top; if (top < 0) { protyle.contentElement.scrollTop = protyle.contentElement.scrollTop + top; @@ -315,10 +315,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { selectElements[0].parentElement.classList.add("protyle-wysiwyg--select"); } } - const ids: string[] = [] + const ids: string[] = []; protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => { - ids.push(item.getAttribute("data-node-id")) - }) + ids.push(item.getAttribute("data-node-id")); + }); countBlockWord(ids); event.stopPropagation(); event.preventDefault(); @@ -362,10 +362,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { selectLastElement.parentElement.classList.add("protyle-wysiwyg--select"); } } - const ids: string[] = [] + const ids: string[] = []; protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => { - ids.push(item.getAttribute("data-node-id")) - }) + ids.push(item.getAttribute("data-node-id")); + }); countBlockWord(ids); event.stopPropagation(); event.preventDefault(); @@ -966,7 +966,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { protyle.hint.enableEmoji = false; } else if (nodeElement.classList.contains("protyle-wysiwyg--select")) { hideElements(["select"], protyle); - countBlockWord([]) + countBlockWord([]); } else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) { // 防止 ESC 时选中当前块 window.siyuan.menus.menu.remove(); @@ -975,7 +975,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { item.classList.remove("protyle-wysiwyg--select"); }); nodeElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([nodeElement.getAttribute("data-node-id")]) + countBlockWord([nodeElement.getAttribute("data-node-id")]); } event.preventDefault(); return; diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index 5326b28d9..e8d0bc8b9 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -413,7 +413,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran return; } previousLastElement.classList.add("protyle-wysiwyg--select"); - countBlockWord([previousId]) + countBlockWord([previousId]); if (previousLastElement.getAttribute("data-type") === "NodeBlockQueryEmbed" || editableElement.textContent !== "") { focusByRange(range); return; diff --git a/app/src/search/index.ts b/app/src/search/index.ts index a938efe4a..7f7d215c6 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -189,7 +189,7 @@ export class Search extends Model { size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, }, getResponse => { onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]); - const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`) + const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`); if (matchElement) { matchElement.scrollIntoView(); } @@ -204,7 +204,7 @@ export class Search extends Model { breadcrumbDocName: true, }, after: () => { - const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`) + const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`); if (matchElement) { matchElement.scrollIntoView(); } diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index 1023370a6..d2dd5fa0e 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -648,7 +648,7 @@ const getArticle = (options: { breadcrumbDocName: true }, after: () => { - const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`) + const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`); if (matchElement) { matchElement.scrollIntoView(); } @@ -664,7 +664,7 @@ const getArticle = (options: { size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, }, getResponse => { onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]); - const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`) + const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`); if (matchElement) { matchElement.scrollIntoView(); } diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 0b68802da..c422557e7 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -1,5 +1,5 @@ import {openSearch} from "../search/spread"; -import {exportLayout, getDockByType, JSONToLayout, resizeDrag, resizeTabs} from "../layout/util"; +import {exportLayout, JSONToLayout, resizeDrag, resizeTabs} from "../layout/util"; import {hotKey2Electron, updateHotkeyTip} from "../protyle/util/compatibility"; /// #if !BROWSER import {ipcRenderer} from "electron";