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/15179

Vanessac9eae8350138
diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.ts
index 09bc55bf33..cc412f19b4 100644
--- a/app/src/protyle/render/av/asset.ts
+++ b/app/src/protyle/render/av/asset.ts
@@ -72,7 +72,11 @@ ${contentHTML}
<svg class="b3-menu__action" data-type="editAssetItem"><use xlink:href="#iconEdit"></use></svg>
</button>`;
});
- return `<div class="b3-menu__items">
+ const ids: string[] = [];
+ cellElements.forEach(item => {
+ ids.push(item.dataset.id);
+ });
+ return `<div class="b3-menu__items" data-ids="${ids}">
${html}
<button data-type="addAssetExist" class="b3-menu__item b3-menu__item--current">
<svg class="b3-menu__icon"><use xlink:href="#iconImage"></use></svg>
diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.ts
index ec89ab218c..c769cf4a50 100644
--- a/app/src/protyle/upload/index.ts
+++ b/app/src/protyle/upload/index.ts
@@ -159,6 +159,14 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
cellElements.push(item);
}
});
+ if (cellElements.length === 0) {
+ document.querySelector(".av__panel .b3-menu__items")?.getAttribute("data-ids")?.split(",").forEach((id: string) => {
+ const item = protyle.wysiwyg.element.querySelector(`.av__gallery-fields [data-dtype="mAsset"][data-id="${id}"]`) as HTMLElement;
+ if (item) {
+ cellElements.push(item);
+ }
+ });
+ }
}
if (cellElements.length > 0) {
const blockElement = hasClosestBlock(cellElements[0]);
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index b8d898ae87..f57a893a6f 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -31,7 +31,7 @@ import {zoomOut} from "../../menus/protyle";
/// #if !BROWSER
import {webUtils} from "electron";
/// #endif
-import {addDragFill} from "../render/av/cell";
+import {addDragFill, getTypeByCellElement} from "../render/av/cell";
import {processClonePHElement} from "../render/util";
import {insertGalleryItemAnimation} from "../render/av/gallery/item";
import {clearSelect} from "./clearSelect";
@@ -1316,13 +1316,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
} else {
const cellElement = hasClosestByClassName(event.target, "av__cell");
if (cellElement) {
- const cellType = avElement.querySelector(`.av__row--header [data-col-id="${cellElement.dataset.colId}"]`)?.getAttribute("data-dtype");
- if (cellType === "mAsset" && event.dataTransfer.types[0] === "Files" && !isBrowser()) {
+ if (getTypeByCellElement(cellElement) === "mAsset" && event.dataTransfer.types[0] === "Files" && !isBrowser()) {
const files: string[] = [];
for (let i = 0; i < event.dataTransfer.files.length; i++) {
files.push(webUtils.getPathForFile(event.dataTransfer.files[i]));
}
dragUpload(files, protyle, cellElement);
+ clearSelect(["cell"], avElement);
}
}
}
@@ -1362,7 +1362,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (blockElement) {
clearSelect(["cell", "row"], protyle.wysiwyg.element);
targetElement.classList.add("av__cell--select");
- addDragFill(targetElement);
+ if (blockElement.getAttribute("data-av-type") !== "gallery") {
+ addDragFill(targetElement);
+ }
dragoverElement = targetElement;
}
}