@lexical/history 0.14.4 → 0.15.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.
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict';
8
10
 
9
11
  var utils = require('@lexical/utils');
@@ -16,6 +18,7 @@ var lexical = require('lexical');
16
18
  * LICENSE file in the root directory of this source tree.
17
19
  *
18
20
  */
21
+
19
22
  const HISTORY_MERGE = 0;
20
23
  const HISTORY_PUSH = 1;
21
24
  const DISCARD_HISTORY_CANDIDATE = 2;
@@ -262,7 +265,7 @@ function registerHistory(editor, historyState, delay) {
262
265
  editorState
263
266
  };
264
267
  };
265
- const unregisterCommandListener = utils.mergeRegister(editor.registerCommand(lexical.UNDO_COMMAND, () => {
268
+ const unregister = utils.mergeRegister(editor.registerCommand(lexical.UNDO_COMMAND, () => {
266
269
  undo(editor, historyState);
267
270
  return true;
268
271
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REDO_COMMAND, () => {
@@ -277,11 +280,7 @@ function registerHistory(editor, historyState, delay) {
277
280
  editor.dispatchCommand(lexical.CAN_UNDO_COMMAND, false);
278
281
  return true;
279
282
  }, lexical.COMMAND_PRIORITY_EDITOR), editor.registerUpdateListener(applyChange));
280
- const unregisterUpdateListener = editor.registerUpdateListener(applyChange);
281
- return () => {
282
- unregisterCommandListener();
283
- unregisterUpdateListener();
284
- };
283
+ return unregister;
285
284
  }
286
285
 
287
286
  /**
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import { mergeRegister } from '@lexical/utils';
8
10
  import { UNDO_COMMAND, COMMAND_PRIORITY_EDITOR, REDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, $isRangeSelection, $isTextNode, $isRootNode } from 'lexical';
9
11
 
@@ -14,6 +16,7 @@ import { UNDO_COMMAND, COMMAND_PRIORITY_EDITOR, REDO_COMMAND, CLEAR_EDITOR_COMMA
14
16
  * LICENSE file in the root directory of this source tree.
15
17
  *
16
18
  */
19
+
17
20
  const HISTORY_MERGE = 0;
18
21
  const HISTORY_PUSH = 1;
19
22
  const DISCARD_HISTORY_CANDIDATE = 2;
@@ -260,7 +263,7 @@ function registerHistory(editor, historyState, delay) {
260
263
  editorState
261
264
  };
262
265
  };
263
- const unregisterCommandListener = mergeRegister(editor.registerCommand(UNDO_COMMAND, () => {
266
+ const unregister = mergeRegister(editor.registerCommand(UNDO_COMMAND, () => {
264
267
  undo(editor, historyState);
265
268
  return true;
266
269
  }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(REDO_COMMAND, () => {
@@ -275,11 +278,7 @@ function registerHistory(editor, historyState, delay) {
275
278
  editor.dispatchCommand(CAN_UNDO_COMMAND, false);
276
279
  return true;
277
280
  }, COMMAND_PRIORITY_EDITOR), editor.registerUpdateListener(applyChange));
278
- const unregisterUpdateListener = editor.registerUpdateListener(applyChange);
279
- return () => {
280
- unregisterCommandListener();
281
- unregisterUpdateListener();
282
- };
281
+ return unregister;
283
282
  }
284
283
 
285
284
  /**
package/LexicalHistory.js CHANGED
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  'use strict'
8
10
  const LexicalHistory = process.env.NODE_ENV === 'development' ? require('./LexicalHistory.dev.js') : require('./LexicalHistory.prod.js');
9
11
  module.exports = LexicalHistory;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  import * as modDev from './LexicalHistory.dev.mjs';
8
10
  import * as modProd from './LexicalHistory.prod.mjs';
9
11
  const mod = process.env.NODE_ENV === 'development' ? modDev : modProd;
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
8
+
7
9
  const mod = await (process.env.NODE_ENV === 'development' ? import('./LexicalHistory.dev.mjs') : import('./LexicalHistory.prod.mjs'));
8
10
  export const createEmptyHistoryState = mod.createEmptyHistoryState;
9
11
  export const registerHistory = mod.registerHistory;
@@ -3,13 +3,14 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- 'use strict';var c=require("@lexical/utils"),x=require("lexical");
8
- function y(b,a,l,h,n){if(null===b||0===l.size&&0===h.size&&!n)return 0;var f=a._selection,d=b._selection;if(n)return 1;if(!(x.$isRangeSelection(f)&&x.$isRangeSelection(d)&&d.isCollapsed()&&f.isCollapsed()))return 0;n=a._nodeMap;let e=[];for(let m of l)l=n.get(m),void 0!==l&&e.push(l);for(let [m,p]of h)p&&(h=n.get(m),void 0===h||x.$isRootNode(h)||e.push(h));if(0===e.length)return 0;if(1<e.length)return h=a._nodeMap,a=h.get(f.anchor.key),d=h.get(d.anchor.key),a&&d&&!b._nodeMap.has(a.__key)&&x.$isTextNode(a)&&
9
- 1===a.__text.length&&1===f.anchor.offset?2:0;a=e[0];b=b._nodeMap.get(a.__key);if(!x.$isTextNode(b)||!x.$isTextNode(a)||b.__mode!==a.__mode)return 0;b=b.__text;a=a.__text;if(b===a)return 0;f=f.anchor;d=d.anchor;if(f.key!==d.key||"text"!==f.type)return 0;f=f.offset;d=d.offset;b=a.length-b.length;return 1===b&&d===f-1?2:-1===b&&d===f+1?3:-1===b&&d===f?4:0}
10
- function z(b,a){let l=Date.now(),h=0;return(n,f,d,e,m,p)=>{let r=Date.now();if(p.has("historic"))return h=0,l=r,2;let q=y(n,f,e,m,b.isComposing()),v=(()=>{var k=null===d||d.editor===b,g=p.has("history-push");if(!g&&k&&p.has("history-merge"))return 0;if(null===n)return 1;var t=f._selection;if(!(0<e.size||0<m.size))return null!==t?0:2;if(!1===g&&0!==q&&q===h&&r<l+a&&k)return 0;if(1===e.size){{g=Array.from(e)[0];k=n._nodeMap.get(g);g=f._nodeMap.get(g);t=n._selection;let u=f._selection,w=!1;x.$isRangeSelection(t)&&
11
- x.$isRangeSelection(u)&&(w="element"===t.anchor.type&&"element"===t.focus.type&&"text"===u.anchor.type&&"text"===u.focus.type);k=!w&&x.$isTextNode(k)&&x.$isTextNode(g)?k.__type===g.__type&&k.__text===g.__text&&k.__mode===g.__mode&&k.__detail===g.__detail&&k.__style===g.__style&&k.__format===g.__format&&k.__parent===g.__parent:!1}if(k)return 0}return 1})();l=r;h=q;return v}}exports.createEmptyHistoryState=function(){return{current:null,redoStack:[],undoStack:[]}};
12
- exports.registerHistory=function(b,a,l){let h=z(b,l);l=({editorState:d,prevEditorState:e,dirtyLeaves:m,dirtyElements:p,tags:r})=>{const q=a.current,v=a.redoStack,k=a.undoStack,g=null===q?null:q.editorState;if(null===q||d!==g){e=h(e,d,q,m,p,r);if(1===e)0!==v.length&&(a.redoStack=[],b.dispatchCommand(x.CAN_REDO_COMMAND,!1)),null!==q&&(k.push({...q}),b.dispatchCommand(x.CAN_UNDO_COMMAND,!0));else if(2===e)return;a.current={editor:b,editorState:d}}};let n=c.mergeRegister(b.registerCommand(x.UNDO_COMMAND,
13
- ()=>{let d=a.redoStack,e=a.undoStack;if(0!==e.length){let m=a.current,p=e.pop();null!==m&&(d.push(m),b.dispatchCommand(x.CAN_REDO_COMMAND,!0));0===e.length&&b.dispatchCommand(x.CAN_UNDO_COMMAND,!1);a.current=p||null;p&&p.editor.setEditorState(p.editorState,{tag:"historic"})}return!0},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.REDO_COMMAND,()=>{let d=a.redoStack;var e=a.undoStack;if(0!==d.length){let m=a.current;null!==m&&(e.push(m),b.dispatchCommand(x.CAN_UNDO_COMMAND,!0));e=d.pop();0===d.length&&
14
- b.dispatchCommand(x.CAN_REDO_COMMAND,!1);a.current=e||null;e&&e.editor.setEditorState(e.editorState,{tag:"historic"})}return!0},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.CLEAR_EDITOR_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!1},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.CLEAR_HISTORY_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;b.dispatchCommand(x.CAN_REDO_COMMAND,!1);b.dispatchCommand(x.CAN_UNDO_COMMAND,!1);return!0},x.COMMAND_PRIORITY_EDITOR),b.registerUpdateListener(l)),
15
- f=b.registerUpdateListener(l);return()=>{n();f()}}
8
+
9
+ 'use strict';var d=require("@lexical/utils"),x=require("lexical");
10
+ function y(b,a,n,h,f){if(null===b||0===n.size&&0===h.size&&!f)return 0;var c=a._selection,e=b._selection;if(f)return 1;if(!(x.$isRangeSelection(c)&&x.$isRangeSelection(e)&&e.isCollapsed()&&c.isCollapsed()))return 0;f=a._nodeMap;let g=[];for(let p of n)n=f.get(p),void 0!==n&&g.push(n);for(let [p,m]of h)m&&(h=f.get(p),void 0===h||x.$isRootNode(h)||g.push(h));if(0===g.length)return 0;if(1<g.length)return h=a._nodeMap,a=h.get(c.anchor.key),e=h.get(e.anchor.key),a&&e&&!b._nodeMap.has(a.__key)&&x.$isTextNode(a)&&
11
+ 1===a.__text.length&&1===c.anchor.offset?2:0;a=g[0];b=b._nodeMap.get(a.__key);if(!x.$isTextNode(b)||!x.$isTextNode(a)||b.__mode!==a.__mode)return 0;b=b.__text;a=a.__text;if(b===a)return 0;c=c.anchor;e=e.anchor;if(c.key!==e.key||"text"!==c.type)return 0;c=c.offset;e=e.offset;b=a.length-b.length;return 1===b&&e===c-1?2:-1===b&&e===c+1?3:-1===b&&e===c?4:0}
12
+ function z(b,a){let n=Date.now(),h=0;return(f,c,e,g,p,m)=>{let q=Date.now();if(m.has("historic"))return h=0,n=q,2;let r=y(f,c,g,p,b.isComposing()),v=(()=>{var l=null===e||e.editor===b,k=m.has("history-push");if(!k&&l&&m.has("history-merge"))return 0;if(null===f)return 1;var t=c._selection;if(!(0<g.size||0<p.size))return null!==t?0:2;if(!1===k&&0!==r&&r===h&&q<n+a&&l)return 0;if(1===g.size){{k=Array.from(g)[0];l=f._nodeMap.get(k);k=c._nodeMap.get(k);t=f._selection;let u=c._selection,w=!1;x.$isRangeSelection(t)&&
13
+ x.$isRangeSelection(u)&&(w="element"===t.anchor.type&&"element"===t.focus.type&&"text"===u.anchor.type&&"text"===u.focus.type);l=!w&&x.$isTextNode(l)&&x.$isTextNode(k)?l.__type===k.__type&&l.__text===k.__text&&l.__mode===k.__mode&&l.__detail===k.__detail&&l.__style===k.__style&&l.__format===k.__format&&l.__parent===k.__parent:!1}if(l)return 0}return 1})();n=q;h=r;return v}}exports.createEmptyHistoryState=function(){return{current:null,redoStack:[],undoStack:[]}};
14
+ exports.registerHistory=function(b,a,n){let h=z(b,n);return d.mergeRegister(b.registerCommand(x.UNDO_COMMAND,()=>{let f=a.redoStack,c=a.undoStack;if(0!==c.length){let e=a.current,g=c.pop();null!==e&&(f.push(e),b.dispatchCommand(x.CAN_REDO_COMMAND,!0));0===c.length&&b.dispatchCommand(x.CAN_UNDO_COMMAND,!1);a.current=g||null;g&&g.editor.setEditorState(g.editorState,{tag:"historic"})}return!0},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.REDO_COMMAND,()=>{let f=a.redoStack;var c=a.undoStack;if(0!==
15
+ f.length){let e=a.current;null!==e&&(c.push(e),b.dispatchCommand(x.CAN_UNDO_COMMAND,!0));c=f.pop();0===f.length&&b.dispatchCommand(x.CAN_REDO_COMMAND,!1);a.current=c||null;c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}return!0},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.CLEAR_EDITOR_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!1},x.COMMAND_PRIORITY_EDITOR),b.registerCommand(x.CLEAR_HISTORY_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;b.dispatchCommand(x.CAN_REDO_COMMAND,
16
+ !1);b.dispatchCommand(x.CAN_UNDO_COMMAND,!1);return!0},x.COMMAND_PRIORITY_EDITOR),b.registerUpdateListener(({editorState:f,prevEditorState:c,dirtyLeaves:e,dirtyElements:g,tags:p})=>{const m=a.current,q=a.redoStack,r=a.undoStack,v=null===m?null:m.editorState;if(null===m||f!==v){c=h(c,f,m,e,g,p);if(1===c)0!==q.length&&(a.redoStack=[],b.dispatchCommand(x.CAN_REDO_COMMAND,!1)),null!==m&&(r.push({...m}),b.dispatchCommand(x.CAN_UNDO_COMMAND,!0));else if(2===c)return;a.current={editor:b,editorState:f}}}))}
@@ -3,5 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  */
7
- import{mergeRegister as t}from"@lexical/utils";import{UNDO_COMMAND as e,COMMAND_PRIORITY_EDITOR as n,REDO_COMMAND as r,CLEAR_EDITOR_COMMAND as o,CLEAR_HISTORY_COMMAND as i,CAN_REDO_COMMAND as s,CAN_UNDO_COMMAND as c,$isRangeSelection as a,$isTextNode as u,$isRootNode as d}from"lexical";const l=0,_=1,f=2,p=0,h=1,m=2,g=3,y=4;function S(t,e,n,r,o){if(null===t||0===n.size&&0===r.size&&!o)return p;const i=e._selection,s=t._selection;if(o)return h;if(!(a(i)&&a(s)&&s.isCollapsed()&&i.isCollapsed()))return p;const c=function(t,e,n){const r=t._nodeMap,o=[];for(const t of e){const e=r.get(t);void 0!==e&&o.push(e)}for(const[t,e]of n){if(!e)continue;const n=r.get(t);void 0===n||d(n)||o.push(n)}return o}(e,n,r);if(0===c.length)return p;if(c.length>1){const n=e._nodeMap,r=n.get(i.anchor.key),o=n.get(s.anchor.key);return r&&o&&!t._nodeMap.has(r.__key)&&u(r)&&1===r.__text.length&&1===i.anchor.offset?m:p}const l=c[0],_=t._nodeMap.get(l.__key);if(!u(_)||!u(l)||_.__mode!==l.__mode)return p;const f=_.__text,S=l.__text;if(f===S)return p;const k=i.anchor,C=s.anchor;if(k.key!==C.key||"text"!==k.type)return p;const x=k.offset,M=C.offset,z=S.length-f.length;return 1===z&&M===x-1?m:-1===z&&M===x+1?g:-1===z&&M===x?y:p}function k(t,e){let n=Date.now(),r=p;return(o,i,s,c,d,h)=>{const m=Date.now();if(h.has("historic"))return r=p,n=m,f;const g=S(o,i,c,d,t.isComposing()),y=(()=>{const y=null===s||s.editor===t,S=h.has("history-push");if(!S&&y&&h.has("history-merge"))return l;if(null===o)return _;const k=i._selection;if(!(c.size>0||d.size>0))return null!==k?l:f;if(!1===S&&g!==p&&g===r&&m<n+e&&y)return l;if(1===c.size){if(function(t,e,n){const r=e._nodeMap.get(t),o=n._nodeMap.get(t),i=e._selection,s=n._selection;let c=!1;return a(i)&&a(s)&&(c="element"===i.anchor.type&&"element"===i.focus.type&&"text"===s.anchor.type&&"text"===s.focus.type),!(c||!u(r)||!u(o))&&r.__type===o.__type&&r.__text===o.__text&&r.__mode===o.__mode&&r.__detail===o.__detail&&r.__style===o.__style&&r.__format===o.__format&&r.__parent===o.__parent}(Array.from(c)[0],o,i))return l}return _})();return n=m,r=g,y}}function C(t){t.undoStack=[],t.redoStack=[],t.current=null}function x(a,u,d){const l=k(a,d),p=({editorState:t,prevEditorState:e,dirtyLeaves:n,dirtyElements:r,tags:o})=>{const i=u.current,d=u.redoStack,p=u.undoStack,h=null===i?null:i.editorState;if(null!==i&&t===h)return;const m=l(e,t,i,n,r,o);if(m===_)0!==d.length&&(u.redoStack=[],a.dispatchCommand(s,!1)),null!==i&&(p.push({...i}),a.dispatchCommand(c,!0));else if(m===f)return;u.current={editor:a,editorState:t}},h=t(a.registerCommand(e,(()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==r.length){const o=e.current,i=r.pop();null!==o&&(n.push(o),t.dispatchCommand(s,!0)),0===r.length&&t.dispatchCommand(c,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}(a,u),!0)),n),a.registerCommand(r,(()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==n.length){const o=e.current;null!==o&&(r.push(o),t.dispatchCommand(c,!0));const i=n.pop();0===n.length&&t.dispatchCommand(s,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}(a,u),!0)),n),a.registerCommand(o,(()=>(C(u),!1)),n),a.registerCommand(i,(()=>(C(u),a.dispatchCommand(s,!1),a.dispatchCommand(c,!1),!0)),n),a.registerUpdateListener(p)),m=a.registerUpdateListener(p);return()=>{h(),m()}}function M(){return{current:null,redoStack:[],undoStack:[]}}export{M as createEmptyHistoryState,x as registerHistory};
8
+
9
+ import{mergeRegister as t}from"@lexical/utils";import{UNDO_COMMAND as e,COMMAND_PRIORITY_EDITOR as n,REDO_COMMAND as o,CLEAR_EDITOR_COMMAND as r,CLEAR_HISTORY_COMMAND as i,CAN_REDO_COMMAND as s,CAN_UNDO_COMMAND as c,$isRangeSelection as a,$isTextNode as u,$isRootNode as d}from"lexical";const l=0,_=1,f=2,p=0,h=1,m=2,g=3,y=4;function S(t,e,n,o,r){if(null===t||0===n.size&&0===o.size&&!r)return p;const i=e._selection,s=t._selection;if(r)return h;if(!(a(i)&&a(s)&&s.isCollapsed()&&i.isCollapsed()))return p;const c=function(t,e,n){const o=t._nodeMap,r=[];for(const t of e){const e=o.get(t);void 0!==e&&r.push(e)}for(const[t,e]of n){if(!e)continue;const n=o.get(t);void 0===n||d(n)||r.push(n)}return r}(e,n,o);if(0===c.length)return p;if(c.length>1){const n=e._nodeMap,o=n.get(i.anchor.key),r=n.get(s.anchor.key);return o&&r&&!t._nodeMap.has(o.__key)&&u(o)&&1===o.__text.length&&1===i.anchor.offset?m:p}const l=c[0],_=t._nodeMap.get(l.__key);if(!u(_)||!u(l)||_.__mode!==l.__mode)return p;const f=_.__text,S=l.__text;if(f===S)return p;const k=i.anchor,C=s.anchor;if(k.key!==C.key||"text"!==k.type)return p;const x=k.offset,M=C.offset,z=S.length-f.length;return 1===z&&M===x-1?m:-1===z&&M===x+1?g:-1===z&&M===x?y:p}function k(t,e){let n=Date.now(),o=p;return(r,i,s,c,d,h)=>{const m=Date.now();if(h.has("historic"))return o=p,n=m,f;const g=S(r,i,c,d,t.isComposing()),y=(()=>{const y=null===s||s.editor===t,S=h.has("history-push");if(!S&&y&&h.has("history-merge"))return l;if(null===r)return _;const k=i._selection;if(!(c.size>0||d.size>0))return null!==k?l:f;if(!1===S&&g!==p&&g===o&&m<n+e&&y)return l;if(1===c.size){if(function(t,e,n){const o=e._nodeMap.get(t),r=n._nodeMap.get(t),i=e._selection,s=n._selection;let c=!1;return a(i)&&a(s)&&(c="element"===i.anchor.type&&"element"===i.focus.type&&"text"===s.anchor.type&&"text"===s.focus.type),!(c||!u(o)||!u(r))&&o.__type===r.__type&&o.__text===r.__text&&o.__mode===r.__mode&&o.__detail===r.__detail&&o.__style===r.__style&&o.__format===r.__format&&o.__parent===r.__parent}(Array.from(c)[0],r,i))return l}return _})();return n=m,o=g,y}}function C(t){t.undoStack=[],t.redoStack=[],t.current=null}function x(a,u,d){const l=k(a,d),p=t(a.registerCommand(e,(()=>(function(t,e){const n=e.redoStack,o=e.undoStack;if(0!==o.length){const r=e.current,i=o.pop();null!==r&&(n.push(r),t.dispatchCommand(s,!0)),0===o.length&&t.dispatchCommand(c,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}(a,u),!0)),n),a.registerCommand(o,(()=>(function(t,e){const n=e.redoStack,o=e.undoStack;if(0!==n.length){const r=e.current;null!==r&&(o.push(r),t.dispatchCommand(c,!0));const i=n.pop();0===n.length&&t.dispatchCommand(s,!1),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:"historic"})}}(a,u),!0)),n),a.registerCommand(r,(()=>(C(u),!1)),n),a.registerCommand(i,(()=>(C(u),a.dispatchCommand(s,!1),a.dispatchCommand(c,!1),!0)),n),a.registerUpdateListener((({editorState:t,prevEditorState:e,dirtyLeaves:n,dirtyElements:o,tags:r})=>{const i=u.current,d=u.redoStack,p=u.undoStack,h=null===i?null:i.editorState;if(null!==i&&t===h)return;const m=l(e,t,i,n,o,r);if(m===_)0!==d.length&&(u.redoStack=[],a.dispatchCommand(s,!1)),null!==i&&(p.push({...i}),a.dispatchCommand(c,!0));else if(m===f)return;u.current={editor:a,editorState:t}})));return p}function M(){return{current:null,redoStack:[],undoStack:[]}}export{M as createEmptyHistoryState,x as registerHistory};
package/package.json CHANGED
@@ -8,12 +8,12 @@
8
8
  "history"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.14.4",
11
+ "version": "0.15.0",
12
12
  "main": "LexicalHistory.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/utils": "0.14.4",
16
- "lexical": "0.14.4"
15
+ "@lexical/utils": "0.15.0",
16
+ "lexical": "0.15.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",