@lexical/react 0.2.0 → 0.2.3

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.
@@ -19,7 +19,6 @@ var react = require('react');
19
19
  *
20
20
  *
21
21
  */
22
- const LowPriority = 1;
23
22
  function useList(editor) {
24
23
  react.useEffect(() => {
25
24
  return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
@@ -30,7 +29,7 @@ function useList(editor) {
30
29
  }
31
30
 
32
31
  return false;
33
- }, LowPriority), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
32
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
34
33
  const hasHandledIndention = list.outdentList();
35
34
 
36
35
  if (hasHandledIndention) {
@@ -38,16 +37,16 @@ function useList(editor) {
38
37
  }
39
38
 
40
39
  return false;
41
- }, LowPriority), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
40
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
42
41
  list.insertList(editor, 'ol');
43
42
  return true;
44
- }, LowPriority), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
43
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
45
44
  list.insertList(editor, 'ul');
46
45
  return true;
47
- }, LowPriority), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
46
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
48
47
  list.removeList(editor);
49
48
  return true;
50
- }, LowPriority), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
49
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
51
50
  const hasHandledInsertParagraph = list.$handleListInsertParagraph();
52
51
 
53
52
  if (hasHandledInsertParagraph) {
@@ -55,7 +54,7 @@ function useList(editor) {
55
54
  }
56
55
 
57
56
  return false;
58
- }, LowPriority));
57
+ }, lexical.COMMAND_PRIORITY_LOW));
59
58
  }, [editor]);
60
59
  }
61
60
 
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var b=require("@lexical/list"),c=require("@lexical/utils"),d=require("lexical"),e=require("react");
8
- function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>b.indentList()?!0:!1,1),a.registerCommand(d.OUTDENT_CONTENT_COMMAND,()=>b.outdentList()?!0:!1,1),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"ol");return!0},1),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"ul");return!0},1),a.registerCommand(b.REMOVE_LIST_COMMAND,()=>{b.removeList(a);return!0},1),a.registerCommand(d.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?
9
- !0:!1,1)),[a])}module.exports=function(a){f(a)};
8
+ function f(a){e.useEffect(()=>c.mergeRegister(a.registerCommand(d.INDENT_CONTENT_COMMAND,()=>b.indentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(d.OUTDENT_CONTENT_COMMAND,()=>b.outdentList()?!0:!1,d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_ORDERED_LIST_COMMAND,()=>{b.insertList(a,"ol");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.INSERT_UNORDERED_LIST_COMMAND,()=>{b.insertList(a,"ul");return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(b.REMOVE_LIST_COMMAND,()=>{b.removeList(a);
9
+ return!0},d.COMMAND_PRIORITY_LOW),a.registerCommand(d.INSERT_PARAGRAPH_COMMAND,()=>b.$handleListInsertParagraph()?!0:!1,d.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(a){f(a)};
@@ -8,6 +8,6 @@
8
8
 
9
9
  import {$ReadOnly} from 'utility-types';
10
10
  type Props = $ReadOnly<{
11
- scrollRef: { current: HTMLElement | null };
11
+ scrollRef: {current: HTMLElement | null};
12
12
  }>;
13
13
  export default function LexicalAutoScrollPlugin(props: Props): null;
@@ -9,4 +9,6 @@
9
9
  type Props = $ReadOnly<{
10
10
  scrollRef: {current: HTMLElement | null},
11
11
  }>;
12
- declare export default function LexicalAutoScrollPlugin(props: Props): React$Node;
12
+ declare export default function LexicalAutoScrollPlugin(
13
+ props: Props,
14
+ ): React$Node;
@@ -61,7 +61,7 @@ function LexicalClearEditorPlugin({
61
61
  }
62
62
  });
63
63
  return true;
64
- }, 0);
64
+ }, lexical.COMMAND_PRIORITY_EDITOR);
65
65
  }, [editor, onClear]);
66
66
  return null;
67
67
  }
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var a=require("@lexical/react/LexicalComposerContext"),d=require("lexical"),g=require("react"),h="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?g.useLayoutEffect:g.useEffect;
8
- module.exports=function({onClear:b}){const [c]=a.useLexicalComposerContext();h(()=>c.registerCommand(d.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){const e=d.$getRoot(),k=d.$getSelection(),f=d.$createParagraphNode();e.clear();e.append(f);null!==k&&f.select()}else b()});return!0},0),[c,b]);return null};
8
+ module.exports=function({onClear:b}){const [c]=a.useLexicalComposerContext();h(()=>c.registerCommand(d.CLEAR_EDITOR_COMMAND,()=>{c.update(()=>{if(null==b){const e=d.$getRoot(),k=d.$getSelection(),f=d.$createParagraphNode();e.clear();e.append(f);null!==k&&f.select()}else b()});return!0},d.COMMAND_PRIORITY_EDITOR),[c,b]);return null};
@@ -21,7 +21,6 @@ var reactDom = require('react-dom');
21
21
  *
