diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index c9691f23f..049f366de 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -625,7 +625,7 @@ export const initKeyboardToolbar = () => { } // appearance if (["clear", "style2", "style4", "color", "backgroundColor", "fontSize", "style1"].includes(type)) { - const nodeElements = getFontNodeElements(protyle) + const nodeElements = getFontNodeElements(protyle); if (type === "style1") { fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.backgroundColor + Constants.ZWSP + buttonElement.firstElementChild.style.color); } else if (type === "fontSize") { diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index b720d3928..8d0b2d66f 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -426,6 +426,19 @@ export class Gutter { }; } + private showMobileAppearance(protyle: IProtyle) { + const toolbarElement = document.getElementById("keyboardToolbar"); + const dynamicElements = toolbarElement.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); + dynamicElements[0].classList.add("fn__none"); + dynamicElements[1].classList.remove("fn__none"); + toolbarElement.querySelector('.keyboard__action[data-type="text"]').classList.add("protyle-toolbar__item--current"); + toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconCloseRound"); + const oldScrollTop = protyle.contentElement.scrollTop; + renderTextMenu(protyle, toolbarElement); + showKeyboardToolbarUtil(oldScrollTop); + toolbarElement.classList.remove("fn__none"); + } + public renderMultipleMenu(protyle: IProtyle, selectsElement: Element[]) { let isList = false; let isContinue = false; @@ -680,17 +693,9 @@ export class Gutter { label: window.siyuan.languages.appearance, icon: "iconFont", accelerator: window.siyuan.config.keymap.editor.insert.appearance.custom, - click() { + click: () => { /// #if MOBILE - const toolbarElement = document.getElementById("keyboardToolbar"); - const dynamicElements = toolbarElement.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); - dynamicElements[0].classList.add("fn__none"); - dynamicElements[1].classList.remove("fn__none"); - toolbarElement.querySelector('.keyboard__action[data-type="text"]').classList.add("protyle-toolbar__item--current"); - toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconCloseRound"); - const oldScrollTop = protyle.contentElement.scrollTop; - renderTextMenu(protyle, toolbarElement); - showKeyboardToolbarUtil(oldScrollTop); + this.showMobileAppearance(protyle); /// #else protyle.toolbar.element.classList.add("fn__none"); protyle.toolbar.subElement.innerHTML = ""; @@ -754,7 +759,7 @@ export class Gutter { public renderMenu(protyle: IProtyle, buttonElement: Element) { if (!buttonElement) { - return + return; } hideElements(["util", "toolbar", "hint"], protyle); window.siyuan.menus.menu.remove(); @@ -1501,17 +1506,9 @@ export class Gutter { label: window.siyuan.languages.appearance, icon: "iconFont", accelerator: window.siyuan.config.keymap.editor.insert.appearance.custom, - click() { + click: () => { /// #if MOBILE - const toolbarElement = document.getElementById("keyboardToolbar"); - const dynamicElements = toolbarElement.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); - dynamicElements[0].classList.add("fn__none"); - dynamicElements[1].classList.remove("fn__none"); - toolbarElement.querySelector('.keyboard__action[data-type="text"]').classList.add("protyle-toolbar__item--current"); - toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconCloseRound"); - const oldScrollTop = protyle.contentElement.scrollTop; - renderTextMenu(protyle, toolbarElement); - showKeyboardToolbarUtil(oldScrollTop); + this.showMobileAppearance(protyle); /// #else protyle.toolbar.element.classList.add("fn__none"); protyle.toolbar.subElement.innerHTML = ""; diff --git a/app/src/protyle/render/util.ts b/app/src/protyle/render/util.ts index 120d56029..d1168ddf7 100644 --- a/app/src/protyle/render/util.ts +++ b/app/src/protyle/render/util.ts @@ -2,5 +2,5 @@ export const genIconHTML = () => { return `
-
` -} +`; +}; diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts index f84ce4dd7..8840aaf5b 100644 --- a/app/src/protyle/toolbar/Font.ts +++ b/app/src/protyle/toolbar/Font.ts @@ -421,4 +421,4 @@ export const getFontNodeElements = (protyle: IProtyle) => { } } return nodeElements; -} +}; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index b96b160d5..4978e53f4 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -2007,7 +2007,7 @@ export class WYSIWYG { if (protyle.options.render.breadcrumb) { setTimeout(() => { protyle.breadcrumb.render(protyle); - }, Constants.TIMEOUT_TRANSITION) + }, Constants.TIMEOUT_TRANSITION); } } else if (lastEditElement) { range.selectNodeContents(lastEditElement); diff --git a/app/src/search/util.ts b/app/src/search/util.ts index e8fda4633..79c786020 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -41,7 +41,7 @@ const toggleReplaceHistory = (replaceHistoryElement: Element, historyElement: El replaceHistoryElement.classList.add("fn__none"); } historyElement.classList.add("fn__none"); -} +}; const toggleSearchHistory = (historyElement: Element, replaceHistoryElement: Element, searchInputElement: HTMLInputElement) => { if (historyElement.classList.contains("fn__none")) { @@ -64,7 +64,7 @@ const toggleSearchHistory = (historyElement: Element, replaceHistoryElement: Ele historyElement.classList.add("fn__none"); } replaceHistoryElement.classList.add("fn__none"); -} +}; const saveKeyList = (type: "keys" | "replaceKeys", value: string) => { let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type]; @@ -609,12 +609,12 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo event.preventDefault(); break; } else if (target.id === "searchHistoryBtn") { - toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement) + toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement); event.stopPropagation(); event.preventDefault(); return; } else if (target.id === "replaceHistoryBtn") { - toggleReplaceHistory(replaceHistoryElement, historyElement, replaceInputElement) + toggleReplaceHistory(replaceHistoryElement, historyElement, replaceInputElement); event.stopPropagation(); event.preventDefault(); return; @@ -756,7 +756,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo return; } const focusIsNew = currentList.getAttribute("data-type") === "search-new"; - const isHistory = !historyElement.classList.contains("fn__none") + const isHistory = !historyElement.classList.contains("fn__none"); if (event.key === "Enter") { if (!isHistory) { if (focusIsNew) { @@ -779,7 +779,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo searchInputElement.value = historyElement.querySelector(".b3-list-item--focus").textContent.trim(); config.page = 1; inputTimeout = inputEvent(element, config, inputTimeout, edit); - toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement) + toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement); } event.preventDefault(); } @@ -789,7 +789,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo } if (isHistory) { if (event.key === "Escape") { - toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement) + toggleSearchHistory(historyElement, replaceHistoryElement, searchInputElement); } else { upDownHint(historyElement, event); } @@ -860,7 +860,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo if (event.isComposing) { return; } - const isHistory = !replaceHistoryElement.classList.contains("fn__none") + const isHistory = !replaceHistoryElement.classList.contains("fn__none"); if (event.key === "Enter") { if (isHistory) { replaceInputElement.value = replaceHistoryElement.querySelector(".b3-list-item--focus").textContent.trim(); @@ -876,7 +876,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo } if (isHistory) { if (event.key === "Escape") { - toggleReplaceHistory(replaceHistoryElement, historyElement, replaceInputElement) + toggleReplaceHistory(replaceHistoryElement, historyElement, replaceInputElement); } else { upDownHint(replaceHistoryElement, event); }