Skip to content

Commit 3897b52

Browse files
committed
fix: remove default values for link target and title
1 parent 4a10953 commit 3897b52

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/pluggableWidgets/rich-text-web/src/utils/formats/link.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ export default class CustomLink extends Link {
2525
const linkConfig = value as linkConfigType;
2626
// @ts-expect-error the constructor is generic function, ts will consider sanitize not exist
2727
this.domNode.setAttribute("href", getLink(this.constructor.sanitize(linkConfig.href)));
28-
this.domNode.setAttribute("target", linkConfig.target ?? "_blank");
29-
this.domNode.setAttribute("title", linkConfig.title ?? "");
3028
this.domNode.textContent = linkConfig.text ?? linkConfig.href;
29+
if (linkConfig.target) {
30+
this.domNode.setAttribute("target", linkConfig.target);
31+
}
32+
if (linkConfig.title) {
33+
this.domNode.setAttribute("title", linkConfig.title);
34+
}
3135
} else {
3236
// @ts-expect-error the constructor is generic function, ts will consider sanitize not exist
3337
this.domNode.setAttribute("href", getLink(this.constructor.sanitize(value)));

packages/pluggableWidgets/rich-text-web/src/utils/modules/clipboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ function customMatchText(node: HTMLElement, delta: Delta, scroll: ScrollBlot): D
120120
function matchLink(node: HTMLElement, _delta: Delta): Delta {
121121
const href = node.getAttribute("href");
122122
const text = node.textContent || href || "";
123-
const title = node.getAttribute("title") || text;
124-
const target = node.getAttribute("target") || "_blank";
123+
const title = node.getAttribute("title");
124+
const target = node.getAttribute("target");
125125
const value = { href, text, title, target };
126126
return new Delta().insert(text, { link: value });
127127
}

0 commit comments

Comments
 (0)