22
22
  *
23
23
  */
24
- const EditorPriority = 0;
25
24
  function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBootstrap) {
26
25
  const isReloadingDoc = React.useRef(false);
27
26
  const [doc, setDoc] = React.useState(docMap.get(id));
@@ -133,7 +132,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
133
132
  }
134
133
 
135
134
  return true;
136
- }, EditorPriority);
135
+ }, lexical.COMMAND_PRIORITY_EDITOR);
137
136
  }, [connect, disconnect, editor]);
138
137
  return [cursorsContainer, binding];
139
138
  }
@@ -142,10 +141,10 @@ function useYjsFocusTracking(editor, provider, name, color) {
142
141
  return utils.mergeRegister(editor.registerCommand(lexical.FOCUS_COMMAND, payload => {
143
142
  yjs.setLocalStateFocus(provider, name, color, true);
144
143
  return true;
145
- }, EditorPriority), editor.registerCommand(lexical.BLUR_COMMAND, payload => {
144
+ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.BLUR_COMMAND, payload => {
146
145
  yjs.setLocalStateFocus(provider, name, color, false);
147
146
  return true;
148
- }, EditorPriority));
147
+ }, lexical.COMMAND_PRIORITY_EDITOR));
149
148
  }, [color, editor, name, provider]);
150
149
  }
151
150
  function useYjsHistory(editor, binding) {
@@ -162,10 +161,10 @@ function useYjsHistory(editor, binding) {
162
161
  return utils.mergeRegister(editor.registerCommand(lexical.UNDO_COMMAND, () => {
163
162
  undo();
164
163
  return true;
165
- }, EditorPriority), editor.registerCommand(lexical.REDO_COMMAND, () => {
164
+ }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REDO_COMMAND, () => {
166
165
  redo();
167
166
  return true;
168
- }, EditorPriority));
167
+ }, lexical.COMMAND_PRIORITY_EDITOR));
169
168
  });
