@lexical/react 0.35.1-nightly.20250919.0 → 0.35.1-nightly.20250922.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.
@@ -12,5 +12,8 @@ export type CollaborationContextType = {
12
12
  name: string;
13
13
  yjsDocMap: Map<string, Doc>;
14
14
  };
15
- export declare const CollaborationContext: import("react").Context<CollaborationContextType>;
15
+ export declare const CollaborationContext: import("react").Context<CollaborationContextType | null>;
16
+ export declare function LexicalCollaboration({ children }: {
17
+ children: React.ReactNode;
18
+ }): import("react/jsx-runtime").JSX.Element;
16
19
  export declare function useCollaborationContext(username?: string, color?: string): CollaborationContextType;
@@ -9,6 +9,7 @@
9
9
  'use strict';
10
10
 
11
11
  var react = require('react');
12
+ var jsxRuntime = require('react/jsx-runtime');
12
13
 
13
14
  /**
14
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -18,16 +19,42 @@ var react = require('react');
18
19
  *
19
20
  */
20
21
 
22
+ // Do not require this module directly! Use normal `invariant` calls.
23
+
24
+ function formatDevErrorMessage(message) {
25
+ throw new Error(message);
26
+ }
27
+
21
28
  const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
22
29
  const randomEntry = entries[Math.floor(Math.random() * entries.length)];
