From fd648825958adfe1fa45cfbd4987b7d5d8888f53 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 2 Jul 2023 23:59:01 +0800 Subject: [PATCH] :rotating_light: --- app/src/protyle/render/av/action.ts | 2 +- app/src/protyle/render/av/addCol.ts | 2 +- app/src/protyle/render/av/cell.ts | 2 +- app/src/protyle/render/av/openMenuPanel.ts | 44 +++++++++++----------- app/src/protyle/render/av/render.ts | 10 ++--- app/src/protyle/util/editorCommonEvent.ts | 16 ++++---- app/src/protyle/wysiwyg/index.ts | 4 +- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 17e217b36..f011c99ca 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -17,7 +17,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add"); if (addElement) { const addMenu = addCol(protyle, blockElement); - const addRect = addElement.getBoundingClientRect() + const addRect = addElement.getBoundingClientRect(); addMenu.open({ x: addRect.left, y: addRect.bottom, diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts index ec230a391..82f5991a5 100644 --- a/app/src/protyle/render/av/addCol.ts +++ b/app/src/protyle/render/av/addCol.ts @@ -99,4 +99,4 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => { } }); return menu; -} +}; diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index b4ae20b5c..793586746 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -217,7 +217,7 @@ export const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement, y: cellRect.bottom, h: cellRect.height }); - const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement + const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement; if (inputElement) { inputElement.select(); inputElement.focus(); diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index c9d306995..f4cc69623 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -10,11 +10,11 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type return; } window.siyuan.menus.menu.remove(); - const avId = blockElement.getAttribute("data-av-id") + const avId = blockElement.getAttribute("data-av-id"); fetchPost("/api/av/renderAttributeView", {id: avId}, (response) => { const data = response.data.av as IAV; - const tabRect = blockElement.querySelector(".layout-tab-bar").getBoundingClientRect() - let html + const tabRect = blockElement.querySelector(".layout-tab-bar").getBoundingClientRect(); + let html; if (type === "config") { html = getConfigHTML(data, tabRect); } else if (type === "properties") { @@ -51,8 +51,8 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type event.stopPropagation(); break; } else if (type === "showAllCol") { - const doOperations: IOperation[] = [] - const undoOperations: IOperation[] = [] + const doOperations: IOperation[] = []; + const undoOperations: IOperation[] = []; data.columns.forEach((item: IAVColumn) => { if (item.hidden) { doOperations.push({ @@ -60,16 +60,16 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type id: item.id, parentID: avId, data: false - }) + }); undoOperations.push({ action: "setAttrViewColHidden", id: item.id, parentID: avId, data: true - }) - item.hidden = false + }); + item.hidden = false; } - }) + }); if (doOperations.length > 0) { transaction(protyle, doOperations, undoOperations); avMenuPanel.innerHTML = getPropertiesHTML(data, tabRect); @@ -77,8 +77,8 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type event.stopPropagation(); break; } else if (type === "hideAllCol") { - const doOperations: IOperation[] = [] - const undoOperations: IOperation[] = [] + const doOperations: IOperation[] = []; + const undoOperations: IOperation[] = []; data.columns.forEach((item: IAVColumn) => { if (!item.hidden && item.type !== "block") { doOperations.push({ @@ -86,16 +86,16 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type id: item.id, parentID: avId, data: true - }) + }); undoOperations.push({ action: "setAttrViewColHidden", id: item.id, parentID: avId, data: false - }) - item.hidden = true + }); + item.hidden = true; } - }) + }); if (doOperations.length > 0) { transaction(protyle, doOperations, undoOperations); avMenuPanel.innerHTML = getPropertiesHTML(data, tabRect); @@ -141,7 +141,7 @@ export const openMenuPanel = (protyle: IProtyle, blockElement: HTMLElement, type } }); }); -} +}; const getConfigHTML = (data: IAV, tabRect: DOMRect) => { return `
@@ -175,8 +175,8 @@ const getConfigHTML = (data: IAV, tabRect: DOMRect) => { 50 -` -} +`; +}; const getPropertiesHTML = (data: IAV, tabRect: DOMRect) => { let showHTML = ""; @@ -187,13 +187,13 @@ const getPropertiesHTML = (data: IAV, tabRect: DOMRect) => { ${item.name} -` +`; } else { showHTML += `` +`; } }); if (hideHTML) { @@ -235,5 +235,5 @@ ${hideHTML}`; ${window.siyuan.languages.new} -` -} +`; +}; diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 3952a4dbc..59a06b88b 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -129,11 +129,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}< } }; -let lastParentID: string -let lastElement: HTMLElement +let lastParentID: string; +let lastElement: HTMLElement; export const refreshAV = (protyle: IProtyle, operation: IOperation) => { if (lastParentID === operation.parentID && protyle.contentElement.isSameNode(lastElement)) { - return + return; } lastElement = protyle.contentElement; lastParentID = operation.parentID; @@ -148,12 +148,12 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.parentID}"]`)).forEach((item: HTMLElement) => { const cellElement = item.querySelector(`.av__cell[data-id="${operation.id}"]`) as HTMLElement; if (!cellElement || cellElement.style.width === operation.data) { - return + return; } const index = cellElement.dataset.index; item.querySelectorAll(".av__row").forEach(rowItem => { (rowItem.querySelector(`[data-index="${index}"]`) as HTMLElement).style.width = operation.data; - }) + }); }); } else { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.parentID}"]`)).forEach((item: HTMLElement) => { diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 9bb24348f..27df81280 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -723,13 +723,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { return; } const rowElement = target.parentElement; - const selectIds = [] + const selectIds = []; if (rowElement.classList.contains("av__row--select")) { rowElement.parentElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach((item) => { - selectIds.push(item.getAttribute("data-id")) - }) + selectIds.push(item.getAttribute("data-id")); + }); } else { - selectIds.push(rowElement.getAttribute("data-id")) + selectIds.push(rowElement.getAttribute("data-id")); } if (selectIds.length === 1) { event.dataTransfer.setDragImage(rowElement, 0, 0); @@ -823,7 +823,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { if (!blockElement) { return; } - const avId = blockElement.getAttribute("data-av-id") + const avId = blockElement.getAttribute("data-av-id"); transaction(protyle, [{ action: "sortAttrViewCol", parentID: avId, @@ -849,7 +849,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else { previousID = targetElement.previousElementSibling?.getAttribute("data-id") || ""; } - const avId = blockElement.getAttribute("data-av-id") + const avId = blockElement.getAttribute("data-av-id"); if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") { // 行内拖拽 const doOperations: IOperation[] = []; @@ -861,13 +861,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { parentID: avId, previousID, id: item, - }) + }); undoOperations.push({ action: "sortAttrViewRow", parentID: avId, previousID: undoPreviousId, id: item, - }) + }); }); transaction(protyle, doOperations, undoOperations); } else { diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index fa48de7a6..3e8c13190 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -356,12 +356,12 @@ export class WYSIWYG { const dragElement = target.parentElement; const oldWidth = dragElement.clientWidth; const dragIndex = dragElement.getAttribute("data-index"); - let newWidth: string + let newWidth: string; documentSelf.onmousemove = (moveEvent: MouseEvent) => { newWidth = oldWidth + (moveEvent.clientX - event.clientX) + "px"; dragElement.parentElement.parentElement.querySelectorAll(".av__row").forEach(item => { (item.querySelector(`[data-index="${dragIndex}"]`) as HTMLElement).style.width = newWidth; - }) + }); }; documentSelf.onmouseup = () => {