@lobehub/editor 2.1.0 → 2.2.0

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.
@@ -40,6 +40,7 @@ export var ReactToolbarPlugin = function ReactToolbarPlugin(_ref) {
40
40
  var rootElement = editor.getRootElement();
41
41
  if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
42
42
  var rangeRect = getDOMRangeRect(nativeSelection, rootElement);
43
+ console.info('rangeRect', rangeRect);
43
44
  setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElemRef.current, false);
44
45
  } else {
45
46
  popupCharStylesEditorElem.style.opacity = '0';
@@ -98,7 +99,7 @@ export var ReactToolbarPlugin = function ReactToolbarPlugin(_ref) {
98
99
  var rootElement = editor.getRootElement();
99
100
  if (rootElement) {
100
101
  rootElement.addEventListener('mousedown', handleMouseDown);
101
- rootElement.addEventListener('mouseup', handleMouseUp);
102
+ document.addEventListener('mouseup', handleMouseUp);
102
103
  }
103
104
  return mergeRegister(registerToolbarCommand(editor, {
104
105
  onHide: $hideFloatingToolbar
@@ -119,7 +120,7 @@ export var ReactToolbarPlugin = function ReactToolbarPlugin(_ref) {
119
120
  }, COMMAND_PRIORITY_LOW), function () {
120
121
  if (rootElement) {
121
122
  rootElement.removeEventListener('mousedown', handleMouseDown);
122
- rootElement.removeEventListener('mouseup', handleMouseUp);
123
+ document.removeEventListener('mouseup', handleMouseUp);
123
124
  }
124
125
  });
125
126
  });
@@ -7,11 +7,25 @@
7
7
  */
8
8
  var VERTICAL_GAP = 4;
9
9
  var HORIZONTAL_OFFSET = 0;
10
+ function getScrollParent(element) {
11
+ var parent = element.parentElement;
12
+ while (parent) {
13
+ var _window$getComputedSt = window.getComputedStyle(parent),
14
+ overflow = _window$getComputedSt.overflow,
15
+ overflowY = _window$getComputedSt.overflowY,
16
+ overflowX = _window$getComputedSt.overflowX;
17
+ if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
18
+ return parent;
19
+ }
20
+ parent = parent.parentElement;
21
+ }
22
+ return document.documentElement;
23
+ }
10
24
  export function setFloatingElemPosition(targetRect, floatingElem, anchorElem) {
11
25
  var isLink = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
12
26
  var verticalGap = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : VERTICAL_GAP;
13
27
  var horizontalOffset = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : HORIZONTAL_OFFSET;
14
- var scrollerElem = anchorElem.parentElement;
28
+ var scrollerElem = getScrollParent(anchorElem);
15
29
  if (targetRect === null || !scrollerElem) {
16
30
  floatingElem.style.opacity = '0';
17
31
  floatingElem.style.transform = 'translate(-10000px, -10000px)';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -17,7 +17,9 @@
17
17
  },
18
18
  "license": "MIT",
19
19
  "author": "LobeHub <i@lobehub.com>",
20
- "sideEffects": false,
20
+ "sideEffects": [
21
+ "**/*.css"
22
+ ],
21
23
  "main": "es/index.js",
22
24
  "module": "es/index.js",
23
25
  "types": "es/index.d.ts",