@tarviks/lexical-rich-editor 1.0.2 → 1.0.4

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/dist/index.js CHANGED
@@ -6471,7 +6471,8 @@ function WordCountPlugin({ onCountChange }) {
6471
6471
  function FocusEventsPlugin({
6472
6472
  onFocus,
6473
6473
  onBlur,
6474
- setFocused
6474
+ setFocused,
6475
+ containerRef
6475
6476
  }) {
6476
6477
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
6477
6478
  React6.useEffect(() => {
@@ -6483,7 +6484,8 @@ function FocusEventsPlugin({
6483
6484
  };
6484
6485
  const handleFocusOut = (e) => {
6485
6486
  const next = e.relatedTarget;
6486
- const stillInside = !!next && root.contains(next);
6487
+ const container = containerRef.current;
6488
+ const stillInside = !!next && (container ? container.contains(next) : root.contains(next));
6487
6489
  if (stillInside) return;
6488
6490
  editor.update(() => {
6489
6491
  lexical.$setSelection(null);
@@ -6497,7 +6499,7 @@ function FocusEventsPlugin({
6497
6499
  root.removeEventListener("focusin", handleFocusIn);
6498
6500
  root.removeEventListener("focusout", handleFocusOut);
6499
6501
  };
6500
- }, [editor, onBlur, onFocus, setFocused]);
6502
+ }, [editor, onBlur, onFocus, setFocused, containerRef]);
6501
6503
  return null;
6502
6504
  }
6503
6505
  var URL_REGEX = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/;
@@ -6617,6 +6619,7 @@ var ContentEditorComponent = React6.forwardRef(
6617
6619
  const setFocused = (focused) => {
6618
6620
  focusedRef.current = focused;
6619
6621
  };
6622
+ const containerRef = React6.useRef(null);
6620
6623
  const onAnchorRef = (elem) => {
6621
6624
  if (elem) setFloatingAnchorElem(elem);
6622
6625
  };
@@ -6702,7 +6705,7 @@ var ContentEditorComponent = React6.forwardRef(
6702
6705
  previousOverLimitRef.current = isOverLimit;
6703
6706
  }
6704
6707
  }, [isOverLimit, wordCount, props.wordLimit, props.onWordLimitExceeded]);
6705
- return /* @__PURE__ */ jsxRuntime.jsx(reactComponents.FluentProvider, { theme: reactComponents.webLightTheme, style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(LexicalComposer.LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsxRuntime.jsxs(
6708
+ return /* @__PURE__ */ jsxRuntime.jsx(reactComponents.FluentProvider, { theme: reactComponents.webLightTheme, style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(LexicalComposer.LexicalComposer, { initialConfig, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, style: { height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
6706
6709
  react.Stack,
6707
6710
  {
6708
6711
  style: {
@@ -6813,7 +6816,8 @@ var ContentEditorComponent = React6.forwardRef(
6813
6816
  {
6814
6817
  onFocus: props.onFocus,
6815
6818
  onBlur: props.onBlur,
6816
- setFocused
6819
+ setFocused,
6820
+ containerRef
6817
6821
  }
6818
6822
  ),
6819
6823
  props.autoFocus && !isReadOnly && /* @__PURE__ */ jsxRuntime.jsx(LexicalAutoFocusPlugin.AutoFocusPlugin, {}),
@@ -6876,7 +6880,7 @@ var ContentEditorComponent = React6.forwardRef(
6876
6880
  )
6877
6881
  ]
6878
6882
  }
6879
- ) }) });
6883
+ ) }) }) });
6880
6884
  }
6881
6885
  );
6882
6886