lexical 0.11.2 → 0.11.3

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/Lexical.dev.js CHANGED
@@ -9372,7 +9372,7 @@ function commitPendingUpdates(editor, recoveryEditorState) {
9372
9372
  }
9373
9373
 
9374
9374
  if (mutatedNodes !== null) {
9375
- triggerMutationListeners(editor, mutatedNodes, tags, dirtyLeaves);
9375
+ triggerMutationListeners(editor, mutatedNodes, tags, dirtyLeaves, currentEditorState);
9376
9376
  }
9377
9377
 
9378
9378
  if (!$isRangeSelection(pendingSelection) && pendingSelection !== null && (currentSelection === null || !currentSelection.is(pendingSelection))) {
@@ -9418,7 +9418,7 @@ function triggerTextContentListeners(editor, currentEditorState, pendingEditorSt
9418
9418
  }
9419
9419
  }
9420
9420
 
9421
- function triggerMutationListeners(editor, mutatedNodes, updateTags, dirtyLeaves) {
9421
+ function triggerMutationListeners(editor, mutatedNodes, updateTags, dirtyLeaves, prevEditorState) {
9422
9422
  const listeners = Array.from(editor._listeners.mutation);
9423
9423
  const listenersLength = listeners.length;
9424
9424
 
@@ -9429,6 +9429,7 @@ function triggerMutationListeners(editor, mutatedNodes, updateTags, dirtyLeaves)
9429
9429
  if (mutatedNodesByType !== undefined) {
9430
9430
  listener(mutatedNodesByType, {
9431
9431
  dirtyLeaves,
9432
+ prevEditorState,
9432
9433
  updateTags
9433
9434
  });
9434
9435
  }
package/Lexical.js.flow CHANGED
@@ -81,14 +81,18 @@ type DecoratorListener = (decorator: {
81
81
  [NodeKey]: any,
82
82
  }) => void;
83
83
  type RootListener = (
84
- element: null | HTMLElement,
85
- element: null | HTMLElement,
84
+ rootElement: null | HTMLElement,
85
+ prevRootElement: null | HTMLElement,
86
86
  ) => void;
87
87
  type TextContentListener = (text: string) => void;
88
88
  type ErrorHandler = (error: Error) => void;
89
89
  export type MutationListener = (
90
90
  nodes: Map<NodeKey, NodeMutation>,
91
- {updateTags: Set<string>, dirtyLeaves: Set<string>},
91
+ {
92
+ updateTags: Set<string>,
93
+ dirtyLeaves: Set<string>,
94
+ prevEditorState: EditorState,
95
+ },
92
96
  ) => void;
93
97
  export type EditableListener = (editable: boolean) => void;
94
98
  type Listeners = {
@@ -477,6 +481,7 @@ declare export class RangeSelection implements BaseSelection {
477
481
  applyDOMRange(range: StaticRange): void;
478
482
  clone(): RangeSelection;
479
483
  toggleFormat(format: TextFormatType): void;
484
+ setStyle(style: string): void;
480
485
  hasFormat(type: TextFormatType): boolean;
481
486
  insertText(text: string): void;
482
487
  insertRawText(text: string): void;
package/Lexical.prod.js CHANGED
@@ -167,9 +167,10 @@ V!==d||null!==V&&Jb(V)))if(C(h)){var mb=h.anchor,Uc=h.focus,Ce=mb.key,Cf=Uc.key,
167
167
  Fe&&P===nb&&Q===Qb&&("Range"!==ja.type||!Ge)&&(null!==V&&d.contains(V)||d.focus({preventScroll:!0}),"element"!==mb.type))break a;try{ja.setBaseAndExtent(nb,Pb,Qb,Fe)}catch(W){}if(!la.has("skip-scroll-into-view")&&h.isCollapsed()&&null!==d&&d===document.activeElement){let W=h instanceof Le&&"element"===h.anchor.type?nb.childNodes[Pb]||null:0<ja.rangeCount?ja.getRangeAt(0):null;if(null!==W){let X;if(W instanceof Text){let U=document.createRange();U.selectNode(W);X=U.getBoundingClientRect()}else X=W.getBoundingClientRect();
168
168
  let wa=d.ownerDocument,Da=wa.defaultView;if(null!==Da)for(var {top:Yc,bottom:Zc}=X,Rb,Sb,oa=d;null!==oa;){let U=oa===wa.body;if(U)Rb=0,Sb=Bb(a).innerHeight;else{let Tb=oa.getBoundingClientRect();Rb=Tb.top;Sb=Tb.bottom}let Ea=0;Yc<Rb?Ea=-(Rb-Yc):Zc>Sb&&(Ea=Zc-Sb);if(0!==Ea)if(U)Da.scrollBy(0,Ea);else{let Tb=oa.scrollTop;oa.scrollTop+=Ea;let He=oa.scrollTop-Tb;Yc-=He;Zc-=He}if(U)break;oa=Mb(oa)}}}Gd=!0}}else null!==g&&Kb(a,P,Q)&&ja.removeAllRanges()}}a:{let E=a._blockCursorElement;if(C(h)&&h.isCollapsed()&&
169
169
  "element"===h.anchor.type&&d.contains(document.activeElement)){let P=h.anchor,Q=P.getNode(),ia=P.offset,lb=Q.getChildrenSize(),V=!1,W=null;if(ia===lb){let X=Q.getChildAtIndex(ia-1);Bc(X)&&(V=!0)}else{let X=Q.getChildAtIndex(ia);if(Bc(X)){let wa=X.getPreviousSibling();if(null===wa||Bc(wa))V=!0,W=a.getElementByKey(X.__key)}}if(V){let X=a.getElementByKey(Q.__key);if(null===E){let wa=a._config.theme,Da=document.createElement("div");Da.contentEditable="false";Da.setAttribute("data-lexical-cursor","true");
170
- let U=wa.blockCursor;if(void 0!==U){if("string"===typeof U){let Ea=U.split(" ");U=wa.blockCursor=Ea}void 0!==U&&Da.classList.add(...U)}a._blockCursorElement=E=Da}d.style.caretColor="transparent";null===W?X.appendChild(E):X.insertBefore(E,W);break a}}null!==E&&Cc(E,a,d)}null!==r&&r.observe(d,ef)}finally{T=p,S=n}}if(null!==u){var Ef=u;let E=Array.from(a._listeners.mutation),P=E.length;for(let Q=0;Q<P;Q++){let [ia,lb]=E[Q],V=Ef.get(lb);void 0!==V&&ia(V,{dirtyLeaves:Y,updateTags:la})}}C(h)||null===h||
171
- null!==g&&g.is(h)||a.dispatchCommand(aa,void 0);var $c=a._pendingDecorators;null!==$c&&(a._decorators=$c,a._pendingDecorators=null,nf("decorator",a,!0,$c));var Ff=fc(b||f),Ie=fc(c);Ff!==Ie&&nf("textcontent",a,!0,Ie);nf("update",a,!0,{dirtyElements:ba,dirtyLeaves:Y,editorState:c,normalizedNodes:Va,prevEditorState:b||f,tags:la});a._deferred=[];if(0!==Sc.length){let E=a._updating;a._updating=!0;try{for(let P=0;P<Sc.length;P++)Sc[P]()}finally{a._updating=E}}var Je=a._updates;if(0!==Je.length){let E=Je.shift();
172
- if(E){let [P,Q]=E;of(a,P,Q)}}}}function nf(a,b,c,...d){let e=b._updating;b._updating=c;try{let f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a].apply(null,d)}finally{b._updating=e}}function R(a,b,c){if(!1===a._updating||T!==a){let f=!1;a.update(()=>{f=R(a,b,c)});return f}let d=kc(a);for(let f=4;0<=f;f--)for(let g=0;g<d.length;g++){var e=d[g]._commands.get(b);if(void 0!==e&&(e=e[f],void 0!==e)){e=Array.from(e);let h=e.length;for(let k=0;k<h;k++)if(!0===e[k](c,a))return!0}}return!1}
170
+ let U=wa.blockCursor;if(void 0!==U){if("string"===typeof U){let Ea=U.split(" ");U=wa.blockCursor=Ea}void 0!==U&&Da.classList.add(...U)}a._blockCursorElement=E=Da}d.style.caretColor="transparent";null===W?X.appendChild(E):X.insertBefore(E,W);break a}}null!==E&&Cc(E,a,d)}null!==r&&r.observe(d,ef)}finally{T=p,S=n}}if(null!==u){var Ef=u;let E=Array.from(a._listeners.mutation),P=E.length;for(let Q=0;Q<P;Q++){let [ia,lb]=E[Q],V=Ef.get(lb);void 0!==V&&ia(V,{dirtyLeaves:Y,prevEditorState:f,updateTags:la})}}C(h)||
171
+ null===h||null!==g&&g.is(h)||a.dispatchCommand(aa,void 0);var $c=a._pendingDecorators;null!==$c&&(a._decorators=$c,a._pendingDecorators=null,nf("decorator",a,!0,$c));var Ff=fc(b||f),Ie=fc(c);Ff!==Ie&&nf("textcontent",a,!0,Ie);nf("update",a,!0,{dirtyElements:ba,dirtyLeaves:Y,editorState:c,normalizedNodes:Va,prevEditorState:b||f,tags:la});a._deferred=[];if(0!==Sc.length){let E=a._updating;a._updating=!0;try{for(let P=0;P<Sc.length;P++)Sc[P]()}finally{a._updating=E}}var Je=a._updates;if(0!==Je.length){let E=
172
+ Je.shift();if(E){let [P,Q]=E;of(a,P,Q)}}}}function nf(a,b,c,...d){let e=b._updating;b._updating=c;try{let f=Array.from(b._listeners[a]);for(a=0;a<f.length;a++)f[a].apply(null,d)}finally{b._updating=e}}
173
+ function R(a,b,c){if(!1===a._updating||T!==a){let f=!1;a.update(()=>{f=R(a,b,c)});return f}let d=kc(a);for(let f=4;0<=f;f--)for(let g=0;g<d.length;g++){var e=d[g]._commands.get(b);if(void 0!==e&&(e=e[f],void 0!==e)){e=Array.from(e);let h=e.length;for(let k=0;k<h;k++)if(!0===e[k](c,a))return!0}}return!1}
173
174
  function pf(a,b){let c=a._updates;for(b=b||!1;0!==c.length;){var d=c.shift();if(d){let [e,f]=d,g;void 0!==f&&(d=f.onUpdate,g=f.tag,f.skipTransforms&&(b=!0),d&&a._deferred.push(d),g&&a._updateTags.add(g));e()}}return b}
