@lexical/react 0.4.1 → 0.5.1-next.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.
Files changed (66) hide show
  1. package/DEPRECATED_useLexical.js.flow +0 -1
  2. package/DEPRECATED_useLexicalDecorators.d.ts +2 -1
  3. package/DEPRECATED_useLexicalDecorators.dev.js +125 -10
  4. package/DEPRECATED_useLexicalDecorators.js.flow +8 -0
  5. package/DEPRECATED_useLexicalDecorators.prod.js +6 -2
  6. package/DEPRECATED_useLexicalPlainText.d.ts +2 -2
  7. package/DEPRECATED_useLexicalPlainText.dev.js +4 -4
  8. package/DEPRECATED_useLexicalPlainText.js.flow +0 -1
  9. package/DEPRECATED_useLexicalPlainText.prod.js +2 -2
  10. package/DEPRECATED_useLexicalRichText.d.ts +2 -2
  11. package/DEPRECATED_useLexicalRichText.dev.js +4 -4
  12. package/DEPRECATED_useLexicalRichText.js.flow +0 -1
  13. package/DEPRECATED_useLexicalRichText.prod.js +2 -2
  14. package/LexicalAutoEmbedPlugin.d.ts +3 -13
  15. package/LexicalAutoEmbedPlugin.dev.js +3 -19
  16. package/LexicalAutoEmbedPlugin.js.flow +3 -11
  17. package/LexicalAutoEmbedPlugin.prod.js +4 -5
  18. package/LexicalAutoLinkPlugin.dev.js +49 -45
  19. package/LexicalAutoLinkPlugin.prod.js +6 -6
  20. package/LexicalBlockWithAlignableContents.dev.js +1 -1
  21. package/LexicalBlockWithAlignableContents.prod.js +1 -1
  22. package/LexicalCollaborationPlugin.d.ts +5 -1
  23. package/LexicalCollaborationPlugin.dev.js +54 -16
  24. package/LexicalCollaborationPlugin.js.flow +1 -0
  25. package/LexicalCollaborationPlugin.prod.js +9 -9
  26. package/LexicalComposer.d.ts +1 -2
  27. package/LexicalComposer.dev.js +15 -1
  28. package/LexicalComposer.js.flow +14 -7
  29. package/LexicalComposer.prod.js +3 -3
  30. package/LexicalContentEditable.dev.js +1 -1
  31. package/LexicalContentEditable.prod.js +1 -1
  32. package/LexicalHorizontalRuleNode.d.ts +4 -2
  33. package/LexicalHorizontalRuleNode.dev.js +25 -3
  34. package/LexicalHorizontalRuleNode.js.flow +0 -1
  35. package/LexicalHorizontalRuleNode.prod.js +5 -5
  36. package/LexicalNestedComposer.d.ts +4 -2
  37. package/LexicalNestedComposer.dev.js +25 -3
  38. package/LexicalNestedComposer.js.flow +1 -0
  39. package/LexicalNestedComposer.prod.js +3 -3
  40. package/LexicalOnChangePlugin.d.ts +1 -2
  41. package/LexicalOnChangePlugin.dev.js +3 -9
  42. package/LexicalOnChangePlugin.js.flow +0 -2
  43. package/LexicalOnChangePlugin.prod.js +2 -2
  44. package/LexicalPlainTextPlugin.d.ts +3 -3
  45. package/LexicalPlainTextPlugin.dev.js +111 -20
  46. package/LexicalPlainTextPlugin.js.flow +3 -1
  47. package/LexicalPlainTextPlugin.prod.js +6 -4
  48. package/LexicalRichTextPlugin.d.ts +3 -3
  49. package/LexicalRichTextPlugin.dev.js +111 -20
  50. package/LexicalRichTextPlugin.js.flow +3 -1
  51. package/LexicalRichTextPlugin.prod.js +6 -4
  52. package/LexicalTableOfContents__EXPERIMENTAL.js.flow +1 -1
  53. package/LexicalTablePlugin.dev.js +1 -1
  54. package/LexicalTablePlugin.prod.js +1 -1
  55. package/LexicalTreeView.dev.js +28 -13
  56. package/LexicalTreeView.prod.js +14 -13
  57. package/LexicalTypeaheadMenuPlugin.d.ts +20 -8
  58. package/LexicalTypeaheadMenuPlugin.dev.js +200 -57
  59. package/LexicalTypeaheadMenuPlugin.js.flow +19 -21
  60. package/LexicalTypeaheadMenuPlugin.prod.js +18 -14
  61. package/package.json +19 -19
  62. package/shared/ReactErrorBoundary.d.ts +63 -0
  63. package/shared/useDecorators.d.ts +8 -1
  64. package/shared/usePlainTextSetup.d.ts +1 -2
  65. package/shared/useRichTextSetup.d.ts +1 -2
  66. package/shared/useYjsCollaboration.d.ts +4 -1
