diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss index a994d9044..1d4f3c120 100644 --- a/app/src/assets/scss/business/_av.scss +++ b/app/src/assets/scss/business/_av.scss @@ -29,6 +29,14 @@ } } + &--select { + background-color: var(--b3-theme-primary-lightest); + + .av__firstcol svg { + opacity: 1; + } + } + &--header, &--footer { background-color: var(--b3-theme-background); diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts index 0b2e40dba..7f7872c97 100644 --- a/app/src/plugin/API.ts +++ b/app/src/plugin/API.ts @@ -17,7 +17,7 @@ import {Setting} from "./Setting"; export class Menu { private menu: SiyuanMenu; - private isOpen: boolean; + public isOpen: boolean; constructor(id?: string, closeCB?: () => void) { this.menu = window.siyuan.menus.menu; diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 10c5e5d99..0e3aa2064 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -103,8 +103,11 @@ const showHeaderCellMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => { const blockElement = hasClosestBlock(event.target); + if (!blockElement) { + return false + } const addElement = hasClosestByAttribute(event.target, "data-type", "av-header-add"); - if (addElement && blockElement) { + if (addElement) { const menu = new Menu("av-header-add"); menu.addItem({ icon: "iconAlignLeft", @@ -137,8 +140,15 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle return true; } + const checkElement = hasClosestByClassName(event.target, "av__firstcol"); + if (checkElement) { + event.preventDefault(); + event.stopPropagation(); + return true; + } + const cellElement = hasClosestByClassName(event.target, "av__cell"); - if (cellElement && blockElement) { + if (cellElement) { if (cellElement.parentElement.classList.contains("av__row--header")) { showHeaderCellMenu(protyle, blockElement, cellElement); event.preventDefault(); @@ -160,8 +170,18 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a if (!blockElement) { return false; } + event.preventDefault(); + event.stopPropagation(); + + blockElement.querySelectorAll(".av__row--select").forEach(item => { + item.classList.remove("av__row--select"); + }); const rowId = rowElement.getAttribute("data-id"); const menu = new Menu("av-row"); + if (menu.isOpen) { + return true + } + rowElement.classList.add("av__row--select"); menu.addItem({ icon: "iconCopy", label: window.siyuan.languages.duplicate, @@ -222,8 +242,6 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a x: event.clientX, y: event.clientY, }); - event.preventDefault(); - event.stopPropagation(); return true; }; diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 7259eebad..f63491b0f 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -6,7 +6,7 @@ export const popTextCell = (protyle: IProtyle, cellElement: HTMLElement) => { const cellRect = cellElement.getBoundingClientRect(); let html = ""; if (type === "block") { - html = ``; + html = ``; } document.body.insertAdjacentHTML("beforeend", `