Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve asset field context menus in database gallery views https://github.com/siyuan-note/siyuan/issues/15673

Daniel6ef00441f160
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 213797bb5d..90ae6b57b3 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -2577,20 +2577,6 @@ export class WYSIWYG {
if (!nodeElement) {
return false;
}
- const avGalleryItemElement = hasClosestByClassName(target, "av__gallery-item");
- if (avGalleryItemElement) {
- openGalleryItemMenu({
- target: avGalleryItemElement.querySelector(".protyle-icon--last"),
- protyle,
- position: {
- x: event.clientX,
- y: event.clientY
- }
- });
- event.stopPropagation();
- event.preventDefault();
- return false;
- }
const avCellElement = hasClosestByClassName(target, "av__cell");
if (avCellElement) {
if (avCellElement.classList.contains("av__cell--header")) {
@@ -2615,11 +2601,11 @@ export class WYSIWYG {
protyle,
cellElements: [avCellElement],
blockElement: hasClosestBlock(assetImgElement) as HTMLElement,
- content: target.tagName === "IMG" ? target.getAttribute("src") : target.getAttribute("data-url"),
- type: target.tagName === "IMG" ? "image" : "file",
- name: target.tagName === "IMG" ? "" : target.getAttribute("data-name"),
+ content: assetImgElement.tagName === "IMG" ? assetImgElement.getAttribute("src") : assetImgElement.getAttribute("data-url"),
+ type: assetImgElement.tagName === "IMG" ? "image" : "file",
+ name: assetImgElement.tagName === "IMG" ? "" : assetImgElement.getAttribute("data-name"),
index,
- rect: target.getBoundingClientRect()
+ rect: assetImgElement.getBoundingClientRect()
});
event.stopPropagation();
event.preventDefault();
@@ -2627,6 +2613,20 @@ export class WYSIWYG {
}
}
}
+ const avGalleryItemElement = hasClosestByClassName(target, "av__gallery-item");
+ if (avGalleryItemElement) {
+ openGalleryItemMenu({
+ target: avGalleryItemElement.querySelector(".protyle-icon--last"),
+ protyle,
+ position: {
+ x: event.clientX,
+ y: event.clientY
+ }
+ });
+ event.stopPropagation();
+ event.preventDefault();
+ return false;
+ }
// 在 span 前面,防止单元格哪 block-ref 被修改
const avRowElement = hasClosestByClassName(target, "av__row");
if (avRowElement && avContextmenu(protyle, avRowElement, {