Vanessa 2025-06-30 15:46:22 +08:00
parent ae823547b4
commit 3e33811194
3 changed files with 25 additions and 15 deletions

View file

@ -131,13 +131,6 @@ export const bindLayoutEvent = (options: {
blockID, blockID,
data: !checked data: !checked
}]); }]);
options.blockElement.querySelectorAll('.av__cell[data-dtype="block"] .b3-menu__avemoji,.av__cell[data-dtype="relation"] .b3-menu__avemoji').forEach(item => {
if (checked) {
item.classList.remove("fn__none");
} else {
item.classList.add("fn__none");
}
});
}); });
const toggleWrapElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-wrap"]') as HTMLInputElement; const toggleWrapElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-gallery-wrap"]') as HTMLInputElement;
toggleWrapElement.addEventListener("change", () => { toggleWrapElement.addEventListener("change", () => {
@ -155,13 +148,6 @@ export const bindLayoutEvent = (options: {
blockID, blockID,
data: !checked data: !checked
}]); }]);
options.blockElement.querySelectorAll(".av__gallery-fields").forEach(item => {
if (checked) {
item.classList.add("av__gallery-fields--wrap");
} else {
item.classList.remove("av__gallery-fields--wrap");
}
});
}); });
if (options.data.viewType !== "gallery") { if (options.data.viewType !== "gallery") {
return; return;

View file

@ -506,6 +506,29 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
} }
} }
}); });
} else if (operation.action === "setAttrViewWrapField") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll(".av__gallery-fields").forEach(fieldItem => {
if (operation.data) {
fieldItem.classList.add("av__gallery-fields--wrap");
} else {
fieldItem.classList.remove("av__gallery-fields--wrap");
}
});
item.querySelectorAll(".av__cell").forEach(fieldItem => {
fieldItem.setAttribute("data-wrap", operation.data.toString());
});
});
} else if (operation.action === "setAttrViewShowIcon") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.querySelectorAll('.av__cell[data-dtype="block"] .b3-menu__avemoji, .av__cell[data-dtype="relation"] .b3-menu__avemoji').forEach(item => {
if (operation.data) {
item.classList.remove("fn__none");
} else {
item.classList.add("fn__none");
}
});
});
} else { } else {
// 修改表格名 avID 传入到 id 上了 https://github.com/siyuan-note/siyuan/issues/12724 // 修改表格名 avID 传入到 id 上了 https://github.com/siyuan-note/siyuan/issues/12724
const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID; const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID;

View file

@ -862,7 +862,8 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView", "removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey", "setAttrViewColDesc", "updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey", "setAttrViewColDesc",
"duplicateAttrViewKey", "setAttrViewViewDesc", "setAttrViewCoverFrom", "setAttrViewCoverFromAssetKeyID", "duplicateAttrViewKey", "setAttrViewViewDesc", "setAttrViewCoverFrom", "setAttrViewCoverFromAssetKeyID",
"setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio", "hideAttrViewName"].includes(operation.action)) { "setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio", "hideAttrViewName", "setAttrViewShowIcon",
"setAttrViewWrapField"].includes(operation.action)) {
if (!isUndo) { if (!isUndo) {
// 撤销 transaction 会进行推送,需使用推送来进行刷新最新数据 https://github.com/siyuan-note/siyuan/issues/13607 // 撤销 transaction 会进行推送,需使用推送来进行刷新最新数据 https://github.com/siyuan-note/siyuan/issues/13607
refreshAV(protyle, operation); refreshAV(protyle, operation);