Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/rich-text-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Fixed

- We fixed an issue where hyperlink tag does not read target attribute when edited from code viewer.

## [4.11.1] - 2026-01-27

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ export default class CustomLink extends Link {
const linkConfig = value as linkConfigType;
// @ts-expect-error the constructor is generic function, ts will consider sanitize not exist
this.domNode.setAttribute("href", getLink(this.constructor.sanitize(linkConfig.href)));
this.domNode.setAttribute("target", linkConfig.target ?? "_blank");
this.domNode.setAttribute("title", linkConfig.title ?? "");
this.domNode.textContent = linkConfig.text ?? linkConfig.href;
if (linkConfig.target) {
this.domNode.setAttribute("target", linkConfig.target);
}
if (linkConfig.title) {
this.domNode.setAttribute("title", linkConfig.title);
}
} else {
// @ts-expect-error the constructor is generic function, ts will consider sanitize not exist
this.domNode.setAttribute("href", getLink(this.constructor.sanitize(value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class CustomClipboard extends Clipboard {
this.matchers.unshift([Node.TEXT_NODE, customMatchText]);
// add custom list matchers for ol and ul to allow custom list types (lower-alpha, lower-roman, etc.)
this.addMatcher("ol, ul", matchList);
this.addMatcher("a", matchLink);
}
}

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

function matchLink(node: HTMLElement, _delta: Delta): Delta {
const href = node.getAttribute("href");
const text = node.textContent || href || "";
const title = node.getAttribute("title");
const target = node.getAttribute("target");
const value = { href, text, title, target };
return new Delta().insert(text, { link: value });
}

function matchList(node: HTMLElement, delta: Delta): Delta {
const format = "list";
let list = "ordered";
Expand Down
Loading