From d1b5051ec46f270032661e015fe048461deb6cbf Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 10 Jun 2023 11:11:49 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/7536 --- app/src/protyle/render/av/action.ts | 16 ++++++++++++++-- app/src/protyle/render/av/render.ts | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index c593e91bc..09a07a7b8 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -36,9 +36,10 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle event.stopPropagation(); return true; } + const cellElement = hasClosestByClassName(event.target, "av__cell"); if (cellElement && blockElement) { - const type = cellElement.getAttribute("data-dtype"); + const type = cellElement.getAttribute("data-dtype") as TAVCol; const menu = new Menu("av-header-cell"); menu.addItem({ icon: getIconByType(type), @@ -98,7 +99,18 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle icon: "iconTrashcan", label: window.siyuan.languages.delete, click() { - + const id = cellElement.getAttribute("data-id") + transaction(protyle, [{ + action: "removeAttrViewCol", + id, + parentID: blockElement.getAttribute("data-av-type"), + }], [{ + action: "addAttrViewCol", + name: cellElement.textContent.trim(), + parentID: blockElement.getAttribute("data-av-id"), + type: type, + id + }]); } }); menu.addSeparator(); diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 7e6da7811..3482a9c78 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -1,6 +1,6 @@ import {fetchPost} from "../../../util/fetch"; -export const getIconByType = (type: string) => { +export const getIconByType = (type: TAVCol) => { switch (type) { case "text": return "iconAlignLeft";