170
169
  const clearHistory = React.useCallback(() => {
171
170
  undoManager.clear();
@@ -238,7 +237,7 @@ function clearEditorSkipCollab(editor, binding) {
238
237
  *
239
238
  */
240
239
  const entries = [['Cat', '255,165,0'], ['Dog', '0,200,55'], ['Rabbit', '160,0,200'], ['Frog', '0,172,200'], ['Fox', '197,200,0'], ['Hedgehog', '31,200,0'], ['Pigeon', '200,0,0'], ['Squirrel', '200,0,148'], ['Bear', '255,235,0'], ['Tiger', '86,255,0'], ['Leopard', '0,255,208'], ['Zebra', '0,243,255'], ['Wolf', '0,102,255'], ['Owl', '147,0,255'], ['Gull', '255,0,153'], ['Squid', '0,220,255']];
241
- const randomEntry = entries[Math.floor(Math.random() * (entries.length - 1 - 0 + 1) + 0)];
240
+ const randomEntry = entries[Math.floor(Math.random() * entries.length)];
242
241
  function CollaborationPlugin({
243
242
  id,
244
243
  providerFactory,
@@ -4,13 +4,13 @@
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
- var e=require("@lexical/react/LexicalComposerContext"),g=require("react"),m=require("@lexical/utils"),x=require("@lexical/yjs"),F=require("lexical"),G=require("react-dom");
8
- function H(b,c,a,d,k,p,q){const n=g.useRef(!1),[r,v]=g.useState(d.get(c)),f=g.useMemo(()=>x.createBinding(b,a,c,r,d),[b,a,c,d,r]),t=g.useCallback(()=>{a.connect()},[a]),u=g.useCallback(()=>{try{a.disconnect()}catch(l){}},[a]);g.useEffect(()=>{const {root:l}=f,{awareness:y}=a,z=({status:h})=>{b.dispatchCommand(x.CONNECTED_COMMAND,"connected"===h)},A=h=>{q&&h&&l.isEmpty()&&0===l._xmlText._length&&!1===n.current&&I(b);n.current=!1},B=()=>{x.syncCursorPositions(f,a)},C=(h,w)=>{w.origin!==f&&x.syncYjsChangesToLexical(f,
9
- a,h)};x.initLocalState(a,k,p,document.activeElement===b.getRootElement());const D=h=>{J(b,f);v(h);d.set(c,h);n.current=!0};a.on("reload",D);a.on("status",z);a.on("sync",A);y.on("update",B);l.getSharedType().observeDeep(C);const R=b.registerUpdateListener(({prevEditorState:h,editorState:w,dirtyLeaves:O,dirtyElements:P,normalizedNodes:Q,tags:E})=>{!1===E.has("skip-collab")&&x.syncLexicalUpdateToYjs(f,a,h,w,P,O,Q,E)});t();return()=>{!1===n.current&&u();a.off("sync",A);a.off("status",z);a.off("reload",
10
- D);y.off("update",B);l.getSharedType().unobserveDeep(C);R()}},[f,p,t,u,d,b,c,k,a,q]);const S=g.useMemo(()=>G.createPortal(g.createElement("div",{ref:l=>{f.cursorsContainer=l}}),document.body),[f]);g.useEffect(()=>b.registerCommand(x.TOGGLE_CONNECT_COMMAND,l=>{void 0!==t&&void 0!==u&&(l?(console.log("Collaboration connected!"),t()):(console.log("Collaboration disconnected!"),u()));return!0},0),[t,u,b]);return[S,f]}
11
- function K(b,c,a,d){g.useEffect(()=>m.mergeRegister(b.registerCommand(F.FOCUS_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!0);return!0},0),b.registerCommand(F.BLUR_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!1);return!0},0)),[d,b,a,c])}
12
- function L(b,c){const a=g.useMemo(()=>x.createUndoManager(c,c.root.getSharedType()),[c]);g.useEffect(()=>m.mergeRegister(b.registerCommand(F.UNDO_COMMAND,()=>{a.undo();return!0},0),b.registerCommand(F.REDO_COMMAND,()=>{a.redo();return!0},0)));return g.useCallback(()=>{a.clear()},[a])}
7
+ var e=require("@lexical/react/LexicalComposerContext"),f=require("react"),h=require("@lexical/utils"),x=require("@lexical/yjs"),F=require("lexical"),G=require("react-dom");
8
+ function H(b,c,a,d,l,p,q){const n=f.useRef(!1),[r,v]=f.useState(d.get(c)),g=f.useMemo(()=>x.createBinding(b,a,c,r,d),[b,a,c,d,r]),t=f.useCallback(()=>{a.connect()},[a]),u=f.useCallback(()=>{try{a.disconnect()}catch(m){}},[a]);f.useEffect(()=>{const {root:m}=g,{awareness:y}=a,z=({status:k})=>{b.dispatchCommand(x.CONNECTED_COMMAND,"connected"===k)},A=k=>{q&&k&&m.isEmpty()&&0===m._xmlText._length&&!1===n.current&&I(b);n.current=!1},B=()=>{x.syncCursorPositions(g,a)},C=(k,w)=>{w.origin!==g&&x.syncYjsChangesToLexical(g,
9
+ a,k)};x.initLocalState(a,l,p,document.activeElement===b.getRootElement());const D=k=>{J(b,g);v(k);d.set(c,k);n.current=!0};a.on("reload",D);a.on("status",z);a.on("sync",A);y.on("update",B);m.getSharedType().observeDeep(C);const R=b.registerUpdateListener(({prevEditorState:k,editorState:w,dirtyLeaves:O,dirtyElements:P,normalizedNodes:Q,tags:E})=>{!1===E.has("skip-collab")&&x.syncLexicalUpdateToYjs(g,a,k,w,P,O,Q,E)});t();return()=>{!1===n.current&&u();a.off("sync",A);a.off("status",z);a.off("reload",
10
+ D);y.off("update",B);m.getSharedType().unobserveDeep(C);R()}},[g,p,t,u,d,b,c,l,a,q]);const S=f.useMemo(()=>G.createPortal(f.createElement("div",{ref:m=>{g.cursorsContainer=m}}),document.body),[g]);f.useEffect(()=>b.registerCommand(x.TOGGLE_CONNECT_COMMAND,m=>{void 0!==t&&void 0!==u&&(m?(console.log("Collaboration connected!"),t()):(console.log("Collaboration disconnected!"),u()));return!0},F.COMMAND_PRIORITY_EDITOR),[t,u,b]);return[S,g]}
11
+ function K(b,c,a,d){f.useEffect(()=>h.mergeRegister(b.registerCommand(F.FOCUS_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!0);return!0},F.COMMAND_PRIORITY_EDITOR),b.registerCommand(F.BLUR_COMMAND,()=>{x.setLocalStateFocus(c,a,d,!1);return!0},F.COMMAND_PRIORITY_EDITOR)),[d,b,a,c])}
12
+ function L(b,c){const a=f.useMemo(()=>x.createUndoManager(c,c.root.getSharedType()),[c]);f.useEffect(()=>h.mergeRegister(b.registerCommand(F.UNDO_COMMAND,()=>{a.undo();return!0},F.COMMAND_PRIORITY_EDITOR),b.registerCommand(F.REDO_COMMAND,()=>{a.redo();return!0},F.COMMAND_PRIORITY_EDITOR)));return f.useCallback(()=>{a.clear()},[a])}
13
13
  function I(b){b.update(()=>{var c=F.$getRoot();if(null===c.getFirstChild()){const a=F.$createParagraphNode();c.append(a);c=document.activeElement;(null!==F.$getSelection()||null!==c&&c===b.getRootElement())&&a.select()}},{tag:"history-merge"})}
