From d77d29cf78ac8248d096573af4d6fba3e9613000 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 27 Jun 2025 10:21:16 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/15092 --- app/src/protyle/render/av/layout.ts | 15 --------------- app/src/protyle/render/av/render.ts | 18 ++++++++++++++++++ app/src/protyle/wysiwyg/transaction.ts | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.ts index 5a6df885b..afcdc236b 100644 --- a/app/src/protyle/render/av/layout.ts +++ b/app/src/protyle/render/av/layout.ts @@ -114,21 +114,6 @@ export const bindLayoutEvent = (options: { blockID, data: checked }]); - if (checked) { - options.blockElement.querySelector(".av__title").classList.remove("fn__none"); - } else { - // hide - options.blockElement.querySelector(".av__title").classList.add("fn__none"); - } - if (options.data.viewType === "gallery") { - const galleryElement = options.blockElement.querySelector(".av__gallery"); - if (checked) { - galleryElement.classList.remove("av__gallery--top"); - } else { - // hide - galleryElement.classList.add("av__gallery--top"); - } - } }); if (options.data.viewType !== "gallery") { return; diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 3f118bba5..b433411ab 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -485,6 +485,24 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => { coverItem.className = "av__gallery-cover av__gallery-cover--" + operation.data; }); }); + } else if (operation.action === "hideAttrViewName") { + Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { + if (!operation.data) { + item.querySelector(".av__title").classList.remove("fn__none"); + } else { + // hide + item.querySelector(".av__title").classList.add("fn__none"); + } + if (item.getAttribute("data-av-type") === "gallery") { + const galleryElement = item.querySelector(".av__gallery"); + if (!operation.data) { + galleryElement.classList.remove("av__gallery--top"); + } else { + // hide + galleryElement.classList.add("av__gallery--top"); + } + } + }); } else { // 修改表格名 avID 传入到 id 上了 https://github.com/siyuan-note/siyuan/issues/12724 const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID; diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index b795c7473..c5eb6244e 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -854,7 +854,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo: "removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView", "updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup", "sortAttrViewKey", "setAttrViewColDesc", "duplicateAttrViewKey", "setAttrViewViewDesc", "setAttrViewCoverFrom", "setAttrViewCoverFromAssetKeyID", - "setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio"].includes(operation.action)) { + "setAttrViewBlockView", "setAttrViewCardSize", "setAttrViewCardAspectRatio", "hideAttrViewName"].includes(operation.action)) { if (!isUndo) { // 撤销 transaction 会进行推送,需使用推送来进行刷新最新数据 https://github.com/siyuan-note/siyuan/issues/13607 refreshAV(protyle, operation);