diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts index ef23756f8..230916cd9 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 += ``; } else { - html += `${item.name}`; + html += `${item.name}`; } }); 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 c8e52b575..e9471515c 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, """).replace(/'/g, "'"); };