14
- function J(b,c){b.update(()=>{const d=F.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursorsContainer,null!=b)){c=Array.from(c.cursors.values());for(let d=0;d<c.length;d++){var a=c[d].selection;if(a&&null!=a.selections){a=a.selections;for(let k=0;k<a.length;k++)b.removeChild(a[d])}}}}
15
- const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*(M.length-1+1))],T=g.createContext({clientID:0,color:N[1],name:N[0],yjsDocMap:new Map});
16
- function U(b){const c=g.useContext(T);null!=b&&(c.name=b);return c}exports.CollaborationContext=T;exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d}){d=U(d);const {yjsDocMap:k,name:p,color:q}=d,[n]=e.useLexicalComposerContext(),r=g.useMemo(()=>c(b,k),[b,c,k]),[v,f]=H(n,b,r,k,p,q,a);d.clientID=f.clientID;L(n,f);K(n,r,p,q);return v};exports.useCollaborationContext=U;
14
+ function J(b,c){b.update(()=>{const d=F.$getRoot();d.clear();d.select()},{tag:"skip-collab"});if(null!=c.cursors&&(b=c.cursorsContainer,null!=b)){c=Array.from(c.cursors.values());for(let d=0;d<c.length;d++){var a=c[d].selection;if(a&&null!=a.selections){a=a.selections;for(let l=0;l<a.length;l++)b.removeChild(a[d])}}}}
15
+ const M=[["Cat","255,165,0"],["Dog","0,200,55"],["Rabbit","160,0,200"],["Frog","0,172,200"],["Fox","197,200,0"],["Hedgehog","31,200,0"],["Pigeon","200,0,0"],["Squirrel","200,0,148"],["Bear","255,235,0"],["Tiger","86,255,0"],["Leopard","0,255,208"],["Zebra","0,243,255"],["Wolf","0,102,255"],["Owl","147,0,255"],["Gull","255,0,153"],["Squid","0,220,255"]],N=M[Math.floor(Math.random()*M.length)],T=f.createContext({clientID:0,color:N[1],name:N[0],yjsDocMap:new Map});
16
+ function U(b){const c=f.useContext(T);null!=b&&(c.name=b);return c}exports.CollaborationContext=T;exports.CollaborationPlugin=function({id:b,providerFactory:c,shouldBootstrap:a,username:d}){d=U(d);const {yjsDocMap:l,name:p,color:q}=d,[n]=e.useLexicalComposerContext(),r=f.useMemo(()=>c(b,l),[b,c,l]),[v,g]=H(n,b,r,l,p,q,a);d.clientID=g.clientID;L(n,g);K(n,r,p,q);return v};exports.useCollaborationContext=U;
@@ -17,6 +17,6 @@ type Props = {
17
17
  theme?: EditorThemeClasses;
18
18
  onError: (error: Error, editor: LexicalEditor) => void;
19
19
  };