174
175
  function of(a,b,c){let d=a._updateTags;var e,f=e=!1;if(void 0!==c){var g=c.onUpdate;e=c.tag;null!=e&&d.add(e);e=c.skipTransforms||!1;f=c.discrete||!1}g&&a._deferred.push(g);c=a._editorState;g=a._pendingEditorState;let h=!1;if(null===g||g._readOnly)g=a._pendingEditorState=new qf(new Map((g||c)._nodeMap)),h=!0;g._flushSync=f;f=S;let k=Z,n=T,m=a._updating;S=g;Z=!1;a._updating=!0;T=a;try{h&&(a._headless?null!=c._selection&&(g._selection=c._selection.clone()):g._selection=af(a));let p=a._compositionKey;
175
176
  b();e=pf(a,e);cf(g,a);0!==a._dirtyType&&(e?gf(g,a):hf(g,a),pf(a),Hc(c,g,a._dirtyLeaves,a._dirtyElements));p!==a._compositionKey&&(g._flushSync=!0);let l=g._selection;if(C(l)){let r=g._nodeMap,u=l.focus.key;void 0!==r.get(l.anchor.key)&&void 0!==r.get(u)||q(19)}else Sd(l)&&0===l._nodes.size&&(g._selection=null)}catch(p){p instanceof Error&&a._onError(p);a._pendingEditorState=c;a._dirtyType=2;a._cloneNotNeeded.clear();a._dirtyLeaves=new Set;a._dirtyElements.clear();lf(a);return}finally{S=f,Z=k,T=n,
@@ -143,6 +143,7 @@ export type TextContentListener = (text: string) => void;
143
143
  export type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: {
144
144
  updateTags: Set<string>;
145
145
  dirtyLeaves: Set<string>;
146
+ prevEditorState: EditorState;
146
147
  }) => void;
147
148
  export type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
148
149
  export type EditableListener = (editable: boolean) => void;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.11.2",
12
+ "version": "0.11.3",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",