diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 6f6f9a555f4..2705c773ad6 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -2,7 +2,7 @@ import {Menu} from "../../../plugin/Menu"; import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../../util/hasClosest"; import {transaction} from "../../wysiwyg/transaction"; import {openEditorTab} from "../../../menus/util"; -import {copySubMenu, openFileAttr} from "../../../menus/commonMenuItem"; +import {openFileAttr} from "../../../menus/commonMenuItem"; import { addDragFill, genCellValueByElement, @@ -93,7 +93,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle searchElement.style.paddingRight = ""; const viewsElement = hasClosestByClassName(searchElement, "av__views"); if (viewsElement) { - viewsElement.classList.add("av__views--show") + viewsElement.classList.add("av__views--show"); } setTimeout(() => { searchElement.focus(); @@ -288,38 +288,38 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi }); /// #endif } - let copyMenu: IMenu[] = [] + let copyMenu: IMenu[] = []; if (rowElements.length === 1 && keyCellElement.getAttribute("data-detached") === "true") { copyMenu.push({ iconHTML: "", - label: window.siyuan.languages['_attrView'].key, + label: window.siyuan.languages["_attrView"].key, click() { writeText(rowElements[0].querySelector('.av__cell[data-dtype="block"] .av__celltext').textContent); } - }) + }); } else { copyMenu = [{ id: "copyBlockRef", iconHTML: "", label: window.siyuan.languages.copyBlockRef, click: async () => { - let text = "" + let text = ""; for (let i = 0; i < ids.length; i++) { const id = ids[i]; - let content = "" - const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']") + let content = ""; + const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { content = cellElement.querySelector(".av__celltext").textContent; } else { const response = await fetchSyncPost("/api/block/getRefText", {id}); - content = `((${id} '${response.data}'))` + content = `((${id} '${response.data}'))`; } if (ids.length > 1) { - text += "* " + text += "* "; } text += content; if (ids.length > 1 && i !== ids.length - 1) { - text += "\n" + text += "\n"; } } writeText(text); @@ -329,21 +329,21 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi iconHTML: "", label: window.siyuan.languages.copyBlockEmbed, click: () => { - let text = "" + let text = ""; ids.forEach((id, index) => { if (ids.length > 1) { - text += "* " + text += "* "; } - const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']") + const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { text += cellElement.querySelector(".av__celltext").textContent; } else { - text += `{{select * from blocks where id='${id}'}}` + text += `{{select * from blocks where id='${id}'}}`; } if (ids.length > 1 && index !== ids.length - 1) { - text += "\n" + text += "\n"; } - }) + }); writeText(text); } }, { @@ -351,12 +351,12 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi iconHTML: "", label: window.siyuan.languages.copyProtocol, click: () => { - let text = "" + let text = ""; ids.forEach((id, index) => { if (ids.length > 1) { text += "* "; } - const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']") + const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { text += cellElement.querySelector(".av__celltext").textContent; } else { @@ -365,7 +365,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi if (ids.length > 1 && index !== ids.length - 1) { text += "\n"; } - }) + }); writeText(text); } }, { @@ -373,23 +373,23 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi iconHTML: "", label: window.siyuan.languages.copyProtocolInMd, click: async () => { - let text = "" + let text = ""; for (let i = 0; i < ids.length; i++) { const id = ids[i]; - let content = "" - const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']") + let content = ""; + const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { content = cellElement.querySelector(".av__celltext").textContent; } else { const response = await fetchSyncPost("/api/block/getRefText", {id}); - content = `[${response.data}](siyuan://blocks/${id})` + content = `[${response.data}](siyuan://blocks/${id})`; } if (ids.length > 1) { - text += "* " + text += "* "; } - text += content + text += content; if (ids.length > 1 && i !== ids.length - 1) { - text += "\n" + text += "\n"; } } writeText(text); @@ -399,24 +399,24 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi iconHTML: "", label: window.siyuan.languages.copyHPath, click: async () => { - let text = "" + let text = ""; for (let i = 0; i < ids.length; i++) { const id = ids[i]; - let content = "" - const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']") + let content = ""; + const cellElement = rowElements[i].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { content = cellElement.querySelector(".av__celltext").textContent; } else { const response = await fetchSyncPost("/api/filetree/getHPathByID", {id}); - content = response.data + content = response.data; } if (ids.length > 1) { - text += "* " + text += "* "; } - text += content + text += content; if (ids.length > 1 && i !== ids.length - 1) { - text += "\n" + text += "\n"; } } writeText(text); @@ -426,24 +426,24 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi iconHTML: "", label: window.siyuan.languages.copyID, click: () => { - let text = "" + let text = ""; ids.forEach((id, index) => { if (ids.length > 1) { text += "* "; } - const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']") + const cellElement = rowElements[index].querySelector(".av__cell[data-dtype='block']"); if (cellElement.getAttribute("data-detached") === "true") { text += cellElement.querySelector(".av__celltext").textContent; } else { - text += id + text += id; } if (ids.length > 1 && index !== ids.length - 1) { text += "\n"; } - }) + }); writeText(text); } - }] + }]; } menu.addItem({ diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts index 0ced26d1357..d4eb15013a8 100644 --- a/app/src/protyle/util/insertHTML.ts +++ b/app/src/protyle/util/insertHTML.ts @@ -209,7 +209,7 @@ const processTable = (range: Range, html: string, protyle: IProtyle, blockElemen const scrollLeft = blockElement.firstElementChild.scrollLeft; const tableSelectElement = blockElement.querySelector(".table__select") as HTMLElement; let index = 0; - const matchCellsElement: HTMLTableCellElement[] = [] + const matchCellsElement: HTMLTableCellElement[] = []; blockElement.querySelectorAll("th, td").forEach((item: HTMLTableCellElement) => { if (!item.classList.contains("fn__none") && item.offsetLeft + 6 > tableSelectElement.offsetLeft + scrollLeft && item.offsetLeft + item.clientWidth - 6 < tableSelectElement.offsetLeft + scrollLeft + tableSelectElement.clientWidth && @@ -227,7 +227,7 @@ const processTable = (range: Range, html: string, protyle: IProtyle, blockElemen if (matchIndex === matchCellsElement.length - 1) { setLastNodeRange(item, range, false); } - }) + }); range.collapse(false); updateTransaction(protyle, blockElement.getAttribute("data-node-id"), blockElement.outerHTML, oldHTML); return true; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index bda56d2dedc..7034df1ac39 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -565,7 +565,7 @@ export class WYSIWYG { documentSelf.onselect = null; if (lastCellElement) { dragFillCellsValue(protyle, nodeElement, originData, originCellIds); - const allActiveCellsElement = nodeElement.querySelectorAll(".av__cell--active") + const allActiveCellsElement = nodeElement.querySelectorAll(".av__cell--active"); addDragFill(allActiveCellsElement[allActiveCellsElement.length - 1]); } return false; @@ -701,7 +701,7 @@ export class WYSIWYG { } // table cell select let tableBlockElement: HTMLElement | false; - const targetCellElemet = hasClosestByMatchTag(target, "TH") || hasClosestByMatchTag(target, "TD") + const targetCellElemet = hasClosestByMatchTag(target, "TH") || hasClosestByMatchTag(target, "TD"); if (targetCellElemet) { target = targetCellElemet; } @@ -790,9 +790,9 @@ export class WYSIWYG { // table cell select if (!protyle.disabled && tableBlockElement && tableBlockElement.contains(moveTarget) && !hasClosestByClassName(tableBlockElement, "protyle-wysiwyg__embed")) { if (moveTarget.classList.contains("table__select")) { - moveTarget.classList.add("fn__none") - const pointElement = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY) - moveTarget.classList.remove("fn__none") + moveTarget.classList.add("fn__none"); + const pointElement = document.elementFromPoint(moveEvent.clientX, moveEvent.clientY); + moveTarget.classList.remove("fn__none"); moveTarget = hasClosestByMatchTag(pointElement, "TH") || hasClosestByMatchTag(pointElement, "TD"); } if (moveTarget && (moveTarget.tagName === "TH" || moveTarget.tagName === "TD") && (!moveCellElement || !moveCellElement.isSameNode(moveTarget))) {