diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts index 560739ce6..ae023c261 100644 --- a/app/src/card/openCard.ts +++ b/app/src/card/openCard.ts @@ -24,7 +24,7 @@ const genCardCount = (unreviewedNewCardCount: number, unreviewedOldCardCount: nu ${unreviewedNewCardCount} + ${unreviewedOldCardCount}`; -} +}; export const genCardHTML = (options: { id: string, diff --git a/app/src/dialog/index.ts b/app/src/dialog/index.ts index 9e43256f1..f18458f6e 100644 --- a/app/src/dialog/index.ts +++ b/app/src/dialog/index.ts @@ -33,8 +33,8 @@ export class Dialog { window.siyuan.dialogs.push(this); this.destroyCallback = options.destroyCallback; this.element = document.createElement("div") as HTMLElement; - let left - let top + let left; + let top; if (!isMobile() && options.positionId) { const dialogPosition = window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION][options.positionId]; if (dialogPosition) { diff --git a/app/src/dialog/moveResize.ts b/app/src/dialog/moveResize.ts index fb50d0643..f89956bb6 100644 --- a/app/src/dialog/moveResize.ts +++ b/app/src/dialog/moveResize.ts @@ -133,8 +133,8 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi documentSelf.ondragstart = null; documentSelf.onselectstart = null; documentSelf.onselect = null; - hideAllElements(["gutter"]) - const dialogElement = hasClosestByClassName(element, "b3-dialog--open") + hideAllElements(["gutter"]); + const dialogElement = hasClosestByClassName(element, "b3-dialog--open"); if (dialogElement) { const dialogId = dialogElement.dataset.key; if (dialogId && element.offsetWidth) { @@ -143,7 +143,7 @@ export const moveResize = (element: HTMLElement, afterCB?: (type: string) => voi height: element.offsetHeight, left: parseInt(element.style.left), top: parseInt(element.style.top), - } + }; setStorageVal(Constants.LOCAL_DIALOGPOSITION, window.siyuan.storage[Constants.LOCAL_DIALOGPOSITION]); } } diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 8197c9dee..302bbd044 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -21,11 +21,10 @@ import {getSearch} from "../util/functions"; import {initRightMenu} from "./menu"; import {openChangelog} from "../boot/openChangelog"; import {registerServiceWorker} from "../util/serviceWorker"; -import {afterLoadPlugin, loadPlugins} from "../plugin/loader"; +import {loadPlugins} from "../plugin/loader"; import {saveScroll} from "../protyle/scroll/saveScroll"; import {removeBlock} from "../protyle/wysiwyg/remove"; import {isNotEditBlock} from "../protyle/wysiwyg/getBlock"; -import {Menu} from "../plugin/Menu"; class App { public plugins: import("../plugin").Plugin[] = []; diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index efeac324b..26b7de3ae 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -46,14 +46,14 @@ const openDockMenu = (app: App) => { custom = plugin.docks[dockId].mobileModel(document.querySelector('#sidebar [data-type="sidebar-plugin"]')); } } - }) + }); }); }); menu.fullscreen("bottom"); if (menu.element.lastElementChild.innerHTML === "") { showMessage(window.siyuan.languages._kernel[122]); } -} +}; export const initFramework = (app: App, isStart: boolean) => { setInlineStyle(); diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.ts index f7bb4beae..a8e602a24 100644 --- a/app/src/protyle/export/util.ts +++ b/app/src/protyle/export/util.ts @@ -143,7 +143,7 @@ id="preview"> if (item.src.endsWith(".svg")) { fetchGet(item.src, (response: string) => { item.src = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(response)))}`; - }) + }); } }); btnsElement[0].removeAttribute("disabled"); diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts index 85c48c30a..1dba14585 100644 --- a/app/src/protyle/render/av/blockAttr.ts +++ b/app/src/protyle/render/av/blockAttr.ts @@ -1,7 +1,6 @@ import {fetchPost} from "../../../util/fetch"; import {getColIconByType} from "./col"; import {escapeAttr} from "../../../util/escape"; -import {hasClosestByAttribute} from "../../util/hasClosest"; import * as dayjs from "dayjs"; import {popTextCell} from "./cell"; @@ -129,27 +128,27 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes popTextCell(protyle, [target], "date"); event.stopPropagation(); event.preventDefault(); - break + break; } else if (type === "select" || type === "mSelect") { popTextCell(protyle, [target], target.getAttribute("data-type") as TAVCol); event.stopPropagation(); event.preventDefault(); - break + break; } else if (type === "mAsset") { popTextCell(protyle, [target], "mAsset"); event.stopPropagation(); event.preventDefault(); - break + break; } else if (type === "checkbox") { popTextCell(protyle, [target], "checkbox"); event.stopPropagation(); event.preventDefault(); - break + break; } else if (type === "relation") { popTextCell(protyle, [target], "relation"); event.stopPropagation(); event.preventDefault(); - break + break; } target = target.parentElement; } diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index c4a222945..9d51c702d 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -540,7 +540,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va if (!hasClosestByClassName(cellElements[0], "custom-attr")) { updateAttrViewCellAnimation(item, cellValue); } else { - item.innerHTML = genAVValueHTML(cellValue) + item.innerHTML = genAVValueHTML(cellValue); } }); if (doOperations.length > 0) { @@ -615,7 +615,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => { } else if (cellValue.type === "relation") { cellValue?.relation?.contents?.forEach((item, index) => { text += `${item}`; - }) + }); } if (["text", "template", "url", "email", "phone", "number", "date", "created", "updated"].includes(cellValue.type) && cellValue && cellValue[cellValue.type as "url"].content) { diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 3ff9afd78..6a59fe020 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -8,7 +8,7 @@ import {getLabelByNumberFormat} from "./number"; import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action"; import {openEmojiPanel, unicode2Emoji} from "../../../emoji"; import {focusBlock} from "../../util/selection"; -import {openSearchAV, toggleUpdateRelationBtn} from "./relation"; +import {toggleUpdateRelationBtn} from "./relation"; export const duplicateCol = (options: { protyle: IProtyle, @@ -334,21 +334,21 @@ export const bindEditEvent = (options: { toggleUpdateRelationBtn(options.menuElement, avID); }); const goSearchElement = options.menuElement.querySelector('[data-type="goSearchAV"]') as HTMLElement; - const oldValue = JSON.parse(goSearchElement.getAttribute("data-old-value")) - const inputElement = options.menuElement.querySelector('[data-type="colName"]') as HTMLInputElement + const oldValue = JSON.parse(goSearchElement.getAttribute("data-old-value")); + const inputElement = options.menuElement.querySelector('[data-type="colName"]') as HTMLInputElement; inputElement.addEventListener("input", () => { toggleUpdateRelationBtn(options.menuElement, avID); - }) + }); if (oldValue.avID) { fetchPost("/api/av/getAttributeView", {id: oldValue.avID}, (response) => { - goSearchElement.querySelector(".b3-menu__accelerator").textContent = oldValue.avID === avID ? window.siyuan.languages.thisDatabase : (response.data.av.name || window.siyuan.languages.title) + goSearchElement.querySelector(".b3-menu__accelerator").textContent = oldValue.avID === avID ? window.siyuan.languages.thisDatabase : (response.data.av.name || window.siyuan.languages.title); response.data.av.keyValues.find((item: { key: { id: string, name: string } }) => { if (item.key.id === oldValue.backKeyID) { inputElement.setAttribute("data-old-value", item.key.name || window.siyuan.languages.title); inputElement.value = item.key.name || window.siyuan.languages.title; return true; } - }) + }); toggleUpdateRelationBtn(options.menuElement, avID); }); } else { diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts index ba25d9d3a..a846f87d8 100644 --- a/app/src/protyle/render/av/filter.ts +++ b/app/src/protyle/render/av/filter.ts @@ -241,12 +241,12 @@ export const setFilter = (options: { }); }); } else if (["text", "url", "block", "email", "phone", "template", "relation"].includes(colData.type)) { - let value = "" + let value = ""; if (options.filter.value) { if (colData.type === "relation") { - value = options.filter.value.relation.contents[0] || "" + value = options.filter.value.relation.contents[0] || ""; } else { - value = options.filter.value[colData.type as "text"].content || "" + value = options.filter.value[colData.type as "text"].content || ""; } } menu.addItem({ diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts index 92a394f7b..b7afb79a2 100644 --- a/app/src/protyle/render/av/relation.ts +++ b/app/src/protyle/render/av/relation.ts @@ -25,24 +25,24 @@ const genSearchList = (element: Element, keyword: string, avId: string, cb?: ()
-` +`; }); element.innerHTML = html; if (cb) { - cb() + cb(); } - }) -} + }); +}; const setDatabase = (avId: string, element: HTMLElement, item: HTMLElement) => { element.dataset.avId = item.dataset.avId; element.dataset.blockId = item.dataset.blockId; - element.querySelector(".b3-menu__accelerator").textContent = item.querySelector(".b3-list-item__hinticon").classList.contains("fn__none") ? item.querySelector(".b3-list-item__text").textContent : window.siyuan.languages.thisDatabase - const menuElement = hasClosestByClassName(element, "b3-menu__items") + element.querySelector(".b3-menu__accelerator").textContent = item.querySelector(".b3-list-item__hinticon").classList.contains("fn__none") ? item.querySelector(".b3-list-item__text").textContent : window.siyuan.languages.thisDatabase; + const menuElement = hasClosestByClassName(element, "b3-menu__items"); if (menuElement) { toggleUpdateRelationBtn(menuElement, avId, true); } -} +}; export const openSearchAV = (avId: string, target: HTMLElement) => { window.siyuan.menus.menu.remove(); @@ -83,7 +83,7 @@ export const openSearchAV = (avId: string, target: HTMLElement) => { const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); if (listItemElement) { event.stopPropagation(); - setDatabase(avId, target, listItemElement) + setDatabase(avId, target, listItemElement); window.siyuan.menus.menu.remove(); } }); @@ -93,13 +93,13 @@ export const openSearchAV = (avId: string, target: HTMLElement) => { x: rect.left, y: rect.bottom, h: rect.height, - }) + }); element.querySelector("input").focus(); }); } }); menu.element.querySelector(".b3-menu__items").setAttribute("style", "overflow: initial"); -} +}; export const updateRelation = (options: { protyle: IProtyle, @@ -110,18 +110,18 @@ export const updateRelation = (options: { }) => { const inputElement = options.avElement.querySelector('input[data-type="colName"]') as HTMLInputElement; const goSearchAVElement = options.avElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement; - const newAVId = goSearchAVElement.getAttribute("data-av-id") - const colId = options.avElement.querySelector(".b3-menu__item").getAttribute("data-col-id") + const newAVId = goSearchAVElement.getAttribute("data-av-id"); + const colId = options.avElement.querySelector(".b3-menu__item").getAttribute("data-col-id"); let colData: IAVColumn; options.colsData.find(item => { if (item.id === colId) { if (!item.relation) { - item.relation = {} + item.relation = {}; } colData = item; return true; } - }) + }); const colNewName = (options.avElement.querySelector('[data-type="name"]') as HTMLInputElement).value; transaction(options.protyle, [{ action: "updateAttrViewColRelation", @@ -145,10 +145,10 @@ export const updateRelation = (options: { options.avElement.remove(); updateAttrViewCellAnimation(options.blockElement.querySelector(`.av__row--header .av__cell[data-col-id="${colId}"]`), undefined, {name: colNewName}); focusBlock(options.blockElement); -} +}; export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: string, resetData = false) => { - const searchElement = menuItemsElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement + const searchElement = menuItemsElement.querySelector('.b3-menu__item[data-type="goSearchAV"]') as HTMLElement; const switchItemElement = searchElement.nextElementSibling; const switchElement = switchItemElement.querySelector(".b3-switch") as HTMLInputElement; const inputItemElement = switchItemElement.nextElementSibling; @@ -161,7 +161,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str inputElement.value = ""; switchElement.checked = false; } else { - inputElement.value = inputElement.dataset.oldValue + inputElement.value = inputElement.dataset.oldValue; switchElement.checked = oldValue.isTwoWay; } } @@ -190,7 +190,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str } btnElement.classList.remove("fn__none"); } -} +}; const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, text?: string) => { if (type === "selected") { @@ -198,20 +198,20 @@ const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, -` +`; } if (type === "empty") { return `` +`; } if (type == "unselect") { return `` +`; } -} +}; export const bindRelationEvent = (options: { protyle: IProtyle, @@ -224,59 +224,59 @@ export const bindRelationEvent = (options: { id: options.menuElement.firstElementChild.getAttribute("data-av-id"), }, response => { const avData = response.data as IAV; - let cellIndex = 0 + let cellIndex = 0; avData.view.columns.find((item, index) => { if (item.type === "block") { - cellIndex = index + cellIndex = index; return true; } - }) - let html = "" - let selectHTML = "" + }); + let html = ""; + let selectHTML = ""; hasIds.forEach(hasId => { if (hasId) { avData.view.rows.find((item) => { if (item.id === hasId) { - selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id) - return true + selectHTML += genSelectItemHTML("selected", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id); + return true; } - }) + }); } - }) + }); avData.view.rows.forEach((item) => { if (!hasIds.includes(item.id)) { - html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id) + html += genSelectItemHTML("unselect", item.id, item.cells[cellIndex].value.block.content || item.cells[cellIndex].value.block.id); } - }) + }); options.menuElement.innerHTML = `` - }) -} +${html || genSelectItemHTML("empty")}`; + }); +}; export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => { - let colRelationData: IAVCellRelationValue + let colRelationData: IAVCellRelationValue; data.view.columns.find(item => { if (item.id === cellElements[0].dataset.colId) { - colRelationData = item.relation + colRelationData = item.relation; return true; } - }) + }); if (colRelationData && colRelationData.avID) { - let ids = "" + let ids = ""; cellElements[0].querySelectorAll("span").forEach((item) => { ids += `${item.getAttribute("data-id")},`; }); - return `${ids}` + return `${ids}`; } else { - return "" + return ""; } -} +}; export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, target: HTMLElement, cellElements: HTMLElement[]) => { const menuElement = hasClosestByClassName(target, "b3-menu__items"); if (!menuElement) { - return + return; } const newValue: { blockIDs: string[] @@ -284,16 +284,16 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar } = { blockIDs: [], contents: [] - } + }; Array.from(menuElement.children).forEach((item) => { - const id = item.getAttribute("data-id") + const id = item.getAttribute("data-id"); if (item.getAttribute("draggable") && id) { newValue.blockIDs.push(id); newValue.contents.push(item.textContent.trim()); } - }) + }); if (target.classList.contains("b3-menu__item")) { - const targetId = target.getAttribute("data-id") + const targetId = target.getAttribute("data-id"); const separatorElement = menuElement.querySelector(".b3-menu__separator"); if (target.getAttribute("draggable")) { if (!separatorElement.nextElementSibling.getAttribute("data-id")) { diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.ts index addf90f8d..d7c7cc49d 100644 --- a/app/src/protyle/wysiwyg/enter.ts +++ b/app/src/protyle/wysiwyg/enter.ts @@ -392,12 +392,12 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle action: "update", data: blockElement.outerHTML, id, - }) + }); undoOperation.push({ action: "update", data: html, id, - }) + }); mathRender(editableElement); } else { doOperation.push({ @@ -405,15 +405,15 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle data: item.outerHTML, id: item.dataset.nodeId, nextID: id, - }) + }); blockElement.insertAdjacentElement("beforebegin", item); undoOperation.push({ action: "delete", id: item.dataset.nodeId, - }) + }); mathRender(item); } - }) + }); let previousElement = blockElement; Array.from(newElement.children).forEach((item: HTMLElement) => {