20
- children: JSX.Element | null;
20
+ children: JSX.Element | JSX.Element[] | null;
21
21
  };
22
22
  export default function LexicalComposer(arg0: Props): JSX.Element | null;
@@ -9,8 +9,8 @@
9
9
  import type {LexicalNode, LexicalCommand} from 'lexical';
10
10
  import {DecoratorNode} from 'lexical';
11
11
  export declare class HorizontalRuleNode extends DecoratorNode<JSX.Element | null> {
12
- getType(): string;
13
- clone(node: HorizontalRuleNode): HorizontalRuleNode;
12
+ static getType(): string;
13
+ static clone(node: HorizontalRuleNode): HorizontalRuleNode;
14
14
  createDOM(): HTMLElement;
15
15
  getTextContent(): '\n';
16
16
  isTopLevel(): true;
@@ -19,7 +19,6 @@ var react = require('react');
19
19
  *
20
20
  *
21
21
  */
22
- const EditorPriority = 0;
23
22
 
24
23
  function toggleLink(url) {
25
24
  const selection = lexical.$getSelection();
@@ -127,7 +126,7 @@ function LinkPlugin() {
127
126
  const url = payload;
128
127
  toggleLink(url);
129
128
  return true;
130
- }, EditorPriority);
129
+ }, lexical.COMMAND_PRIORITY_EDITOR);
131
130
  }, [editor]);
132
131
  return null;
133
132
  }
@@ -7,4 +7,4 @@
7
7
  var g=require("@lexical/link"),k=require("@lexical/react/LexicalComposerContext"),m=require("lexical"),n=require("react");
8
8
  function p(e){var b=m.$getSelection();null!==b&&m.$setSelection(b);b=m.$getSelection();if(null!==b)if(b=b.extract(),null===e)b.forEach(f=>{f=f.getParent();if(g.$isLinkNode(f)){const c=f.getChildren();for(let a=0;a<c.length;a++)f.insertBefore(c[a]);f.remove()}});else{if(1===b.length){var h=b[0];if(g.$isLinkNode(h)){h.setURL(e);return}h=h.getParent();if(g.$isLinkNode(h)){h.setURL(e);return}}let f=null,c=null;b.forEach(a=>{var d=a.getParent();if(d!==c&&null!==d&&(!m.$isElementNode(a)||a.isInline()))if(d.is(f)||
9
9
  (f=d,c=g.$createLinkNode(e),g.$isLinkNode(d)?null===a.getPreviousSibling()?d.insertBefore(c):d.insertAfter(c):a.insertBefore(c)),g.$isLinkNode(a)){if(null!==c){d=a.getChildren();for(let l=0;l<d.length;l++)c.append(d[l])}a.remove()}else null!==c&&c.append(a)})}}
