feat: change database click action (#8937)

This commit is contained in:
zxhd863943427 2023-08-09 21:43:19 +08:00 committed by GitHub
parent 7361429c6f
commit 7f21a05d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 11 deletions

View file

@ -15,6 +15,7 @@ export const initBlockPopover = (app: App) => {
return;
}
const aElement = hasClosestByAttribute(event.target, "data-type", "a", true) ||
hasClosestByAttribute(event.target, "data-type", "url") ||
hasClosestByAttribute(event.target, "data-type", "tab-header") ||
hasClosestByClassName(event.target, "ariaLabel") ||
hasClosestByAttribute(event.target, "data-type", "inline-memo");
@ -207,7 +208,9 @@ export const showPopover = async (app: App, showRef = false) => {
});
ids = postResponse.data;
}
} else if (popoverTargetElement.getAttribute("data-type")?.split(" ").includes("a")) {
} else if (
popoverTargetElement.getAttribute("data-type")?.split(" ").includes("a") ||
popoverTargetElement.getAttribute("data-type")?.split(" ").includes("url")) {
// 以思源协议开头的链接
ids = [getIdFromSYProtocol(popoverTargetElement.getAttribute("data-href"))];
} else {

View file

@ -116,13 +116,16 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
const linkElement = hasClosestByClassName(event.target, "av__celltext--url");
if (linkElement) {
let prefix = "";
if (linkElement.dataset.type === "phone") {
prefix = "tel:";
} else if (linkElement.dataset.type === "email") {
prefix = "mailto:";
}
window.open(prefix + linkElement.textContent.trim());
// let prefix = "";
// if (linkElement.dataset.type === "phone") {
// prefix = "tel:";
// } else if (linkElement.dataset.type === "email") {
// prefix = "mailto:";
// }
// window.open(prefix + linkElement.textContent.trim());
let linkUrl = linkElement.getAttribute("data-href")
window.open(linkUrl.trim());
event.preventDefault();
event.stopPropagation();
return true;

View file

@ -68,8 +68,18 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
let text = "";
if (cell.valueType === "text") {
text = `<span class="av__celltext">${cell.value?.text.content || ""}</span>`;
} else if (["url", "email", "phone"].includes(cell.valueType)) {
text = `<span class="av__celltext av__celltext--url" data-type="${cell.valueType}">${cell.value ? cell.value[cell.valueType as "url"].content : ""}</span>`;
} else if (cell.valueType === "url") {
text = `<span class="av__celltext av__celltext--url" data-type="url" data-href="${cell.value ? cell.value[cell.valueType as "url"].content : ""}">${cell.value ? cell.value[cell.valueType as "url"].content : ""}</span>`;
if (cell.value && cell.value[cell.valueType as "url"].content) {
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}
} else if (cell.valueType === "email") {
text = `<span class="av__celltext av__celltext--url" data-type="email" data-href="${cell.value ? "mailto:" + cell.value[cell.valueType as "url"].content : ""}">${cell.value ? cell.value[cell.valueType as "url"].content : ""}</span>`;
if (cell.value && cell.value[cell.valueType as "url"].content) {
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}
} else if (cell.valueType === "phone") {
text = `<span class="av__celltext av__celltext--url" data-type="phone" data-href="${cell.value ? "tel:" + cell.value[cell.valueType as "url"].content : ""}">${cell.value ? cell.value[cell.valueType as "url"].content : ""}</span>`;
if (cell.value && cell.value[cell.valueType as "url"].content) {
text += `<span data-type="copy" class="b3-tooltips b3-tooltips__n block__icon" aria-label="${window.siyuan.languages.copy}"><svg><use xlink:href="#iconCopy"></use></svg></span>`;
}

View file

@ -1640,7 +1640,8 @@ export class WYSIWYG {
const range = getEditorRange(this.element);
// 需放在嵌入块之前否则嵌入块内的引用、链接、pdf 双链无法点击打开 https://ld246.com/article/1630479789513
const blockRefElement = hasClosestByAttribute(event.target, "data-type", "block-ref");
const aElement = hasClosestByAttribute(event.target, "data-type", "a");
let ifaElement = hasClosestByAttribute(event.target, "data-type", "a");
const aElement = ifaElement ? ifaElement : hasClosestByAttribute(event.target, "data-type", "url")
if (blockRefElement ||
(aElement && aElement.getAttribute("data-href").startsWith("siyuan://blocks/"))
) {