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/12044 1 & 2

Vanessa85f6ecc20508
diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts
index ef23756f81..230916cd9e 100644
--- a/app/src/protyle/render/av/blockAttr.ts
+++ b/app/src/protyle/render/av/blockAttr.ts
@@ -8,6 +8,8 @@ import {unicode2Emoji} from "../../../emoji";
import {transaction} from "../../wysiwyg/transaction";
import {openMenuPanel} from "./openMenuPanel";
import {uploadFiles} from "../../upload";
+import {openLink} from "../../../editor/openLink";
+import {editAssetItem} from "./asset";
const genAVRollupHTML = (value: IAVCellValue) => {
let html = "";
@@ -72,7 +74,7 @@ export const genAVValueHTML = (value: IAVCellValue) => {
if (item.type === "image") {
html += `<img class="av__cellassetimg" src="${item.content}">`;
} else {
- html += `<span class="b3-chip b3-chip--middle av__celltext--url" data-url="${item.content}">${item.name}</span>`;
+ html += `<span class="b3-chip b3-chip--middle av__celltext--url" data-url="${item.content}" data-name="${item.name}">${item.name}</span>`;
}
});
break;
@@ -345,7 +347,32 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
}
while (target && !element.isSameNode(target)) {
const type = target.getAttribute("data-type");
- if (type === "date") {
+ if (target.classList.contains("av__celltext--url") || target.classList.contains("av__cellassetimg")) {
+ if (event.type === "contextmenu") {
+ let index = 0;
+ Array.from(target.parentElement.children).find((item, i) => {
+ if (item.isSameNode(target)) {
+ index = i;
+ return true;
+ }
+ });
+ editAssetItem({
+ protyle,
+ cellElements: [target.parentElement],
+ blockElement: hasClosestBlock(target) as HTMLElement,
+ content: target.tagName === "IMG" ? target.getAttribute("src") : target.getAttribute("data-url"),
+ type: target.tagName === "IMG" ? "image" : "file",
+ name: target.tagName === "IMG" ? "" : target.getAttribute("data-name"),
+ index,
+ rect: target.getBoundingClientRect()
+ });
+ } else {
+ openLink(protyle, target.dataset.url, event, event.ctrlKey || event.metaKey);
+ }
+ event.stopPropagation();
+ event.preventDefault();
+ break;
+ } else if (type === "date") {
popTextCell(protyle, [target], "date");
event.stopPropagation();
event.preventDefault();
diff --git a/app/src/util/escape.ts b/app/src/util/escape.ts
index c8e52b5752..e9471515cf 100644
--- a/app/src/util/escape.ts
+++ b/app/src/util/escape.ts
@@ -10,6 +10,9 @@ export const escapeGreat = (html: string) => {
};
export const escapeAttr = (html: string) => {
+ if (!html) {
+ return html;
+ }
return html.replace(/"/g, "&quot;").replace(/'/g, "&apos;");
};