@@ -4,19 +4,23 @@
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 m=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),w=require("lexical"),x=require("react"),y="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class z{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
8
- let A=b=>{var a=document.getElementById("typeahead-menu");if(a){a=a.getBoundingClientRect();const c=b.getBoundingClientRect();c.bottom>a.bottom?b.scrollIntoView(!1):c.top<a.top&&b.scrollIntoView()}};function C(b,a){var c=window.getSelection();if(null===c||!c.isCollapsed)return!1;let e=c.anchorNode;c=c.anchorOffset;if(null==e||null==c)return!1;try{a.setStart(e,b),a.setEnd(e,c)}catch(f){return!1}return!0}
7
+ 'use strict';var k=require("@lexical/react/LexicalComposerContext"),n=require("@lexical/utils"),w=require("lexical"),x=require("react"),z="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?x.useLayoutEffect:x.useEffect;class A{constructor(b){this.key=b;this.ref={current:null};this.setRefElement=this.setRefElement.bind(this)}setRefElement(b){this.ref={current:b}}}
8
+ let B=b=>{var a=document.getElementById("typeahead-menu");if(a){a=a.getBoundingClientRect();const c=b.getBoundingClientRect();c.bottom>a.bottom?b.scrollIntoView(!1):c.top<a.top&&b.scrollIntoView()}};function C(b,a){var c=window.getSelection();if(null===c||!c.isCollapsed)return!1;let e=c.anchorNode;c=c.anchorOffset;if(null==e||null==c)return!1;try{a.setStart(e,b),a.setEnd(e,c)}catch(f){return!1}return!0}
9
9
  function D(b){let a=null;b.getEditorState().read(()=>{var c=w.$getSelection();if(w.$isRangeSelection(c)){var e=c.anchor;"text"!==e.type?a=null:(c=e.getNode(),c.isSimpleText()?(e=e.offset,a=c.getTextContent().slice(0,e)):a=null)}});return a}
10
- function E(b,a){b=w.$getSelection();if(!w.$isRangeSelection(b)||!b.isCollapsed())return null;var c=b.anchor;if("text"!==c.type)return null;b=c.getNode();if(!b.isSimpleText())return null;c=c.offset;let e=b.getTextContent().slice(0,c);var f=a.matchingString;a=a.replaceableString.length;for(let k=a;k<=f.length;k++)e.substr(-k)===f.substr(0,k)&&(a=k);a=c-a;if(0>a)return null;let d;0===a?[d]=b.splitText(c):[,d]=b.splitText(a,c);return d}
10
+ function E(b,a){b=w.$getSelection();if(!w.$isRangeSelection(b)||!b.isCollapsed())return null;var c=b.anchor;if("text"!==c.type)return null;b=c.getNode();if(!b.isSimpleText())return null;c=c.offset;let e=b.getTextContent().slice(0,c);var f=a.matchingString;a=a.replaceableString.length;for(let p=a;p<=f.length;p++)e.substr(-p)===f.substr(0,p)&&(a=p);a=c-a;if(0>a)return null;let q;0===a?[q]=b.splitText(c):[,q]=b.splitText(a,c);return q}
11
11
  function F(b,a){return 0!==a?!1:b.getEditorState().read(()=>{var c=w.$getSelection();return w.$isRangeSelection(c)?(c=c.anchor.getNode().getPreviousSibling(),w.$isTextNode(c)&&c.isTextEntity()):!1})}function G(b){x.startTransition?x.startTransition(b):b()}
