This commit is contained in:
Vanessa 2023-06-10 17:56:45 +08:00
parent 8a4ab0daff
commit cd41c3b6e2
4 changed files with 32 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
};

View File

@ -6,7 +6,7 @@ export const popTextCell = (protyle: IProtyle, cellElement: HTMLElement) => {
const cellRect = cellElement.getBoundingClientRect();
let html = "";
if (type === "block") {
html = `<textarea style="position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px" class="b3-text-field fn__size200">${cellElement.textContent}</textarea>`;
html = `<textarea style="position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 200)}px" class="b3-text-field">${cellElement.textContent}</textarea>`;
}
document.body.insertAdjacentHTML("beforeend", `<div class="av__mask">
${html}