Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/10414

Vanessad362524d0e2a
diff --git a/app/src/protyle/render/av/gallery/util.ts b/app/src/protyle/render/av/gallery/util.ts
index dcda781035..b4317a6d43 100644
--- a/app/src/protyle/render/av/gallery/util.ts
+++ b/app/src/protyle/render/av/gallery/util.ts
@@ -227,6 +227,7 @@ export const openGalleryItemMenu = (options: {
target: HTMLElement,
blockElement: HTMLElement,
protyle: IProtyle,
+ returnMenu: boolean
}) => {
const menu = new Menu();
const avID = options.blockElement.getAttribute("data-av-id");
@@ -267,6 +268,9 @@ export const openGalleryItemMenu = (options: {
}
}
});
+ if (options.returnMenu) {
+ return menu;
+ }
const rect = options.target.getBoundingClientRect();
menu.open({
x: rect.left,
diff --git a/app/src/protyle/render/av/view.ts b/app/src/protyle/render/av/view.ts
index 5485d3996f..f73aca662b 100644
--- a/app/src/protyle/render/av/view.ts
+++ b/app/src/protyle/render/av/view.ts
@@ -291,7 +291,7 @@ export const getSwitcherHTML = (views: IAVView[], viewId: string) => {
html += `<button draggable="true" class="b3-menu__item${item.id === viewId ? " b3-menu__item--current" : ""}" data-id="${item.id}">
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="b3-menu__label fn__flex" data-type="av-view-switch" data-av-type="${item.type}">
- ${item.icon ? unicode2Emoji(item.icon, "b3-menu__icon", true) : '<svg class="b3-menu__icon"><use xlink:href="#iconTable"></use></svg>'}
+ ${item.icon ? unicode2Emoji(item.icon, "b3-menu__icon", true) : `<svg class="b3-menu__icon"><use xlink:href="#${getViewIcon(item.type)}"></use></svg>`}
<span class="fn__ellipsis">${item.name}</span>
</div>
<svg class="b3-menu__action" data-type="av-view-edit"><use xlink:href="#iconEdit"></use></svg>
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 7153940786..a4d217cf54 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -98,6 +98,7 @@ import {editAssetItem} from "../render/av/asset";
import {img3115} from "../../boot/compatibleVersion";
import {globalClickHideMenu} from "../../boot/globalEvent/click";
import {hideTooltip} from "../../dialog/tooltip";
+import {openGalleryItemMenu} from "../render/av/gallery/util";
export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
@@ -1794,6 +1795,23 @@ export class WYSIWYG {
if (!nodeElement) {
return false;
}
+ const avGalleryItemElement = hasClosestByClassName(target, "av__gallery-item");
+ if (avGalleryItemElement) {
+ avGalleryItemElement.classList.add("av__gallery-item--select");
+ const menu = openGalleryItemMenu({
+ target: avGalleryItemElement.querySelector('.protyle-icon--last'),
+ blockElement: nodeElement,
+ protyle,
+ returnMenu: true
+ });
+ menu.open({
+ x: event.clientX,
+ y: event.clientY
+ });
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
const avCellElement = hasClosestByClassName(target, "av__cell");
if (avCellElement) {
if (avCellElement.classList.contains("av__cell--header")) {