mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
84f884dff2
commit
5c57054eba
5 changed files with 34 additions and 31 deletions
|
|
@ -162,12 +162,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cellType = getTypeByCellElement(target);
|
const cellType = getTypeByCellElement(target);
|
||||||
if (viewType === "gallery") {
|
if (viewType === "table") {
|
||||||
const itemElement = hasClosestByClassName(target, "av__gallery-item");
|
|
||||||
if (itemElement && cellType !== "updated" && cellType !== "created" && cellType !== "lineNumber") {
|
|
||||||
popTextCell(protyle, [target]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const scrollElement = hasClosestByClassName(target, "av__scroll");
|
const scrollElement = hasClosestByClassName(target, "av__scroll");
|
||||||
if (!scrollElement) {
|
if (!scrollElement) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -176,7 +171,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
if (!rowElement) {
|
if (!rowElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO 点击单元格的时候, lineNumber 选中整行
|
|
||||||
if (cellType === "updated" || cellType === "created" || cellType === "lineNumber") {
|
if (cellType === "updated" || cellType === "created" || cellType === "lineNumber") {
|
||||||
selectRow(rowElement.querySelector(".av__firstcol"), "toggle");
|
selectRow(rowElement.querySelector(".av__firstcol"), "toggle");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -187,6 +181,11 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
|
||||||
updateHeader(rowElement);
|
updateHeader(rowElement);
|
||||||
popTextCell(protyle, [target]);
|
popTextCell(protyle, [target]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const itemElement = hasClosestByClassName(target, "av__gallery-item");
|
||||||
|
if (itemElement && cellType !== "updated" && cellType !== "created" && cellType !== "lineNumber") {
|
||||||
|
popTextCell(protyle, [target]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -834,7 +833,7 @@ export const updateAttrViewCellAnimation = (cellElement: HTMLElement, value: IAV
|
||||||
}
|
}
|
||||||
const viewType = blockElement.getAttribute("data-av-type") as TAVView;
|
const viewType = blockElement.getAttribute("data-av-type") as TAVView;
|
||||||
const iconElement = cellElement.querySelector(".b3-menu__avemoji");
|
const iconElement = cellElement.querySelector(".b3-menu__avemoji");
|
||||||
if (viewType === "gallery") {
|
if (["gallery", "kanban"].includes(viewType)) {
|
||||||
if (value.type === "checkbox") {
|
if (value.type === "checkbox") {
|
||||||
value.checkbox = {
|
value.checkbox = {
|
||||||
checked: value.checkbox?.checked || false,
|
checked: value.checkbox?.checked || false,
|
||||||
|
|
|
||||||
|
|
@ -996,7 +996,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru
|
||||||
});
|
});
|
||||||
} else if (cellValue.type === "checkbox") {
|
} 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>`;
|
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 += `<span class="fn__space"></span>${cellValue?.checkbox?.content}`;
|
||||||
}
|
}
|
||||||
text += "</div>";
|
text += "</div>";
|
||||||
|
|
@ -1223,7 +1223,7 @@ export const cellValueIsEmpty = (value: IAVCellValue) => {
|
||||||
return !value[value.type as "text"]?.content;
|
return !value[value.type as "text"]?.content;
|
||||||
}
|
}
|
||||||
if (value.type === "number") {
|
if (value.type === "number") {
|
||||||
return !value.number?.isNotEmpty;
|
return value.number ? !value.number.isNotEmpty : true;
|
||||||
}
|
}
|
||||||
if (["mSelect", "mAsset", "select"].includes(value.type)) {
|
if (["mSelect", "mAsset", "select"].includes(value.type)) {
|
||||||
if (value[(value.type === "select" ? "mSelect" : value.type) as "mSelect"]?.length > 0) {
|
if (value[(value.type === "select" ? "mSelect" : value.type) as "mSelect"]?.length > 0) {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import {hasClosestByClassName} from "../../util/hasClosest";
|
||||||
export const getColId = (element: Element, viewType: TAVView) => {
|
export const getColId = (element: Element, viewType: TAVView) => {
|
||||||
if (viewType === "table" || hasClosestByClassName(element, "custom-attr")) {
|
if (viewType === "table" || hasClosestByClassName(element, "custom-attr")) {
|
||||||
return element.getAttribute("data-col-id");
|
return element.getAttribute("data-col-id");
|
||||||
} else if (viewType === "gallery") {
|
} else if (["gallery", "kanban"].includes(viewType)) {
|
||||||
return element.getAttribute("data-field-id");
|
return element.getAttribute("data-field-id");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -178,24 +178,6 @@ export const bindLayoutEvent = (options: {
|
||||||
if (options.data.viewType === "table") {
|
if (options.data.viewType === "table") {
|
||||||
return;
|
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;
|
const toggleFitElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-fit"]') as HTMLInputElement;
|
||||||
toggleFitElement.addEventListener("change", () => {
|
toggleFitElement.addEventListener("change", () => {
|
||||||
const avID = options.blockElement.getAttribute("data-av-id");
|
const avID = options.blockElement.getAttribute("data-av-id");
|
||||||
|
|
@ -232,6 +214,27 @@ export const bindLayoutEvent = (options: {
|
||||||
}]);
|
}]);
|
||||||
(options.data.view as IAVGallery).displayFieldName = checked;
|
(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: {
|
export const updateLayout = async (options: {
|
||||||
|
|
|
||||||
|
|
@ -600,11 +600,12 @@ export const openMenuPanel = (options: {
|
||||||
hideElements(["util"], options.protyle);
|
hideElements(["util"], options.protyle);
|
||||||
} else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
|
} else if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
|
||||||
// 过滤面板先关闭过滤条件
|
// 过滤面板先关闭过滤条件
|
||||||
window.siyuan.menus.menu.remove();
|
|
||||||
} else {
|
} else {
|
||||||
closeCB?.();
|
closeCB?.();
|
||||||
avPanelElement.remove();
|
avPanelElement.remove();
|
||||||
focusBlock(options.blockElement);
|
setTimeout(() => {
|
||||||
|
focusBlock(options.blockElement);
|
||||||
|
}, Constants.TIMEOUT_TRANSITION); // 单选使用 enter 修改选项后会滚动
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue