Vanessa 2025-11-05 21:53:28 +08:00
parent 84f884dff2
commit 5c57054eba
5 changed files with 34 additions and 31 deletions

View file

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

View file

@ -996,7 +996,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru
});
} else if (cellValue.type === "checkbox") {
text += `<div class="fn__flex"><svg class="av__checkbox"><use xlink:href="#icon${cellValue?.checkbox?.checked ? "Check" : "Uncheck"}"></use></svg>`;
if (type === "gallery" && cellValue?.checkbox?.content) {
if (["gallery", "kanban"].includes(type) && cellValue?.checkbox?.content) {
text += `<span class="fn__space"></span>${cellValue?.checkbox?.content}`;
}
text += "</div>";
@ -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) {

View file

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

View file

@ -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: {

View file

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