Vanessa 2025-06-30 12:26:47 +08:00
parent 751e10196c
commit c9eae83501
3 changed files with 19 additions and 5 deletions

View file

@ -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>

View file

@ -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]);

View file

@ -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;
}
}