Skip to content

Commit 0a6937f

Browse files
committed
fix: rich text edit link tooltip clipped
1 parent e233008 commit 0a6937f

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

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

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

1313
- We fixed an issue where tab `\t` being removed on save.
1414

15+
- We fixed an issue where link tooltip get clipped by the boundaries of rich text.
16+
1517
## [4.11.0] - 2025-11-06
1618

1719
### Fixed

packages/pluggableWidgets/rich-text-web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@codemirror/lang-html": "^6.4.9",
4747
"@codemirror/state": "^6.5.2",
48+
"@floating-ui/dom": "^1.7.4",
4849
"@floating-ui/react": "^0.26.27",
4950
"@melloware/coloris": "^0.25.0",
5051
"@uiw/codemirror-theme-github": "^4.23.13",

packages/pluggableWidgets/rich-text-web/src/utils/themes/mxTooltip.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import LinkBlot from "quill/formats/link";
44
import { BaseTooltip } from "quill/themes/base";
55
import { linkConfigType } from "../formats";
66
import { ACTION_DISPATCHER } from "../helpers";
7+
import { computePosition, flip, shift } from "@floating-ui/dom";
78

89
export default class MxTooltip extends BaseTooltip {
910
static TEMPLATE = [
@@ -56,10 +57,7 @@ export default class MxTooltip extends BaseTooltip {
5657
// @ts-expect-error Fix me later
5758
this.preview.setAttribute("href", preview);
5859
this.show();
59-
const bounds = this.quill.getBounds(this.linkRange);
60-
if (bounds != null) {
61-
this.position(bounds);
62-
}
60+
this.setPosition(link.domNode);
6361
return;
6462
}
6563
} else {
@@ -86,6 +84,18 @@ export default class MxTooltip extends BaseTooltip {
8684
}
8785
}
8886

87+
setPosition(domNode: HTMLElement): void {
88+
computePosition(domNode, this.root, {
89+
placement: "bottom",
90+
middleware: [flip(), shift({ padding: 5 })]
91+
}).then(({ x, y }) => {
92+
Object.assign(this.root.style, {
93+
left: `${x}px`,
94+
top: `${y}px`
95+
});
96+
});
97+
}
98+
8999
show(): void {
90100
super.show();
91101
this.root.removeAttribute("data-mode");

pnpm-lock.yaml

Lines changed: 5 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)