Skip to content

Commit 4a10953

Browse files
committed
fix: hyperlink does not read attribute from clipboard
1 parent 030a749 commit 4a10953

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/pluggableWidgets/rich-text-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue where hyperlink tag does not read target attribute when edited from code viewer.
12+
913
## [4.11.1] - 2026-01-27
1014

1115
### Fixed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class CustomClipboard extends Clipboard {
2222
this.matchers.unshift([Node.TEXT_NODE, customMatchText]);
2323
// add custom list matchers for ol and ul to allow custom list types (lower-alpha, lower-roman, etc.)
2424
this.addMatcher("ol, ul", matchList);
25+
this.addMatcher("a", matchLink);
2526
}
2627
}
2728

@@ -116,6 +117,15 @@ function customMatchText(node: HTMLElement, delta: Delta, scroll: ScrollBlot): D
116117
return delta.insert(text);
117118
}
118119

120+
function matchLink(node: HTMLElement, _delta: Delta): Delta {
121+
const href = node.getAttribute("href");
122+
const text = node.textContent || href || "";
123+
const title = node.getAttribute("title") || text;
124+
const target = node.getAttribute("target") || "_blank";
125+
const value = { href, text, title, target };
126+
return new Delta().insert(text, { link: value });
127+
}
128+
119129
function matchList(node: HTMLElement, delta: Delta): Delta {
120130
const format = "list";
121131
let list = "ordered";

0 commit comments

Comments
 (0)