@squiz/formatted-text-editor 1.66.0 → 1.66.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
@@ -74,11 +74,20 @@ const createToolbarPositioner = ({ types }) => {
|
|
74
74
|
const leftmost = Math.min(from.left, to.left);
|
75
75
|
// The position nearest the top.
|
76
76
|
const topmost = Math.min(from.top, to.top);
|
77
|
+
const bottommost = Math.max(from.bottom, to.bottom);
|
77
78
|
const left = parent.scrollLeft + (spansMultipleLines ? to.left - parentRect.left : leftmost - parentRect.left);
|
78
79
|
const top = parent.scrollTop + topmost - parentRect.top;
|
79
80
|
const width = spansMultipleLines ? 1 : Math.abs(from.left - to.right);
|
80
81
|
const rect = new DOMRect(spansMultipleLines ? to.left : leftmost, topmost, width, height);
|
81
|
-
|
82
|
+
// Get header toolbar by class inside the current element/editor
|
83
|
+
const headerToolbar = element.parentElement?.getElementsByClassName('header-toolbar')?.[0];
|
84
|
+
const headerBarRects = headerToolbar?.getBoundingClientRect();
|
85
|
+
const headerBarHeight = headerBarRects?.height ?? 0;
|
86
|
+
const headerBarBottom = (headerBarRects?.top ?? 0) + headerBarHeight;
|
87
|
+
// If floating toolbar will overlap fixed toolbar, set position to under selection
|
88
|
+
const isOverlapping = headerBarBottom + headerBarHeight > topmost;
|
89
|
+
const y = isOverlapping ? bottommost + 62 : top; // FIXME: need to calculate rather than hard-code
|
90
|
+
return { rect, y, x: left, height, width, visible };
|
82
91
|
},
|
83
92
|
});
|
84
93
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squiz/formatted-text-editor",
|
3
|
-
"version": "1.66.
|
3
|
+
"version": "1.66.1",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"types": "lib/index.d.ts",
|
6
6
|
"private": false,
|
@@ -35,7 +35,7 @@
|
|
35
35
|
"@testing-library/jest-dom": "5.16.5",
|
36
36
|
"@testing-library/react": "14.0.0",
|
37
37
|
"@testing-library/user-event": "14.4.3",
|
38
|
-
"@types/node": "
|
38
|
+
"@types/node": "20.11.24",
|
39
39
|
"@types/react": "^18.2.45",
|
40
40
|
"@types/react-dom": "^18.2.18",
|
41
41
|
"@vitejs/plugin-react": "3.0.0",
|
@@ -103,13 +103,24 @@ export const createToolbarPositioner = ({ types }: ToolbarPositionerProps) => {
|
|
103
103
|
|
104
104
|
// The position nearest the top.
|
105
105
|
const topmost = Math.min(from.top, to.top);
|
106
|
+
const bottommost = Math.max(from.bottom, to.bottom);
|
106
107
|
|
107
108
|
const left = parent.scrollLeft + (spansMultipleLines ? to.left - parentRect.left : leftmost - parentRect.left);
|
108
109
|
const top = parent.scrollTop + topmost - parentRect.top;
|
109
110
|
const width = spansMultipleLines ? 1 : Math.abs(from.left - to.right);
|
110
111
|
const rect = new DOMRect(spansMultipleLines ? to.left : leftmost, topmost, width, height);
|
111
112
|
|
112
|
-
|
113
|
+
// Get header toolbar by class inside the current element/editor
|
114
|
+
const headerToolbar = element.parentElement?.getElementsByClassName('header-toolbar')?.[0];
|
115
|
+
const headerBarRects = headerToolbar?.getBoundingClientRect();
|
116
|
+
const headerBarHeight = headerBarRects?.height ?? 0;
|
117
|
+
const headerBarBottom = (headerBarRects?.top ?? 0) + headerBarHeight;
|
118
|
+
|
119
|
+
// If floating toolbar will overlap fixed toolbar, set position to under selection
|
120
|
+
const isOverlapping = headerBarBottom + headerBarHeight > topmost;
|
121
|
+
const y = isOverlapping ? bottommost + 62 : top; // FIXME: need to calculate rather than hard-code
|
122
|
+
|
123
|
+
return { rect, y, x: left, height, width, visible };
|
113
124
|
},
|
114
125
|
});
|
115
126
|
};
|