Skip to content

Commit 0e7e6be

Browse files
committed
fix: center hyperlink modal on screen
[FIX] Change hyperlink modal position from absolute to fixed [FIX] Center modal horizontally and vertically on screen [IMPROVE] Increase modal width to 360-420px for better readability [IMPROVE] Larger border-radius (12px) and better shadow [IMPROVE] More padding (16px) for better spacing
1 parent a193ba8 commit 0e7e6be

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

admin/src/components/EditorTools/HyperlinkTool.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ class HyperlinkTool {
111111
this.popup = document.createElement('div');
112112
this.popup.classList.add('ce-inline-tool-hyperlink-popup');
113113
this.popup.style.cssText = `
114-
position: absolute;
114+
position: fixed;
115115
background: white;
116116
border: 1px solid #e2e8f0;
117-
border-radius: 8px;
118-
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
119-
padding: 12px;
117+
border-radius: 12px;
118+
box-shadow: 0 8px 32px rgba(0,0,0,0.15);
119+
padding: 16px;
120120
z-index: 999999;
121-
min-width: 300px;
121+
min-width: 360px;
122+
max-width: 420px;
122123
`;
123124

124125
// URL Input
@@ -336,29 +337,19 @@ class HyperlinkTool {
336337
}
337338

338339
/**
339-
* Positions the popup near the selection
340+
* Positions the popup centered on screen
340341
*/
341342
_positionPopup() {
342343
if (!this.popup) return;
343344

344-
const selection = window.getSelection();
345-
if (!selection.rangeCount) return;
346-
347-
const range = selection.getRangeAt(0);
348-
const rect = range.getBoundingClientRect();
349-
350345
const popupRect = this.popup.getBoundingClientRect();
351-
let left = rect.left + (rect.width / 2) - (popupRect.width / 2);
352-
let top = rect.bottom + 10 + window.scrollY;
353346

354-
// Keep popup in viewport
355-
if (left < 10) left = 10;
356-
if (left + popupRect.width > window.innerWidth - 10) {
357-
left = window.innerWidth - popupRect.width - 10;
358-
}
347+
// Center horizontally and vertically
348+
const left = (window.innerWidth - popupRect.width) / 2;
349+
const top = (window.innerHeight - popupRect.height) / 2;
359350

360-
this.popup.style.left = `${left}px`;
361-
this.popup.style.top = `${top}px`;
351+
this.popup.style.left = `${Math.max(10, left)}px`;
352+
this.popup.style.top = `${Math.max(10, top)}px`;
362353
}
363354

364355
/**

0 commit comments

Comments
 (0)