Vanessa 2024-03-31 09:58:50 +08:00
parent 487e2f980b
commit 8853b9a192
2 changed files with 7 additions and 12 deletions

View file

@ -18,10 +18,12 @@ const renderCellURL = (urlContent: string) => {
let suffix = "";
try {
const urlObj = new URL(urlContent);
host = urlObj.host;
suffix = urlObj.href.replace(urlObj.origin, "");
if (suffix.length > 12) {
suffix = suffix.substring(0, 4) + "..." + suffix.substring(suffix.length - 6);
if (urlObj.protocol.startsWith("http")) {
host = urlObj.host;
suffix = urlObj.href.replace(urlObj.origin, "");
if (suffix.length > 12) {
suffix = suffix.substring(0, 4) + "..." + suffix.substring(suffix.length - 6);
}
}
} catch (e) {
// 不是 url 地址

View file

@ -1983,14 +1983,7 @@ export class WYSIWYG {
// 需放在嵌入块之前否则嵌入块内的引用、链接、pdf 双链无法点击打开 https://ld246.com/article/1630479789513
const blockRefElement = hasClosestByAttribute(event.target, "data-type", "block-ref");
const aElement = hasClosestByAttribute(event.target, "data-type", "a") || hasClosestByAttribute(event.target, "data-type", "url");
let aLink = "";
if (aElement) {
if (aElement.classList.contains("av__celltext")) {
aLink = aElement.textContent.trim();
} else {
aLink = aElement.getAttribute("data-href");
}
}
const aLink = aElement ? aElement.getAttribute("data-href") : "";
if (blockRefElement || aLink.startsWith("siyuan://blocks/")) {
event.stopPropagation();
event.preventDefault();