New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

slate-history

Package Overview
Dependencies
Maintainers
1
Versions
279
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slate-history - npm Package Compare versions

Comparing version 0.53.0 to 0.54.0

8

dist/history-command.d.ts

@@ -13,11 +13,3 @@ export interface RedoCommand {

isHistoryCommand(value: any): value is HistoryCommand;
/**
* Check if a value is a `RedoCommand` object.
*/
isRedoCommand(value: any): value is RedoCommand;
/**
* Check if a value is an `UndoCommand` object.
*/
isUndoCommand(value: any): value is UndoCommand;
};
//# sourceMappingURL=history-command.d.ts.map

28

dist/index.es.js

@@ -18,17 +18,11 @@ import isPlainObject from 'is-plain-object';

isHistoryCommand: function isHistoryCommand(value) {
return HistoryCommand.isRedoCommand(value) || HistoryCommand.isUndoCommand(value);
},
if (Command.isCommand(value)) {
switch (value.type) {
case 'redo':
case 'undo':
return true;
}
}
/**
* Check if a value is a `RedoCommand` object.
*/
isRedoCommand: function isRedoCommand(value) {
return Command.isCommand(value) && value.type === 'redo';
},
/**
* Check if a value is an `UndoCommand` object.
*/
isUndoCommand: function isUndoCommand(value) {
return Command.isCommand(value) && value.type === 'undo';
return false;
}

@@ -103,3 +97,3 @@ };

