This commit is contained in:
Jeffrey Chen 2025-12-16 10:56:48 +08:00 committed by GitHub
commit 99ef1d39c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 12 additions and 12 deletions

View file

@ -26,7 +26,7 @@ export const unicode2Emoji = (unicode: string, className = "", needSpan = false,
} }
let emoji = ""; let emoji = "";
if (unicode.startsWith("api/icon/getDynamicIcon")) { if (unicode.startsWith("api/icon/getDynamicIcon")) {
emoji = `<img class="${className}" ${lazy ? "data-" : ""}src="${unicode}"/>`; emoji = `<img class="${className}" ${lazy ? "data-" : ""}src="${unicode}" data-src="${unicode}"/>`;
} else if (unicode.indexOf(".") > -1) { } else if (unicode.indexOf(".") > -1) {
emoji = `<img class="${className}" ${lazy ? "data-" : ""}src="/emojis/${unicode}"/>`; emoji = `<img class="${className}" ${lazy ? "data-" : ""}src="/emojis/${unicode}"/>`;
} else { } else {

View file

@ -295,7 +295,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true; return true;
} else if (target.classList.contains("av__cellassetimg")) { } else if (target.classList.contains("av__cellassetimg")) {
previewAttrViewImages( previewAttrViewImages(
removeCompressURL((target as HTMLImageElement).getAttribute("src")), (target as HTMLImageElement).getAttribute("data-src") || removeCompressURL((target as HTMLImageElement).getAttribute("src")),
blockElement.getAttribute("data-av-id"), blockElement.getAttribute("data-av-id"),
blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW), blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
(blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement)?.value.trim() || "" (blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement)?.value.trim() || ""

View file

@ -61,7 +61,7 @@ export const getAssetHTML = (cellElements: HTMLElement[]) => {
let contentHTML; let contentHTML;
if (item.type === "image") { if (item.type === "image") {
contentHTML = `<span data-type="openAssetItem" class="fn__flex-1 ariaLabel" aria-label="${item.content}"> contentHTML = `<span data-type="openAssetItem" class="fn__flex-1 ariaLabel" aria-label="${item.content}">
<img style="max-height: 180px;max-width: 360px;border-radius: var(--b3-border-radius);margin: 4px 0;" src="${getCompressURL(item.content)}"/> <img style="max-height: 180px;max-width: 360px;border-radius: var(--b3-border-radius);margin: 4px 0;" src="${getCompressURL(item.content)}" data-src="${item.content}"/>
</span>`; </span>`;
} else { } else {
contentHTML = `<span data-type="openAssetItem" class="fn__ellipsis b3-menu__label ariaLabel" aria-label="${escapeAttr(item.content)}" style="max-width: 360px">${item.name || item.content}</span>`; contentHTML = `<span data-type="openAssetItem" class="fn__ellipsis b3-menu__label ariaLabel" aria-label="${escapeAttr(item.content)}" style="max-width: 360px">${item.name || item.content}</span>`;

View file

@ -16,7 +16,7 @@ import {webUtils} from "electron";
/// #endif /// #endif
import {isBrowser} from "../../../util/functions"; import {isBrowser} from "../../../util/functions";
import {Constants} from "../../../constants"; import {Constants} from "../../../constants";
import {getCompressURL} from "../../../util/image"; import {getCompressURL, removeCompressURL} from "../../../util/image";
const genAVRollupHTML = (value: IAVCellValue) => { const genAVRollupHTML = (value: IAVCellValue) => {
let html = ""; let html = "";
@ -90,7 +90,7 @@ export const genAVValueHTML = (value: IAVCellValue) => {
case "mAsset": case "mAsset":
value.mAsset?.forEach(item => { value.mAsset?.forEach(item => {
if (item.type === "image") { if (item.type === "image") {
html += `<img loading="lazy" class="av__cellassetimg ariaLabel" aria-label="${item.content}" src="${getCompressURL(item.content)}">`; html += `<img loading="lazy" class="av__cellassetimg ariaLabel" aria-label="${item.content}" src="${getCompressURL(item.content)}" data-src="${item.content}">`;
} else { } else {
html += `<span class="b3-chip b3-chip--middle av__celltext--url ariaLabel" aria-label="${escapeAttr(item.content)}" data-name="${escapeAttr(item.name)}" data-url="${escapeAttr(item.content)}">${item.name || item.content}</span>`; html += `<span class="b3-chip b3-chip--middle av__celltext--url ariaLabel" aria-label="${escapeAttr(item.content)}" data-name="${escapeAttr(item.name)}" data-url="${escapeAttr(item.content)}">${item.name || item.content}</span>`;
} }
@ -491,7 +491,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
protyle, protyle,
cellElements: [target.parentElement], cellElements: [target.parentElement],
blockElement: hasClosestBlock(target) as HTMLElement, blockElement: hasClosestBlock(target) as HTMLElement,
content: target.tagName === "IMG" ? target.getAttribute("src") : target.getAttribute("data-url"), content: target.tagName === "IMG" ? (target.getAttribute("data-src") || target.getAttribute("src")) : target.getAttribute("data-url"),
type: target.tagName === "IMG" ? "image" : "file", type: target.tagName === "IMG" ? "image" : "file",
name: target.tagName === "IMG" ? "" : target.getAttribute("data-name"), name: target.tagName === "IMG" ? "" : target.getAttribute("data-name"),
index, index,
@ -499,7 +499,7 @@ const openEdit = (protyle: IProtyle, element: HTMLElement, event: MouseEvent) =>
}); });
} else { } else {
if (target.tagName === "IMG") { if (target.tagName === "IMG") {
previewImages([target.getAttribute("src")]); previewImages([target.getAttribute("data-src") || removeCompressURL(target.getAttribute("src"))]);
} else { } else {
openLink(protyle, target.dataset.url, event, event.ctrlKey || event.metaKey); openLink(protyle, target.dataset.url, event, event.ctrlKey || event.metaKey);
} }

View file

@ -131,7 +131,7 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)
const isImg = item.classList.contains("av__cellassetimg"); const isImg = item.classList.contains("av__cellassetimg");
mAsset.push({ mAsset.push({
type: isImg ? "image" : "file", type: isImg ? "image" : "file",
content: isImg ? removeCompressURL(item.getAttribute("src")) : item.getAttribute("data-url"), content: isImg ? (item.getAttribute("data-src") || removeCompressURL(item.getAttribute("src"))) : item.getAttribute("data-url"),
name: isImg ? "" : item.getAttribute("data-name") name: isImg ? "" : item.getAttribute("data-name")
}); });
}); });
@ -989,7 +989,7 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru
} else if (cellValue.type === "mAsset") { } else if (cellValue.type === "mAsset") {
cellValue?.mAsset?.forEach((item) => { cellValue?.mAsset?.forEach((item) => {
if (item.type === "image") { if (item.type === "image") {
text += `<img loading="lazy" class="av__cellassetimg ariaLabel" aria-label="${item.content}" src="${getCompressURL(item.content)}">`; text += `<img loading="lazy" class="av__cellassetimg ariaLabel" aria-label="${item.content}" src="${getCompressURL(item.content)}" data-src="${item.content}">`;
} else { } else {
text += `<span class="b3-chip av__celltext--url ariaLabel" aria-label="${escapeAttr(item.content)}" data-name="${escapeAttr(item.name)}" data-url="${escapeAttr(item.content)}">${item.name || item.content}</span>`; text += `<span class="b3-chip av__celltext--url ariaLabel" aria-label="${escapeAttr(item.content)}" data-name="${escapeAttr(item.name)}" data-url="${escapeAttr(item.content)}">${item.name || item.content}</span>`;
} }

View file

@ -2577,7 +2577,7 @@ export class WYSIWYG {
this.element.addEventListener("dblclick", (event: MouseEvent & { target: HTMLElement }) => { this.element.addEventListener("dblclick", (event: MouseEvent & { target: HTMLElement }) => {
if (event.target.tagName === "IMG" && !event.target.classList.contains("emoji")) { if (event.target.tagName === "IMG" && !event.target.classList.contains("emoji")) {
previewDocImage((event.target as HTMLElement).getAttribute("src"), protyle.block.rootID); previewDocImage((event.target as HTMLElement).getAttribute("data-src") || (event.target as HTMLElement).getAttribute("src"), protyle.block.rootID);
return; return;
} }
}); });
@ -3064,7 +3064,7 @@ export class WYSIWYG {
const oldHTML = nodeElement.outerHTML; const oldHTML = nodeElement.outerHTML;
let emojiHTML; let emojiHTML;
if (unicode.startsWith("api/icon/getDynamicIcon")) { if (unicode.startsWith("api/icon/getDynamicIcon")) {
emojiHTML = `<img class="callout-img" src="${unicode}"/>`; emojiHTML = `<img class="callout-img" src="${unicode}" data-src="${unicode}"/>`;
} else if (unicode.indexOf(".") > -1) { } else if (unicode.indexOf(".") > -1) {
emojiHTML = `<img class="callout-img" src="/emojis/${unicode}">`; emojiHTML = `<img class="callout-img" src="/emojis/${unicode}">`;
} else { } else {
@ -3096,7 +3096,7 @@ export class WYSIWYG {
const oldHTML = nodeElement.outerHTML; const oldHTML = nodeElement.outerHTML;
let emojiHTML; let emojiHTML;
if (unicode.startsWith("api/icon/getDynamicIcon")) { if (unicode.startsWith("api/icon/getDynamicIcon")) {
emojiHTML = `<img class="emoji" src="${unicode}"/>`; emojiHTML = `<img class="emoji" src="${unicode}" data-src="${unicode}"/>`;
} else if (unicode.indexOf(".") > -1) { } else if (unicode.indexOf(".") > -1) {
const emojiList = unicode.split("."); const emojiList = unicode.split(".");
emojiHTML = `<img alt="${emojiList[0]}" class="emoji" src="/emojis/${unicode}" title="${emojiList[0]}">`; emojiHTML = `<img alt="${emojiList[0]}" class="emoji" src="/emojis/${unicode}" title="${emojiList[0]}">`;