@lexical/react 0.5.1-next.2 → 0.6.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.
- package/DEPRECATED_useLexicalDecorators.d.ts +1 -1
- package/DEPRECATED_useLexicalDecorators.dev.js +2 -123
- package/DEPRECATED_useLexicalDecorators.js.flow +1 -2
- package/DEPRECATED_useLexicalDecorators.prod.js +2 -6
- package/LexicalErrorBoundary.d.ts +13 -0
- package/LexicalErrorBoundary.dev.js +159 -0
- package/LexicalErrorBoundary.js +9 -0
- package/LexicalErrorBoundary.js.flow +14 -0
- package/LexicalErrorBoundary.prod.js +10 -0
- package/LexicalPlainTextPlugin.d.ts +1 -1
- package/LexicalPlainTextPlugin.dev.js +2 -123
- package/LexicalPlainTextPlugin.js.flow +1 -2
- package/LexicalPlainTextPlugin.prod.js +4 -7
- package/LexicalRichTextPlugin.d.ts +1 -1
- package/LexicalRichTextPlugin.dev.js +2 -123
- package/LexicalRichTextPlugin.js.flow +1 -2
- package/LexicalRichTextPlugin.prod.js +4 -7
- package/package.json +20 -19
- package/shared/useDecorators.d.ts +1 -1
- package/shared/ReactErrorBoundary.d.ts +0 -63
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { LexicalEditor } from 'lexical';
|
|
9
9
|
import { ErrorBoundaryType } from './shared/useDecorators';
|
|
10
|
-
export declare function useLexicalDecorators(editor: LexicalEditor, ErrorBoundary
|
|
10
|
+
export declare function useLexicalDecorators(editor: LexicalEditor, ErrorBoundary: ErrorBoundaryType): Array<JSX.Element>;
|
|
@@ -9,103 +9,6 @@
|
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var reactDom = require('react-dom');
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const changedArray = (a = [], b = []) => a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
21
|
-
|
|
22
|
-
const initialState = {
|
|
23
|
-
error: null
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
class ErrorBoundary extends React.Component {
|
|
27
|
-
constructor(props) {
|
|
28
|
-
super(props);
|
|
29
|
-
this.state = initialState;
|
|
30
|
-
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static getDerivedStateFromError(error) {
|
|
34
|
-
return {
|
|
35
|
-
error
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
resetErrorBoundary(...args) {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
// eslint-disable-next-line no-unused-expressions
|
|
42
|
-
this.props.onReset && this.props.onReset(...args);
|
|
43
|
-
this.reset();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
reset() {
|
|
47
|
-
this.setState(initialState);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
componentDidCatch(error, info) {
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
// eslint-disable-next-line no-unused-expressions
|
|
53
|
-
this.props.onError && this.props.onError(error, info);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
componentDidUpdate(prevProps, prevState) {
|
|
57
|
-
const {
|
|
58
|
-
error
|
|
59
|
-
} = this.state;
|
|
60
|
-
const {
|
|
61
|
-
resetKeys
|
|
62
|
-
} = this.props; // There's an edge case where if the thing that triggered the error
|
|
63
|
-
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
64
|
-
// the error boundary immediately. This would likely trigger a second
|
|
65
|
-
// error to be thrown.
|
|
66
|
-
// So we make sure that we don't check the resetKeys on the first call
|
|
67
|
-
// of cDU after the error is set
|
|
68
|
-
|
|
69
|
-
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
// eslint-disable-next-line no-unused-expressions
|
|
72
|
-
this.props.onResetKeysChange && this.props.onResetKeysChange(prevProps.resetKeys, resetKeys);
|
|
73
|
-
this.reset();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
render() {
|
|
78
|
-
const {
|
|
79
|
-
error
|
|
80
|
-
} = this.state;
|
|
81
|
-
const {
|
|
82
|
-
fallbackRender,
|
|
83
|
-
FallbackComponent,
|
|
84
|
-
fallback
|
|
85
|
-
} = this.props;
|
|
86
|
-
|
|
87
|
-
if (error !== null) {
|
|
88
|
-
const props = {
|
|
89
|
-
error,
|
|
90
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
if ( /*#__PURE__*/React.isValidElement(fallback)) {
|
|
94
|
-
return fallback;
|
|
95
|
-
} else if (typeof fallbackRender === 'function') {
|
|
96
|
-
return fallbackRender(props);
|
|
97
|
-
} else if (FallbackComponent) {
|
|
98
|
-
return /*#__PURE__*/React.createElement(FallbackComponent, props);
|
|
99
|
-
} else {
|
|
100
|
-
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return this.props.children;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
12
|
/**
|
|
110
13
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
111
14
|
*
|
|
@@ -132,19 +35,7 @@ var useLayoutEffect = useLayoutEffectImpl;
|
|
|
132
35
|
* LICENSE file in the root directory of this source tree.
|
|
133
36
|
*
|
|
134
37
|
*/
|
|
135
|
-
|
|
136
|
-
const fallbackRenderer$1 = () => null;
|
|
137
|
-
|
|
138
|
-
const DefaultErrorBoundary$1 = ({
|
|
139
|
-
children,
|
|
140
|
-
onError
|
|
141
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
142
|
-
fallbackRender: fallbackRenderer$1,
|
|
143
|
-
onError: onError
|
|
144
|
-
}, children);
|
|
145
|
-
|
|
146
|
-
function useDecorators(editor, // TODO 0.6 Make non-optional non-default
|
|
147
|
-
ErrorBoundary = DefaultErrorBoundary$1) {
|
|
38
|
+
function useDecorators(editor, ErrorBoundary) {
|
|
148
39
|
const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
|
|
149
40
|
|
|
150
41
|
useLayoutEffect(() => {
|
|
@@ -190,19 +81,7 @@ ErrorBoundary = DefaultErrorBoundary$1) {
|
|
|
190
81
|
* LICENSE file in the root directory of this source tree.
|
|
191
82
|
*
|
|
192
83
|
*/
|
|
193
|
-
|
|
194
|
-
const fallbackRenderer = () => null;
|
|
195
|
-
|
|
196
|
-
const DefaultErrorBoundary = ({
|
|
197
|
-
children,
|
|
198
|
-
onError
|
|
199
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
200
|
-
fallbackRender: fallbackRenderer,
|
|
201
|
-
onError: onError
|
|
202
|
-
}, children);
|
|
203
|
-
|
|
204
|
-
function useLexicalDecorators(editor, // TODO 0.6 Make non-optional non-default
|
|
205
|
-
ErrorBoundary = DefaultErrorBoundary) {
|
|
84
|
+
function useLexicalDecorators(editor, ErrorBoundary) {
|
|
206
85
|
return useDecorators(editor, ErrorBoundary);
|
|
207
86
|
}
|
|
208
87
|
|
|
@@ -20,6 +20,5 @@ export type ErrorBoundaryType = React.AbstractComponent<ErrorBoundaryProps>;
|
|
|
20
20
|
|
|
21
21
|
declare export function useLexicalDecorators(
|
|
22
22
|
editor: LexicalEditor,
|
|
23
|
-
|
|
24
|
-
ErrorBoundary?: ErrorBoundaryType,
|
|
23
|
+
ErrorBoundary: ErrorBoundaryType,
|
|
25
24
|
): Array<React.Node>;
|
|
@@ -4,9 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var
|
|
8
|
-
|
|
9
|
-
e),this.reset())}render(){var {error:a}=this.state;let {fallbackRender:b,FallbackComponent:d,fallback:e}=this.props;if(null!==a){a={error:a,resetErrorBoundary:this.resetErrorBoundary};if(c.isValidElement(e))return e;if("function"===typeof b)return b(a);if(d)return c.createElement(d,a);throw Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop");}return this.props.children}}
|
|
10
|
-
var q="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?c.useLayoutEffect:c.useEffect;let r=()=>null,t=({children:a,onError:b})=>c.createElement(p,{fallbackRender:r,onError:b},a);
|
|
11
|
-
function u(a,b=t){let [d,e]=c.useState(()=>a.getDecorators());q(()=>a.registerDecoratorListener(g=>{k.flushSync(()=>{e(g)})}),[a]);c.useEffect(()=>{e(a.getDecorators())},[a]);return c.useMemo(()=>{let g=[],n=Object.keys(d);for(let h=0;h<n.length;h++){var f=n[h];let w=c.createElement(b,{onError:v=>a._onError(v)},c.createElement(c.Suspense,{fallback:null},d[f]));f=a.getElementByKey(f);null!==f&&g.push(k.createPortal(w,f))}return g},[b,d,a])}
|
|
12
|
-
let x=()=>null,y=({children:a,onError:b})=>c.createElement(p,{fallbackRender:x,onError:b},a);exports.useLexicalDecorators=function(a,b=y){return u(a,b)}
|
|
7
|
+
'use strict';var b=require("react"),h=require("react-dom"),m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?b.useLayoutEffect:b.useEffect;
|
|
8
|
+
function n(a,d){let [f,k]=b.useState(()=>a.getDecorators());m(()=>a.registerDecoratorListener(e=>{h.flushSync(()=>{k(e)})}),[a]);b.useEffect(()=>{k(a.getDecorators())},[a]);return b.useMemo(()=>{let e=[],l=Object.keys(f);for(let g=0;g<l.length;g++){var c=l[g];let q=b.createElement(d,{onError:p=>a._onError(p)},b.createElement(b.Suspense,{fallback:null},f[c]));c=a.getElementByKey(c);null!==c&&e.push(h.createPortal(q,c))}return e},[d,f,a])}exports.useLexicalDecorators=function(a,d){return n(a,d)}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
declare type Props = {
|
|
9
|
+
children: JSX.Element;
|
|
10
|
+
onError: (error: Error) => void;
|
|
11
|
+
};
|
|
12
|
+
export default function LexicalErrorBoundary({ children, onError, }: Props): JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var React = require('react');
|
|
10
|
+
|
|
11
|
+
function _setPrototypeOf(o, p) {
|
|
12
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
13
|
+
o.__proto__ = p;
|
|
14
|
+
return o;
|
|
15
|
+
};
|
|
16
|
+
return _setPrototypeOf(o, p);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _inheritsLoose(subClass, superClass) {
|
|
20
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
21
|
+
subClass.prototype.constructor = subClass;
|
|
22
|
+
_setPrototypeOf(subClass, superClass);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var changedArray = function changedArray(a, b) {
|
|
26
|
+
if (a === void 0) {
|
|
27
|
+
a = [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (b === void 0) {
|
|
31
|
+
b = [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return a.length !== b.length || a.some(function (item, index) {
|
|
35
|
+
return !Object.is(item, b[index]);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var initialState = {
|
|
40
|
+
error: null
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
44
|
+
_inheritsLoose(ErrorBoundary, _React$Component);
|
|
45
|
+
|
|
46
|
+
function ErrorBoundary() {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
|
+
_args[_key] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
54
|
+
_this.state = initialState;
|
|
55
|
+
|
|
56
|
+
_this.resetErrorBoundary = function () {
|
|
57
|
+
var _this$props;
|
|
58
|
+
|
|
59
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
60
|
+
args[_key2] = arguments[_key2];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
|
|
64
|
+
|
|
65
|
+
_this.reset();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
|
|
72
|
+
return {
|
|
73
|
+
error: error
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var _proto = ErrorBoundary.prototype;
|
|
78
|
+
|
|
79
|
+
_proto.reset = function reset() {
|
|
80
|
+
this.setState(initialState);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
_proto.componentDidCatch = function componentDidCatch(error, info) {
|
|
84
|
+
var _this$props$onError, _this$props2;
|
|
85
|
+
|
|
86
|
+
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
90
|
+
var error = this.state.error;
|
|
91
|
+
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
92
|
+
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
93
|
+
// the error boundary immediately. This would likely trigger a second
|
|
94
|
+
// error to be thrown.
|
|
95
|
+
// So we make sure that we don't check the resetKeys on the first call
|
|
96
|
+
// of cDU after the error is set
|
|
97
|
+
|
|
98
|
+
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
99
|
+
var _this$props$onResetKe, _this$props3;
|
|
100
|
+
|
|
101
|
+
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
|
|
102
|
+
this.reset();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
_proto.render = function render() {
|
|
107
|
+
var error = this.state.error;
|
|
108
|
+
var _this$props4 = this.props,
|
|
109
|
+
fallbackRender = _this$props4.fallbackRender,
|
|
110
|
+
FallbackComponent = _this$props4.FallbackComponent,
|
|
111
|
+
fallback = _this$props4.fallback;
|
|
112
|
+
|
|
113
|
+
if (error !== null) {
|
|
114
|
+
var _props = {
|
|
115
|
+
error: error,
|
|
116
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if ( /*#__PURE__*/React.isValidElement(fallback)) {
|
|
120
|
+
return fallback;
|
|
121
|
+
} else if (typeof fallbackRender === 'function') {
|
|
122
|
+
return fallbackRender(_props);
|
|
123
|
+
} else if (FallbackComponent) {
|
|
124
|
+
return /*#__PURE__*/React.createElement(FallbackComponent, _props);
|
|
125
|
+
} else {
|
|
126
|
+
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return this.props.children;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
return ErrorBoundary;
|
|
134
|
+
}(React.Component);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the MIT license found in the
|
|
140
|
+
* LICENSE file in the root directory of this source tree.
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
function LexicalErrorBoundary({
|
|
144
|
+
children,
|
|
145
|
+
onError
|
|
146
|
+
}) {
|
|
147
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
148
|
+
fallback: /*#__PURE__*/React.createElement("div", {
|
|
149
|
+
style: {
|
|
150
|
+
border: '1px solid #f00',
|
|
151
|
+
color: '#f00',
|
|
152
|
+
padding: '8px'
|
|
153
|
+
}
|
|
154
|
+
}, "An error was thrown."),
|
|
155
|
+
onError: onError
|
|
156
|
+
}, children);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = LexicalErrorBoundary;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
'use strict'
|
|
8
|
+
const LexicalErrorBoundary = process.env.NODE_ENV === 'development' ? require('./LexicalErrorBoundary.dev.js') : require('./LexicalErrorBoundary.prod.js')
|
|
9
|
+
module.exports = LexicalErrorBoundary;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type Props = $ReadOnly<{
|
|
10
|
+
children: JSX.Element,
|
|
11
|
+
onError: (error: Error) => void,
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
declare export default function LexicalErrorBoundary(): React.ReactNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
'use strict';var h=require("react");function m(b,c){m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,a){g.__proto__=a;return g};return m(b,c)}function n(b,c){b.prototype=Object.create(c.prototype);b.prototype.constructor=b;m(b,c)}function r(b,c){void 0===b&&(b=[]);void 0===c&&(c=[]);return b.length!==c.length||b.some(function(g,a){return!Object.is(g,c[a])})}
|
|
8
|
+
var t={error:null},u=function(b){function c(){for(var a,d=arguments.length,f=Array(d),e=0;e<d;e++)f[e]=arguments[e];a=b.call.apply(b,[this].concat(f))||this;a.state=t;a.resetErrorBoundary=function(){for(var k,p=arguments.length,q=Array(p),l=0;l<p;l++)q[l]=arguments[l];null==a.props.onReset?void 0:(k=a.props).onReset.apply(k,q);a.reset()};return a}n(c,b);c.getDerivedStateFromError=function(a){return{error:a}};var g=c.prototype;g.reset=function(){this.setState(t)};g.componentDidCatch=function(a,d){var f,
|
|
9
|
+
e;null==(f=(e=this.props).onError)?void 0:f.call(e,a,d)};g.componentDidUpdate=function(a,d){var f=this.props.resetKeys;if(null!==this.state.error&&null!==d.error&&r(a.resetKeys,f)){var e,k;null==(e=(k=this.props).onResetKeysChange)?void 0:e.call(k,a.resetKeys,f);this.reset()}};g.render=function(){var a=this.state.error,d=this.props,f=d.fallbackRender,e=d.FallbackComponent;d=d.fallback;if(null!==a){a={error:a,resetErrorBoundary:this.resetErrorBoundary};if(h.isValidElement(d))return d;if("function"===
|
|
10
|
+
typeof f)return f(a);if(e)return h.createElement(e,a);throw Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop");}return this.props.children};return c}(h.Component);module.exports=function({children:b,onError:c}){return h.createElement(u,{fallback:h.createElement("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"}},"An error was thrown."),onError:c},b)}
|
|
@@ -9,5 +9,5 @@ import { ErrorBoundaryType } from './shared/useDecorators';
|
|
|
9
9
|
export declare function PlainTextPlugin({ contentEditable, placeholder, ErrorBoundary, }: {
|
|
10
10
|
contentEditable: JSX.Element;
|
|
11
11
|
placeholder: JSX.Element | string;
|
|
12
|
-
ErrorBoundary
|
|
12
|
+
ErrorBoundary: ErrorBoundaryType;
|
|
13
13
|
}): JSX.Element;
|
|
@@ -14,103 +14,6 @@ var reactDom = require('react-dom');
|
|
|
14
14
|
var dragon = require('@lexical/dragon');
|
|
15
15
|
var plainText = require('@lexical/plain-text');
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the MIT license found in the
|
|
21
|
-
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const changedArray = (a = [], b = []) => a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
26
|
-
|
|
27
|
-
const initialState = {
|
|
28
|
-
error: null
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class ErrorBoundary extends React.Component {
|
|
32
|
-
constructor(props) {
|
|
33
|
-
super(props);
|
|
34
|
-
this.state = initialState;
|
|
35
|
-
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static getDerivedStateFromError(error) {
|
|
39
|
-
return {
|
|
40
|
-
error
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
resetErrorBoundary(...args) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
// eslint-disable-next-line no-unused-expressions
|
|
47
|
-
this.props.onReset && this.props.onReset(...args);
|
|
48
|
-
this.reset();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
reset() {
|
|
52
|
-
this.setState(initialState);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
componentDidCatch(error, info) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
// eslint-disable-next-line no-unused-expressions
|
|
58
|
-
this.props.onError && this.props.onError(error, info);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
componentDidUpdate(prevProps, prevState) {
|
|
62
|
-
const {
|
|
63
|
-
error
|
|
64
|
-
} = this.state;
|
|
65
|
-
const {
|
|
66
|
-
resetKeys
|
|
67
|
-
} = this.props; // There's an edge case where if the thing that triggered the error
|
|
68
|
-
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
69
|
-
// the error boundary immediately. This would likely trigger a second
|
|
70
|
-
// error to be thrown.
|
|
71
|
-
// So we make sure that we don't check the resetKeys on the first call
|
|
72
|
-
// of cDU after the error is set
|
|
73
|
-
|
|
74
|
-
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
// eslint-disable-next-line no-unused-expressions
|
|
77
|
-
this.props.onResetKeysChange && this.props.onResetKeysChange(prevProps.resetKeys, resetKeys);
|
|
78
|
-
this.reset();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
render() {
|
|
83
|
-
const {
|
|
84
|
-
error
|
|
85
|
-
} = this.state;
|
|
86
|
-
const {
|
|
87
|
-
fallbackRender,
|
|
88
|
-
FallbackComponent,
|
|
89
|
-
fallback
|
|
90
|
-
} = this.props;
|
|
91
|
-
|
|
92
|
-
if (error !== null) {
|
|
93
|
-
const props = {
|
|
94
|
-
error,
|
|
95
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
if ( /*#__PURE__*/React.isValidElement(fallback)) {
|
|
99
|
-
return fallback;
|
|
100
|
-
} else if (typeof fallbackRender === 'function') {
|
|
101
|
-
return fallbackRender(props);
|
|
102
|
-
} else if (FallbackComponent) {
|
|
103
|
-
return /*#__PURE__*/React.createElement(FallbackComponent, props);
|
|
104
|
-
} else {
|
|
105
|
-
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return this.props.children;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
17
|
/**
|
|
115
18
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
116
19
|
*
|
|
@@ -168,19 +71,7 @@ function useCanShowPlaceholder(editor) {
|
|
|
168
71
|
* LICENSE file in the root directory of this source tree.
|
|
169
72
|
*
|
|
170
73
|
*/
|
|
171
|
-
|
|
172
|
-
const fallbackRenderer$1 = () => null;
|
|
173
|
-
|
|
174
|
-
const DefaultErrorBoundary$1 = ({
|
|
175
|
-
children,
|
|
176
|
-
onError
|
|
177
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
178
|
-
fallbackRender: fallbackRenderer$1,
|
|
179
|
-
onError: onError
|
|
180
|
-
}, children);
|
|
181
|
-
|
|
182
|
-
function useDecorators(editor, // TODO 0.6 Make non-optional non-default
|
|
183
|
-
ErrorBoundary = DefaultErrorBoundary$1) {
|
|
74
|
+
function useDecorators(editor, ErrorBoundary) {
|
|
184
75
|
const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
|
|
185
76
|
|
|
186
77
|
useLayoutEffect(() => {
|
|
@@ -240,22 +131,10 @@ function usePlainTextSetup(editor) {
|
|
|
240
131
|
* LICENSE file in the root directory of this source tree.
|
|
241
132
|
*
|
|
242
133
|
*/
|
|
243
|
-
|
|
244
|
-
const fallbackRenderer = () => null;
|
|
245
|
-
|
|
246
|
-
const DefaultErrorBoundary = ({
|
|
247
|
-
children,
|
|
248
|
-
onError
|
|
249
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
250
|
-
fallbackRender: fallbackRenderer,
|
|
251
|
-
onError: onError
|
|
252
|
-
}, children);
|
|
253
|
-
|
|
254
134
|
function PlainTextPlugin({
|
|
255
135
|
contentEditable,
|
|
256
136
|
placeholder,
|
|
257
|
-
|
|
258
|
-
ErrorBoundary = DefaultErrorBoundary
|
|
137
|
+
ErrorBoundary
|
|
259
138
|
}) {
|
|
260
139
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
261
140
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
@@ -19,6 +19,5 @@ type InitialEditorStateType =
|
|
|
19
19
|
declare export function PlainTextPlugin({
|
|
20
20
|
contentEditable: React$Node,
|
|
21
21
|
placeholder: React$Node,
|
|
22
|
-
|
|
23
|
-
ErrorBoundary?: ErrorBoundaryType,
|
|
22
|
+
ErrorBoundary: ErrorBoundaryType,
|
|
24
23
|
}): React$Node;
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let z=()=>null,A=({children:a,onError:b})=>h.createElement(v,{fallbackRender:z,onError:b},a);
|
|
12
|
-
function B(a,b=A){let [e,c]=h.useState(()=>a.getDecorators());w(()=>a.registerDecoratorListener(f=>{n.flushSync(()=>{c(f)})}),[a]);h.useEffect(()=>{c(a.getDecorators())},[a]);return h.useMemo(()=>{let f=[],r=Object.keys(e);for(let k=0;k<r.length;k++){var g=r[k];let D=h.createElement(b,{onError:C=>a._onError(C)},h.createElement(h.Suspense,{fallback:null},e[g]));g=a.getElementByKey(g);null!==g&&f.push(n.createPortal(D,g))}return f},[b,e,a])}
|
|
13
|
-
function E(a){w(()=>m.mergeRegister(q.registerPlainText(a),p.registerDragonSupport(a)),[a])}let F=()=>null,G=({children:a,onError:b})=>h.createElement(v,{fallbackRender:F,onError:b},a);exports.PlainTextPlugin=function({contentEditable:a,placeholder:b,ErrorBoundary:e=G}){let [c]=d.useLexicalComposerContext(),f=y(c);e=B(c,e);E(c);return h.createElement(h.Fragment,null,a,f&&b,e)}
|
|
7
|
+
'use strict';var b=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),q=require("@lexical/dragon"),r=require("@lexical/plain-text"),t="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function u(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isEditable()))}
|
|
8
|
+
function v(a){let [f,d]=h.useState(()=>u(a));t(()=>{function c(){let e=u(a);d(e)}c();return m.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerEditableListener(()=>{c()}))},[a]);return f}
|
|
9
|
+
function w(a,f){let [d,c]=h.useState(()=>a.getDecorators());t(()=>a.registerDecoratorListener(e=>{n.flushSync(()=>{c(e)})}),[a]);h.useEffect(()=>{c(a.getDecorators())},[a]);return h.useMemo(()=>{let e=[],p=Object.keys(d);for(let k=0;k<p.length;k++){var g=p[k];let y=h.createElement(f,{onError:x=>a._onError(x)},h.createElement(h.Suspense,{fallback:null},d[g]));g=a.getElementByKey(g);null!==g&&e.push(n.createPortal(y,g))}return e},[f,d,a])}
|
|
10
|
+
function z(a){t(()=>m.mergeRegister(r.registerPlainText(a),q.registerDragonSupport(a)),[a])}exports.PlainTextPlugin=function({contentEditable:a,placeholder:f,ErrorBoundary:d}){let [c]=b.useLexicalComposerContext(),e=v(c);d=w(c,d);z(c);return h.createElement(h.Fragment,null,a,e&&f,d)}
|
|
@@ -9,5 +9,5 @@ import { ErrorBoundaryType } from './shared/useDecorators';
|
|
|
9
9
|
export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary, }: Readonly<{
|
|
10
10
|
contentEditable: JSX.Element;
|
|
11
11
|
placeholder: JSX.Element | string;
|
|
12
|
-
ErrorBoundary
|
|
12
|
+
ErrorBoundary: ErrorBoundaryType;
|
|
13
13
|
}>): JSX.Element;
|
|
@@ -14,103 +14,6 @@ var reactDom = require('react-dom');
|
|
|
14
14
|
var dragon = require('@lexical/dragon');
|
|
15
15
|
var richText = require('@lexical/rich-text');
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the MIT license found in the
|
|
21
|
-
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const changedArray = (a = [], b = []) => a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
26
|
-
|
|
27
|
-
const initialState = {
|
|
28
|
-
error: null
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
class ErrorBoundary extends React.Component {
|
|
32
|
-
constructor(props) {
|
|
33
|
-
super(props);
|
|
34
|
-
this.state = initialState;
|
|
35
|
-
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static getDerivedStateFromError(error) {
|
|
39
|
-
return {
|
|
40
|
-
error
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
resetErrorBoundary(...args) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
// eslint-disable-next-line no-unused-expressions
|
|
47
|
-
this.props.onReset && this.props.onReset(...args);
|
|
48
|
-
this.reset();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
reset() {
|
|
52
|
-
this.setState(initialState);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
componentDidCatch(error, info) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
// eslint-disable-next-line no-unused-expressions
|
|
58
|
-
this.props.onError && this.props.onError(error, info);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
componentDidUpdate(prevProps, prevState) {
|
|
62
|
-
const {
|
|
63
|
-
error
|
|
64
|
-
} = this.state;
|
|
65
|
-
const {
|
|
66
|
-
resetKeys
|
|
67
|
-
} = this.props; // There's an edge case where if the thing that triggered the error
|
|
68
|
-
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
69
|
-
// the error boundary immediately. This would likely trigger a second
|
|
70
|
-
// error to be thrown.
|
|
71
|
-
// So we make sure that we don't check the resetKeys on the first call
|
|
72
|
-
// of cDU after the error is set
|
|
73
|
-
|
|
74
|
-
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
// eslint-disable-next-line no-unused-expressions
|
|
77
|
-
this.props.onResetKeysChange && this.props.onResetKeysChange(prevProps.resetKeys, resetKeys);
|
|
78
|
-
this.reset();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
render() {
|
|
83
|
-
const {
|
|
84
|
-
error
|
|
85
|
-
} = this.state;
|
|
86
|
-
const {
|
|
87
|
-
fallbackRender,
|
|
88
|
-
FallbackComponent,
|
|
89
|
-
fallback
|
|
90
|
-
} = this.props;
|
|
91
|
-
|
|
92
|
-
if (error !== null) {
|
|
93
|
-
const props = {
|
|
94
|
-
error,
|
|
95
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
if ( /*#__PURE__*/React.isValidElement(fallback)) {
|
|
99
|
-
return fallback;
|
|
100
|
-
} else if (typeof fallbackRender === 'function') {
|
|
101
|
-
return fallbackRender(props);
|
|
102
|
-
} else if (FallbackComponent) {
|
|
103
|
-
return /*#__PURE__*/React.createElement(FallbackComponent, props);
|
|
104
|
-
} else {
|
|
105
|
-
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return this.props.children;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
17
|
/**
|
|
115
18
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
116
19
|
*
|
|
@@ -168,19 +71,7 @@ function useCanShowPlaceholder(editor) {
|
|
|
168
71
|
* LICENSE file in the root directory of this source tree.
|
|
169
72
|
*
|
|
170
73
|
*/
|
|
171
|
-
|
|
172
|
-
const fallbackRenderer$1 = () => null;
|
|
173
|
-
|
|
174
|
-
const DefaultErrorBoundary$1 = ({
|
|
175
|
-
children,
|
|
176
|
-
onError
|
|
177
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
178
|
-
fallbackRender: fallbackRenderer$1,
|
|
179
|
-
onError: onError
|
|
180
|
-
}, children);
|
|
181
|
-
|
|
182
|
-
function useDecorators(editor, // TODO 0.6 Make non-optional non-default
|
|
183
|
-
ErrorBoundary = DefaultErrorBoundary$1) {
|
|
74
|
+
function useDecorators(editor, ErrorBoundary) {
|
|
184
75
|
const [decorators, setDecorators] = React.useState(() => editor.getDecorators()); // Subscribe to changes
|
|
185
76
|
|
|
186
77
|
useLayoutEffect(() => {
|
|
@@ -240,22 +131,10 @@ function useRichTextSetup(editor) {
|
|
|
240
131
|
* LICENSE file in the root directory of this source tree.
|
|
241
132
|
*
|
|
242
133
|
*/
|
|
243
|
-
|
|
244
|
-
const fallbackRenderer = () => null;
|
|
245
|
-
|
|
246
|
-
const DefaultErrorBoundary = ({
|
|
247
|
-
children,
|
|
248
|
-
onError
|
|
249
|
-
}) => /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
250
|
-
fallbackRender: fallbackRenderer,
|
|
251
|
-
onError: onError
|
|
252
|
-
}, children);
|
|
253
|
-
|
|
254
134
|
function RichTextPlugin({
|
|
255
135
|
contentEditable,
|
|
256
136
|
placeholder,
|
|
257
|
-
|
|
258
|
-
ErrorBoundary = DefaultErrorBoundary
|
|
137
|
+
ErrorBoundary
|
|
259
138
|
}) {
|
|
260
139
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
261
140
|
const showPlaceholder = useCanShowPlaceholder(editor);
|
|
@@ -19,6 +19,5 @@ type InitialEditorStateType =
|
|
|
19
19
|
declare export function RichTextPlugin({
|
|
20
20
|
contentEditable: React$Node,
|
|
21
21
|
placeholder: React$Node,
|
|
22
|
-
|
|
23
|
-
ErrorBoundary?: ErrorBoundaryType,
|
|
22
|
+
ErrorBoundary: ErrorBoundaryType,
|
|
24
23
|
}): React$Node;
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let z=()=>null,A=({children:a,onError:b})=>h.createElement(v,{fallbackRender:z,onError:b},a);
|
|
12
|
-
function B(a,b=A){let [e,c]=h.useState(()=>a.getDecorators());w(()=>a.registerDecoratorListener(f=>{n.flushSync(()=>{c(f)})}),[a]);h.useEffect(()=>{c(a.getDecorators())},[a]);return h.useMemo(()=>{let f=[],r=Object.keys(e);for(let k=0;k<r.length;k++){var g=r[k];let D=h.createElement(b,{onError:C=>a._onError(C)},h.createElement(h.Suspense,{fallback:null},e[g]));g=a.getElementByKey(g);null!==g&&f.push(n.createPortal(D,g))}return f},[b,e,a])}
|
|
13
|
-
function E(a){w(()=>m.mergeRegister(q.registerRichText(a),p.registerDragonSupport(a)),[a])}let F=()=>null,G=({children:a,onError:b})=>h.createElement(v,{fallbackRender:F,onError:b},a);exports.RichTextPlugin=function({contentEditable:a,placeholder:b,ErrorBoundary:e=G}){let [c]=d.useLexicalComposerContext(),f=y(c);e=B(c,e);E(c);return h.createElement(h.Fragment,null,a,f&&b,e)}
|
|
7
|
+
'use strict';var b=require("@lexical/react/LexicalComposerContext"),h=require("react"),l=require("@lexical/text"),m=require("@lexical/utils"),n=require("react-dom"),q=require("@lexical/dragon"),r=require("@lexical/rich-text"),t="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?h.useLayoutEffect:h.useEffect;function u(a){return a.getEditorState().read(l.$canShowPlaceholderCurry(a.isComposing(),a.isEditable()))}
|
|
8
|
+
function v(a){let [f,d]=h.useState(()=>u(a));t(()=>{function c(){let e=u(a);d(e)}c();return m.mergeRegister(a.registerUpdateListener(()=>{c()}),a.registerEditableListener(()=>{c()}))},[a]);return f}
|
|
9
|
+
function w(a,f){let [d,c]=h.useState(()=>a.getDecorators());t(()=>a.registerDecoratorListener(e=>{n.flushSync(()=>{c(e)})}),[a]);h.useEffect(()=>{c(a.getDecorators())},[a]);return h.useMemo(()=>{let e=[],p=Object.keys(d);for(let k=0;k<p.length;k++){var g=p[k];let y=h.createElement(f,{onError:x=>a._onError(x)},h.createElement(h.Suspense,{fallback:null},d[g]));g=a.getElementByKey(g);null!==g&&e.push(n.createPortal(y,g))}return e},[f,d,a])}
|
|
10
|
+
function z(a){t(()=>m.mergeRegister(r.registerRichText(a),q.registerDragonSupport(a)),[a])}exports.RichTextPlugin=function({contentEditable:a,placeholder:f,ErrorBoundary:d}){let [c]=b.useLexicalComposerContext(),e=v(c);d=w(c,d);z(c);return h.createElement(h.Fragment,null,a,e&&f,d)}
|
package/package.json
CHANGED
|
@@ -8,28 +8,29 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.6.0",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.
|
|
14
|
-
"@lexical/code": "0.
|
|
15
|
-
"@lexical/dragon": "0.
|
|
16
|
-
"@lexical/hashtag": "0.
|
|
17
|
-
"@lexical/history": "0.
|
|
18
|
-
"@lexical/link": "0.
|
|
19
|
-
"@lexical/list": "0.
|
|
20
|
-
"@lexical/mark": "0.
|
|
21
|
-
"@lexical/markdown": "0.
|
|
22
|
-
"@lexical/overflow": "0.
|
|
23
|
-
"@lexical/plain-text": "0.
|
|
24
|
-
"@lexical/rich-text": "0.
|
|
25
|
-
"@lexical/selection": "0.
|
|
26
|
-
"@lexical/table": "0.
|
|
27
|
-
"@lexical/text": "0.
|
|
28
|
-
"@lexical/utils": "0.
|
|
29
|
-
"@lexical/yjs": "0.
|
|
13
|
+
"@lexical/clipboard": "0.6.0",
|
|
14
|
+
"@lexical/code": "0.6.0",
|
|
15
|
+
"@lexical/dragon": "0.6.0",
|
|
16
|
+
"@lexical/hashtag": "0.6.0",
|
|
17
|
+
"@lexical/history": "0.6.0",
|
|
18
|
+
"@lexical/link": "0.6.0",
|
|
19
|
+
"@lexical/list": "0.6.0",
|
|
20
|
+
"@lexical/mark": "0.6.0",
|
|
21
|
+
"@lexical/markdown": "0.6.0",
|
|
22
|
+
"@lexical/overflow": "0.6.0",
|
|
23
|
+
"@lexical/plain-text": "0.6.0",
|
|
24
|
+
"@lexical/rich-text": "0.6.0",
|
|
25
|
+
"@lexical/selection": "0.6.0",
|
|
26
|
+
"@lexical/table": "0.6.0",
|
|
27
|
+
"@lexical/text": "0.6.0",
|
|
28
|
+
"@lexical/utils": "0.6.0",
|
|
29
|
+
"@lexical/yjs": "0.6.0",
|
|
30
|
+
"react-error-boundary": "^3.1.4"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"lexical": "0.
|
|
33
|
+
"lexical": "0.6.0",
|
|
33
34
|
"react": ">=17.x",
|
|
34
35
|
"react-dom": ">=17.x"
|
|
35
36
|
},
|
|
@@ -12,5 +12,5 @@ declare type ErrorBoundaryProps = {
|
|
|
12
12
|
onError: (error: Error) => void;
|
|
13
13
|
};
|
|
14
14
|
export declare type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;
|
|
15
|
-
export declare function useDecorators(editor: LexicalEditor, ErrorBoundary
|
|
15
|
+
export declare function useDecorators(editor: LexicalEditor, ErrorBoundary: ErrorBoundaryType): Array<JSX.Element>;
|
|
16
16
|
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
interface FallbackProps {
|
|
10
|
-
error: Error;
|
|
11
|
-
resetErrorBoundary: (...args: Array<unknown>) => void;
|
|
12
|
-
}
|
|
13
|
-
interface ErrorBoundaryPropsWithComponent {
|
|
14
|
-
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
15
|
-
onReset?: (...args: Array<unknown>) => void;
|
|
16
|
-
onError?: (error: Error, info: {
|
|
17
|
-
componentStack: string;
|
|
18
|
-
}) => void;
|
|
19
|
-
resetKeys?: Array<unknown>;
|
|
20
|
-
fallback?: never;
|
|
21
|
-
FallbackComponent: React.ComponentType<FallbackProps>;
|
|
22
|
-
fallbackRender?: never;
|
|
23
|
-
}
|
|
24
|
-
declare function FallbackRender(props: FallbackProps): React.ReactElement<unknown, string | React.FunctionComponent | typeof React.Component> | null;
|
|
25
|
-
interface ErrorBoundaryPropsWithRender {
|
|
26
|
-
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
27
|
-
onReset?: (...args: Array<unknown>) => void;
|
|
28
|
-
onError?: (error: Error, info: {
|
|
29
|
-
componentStack: string;
|
|
30
|
-
}) => void;
|
|
31
|
-
resetKeys?: Array<unknown>;
|
|
32
|
-
fallback?: never;
|
|
33
|
-
FallbackComponent?: never;
|
|
34
|
-
fallbackRender: typeof FallbackRender;
|
|
35
|
-
}
|
|
36
|
-
interface ErrorBoundaryPropsWithFallback {
|
|
37
|
-
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
38
|
-
onReset?: (...args: Array<unknown>) => void;
|
|
39
|
-
onError?: (error: Error, info: {
|
|
40
|
-
componentStack: string;
|
|
41
|
-
}) => void;
|
|
42
|
-
resetKeys?: Array<unknown>;
|
|
43
|
-
fallback: React.ReactElement<unknown, string | React.FunctionComponent | typeof React.Component> | null;
|
|
44
|
-
FallbackComponent?: never;
|
|
45
|
-
fallbackRender?: never;
|
|
46
|
-
}
|
|
47
|
-
declare type ErrorBoundaryProps = ErrorBoundaryPropsWithFallback | ErrorBoundaryPropsWithComponent | ErrorBoundaryPropsWithRender;
|
|
48
|
-
declare type ErrorBoundaryState = {
|
|
49
|
-
error: Error | null;
|
|
50
|
-
};
|
|
51
|
-
declare class ErrorBoundary extends React.Component<React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>, ErrorBoundaryState> {
|
|
52
|
-
state: ErrorBoundaryState;
|
|
53
|
-
constructor(props: ErrorBoundaryProps);
|
|
54
|
-
static getDerivedStateFromError(error: Error): {
|
|
55
|
-
error: Error;
|
|
56
|
-
};
|
|
57
|
-
resetErrorBoundary(...args: Array<unknown>): void;
|
|
58
|
-
reset(): void;
|
|
59
|
-
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
60
|
-
componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
|
|
61
|
-
render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
|
|
62
|
-
}
|
|
63
|
-
export { ErrorBoundary };
|