From 8853b9a1923479417b78cffe5f2398faccf78ef5 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 31 Mar 2024 09:58:50 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/10789 --- app/src/protyle/render/av/cell.ts | 10 ++++++---- app/src/protyle/wysiwyg/index.ts | 9 +-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index c444bc38971..16ebcdd2be6 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -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 地址 diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 831f7dac02c..2219bd31216 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -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();