Skip to content

Commit

Permalink
🎨 fix #10678
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Apr 24, 2024
1 parent 92bc52c commit 421297d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions app/src/protyle/render/av/blockAttr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
import {unicode2Emoji} from "../../../emoji";
import {transaction} from "../../wysiwyg/transaction";
import {openMenuPanel} from "./openMenuPanel";
import {uploadFiles} from "../../upload";

const genAVRollupHTML = (value: IAVCellValue) => {
let html = "";
Expand Down Expand Up @@ -274,6 +275,12 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
window.siyuan.dragElement = undefined;
}
});
element.addEventListener("paste", (event) => {
const files = event.clipboardData.files;
if (document.querySelector(".av__panel .b3-form__upload") && files && files.length > 0) {
uploadFiles(protyle, files);
}
})
element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
const blockElement = hasClosestBlock(target);
Expand All @@ -293,6 +300,11 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
event.preventDefault();
break;
} else if (type === "mAsset") {
element.querySelectorAll('.custom-attr__avvalue[data-type="mAsset"]').forEach(item => {
item.removeAttribute("data-active");
})
target.setAttribute("data-active", "true");
target.focus();
popTextCell(protyle, [target], "mAsset");
event.stopPropagation();
event.preventDefault();
Expand Down
15 changes: 9 additions & 6 deletions app/src/protyle/upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
}

if (document.querySelector(".av__panel")) {
const cellElements: HTMLElement[] = [];
protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
if (getTypeByCellElement(item) === "mAsset") {
cellElements.push(item);
}
});
const cellElements: HTMLElement[] = [document.querySelector('.custom-attr__avvalue[data-type="mAsset"][data-active="true"]')];
if (!cellElements[0]) {
cellElements.splice(0, 1);
protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
if (getTypeByCellElement(item) === "mAsset") {
cellElements.push(item);
}
});
}
if (cellElements.length > 0) {
const blockElement = hasClosestBlock(cellElements[0]);
if (blockElement) {
Expand Down

0 comments on commit 421297d

Please sign in to comment.