12
- function H({close:b,editor:a,anchorElement:c,resolution:e,options:f,menuRenderFn:d,onSelectOption:k}){let [g,q]=x.useState(null);x.useEffect(()=>{q(0)},[e.match.matchingString]);let r=x.useCallback(async h=>{a.update(()=>{const l=E(a,e.match);k(h,l,b,e.match.matchingString)})},[b,a,e.match,k]),p=x.useCallback(h=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant","typeahead-item-"+h),q(h))},[a]);x.useEffect(()=>()=>{let h=a.getRootElement();null!==h&&h.removeAttribute("aria-activedescendant")},
13
- [a]);y(()=>{null===f?q(null):null===g&&p(0)},[f,g,p]);x.useEffect(()=>n.mergeRegister(a.registerCommand(w.KEY_ARROW_DOWN_COMMAND,h=>{if(null!==f&&f.length&&null!==g){var l=g!==f.length-1?g+1:0;p(l);l=f[l];null!=l.ref&&l.ref.current&&A(l.ref.current);h.preventDefault();h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_NORMAL),a.registerCommand(w.KEY_ARROW_UP_COMMAND,h=>{if(null!==f&&f.length&&null!==g){var l=0!==g?g-1:f.length-1;p(l);l=f[l];null!=l.ref&&l.ref.current&&A(l.ref.current);h.preventDefault();
14
- h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_NORMAL),a.registerCommand(w.KEY_ESCAPE_COMMAND,h=>{h.preventDefault();h.stopImmediatePropagation();b();return!0},w.COMMAND_PRIORITY_NORMAL),a.registerCommand(w.KEY_TAB_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;h.preventDefault();h.stopImmediatePropagation();r(f[g]);return!0},w.COMMAND_PRIORITY_NORMAL),a.registerCommand(w.KEY_ENTER_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;null!==h&&(h.preventDefault(),h.stopImmediatePropagation());
15
- r(f[g]);return!0},w.COMMAND_PRIORITY_NORMAL)),[r,b,a,f,g,p]);let t=x.useMemo(()=>({selectOptionAndCleanUp:r,selectedIndex:g,setHighlightedIndex:q}),[r,g]);return d(c,t,e.match.matchingString)}
16
- function I(b){let [a]=m.useLexicalComposerContext(),c=x.useRef(document.createElement("div"));x.useEffect(()=>{function e(){let d=c.current;d.setAttribute("aria-label","Typeahead menu");d.setAttribute("id","typeahead-menu");d.setAttribute("role","listbox");if(null!==f&&null!==b){let {left:k,top:g,height:q}=b.getRect();d.style.top=`${g+q+5+window.pageYOffset}px`;d.style.left=`${k+window.pageXOffset}px`;d.style.display="block";d.style.position="absolute";d.isConnected||document.body.append(d);c.current=
17
- d;f.setAttribute("aria-controls","typeahead-menu")}}let f=a.getRootElement();if(null!==b)return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e);null!==f&&f.removeAttribute("aria-controls")}},[a,b]);return c}
18
- exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:c,onSelectOption:e,menuRenderFn:f}){let [d]=m.useLexicalComposerContext(),[k,g]=x.useState(null),q=I(k);x.useEffect(()=>{a&&null==k?d.update(()=>{let r=w.$getNodeByKey(a),p=d.getElementByKey(a);if(null!=r&&null!=p){let t=r.getTextContent();G(()=>g({getRect:()=>p.getBoundingClientRect(),match:{leadOffset:t.length,matchingString:t,replaceableString:t}}))}}):null==a&&null!=k&&g(null)},[d,a,k]);return null===k||null===d?null:x.createElement(H,
19
- {close:c,resolution:k,editor:d,anchorElement:q.current,options:b,menuRenderFn:f,onSelectOption:e})};
20
- exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,menuRenderFn:e,triggerFn:f}){let [d]=m.useLexicalComposerContext(),[k,g]=x.useState(null),q=I(k);x.useEffect(()=>{let p=document.createRange(),t=null,h=d.registerUpdateListener(()=>{d.getEditorState().read(()=>{const l=p,B=w.$getSelection(),v=D(d);if(w.$isRangeSelection(B)&&B.isCollapsed()&&v!==t&&null!==v&&null!==l){t=v;var u=f(v,d);a(u?u.matchingString:null);null===u||F(d,u.leadOffset)||null===C(u.leadOffset,
21
- l)?g(null):G(()=>g({getRect:()=>l.getBoundingClientRect(),match:u}))}else g(null)})});return()=>{p=null;h()}},[d,f,a,k]);let r=x.useCallback(()=>{g(null)},[]);return null===k||null===d?null:x.createElement(H,{close:r,resolution:k,editor:d,anchorElement:q.current,options:b,menuRenderFn:e,onSelectOption:c})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";exports.TypeaheadOption=z;
22
- exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return x.useCallback(e=>{e=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(e);if(null!==e){let f=e[1],d=e[3];if(d.length>=a)return{leadOffset:e.index+f.length,matchingString:d,replaceableString:e[2]}}return null},[c,a,b])}
12
+ function J(b,a){let c=getComputedStyle(b),e="absolute"===c.position;a=a?/(auto|scroll|hidden)/:/(auto|scroll)/;if("fixed"===c.position)return document.body;for(;b=b.parentElement;)if(c=getComputedStyle(b),(!e||"static"!==c.position)&&a.test(c.overflow+c.overflowY+c.overflowX))return b;return document.body}function K(b,a){b=b.getBoundingClientRect();a=a.getBoundingClientRect();return b.top>a.top&&b.top<a.bottom}
13
+ function L(b,a,c,e){let [f]=k.useLexicalComposerContext();x.useEffect(()=>{if(null!=a&&null!=b){let q=f.getRootElement(),p=null!=q?J(q,!1):document.body,g=!1,d=K(a,p),m=function(){g||(window.requestAnimationFrame(function(){c();g=!1}),g=!0);const t=K(a,p);t!==d&&(d=t,null!=e&&e(t))},r=new ResizeObserver(c);window.addEventListener("resize",c);document.addEventListener("scroll",m,{capture:!0,passive:!0});r.observe(a);return()=>{r.unobserve(a);window.removeEventListener("resize",c);document.removeEventListener("scroll",
14
+ m)}}},[a,f,e,c,b])}let M=w.createCommand("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");
15
+ function N({close:b,editor:a,anchorElementRef:c,resolution:e,options:f,menuRenderFn:q,onSelectOption:p}){let [g,d]=x.useState(null);x.useEffect(()=>{d(0)},[e.match.matchingString]);let m=x.useCallback(h=>{a.update(()=>{const l=E(a,e.match);p(h,l,b,e.match.matchingString)})},[b,a,e.match,p]),r=x.useCallback(h=>{const l=a.getRootElement();null!==l&&(l.setAttribute("aria-activedescendant","typeahead-item-"+h),d(h))},[a]);x.useEffect(()=>()=>{let h=a.getRootElement();null!==h&&h.removeAttribute("aria-activedescendant")},
16
+ [a]);z(()=>{null===f?d(null):null===g&&r(0)},[f,g,r]);x.useEffect(()=>n.mergeRegister(a.registerCommand(M,({option:h})=>h.ref&&null!=h.ref.current?(B(h.ref.current),!0):!1,w.COMMAND_PRIORITY_LOW)),[a,r]);x.useEffect(()=>n.mergeRegister(a.registerCommand(w.KEY_ARROW_DOWN_COMMAND,h=>{if(null!==f&&f.length&&null!==g){let l=g!==f.length-1?g+1:0;r(l);let u=f[l];null!=u.ref&&u.ref.current&&a.dispatchCommand(M,{index:l,option:u});h.preventDefault();h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_CRITICAL),
17
+ a.registerCommand(w.KEY_ARROW_UP_COMMAND,h=>{if(null!==f&&f.length&&null!==g){var l=0!==g?g-1:f.length-1;r(l);l=f[l];null!=l.ref&&l.ref.current&&B(l.ref.current);h.preventDefault();h.stopImmediatePropagation()}return!0},w.COMMAND_PRIORITY_CRITICAL),a.registerCommand(w.KEY_ESCAPE_COMMAND,h=>{h.preventDefault();h.stopImmediatePropagation();b();return!0},w.COMMAND_PRIORITY_CRITICAL),a.registerCommand(w.KEY_TAB_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;h.preventDefault();h.stopImmediatePropagation();
18
+ m(f[g]);return!0},w.COMMAND_PRIORITY_CRITICAL),a.registerCommand(w.KEY_ENTER_COMMAND,h=>{if(null===f||null===g||null==f[g])return!1;null!==h&&(h.preventDefault(),h.stopImmediatePropagation());m(f[g]);return!0},w.COMMAND_PRIORITY_CRITICAL)),[m,b,a,f,g,r]);let t=x.useMemo(()=>({options:f,selectOptionAndCleanUp:m,selectedIndex:g,setHighlightedIndex:d}),[m,g,f]);return q(c,t,e.match.matchingString)}
19
+ function O(b,a,c){let [e]=k.useLexicalComposerContext(),f=x.useRef(document.createElement("div")),q=x.useCallback(()=>{const g=e.getRootElement(),d=f.current;if(null!==g&&null!==b){const {left:m,top:r,width:t,height:h}=b.getRect();d.style.top=`${r+window.pageYOffset}px`;d.style.left=`${m+window.pageXOffset}px`;d.style.height=`${h}px`;d.style.width=`${t}px`;d.isConnected||(null!=c&&(d.className=c),d.setAttribute("aria-label","Typeahead menu"),d.setAttribute("id","typeahead-menu"),d.setAttribute("role",
20
+ "listbox"),d.style.display="block",d.style.position="absolute",document.body.append(d));f.current=d;g.setAttribute("aria-controls","typeahead-menu")}},[e,b,c]);x.useEffect(()=>{let g=e.getRootElement();if(null!==b)return q(),()=>{null!==g&&g.removeAttribute("aria-controls");let d=f.current;null!==d&&d.isConnected&&d.remove()}},[e,q,b]);let p=x.useCallback(g=>{null!==b&&(g||a(null))},[b,a]);L(b,f.current,q,p);return f}
21
+ exports.LexicalNodeMenuPlugin=function({options:b,nodeKey:a,onClose:c,onOpen:e,onSelectOption:f,menuRenderFn:q,anchorClassName:p}){let [g]=k.useLexicalComposerContext(),[d,m]=x.useState(null);p=O(d,m,p);let r=x.useCallback(()=>{m(null);null!=c&&null!==d&&c()},[c,d]),t=x.useCallback(h=>{m(h);null!=e&&null===d&&e(h)},[e,d]);x.useEffect(()=>{a&&null==d?g.update(()=>{let h=w.$getNodeByKey(a),l=g.getElementByKey(a);if(null!=h&&null!=l){let u=h.getTextContent();G(()=>t({getRect:()=>l.getBoundingClientRect(),
22
+ match:{leadOffset:u.length,matchingString:u,replaceableString:u}}))}}):null==a&&null!=d&&r()},[r,g,a,t,d]);return null===d||null===g?null:x.createElement(N,{close:r,resolution:d,editor:g,anchorElementRef:p,options:b,menuRenderFn:q,onSelectOption:f})};
23
+ exports.LexicalTypeaheadMenuPlugin=function({options:b,onQueryChange:a,onSelectOption:c,onOpen:e,onClose:f,menuRenderFn:q,triggerFn:p,anchorClassName:g}){let [d]=k.useLexicalComposerContext(),[m,r]=x.useState(null);g=O(m,r,g);let t=x.useCallback(()=>{r(null);null!=f&&null!==m&&f()},[f,m]),h=x.useCallback(l=>{r(l);null!=e&&null===m&&e(l)},[e,m]);x.useEffect(()=>{let l=document.createRange(),u=d.registerUpdateListener(()=>{d.getEditorState().read(()=>{const y=l,H=w.$getSelection(),I=D(d);if(w.$isRangeSelection(H)&&
24
+ H.isCollapsed()&&null!==I&&null!==y){var v=p(I,d);a(v?v.matchingString:null);null===v||F(d,v.leadOffset)||null===C(v.leadOffset,y)?t():G(()=>h({getRect:()=>y.getBoundingClientRect(),match:v}))}else t()})});return()=>{l=null;u()}},[d,p,a,m,t,h]);return null===m||null===d?null:x.createElement(N,{close:t,resolution:m,editor:d,anchorElementRef:g,options:b,menuRenderFn:q,onSelectOption:c})};exports.PUNCTUATION="\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
25
+ exports.SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND=M;exports.TypeaheadOption=A;exports.getScrollParent=J;exports.useBasicTypeaheadTriggerMatch=function(b,{minLength:a=1,maxLength:c=75}){return x.useCallback(e=>{e=(new RegExp("(^|\\s|\\()(["+b+"]((?:[^"+(b+"\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;\\s]){0,")+c+"}))$")).exec(e);if(null!==e){let f=e[1],q=e[3];if(q.length>=a)return{leadOffset:e.index+f.length,matchingString:q,replaceableString:e[2]}}return null},[c,a,b])};
26
+ exports.useDynamicPositioning=L
package/package.json CHANGED
@@ -8,28 +8,28 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.4.1",
11
+ "version": "0.5.1-next.0",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.4.1",
14
- "@lexical/code": "0.4.1",
15
- "@lexical/dragon": "0.4.1",
16
- "@lexical/hashtag": "0.4.1",
17
- "@lexical/history": "0.4.1",
18
- "@lexical/link": "0.4.1",
19
- "@lexical/list": "0.4.1",
20
- "@lexical/mark": "0.4.1",
21
- "@lexical/markdown": "0.4.1",
22
- "@lexical/overflow": "0.4.1",
23
- "@lexical/plain-text": "0.4.1",
24
- "@lexical/rich-text": "0.4.1",
25
- "@lexical/selection": "0.4.1",
26
- "@lexical/table": "0.4.1",
27
- "@lexical/text": "0.4.1",
28
- "@lexical/utils": "0.4.1",
29
- "@lexical/yjs": "0.4.1"
13
+ "@lexical/clipboard": "0.5.1-next.0",
14
+ "@lexical/code": "0.5.1-next.0",
15
+ "@lexical/dragon": "0.5.1-next.0",
16
+ "@lexical/hashtag": "0.5.1-next.0",
17
+ "@lexical/history": "0.5.1-next.0",
18
+ "@lexical/link": "0.5.1-next.0",
19
+ "@lexical/list": "0.5.1-next.0",
20
+ "@lexical/mark": "0.5.1-next.0",
21
+ "@lexical/markdown": "0.5.1-next.0",
22
+ "@lexical/overflow": "0.5.1-next.0",
23
+ "@lexical/plain-text": "0.5.1-next.0",
24
+ "@lexical/rich-text": "0.5.1-next.0",
25
+ "@lexical/selection": "0.5.1-next.0",
26
+ "@lexical/table": "0.5.1-next.0",
27
+ "@lexical/text": "0.5.1-next.0",
28
+ "@lexical/utils": "0.5.1-next.0",
29
+ "@lexical/yjs": "0.5.1-next.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "lexical": "0.4.1",
32
+ "lexical": "0.5.1-next.0",
33
33
  "react": ">=17.x",
34
34
  "react-dom": ">=17.x"
35
35
  },
