@lexical/react 0.35.1-nightly.20250918.0 → 0.35.1-nightly.20250919.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.
- package/LexicalCollaborationContext.d.ts +0 -1
- package/LexicalCollaborationContext.dev.js +0 -1
- package/LexicalCollaborationContext.dev.mjs +0 -1
- package/LexicalCollaborationContext.prod.js +1 -1
- package/LexicalCollaborationContext.prod.mjs +1 -1
- package/LexicalCollaborationPlugin.dev.js +0 -1
- package/LexicalCollaborationPlugin.dev.mjs +0 -1
- package/LexicalCollaborationPlugin.prod.js +1 -1
- package/LexicalCollaborationPlugin.prod.mjs +1 -1
- package/package.json +17 -17
|
@@ -21,7 +21,6 @@ var react = require('react');
|
|
|
21
21
|
const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
|
|
22
22
|
const randomEntry = entries[Math.floor(Math.random() * entries.length)];
|
|
23
23
|
const CollaborationContext = /*#__PURE__*/react.createContext({
|
|
24
|
-
clientID: 0,
|
|
25
24
|
color: randomEntry[1],
|
|
26
25
|
isCollabActive: false,
|
|
27
26
|
name: randomEntry[0],
|
|
@@ -19,7 +19,6 @@ import { createContext, useContext } from 'react';
|
|
|
19
19
|
const entries = [['Cat', 'rgb(125, 50, 0)'], ['Dog', 'rgb(100, 0, 0)'], ['Rabbit', 'rgb(150, 0, 0)'], ['Frog', 'rgb(200, 0, 0)'], ['Fox', 'rgb(200, 75, 0)'], ['Hedgehog', 'rgb(0, 75, 0)'], ['Pigeon', 'rgb(0, 125, 0)'], ['Squirrel', 'rgb(75, 100, 0)'], ['Bear', 'rgb(125, 100, 0)'], ['Tiger', 'rgb(0, 0, 150)'], ['Leopard', 'rgb(0, 0, 200)'], ['Zebra', 'rgb(0, 0, 250)'], ['Wolf', 'rgb(0, 100, 150)'], ['Owl', 'rgb(0, 100, 100)'], ['Gull', 'rgb(100, 0, 100)'], ['Squid', 'rgb(150, 0, 150)']];
|
|
20
20
|
const randomEntry = entries[Math.floor(Math.random() * entries.length)];
|
|
21
21
|
const CollaborationContext = /*#__PURE__*/createContext({
|
|
22
|
-
clientID: 0,
|
|
23
22
|
color: randomEntry[1],
|
|
24
23
|
isCollabActive: false,
|
|
25
24
|
name: randomEntry[0],
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var r=require("react");const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],e=o[Math.floor(Math.random()*o.length)],t=r.createContext({
|
|
9
|
+
"use strict";var r=require("react");const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],e=o[Math.floor(Math.random()*o.length)],t=r.createContext({color:e[1],isCollabActive:!1,name:e[0],yjsDocMap:new Map});exports.CollaborationContext=t,exports.useCollaborationContext=function(o,e){const g=r.useContext(t);return null!=o&&(g.name=o),null!=e&&(g.color=e),g};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({
|
|
9
|
+
import{createContext as r,useContext as g}from"react";const o=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],b=o[Math.floor(Math.random()*o.length)],e=r({color:b[1],isCollabActive:!1,name:b[0],yjsDocMap:new Map});function l(r,o){const b=g(e);return null!=r&&(b.name=r),null!=o&&(b.color=o),b}export{e as CollaborationContext,l as useCollaborationContext};
|
|
@@ -390,7 +390,6 @@ function YjsCollaborationCursors({
|
|
|
390
390
|
syncCursorPositionsFn
|
|
391
391
|
}) {
|
|
392
392
|
const cursors = useYjsCollaboration(editor, id, provider, yjsDocMap, name, color, shouldBootstrap, binding, setDoc, cursorsContainerRef, initialEditorState, awarenessData, syncCursorPositionsFn);
|
|
393
|
-
collabContext.clientID = binding.clientID;
|
|
394
393
|
useYjsHistory(editor, binding);
|
|
395
394
|
useYjsFocusTracking(editor, provider, name, color, awarenessData);
|
|
396
395
|
return cursors;
|
|
@@ -376,7 +376,6 @@ function YjsCollaborationCursors({
|
|
|
376
376
|
syncCursorPositionsFn
|
|
377
377
|
}) {
|
|
378
378
|
const cursors = useYjsCollaboration(editor, id, provider, yjsDocMap, name, color, shouldBootstrap, binding, setDoc, cursorsContainerRef, initialEditorState, awarenessData, syncCursorPositionsFn);
|
|
379
|
-
collabContext.clientID = binding.clientID;
|
|
380
379
|
useYjsHistory(editor, binding);
|
|
381
380
|
useYjsFocusTracking(editor, provider, name, color, awarenessData);
|
|
382
381
|
return cursors;
|
|
@@ -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,u,l,d,f,C,m,g,p,E,R=o.syncCursorPositions){const O=r.useRef(!1),M=r.useCallback((()=>n.connect()),[n]),_=r.useCallback((()=>{try{n.disconnect()}catch(e){}}),[n]);r.useEffect((()=>{const{root:r}=C,{awareness:a}=n,i=({status:t})=>{e.dispatchCommand(o.CONNECTED_COMMAND,"connected"===t)},g=t=>{f&&t&&r.isEmpty()&&0===r._xmlText._length&&!1===O.current&&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})}(e,p),O.current=!1},D=()=>{R(C,n)},T=(e,t)=>{const r=t.origin;if(r!==C){const t=r instanceof c.UndoManager;o.syncYjsChangesToLexical(C,n,e,t,R)}};o.initLocalState(n,l,d,document.activeElement===e.getRootElement(),E||{});const y=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,C),m(o),u.set(t,o),O.current=!0};n.on("reload",y),n.on("status",i),n.on("sync",g),a.on("update",D),r.getSharedType().observeDeep(T);const S=e.registerUpdateListener((({prevEditorState:e,editorState:t,dirtyLeaves:r,dirtyElements:a,normalizedNodes:c,tags:i})=>{!1===i.has(s.SKIP_COLLAB_TAG)&&o.syncLexicalUpdateToYjs(C,n,e,t,a,r,c,i)})),A=M();return()=>{!1===O.current&&(A?A.then(_):_()),n.off("sync",g),n.off("status",i),n.off("reload",y),a.off("update",D),r.getSharedType().unobserveDeep(T),u.delete(t),S()}}),[C,d,M,_,u,e,t,p,l,n,f,E,m,R]);const D=r.useMemo((()=>a.createPortal(i.jsx("div",{ref:e=>{C.cursorsContainer=e}}),g&&g.current||document.body)),[C,g]);return r.useEffect((()=>e.registerCommand(o.TOGGLE_CONNECT_COMMAND,(e=>(e?(console.log("Collaboration connected!"),M()):(console.log("Collaboration disconnected!"),_()),!0)),s.COMMAND_PRIORITY_EDITOR)),[M,_,e]),D}function f(e,t){const a=r.useMemo((()=>o.createUndoManager(t,t.root.getSharedType())),[t]);r.useEffect((()=>n.mergeRegister(e.registerCommand(s.UNDO_COMMAND,(()=>(a.undo(),!0)),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.REDO_COMMAND,(()=>(a.redo(),!0)),s.COMMAND_PRIORITY_EDITOR))));const c=r.useCallback((()=>{a.clear()}),[a]);return l.useEffect((()=>{const t=()=>{e.dispatchCommand(s.CAN_UNDO_COMMAND,a.undoStack.length>0),e.dispatchCommand(s.CAN_REDO_COMMAND,a.redoStack.length>0)};return a.on("stack-item-added",t),a.on("stack-item-popped",t),a.on("stack-cleared",t),()=>{a.off("stack-item-added",t),a.off("stack-item-popped",t),a.off("stack-cleared",t)}}),[e,a]),c}function C({editor:e,id:t,provider:a,yjsDocMap:c,name:i,color:u,shouldBootstrap:l,cursorsContainerRef:C,initialEditorState:m,awarenessData:g,collabContext:p,binding:E,setDoc:R,syncCursorPositionsFn:O}){const M=d(e,t,a,c,i,u,l,E,R,C,m,g,O);return
|
|
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,u,l,d,f,C,m,g,p,E,R=o.syncCursorPositions){const O=r.useRef(!1),M=r.useCallback((()=>n.connect()),[n]),_=r.useCallback((()=>{try{n.disconnect()}catch(e){}}),[n]);r.useEffect((()=>{const{root:r}=C,{awareness:a}=n,i=({status:t})=>{e.dispatchCommand(o.CONNECTED_COMMAND,"connected"===t)},g=t=>{f&&t&&r.isEmpty()&&0===r._xmlText._length&&!1===O.current&&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})}(e,p),O.current=!1},D=()=>{R(C,n)},T=(e,t)=>{const r=t.origin;if(r!==C){const t=r instanceof c.UndoManager;o.syncYjsChangesToLexical(C,n,e,t,R)}};o.initLocalState(n,l,d,document.activeElement===e.getRootElement(),E||{});const y=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,C),m(o),u.set(t,o),O.current=!0};n.on("reload",y),n.on("status",i),n.on("sync",g),a.on("update",D),r.getSharedType().observeDeep(T);const S=e.registerUpdateListener((({prevEditorState:e,editorState:t,dirtyLeaves:r,dirtyElements:a,normalizedNodes:c,tags:i})=>{!1===i.has(s.SKIP_COLLAB_TAG)&&o.syncLexicalUpdateToYjs(C,n,e,t,a,r,c,i)})),A=M();return()=>{!1===O.current&&(A?A.then(_):_()),n.off("sync",g),n.off("status",i),n.off("reload",y),a.off("update",D),r.getSharedType().unobserveDeep(T),u.delete(t),S()}}),[C,d,M,_,u,e,t,p,l,n,f,E,m,R]);const D=r.useMemo((()=>a.createPortal(i.jsx("div",{ref:e=>{C.cursorsContainer=e}}),g&&g.current||document.body)),[C,g]);return r.useEffect((()=>e.registerCommand(o.TOGGLE_CONNECT_COMMAND,(e=>(e?(console.log("Collaboration connected!"),M()):(console.log("Collaboration disconnected!"),_()),!0)),s.COMMAND_PRIORITY_EDITOR)),[M,_,e]),D}function f(e,t){const a=r.useMemo((()=>o.createUndoManager(t,t.root.getSharedType())),[t]);r.useEffect((()=>n.mergeRegister(e.registerCommand(s.UNDO_COMMAND,(()=>(a.undo(),!0)),s.COMMAND_PRIORITY_EDITOR),e.registerCommand(s.REDO_COMMAND,(()=>(a.redo(),!0)),s.COMMAND_PRIORITY_EDITOR))));const c=r.useCallback((()=>{a.clear()}),[a]);return l.useEffect((()=>{const t=()=>{e.dispatchCommand(s.CAN_UNDO_COMMAND,a.undoStack.length>0),e.dispatchCommand(s.CAN_REDO_COMMAND,a.redoStack.length>0)};return a.on("stack-item-added",t),a.on("stack-item-popped",t),a.on("stack-cleared",t),()=>{a.off("stack-item-added",t),a.off("stack-item-popped",t),a.off("stack-cleared",t)}}),[e,a]),c}function C({editor:e,id:t,provider:a,yjsDocMap:c,name:i,color:u,shouldBootstrap:l,cursorsContainerRef:C,initialEditorState:m,awarenessData:g,collabContext:p,binding:E,setDoc:R,syncCursorPositionsFn:O}){const M=d(e,t,a,c,i,u,l,E,R,C,m,g,O);return f(e,E),function(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])}(e,a,i,u,g),M}exports.CollaborationPlugin=function({id:n,providerFactory:s,shouldBootstrap:a,username:c,cursorColor:u,cursorsContainerRef:l,initialEditorState:d,excludedProperties:f,awarenessData:m,syncCursorPositionsFn:g}){const p=r.useRef(!1),E=r.useRef(!1),R=e.useCollaborationContext(c,u),{yjsDocMap:O,name:M,color:_}=R,[D]=t.useLexicalComposerContext();r.useEffect((()=>(R.isCollabActive=!0,()=>{null==D._parentEditor&&(R.isCollabActive=!1)})),[R,D]);const[T,y]=r.useState(),[S,A]=r.useState();r.useEffect((()=>{if(E.current)return;E.current=!0;const e=s(n,O);return y(e),A(O.get(n)),()=>{e.disconnect()}}),[n,s,O]);const[x,N]=r.useState();return r.useEffect((()=>{if(!T)return;if(p.current)return;p.current=!0;const e=o.createBinding(D,T,n,S||O.get(n),O,f);return N(e),()=>{e.root.destroy(e)}}),[D,T,n,O,S,f]),T&&x?i.jsx(C,{awarenessData:m,binding:x,collabContext:R,color:_,cursorsContainerRef:l,editor:D,id:n,initialEditorState:d,name:M,provider:T,setDoc:A,shouldBootstrap:a,yjsDocMap:O,syncCursorPositionsFn:g}):i.jsx(i.Fragment,{})};
|
|
@@ -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{initLocalState as o,syncLexicalUpdateToYjs as r,TOGGLE_CONNECT_COMMAND as n,syncCursorPositions as s,setLocalStateFocus as c,createUndoManager as a,CONNECTED_COMMAND as i,syncYjsChangesToLexical as l,createBinding as d}from"@lexical/yjs";import*as u from"react";import{useRef as m,useCallback as f,useEffect as p,useMemo as g,useState as C}from"react";import{mergeRegister as y}from"@lexical/utils";import{SKIP_COLLAB_TAG as h,COMMAND_PRIORITY_EDITOR as E,FOCUS_COMMAND as x,BLUR_COMMAND as b,UNDO_COMMAND as v,REDO_COMMAND as S,CAN_UNDO_COMMAND as
|
|
9
|
+
import{useCollaborationContext as t}from"@lexical/react/LexicalCollaborationContext";import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{initLocalState as o,syncLexicalUpdateToYjs as r,TOGGLE_CONNECT_COMMAND as n,syncCursorPositions as s,setLocalStateFocus as c,createUndoManager as a,CONNECTED_COMMAND as i,syncYjsChangesToLexical as l,createBinding as d}from"@lexical/yjs";import*as u from"react";import{useRef as m,useCallback as f,useEffect as p,useMemo as g,useState as C}from"react";import{mergeRegister as y}from"@lexical/utils";import{SKIP_COLLAB_TAG as h,COMMAND_PRIORITY_EDITOR as E,FOCUS_COMMAND as x,BLUR_COMMAND as b,UNDO_COMMAND as v,REDO_COMMAND as S,CAN_UNDO_COMMAND as k,CAN_REDO_COMMAND as D,$getRoot as j,HISTORY_MERGE_TAG as w,$createParagraphNode as R,$getSelection as F}from"lexical";import{createPortal as L}from"react-dom";import{UndoManager as P}from"yjs";import{jsx as T,Fragment as A}from"react/jsx-runtime";function B(t,e,c,a,d,u,C,y,x,b,v,S,k=s){const D=m(!1),A=f((()=>c.connect()),[c]),B=f((()=>{try{c.disconnect()}catch(t){}}),[c]);p((()=>{const{root:n}=y,{awareness:s}=c,m=({status:e})=>{t.dispatchCommand(i,"connected"===e)},f=e=>{C&&e&&n.isEmpty()&&0===n._xmlText._length&&!1===D.current&&function(t,e){t.update((()=>{const o=j();if(o.isEmpty())if(e)switch(typeof e){case"string":{const o=t.parseEditorState(e);t.setEditorState(o,{tag:w});break}case"object":t.setEditorState(e,{tag:w});break;case"function":t.update((()=>{j().isEmpty()&&e(t)}),{tag:w})}else{const e=R();o.append(e);const{activeElement:r}=document;(null!==F()||null!==r&&r===t.getRootElement())&&e.select()}}),{tag:w})}(t,v),D.current=!1},p=()=>{k(y,c)},g=(t,e)=>{const o=e.origin;if(o!==y){l(y,c,t,o instanceof P,k)}};o(c,d,u,document.activeElement===t.getRootElement(),S||{});const E=o=>{!function(t,e){if(t.update((()=>{const t=j();t.clear(),t.select()}),{tag:h}),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,y),x(o),a.set(e,o),D.current=!0};c.on("reload",E),c.on("status",m),c.on("sync",f),s.on("update",p),n.getSharedType().observeDeep(g);const b=t.registerUpdateListener((({prevEditorState:t,editorState:e,dirtyLeaves:o,dirtyElements:n,normalizedNodes:s,tags:a})=>{!1===a.has(h)&&r(y,c,t,e,n,o,s,a)})),L=A();return()=>{!1===D.current&&(L?L.then(B):B()),c.off("sync",f),c.off("status",m),c.off("reload",E),s.off("update",p),n.getSharedType().unobserveDeep(g),a.delete(e),b()}}),[y,u,A,B,a,t,e,v,d,c,C,S,x,k]);const M=g((()=>L(T("div",{ref:t=>{y.cursorsContainer=t}}),b&&b.current||document.body)),[y,b]);return p((()=>t.registerCommand(n,(t=>(t?(console.log("Collaboration connected!"),A()):(console.log("Collaboration disconnected!"),B()),!0)),E)),[A,B,t]),M}function M(t,e){const o=g((()=>a(e,e.root.getSharedType())),[e]);p((()=>y(t.registerCommand(v,(()=>(o.undo(),!0)),E),t.registerCommand(S,(()=>(o.redo(),!0)),E))));const r=f((()=>{o.clear()}),[o]);return u.useEffect((()=>{const e=()=>{t.dispatchCommand(k,o.undoStack.length>0),t.dispatchCommand(D,o.redoStack.length>0)};return o.on("stack-item-added",e),o.on("stack-item-popped",e),o.on("stack-cleared",e),()=>{o.off("stack-item-added",e),o.off("stack-item-popped",e),o.off("stack-cleared",e)}}),[t,o]),r}function _({id:o,providerFactory:r,shouldBootstrap:n,username:s,cursorColor:c,cursorsContainerRef:a,initialEditorState:i,excludedProperties:l,awarenessData:u,syncCursorPositionsFn:f}){const g=m(!1),y=m(!1),h=t(s,c),{yjsDocMap:E,name:x,color:b}=h,[v]=e();p((()=>(h.isCollabActive=!0,()=>{null==v._parentEditor&&(h.isCollabActive=!1)})),[h,v]);const[S,k]=C(),[D,j]=C();p((()=>{if(y.current)return;y.current=!0;const t=r(o,E);return k(t),j(E.get(o)),()=>{t.disconnect()}}),[o,r,E]);const[w,R]=C();return p((()=>{if(!S)return;if(g.current)return;g.current=!0;const t=d(v,S,o,D||E.get(o),E,l);return R(t),()=>{t.root.destroy(t)}}),[v,S,o,E,D,l]),S&&w?T(z,{awarenessData:u,binding:w,collabContext:h,color:b,cursorsContainerRef:a,editor:v,id:o,initialEditorState:i,name:x,provider:S,setDoc:j,shouldBootstrap:n,yjsDocMap:E,syncCursorPositionsFn:f}):T(A,{})}function z({editor:t,id:e,provider:o,yjsDocMap:r,name:n,color:s,shouldBootstrap:a,cursorsContainerRef:i,initialEditorState:l,awarenessData:d,collabContext:u,binding:m,setDoc:f,syncCursorPositionsFn:g}){const C=B(t,e,o,r,n,s,a,m,f,i,l,d,g);return M(t,m),function(t,e,o,r,n){p((()=>y(t.registerCommand(x,(()=>(c(e,o,r,!0,n||{}),!1)),E),t.registerCommand(b,(()=>(c(e,o,r,!1,n||{}),!1)),E))),[r,t,o,e,n])}(t,o,n,s,d),C}export{_ as CollaborationPlugin};
|
package/package.json
CHANGED
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.35.1-nightly.
|
|
11
|
+
"version": "0.35.1-nightly.20250919.0",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@floating-ui/react": "^0.27.8",
|
|
14
|
-
"@lexical/devtools-core": "0.35.1-nightly.
|
|
15
|
-
"@lexical/dragon": "0.35.1-nightly.
|
|
16
|
-
"@lexical/hashtag": "0.35.1-nightly.
|
|
17
|
-
"@lexical/history": "0.35.1-nightly.
|
|
18
|
-
"@lexical/link": "0.35.1-nightly.
|
|
19
|
-
"@lexical/list": "0.35.1-nightly.
|
|
20
|
-
"@lexical/mark": "0.35.1-nightly.
|
|
21
|
-
"@lexical/markdown": "0.35.1-nightly.
|
|
22
|
-
"@lexical/overflow": "0.35.1-nightly.
|
|
23
|
-
"@lexical/plain-text": "0.35.1-nightly.
|
|
24
|
-
"@lexical/rich-text": "0.35.1-nightly.
|
|
25
|
-
"@lexical/table": "0.35.1-nightly.
|
|
26
|
-
"@lexical/text": "0.35.1-nightly.
|
|
27
|
-
"@lexical/utils": "0.35.1-nightly.
|
|
28
|
-
"@lexical/yjs": "0.35.1-nightly.
|
|
29
|
-
"lexical": "0.35.1-nightly.
|
|
14
|
+
"@lexical/devtools-core": "0.35.1-nightly.20250919.0",
|
|
15
|
+
"@lexical/dragon": "0.35.1-nightly.20250919.0",
|
|
16
|
+
"@lexical/hashtag": "0.35.1-nightly.20250919.0",
|
|
17
|
+
"@lexical/history": "0.35.1-nightly.20250919.0",
|
|
18
|
+
"@lexical/link": "0.35.1-nightly.20250919.0",
|
|
19
|
+
"@lexical/list": "0.35.1-nightly.20250919.0",
|
|
20
|
+
"@lexical/mark": "0.35.1-nightly.20250919.0",
|
|
21
|
+
"@lexical/markdown": "0.35.1-nightly.20250919.0",
|
|
22
|
+
"@lexical/overflow": "0.35.1-nightly.20250919.0",
|
|
23
|
+
"@lexical/plain-text": "0.35.1-nightly.20250919.0",
|
|
24
|
+
"@lexical/rich-text": "0.35.1-nightly.20250919.0",
|
|
25
|
+
"@lexical/table": "0.35.1-nightly.20250919.0",
|
|
26
|
+
"@lexical/text": "0.35.1-nightly.20250919.0",
|
|
27
|
+
"@lexical/utils": "0.35.1-nightly.20250919.0",
|
|
28
|
+
"@lexical/yjs": "0.35.1-nightly.20250919.0",
|
|
29
|
+
"lexical": "0.35.1-nightly.20250919.0",
|
|
30
30
|
"react-error-boundary": "^3.1.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|