@lexical/react 0.35.1-nightly.20250919.0 → 0.35.1-nightly.20250923.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/LexicalContextMenuPlugin.dev.js +2 -1
- package/LexicalContextMenuPlugin.dev.mjs +2 -1
- package/LexicalContextMenuPlugin.prod.js +1 -1
- package/LexicalContextMenuPlugin.prod.mjs +1 -1
- 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/LexicalNodeMenuPlugin.dev.js +2 -1
- package/LexicalNodeMenuPlugin.dev.mjs +2 -1
- package/LexicalNodeMenuPlugin.prod.js +1 -1
- package/LexicalNodeMenuPlugin.prod.mjs +1 -1
- package/LexicalTypeaheadMenuPlugin.dev.js +2 -1
- package/LexicalTypeaheadMenuPlugin.dev.mjs +2 -1
- package/LexicalTypeaheadMenuPlugin.prod.js +1 -1
- package/LexicalTypeaheadMenuPlugin.prod.mjs +1 -1
- 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;
|
|
@@ -164,7 +164,8 @@ function getScrollParent(element, includeHidden) {
|
|
|
164
164
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
165
165
|
const tRect = targetElement.getBoundingClientRect();
|
|
166
166
|
const cRect = containerElement.getBoundingClientRect();
|
|
167
|
-
|
|
167
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
168
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -150,7 +150,8 @@ function getScrollParent(element, includeHidden) {
|
|
|
150
150
|
function isTriggerVisibleInNearestScrollContainer(targetElement, containerElement) {
|
|
151
151
|
const tRect = targetElement.getBoundingClientRect();
|
|
152
152
|
const cRect = containerElement.getBoundingClientRect();
|
|
153
|
-
|
|
153
|
+
const VISIBILITY_MARGIN_PX = 6;
|
|
154
|
+
return tRect.top >= cRect.top - VISIBILITY_MARGIN_PX && tRect.top <= cRect.bottom + VISIBILITY_MARGIN_PX;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
// Reposition the menu on scroll, window resize, and element resize.
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/utils"),n=require("lexical"),l=require("react"),o=require("react/jsx-runtime");function r(e){var t=Object.create(null);if(e)for(var n in e)t[n]=e[n];return t.default=e,t}var i=r(l);const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=u?l.useLayoutEffect:l.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();return n.top
|
|
9
|
+
"use strict";var e=require("@lexical/react/LexicalComposerContext"),t=require("@lexical/utils"),n=require("lexical"),l=require("react"),o=require("react/jsx-runtime");function r(e){var t=Object.create(null);if(e)for(var n in e)t[n]=e[n];return t.default=e,t}var i=r(l);const u="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,s=u?l.useLayoutEffect:l.useEffect;const c=e=>{const t=document.getElementById("typeahead-menu");if(!t)return;const n=t.getBoundingClientRect();n.top+n.height>window.innerHeight&&t.scrollIntoView({block:"center"}),n.top<0&&t.scrollIntoView({block:"center"}),e.scrollIntoView({block:"nearest"})};function a(e,t){const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();return n.top>=l.top-6&&n.top<=l.bottom+6}function m(t,n,o,r){const[i]=e.useLexicalComposerContext();l.useEffect((()=>{if(null!=n&&null!=t){const e=i.getRootElement(),t=null!=e?function(e,t){let n=getComputedStyle(e);const l="absolute"===n.position,o=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let t=e;t=t.parentElement;)if(n=getComputedStyle(t),(!l||"static"!==n.position)&&o.test(n.overflow+n.overflowY+n.overflowX))return t;return document.body}(e):document.body;let l=!1,u=a(n,t);const s=function(){l||(window.requestAnimationFrame((function(){o(),l=!1})),l=!0);const e=a(n,t);e!==u&&(u=e,null!=r&&r(e))},c=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",s,{capture:!0,passive:!0}),c.observe(n),()=>{c.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",s,!0)}}}),[n,i,r,o,t])}const d=n.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function f({close:e,editor:o,anchorElementRef:r,resolution:i,options:u,menuRenderFn:a,onSelectOption:m,shouldSplitNodeWithQuery:f=!1,commandPriority:p=n.COMMAND_PRIORITY_LOW,preselectFirstItem:g=!0}){const[h,C]=l.useState(null),E=i.match&&i.match.matchingString;l.useEffect((()=>{g&&C(0)}),[E,g]);const v=l.useCallback((t=>{o.update((()=>{const l=null!=i.match&&f?function(e){const t=n.$getSelection();if(!n.$isRangeSelection(t)||!t.isCollapsed())return null;const l=t.anchor;if("text"!==l.type)return null;const o=l.getNode();if(!o.isSimpleText())return null;const r=l.offset,i=o.getTextContent().slice(0,r),u=e.replaceableString.length,s=r-function(e,t,n){let l=n;for(let n=l;n<=t.length;n++)e.slice(-n)===t.substring(0,n)&&(l=n);return l}(i,e.matchingString,u);if(s<0)return null;let c;return 0===s?[c]=o.splitText(r):[,c]=o.splitText(s,r),c}(i.match):null;m(t,l,e,i.match?i.match.matchingString:"")}))}),[o,f,i.match,m,e]),R=l.useCallback((e=>{const t=o.getRootElement();null!==t&&(t.setAttribute("aria-activedescendant","typeahead-item-"+e),C(e))}),[o]);l.useEffect((()=>()=>{const e=o.getRootElement();null!==e&&e.removeAttribute("aria-activedescendant")}),[o]),s((()=>{null===u?C(null):null===h&&g&&R(0)}),[u,h,R,g]),l.useEffect((()=>t.mergeRegister(o.registerCommand(d,(({option:e})=>!(!e.ref||null==e.ref.current)&&(c(e.ref.current),!0)),p))),[o,R,p]),l.useEffect((()=>t.mergeRegister(o.registerCommand(n.KEY_ARROW_DOWN_COMMAND,(e=>{const t=e;if(null!==u&&u.length){const e=null===h?0:h!==u.length-1?h+1:0;R(e);const n=u[e];null!=n.ref&&n.ref.current&&o.dispatchCommand(d,{index:e,option:n}),t.preventDefault(),t.stopImmediatePropagation()}return!0}),p),o.registerCommand(n.KEY_ARROW_UP_COMMAND,(e=>{const t=e;if(null!==u&&u.length){const e=null===h?u.length-1:0!==h?h-1:u.length-1;R(e);const n=u[e];null!=n.ref&&n.ref.current&&c(n.ref.current),t.preventDefault(),t.stopImmediatePropagation()}return!0}),p),o.registerCommand(n.KEY_ESCAPE_COMMAND,(t=>{const n=t;return n.preventDefault(),n.stopImmediatePropagation(),e(),!0}),p),o.registerCommand(n.KEY_TAB_COMMAND,(e=>{const t=e;return null!==u&&null!==h&&null!=u[h]&&(t.preventDefault(),t.stopImmediatePropagation(),v(u[h]),!0)}),p),o.registerCommand(n.KEY_ENTER_COMMAND,(e=>null!==u&&null!==h&&null!=u[h]&&(null!==e&&(e.preventDefault(),e.stopImmediatePropagation()),v(u[h]),!0)),p))),[v,e,o,u,h,R,p]);return a(r,l.useMemo((()=>({options:u,selectOptionAndCleanUp:v,selectedIndex:h,setHighlightedIndex:C})),[v,h,u]),i.match?i.match.matchingString:"")}function p(e,t){null!=t&&(e.className=t),e.setAttribute("aria-label","Typeahead menu"),e.setAttribute("role","listbox"),e.style.display="block",e.style.position="absolute"}exports.LexicalContextMenuPlugin=function({options:r,onWillOpen:s,onClose:c,onOpen:a,onSelectOption:d,menuRenderFn:g,anchorClassName:h,commandPriority:C=n.COMMAND_PRIORITY_LOW,parent:E}){const[v]=e.useLexicalComposerContext(),[R,b]=l.useState(null),w=i.useRef(null),x=function(t,n,o,r=(u?document.body:void 0),i=!0){const[s]=e.useLexicalComposerContext(),c=u?document.createElement("div"):null,a=l.useRef(c),d=l.useCallback((()=>{if(null===a.current||void 0===r)return;a.current.style.top=a.current.style.bottom;const e=s.getRootElement(),n=a.current,l=n.firstChild;if(null!==e&&null!==t){const{left:u,top:s,width:c,height:m}=t.getRect(),d=a.current.offsetHeight;if(n.style.top=`${s+d+3+(i?window.pageYOffset:0)}px`,n.style.left=`${u+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${c}px`,null!==l){l.style.top=`${s}`;const t=l.getBoundingClientRect(),o=t.height,r=t.width,c=e.getBoundingClientRect();u+r>c.right&&(n.style.left=`${c.right-r+window.pageXOffset}px`),(s+o>window.innerHeight||s+o>c.bottom)&&s-c.top>o+m&&(n.style.top=`${s-o-m+(i?window.pageYOffset:0)}px`)}n.isConnected||(p(n,o),r.append(n)),n.setAttribute("id","typeahead-menu"),e.setAttribute("aria-controls","typeahead-menu")}}),[s,t,i,o,r]);l.useEffect((()=>{const e=s.getRootElement();return null!==t&&d(),()=>{null!==e&&e.removeAttribute("aria-controls");const t=a.current;null!==t&&t.isConnected&&(t.remove(),t.removeAttribute("id"))}}),[s,d,t]);const f=l.useCallback((e=>{null!==t&&(e||n(null))}),[t,n]);return m(t,a.current,d,f),null!=c&&c===a.current&&(p(c,o),null!=r&&r.append(c)),a}(R,b,h,E),O=l.useCallback((()=>{b(null),null!=c&&null!==R&&c()}),[c,R]),y=l.useCallback((e=>{b(e),null!=a&&null===R&&a(e)}),[a,R]),A=l.useCallback((e=>{e.preventDefault(),null!=s&&s(e);const n=t.calculateZoomLevel(e.target);y({getRect:()=>new DOMRect(e.clientX/n,e.clientY/n,1,1)})}),[y,s]),M=l.useCallback((e=>{null!==R&&null!=w.current&&null!=e.target&&n.isDOMNode(e.target)&&!w.current.contains(e.target)&&O()}),[O,R]);return l.useEffect((()=>{const e=v.getRootElement();if(e)return e.addEventListener("contextmenu",A),()=>e.removeEventListener("contextmenu",A)}),[v,A]),l.useEffect((()=>(document.addEventListener("click",M),()=>document.removeEventListener("click",M))),[v,M]),null===x.current||null===R||null===v?null:o.jsx(f,{close:O,resolution:R,editor:v,anchorElementRef:x,options:r,menuRenderFn:(e,t)=>g(e,t,{setMenuRef:e=>{w.current=e}}),onSelectOption:d,commandPriority:C})},exports.MenuOption=class{constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m,isDOMNode as d}from"lexical";import*as p from"react";import{useLayoutEffect as f,useEffect as g,useState as h,useCallback as v,useMemo as w,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,E=C?f:g;class R{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top
|
|
9
|
+
import{useLexicalComposerContext as t}from"@lexical/react/LexicalComposerContext";import{mergeRegister as e,calculateZoomLevel as n}from"@lexical/utils";import{createCommand as o,KEY_ARROW_DOWN_COMMAND as l,KEY_ARROW_UP_COMMAND as r,KEY_ESCAPE_COMMAND as i,KEY_TAB_COMMAND as u,KEY_ENTER_COMMAND as c,COMMAND_PRIORITY_LOW as s,$getSelection as a,$isRangeSelection as m,isDOMNode as d}from"lexical";import*as p from"react";import{useLayoutEffect as f,useEffect as g,useState as h,useCallback as v,useMemo as w,useRef as y}from"react";import{jsx as b}from"react/jsx-runtime";const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,E=C?f:g;class R{constructor(t){this.key=t,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(t){this.ref={current:t}}}const x=t=>{const e=document.getElementById("typeahead-menu");if(!e)return;const n=e.getBoundingClientRect();n.top+n.height>window.innerHeight&&e.scrollIntoView({block:"center"}),n.top<0&&e.scrollIntoView({block:"center"}),t.scrollIntoView({block:"nearest"})};function O(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return n.top>=o.top-6&&n.top<=o.bottom+6}function I(e,n,o,l){const[r]=t();g((()=>{if(null!=n&&null!=e){const t=r.getRootElement(),e=null!=t?function(t,e){let n=getComputedStyle(t);const o="absolute"===n.position,l=/(auto|scroll)/;if("fixed"===n.position)return document.body;for(let e=t;e=e.parentElement;)if(n=getComputedStyle(e),(!o||"static"!==n.position)&&l.test(n.overflow+n.overflowY+n.overflowX))return e;return document.body}(t):document.body;let i=!1,u=O(n,e);const c=function(){i||(window.requestAnimationFrame((function(){o(),i=!1})),i=!0);const t=O(n,e);t!==u&&(u=t,null!=l&&l(t))},s=new ResizeObserver(o);return window.addEventListener("resize",o),document.addEventListener("scroll",c,{capture:!0,passive:!0}),s.observe(n),()=>{s.unobserve(n),window.removeEventListener("resize",o),document.removeEventListener("scroll",c,!0)}}}),[n,r,l,o,e])}const A=o("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function S({close:t,editor:n,anchorElementRef:o,resolution:d,options:p,menuRenderFn:f,onSelectOption:y,shouldSplitNodeWithQuery:b=!1,commandPriority:C=s,preselectFirstItem:R=!0}){const[O,I]=h(null),S=d.match&&d.match.matchingString;g((()=>{R&&I(0)}),[S,R]);const L=v((e=>{n.update((()=>{const n=null!=d.match&&b?function(t){const e=a();if(!m(e)||!e.isCollapsed())return null;const n=e.anchor;if("text"!==n.type)return null;const o=n.getNode();if(!o.isSimpleText())return null;const l=n.offset,r=o.getTextContent().slice(0,l),i=t.replaceableString.length,u=l-function(t,e,n){let o=n;for(let n=o;n<=e.length;n++)t.slice(-n)===e.substring(0,n)&&(o=n);return o}(r,t.matchingString,i);if(u<0)return null;let c;return 0===u?[c]=o.splitText(l):[,c]=o.splitText(u,l),c}(d.match):null;y(e,n,t,d.match?d.match.matchingString:"")}))}),[n,b,d.match,y,t]),P=v((t=>{const e=n.getRootElement();null!==e&&(e.setAttribute("aria-activedescendant","typeahead-item-"+t),I(t))}),[n]);g((()=>()=>{const t=n.getRootElement();null!==t&&t.removeAttribute("aria-activedescendant")}),[n]),E((()=>{null===p?I(null):null===O&&R&&P(0)}),[p,O,P,R]),g((()=>e(n.registerCommand(A,(({option:t})=>!(!t.ref||null==t.ref.current)&&(x(t.ref.current),!0)),C))),[n,P,C]),g((()=>e(n.registerCommand(l,(t=>{const e=t;if(null!==p&&p.length){const t=null===O?0:O!==p.length-1?O+1:0;P(t);const o=p[t];null!=o.ref&&o.ref.current&&n.dispatchCommand(A,{index:t,option:o}),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),n.registerCommand(r,(t=>{const e=t;if(null!==p&&p.length){const t=null===O?p.length-1:0!==O?O-1:p.length-1;P(t);const n=p[t];null!=n.ref&&n.ref.current&&x(n.ref.current),e.preventDefault(),e.stopImmediatePropagation()}return!0}),C),n.registerCommand(i,(e=>{const n=e;return n.preventDefault(),n.stopImmediatePropagation(),t(),!0}),C),n.registerCommand(u,(t=>{const e=t;return null!==p&&null!==O&&null!=p[O]&&(e.preventDefault(),e.stopImmediatePropagation(),L(p[O]),!0)}),C),n.registerCommand(c,(t=>null!==p&&null!==O&&null!=p[O]&&(null!==t&&(t.preventDefault(),t.stopImmediatePropagation()),L(p[O]),!0)),C))),[L,t,n,p,O,P,C]);return f(o,w((()=>({options:p,selectOptionAndCleanUp:L,selectedIndex:O,setHighlightedIndex:I})),[L,O,p]),d.match?d.match.matchingString:"")}function L(t,e){null!=e&&(t.className=e),t.setAttribute("aria-label","Typeahead menu"),t.setAttribute("role","listbox"),t.style.display="block",t.style.position="absolute"}function P({options:e,onWillOpen:o,onClose:l,onOpen:r,onSelectOption:i,menuRenderFn:u,anchorClassName:c,commandPriority:a=s,parent:m}){const[f]=t(),[w,E]=h(null),R=p.useRef(null),x=function(e,n,o,l=(C?document.body:void 0),r=!0){const[i]=t(),u=C?document.createElement("div"):null,c=y(u),s=v((()=>{if(null===c.current||void 0===l)return;c.current.style.top=c.current.style.bottom;const t=i.getRootElement(),n=c.current,u=n.firstChild;if(null!==t&&null!==e){const{left:i,top:s,width:a,height:m}=e.getRect(),d=c.current.offsetHeight;if(n.style.top=`${s+d+3+(r?window.pageYOffset:0)}px`,n.style.left=`${i+window.pageXOffset}px`,n.style.height=`${m}px`,n.style.width=`${a}px`,null!==u){u.style.top=`${s}`;const e=u.getBoundingClientRect(),o=e.height,l=e.width,c=t.getBoundingClientRect();i+l>c.right&&(n.style.left=`${c.right-l+window.pageXOffset}px`),(s+o>window.innerHeight||s+o>c.bottom)&&s-c.top>o+m&&(n.style.top=`${s-o-m+(r?window.pageYOffset:0)}px`)}n.isConnected||(L(n,o),l.append(n)),n.setAttribute("id","typeahead-menu"),t.setAttribute("aria-controls","typeahead-menu")}}),[i,e,r,o,l]);g((()=>{const t=i.getRootElement();return null!==e&&s(),()=>{null!==t&&t.removeAttribute("aria-controls");const e=c.current;null!==e&&e.isConnected&&(e.remove(),e.removeAttribute("id"))}}),[i,s,e]);const a=v((t=>{null!==e&&(t||n(null))}),[e,n]);return I(e,c.current,s,a),null!=u&&u===c.current&&(L(u,o),null!=l&&l.append(u)),c}(w,E,c,m),O=v((()=>{E(null),null!=l&&null!==w&&l()}),[l,w]),A=v((t=>{E(t),null!=r&&null===w&&r(t)}),[r,w]),P=v((t=>{t.preventDefault(),null!=o&&o(t);const e=n(t.target);A({getRect:()=>new DOMRect(t.clientX/e,t.clientY/e,1,1)})}),[A,o]),D=v((t=>{null!==w&&null!=R.current&&null!=t.target&&d(t.target)&&!R.current.contains(t.target)&&O()}),[O,w]);return g((()=>{const t=f.getRootElement();if(t)return t.addEventListener("contextmenu",P),()=>t.removeEventListener("contextmenu",P)}),[f,P]),g((()=>(document.addEventListener("click",D),()=>document.removeEventListener("click",D))),[f,D]),null===x.current||null===w||null===f?null:b(S,{close:O,resolution:w,editor:f,anchorElementRef:x,options:e,menuRenderFn:(t,e)=>u(t,e,{setMenuRef:t=>{R.current=t}}),onSelectOption:i,commandPriority:a})}export{P as LexicalContextMenuPlugin,R as MenuOption};
|
|
@@ -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;
|