@squiz/formatted-text-editor 1.66.1 → 1.66.3

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
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.66.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 7234d6c: Fixed FTE popover menu from having unusual positioning in certain circumstances
8
+
9
+ ## 1.66.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 629a64f: Fixed FTE bubble menu from staying visible when unfocusing from editor
14
+
3
15
  ## 1.66.1
4
16
 
5
17
  ### Patch Changes
@@ -70,6 +70,6 @@ const Editor = ({ content, className, border = true, editable = true, onChange,
70
70
  editable && react_1.default.createElement(EditorToolbar_1.Toolbar, { isVisible: isVisible }),
71
71
  children && react_1.default.createElement("div", { className: "squiz-fte-scope__editor__children" }, children),
72
72
  react_1.default.createElement(WrappedEditor, null),
73
- editable && react_1.default.createElement(EditorToolbar_1.FloatingToolbar, null))));
73
+ editable && isVisible && react_1.default.createElement(EditorToolbar_1.FloatingToolbar, null))));
74
74
  };
75
75
  exports.default = Editor;
@@ -32,7 +32,9 @@ const useFocus = (initialState) => {
32
32
  // (and therefore still in our React tree resulting in the element still effectively being focused).
33
33
  const isBlurringEditor = wrapperRef.current?.contains(event.target);
34
34
  const isFocusedInEditor = wrapperRef.current?.contains(event.relatedTarget);
35
- if (isBlurringEditor && !isFocusedInEditor) {
35
+ // Detect if the blur event happens when the related/clicked target is the floating popover
36
+ const isClickingFloatingToolbar = !!event.relatedTarget?.closest('.squiz-fte-scope__floating-popover');
37
+ if (isBlurringEditor && !isFocusedInEditor && !isClickingFloatingToolbar) {
36
38
  setIsVisible(false);
37
39
  }
38
40
  }, [wrapperRef]);
@@ -86,7 +86,9 @@ const createToolbarPositioner = ({ types }) => {
86
86
  const headerBarBottom = (headerBarRects?.top ?? 0) + headerBarHeight;
87
87
  // If floating toolbar will overlap fixed toolbar, set position to under selection
88
88
  const isOverlapping = headerBarBottom + headerBarHeight > topmost;
89
- const y = isOverlapping ? bottommost + 62 : top; // FIXME: need to calculate rather than hard-code
89
+ // This is a good bottom position instead of it being on top of the toolbar when there is an overlap
90
+ const bottomPosition = parent.scrollTop + bottommost - parentRect.top + 62;
91
+ const y = isOverlapping ? bottomPosition : top;
90
92
  return { rect, y, x: left, height, width, visible };
91
93
  },
92
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/formatted-text-editor",
3
- "version": "1.66.1",
3
+ "version": "1.66.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "private": false,
@@ -93,7 +93,7 @@ const Editor = ({
93
93
  {editable && <Toolbar isVisible={isVisible} />}
94
94
  {children && <div className="squiz-fte-scope__editor__children">{children}</div>}
95
95
  <WrappedEditor />
96
- {editable && <FloatingToolbar />}
96
+ {editable && isVisible && <FloatingToolbar />}
97
97
  </Remirror>
98
98
  </div>
99
99
  );
@@ -45,7 +45,10 @@ const useFocus = (
45
45
  const isBlurringEditor = wrapperRef.current?.contains(event.target);
46
46
  const isFocusedInEditor = wrapperRef.current?.contains(event.relatedTarget);
47
47
 
48
- if (isBlurringEditor && !isFocusedInEditor) {
48
+ // Detect if the blur event happens when the related/clicked target is the floating popover
49
+ const isClickingFloatingToolbar = !!event.relatedTarget?.closest('.squiz-fte-scope__floating-popover');
50
+
51
+ if (isBlurringEditor && !isFocusedInEditor && !isClickingFloatingToolbar) {
49
52
  setIsVisible(false);
50
53
  }
51
54
  },
@@ -118,7 +118,9 @@ export const createToolbarPositioner = ({ types }: ToolbarPositionerProps) => {
118
118
 
119
119
  // If floating toolbar will overlap fixed toolbar, set position to under selection
120
120
  const isOverlapping = headerBarBottom + headerBarHeight > topmost;
121
- const y = isOverlapping ? bottommost + 62 : top; // FIXME: need to calculate rather than hard-code
121
+ // This is a good bottom position instead of it being on top of the toolbar when there is an overlap
122
+ const bottomPosition = parent.scrollTop + bottommost - parentRect.top + 62;
123
+ const y = isOverlapping ? bottomPosition : top;
122
124
 
123
125
  return { rect, y, x: left, height, width, visible };
124
126
  },