@lexical/react 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPRECATED_useLexicalList.dev.js +6 -7
- package/DEPRECATED_useLexicalList.prod.js +2 -2
- package/LexicalAutoScrollPlugin.d.ts +1 -1
- package/LexicalAutoScrollPlugin.js.flow +3 -1
- package/LexicalClearEditorPlugin.dev.js +1 -1
- package/LexicalClearEditorPlugin.prod.js +1 -1
- package/LexicalCollaborationPlugin.dev.js +5 -6
- package/LexicalCollaborationPlugin.prod.js +9 -9
- package/LexicalHorizontalRuleNode.d.ts +2 -2
- package/LexicalLinkPlugin.dev.js +1 -2
- package/LexicalLinkPlugin.prod.js +1 -1
- package/LexicalListPlugin.dev.js +6 -7
- package/LexicalListPlugin.prod.js +2 -2
- package/LexicalNestedComposer.dev.js +10 -2
- package/LexicalNestedComposer.prod.js +3 -3
- package/LexicalTablePlugin.dev.js +1 -2
- package/LexicalTablePlugin.prod.js +4 -4
- package/package.json +18 -18
|
@@ -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
|
-
},
|
|
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
|
-
},
|
|
40
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
|
|
42
41
|
list.insertList(editor, 'ol');
|
|
43
42
|
return true;
|
|
44
|
-
},
|
|
43
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
|
|
45
44
|
list.insertList(editor, 'ul');
|
|
46
45
|
return true;
|
|
47
|
-
},
|
|
46
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
|
|
48
47
|
list.removeList(editor);
|
|
49
48
|
return true;
|
|
50
|
-
},
|
|
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
|
-
},
|
|
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,
|
|
9
|
-
!0:!1,
|
|
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)};
|
|
@@ -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},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
144
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.BLUR_COMMAND, payload => {
|
|
146
145
|
yjs.setLocalStateFocus(provider, name, color, false);
|
|
147
146
|
return true;
|
|
148
|
-
},
|
|
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
|
-
},
|
|
164
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REDO_COMMAND, () => {
|
|
166
165
|
redo();
|
|
167
166
|
return true;
|
|
168
|
-
},
|
|
167
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
169
168
|
});
|
|
170
169
|
const clearHistory = React.useCallback(() => {
|
|
171
170
|
undoManager.clear();
|
|
@@ -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"),
|
|
8
|
-
function H(b,c,a,d,
|
|
9
|
-
a,
|
|
10
|
-
D);y.off("update",B);
|
|
11
|
-
function K(b,c,a,d){
|
|
12
|
-
function L(b,c){const 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
|
|
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=
|
|
16
|
-
function U(b){const c=
|
|
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;
|
|
@@ -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;
|
package/LexicalLinkPlugin.dev.js
CHANGED
|
@@ -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
|
-
},
|
|
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},
|
|
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};
|
package/LexicalListPlugin.dev.js
CHANGED
|
@@ -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
|
-
},
|
|
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
|
-
},
|
|
41
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_ORDERED_LIST_COMMAND, () => {
|
|
43
42
|
list.insertList(editor, 'ol');
|
|
44
43
|
return true;
|
|
45
|
-
},
|
|
44
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.INSERT_UNORDERED_LIST_COMMAND, () => {
|
|
46
45
|
list.insertList(editor, 'ul');
|
|
47
46
|
return true;
|
|
48
|
-
},
|
|
47
|
+
}, lexical.COMMAND_PRIORITY_LOW), editor.registerCommand(list.REMOVE_LIST_COMMAND, () => {
|
|
49
48
|
list.removeList(editor);
|
|
50
49
|
return true;
|
|
51
|
-
},
|
|
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
|
-
},
|
|
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,
|
|
9
|
-
!0:!1,
|
|
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};
|
|
@@ -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
|
|
8
|
-
module.exports=function({initialEditor:a,children:
|
|
9
|
-
{value:
|
|
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
|
-
},
|
|
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"),
|
|
8
|
-
module.exports=function(){const [c]=e.useLexicalComposerContext();m.useEffect(()=>{if(!c.hasNodes([
|
|
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},
|
|
10
|
-
b,c),a.set(
|
|
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.
|
|
11
|
+
"version": "0.2.2",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.2.
|
|
14
|
-
"@lexical/list": "0.2.
|
|
15
|
-
"@lexical/table": "0.2.
|
|
16
|
-
"@lexical/yjs": "0.2.
|
|
17
|
-
"@lexical/hashtag": "0.2.
|
|
18
|
-
"@lexical/selection": "0.2.
|
|
19
|
-
"@lexical/utils": "0.2.
|
|
20
|
-
"@lexical/dragon": "0.2.
|
|
21
|
-
"@lexical/plain-text": "0.2.
|
|
22
|
-
"@lexical/rich-text": "0.2.
|
|
23
|
-
"@lexical/code": "0.2.
|
|
24
|
-
"@lexical/text": "0.2.
|
|
25
|
-
"@lexical/link": "0.2.
|
|
26
|
-
"@lexical/overflow": "0.2.
|
|
27
|
-
"@lexical/history": "0.2.
|
|
28
|
-
"@lexical/markdown": "0.2.
|
|
13
|
+
"@lexical/clipboard": "0.2.2",
|
|
14
|
+
"@lexical/list": "0.2.2",
|
|
15
|
+
"@lexical/table": "0.2.2",
|
|
16
|
+
"@lexical/yjs": "0.2.2",
|
|
17
|
+
"@lexical/hashtag": "0.2.2",
|
|
18
|
+
"@lexical/selection": "0.2.2",
|
|
19
|
+
"@lexical/utils": "0.2.2",
|
|
20
|
+
"@lexical/dragon": "0.2.2",
|
|
21
|
+
"@lexical/plain-text": "0.2.2",
|
|
22
|
+
"@lexical/rich-text": "0.2.2",
|
|
23
|
+
"@lexical/code": "0.2.2",
|
|
24
|
+
"@lexical/text": "0.2.2",
|
|
25
|
+
"@lexical/link": "0.2.2",
|
|
26
|
+
"@lexical/overflow": "0.2.2",
|
|
27
|
+
"@lexical/history": "0.2.2",
|
|
28
|
+
"@lexical/markdown": "0.2.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"lexical": "0.2.
|
|
31
|
+
"lexical": "0.2.2",
|
|
32
32
|
"react": ">=17.x",
|
|
33
33
|
"react-dom": ">=17.x"
|
|
34
34
|
},
|