10
- module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([g.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(g.TOGGLE_LINK_COMMAND,b=>{p(b);return!0},0),[e]);return null};
10
+ module.exports=function(){const [e]=k.useLexicalComposerContext();n.useEffect(()=>{if(!e.hasNodes([g.LinkNode]))throw Error("LinkPlugin: LinkNode not registered on editor");},[e]);n.useEffect(()=>e.registerCommand(g.TOGGLE_LINK_COMMAND,b=>{p(b);return!0},m.COMMAND_PRIORITY_EDITOR),[e]);return null};
@@ -20,7 +20,6 @@ var react = require('react');
20
20
  *
21
21
  *
22
22
  */
23
- const LowPriority = 1;
24
23
  function useList(editor) {
25
24
  react.useEffect(() => {
26
25
  return utils.mergeRegister(editor.registerCommand(lexical.INDENT_CONTENT_COMMAND, () => {
@@ -31,7 +30,7 @@ function useList(editor) {
31
30
  }
32
31
 
33
32
  return false;
34
- }, LowPriority), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
33
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.OUTDENT_CONTENT_COMMAND, () => {
35
34
  const hasHandledIndention = list.outdentList();
36
35
 
37
36
  if (hasHandledIndention) {
@@ -39,16 +38,16 @@ function useList(editor) {
39
38
  }
40
39
 
41
40
  return false;
42
- }, LowPriority), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
41
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
43
42
  list.insertList(editor, 'ol');
44
43
  return true;
45
- }, LowPriority), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
44
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
46
45
  list.insertList(editor, 'ul');
47
46
  return true;
48
- }, LowPriority), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
47
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
49
48
  list.removeList(editor);
50
49
  return true;
51
- }, LowPriority), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
50
+ }, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(lexical.INSERT_PARAGRAPH_COMMAND, () => {
52
51
  const hasHandledInsertParagraph = list.$handleListInsertParagraph();
53
52
 
54
53
  if (hasHandledInsertParagraph) {
@@ -56,7 +55,7 @@ function useList(editor) {
56
55
  }
57
56
 
58
57
  return false;
59
- }, LowPriority));
58
+ }, lexical.COMMAND_PRIORITY_LOW));
60
59
  }, [editor]);
61
60
  }
62
61
 
@@ -5,5 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var b=require("@lexical/react/LexicalComposerContext"),c=require("@lexical/list"),d=require("@lexical/utils"),e=require("lexical"),f=require("react");
8
- function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>c.indentList()?!0:!1,1),a.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>c.outdentList()?!0:!1,1),a.registerCommand(c.INSERT_ORDERED_LIST_COMMAND,()=>{c.insertList(a,"ol");return!0},1),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"ul");return!0},1),a.registerCommand(c.REMOVE_LIST_COMMAND,()=>{c.removeList(a);return!0},1),a.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>c.$handleListInsertParagraph()?
9
- !0:!1,1)),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();g(a);return null};
8
+ function g(a){f.useEffect(()=>d.mergeRegister(a.registerCommand(e.INDENT_CONTENT_COMMAND,()=>c.indentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(e.OUTDENT_CONTENT_COMMAND,()=>c.outdentList()?!0:!1,e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_ORDERED_LIST_COMMAND,()=>{c.insertList(a,"ol");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.INSERT_UNORDERED_LIST_COMMAND,()=>{c.insertList(a,"ul");return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(c.REMOVE_LIST_COMMAND,()=>{c.removeList(a);
9
+ return!0},e.COMMAND_PRIORITY_LOW),a.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>c.$handleListInsertParagraph()?!0:!1,e.COMMAND_PRIORITY_LOW)),[a])}module.exports=function(){const [a]=b.useLexicalComposerContext();g(a);return null};
@@ -11,5 +11,5 @@ import type {LexicalEditor, EditorThemeClasses} from 'lexical';
11
11
  export default function LexicalNestedComposer(arg0: {
12
12
  initialEditor: LexicalEditor;
13
13
  initialTheme?: EditorThemeClasses;
14
- children: JSX.Element | null;
14
+ children: JSX.Element | JSX.Element[] | null;
15
15
  }): JSX.Element | null;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  'use strict';
8
8
 
9
+ var LexicalCollaborationPlugin = require('@lexical/react/LexicalCollaborationPlugin');
9
10
  var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
10
11
  var React = require('react');
11
12
 
@@ -44,10 +45,17 @@ function LexicalNestedComposer({
44
45
  return [initialEditor, context];
45
46
  }, // We only do this for init
46
47
  // eslint-disable-next-line react-hooks/exhaustive-deps
47
- []);
48
+ []); // If collaboration is enabled, make sure we don't render the children
49
+ // until the collaboration subdocument is ready.
50
+
51
+ const {
52
+ yjsDocMap
53
+ } = LexicalCollaborationPlugin.useCollaborationContext();
54
+ const isCollab = yjsDocMap.get('main') !== undefined;
55
+ const isCollabReady = yjsDocMap.has(initialEditor.getKey());
48
56
  return /*#__PURE__*/React.createElement(LexicalComposerContext.LexicalComposerContext.Provider, {
49
57
  value: composerContext
50
- }, children);
58
+ }, !isCollab || isCollabReady ? children : null);
51
59
  }
