Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lexical/history

Package Overview
Dependencies
Maintainers
3
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lexical/history - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

9

LexicalHistory.dev.js

@@ -28,3 +28,2 @@ /**

const DELETE_CHARACTER_AFTER_SELECTION = 4;
const EditorPriority = 0;

@@ -291,12 +290,12 @@ function getDirtyNodes(editorState, dirtyLeaves, dirtyElements) {

return true;
}, EditorPriority), editor.registerCommand(lexical.REDO_COMMAND, () => {
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.REDO_COMMAND, () => {
redo(editor, historyState);
return true;
}, EditorPriority), editor.registerCommand(lexical.CLEAR_EDITOR_COMMAND, () => {
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CLEAR_EDITOR_COMMAND, () => {
clearHistory(historyState);
return false;
}, EditorPriority), editor.registerCommand(lexical.CLEAR_HISTORY_COMMAND, () => {
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerCommand(lexical.CLEAR_HISTORY_COMMAND, () => {
clearHistory(historyState);
return true;
}, EditorPriority), editor.registerUpdateListener(applyChange));
}, lexical.COMMAND_PRIORITY_EDITOR), editor.registerUpdateListener(applyChange));
const unregisterUpdateListener = editor.registerUpdateListener(applyChange);

@@ -303,0 +302,0 @@ return () => {

@@ -7,9 +7,10 @@ /**

*/
var g=require("@lexical/utils"),u=require("lexical");
function v(b,a,k,h,m){if(null===b||0===k.size&&0===h.size)return 0;var e=a._selection,c=b._selection;if(m)return 1;if(!(u.$isRangeSelection(e)&&u.$isRangeSelection(c)&&c.isCollapsed()&&e.isCollapsed()))return 0;m=a._nodeMap;const d=[];for(const f of k)k=m.get(f),void 0!==k&&d.push(k);for(const [f,l]of h)l&&(h=m.get(f),void 0===h||u.$isRootNode(h)||d.push(h));if(0===d.length)return 0;if(1<d.length)return h=a._nodeMap,a=h.get(e.anchor.key),c=h.get(c.anchor.key),a&&c&&!b._nodeMap.has(a.__key)&&u.$isTextNode(a)&&
1===a.__text.length&&1===e.anchor.offset?2:0;a=d[0];b=b._nodeMap.get(a.__key);if(!u.$isTextNode(b)||!u.$isTextNode(a)||b.__mode!==a.__mode)return 0;b=b.__text;a=a.__text;if(b===a)return 0;e=e.anchor;c=c.anchor;if(e.key!==c.key||"text"!==e.type)return 0;e=e.offset;c=c.offset;b=a.length-b.length;return 1===b&&c===e-1?2:-1===b&&c===e+1?3:-1===b&&c===e?4:0}
function w(b,a){let k=Date.now(),h=0;return(m,e,c,d,f,l)=>{const p=Date.now();if(l.has("historic"))return h=0,k=p,2;const n=v(m,e,d,f,b.isComposing()),t=(()=>{const r=l.has("history-push");if(!r&&l.has("history-merge"))return 0;if(null===m)return 1;var q=e._selection;const x=m._selection;if(!(0<d.size||0<f.size))return null===x&&null!==q?0:2;q=null===c||c.editor===b;return!1===r&&0!==n&&n===h&&p<k+a&&q?0:1})();k=p;h=n;return t}}
var e=require("@lexical/utils"),u=require("lexical");
function v(b,a,k,h,m){if(null===b||0===k.size&&0===h.size)return 0;var f=a._selection,c=b._selection;if(m)return 1;if(!(u.$isRangeSelection(f)&&u.$isRangeSelection(c)&&c.isCollapsed()&&f.isCollapsed()))return 0;m=a._nodeMap;const d=[];for(const g of k)k=m.get(g),void 0!==k&&d.push(k);for(const [g,l]of h)l&&(h=m.get(g),void 0===h||u.$isRootNode(h)||d.push(h));if(0===d.length)return 0;if(1<d.length)return h=a._nodeMap,a=h.get(f.anchor.key),c=h.get(c.anchor.key),a&&c&&!b._nodeMap.has(a.__key)&&u.$isTextNode(a)&&
1===a.__text.length&&1===f.anchor.offset?2:0;a=d[0];b=b._nodeMap.get(a.__key);if(!u.$isTextNode(b)||!u.$isTextNode(a)||b.__mode!==a.__mode)return 0;b=b.__text;a=a.__text;if(b===a)return 0;f=f.anchor;c=c.anchor;if(f.key!==c.key||"text"!==f.type)return 0;f=f.offset;c=c.offset;b=a.length-b.length;return 1===b&&c===f-1?2:-1===b&&c===f+1?3:-1===b&&c===f?4:0}
function w(b,a){let k=Date.now(),h=0;return(m,f,c,d,g,l)=>{const p=Date.now();if(l.has("historic"))return h=0,k=p,2;const n=v(m,f,d,g,b.isComposing()),t=(()=>{const r=l.has("history-push");if(!r&&l.has("history-merge"))return 0;if(null===m)return 1;var q=f._selection;const x=m._selection;if(!(0<d.size||0<g.size))return null===x&&null!==q?0:2;q=null===c||c.editor===b;return!1===r&&0!==n&&n===h&&p<k+a&&q?0:1})();k=p;h=n;return t}}
exports.createEmptyHistoryState=function(){return{current:null,redoStack:[],undoStack:[]}};
exports.registerHistory=function(b,a,k){const h=w(b,k);k=({editorState:c,prevEditorState:d,dirtyLeaves:f,dirtyElements:l,tags:p})=>{const n=a.current,t=a.redoStack,r=a.undoStack,q=null===n?null:n.editorState;if(null===n||c!==q){f=h(d,c,n,f,l,p);if(1===f)0!==t.length&&(a.redoStack=[]),null!==n&&(r.push({...n,undoSelection:d.read(u.$getSelection)}),b.dispatchCommand(u.CAN_UNDO_COMMAND,!0));else if(2===f)return;a.current={editor:b,editorState:c}}};const m=g.mergeRegister(b.registerCommand(u.UNDO_COMMAND,
()=>{const c=a.redoStack,d=a.undoStack;if(0!==d.length){const f=a.current,l=d.pop();null!==f&&(c.push(f),b.dispatchCommand(u.CAN_REDO_COMMAND,!0));0===d.length&&b.dispatchCommand(u.CAN_UNDO_COMMAND,!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0},0),b.registerCommand(u.REDO_COMMAND,()=>{const c=a.redoStack;var d=a.undoStack;if(0!==c.length){const f=a.current;null!==f&&(d.push(f),b.dispatchCommand(u.CAN_UNDO_COMMAND,!0));d=c.pop();0===c.length&&
b.dispatchCommand(u.CAN_REDO_COMMAND,!1);a.current=d;d.editor.setEditorState(d.editorState,{tag:"historic"})}return!0},0),b.registerCommand(u.CLEAR_EDITOR_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!1},0),b.registerCommand(u.CLEAR_HISTORY_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!0},0),b.registerUpdateListener(k)),e=b.registerUpdateListener(k);return()=>{m();e()}};
exports.registerHistory=function(b,a,k){const h=w(b,k);k=({editorState:c,prevEditorState:d,dirtyLeaves:g,dirtyElements:l,tags:p})=>{const n=a.current,t=a.redoStack,r=a.undoStack,q=null===n?null:n.editorState;if(null===n||c!==q){g=h(d,c,n,g,l,p);if(1===g)0!==t.length&&(a.redoStack=[]),null!==n&&(r.push({...n,undoSelection:d.read(u.$getSelection)}),b.dispatchCommand(u.CAN_UNDO_COMMAND,!0));else if(2===g)return;a.current={editor:b,editorState:c}}};const m=e.mergeRegister(b.registerCommand(u.UNDO_COMMAND,
()=>{const c=a.redoStack,d=a.undoStack;if(0!==d.length){const g=a.current,l=d.pop();null!==g&&(c.push(g),b.dispatchCommand(u.CAN_REDO_COMMAND,!0));0===d.length&&b.dispatchCommand(u.CAN_UNDO_COMMAND,!1);a.current=l;l.editor.setEditorState(l.editorState.clone(l.undoSelection),{tag:"historic"})}return!0},u.COMMAND_PRIORITY_EDITOR),b.registerCommand(u.REDO_COMMAND,()=>{const c=a.redoStack;var d=a.undoStack;if(0!==c.length){const g=a.current;null!==g&&(d.push(g),b.dispatchCommand(u.CAN_UNDO_COMMAND,!0));
d=c.pop();0===c.length&&b.dispatchCommand(u.CAN_REDO_COMMAND,!1);a.current=d;d.editor.setEditorState(d.editorState,{tag:"historic"})}return!0},u.COMMAND_PRIORITY_EDITOR),b.registerCommand(u.CLEAR_EDITOR_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!1},u.COMMAND_PRIORITY_EDITOR),b.registerCommand(u.CLEAR_HISTORY_COMMAND,()=>{a.undoStack=[];a.redoStack=[];a.current=null;return!0},u.COMMAND_PRIORITY_EDITOR),b.registerUpdateListener(k)),f=b.registerUpdateListener(k);return()=>{m();
f()}};

@@ -11,9 +11,9 @@ {

"license": "MIT",
"version": "0.2.1",
"version": "0.2.2",
"main": "LexicalHistory.js",
"peerDependencies": {
"lexical": "0.2.1"
"lexical": "0.2.2"
},
"dependencies": {
"@lexical/utils": "0.2.1"
"@lexical/utils": "0.2.2"
},

@@ -20,0 +20,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc