@lexical/yjs 0.1.13 → 0.1.14
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/LexicalYjs.dev.js +17 -8
- package/LexicalYjs.prod.js +2 -2
- package/package.json +2 -2
package/LexicalYjs.dev.js
CHANGED
|
@@ -1398,10 +1398,8 @@ function $createCollabElementNode(xmlText, parent, type) {
|
|
|
1398
1398
|
*
|
|
1399
1399
|
*
|
|
1400
1400
|
*/
|
|
1401
|
-
function createBinding(editor, provider, id, docMap) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (doc === undefined) {
|
|
1401
|
+
function createBinding(editor, provider, id, doc, docMap) {
|
|
1402
|
+
if (doc === undefined || doc === null) {
|
|
1405
1403
|
throw new Error('Should never happen');
|
|
1406
1404
|
} // $FlowFixMe: this will work
|
|
1407
1405
|
|
|
@@ -2469,13 +2467,24 @@ function initLocalState(provider, name, color, focusing) {
|
|
|
2469
2467
|
name
|
|
2470
2468
|
});
|
|
2471
2469
|
}
|
|
2472
|
-
function setLocalStateFocus(provider, focusing) {
|
|
2470
|
+
function setLocalStateFocus(provider, name, color, focusing) {
|
|
2473
2471
|
const {
|
|
2474
2472
|
awareness
|
|
2475
2473
|
} = provider;
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2474
|
+
let localState = awareness.getLocalState();
|
|
2475
|
+
|
|
2476
|
+
if (localState === null) {
|
|
2477
|
+
localState = {
|
|
2478
|
+
anchorPos: null,
|
|
2479
|
+
color,
|
|
2480
|
+
focusPos: null,
|
|
2481
|
+
focusing: focusing,
|
|
2482
|
+
name
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
localState.focusing = focusing;
|
|
2487
|
+
awareness.setLocalState(localState);
|
|
2479
2488
|
}
|
|
2480
2489
|
|
|
2481
2490
|
exports.createBinding = createBinding;
|
package/LexicalYjs.prod.js
CHANGED
|
@@ -59,8 +59,8 @@ function za(a,b,c,d,e,f){let g=null,h=null;const n=b.length;for(let w=0;w<n;w++)
|
|
|
59
59
|
p?u.__text.length:1,key:k,next:null,parent:r,prev:null,start:y,type:p?"text":"inline"},q.set(k,l),k=l}null===h?g=k:(k.prev=h,h.next=k);h=k}return g}function Ea(a,b=1,c){c=(c||a._pendingEditorState||a._editorState)._nodeMap;const d=c.get("root");a=new Map;c=za({offset:0,prevIsBlock:!1},d.__children,null,c,a,b);return new xa(a,c,b)}
|
|
60
60
|
function Fa(a,b){var {target:c}=b;const d=L(a,c),e=c._lexicalValue;if(void 0!==e&&d instanceof X)if(c instanceof m.Map)V(a,d,c,e,b.keysChanged);else{if(c instanceof m.Array&&v.isDecoratorArray(e)){b=b.delta;let g=0;for(let h=0;h<b.length;h++){var f=b[h];const n=f.retain,l=f.delete;f=f.insert;if(void 0!==n)g+=n;else if(void 0!==l)R(()=>{e._array.slice(g,g+l).forEach(k=>{(v.isDecoratorArray(k)||v.isDecoratorMap(k))&&k.destroy()});e.splice(g,l)});else if(void 0!==f)ja(a,d,c,e,g);else throw Error("Not supported");
|
|
61
61
|
}}}else if(d instanceof M&&b instanceof m.YTextEvent){const {keysChanged:g,childListChanged:h,delta:n}=b;0<g.size&&d.syncPropertiesFromYjs(a,g);h&&(d.applyChildrenYjsDelta(a,n),d.syncChildrenFromYjs(a))}else if(d instanceof D&&b instanceof m.YMapEvent)({keysChanged:c}=b),0<c.size&&d.syncPropertiesAndTextFromYjs(a,c);else if(d instanceof X&&b instanceof m.YXmlEvent)({attributesChanged:c}=b),0<c.size&&d.syncPropertiesFromYjs(a,c);else throw Error("Should never happen");}
|
|
62
|
-
exports.createBinding=function(a,b,c,d){
|
|
63
|
-
exports.initLocalState=function(a,b,c,d){a.awareness.setLocalState({anchorPos:null,color:c,focusPos:null,focusing:d,name:b})};exports.setLocalStateFocus=function(a,b){({awareness:a}=a);a.
|
|
62
|
+
exports.createBinding=function(a,b,c,d,e){if(void 0===d||null===d)throw Error("Should never happen");b=d.get("root",m.XmlText);b=K(b,null,"root");b._key="root";return{clientID:d.clientID,collabNodeMap:new Map,cursors:new Map,cursorsContainer:null,doc:d,docMap:e,editor:a,id:c,nodeProperties:new Map,root:b}};exports.createUndoManager=function(a,b){return new m.UndoManager(b,{trackedOrigins:new Set([a,null])})};
|
|
63
|
+
exports.initLocalState=function(a,b,c,d){a.awareness.setLocalState({anchorPos:null,color:c,focusPos:null,focusing:d,name:b})};exports.setLocalStateFocus=function(a,b,c,d){({awareness:a}=a);let e=a.getLocalState();null===e&&(e={anchorPos:null,color:c,focusPos:null,focusing:d,name:b});e.focusing=d;a.setLocalState(e)};exports.syncCursorPositions=va;
|
|
64
64
|
exports.syncLexicalUpdateToYjs=function(a,b,c,d,e,f,g,h){P(a,()=>{d.read(()=>{if(h.has("collaboration")){if(0<g.size){var n=Array.from(g),l=a.collabNodeMap,k=[];for(let p=0;p<n.length;p++){var r=n[p],t=v.$getNodeByKey(r),q=l.get(r);if(q instanceof D)if(v.$isTextNode(t))k.push([q,t.__text]);else{t=q.getOffset();if(-1===t)continue;const u=q._parent;q._normalized=!0;u._xmlText.delete(t,1);l.delete(r);r=u._children;q=r.indexOf(q);r.splice(q,1)}}for(n=0;n<k.length;n++){const [p,u]=k[n];p._text=u}}}else e.has("root")&&
|
|
65
65
|
(k=c._nodeMap,n=v.$getRoot(),l=a.root,l.syncPropertiesFromLexical(a,n,k),l.syncChildrenFromLexical(a,n,k,e,f)),k=v.$getSelection(),wa(a,b,c._selection,k)})})};
|
|
66
66
|
exports.syncYjsChangesToLexical=function(a,b,c){const d=a.editor,e=d._editorState;d.update(()=>{var f=d._pendingEditorState;for(var g=0;g<c.length;g++)Fa(a,c[g]);var h=v.$getSelection();if(v.$isRangeSelection(h))if(ca(h)){g=e._selection;if(v.$isRangeSelection(g)){const n=Ea(d,0,e);f=Ea(d,0,f);const [l,k]=n.getOffsetsFromSelection(g);f=f.createSelectionFromOffsets(l,k,n);null!==f?v.$setSelection(f):(qa(a,b),ca(h)&&(h=v.$getRoot(),0===h.getChildrenSize()&&h.append(v.$createParagraphNode()),v.$getRoot().selectEnd()))}wa(a,
|
package/package.json
CHANGED