52
60
 
53
61
  module.exports = LexicalNestedComposer;
@@ -4,6 +4,6 @@
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
- var b=require("@lexical/react/LexicalComposerContext"),c=require("react");
8
- module.exports=function({initialEditor:a,children:g,initialTheme:h}){const d=c.useContext(b.LexicalComposerContext);if(null==d)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const m=c.useMemo(()=>{const [f,k]=d,e=h||k.getTheme()||void 0,l=b.createLexicalComposerContext(d,e);void 0!==e&&(a._config.theme=e);a._parentEditor=f;a._nodes=f._nodes;return[a,l]},[]);return c.createElement(b.LexicalComposerContext.Provider,
9
- {value:m},g)};
7
+ var c=require("@lexical/react/LexicalCollaborationPlugin"),d=require("@lexical/react/LexicalComposerContext"),h=require("react");
8
+ module.exports=function({initialEditor:a,children:k,initialTheme:l}){const e=h.useContext(d.LexicalComposerContext);if(null==e)throw Error("Minified Lexical error #72; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");const p=h.useMemo(()=>{const [g,m]=e,f=l||m.getTheme()||void 0,n=d.createLexicalComposerContext(e,f);void 0!==f&&(a._config.theme=f);a._parentEditor=g;a._nodes=g._nodes;return[a,n]},[]);var {yjsDocMap:b}=c.useCollaborationContext();
9
+ const q=void 0!==b.get("main");b=b.has(a.getKey());return h.createElement(d.LexicalComposerContext.Provider,{value:p},!q||b?k:null)};
@@ -19,7 +19,6 @@ var react = require('react');
19
19
  *
20
20
  *
21
21
  */
22
- const EditorPriority = 0;
23
22
  function TablePlugin() {
24
23
  const [editor] = LexicalComposerContext.useLexicalComposerContext();
25
24
  react.useEffect(() => {
@@ -67,7 +66,7 @@ function TablePlugin() {
67
66
  }
68
67
 
69
68
  return true;
70
- }, EditorPriority);
69
+ }, lexical.COMMAND_PRIORITY_EDITOR);
71
70
  }, [editor]);
