@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.
- package/LexicalCollaborationContext.d.ts +4 -1
- package/LexicalCollaborationContext.dev.js +35 -7
- package/LexicalCollaborationContext.dev.mjs +36 -9
- package/LexicalCollaborationContext.mjs +1 -0
- package/LexicalCollaborationContext.node.mjs +1 -0
- package/LexicalCollaborationContext.prod.js +1 -1
- package/LexicalCollaborationContext.prod.mjs +1 -1
- package/LexicalContextMenuPlugin.d.ts +2 -2
- package/LexicalEditorRefPlugin.d.ts +2 -2
- package/LexicalErrorBoundary.dev.js +2 -140
- package/LexicalErrorBoundary.dev.mjs +1 -126
- package/LexicalErrorBoundary.prod.js +1 -1
- package/LexicalErrorBoundary.prod.mjs +1 -1
- package/LexicalNestedComposer.dev.js +3 -2
- package/LexicalNestedComposer.dev.mjs +4 -3
- package/LexicalNestedComposer.prod.js +1 -1
- package/LexicalNestedComposer.prod.mjs +1 -1
- package/LexicalNodeContextMenuPlugin.d.ts +2 -2
- package/LexicalNodeContextMenuPlugin.dev.js +27 -5221
- package/LexicalNodeContextMenuPlugin.dev.mjs +3 -5184
- package/LexicalNodeContextMenuPlugin.prod.js +1 -5
- package/LexicalNodeContextMenuPlugin.prod.mjs +1 -5
- package/package.json +19 -19
- package/shared/LexicalMenu.d.ts +5 -5
- package/shared/mergeRefs.d.ts +1 -1
- package/shared/useYjsCollaboration.d.ts +1 -1
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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)"]],
|
|
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
|
|
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 {
|
|
11
|
+
import { ReactPortal, RefObject } from 'react';
|
|
12
12
|
import { MenuOption } from './shared/LexicalMenu';
|
|
13
|
-
export type ContextMenuRenderFn<TOption extends MenuOption> = (anchorElementRef:
|
|
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 {
|
|
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> |
|
|
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
|
|
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
|
|
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");
|
|
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
|
|
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
|
-
} =
|
|
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 {
|
|
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
|
-
} =
|
|
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
|
|
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{
|
|
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 {
|
|
9
|
+
import { JSX, RefObject } from 'react';
|
|
10
10
|
declare class MenuOption {
|
|
11
11
|
key: string;
|
|
12
|
-
ref?:
|
|
12
|
+
ref?: RefObject<HTMLElement | null>;
|
|
13
13
|
constructor(key: string);
|
|
14
14
|
setRefElement(element: HTMLElement | null): void;
|
|
15
15
|
}
|