@lexical/react 0.36.3-nightly.20251006.0 → 0.36.3-nightly.20251007.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.
|
@@ -132,6 +132,24 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
132
132
|
initializeEditor(editor);
|
|
133
133
|
}
|
|
134
134
|
}, [binding, editor, shouldBootstrap]);
|
|
135
|
+
const [diffSnapshots, setDiffSnapshots] = React.useState();
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
utils.mergeRegister(editor.registerCommand(yjs.CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
|
|
138
|
+
setDiffSnapshots(null);
|
|
139
|
+
// Ensure that any state already in Yjs is loaded into the editor (eg: after clearing diff view).
|
|
140
|
+
yjs.syncYjsStateToLexicalV2__EXPERIMENTAL(binding, provider);
|
|
141
|
+
return true;
|
|
142
|
+
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(yjs.DIFF_VERSIONS_COMMAND__EXPERIMENTAL, ({
|
|
143
|
+
prevSnapshot,
|
|
144
|
+
snapshot
|
|
145
|
+
}) => {
|
|
146
|
+
setDiffSnapshots({
|
|
147
|
+
prevSnapshot,
|
|
148
|
+
snapshot
|
|
149
|
+
});
|
|
150
|
+
return true;
|
|
151
|
+
}, lexical.COMMAND_PRIORITY_EDITOR));
|
|
152
|
+
}, [editor, binding, provider]);
|
|
135
153
|
React.useEffect(() => {
|
|
136
154
|
const {
|
|
137
155
|
root
|
|
@@ -139,6 +157,10 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
139
157
|
const {
|
|
140
158
|
awareness
|
|
141
159
|
} = provider;
|
|
160
|
+
if (diffSnapshots) {
|
|
161
|
+
yjs.renderSnapshot__EXPERIMENTAL(binding, diffSnapshots.snapshot, diffSnapshots.prevSnapshot);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
142
164
|
const onYjsTreeChanges = (events, transaction) => {
|
|
143
165
|
const origin = transaction.origin;
|
|
144
166
|
if (origin !== binding) {
|
|
@@ -169,7 +191,7 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
169
191
|
removeListener();
|
|
170
192
|
awareness.off('update', onAwarenessUpdate);
|
|
171
193
|
};
|
|
172
|
-
}, [binding, provider, editor]);
|
|
194
|
+
}, [binding, provider, editor, diffSnapshots]);
|
|
173
195
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
174
196
|
return binding;
|
|
175
197
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { useCollaborationContext } from '@lexical/react/LexicalCollaborationContext';
|
|
10
10
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
11
|
-
import { syncCursorPositions, syncLexicalUpdateToYjs, createUndoManager, setLocalStateFocus, createBindingV2__EXPERIMENTAL, syncLexicalUpdateToYjsV2__EXPERIMENTAL, syncYjsChangesToLexical, initLocalState, TOGGLE_CONNECT_COMMAND, syncYjsChangesToLexicalV2__EXPERIMENTAL, CONNECTED_COMMAND, createBinding } from '@lexical/yjs';
|
|
11
|
+
import { syncCursorPositions, syncLexicalUpdateToYjs, createUndoManager, setLocalStateFocus, createBindingV2__EXPERIMENTAL, CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, syncYjsStateToLexicalV2__EXPERIMENTAL, DIFF_VERSIONS_COMMAND__EXPERIMENTAL, renderSnapshot__EXPERIMENTAL, syncLexicalUpdateToYjsV2__EXPERIMENTAL, syncYjsChangesToLexical, initLocalState, TOGGLE_CONNECT_COMMAND, syncYjsChangesToLexicalV2__EXPERIMENTAL, CONNECTED_COMMAND, createBinding } from '@lexical/yjs';
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import { useRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
14
|
import { mergeRegister } from '@lexical/utils';
|
|
@@ -118,6 +118,24 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
118
118
|
initializeEditor(editor);
|
|
119
119
|
}
|
|
120
120
|
}, [binding, editor, shouldBootstrap]);
|
|
121
|
+
const [diffSnapshots, setDiffSnapshots] = useState();
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
mergeRegister(editor.registerCommand(CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL, () => {
|
|
124
|
+
setDiffSnapshots(null);
|
|
125
|
+
// Ensure that any state already in Yjs is loaded into the editor (eg: after clearing diff view).
|
|
126
|
+
syncYjsStateToLexicalV2__EXPERIMENTAL(binding, provider);
|
|
127
|
+
return true;
|
|
128
|
+
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(DIFF_VERSIONS_COMMAND__EXPERIMENTAL, ({
|
|
129
|
+
prevSnapshot,
|
|
130
|
+
snapshot
|
|
131
|
+
}) => {
|
|
132
|
+
setDiffSnapshots({
|
|
133
|
+
prevSnapshot,
|
|
134
|
+
snapshot
|
|
135
|
+
});
|
|
136
|
+
return true;
|
|
137
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
138
|
+
}, [editor, binding, provider]);
|
|
121
139
|
useEffect(() => {
|
|
122
140
|
const {
|
|
123
141
|
root
|
|
@@ -125,6 +143,10 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
125
143
|
const {
|
|
126
144
|
awareness
|
|
127
145
|
} = provider;
|
|
146
|
+
if (diffSnapshots) {
|
|
147
|
+
renderSnapshot__EXPERIMENTAL(binding, diffSnapshots.snapshot, diffSnapshots.prevSnapshot);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
128
150
|
const onYjsTreeChanges = (events, transaction) => {
|
|
129
151
|
const origin = transaction.origin;
|
|
130
152
|
if (origin !== binding) {
|
|
@@ -155,7 +177,7 @@ function useYjsCollaborationV2__EXPERIMENTAL(editor, id, doc, provider, docMap,
|
|
|
155
177
|
removeListener();
|
|
156
178
|
awareness.off('update', onAwarenessUpdate);
|
|
157
179
|
};
|
|
158
|
-
}, [binding, provider, editor]);
|
|
180
|
+
}, [binding, provider, editor, diffSnapshots]);
|
|
159
181
|
useProvider(editor, provider, name, color, isReloadingDoc, awarenessData, onBootstrap);
|
|
160
182
|
return binding;
|
|
161
183
|
}
|
|
@@ -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,E,p,
|
|
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,E,p,m,M,g=o.syncCursorPositions){const R=r.useRef(!1),O=r.useCallback(()=>{const{root:t}=d;l&&t.isEmpty()&&0===t._xmlText._length&&_(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,g)}};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,E,a,t,g]),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),E(o),a.set(t,o),R.current=!0},r=()=>{R.current=!1};return n.on("reload",o),n.on("sync",r),()=>{n.off("reload",o),n.off("sync",r)}},[d,n,e,E,a,t]),f(e,n,i,u,R,M,O),C(d,p)}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 C(e,t){return r.useMemo(()=>a.createPortal(i.jsx("div",{ref:t=>{e.cursorsContainer=t}}),t&&t.current||document.body),[e,t])}function E(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 p(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 _(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:C,binding:_,setDoc:m,syncCursorPositionsFn:M}){const g=d(e,t,n,s,a,c,i,_,m,u,l,f,M);return function(e,t){p(e,r.useMemo(()=>o.createUndoManager(t,t.root.getSharedType()),[t]))}(e,_),E(e,n,a,c,f),g}const M=(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:C,syncCursorPositionsFn:E}){const p=r.useRef(!1),_=r.useRef(!1),g=e.useCollaborationContext(c,u),{yjsDocMap:R,name:O,color:D}=g,[T]=t.useLexicalComposerContext();M(g,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:C,binding:x,collabContext:g,color:D,cursorsContainerRef:l,editor:T,id:n,initialEditorState:d,name:O,provider:A,setDoc:S,shouldBootstrap:a,yjsDocMap:R,syncCursorPositionsFn:E}):i.jsx(i.Fragment,{})},exports.CollaborationPluginV2__EXPERIMENTAL=function({id:a,doc:i,provider:u,__shouldBootstrapUnsafe:l,username:d,cursorColor:m,cursorsContainerRef:g,excludedProperties:R,awarenessData:O}){const D=e.useCollaborationContext(d,m),{yjsDocMap:T,name:A,color:I}=D,[N]=t.useLexicalComposerContext();M(D,N);const S=function(e,t,a,i,u,l,d,C={}){const{awarenessData:E,excludedProperties:p,rootName:m,__shouldBootstrapUnsafe:M}=C,g=r.useMemo(()=>({current:!1}),[]),R=r.useMemo(()=>o.createBindingV2__EXPERIMENTAL(e,t,a,u,{excludedProperties:p,rootName:m}),[e,t,a,u,p,m]);r.useEffect(()=>(u.set(t,a),()=>{u.delete(t)}),[a,u,t]);const O=r.useCallback(()=>{const{root:t}=R;M&&0===t._length&&_(e)},[R,e,M]),[D,T]=r.useState();return r.useEffect(()=>{n.mergeRegister(e.registerCommand(o.CLEAR_DIFF_VERSIONS_COMMAND__EXPERIMENTAL,()=>(T(null),o.syncYjsStateToLexicalV2__EXPERIMENTAL(R,i),!0),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(o.DIFF_VERSIONS_COMMAND__EXPERIMENTAL,({prevSnapshot:e,snapshot:t})=>(T({prevSnapshot:e,snapshot:t}),!0),s.COMMAND_PRIORITY_EDITOR))},[e,R,i]),r.useEffect(()=>{const{root:t}=R,{awareness:r}=i;if(D)return void o.renderSnapshot__EXPERIMENTAL(R,D.snapshot,D.prevSnapshot);const n=(e,t)=>{const r=t.origin;if(r!==R){const n=r instanceof c.UndoManager;o.syncYjsChangesToLexicalV2__EXPERIMENTAL(R,i,e,t,n)}};t.observeDeep(n);const a=e.registerUpdateListener(({prevEditorState:e,editorState:t,dirtyElements:r,normalizedNodes:n,tags:a})=>{a.has(s.SKIP_COLLAB_TAG)||o.syncLexicalUpdateToYjsV2__EXPERIMENTAL(R,i,e,t,r,n,a)}),u=()=>{o.syncCursorPositions(R,i)};return r.on("update",u),()=>{t.unobserveDeep(n),a(),r.off("update",u)}},[R,i,e,D]),f(e,i,l,d,g,E,O),R}(N,a,i,u,T,A,I,{__shouldBootstrapUnsafe:l,awarenessData:O,excludedProperties:R});return function(e,t){p(e,r.useMemo(()=>o.createUndoManager(t,t.root),[t]))}(N,S),E(N,u,A,I,O),C(S,g)};
|
|
@@ -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 c,syncLexicalUpdateToYjsV2__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 l,syncLexicalUpdateToYjsV2__EXPERIMENTAL as u,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,l,u,m,f,g=o){const C=v(!1),h=x(()=>{const{root:e}=d;i&&e.isEmpty()&&0===e._xmlText._length&&O(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,l,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),l(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,l,s,e]),H(t,n,a,c,C,f,h),I(d,u)}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)},l=t=>{t&&!1===n.current&&a&&a()};m(e,o,r,document.activeElement===t.getRootElement(),s||{}),e.on("status",d),e.on("sync",l);const u=c();return()=>{!1===n.current&&(u?u.then(i):i()),e.off("sync",l),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){return S(()=>T(z("div",{ref:e=>{t.cursorsContainer=e}}),e&&e.current||document.body),[t,e])}function J(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 K(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 O(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 Q({id:o,providerFactory:r,shouldBootstrap:n,username:s,cursorColor:a,cursorsContainerRef:c,initialEditorState:i,excludedProperties:d,awarenessData:l,syncCursorPositionsFn:u}){const p=v(!1),m=v(!1),f=t(s,a),{yjsDocMap:g,name:C,color:y}=f,[x]=e();X(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(V,{awarenessData:l,binding:j,collabContext:f,color:y,cursorsContainerRef:c,editor:x,id:o,initialEditorState:i,name:C,provider:S,setDoc:_,shouldBootstrap:n,yjsDocMap:g,syncCursorPositionsFn:u}):z(q,{})}function V({editor:t,id:e,provider:o,yjsDocMap:r,name:s,color:a,shouldBootstrap:c,cursorsContainerRef:i,initialEditorState:d,awarenessData:l,collabContext:u,binding:p,setDoc:m,syncCursorPositionsFn:f}){const g=G(t,e,o,r,s,a,c,p,m,i,d,l,f);return function(t,e){K(t,S(()=>n(e,e.root.getSharedType()),[e]))}(t,p),J(t,o,s,a,l),g}function W({id:r,doc:s,provider:p,__shouldBootstrapUnsafe:m,username:f,cursorColor:C,cursorsContainerRef:h,excludedProperties:y,awarenessData:v}){const _=t(f,C),{yjsDocMap:w,name:P,color:B}=_,[R]=e();X(_,R);const L=function(t,e,r,n,s,p,m,f={}){const{awarenessData:C,excludedProperties:h,rootName:y,__shouldBootstrapUnsafe:v}=f,_=S(()=>({current:!1}),[]),w=S(()=>a(t,e,r,s,{excludedProperties:h,rootName:y}),[t,e,r,s,h,y]);E(()=>(s.set(e,r),()=>{s.delete(e)}),[r,s,e]);const P=x(()=>{const{root:e}=w;v&&0===e._length&&O(t)},[w,t,v]),[B,R]=b();return E(()=>{D(t.registerCommand(c,()=>(R(null),i(w,n),!0),j),t.registerCommand(d,({prevSnapshot:t,snapshot:e})=>(R({prevSnapshot:t,snapshot:e}),!0),j))},[t,w,n]),E(()=>{const{root:e}=w,{awareness:r}=n;if(B)return void l(w,B.snapshot,B.prevSnapshot);const s=(t,e)=>{const o=e.origin;o!==w&&g(w,n,t,e,o instanceof A)};e.observeDeep(s);const a=t.registerUpdateListener(({prevEditorState:t,editorState:e,dirtyElements:o,normalizedNodes:r,tags:s})=>{s.has(k)||u(w,n,t,e,o,r,s)}),c=()=>{o(w,n)};return r.on("update",c),()=>{e.unobserveDeep(s),a(),r.off("update",c)}},[w,n,t,B]),H(t,n,p,m,_,C,P),w}(R,r,s,p,w,P,B,{__shouldBootstrapUnsafe:m,awarenessData:v,excludedProperties:y});return function(t,e){K(t,S(()=>n(e,e.root),[e]))}(R,L),J(R,p,P,B,v),I(L,h)}const X=(t,e)=>{E(()=>(t.isCollabActive=!0,()=>{null==e._parentEditor&&(t.isCollabActive=!1)}),[t,e])};export{Q as CollaborationPlugin,W as CollaborationPluginV2__EXPERIMENTAL};
|
package/package.json
CHANGED
|
@@ -8,26 +8,26 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.36.3-nightly.
|
|
11
|
+
"version": "0.36.3-nightly.20251007.0",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@floating-ui/react": "^0.27.16",
|
|
14
|
-
"@lexical/devtools-core": "0.36.3-nightly.
|
|
15
|
-
"@lexical/dragon": "0.36.3-nightly.
|
|
16
|
-
"@lexical/extension": "0.36.3-nightly.
|
|
17
|
-
"@lexical/hashtag": "0.36.3-nightly.
|
|
18
|
-
"@lexical/history": "0.36.3-nightly.
|
|
19
|
-
"@lexical/link": "0.36.3-nightly.
|
|
20
|
-
"@lexical/list": "0.36.3-nightly.
|
|
21
|
-
"@lexical/mark": "0.36.3-nightly.
|
|
22
|
-
"@lexical/markdown": "0.36.3-nightly.
|
|
23
|
-
"@lexical/overflow": "0.36.3-nightly.
|
|
24
|
-
"@lexical/plain-text": "0.36.3-nightly.
|
|
25
|
-
"@lexical/rich-text": "0.36.3-nightly.
|
|
26
|
-
"@lexical/table": "0.36.3-nightly.
|
|
27
|
-
"@lexical/text": "0.36.3-nightly.
|
|
28
|
-
"@lexical/utils": "0.36.3-nightly.
|
|
29
|
-
"@lexical/yjs": "0.36.3-nightly.
|
|
30
|
-
"lexical": "0.36.3-nightly.
|
|
14
|
+
"@lexical/devtools-core": "0.36.3-nightly.20251007.0",
|
|
15
|
+
"@lexical/dragon": "0.36.3-nightly.20251007.0",
|
|
16
|
+
"@lexical/extension": "0.36.3-nightly.20251007.0",
|
|
17
|
+
"@lexical/hashtag": "0.36.3-nightly.20251007.0",
|
|
18
|
+
"@lexical/history": "0.36.3-nightly.20251007.0",
|
|
19
|
+
"@lexical/link": "0.36.3-nightly.20251007.0",
|
|
20
|
+
"@lexical/list": "0.36.3-nightly.20251007.0",
|
|
21
|
+
"@lexical/mark": "0.36.3-nightly.20251007.0",
|
|
22
|
+
"@lexical/markdown": "0.36.3-nightly.20251007.0",
|
|
23
|
+
"@lexical/overflow": "0.36.3-nightly.20251007.0",
|
|
24
|
+
"@lexical/plain-text": "0.36.3-nightly.20251007.0",
|
|
25
|
+
"@lexical/rich-text": "0.36.3-nightly.20251007.0",
|
|
26
|
+
"@lexical/table": "0.36.3-nightly.20251007.0",
|
|
27
|
+
"@lexical/text": "0.36.3-nightly.20251007.0",
|
|
28
|
+
"@lexical/utils": "0.36.3-nightly.20251007.0",
|
|
29
|
+
"@lexical/yjs": "0.36.3-nightly.20251007.0",
|
|
30
|
+
"lexical": "0.36.3-nightly.20251007.0",
|
|
31
31
|
"react-error-boundary": "^6.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|