Vanessa 2023-06-30 10:26:48 +08:00
parent f8c6cacf22
commit 4be64ed121
10 changed files with 22 additions and 6 deletions

View file

@ -45,6 +45,14 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true;
}
const gutterElement = hasClosestByClassName(event.target, "av__gutters");
if (gutterElement) {
avContextmenu(protyle, event, gutterElement);
event.preventDefault();
event.stopPropagation();
return true;
}
const checkElement = hasClosestByClassName(event.target, "av__firstcol");
if (checkElement) {
// TODO
@ -72,6 +80,9 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
if (!rowElement) {
return false;
}
if (rowElement.classList.contains("av__row--header")) {
return false
}
const blockElement = hasClosestBlock(rowElement);
if (!blockElement) {
return false;
@ -83,7 +94,7 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
item.classList.remove("av__row--select");
});
const rowId = rowElement.getAttribute("data-id");
const menu = new Menu("av-row");
const menu = new Menu();
if (menu.isOpen) {
return true;
}
@ -101,7 +112,7 @@ export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: a
click() {
transaction(protyle, [{
action: "removeAttrViewBlock",
srcIDs: [rowId],
srcIDs: [rowElement.querySelector(".av__cell").getAttribute("data-block-id")],
parentID: blockElement.getAttribute("data-av-id"),
}], [{
action: "insertAttrViewBlock",

View file

@ -43,12 +43,12 @@ export const avRender = (element: Element, cb?: () => void) => {
// body
data.rows.forEach((row: IAVRow) => {
tableHTML += `<div class="av__row" data-id="${row.id}">
<div class="av__gutters">
<div class="av__gutters" data-position="right" aria-label="${window.siyuan.languages.rowTip}">
<button><svg><use xlink:href="#iconLine"></use></svg></button>
</div>
<div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>`;
row.cells.forEach((cell, index) => {
tableHTML += `<div class="av__cell" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${cell.renderValue?.content || ""}</div>`;
tableHTML += `<div class="av__cell" data-block-id="${cell.renderValue?.id || ""}" data-index="${index}" style="width: ${data.columns[index].width || 200}px;${cell.bgColor ? `background-color:${cell.bgColor};` : ""}${cell.color ? `color:${cell.color};` : ""}">${cell.renderValue?.content || ""}</div>`;
});
tableHTML += "<div></div></div>";
});