23
- const CollaborationContext = /*#__PURE__*/react.createContext({
24
- color: randomEntry[1],
25
- isCollabActive: false,
26
- name: randomEntry[0],
27
- yjsDocMap: new Map()
28
- });
30
+ const CollaborationContext = /*#__PURE__*/react.createContext(null);
31
+ function newContext() {
32
+ return {
33
+ color: randomEntry[1],
34
+ isCollabActive: false,
35
+ name: randomEntry[0],
36
+ yjsDocMap: new Map()
37
+ };
38
+ }
39
+
40
+ // This is here to help the transition post-#7818, however should be removed in a future release as
41
+ // a shared context across editors is likely to lead to bugs.
42
+ const UNSAFE_GLOBAL_CONTEXT = newContext();
43
+ function LexicalCollaboration({
44
+ children
45
+ }) {
46
+ const collabContext = react.useMemo(() => newContext(), []);
47
+ return /*#__PURE__*/jsxRuntime.jsx(CollaborationContext.Provider, {
48
+ value: collabContext,
49
+ children: children
50
+ });
51
+ }
29
52
  function useCollaborationContext(username, color) {
30
- const collabContext = react.useContext(CollaborationContext);
53
+ let collabContext = react.useContext(CollaborationContext);
54
+ if (!(collabContext != null)) {
55
+ formatDevErrorMessage(`useCollaborationContext: no context provider found`);
56
+ }
57
+ collabContext = collabContext ?? UNSAFE_GLOBAL_CONTEXT;
31
58
  if (username != null) {
32
59
  collabContext.name = username;
33
60
  }
@@ -38,4 +65,5 @@ function useCollaborationContext(username, color) {
38
65
  }
39
66
 
40
67
  exports.CollaborationContext = CollaborationContext;
68
+ exports.LexicalCollaboration = LexicalCollaboration;
41
69
  exports.useCollaborationContext = useCollaborationContext;
@@ -6,7 +6,8 @@
6
6
  *
7
7
  */
8
8
 
9
- import { createContext, useContext } from 'react';
9
+ import { createContext, useMemo, useContext } from 'react';
10
+ import { jsx } from 'react/jsx-runtime';
10
11
 
11
12
  /**
12
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -16,16 +17,42 @@ import { createContext, useContext } from 'react';
16
17
  *
17
18
  */
18
19
 
20
+ // Do not require this module directly! Use normal `invariant` calls.
21
+
22
+ function formatDevErrorMessage(message) {
23
+ throw new Error(message);
24
+ }
25
+
19
26
  const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
20
27
  const randomEntry = entries[Math.floor(Math.random() * entries.length)];
21
- const CollaborationContext = /*#__PURE__*/createContext({
22
- color: randomEntry[1],
23
- isCollabActive: false,
24
- name: randomEntry[0],
25
- yjsDocMap: new Map()
26
- });
28
+ const CollaborationContext = /*#__PURE__*/createContext(null);
29
+ function newContext() {
30
+ return {
31
+ color: randomEntry[1],
32
+ isCollabActive: false,
33
+ name: randomEntry[0],
34
+ yjsDocMap: new Map()
35
+ };
36
+ }
37
+
38
+ // This is here to help the transition post-#7818, however should be removed in a future release as
39
+ // a shared context across editors is likely to lead to bugs.
40
+ const UNSAFE_GLOBAL_CONTEXT = newContext();
41
+ function LexicalCollaboration({
42
+ children
43
+ }) {
44
+ const collabContext = useMemo(() => newContext(), []);
45
+ return /*#__PURE__*/jsx(CollaborationContext.Provider, {
46
+ value: collabContext,
47
+ children: children
48
+ });
49
+ }
27
50
  function useCollaborationContext(username, color) {
28
- const collabContext = useContext(CollaborationContext);
51
+ let collabContext = useContext(CollaborationContext);
52
+ if (!(collabContext != null)) {
53
+ formatDevErrorMessage(`useCollaborationContext: no context provider found`);
54
+ }
55
+ collabContext = collabContext ?? UNSAFE_GLOBAL_CONTEXT;
29
56
  if (username != null) {
30
57
  collabContext.name = username;
31
58
  }
@@ -35,4 +62,4 @@ function useCollaborationContext(username, color) {
35
62
  return collabContext;
36
63
  }
37
64
 
38
- export { CollaborationContext, useCollaborationContext };
65
+ export { CollaborationContext, LexicalCollaboration, useCollaborationContext };
@@ -10,4 +10,5 @@ import * as modDev from './LexicalCollaborationContext.dev.mjs';
10
10
  import * as modProd from './LexicalCollaborationContext.prod.mjs';
11
11
  const mod = process.env.NODE_ENV !== 'production' ? modDev : modProd;
12
12
  export const CollaborationContext = mod.CollaborationContext;
13
+ export const LexicalCollaboration = mod.LexicalCollaboration;
13
14
  export const useCollaborationContext = mod.useCollaborationContext;
@@ -8,4 +8,5 @@
8
8
 
9
9
  const mod = await (process.env.NODE_ENV !== 'production' ? import('./LexicalCollaborationContext.dev.mjs') : import('./LexicalCollaborationContext.prod.mjs'));
10
10
  export const CollaborationContext = mod.CollaborationContext;
11
+ export const LexicalCollaboration = mod.LexicalCollaboration;
11
12
  export const useCollaborationContext = mod.useCollaborationContext;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var r=require("react");const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],e=o[Math.floor(Math.random()*o.length)],t=r.createContext({color:e[1],isCollabActive:!1,name:e[0],yjsDocMap:new Map});exports.CollaborationContext=t,exports.useCollaborationContext=function(o,e){const g=r.useContext(t);return null!=o&&(g.name=o),null!=e&&(g.color=e),g};
9
+ "use strict";var r=require("react"),e=require("react/jsx-runtime");const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],n=o[Math.floor(Math.random()*o.length)],t=r.createContext(null);function l(){return{color:n[1],isCollabActive:!1,name:n[0],yjsDocMap:new Map}}const a=l();exports.CollaborationContext=t,exports.LexicalCollaboration=function({children:o}){const n=r.useMemo((()=>l()),[]);return e.jsx(t.Provider,{value:n,children:o})},exports.useCollaborationContext=function(e,o){let n=r.useContext(t);return null==n&&function(r,...e){const o=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",r);for(const r of e)n.append("v",r);o.search=n.toString(),console.warn(`Minified Lexical warning #${r}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(291),n=n??a,null!=e&&(n.name=e),null!=o&&(n.color=o),n};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({color:b[1],isCollabActive:!1,name:b[0],yjsDocMap:new Map});function l(r,o){const b=g(e);return null!=r&&(b.name=r),null!=o&&(b.color=o),b}export{e as CollaborationContext,l as useCollaborationContext};
9
+ import{createContext as r,useMemo as n,useContext as e}from"react";import{jsx as o}from"react/jsx-runtime";const t=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],i=t[Math.floor(Math.random()*t.length)],l=r(null);function a(){return{color:i[1],isCollabActive:!1,name:i[0],yjsDocMap:new Map}}const g=a();function c({children:r}){const e=n((()=>a()),[]);return o(l.Provider,{value:e,children:r})}function b(r,n){let o=e(l);return null==o&&function(r,...n){const e=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const r of n)o.append("v",r);e.search=o.toString(),console.warn(`Minified Lexical warning #${r}; visit ${e.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(291),o=o??g,null!=r&&(o.name=r),null!=n&&(o.color=n),o}export{l as CollaborationContext,c as LexicalCollaboration,b as useCollaborationContext};
@@ -8,9 +8,9 @@
8
8
  import type { MenuRenderFn, MenuResolution } from './shared/LexicalMenu';
9
9
  import type { JSX } from 'react';
10
10
  import { CommandListenerPriority, LexicalNode } from 'lexical';
11
- import { MutableRefObject, ReactPortal } from 'react';
11
+ import { ReactPortal, RefObject } from 'react';
12
12
  import { MenuOption } from './shared/LexicalMenu';
13
- export type ContextMenuRenderFn<TOption extends MenuOption> = (anchorElementRef: MutableRefObject<HTMLElement | null>, itemProps: {
13
+ export type ContextMenuRenderFn<TOption extends MenuOption> = (anchorElementRef: RefObject<HTMLElement | null>, itemProps: {
14
14
  selectedIndex: number | null;
15
15
  selectOptionAndCleanUp: (option: TOption) => void;
16
16
  setHighlightedIndex: (index: number) => void;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import { LexicalEditor } from 'lexical';
9
- import { MutableRefObject } from 'react';
9
+ import { RefObject } from 'react';
10
10
  import * as React from 'react';
11
11
  /**
12
12
  *
@@ -16,5 +16,5 @@ import * as React from 'react';
16
16
  * be positioned outside the LexicalComposer in the React tree.
17
17
  */
18
18
  export declare function EditorRefPlugin({ editorRef, }: {
19
- editorRef: React.RefCallback<LexicalEditor> | MutableRefObject<LexicalEditor | null | undefined>;
19
+ editorRef: React.RefCallback<LexicalEditor> | RefObject<LexicalEditor | null | undefined>;
20
20
  }): null;
@@ -8,147 +8,9 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- var React = require('react');
11
+ var reactErrorBoundary = require('react-error-boundary');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
13
 
14
- function _interopNamespaceDefault(e) {
15
- var n = Object.create(null);
16
- if (e) {
17
- for (var k in e) {
18
- n[k] = e[k];
19
- }
20
- }
21
- n.default = e;
22
- return n;
23
- }
24
-
25
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
-
27
- function _setPrototypeOf(o, p) {
28
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
29
- o.__proto__ = p;
30
- return o;
31
- };
32
- return _setPrototypeOf(o, p);
33
- }
34
-
35
- function _inheritsLoose(subClass, superClass) {
36
- subClass.prototype = Object.create(superClass.prototype);
37
- subClass.prototype.constructor = subClass;
38
- _setPrototypeOf(subClass, superClass);
39
- }
40
-
41
- var changedArray = function changedArray(a, b) {
42
- if (a === void 0) {
43
- a = [];
44
- }
45
-
46
- if (b === void 0) {
47
- b = [];
48
- }
49
-
50
- return a.length !== b.length || a.some(function (item, index) {
51
- return !Object.is(item, b[index]);
52
- });
53
- };
54
-
55
- var initialState = {
56
- error: null
57
- };
58
-
59
- var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
60
- _inheritsLoose(ErrorBoundary, _React$Component);
61
-
62
- function ErrorBoundary() {
63
- var _this;
64
-
65
- for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
66
- _args[_key] = arguments[_key];
67
- }
68
-
69
- _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
70
- _this.state = initialState;
71
-
72
- _this.resetErrorBoundary = function () {
73
- var _this$props;
74
-
75
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
76
- args[_key2] = arguments[_key2];
77
- }
78
-
79
- _this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
80
-
81
- _this.reset();
82
- };
83
-
84
- return _this;
85
- }
86
-
87
- ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
88
- return {
89
- error: error
90
- };
91
- };
92
-
93
- var _proto = ErrorBoundary.prototype;
94
-
95
- _proto.reset = function reset() {
96
- this.setState(initialState);
97
- };
98
-
99
- _proto.componentDidCatch = function componentDidCatch(error, info) {
100
- var _this$props$onError, _this$props2;
101
-
102
- (_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
103
- };
104
-
105
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
106
- var error = this.state.error;
107
- var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
108
- // happens to *also* be in the resetKeys array, we'd end up resetting
109
- // the error boundary immediately. This would likely trigger a second
110
- // error to be thrown.
111
- // So we make sure that we don't check the resetKeys on the first call
112
- // of cDU after the error is set
113
-
114
- if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
115
- var _this$props$onResetKe, _this$props3;
116
-
117
- (_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
118
- this.reset();
119
- }
120
- };
121
-
122
- _proto.render = function render() {
123
- var error = this.state.error;
124
- var _this$props4 = this.props,
125
- fallbackRender = _this$props4.fallbackRender,
126
- FallbackComponent = _this$props4.FallbackComponent,
127
- fallback = _this$props4.fallback;
128
-
129
- if (error !== null) {
130
- var _props = {
131
- error: error,
132
- resetErrorBoundary: this.resetErrorBoundary
133
- };
134
-
135
- if ( /*#__PURE__*/React__namespace.isValidElement(fallback)) {
136
- return fallback;
137
- } else if (typeof fallbackRender === 'function') {
138
- return fallbackRender(_props);
139
- } else if (FallbackComponent) {
140
- return /*#__PURE__*/React__namespace.createElement(FallbackComponent, _props);
141
- } else {
142
- throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
143
- }
144
- }
145
-
146
- return this.props.children;
147
- };
148
-
149
- return ErrorBoundary;
150
- }(React__namespace.Component);
151
-
152
14
  /**
153
15
  * Copyright (c) Meta Platforms, Inc. and affiliates.
154
16
  *
@@ -161,7 +23,7 @@ function LexicalErrorBoundary({
161
23
  children,
162
24
  onError
163
25
  }) {
164
- return /*#__PURE__*/jsxRuntime.jsx(ErrorBoundary, {
26
+ return /*#__PURE__*/jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, {
165
27
  fallback: /*#__PURE__*/jsxRuntime.jsx("div", {
166
28
  style: {
167
29
  border: '1px solid #f00',
@@ -6,134 +6,9 @@
6
6
  *
7
7
  */
8
8
 
9
- import * as React from 'react';
9
+ import { ErrorBoundary } from 'react-error-boundary';
10
10
  import { jsx } from 'react/jsx-runtime';
11
11
 
12
- function _setPrototypeOf(o, p) {
13
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
14
- o.__proto__ = p;
15
- return o;
16
- };
17
- return _setPrototypeOf(o, p);
18
- }
19
-
20
- function _inheritsLoose(subClass, superClass) {
21
- subClass.prototype = Object.create(superClass.prototype);
22
- subClass.prototype.constructor = subClass;
23
- _setPrototypeOf(subClass, superClass);
24
- }
25
-
26
- var changedArray = function changedArray(a, b) {
27
- if (a === void 0) {
28
- a = [];
29
- }
30
-
31
- if (b === void 0) {
32
- b = [];
33
- }
34
-
35
- return a.length !== b.length || a.some(function (item, index) {
36
- return !Object.is(item, b[index]);
37
- });
38
- };
39
-
40
- var initialState = {
41
- error: null
42
- };
43
-
44
- var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
45
- _inheritsLoose(ErrorBoundary, _React$Component);
46
-
47
- function ErrorBoundary() {
48
- var _this;
49
-
50
- for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
51
- _args[_key] = arguments[_key];
52
- }
53
-
54
- _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
55
- _this.state = initialState;
56
-
57
- _this.resetErrorBoundary = function () {
58
- var _this$props;
59
-
60
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
61
- args[_key2] = arguments[_key2];
62
- }
63
-
64
- _this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
65
-
66
- _this.reset();
67
- };
68
-
69
- return _this;
70
- }
71
-
72
- ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
73
- return {
74
- error: error
75
- };
76
- };
77
-
78
- var _proto = ErrorBoundary.prototype;
79
-
80
- _proto.reset = function reset() {
81
- this.setState(initialState);
82
- };
83
-
84
- _proto.componentDidCatch = function componentDidCatch(error, info) {
85
- var _this$props$onError, _this$props2;
86
-
87
- (_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
88
- };
89
-
90
- _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
91
- var error = this.state.error;
92
- var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
93
- // happens to *also* be in the resetKeys array, we'd end up resetting
94
- // the error boundary immediately. This would likely trigger a second
95
- // error to be thrown.
96
- // So we make sure that we don't check the resetKeys on the first call
97
- // of cDU after the error is set
98
-
99
- if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
100
- var _this$props$onResetKe, _this$props3;
101
-
102
- (_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
103
- this.reset();
104
- }
105
- };
106
-
107
- _proto.render = function render() {
108
- var error = this.state.error;
109
- var _this$props4 = this.props,
110
- fallbackRender = _this$props4.fallbackRender,
111
- FallbackComponent = _this$props4.FallbackComponent,
112
- fallback = _this$props4.fallback;
113
-
114
- if (error !== null) {
115
- var _props = {
116
- error: error,
117
- resetErrorBoundary: this.resetErrorBoundary
118
- };
119
-
120
- if ( /*#__PURE__*/React.isValidElement(fallback)) {
121
- return fallback;
122
- } else if (typeof fallbackRender === 'function') {
123
- return fallbackRender(_props);
124
- } else if (FallbackComponent) {
125
- return /*#__PURE__*/React.createElement(FallbackComponent, _props);
126
- } else {
127
- throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
128
- }
129
- }
130
-
131
- return this.props.children;
132
- };
133
-
134
- return ErrorBoundary;
135
- }(React.Component);
136
-
137
12
  /**
138
13
  * Copyright (c) Meta Platforms, Inc. and affiliates.
139
14
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var r=require("react"),e=require("react/jsx-runtime");function t(r){var e=Object.create(null);if(r)for(var t in r)e[t]=r[t];return e.default=r,e}var n=t(r);function o(r,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},o(r,e)}var a={error:null},i=function(r){var e,t;function i(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=r.call.apply(r,[this].concat(n))||this).state=a,e.resetErrorBoundary=function(){for(var r,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];null==e.props.onReset||(r=e.props).onReset.apply(r,n),e.reset()},e}t=r,(e=i).prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t),i.getDerivedStateFromError=function(r){return{error:r}};var s=i.prototype;return s.reset=function(){this.setState(a)},s.componentDidCatch=function(r,e){var t,n;null==(t=(n=this.props).onError)||t.call(n,r,e)},s.componentDidUpdate=function(r,e){var t,n,o,a,i=this.state.error,s=this.props.resetKeys;null!==i&&null!==e.error&&(void 0===(o=r.resetKeys)&&(o=[]),void 0===(a=s)&&(a=[]),o.length!==a.length||o.some((function(r,e){return!Object.is(r,a[e])})))&&(null==(t=(n=this.props).onResetKeysChange)||t.call(n,r.resetKeys,s),this.reset())},s.render=function(){var r=this.state.error,e=this.props,t=e.fallbackRender,o=e.FallbackComponent,a=e.fallback;if(null!==r){var i={error:r,resetErrorBoundary:this.resetErrorBoundary};if(n.isValidElement(a))return a;if("function"==typeof t)return t(i);if(o)return n.createElement(o,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},i}(n.Component);exports.LexicalErrorBoundary=function({children:r,onError:t}){return e.jsx(i,{fallback:e.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:t,children:r})};
9
+ "use strict";var r=require("react-error-boundary"),e=require("react/jsx-runtime");exports.LexicalErrorBoundary=function({children:o,onError:n}){return e.jsx(r.ErrorBoundary,{fallback:e.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:n,children:o})};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import*as r from"react";import{jsx as e}from"react/jsx-runtime";function t(r,e){return t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},t(r,e)}var o={error:null},n=function(e){var n,a;function s(){for(var r,t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return(r=e.call.apply(e,[this].concat(n))||this).state=o,r.resetErrorBoundary=function(){for(var e,t=arguments.length,o=new Array(t),n=0;n<t;n++)o[n]=arguments[n];null==r.props.onReset||(e=r.props).onReset.apply(e,o),r.reset()},r}a=e,(n=s).prototype=Object.create(a.prototype),n.prototype.constructor=n,t(n,a),s.getDerivedStateFromError=function(r){return{error:r}};var i=s.prototype;return i.reset=function(){this.setState(o)},i.componentDidCatch=function(r,e){var t,o;null==(t=(o=this.props).onError)||t.call(o,r,e)},i.componentDidUpdate=function(r,e){var t,o,n,a,s=this.state.error,i=this.props.resetKeys;null!==s&&null!==e.error&&(void 0===(n=r.resetKeys)&&(n=[]),void 0===(a=i)&&(a=[]),n.length!==a.length||n.some((function(r,e){return!Object.is(r,a[e])})))&&(null==(t=(o=this.props).onResetKeysChange)||t.call(o,r.resetKeys,i),this.reset())},i.render=function(){var e=this.state.error,t=this.props,o=t.fallbackRender,n=t.FallbackComponent,a=t.fallback;if(null!==e){var s={error:e,resetErrorBoundary:this.resetErrorBoundary};if(r.isValidElement(a))return a;if("function"==typeof o)return o(s);if(n)return r.createElement(n,s);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},s}(r.Component);function a({children:r,onError:t}){return e(n,{fallback:e("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:t,children:r})}export{a as LexicalErrorBoundary};
9
+ import{ErrorBoundary as r}from"react-error-boundary";import{jsx as o}from"react/jsx-runtime";function n({children:n,onError:e}){return o(r,{fallback:o("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:n})}export{n as LexicalErrorBoundary};
@@ -149,11 +149,12 @@ function LexicalNestedComposer({
149
149
  []);
150
150
 
151
151
  // If collaboration is enabled, make sure we don't render the children until the collaboration subdocument is ready.
152
+ const collabContext = react.useContext(LexicalCollaborationContext.CollaborationContext);
152
153
  const {
153
154
  isCollabActive,
154
155
  yjsDocMap
155
- } = LexicalCollaborationContext.useCollaborationContext();
156
- const isCollabReady = skipCollabChecks || wasCollabPreviouslyReadyRef.current || yjsDocMap.has(initialEditor.getKey());
156
+ } = collabContext ?? {};
157
+ const isCollabReady = skipCollabChecks || wasCollabPreviouslyReadyRef.current || yjsDocMap && yjsDocMap.has(initialEditor.getKey());
157
158
  react.useEffect(() => {
158
159
  if (isCollabReady) {
159
160
  wasCollabPreviouslyReadyRef.current = true;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
9
+ import { CollaborationContext } from '@lexical/react/LexicalCollaborationContext';
10
10
  import { LexicalComposerContext, createLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
11
11
  import { createSharedNodeState, getRegisteredNode, getStaticNodeConfig } from 'lexical';
12
12
  import { useRef, useContext, useMemo, useEffect } from 'react';
@@ -147,11 +147,12 @@ function LexicalNestedComposer({
147
147
  []);
148
148
 
149
149
  // If collaboration is enabled, make sure we don't render the children until the collaboration subdocument is ready.
150
+ const collabContext = useContext(CollaborationContext);
150
151
  const {
151
152
  isCollabActive,
152
153
  yjsDocMap
153
- } = useCollaborationContext();
154
- const isCollabReady = skipCollabChecks || wasCollabPreviouslyReadyRef.current || yjsDocMap.has(initialEditor.getKey());
154
+ } = collabContext ?? {};
155
+ const isCollabReady = skipCollabChecks || wasCollabPreviouslyReadyRef.current || yjsDocMap && yjsDocMap.has(initialEditor.getKey());
155
156
  useEffect(() => {
156
157
  if (isCollabReady) {
157
158
  wasCollabPreviouslyReadyRef.current = true;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),o=require("lexical"),r=require("react"),n=require("react/jsx-runtime");function s(e){const t=new Set,{ownNodeConfig:r}=o.getStaticNodeConfig(e),n=e.transform();if(r){const e=r.$transform;e&&t.add(e)}return n&&t.add(n),t}const a=()=>{},i=()=>{};exports.LexicalNestedComposer=function({initialEditor:c,children:l,initialNodes:d,initialTheme:f,skipCollabChecks:p,skipEditableListener:u}){const m=r.useRef(!1),x=r.useContext(t.LexicalComposerContext);null==x&&function(e,...t){const o=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw o.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[h,{getTheme:g}]=x,C=r.useMemo((()=>{const e=f||g()||void 0,r=t.createLexicalComposerContext(x,e);void 0!==e&&(c._config.theme=e),c._parentEditor=c._parentEditor||h;const n=c._createEditorArgs,l=n&&n.namespace;if(d){a(),l||(i(),c._config.namespace=h._config.namespace);for(let e of d){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const n=o.getRegisteredNode(c,e.getType());c._nodes.set(e.getType(),{exportDOM:n?n.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,sharedNodeState:o.createSharedNodeState(e),transforms:s(e)})}}else if(n&&n.nodes)l||(i(),c._config.namespace=h._config.namespace);else{const e=c._nodes=new Map(h._nodes);l||(c._config.namespace=h._config.namespace);for(const[t,r]of e)c._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,sharedNodeState:o.createSharedNodeState(r.klass),transforms:s(r.klass)})}return[c,r]}),[]),{isCollabActive:_,yjsDocMap:v}=e.useCollaborationContext(),E=p||m.current||v.has(c.getKey());return r.useEffect((()=>{E&&(m.current=!0)}),[E]),r.useEffect((()=>{if(!u){const e=e=>c.setEditable(e);return e(h.isEditable()),h.registerEditableListener(e)}}),[c,h,u]),n.jsx(t.LexicalComposerContext.Provider,{value:C,children:!_||E?l:null})};
9
+ "use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),o=require("lexical"),r=require("react"),n=require("react/jsx-runtime");function s(e){const t=new Set,{ownNodeConfig:r}=o.getStaticNodeConfig(e),n=e.transform();if(r){const e=r.$transform;e&&t.add(e)}return n&&t.add(n),t}const a=()=>{},i=()=>{};exports.LexicalNestedComposer=function({initialEditor:c,children:l,initialNodes:d,initialTheme:f,skipCollabChecks:p,skipEditableListener:u}){const x=r.useRef(!1),m=r.useContext(t.LexicalComposerContext);null==m&&function(e,...t){const o=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw o.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[h,{getTheme:g}]=m,C=r.useMemo((()=>{const e=f||g()||void 0,r=t.createLexicalComposerContext(m,e);void 0!==e&&(c._config.theme=e),c._parentEditor=c._parentEditor||h;const n=c._createEditorArgs,l=n&&n.namespace;if(d){a(),l||(i(),c._config.namespace=h._config.namespace);for(let e of d){let t=null,r=null;if("function"!=typeof e){const o=e;e=o.replace,t=o.with,r=o.withKlass||null}const n=o.getRegisteredNode(c,e.getType());c._nodes.set(e.getType(),{exportDOM:n?n.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:r,sharedNodeState:o.createSharedNodeState(e),transforms:s(e)})}}else if(n&&n.nodes)l||(i(),c._config.namespace=h._config.namespace);else{const e=c._nodes=new Map(h._nodes);l||(c._config.namespace=h._config.namespace);for(const[t,r]of e)c._nodes.set(t,{exportDOM:r.exportDOM,klass:r.klass,replace:r.replace,replaceWithKlass:r.replaceWithKlass,sharedNodeState:o.createSharedNodeState(r.klass),transforms:s(r.klass)})}return[c,r]}),[]),_=r.useContext(e.CollaborationContext),{isCollabActive:v,yjsDocMap:E}=_??{},L=p||x.current||E&&E.has(c.getKey());return r.useEffect((()=>{L&&(x.current=!0)}),[L]),r.useEffect((()=>{if(!u){const e=e=>c.setEditable(e);return e(h.isEditable()),h.registerEditableListener(e)}}),[c,h,u]),n.jsx(t.LexicalComposerContext.Provider,{value:C,children:!v||L?l:null})};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{useCollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{createSharedNodeState as r,getRegisteredNode as n,getStaticNodeConfig as i}from"lexical";import{useRef as s,useContext as a,useMemo as l,useEffect as c}from"react";import{jsx as d}from"react/jsx-runtime";function f(e){const t=new Set,{ownNodeConfig:o}=i(e),r=e.transform();if(o){const e=o.$transform;e&&t.add(e)}return r&&t.add(r),t}const p=()=>{},m=()=>{};function h({initialEditor:i,children:h,initialNodes:u,initialTheme:g,skipCollabChecks:x,skipEditableListener:_}){const v=s(!1),w=a(t);null==w&&function(e,...t){const o=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw o.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[E,{getTheme:k}]=w,C=l((()=>{const e=g||k()||void 0,t=o(w,e);void 0!==e&&(i._config.theme=e),i._parentEditor=i._parentEditor||E;const s=i._createEditorArgs,a=s&&s.namespace;if(u){p(),a||(m(),i._config.namespace=E._config.namespace);for(let e of u){let t=null,o=null;if("function"!=typeof e){const r=e;e=r.replace,t=r.with,o=r.withKlass||null}const s=n(i,e.getType());i._nodes.set(e.getType(),{exportDOM:s?s.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:o,sharedNodeState:r(e),transforms:f(e)})}}else if(s&&s.nodes)a||(m(),i._config.namespace=E._config.namespace);else{const e=i._nodes=new Map(E._nodes);a||(i._config.namespace=E._config.namespace);for(const[t,o]of e)i._nodes.set(t,{exportDOM:o.exportDOM,klass:o.klass,replace:o.replace,replaceWithKlass:o.replaceWithKlass,sharedNodeState:r(o.klass),transforms:f(o.klass)})}return[i,t]}),[]),{isCollabActive:b,yjsDocMap:L}=e(),M=x||v.current||L.has(i.getKey());return c((()=>{M&&(v.current=!0)}),[M]),c((()=>{if(!_){const e=e=>i.setEditable(e);return e(E.isEditable()),E.registerEditableListener(e)}}),[i,E,_]),d(t.Provider,{value:C,children:!b||M?h:null})}export{h as LexicalNestedComposer};
9
+ import{CollaborationContext as e}from"@lexical/react/LexicalCollaborationContext";import{LexicalComposerContext as t,createLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{createSharedNodeState as r,getRegisteredNode as n,getStaticNodeConfig as i}from"lexical";import{useRef as s,useContext as a,useMemo as l,useEffect as c}from"react";import{jsx as d}from"react/jsx-runtime";function f(e){const t=new Set,{ownNodeConfig:o}=i(e),r=e.transform();if(o){const e=o.$transform;e&&t.add(e)}return r&&t.add(r),t}const p=()=>{},m=()=>{};function h({initialEditor:i,children:h,initialNodes:u,initialTheme:g,skipCollabChecks:x,skipEditableListener:_}){const v=s(!1),w=a(t);null==w&&function(e,...t){const o=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw o.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${o.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(9);const[E,{getTheme:k}]=w,C=l((()=>{const e=g||k()||void 0,t=o(w,e);void 0!==e&&(i._config.theme=e),i._parentEditor=i._parentEditor||E;const s=i._createEditorArgs,a=s&&s.namespace;if(u){p(),a||(m(),i._config.namespace=E._config.namespace);for(let e of u){let t=null,o=null;if("function"!=typeof e){const r=e;e=r.replace,t=r.with,o=r.withKlass||null}const s=n(i,e.getType());i._nodes.set(e.getType(),{exportDOM:s?s.exportDOM:void 0,klass:e,replace:t,replaceWithKlass:o,sharedNodeState:r(e),transforms:f(e)})}}else if(s&&s.nodes)a||(m(),i._config.namespace=E._config.namespace);else{const e=i._nodes=new Map(E._nodes);a||(i._config.namespace=E._config.namespace);for(const[t,o]of e)i._nodes.set(t,{exportDOM:o.exportDOM,klass:o.klass,replace:o.replace,replaceWithKlass:o.replaceWithKlass,sharedNodeState:r(o.klass),transforms:f(o.klass)})}return[i,t]}),[]),b=a(e),{isCollabActive:L,yjsDocMap:M}=b??{},S=x||v.current||M&&M.has(i.getKey());return c((()=>{S&&(v.current=!0)}),[S]),c((()=>{if(!_){const e=e=>i.setEditable(e);return e(E.isEditable()),E.registerEditableListener(e)}}),[i,E,_]),d(t.Provider,{value:C,children:!L||S?h:null})}export{h as LexicalNestedComposer};
@@ -6,10 +6,10 @@
6
6
  *
7
7
  */
8
8
  import { LexicalNode } from 'lexical';
9
- import { MutableRefObject } from 'react';
9
+ import { JSX, RefObject } from 'react';
10
10
  declare class MenuOption {
11
11
  key: string;
12
- ref?: MutableRefObject<HTMLElement | null>;
12
+ ref?: RefObject<HTMLElement | null>;
13
13
  constructor(key: string);
14
14
  setRefElement(element: HTMLElement | null): void;
15
15
  }