Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/10678

Vanessa421297d3380b
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index 2614159305..b9f8406634 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -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 = "";
@@ -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);
@@ -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();
diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.ts
index 25a0c1b300..dbe71bd46a 100644
--- a/app/src/protyle/upload/index.ts
+++ b/app/src/protyle/upload/index.ts
@@ -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) {