editor.exec = function (command) {
if (HistoryEditor.isHistoryEditor(editor)) {
if (HistoryEditor.isHistoryEditor(editor) && HistoryCommand.isHistoryCommand(command)) {
var history = editor.history;

@@ -109,3 +103,3 @@ var undos = history.undos,

if (redos.length > 0 && HistoryCommand.isRedoCommand(command)) {
if (command.type === 'redo' && redos.length > 0) {
var batch = redos[redos.length - 1];

@@ -144,3 +138,3 @@ HistoryEditor.withoutSaving(editor, function () {

if (undos.length > 0 && HistoryCommand.isUndoCommand(command)) {
if (command.type === 'undo' && undos.length > 0) {
var _batch = undos[undos.length - 1];

@@ -147,0 +141,0 @@ HistoryEditor.withoutSaving(editor, function () {

@@ -24,17 +24,11 @@ 'use strict';

isHistoryCommand: function isHistoryCommand(value) {
return HistoryCommand.isRedoCommand(value) || HistoryCommand.isUndoCommand(value);
},
if (slate.Command.isCommand(value)) {
switch (value.type) {
case 'redo':
case 'undo':
return true;
}
}
/**
* Check if a value is a `RedoCommand` object.
*/
isRedoCommand: function isRedoCommand(value) {
return slate.Command.isCommand(value) && value.type === 'redo';
},
/**
* Check if a value is an `UndoCommand` object.
*/
isUndoCommand: function isUndoCommand(value) {
return slate.Command.isCommand(value) && value.type === 'undo';
return false;
}

@@ -109,3 +103,3 @@ };

editor.exec = function (command) {
if (HistoryEditor.isHistoryEditor(editor)) {
if (HistoryEditor.isHistoryEditor(editor) && HistoryCommand.isHistoryCommand(command)) {
var history = editor.history;

@@ -115,3 +109,3 @@ var undos = history.undos,

if (redos.length > 0 && HistoryCommand.isRedoCommand(command)) {
if (command.type === 'redo' && redos.length > 0) {
var batch = redos[redos.length - 1];

@@ -150,3 +144,3 @@ HistoryEditor.withoutSaving(editor, function () {

if (undos.length > 0 && HistoryCommand.isUndoCommand(command)) {
if (command.type === 'undo' && undos.length > 0) {
var _batch = undos[undos.length - 1];

@@ -153,0 +147,0 @@ HistoryEditor.withoutSaving(editor, function () {

@@ -66,17 +66,11 @@ (function (global, factory) {

isHistoryCommand: function isHistoryCommand(value) {
return HistoryCommand.isRedoCommand(value) || HistoryCommand.isUndoCommand(value);
},
if (slate.Command.isCommand(value)) {
switch (value.type) {
case 'redo':
case 'undo':
return true;
}
}
/**
* Check if a value is a `RedoCommand` object.
*/
isRedoCommand: function isRedoCommand(value) {
return slate.Command.isCommand(value) && value.type === 'redo';
},
/**
* Check if a value is an `UndoCommand` object.
*/
isUndoCommand: function isUndoCommand(value) {
return slate.Command.isCommand(value) && value.type === 'undo';
return false;
}

@@ -151,3 +145,3 @@ };

editor.exec = function (command) {
if (HistoryEditor.isHistoryEditor(editor)) {
if (HistoryEditor.isHistoryEditor(editor) && HistoryCommand.isHistoryCommand(command)) {
var history = editor.history;

@@ -157,3 +151,3 @@ var undos = history.undos,

if (redos.length > 0 && HistoryCommand.isRedoCommand(command)) {
if (command.type === 'redo' && redos.length > 0) {
var batch = redos[redos.length - 1];

@@ -192,3 +186,3 @@ HistoryEditor.withoutSaving(editor, function () {

if (undos.length > 0 && HistoryCommand.isUndoCommand(command)) {
if (command.type === 'undo' && undos.length > 0) {
var _batch = undos[undos.length - 1];

@@ -195,0 +189,0 @@ HistoryEditor.withoutSaving(editor, function () {

@@ -14,2 +14,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("slate")):"function"==typeof define&&define.amd?define(["exports","slate"],e):e((t=t||self).SlateHistory={},t.Slate)}(this,(function(t,e){"use strict";

*/
function n(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}var o={isHistory:function(t){return!1!==n(o=t)&&"function"==typeof(r=o.constructor)&&!1!==n(i=r.prototype)&&!1!==i.hasOwnProperty("isPrototypeOf")&&Array.isArray(t.redos)&&Array.isArray(t.undos)&&(0===t.redos.length||e.Operation.isOperationList(t.redos[0]))&&(0===t.undos.length||e.Operation.isOperationList(t.undos[0]));var o,r,i}},r={isHistoryCommand:function(t){return r.isRedoCommand(t)||r.isUndoCommand(t)},isRedoCommand:function(t){return e.Command.isCommand(t)&&"redo"===t.type},isUndoCommand:function(t){return e.Command.isCommand(t)&&"undo"===t.type}},i=new WeakMap,s=new WeakMap,a=new WeakMap,u={isHistoryEditor:function(t){return e.Editor.isEditor(t)&&o.isHistory(t.history)},isMerging:function(t){return a.get(t)},isSaving:function(t){return s.get(t)},withoutMerging:function(t,e){var n=u.isMerging(t);a.set(t,!1),e(),a.set(t,n)},withoutSaving:function(t,e){var n=u.isSaving(t);s.set(t,!1),e(),s.set(t,n)}},l=function(t,n){return"set_selection"===t.type||(!(!n||"insert_text"!==t.type||"insert_text"!==n.type||t.offset!==n.offset+n.text.length||!e.Path.equals(t.path,n.path))||!(!n||"remove_text"!==t.type||"remove_text"!==n.type||t.offset+t.text.length!==n.offset||!e.Path.equals(t.path,n.path)))},f=function(t,e){return"set_selection"!==t.type||null!=t.newProperties},p=function(t,e){return!(!e||"set_selection"!==t.type||"set_selection"!==e.type)},d=function(t){return"set_selection"!==t.type};t.HISTORY=i,t.History=o,t.HistoryCommand=r,t.HistoryEditor=u,t.MERGING=a,t.SAVING=s,t.withHistory=function(t){var n=t.apply,o=t.exec;return t.history={undos:[],redos:[]},t.exec=function(n){if(u.isHistoryEditor(t)){var i=t.history,s=i.undos,a=i.redos;if(a.length>0&&r.isRedoCommand(n)){var l=a[a.length-1];return u.withoutSaving(t,(function(){e.Editor.withoutNormalizing(t,(function(){var e=!0,n=!1,o=void 0;try{for(var r,i=l[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var s=r.value;t.apply(s)}}catch(t){n=!0,o=t}finally{try{e||null==i.return||i.return()}finally{if(n)throw o}}}))})),i.redos.pop(),void i.undos.push(l)}if(s.length>0&&r.isUndoCommand(n)){var f=s[s.length-1];return u.withoutSaving(t,(function(){e.Editor.withoutNormalizing(t,(function(){var n=f.map(e.Operation.inverse).reverse(),o=!0,r=!1,i=void 0;try{for(var s,a=n[Symbol.iterator]();!(o=(s=a.next()).done);o=!0){var u=s.value;u===n[n.length-1]&&"set_selection"===u.type&&null==u.newProperties||t.apply(u)}}catch(t){r=!0,i=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw i}}}))})),i.redos.push(f),void i.undos.pop()}}o(n)},t.apply=function(e){if(u.isHistoryEditor(t)){var o=t.operations,r=t.history,i=r.undos,s=i[i.length-1],a=s&&s[s.length-1],y=p(e,a),c=u.isSaving(t),h=u.isMerging(t);if(null==c&&(c=f(e)),c){if(null==h&&(h=null!=s&&(0!==o.length||(l(e,a)||y))),s&&h)y&&s.pop(),s.push(e);else{var v=[e];i.push(v)}for(;i.length>100;)i.shift();d(e)&&(r.redos=[])}}n(e)},t},Object.defineProperty(t,"__esModule",{value:!0})}));
function r(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}var n={isHistory:function(t){return!1!==r(n=t)&&"function"==typeof(o=n.constructor)&&!1!==r(i=o.prototype)&&!1!==i.hasOwnProperty("isPrototypeOf")&&Array.isArray(t.redos)&&Array.isArray(t.undos)&&(0===t.redos.length||e.Operation.isOperationList(t.redos[0]))&&(0===t.undos.length||e.Operation.isOperationList(t.undos[0]));var n,o,i}},o={isHistoryCommand:function(t){if(e.Command.isCommand(t))switch(t.type){case"redo":case"undo":return!0}return!1}},i=new WeakMap,s=new WeakMap,a=new WeakMap,u={isHistoryEditor:function(t){return e.Editor.isEditor(t)&&n.isHistory(t.history)},isMerging:function(t){return a.get(t)},isSaving:function(t){return s.get(t)},withoutMerging:function(t,e){var r=u.isMerging(t);a.set(t,!1),e(),a.set(t,r)},withoutSaving:function(t,e){var r=u.isSaving(t);s.set(t,!1),e(),s.set(t,r)}},l=function(t,r){return"set_selection"===t.type||(!(!r||"insert_text"!==t.type||"insert_text"!==r.type||t.offset!==r.offset+r.text.length||!e.Path.equals(t.path,r.path))||!(!r||"remove_text"!==t.type||"remove_text"!==r.type||t.offset+t.text.length!==r.offset||!e.Path.equals(t.path,r.path)))},p=function(t,e){return"set_selection"!==t.type||null!=t.newProperties},f=function(t,e){return!(!e||"set_selection"!==t.type||"set_selection"!==e.type)},y=function(t){return"set_selection"!==t.type};t.HISTORY=i,t.History=n,t.HistoryCommand=o,t.HistoryEditor=u,t.MERGING=a,t.SAVING=s,t.withHistory=function(t){var r=t.apply,n=t.exec;return t.history={undos:[],redos:[]},t.exec=function(r){if(u.isHistoryEditor(t)&&o.isHistoryCommand(r)){var i=t.history,s=i.undos,a=i.redos;if("redo"===r.type&&a.length>0){var l=a[a.length-1];return u.withoutSaving(t,(function(){e.Editor.withoutNormalizing(t,(function(){var e=!0,r=!1,n=void 0;try{for(var o,i=l[Symbol.iterator]();!(e=(o=i.next()).done);e=!0){var s=o.value;t.apply(s)}}catch(t){r=!0,n=t}finally{try{e||null==i.return||i.return()}finally{if(r)throw n}}}))})),i.redos.pop(),void i.undos.push(l)}if("undo"===r.type&&s.length>0){var p=s[s.length-1];return u.withoutSaving(t,(function(){e.Editor.withoutNormalizing(t,(function(){var r=p.map(e.Operation.inverse).reverse(),n=!0,o=!1,i=void 0;try{for(var s,a=r[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value;u===r[r.length-1]&&"set_selection"===u.type&&null==u.newProperties||t.apply(u)}}catch(t){o=!0,i=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}}))})),i.redos.push(p),void i.undos.pop()}}n(r)},t.apply=function(e){if(u.isHistoryEditor(t)){var n=t.operations,o=t.history,i=o.undos,s=i[i.length-1],a=s&&s[s.length-1],c=f(e,a),d=u.isSaving(t),h=u.isMerging(t);if(null==d&&(d=p(e)),d){if(null==h&&(h=null!=s&&(0!==n.length||(l(e,a)||c))),s&&h)c&&s.pop(),s.push(e);else{var v=[e];i.push(v)}for(;i.length>100;)i.shift();y(e)&&(o.redos=[])}}r(e)},t},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "slate-history",
"description": "An operation-based history implementation for Slate editors.",
"version": "0.53.0",
"version": "0.54.0",
"license": "MIT",

@@ -21,4 +21,4 @@ "repository": "git://github.com/ianstormtaylor/slate.git",

"devDependencies": {
"slate": "^0.53.0",
"slate-hyperscript": "^0.53.0"
"slate": "^0.54.0",
"slate-hyperscript": "^0.54.0"
},

@@ -41,3 +41,3 @@ "peerDependencies": {

],
"gitHead": "26b67578d4e309bf37be8d07d5e3a81962d15fe7"
"gitHead": "c9ee5038286286825a1393b9357ed0730268202f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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