@@ -0,0 +1,63 @@
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 };
@@ -6,4 +6,11 @@
6
6
  *
7
7
  */
8
8
  import type { LexicalEditor } from 'lexical';
9
- export declare function useDecorators(editor: LexicalEditor): Array<JSX.Element>;
9
+ import * as React from 'react';
10
+ declare type ErrorBoundaryProps = {
11
+ children: JSX.Element;
12
+ onError: (error: Error) => void;
13
+ };
14
+ export declare type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;
15
+ export declare function useDecorators(editor: LexicalEditor, ErrorBoundary?: ErrorBoundaryType): Array<JSX.Element>;
16
+ export {};
@@ -6,5 +6,4 @@
6
6
  *
7
7
  */
8
8
  import type { LexicalEditor } from 'lexical';
9
- import { InitialEditorStateType } from '@lexical/plain-text';
10
- export declare function usePlainTextSetup(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): void;
9
+ export declare function usePlainTextSetup(editor: LexicalEditor): void;
@@ -5,6 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { InitialEditorStateType } from '@lexical/rich-text';
9
8
  import type { LexicalEditor } from 'lexical';
10
- export declare function useRichTextSetup(editor: LexicalEditor, initialEditorState?: InitialEditorStateType): void;
9
+ export declare function useRichTextSetup(editor: LexicalEditor): void;
@@ -8,7 +8,10 @@
8
8
  import type { Binding } from '@lexical/yjs';
9
9
  import type { LexicalEditor } from 'lexical';
10
10
  import type { Doc } from 'yjs';
11
+ import * as React from 'react';
11
12
  import { WebsocketProvider } from 'y-websocket';
12
- export declare function useYjsCollaboration(editor: LexicalEditor, id: string, provider: WebsocketProvider, docMap: Map<string, Doc>, name: string, color: string, shouldBootstrap: boolean): [JSX.Element, Binding];
13
+ import { InitialEditorStateType } from '../LexicalComposer';
14
+ export declare type CursorsContainerRef = React.MutableRefObject<HTMLElement | null>;
15
+ export declare function useYjsCollaboration(editor: LexicalEditor, id: string, provider: WebsocketProvider, docMap: Map<string, Doc>, name: string, color: string, shouldBootstrap: boolean, cursorsContainerRef?: CursorsContainerRef, initialEditorState?: InitialEditorStateType): [JSX.Element, Binding];
13
16
  export declare function useYjsFocusTracking(editor: LexicalEditor, provider: WebsocketProvider, name: string, color: string): void;
14
17
  export declare function useYjsHistory(editor: LexicalEditor, binding: Binding): () => void;