72
71
  react.useEffect(() => {
73
72
  const tableSelections = new Map();
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- var e=require("@lexical/react/LexicalComposerContext"),g=require("@lexical/table"),k=require("lexical"),m=require("react");
8
- module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([g.TableNode,g.TableCellNode,g.TableRowNode]))throw Error("Minified Lexical error #54; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(g.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:f}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=g.$createTableNodeWithDimensions(Number(f),
9
- Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},0)},[c]);m.useEffect(()=>{const a=new Map;return c.registerMutationListener(g.TableNode,h=>{for(const [f,d]of h)"created"===d?c.update(()=>{var b=c.getElementByKey(f);const l=k.$getNodeByKey(f);b&&l&&(b=g.applyTableHandlers(l,
10
- b,c),a.set(f,b))}):"destroyed"===d&&(h=a.get(f))&&(h.removeListeners(),a.delete(f))})},[c]);return null};
7
+ var e=require("@lexical/react/LexicalComposerContext"),f=require("@lexical/table"),k=require("lexical"),m=require("react");
8
+ module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([f.TableNode,f.TableCellNode,f.TableRowNode]))throw Error("Minified Lexical error #54; see codes.json for the full message or use the non-minified dev environment for full errors and additional helpful warnings.");return c.registerCommand(f.INSERT_TABLE_COMMAND,a=>{const {columns:h,rows:g}=a;a=k.$getSelection();if(!k.$isRangeSelection(a))return!0;var d=a.focus;a=d.getNode();if(null!==a){const b=f.$createTableNodeWithDimensions(Number(g),
9
+ Number(h));k.$isRootNode(a)?(d=a.getChildAtIndex(d.offset),null!==d?d.insertBefore(b):a.append(b),b.insertBefore(k.$createParagraphNode())):a.getTopLevelElementOrThrow().insertAfter(b);b.insertAfter(k.$createParagraphNode());b.getFirstChildOrThrow().getFirstChildOrThrow().select()}return!0},k.COMMAND_PRIORITY_EDITOR)},[c]);m.useEffect(()=>{const a=new Map;return c.registerMutationListener(f.TableNode,h=>{for(const [g,d]of h)"created"===d?c.update(()=>{var b=c.getElementByKey(g);const l=k.$getNodeByKey(g);
10
+ b&&l&&(b=f.applyTableHandlers(l,b,c),a.set(g,b))}):"destroyed"===d&&(h=a.get(g))&&(h.removeListeners(),a.delete(g))})},[c]);return null};
package/package.json CHANGED
@@ -8,27 +8,27 @@
8
8
  "rich-text"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.2.0",
11
+ "version": "0.2.3",
12
12
  "dependencies": {
13
- "@lexical/clipboard": "0.2.0",
14
- "@lexical/list": "0.2.0",
15
- "@lexical/table": "0.2.0",
16
- "@lexical/yjs": "0.2.0",
17
- "@lexical/hashtag": "0.2.0",
18
- "@lexical/selection": "0.2.0",
19
- "@lexical/utils": "0.2.0",
20
- "@lexical/dragon": "0.2.0",
21
- "@lexical/plain-text": "0.2.0",
22
- "@lexical/rich-text": "0.2.0",
23
- "@lexical/code": "0.2.0",
24
- "@lexical/text": "0.2.0",
25
- "@lexical/link": "0.2.0",
26
- "@lexical/overflow": "0.2.0",
27
- "@lexical/history": "0.2.0",
28
- "@lexical/markdown": "0.2.0"
13
+ "@lexical/clipboard": "0.2.3",
14
+ "@lexical/list": "0.2.3",
15
+ "@lexical/table": "0.2.3",
16
+ "@lexical/yjs": "0.2.3",
17
+ "@lexical/hashtag": "0.2.3",
18
+ "@lexical/selection": "0.2.3",
19
+ "@lexical/utils": "0.2.3",
20
+ "@lexical/dragon": "0.2.3",
21
+ "@lexical/plain-text": "0.2.3",
22
+ "@lexical/rich-text": "0.2.3",
23
+ "@lexical/code": "0.2.3",
24
+ "@lexical/text": "0.2.3",
25
+ "@lexical/link": "0.2.3",
26
+ "@lexical/overflow": "0.2.3",
27
+ "@lexical/history": "0.2.3",
28
+ "@lexical/markdown": "0.2.3"
29
29
  },
30
30
  "peerDependencies": {
31
- "lexical": "0.2.0",
31
+ "lexical": "0.2.3",
32
32
  "react": ">=17.x",
33
33
  "react-dom": ">=17.x"
34
34
  },