Vanessa 2025-07-09 23:02:20 +08:00
parent f2e57f7028
commit b8535f23aa
4 changed files with 14 additions and 5 deletions

View file

@ -36,6 +36,7 @@ import {scrollCenter} from "../../../util/highlightById";
import {escapeHtml} from "../../../util/escape";
import {editGalleryItem, openGalleryItemMenu} from "./gallery/util";
import {clearSelect} from "../../util/clearSelect";
import {removeCompressURL} from "../../../util/image";
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
if (isOnlyMeta(event)) {
@ -70,7 +71,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
const imgElement = hasClosestByClassName(event.target, "av__cellassetimg");
if (imgElement) {
previewAttrViewImages(
(imgElement as HTMLImageElement).src,
removeCompressURL((imgElement as HTMLImageElement).src),
blockElement.getAttribute("data-av-id"),
blockElement.getAttribute(Constants.CUSTOM_SY_AV_VIEW),
(blockElement.querySelector('[data-type="av-search"]') as HTMLInputElement)?.value.trim() || ""

View file

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

View file

@ -18,7 +18,7 @@ import {escapeAttr, escapeHtml} from "../../../util/escape";
import {electronUndo} from "../../undo";
import {getFieldIdByCellElement} from "./row";
import {getFieldsByData} from "./view";
import {getCompressURL} from "../../../util/image";
import {getCompressURL, removeCompressURL} from "../../../util/image";
const renderCellURL = (urlContent: string) => {
let host = urlContent;
@ -131,7 +131,7 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)
const isImg = item.classList.contains("av__cellassetimg");
mAsset.push({
type: isImg ? "image" : "file",
content: isImg ? item.getAttribute("src") : item.getAttribute("data-url"),
content: isImg ? removeCompressURL(item.getAttribute("src")) : item.getAttribute("data-url"),
name: isImg ? "" : item.getAttribute("data-name")
});
});

View file

@ -4,3 +4,11 @@ export const getCompressURL = (url: string) => {
return url + "?style=thumb";
}
};
export const removeCompressURL = (url: string) => {
if (url.startsWith("assets/") &&
(url.endsWith(".png?style=thumb") || url.endsWith(".jpg?style=thumb") || url.endsWith(".jpeg?style=thumb"))) {
return url.replace("?style=thumb", "");
}
return url;
};