Skip to content

Commit

Permalink
🎨 #10789
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Mar 31, 2024
1 parent 487e2f9 commit 8853b9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 6 additions & 4 deletions app/src/protyle/render/av/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 地址
Expand Down
9 changes: 1 addition & 8 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8853b9a

Please sign in to comment.