diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 097db9e6e..e2d352c3b 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -162,12 +162,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle return; } const cellType = getTypeByCellElement(target); - if (viewType === "gallery") { - const itemElement = hasClosestByClassName(target, "av__gallery-item"); - if (itemElement && cellType !== "updated" && cellType !== "created" && cellType !== "lineNumber") { - popTextCell(protyle, [target]); - } - } else { + if (viewType === "table") { const scrollElement = hasClosestByClassName(target, "av__scroll"); if (!scrollElement) { return; @@ -176,7 +171,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle if (!rowElement) { return; } - // TODO 点击单元格的时候, lineNumber 选中整行 if (cellType === "updated" || cellType === "created" || cellType === "lineNumber") { selectRow(rowElement.querySelector(".av__firstcol"), "toggle"); } else { @@ -187,6 +181,11 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle updateHeader(rowElement); popTextCell(protyle, [target]); } + } else { + const itemElement = hasClosestByClassName(target, "av__gallery-item"); + if (itemElement && cellType !== "updated" && cellType !== "created" && cellType !== "lineNumber") { + popTextCell(protyle, [target]); + } } } event.preventDefault(); @@ -834,7 +833,7 @@ export const updateAttrViewCellAnimation = (cellElement: HTMLElement, value: IAV } const viewType = blockElement.getAttribute("data-av-type") as TAVView; const iconElement = cellElement.querySelector(".b3-menu__avemoji"); - if (viewType === "gallery") { + if (["gallery", "kanban"].includes(viewType)) { if (value.type === "checkbox") { value.checkbox = { checked: value.checkbox?.checked || false, diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index ec90c751b..9d77ab25f 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -996,7 +996,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru }); } else if (cellValue.type === "checkbox") { text += `
`; - if (type === "gallery" && cellValue?.checkbox?.content) { + if (["gallery", "kanban"].includes(type) && cellValue?.checkbox?.content) { text += `${cellValue?.checkbox?.content}`; } text += "
"; @@ -1223,7 +1223,7 @@ export const cellValueIsEmpty = (value: IAVCellValue) => { return !value[value.type as "text"]?.content; } if (value.type === "number") { - return !value.number?.isNotEmpty; + return value.number ? !value.number.isNotEmpty : true; } if (["mSelect", "mAsset", "select"].includes(value.type)) { if (value[(value.type === "select" ? "mSelect" : value.type) as "mSelect"]?.length > 0) { diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 60b03820a..ae3560247 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -22,7 +22,7 @@ import {hasClosestByClassName} from "../../util/hasClosest"; export const getColId = (element: Element, viewType: TAVView) => { if (viewType === "table" || hasClosestByClassName(element, "custom-attr")) { return element.getAttribute("data-col-id"); - } else if (viewType === "gallery") { + } else if (["gallery", "kanban"].includes(viewType)) { return element.getAttribute("data-field-id"); } }; diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.ts index 8e729579c..cdbfab658 100644 --- a/app/src/protyle/render/av/layout.ts +++ b/app/src/protyle/render/av/layout.ts @@ -178,24 +178,6 @@ export const bindLayoutEvent = (options: { if (options.data.viewType === "table") { return; } - const toggleBgElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-kanban-bg"]') as HTMLInputElement; - toggleBgElement.addEventListener("change", () => { - const avID = options.blockElement.getAttribute("data-av-id"); - const blockID = options.blockElement.getAttribute("data-node-id"); - const checked = toggleBgElement.checked; - transaction(options.protyle, [{ - action: "setAttrViewFillColBackgroundColor", - avID, - blockID, - data: checked - }], [{ - action: "setAttrViewFillColBackgroundColor", - avID, - blockID, - data: !checked - }]); - (options.data.view as IAVKanban).fillColBackgroundColor = checked; - }) const toggleFitElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-fit"]') as HTMLInputElement; toggleFitElement.addEventListener("change", () => { const avID = options.blockElement.getAttribute("data-av-id"); @@ -232,6 +214,27 @@ export const bindLayoutEvent = (options: { }]); (options.data.view as IAVGallery).displayFieldName = checked; }); + if (options.data.viewType === "gallery") { + return; + } + const toggleBgElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-kanban-bg"]') as HTMLInputElement; + toggleBgElement.addEventListener("change", () => { + const avID = options.blockElement.getAttribute("data-av-id"); + const blockID = options.blockElement.getAttribute("data-node-id"); + const checked = toggleBgElement.checked; + transaction(options.protyle, [{ + action: "setAttrViewFillColBackgroundColor", + avID, + blockID, + data: checked + }], [{ + action: "setAttrViewFillColBackgroundColor", + avID, + blockID, + data: !checked + }]); + (options.data.view as IAVKanban).fillColBackgroundColor = checked; + }); }; export const updateLayout = async (options: { diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 103c6594a..f3e8dfa23 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -600,11 +600,12 @@ export const openMenuPanel = (options: { hideElements(["util"], options.protyle); } else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) { // 过滤面板先关闭过滤条件 - window.siyuan.menus.menu.remove(); } else { closeCB?.(); avPanelElement.remove(); - focusBlock(options.blockElement); + setTimeout(() => { + focusBlock(options.blockElement); + }, Constants.TIMEOUT_TRANSITION); // 单选使用 enter 修改选项后会滚动 } window.siyuan.menus.menu.remove(); event.preventDefault();