@lexical/react 0.38.2-nightly.20251029.0 → 0.38.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.
|
@@ -100,6 +100,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
100
100
|
};
|
|
101
101
|
}, [binding, provider, editor, setDoc, docMap, id]);
|
|
102
102
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
103
|
+
useAwareness(binding, provider);
|
|
103
104
|
return useYjsCursors(binding, cursorsContainerRef);
|
|
104
105
|
}
|
|
105
106
|
function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap, name, color, options = {}) {
|
|
@@ -154,9 +155,6 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
154
155
|
const {
|
|
155
156
|
root
|
|
156
157
|
} = binding;
|
|
157
|
-
const {
|
|
158
|
-
awareness
|
|
159
|
-
} = provider;
|
|
160
158
|
if (diffSnapshots) {
|
|
161
159
|
yjs.renderSnapshot__EXPERIMENTAL(binding, diffSnapshots.snapshot, diffSnapshots.prevSnapshot);
|
|
162
160
|
return;
|
|
@@ -182,17 +180,13 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
182
180
|
yjs.syncLexicalUpdateToYjsV2__EXPERIMENTAL(binding, provider, prevEditorState, editorState, dirtyElements, normalizedNodes, tags);
|
|
183
181
|
}
|
|
184
182
|
});
|
|
185
|
-
const onAwarenessUpdate = () => {
|
|
186
|
-
yjs.syncCursorPositions(binding, provider);
|
|
187
|
-
};
|
|
188
|
-
awareness.on('update', onAwarenessUpdate);
|
|
189
183
|
return () => {
|
|
190
184
|
root.unobserveDeep(onYjsTreeChanges);
|
|
191
185
|
removeListener();
|
|
192
|
-
awareness.off('update', onAwarenessUpdate);
|
|
193
186
|
};
|
|
194
187
|
}, [binding, provider, editor, diffSnapshots]);
|
|
195
188
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
189
|
+
useAwareness(binding, provider);
|
|
196
190
|
return binding;
|
|
197
191
|
}
|
|
198
192
|
function useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap) {
|
|
@@ -255,6 +249,20 @@ function useProvider(editor, provider, name, color, isReloadingDoc, awarenessDat
|
|
|
255
249
|
}, lexical.COMMAND_PRIORITY_EDITOR);
|
|
256
250
|
}, [connect, disconnect, editor]);
|
|
257
251
|
}
|
|
252
|
+
function useAwareness(binding, provider) {
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
const {
|
|
255
|
+
awareness
|
|
256
|
+
} = provider;
|
|
257
|
+
const onAwarenessUpdate = () => {
|
|
258
|
+
yjs.syncCursorPositions(binding, provider);
|
|
259
|
+
};
|
|
260
|
+
awareness.on('update', onAwarenessUpdate);
|
|
261
|
+
return () => {
|
|
262
|
+
awareness.off('update', onAwarenessUpdate);
|
|
263
|
+
};
|
|
264
|
+
}, [binding, provider]);
|
|
265
|
+
}
|
|
258
266
|
function useYjsCursors(binding, cursorsContainerRef) {
|
|
259
267
|
return React.useMemo(() => {
|
|
260
268
|
const ref = element => {
|
|
@@ -86,6 +86,7 @@ function useYjsCollaboration(editor, id, provider, docMap, name, color, shouldBo
|
|
|
86
86
|
};
|
|
87
87
|
}, [binding, provider, editor, setDoc, docMap, id]);
|
|
88
88
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
89
|
+
useAwareness(binding, provider);
|
|
89
90
|
return useYjsCursors(binding, cursorsContainerRef);
|
|
90
91
|
}
|
|
91
92
|
function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap, name, color, options = {}) {
|
|
@@ -140,9 +141,6 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
140
141
|
const {
|
|
141
142
|
root
|
|
142
143
|
} = binding;
|
|
143
|
-
const {
|
|
144
|
-
awareness
|
|
145
|
-
} = provider;
|
|
146
144
|
if (diffSnapshots) {
|
|
147
145
|
renderSnapshot__EXPERIMENTAL(binding, diffSnapshots.snapshot, diffSnapshots.prevSnapshot);
|
|
148
146
|
return;
|
|
@@ -168,17 +166,13 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
168
166
|
syncLexicalUpdateToYjsV2__EXPERIMENTAL(binding, provider, prevEditorState, editorState, dirtyElements, normalizedNodes, tags);
|
|
169
167
|
}
|
|
170
168
|
});
|
|
171
|
-
const onAwarenessUpdate = () => {
|
|
172
|
-
syncCursorPositions(binding, provider);
|
|
173
|
-
};
|
|
174
|
-
awareness.on('update', onAwarenessUpdate);
|
|
175
169
|
return () => {
|
|
176
170
|
root.unobserveDeep(onYjsTreeChanges);
|
|
177
171
|
removeListener();
|
|
178
|
-
awareness.off('update', onAwarenessUpdate);
|
|
179
172
|
};
|
|
180
173
|
}, [binding, provider, editor, diffSnapshots]);
|
|
181
174
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
175
|
+
useAwareness(binding, provider);
|
|
182
176
|
return binding;
|
|
183
177
|
}
|
|
184
178
|
function useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap) {
|
|
@@ -241,6 +235,20 @@ function useProvider(editor, provider, name, color, isReloadingDoc, awarenessDat
|
|
|
241
235
|
}, COMMAND_PRIORITY_EDITOR);
|
|
242
236
|
}, [connect, disconnect, editor]);
|
|
243
237
|
}
|
|
238
|
+
function useAwareness(binding, provider) {
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
const {
|
|
241
|
+
awareness
|
|
242
|
+
} = provider;
|
|
243
|
+
const onAwarenessUpdate = () => {
|
|
244
|
+
syncCursorPositions(binding, provider);
|
|
245
|
+
};
|
|
246
|
+
awareness.on('update', onAwarenessUpdate);
|
|
247
|
+
return () => {
|
|
248
|
+
awareness.off('update', onAwarenessUpdate);
|
|
249
|
+
};
|
|
250
|
+
}, [binding, provider]);
|
|
251
|
+
}
|
|
244
252
|
function useYjsCursors(binding, cursorsContainerRef) {
|
|
245
253
|
return useMemo(() => {
|
|
246
254
|
const ref = element => {
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),o=require("@lexical/yjs"),r=require("react"),n=require("@lexical/utils"),s=require("lexical"),a=require("react-dom"),c=require("yjs"),i=require("react/jsx-runtime");function u(e){var t=Object.create(null);if(e)for(var o in e)t[o]=e[o];return t.default=e,t}var l=u(r);function d(e,t,n,a,i,u,l,d,
|
|
9
|
+
"use strict";var e=require("@lexical/react/LexicalCollaborationContext"),t=require("@lexical/react/LexicalComposerContext"),o=require("@lexical/yjs"),r=require("react"),n=require("@lexical/utils"),s=require("lexical"),a=require("react-dom"),c=require("yjs"),i=require("react/jsx-runtime");function u(e){var t=Object.create(null);if(e)for(var o in e)t[o]=e[o];return t.default=e,t}var l=u(r);function d(e,t,n,a,i,u,l,d,p,_,M,g,R=o.syncCursorPositions){const O=r.useRef(!1),D=r.useCallback(()=>{const{root:t}=d;l&&t.isEmpty()&&0===t._xmlText._length&&m(e,M)},[d,e,M,l]);return r.useEffect(()=>{const{root:t}=d,r=(e,t)=>{const r=t.origin;if(r!==d){const t=r instanceof c.UndoManager;o.syncYjsChangesToLexical(d,n,e,t,R)}};t.getSharedType().observeDeep(r);const a=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyLeaves:r,dirtyElements:a,normalizedNodes:c,tags:i})=>{i.has(s.SKIP_COLLAB_TAG)||o.syncLexicalUpdateToYjs(d,n,e,t,a,r,c,i)});return()=>{t.getSharedType().unobserveDeep(r),a()}},[d,n,e,p,a,t,R]),r.useEffect(()=>{const o=o=>{!function(e,t){if(e.update(()=>{const e=s.$getRoot();e.clear(),e.select()},{tag:s.SKIP_COLLAB_TAG}),null==t.cursors)return;const o=t.cursors;if(null==o)return;const r=t.cursorsContainer;if(null==r)return;const n=Array.from(o.values());for(let e=0;e<n.length;e++){const t=n[e].selection;if(t&&null!=t.selections){const o=t.selections;for(let t=0;t<o.length;t++)r.removeChild(o[e])}}}(e,d),p(o),a.set(t,o),O.current=!0},r=()=>{O.current=!1};return n.on("reload",o),n.on("sync",r),()=>{n.off("reload",o),n.off("sync",r)}},[d,n,e,p,a,t]),f(e,n,i,u,O,g,D),E(d,n),C(d,_)}function f(e,t,n,a,c,i,u){const l=r.useCallback(()=>t.connect(),[t]),d=r.useCallback(()=>{try{t.disconnect()}catch(e){}},[t]);r.useEffect(()=>{const r=({status:t})=>{e.dispatchCommand(o.CONNECTED_COMMAND,"connected"===t)},s=e=>{e&&!1===c.current&&u&&u()};o.initLocalState(t,n,a,document.activeElement===e.getRootElement(),i||{}),t.on("status",r),t.on("sync",s);const f=l();return()=>{!1===c.current&&(f?f.then(d):d()),t.off("sync",s),t.off("status",r)}},[e,t,n,a,c,i,u,l,d]),r.useEffect(()=>e.registerCommand(o.TOGGLE_CONNECT_COMMAND,e=>(e?(console.log("Collaboration connected!"),l()):(console.log("Collaboration disconnected!"),d()),!0),s.COMMAND_PRIORITY_EDITOR),[l,d,e])}function E(e,t){r.useEffect(()=>{const{awareness:r}=t,n=()=>{o.syncCursorPositions(e,t)};return r.on("update",n),()=>{r.off("update",n)}},[e,t])}function C(e,t){return r.useMemo(()=>a.createPortal(i.jsx("div",{ref:t=>{e.cursorsContainer=t}}),t&&t.current||document.body),[e,t])}function p(e,t,a,c,i){r.useEffect(()=>n.mergeRegister(e.registerCommand(s.FOCUS_COMMAND,()=>(o.setLocalStateFocus(t,a,c,!0,i||{}),!1),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.BLUR_COMMAND,()=>(o.setLocalStateFocus(t,a,c,!1,i||{}),!1),s.COMMAND_PRIORITY_EDITOR)),[c,e,a,t,i])}function _(e,t){r.useEffect(()=>n.mergeRegister(e.registerCommand(s.UNDO_COMMAND,()=>(t.undo(),!0),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.REDO_COMMAND,()=>(t.redo(),!0),s.COMMAND_PRIORITY_EDITOR)));const o=r.useCallback(()=>{t.clear()},[t]);return l.useEffect(()=>{const o=()=>{e.dispatchCommand(s.CAN_UNDO_COMMAND,t.undoStack.length>0),e.dispatchCommand(s.CAN_REDO_COMMAND,t.redoStack.length>0)};return t.on("stack-item-added",o),t.on("stack-item-popped",o),t.on("stack-cleared",o),()=>{t.off("stack-item-added",o),t.off("stack-item-popped",o),t.off("stack-cleared",o)}},[e,t]),o}function m(e,t){e.update(()=>{const o=s.$getRoot();if(o.isEmpty())if(t)switch(typeof t){case"string":{const o=e.parseEditorState(t);e.setEditorState(o,{tag:s.HISTORY_MERGE_TAG});break}case"object":e.setEditorState(t,{tag:s.HISTORY_MERGE_TAG});break;case"function":e.update(()=>{s.$getRoot().isEmpty()&&t(e)},{tag:s.HISTORY_MERGE_TAG})}else{const t=s.$createParagraphNode();o.append(t);const{activeElement:r}=document;(null!==s.$getSelection()||null!==r&&r===e.getRootElement())&&t.select()}},{tag:s.HISTORY_MERGE_TAG})}function M({editor:e,id:t,provider:n,yjsDocMap:s,name:a,color:c,shouldBootstrap:i,cursorsContainerRef:u,initialEditorState:l,awarenessData:f,collabContext:E,binding:C,setDoc:m,syncCursorPositionsFn:M}){const g=d(e,t,n,s,a,c,i,C,m,u,l,f,M);return function(e,t){_(e,r.useMemo(()=>o.createUndoManager(t,t.root.getSharedType()),[t]))}(e,C),p(e,n,a,c,f),g}const g=(e,t)=>{r.useEffect(()=>(e.isCollabActive=!0,()=>{null==t._parentEditor&&(e.isCollabActive=!1)}),[e,t])};exports.CollaborationPlugin=function({id:n,providerFactory:s,shouldBootstrap:a,username:c,cursorColor:u,cursorsContainerRef:l,initialEditorState:d,excludedProperties:f,awarenessData:E,syncCursorPositionsFn:C}){const p=r.useRef(!1),_=r.useRef(!1),m=e.useCollaborationContext(c,u),{yjsDocMap:R,name:O,color:D}=m,[T]=t.useLexicalComposerContext();g(m,T);const[A,I]=r.useState(),[N,S]=r.useState();r.useEffect(()=>{if(_.current)return;_.current=!0;const e=s(n,R);return I(e),S(R.get(n)),()=>{e.disconnect()}},[n,s,R]);const[x,y]=r.useState();return r.useEffect(()=>{if(!A)return;if(p.current)return;p.current=!0;const e=o.createBinding(T,A,n,N||R.get(n),R,f);return y(e),()=>{e.root.destroy(e)}},[T,A,n,R,N,f]),A&&x?i.jsx(M,{awarenessData:E,binding:x,collabContext:m,color:D,cursorsContainerRef:l,editor:T,id:n,initialEditorState:d,name:O,provider:A,setDoc:S,shouldBootstrap:a,yjsDocMap:R,syncCursorPositionsFn:C}):i.jsx(i.Fragment,{})},exports.CollaborationPluginV2__EXPERIMENTAL=function({id:a,doc:i,provider:u,__shouldBootstrapUnsafe:l,username:d,cursorColor:M,cursorsContainerRef:R,excludedProperties:O,awarenessData:D}){const T=e.useCollaborationContext(d,M),{yjsDocMap:A,name:I,color:N}=T,[S]=t.useLexicalComposerContext();g(T,S);const x=function(e,t,a,i,u,l,d,C={}){const{awarenessData:p,excludedProperties:_,rootName:M,__shouldBootstrapUnsafe:g}=C,R=r.useMemo(()=>({current:!1}),[]),O=r.useMemo(()=>o.createBindingV2__EXPERIMENTAL(e,t,a,u,{excludedProperties:_,rootName:M}),[e,t,a,u,_,M]);r.useEffect(()=>(u.set(t,a),()=>{u.delete(t)}),[a,u,t]);const D=r.useCallback(()=>{const{root:t}=O;g&&0===t._length&&m(e)},[O,e,g]),[T,A]=r.useState();return r.useEffect(()=>{n.mergeRegister(e.registerCommand(o.CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL,()=>(A(null),o.syncYjsStateToLexicalV2__EXPERIMENTAL(O,i),!0),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(o.DIFF_VERSIONS_COMMAND__EXPERIMENTAL,({prevSnapshot:e,snapshot:t})=>(A({prevSnapshot:e,snapshot:t}),!0),s.COMMAND_PRIORITY_EDITOR))},[e,O,i]),r.useEffect(()=>{const{root:t}=O;if(T)return void o.renderSnapshot__EXPERIMENTAL(O,T.snapshot,T.prevSnapshot);const r=(e,t)=>{const r=t.origin;if(r!==O){const n=r instanceof c.UndoManager;o.syncYjsChangesToLexicalV2__EXPERIMENTAL(O,i,e,t,n)}};t.observeDeep(r);const n=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyElements:r,normalizedNodes:n,tags:a})=>{a.has(s.SKIP_COLLAB_TAG)||o.syncLexicalUpdateToYjsV2__EXPERIMENTAL(O,i,e,t,r,n,a)});return()=>{t.unobserveDeep(r),n()}},[O,i,e,T]),f(e,i,l,d,R,p,D),E(O,i),O}(S,a,i,u,A,I,N,{__shouldBootstrapUnsafe:l,awarenessData:D,excludedProperties:O});return function(e,t){_(e,r.useMemo(()=>o.createUndoManager(t,t.root),[t]))}(S,x),p(S,u,I,N,D),C(x,R)};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{useCollaborationContext as t}from"@lexical/react/LexicalCollaborationContext";import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{syncCursorPositions as o,syncLexicalUpdateToYjs as r,createUndoManager as n,setLocalStateFocus as s,createBindingV2__EXPERIMENTAL as a,CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL as c,syncYjsStateToLexicalV2__EXPERIMENTAL as i,DIFF_VERSIONS_COMMAND__EXPERIMENTAL as d,renderSnapshot__EXPERIMENTAL as
|
|
9
|
+
import{useCollaborationContext as t}from"@lexical/react/LexicalCollaborationContext";import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{syncCursorPositions as o,syncLexicalUpdateToYjs as r,createUndoManager as n,setLocalStateFocus as s,createBindingV2__EXPERIMENTAL as a,CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL as c,syncYjsStateToLexicalV2__EXPERIMENTAL as i,DIFF_VERSIONS_COMMAND__EXPERIMENTAL as d,renderSnapshot__EXPERIMENTAL as u,syncLexicalUpdateToYjsV2__EXPERIMENTAL as l,syncYjsChangesToLexical as p,initLocalState as m,TOGGLE_CONNECT_COMMAND as f,syncYjsChangesToLexicalV2__EXPERIMENTAL as g,CONNECTED_COMMAND as C,createBinding as h}from"@lexical/yjs";import*as y from"react";import{useRef as v,useCallback as x,useEffect as E,useMemo as S,useState as b}from"react";import{mergeRegister as D}from"@lexical/utils";import{SKIP_COLLAB_TAG as k,FOCUS_COMMAND as _,COMMAND_PRIORITY_EDITOR as j,BLUR_COMMAND as w,$getRoot as P,HISTORY_MERGE_TAG as B,$createParagraphNode as R,$getSelection as L,UNDO_COMMAND as U,REDO_COMMAND as F,CAN_UNDO_COMMAND as M,CAN_REDO_COMMAND as N}from"lexical";import{createPortal as T}from"react-dom";import{UndoManager as A}from"yjs";import{jsx as z,Fragment as q}from"react/jsx-runtime";function G(t,e,n,s,a,c,i,d,u,l,m,f,g=o){const C=v(!1),h=x(()=>{const{root:e}=d;i&&e.isEmpty()&&0===e._xmlText._length&&Q(t,m)},[d,t,m,i]);return E(()=>{const{root:e}=d,o=(t,e)=>{const o=e.origin;if(o!==d){p(d,n,t,o instanceof A,g)}};e.getSharedType().observeDeep(o);const s=t.registerUpdateListener(({prevEditorState:t,editorState:e,dirtyLeaves:o,dirtyElements:s,normalizedNodes:a,tags:c})=>{c.has(k)||r(d,n,t,e,s,o,a,c)});return()=>{e.getSharedType().unobserveDeep(o),s()}},[d,n,t,u,s,e,g]),E(()=>{const o=o=>{!function(t,e){if(t.update(()=>{const t=P();t.clear(),t.select()},{tag:k}),null==e.cursors)return;const o=e.cursors;if(null==o)return;const r=e.cursorsContainer;if(null==r)return;const n=Array.from(o.values());for(let t=0;t<n.length;t++){const e=n[t].selection;if(e&&null!=e.selections){const o=e.selections;for(let e=0;e<o.length;e++)r.removeChild(o[t])}}}(t,d),u(o),s.set(e,o),C.current=!0},r=()=>{C.current=!1};return n.on("reload",o),n.on("sync",r),()=>{n.off("reload",o),n.off("sync",r)}},[d,n,t,u,s,e]),H(t,n,a,c,C,f,h),I(d,n),J(d,l)}function H(t,e,o,r,n,s,a){const c=x(()=>e.connect(),[e]),i=x(()=>{try{e.disconnect()}catch(t){}},[e]);E(()=>{const d=({status:e})=>{t.dispatchCommand(C,"connected"===e)},u=t=>{t&&!1===n.current&&a&&a()};m(e,o,r,document.activeElement===t.getRootElement(),s||{}),e.on("status",d),e.on("sync",u);const l=c();return()=>{!1===n.current&&(l?l.then(i):i()),e.off("sync",u),e.off("status",d)}},[t,e,o,r,n,s,a,c,i]),E(()=>t.registerCommand(f,t=>(t?(console.log("Collaboration connected!"),c()):(console.log("Collaboration disconnected!"),i()),!0),j),[c,i,t])}function I(t,e){E(()=>{const{awareness:r}=e,n=()=>{o(t,e)};return r.on("update",n),()=>{r.off("update",n)}},[t,e])}function J(t,e){return S(()=>T(z("div",{ref:e=>{t.cursorsContainer=e}}),e&&e.current||document.body),[t,e])}function K(t,e,o,r,n){E(()=>D(t.registerCommand(_,()=>(s(e,o,r,!0,n||{}),!1),j),t.registerCommand(w,()=>(s(e,o,r,!1,n||{}),!1),j)),[r,t,o,e,n])}function O(t,e){E(()=>D(t.registerCommand(U,()=>(e.undo(),!0),j),t.registerCommand(F,()=>(e.redo(),!0),j)));const o=x(()=>{e.clear()},[e]);return y.useEffect(()=>{const o=()=>{t.dispatchCommand(M,e.undoStack.length>0),t.dispatchCommand(N,e.redoStack.length>0)};return e.on("stack-item-added",o),e.on("stack-item-popped",o),e.on("stack-cleared",o),()=>{e.off("stack-item-added",o),e.off("stack-item-popped",o),e.off("stack-cleared",o)}},[t,e]),o}function Q(t,e){t.update(()=>{const o=P();if(o.isEmpty())if(e)switch(typeof e){case"string":{const o=t.parseEditorState(e);t.setEditorState(o,{tag:B});break}case"object":t.setEditorState(e,{tag:B});break;case"function":t.update(()=>{P().isEmpty()&&e(t)},{tag:B})}else{const e=R();o.append(e);const{activeElement:r}=document;(null!==L()||null!==r&&r===t.getRootElement())&&e.select()}},{tag:B})}function V({id:o,providerFactory:r,shouldBootstrap:n,username:s,cursorColor:a,cursorsContainerRef:c,initialEditorState:i,excludedProperties:d,awarenessData:u,syncCursorPositionsFn:l}){const p=v(!1),m=v(!1),f=t(s,a),{yjsDocMap:g,name:C,color:y}=f,[x]=e();Y(f,x);const[S,D]=b(),[k,_]=b();E(()=>{if(m.current)return;m.current=!0;const t=r(o,g);return D(t),_(g.get(o)),()=>{t.disconnect()}},[o,r,g]);const[j,w]=b();return E(()=>{if(!S)return;if(p.current)return;p.current=!0;const t=h(x,S,o,k||g.get(o),g,d);return w(t),()=>{t.root.destroy(t)}},[x,S,o,g,k,d]),S&&j?z(W,{awarenessData:u,binding:j,collabContext:f,color:y,cursorsContainerRef:c,editor:x,id:o,initialEditorState:i,name:C,provider:S,setDoc:_,shouldBootstrap:n,yjsDocMap:g,syncCursorPositionsFn:l}):z(q,{})}function W({editor:t,id:e,provider:o,yjsDocMap:r,name:s,color:a,shouldBootstrap:c,cursorsContainerRef:i,initialEditorState:d,awarenessData:u,collabContext:l,binding:p,setDoc:m,syncCursorPositionsFn:f}){const g=G(t,e,o,r,s,a,c,p,m,i,d,u,f);return function(t,e){O(t,S(()=>n(e,e.root.getSharedType()),[e]))}(t,p),K(t,o,s,a,u),g}function X({id:o,doc:r,provider:s,__shouldBootstrapUnsafe:p,username:m,cursorColor:f,cursorsContainerRef:C,excludedProperties:h,awarenessData:y}){const v=t(m,f),{yjsDocMap:_,name:w,color:P}=v,[B]=e();Y(v,B);const R=function(t,e,o,r,n,s,p,m={}){const{awarenessData:f,excludedProperties:C,rootName:h,__shouldBootstrapUnsafe:y}=m,v=S(()=>({current:!1}),[]),_=S(()=>a(t,e,o,n,{excludedProperties:C,rootName:h}),[t,e,o,n,C,h]);E(()=>(n.set(e,o),()=>{n.delete(e)}),[o,n,e]);const w=x(()=>{const{root:e}=_;y&&0===e._length&&Q(t)},[_,t,y]),[P,B]=b();return E(()=>{D(t.registerCommand(c,()=>(B(null),i(_,r),!0),j),t.registerCommand(d,({prevSnapshot:t,snapshot:e})=>(B({prevSnapshot:t,snapshot:e}),!0),j))},[t,_,r]),E(()=>{const{root:e}=_;if(P)return void u(_,P.snapshot,P.prevSnapshot);const o=(t,e)=>{const o=e.origin;o!==_&&g(_,r,t,e,o instanceof A)};e.observeDeep(o);const n=t.registerUpdateListener(({prevEditorState:t,editorState:e,dirtyElements:o,normalizedNodes:n,tags:s})=>{s.has(k)||l(_,r,t,e,o,n,s)});return()=>{e.unobserveDeep(o),n()}},[_,r,t,P]),H(t,r,s,p,v,f,w),I(_,r),_}(B,o,r,s,_,w,P,{__shouldBootstrapUnsafe:p,awarenessData:y,excludedProperties:h});return function(t,e){O(t,S(()=>n(e,e.root),[e]))}(B,R),K(B,s,w,P,y),J(R,C)}const Y=(t,e)=>{E(()=>(t.isCollabActive=!0,()=>{null==e._parentEditor&&(t.isCollabActive=!1)}),[t,e])};export{V as CollaborationPlugin,X as CollaborationPluginV2__EXPERIMENTAL};
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.38.2
|
|
11
|
+
"version": "0.38.2",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@floating-ui/react": "^0.27.16",
|
|
14
|
-
"@lexical/devtools-core": "0.38.2
|
|
15
|
-
"@lexical/dragon": "0.38.2
|
|
16
|
-
"@lexical/extension": "0.38.2
|
|
17
|
-
"@lexical/hashtag": "0.38.2
|
|
18
|
-
"@lexical/history": "0.38.2
|
|
19
|
-
"@lexical/link": "0.38.2
|
|
20
|
-
"@lexical/list": "0.38.2
|
|
21
|
-
"@lexical/mark": "0.38.2
|
|
22
|
-
"@lexical/markdown": "0.38.2
|
|
23
|
-
"@lexical/overflow": "0.38.2
|
|
24
|
-
"@lexical/plain-text": "0.38.2
|
|
25
|
-
"@lexical/rich-text": "0.38.2
|
|
26
|
-
"@lexical/table": "0.38.2
|
|
27
|
-
"@lexical/text": "0.38.2
|
|
28
|
-
"@lexical/utils": "0.38.2
|
|
29
|
-
"@lexical/yjs": "0.38.2
|
|
30
|
-
"lexical": "0.38.2
|
|
14
|
+
"@lexical/devtools-core": "0.38.2",
|
|
15
|
+
"@lexical/dragon": "0.38.2",
|
|
16
|
+
"@lexical/extension": "0.38.2",
|
|
17
|
+
"@lexical/hashtag": "0.38.2",
|
|
18
|
+
"@lexical/history": "0.38.2",
|
|
19
|
+
"@lexical/link": "0.38.2",
|
|
20
|
+
"@lexical/list": "0.38.2",
|
|
21
|
+
"@lexical/mark": "0.38.2",
|
|
22
|
+
"@lexical/markdown": "0.38.2",
|
|
23
|
+
"@lexical/overflow": "0.38.2",
|
|
24
|
+
"@lexical/plain-text": "0.38.2",
|
|
25
|
+
"@lexical/rich-text": "0.38.2",
|
|
26
|
+
"@lexical/table": "0.38.2",
|
|
27
|
+
"@lexical/text": "0.38.2",
|
|
28
|
+
"@lexical/utils": "0.38.2",
|
|
29
|
+
"@lexical/yjs": "0.38.2",
|
|
30
|
+
"lexical": "0.38.2",
|
|
31
31
|
"react-error-boundary": "^6.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|