@lobehub/editor 1.8.0 → 1.8.2

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.
@@ -10,6 +10,7 @@ import { computePosition, flip, offset, shift } from '@floating-ui/dom';
10
10
  import { mergeRegister } from '@lexical/utils';
11
11
  import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_NORMAL } from 'lexical';
12
12
  import { useLayoutEffect, useRef, useState } from 'react';
13
+ import { createPortal } from 'react-dom';
13
14
  import { useLexicalEditor } from "../../../editor-kernel/react";
14
15
  import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
15
16
  import { MarkdownPlugin } from "../../markdown";
@@ -23,6 +24,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
23
24
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
25
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
26
  export var ReactLinkPlugin = function ReactLinkPlugin(_ref) {
27
+ var _editor$getLexicalEdi, _lexicalEditor$getRoo;
26
28
  var theme = _ref.theme,
27
29
  _ref$enableHotkey = _ref.enableHotkey,
28
30
  enableHotkey = _ref$enableHotkey === void 0 ? true : _ref$enableHotkey,
@@ -98,7 +100,6 @@ export var ReactLinkPlugin = function ReactLinkPlugin(_ref) {
98
100
  return false;
99
101
  }
100
102
  LinkRef.current = payload.event.target;
101
- // const url = editor.read(() => payload.linkNode.getURL());
102
103
  divRef.current.style.left = "".concat(x, "px");
103
104
  divRef.current.style.top = "".concat(y, "px");
104
105
  });
@@ -114,7 +115,13 @@ export var ReactLinkPlugin = function ReactLinkPlugin(_ref) {
114
115
  return true;
115
116
  }, COMMAND_PRIORITY_NORMAL));
116
117
  }, []);
117
- return /*#__PURE__*/_jsxs(_Fragment, {
118
+
119
+ // Determine anchor element (editor inner wrapper)
120
+ var lexicalEditor = (_editor$getLexicalEdi = editor.getLexicalEditor) === null || _editor$getLexicalEdi === void 0 ? void 0 : _editor$getLexicalEdi.call(editor);
121
+ var root = lexicalEditor === null || lexicalEditor === void 0 || (_lexicalEditor$getRoo = lexicalEditor.getRootElement) === null || _lexicalEditor$getRoo === void 0 ? void 0 : _lexicalEditor$getRoo.call(lexicalEditor);
122
+ var anchor = root ? root.parentElement : null;
123
+ var targetElement = anchor || (typeof document !== 'undefined' ? document.body : null);
124
+ return targetElement ? /*#__PURE__*/createPortal( /*#__PURE__*/_jsxs(_Fragment, {
118
125
  children: [/*#__PURE__*/_jsx(LinkToolbar, {
119
126
  editor: editor.getLexicalEditor(),
120
127
  linkNode: linkNode,
@@ -130,7 +137,7 @@ export var ReactLinkPlugin = function ReactLinkPlugin(_ref) {
130
137
  },
131
138
  ref: divRef
132
139
  }), /*#__PURE__*/_jsx(LinkEdit, {})]
133
- });
140
+ }), targetElement) : null;
134
141
  };
135
142
  ReactLinkPlugin.displayName = 'ReactLinkPlugin';
136
143
  export default ReactLinkPlugin;
@@ -472,7 +472,9 @@ export default /*#__PURE__*/memo(function (_ref3) {
472
472
  if (typeof document === 'undefined') {
473
473
  return null;
474
474
  }
475
- var targetElement = anchorElem || document.body;
475
+ var root = editor.getRootElement();
476
+ var anchor = root ? root.parentElement : null;
477
+ var targetElement = anchorElem || anchor || document.body;
476
478
  return /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(TableCellActionMenuContainer, {
477
479
  anchorElem: targetElement,
478
480
  cellMerge: cellMerge,
@@ -254,7 +254,9 @@ export default /*#__PURE__*/memo(function (_ref2) {
254
254
  if (typeof document === 'undefined') {
255
255
  return null;
256
256
  }
257
- var targetElement = anchorElem || document.body;
257
+ var root = editor.getRootElement();
258
+ var anchor = root ? root.parentElement : null;
259
+ var targetElement = anchorElem || anchor || document.body;
258
260
  return /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(TableHoverActionsContainer, {
259
261
  anchorElem: targetElement,
260
262
  editor: editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
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",