This commit is contained in:
Vanessa 2023-09-22 20:40:28 +08:00
parent 643d5e82c5
commit a55b980512
4 changed files with 59 additions and 46 deletions

View file

@ -13,6 +13,7 @@ import {hideElements} from "../../ui/hideElements";
import {focusByRange} from "../../util/selection"; import {focusByRange} from "../../util/selection";
import {writeText} from "../../util/compatibility"; import {writeText} from "../../util/compatibility";
import {showMessage} from "../../../dialog/message"; import {showMessage} from "../../../dialog/message";
import {previewImage} from "../../preview/image";
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => { export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
const blockElement = hasClosestBlock(event.target); const blockElement = hasClosestBlock(event.target);
@ -118,13 +119,23 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
const linkElement = hasClosestByClassName(event.target, "av__celltext--url"); const linkElement = hasClosestByClassName(event.target, "av__celltext--url");
if (linkElement) { if (linkElement) {
let prefix = ""; let linkAddress = linkElement.textContent.trim();
if (linkElement.dataset.type === "phone") { if (linkElement.dataset.type === "phone") {
prefix = "tel:"; linkAddress = "tel:" + linkAddress;
} else if (linkElement.dataset.type === "email") { } else if (linkElement.dataset.type === "email") {
prefix = "mailto:"; linkAddress = "mailto:" + linkAddress;
} else if (linkElement.classList.contains("b3-chip")) {
linkAddress = linkElement.dataset.url;
} }
window.open(prefix + linkElement.textContent.trim()); window.open(linkAddress);
event.preventDefault();
event.stopPropagation();
return true;
}
const imgElement = hasClosestByClassName(event.target, "av__cellassetimg") as HTMLImageElement
if (imgElement) {
previewImage(imgElement.src);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
return true; return true;

View file

@ -379,6 +379,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
}); });
} }
}); });
if (type !== "mAsset") {
menu.addItem({ menu.addItem({
icon: "iconFilter", icon: "iconFilter",
label: window.siyuan.languages.filter, label: window.siyuan.languages.filter,
@ -421,6 +422,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
}); });
} }
}); });
}
menu.addSeparator(); menu.addSeparator();
if (type !== "block") { if (type !== "block") {
menu.addItem({ menu.addItem({

View file

@ -301,7 +301,7 @@ export const addFilter = (options: {
return true; return true;
} }
}); });
if (!hasFilter) { if (!hasFilter && column.type !== "mAsset") {
menu.addItem({ menu.addItem({
label: column.name, label: column.name,
icon: getColIconByType(column.type), icon: getColIconByType(column.type),

View file

@ -103,7 +103,7 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
if (item.type === "image") { if (item.type === "image") {
text += `<img class="av__cellassetimg" src="${item.content}">`; text += `<img class="av__cellassetimg" src="${item.content}">`;
} else { } else {
text += `<span class="b3-chip b3-chip--middle" data-url="${item.content}">${item.name}</span>`; text += `<span class="b3-chip b3-chip--middle av__celltext--url" data-url="${item.content}">${item.name}</span>`;
} }
}); });
if (!text) { if (!text) {