slate-history
Advanced tools
Comparing version 0.50.4 to 0.50.5
@@ -276,3 +276,5 @@ (function (global, factory) { | ||
history.redos = []; | ||
if (shouldClear(op)) { | ||
history.redos = []; | ||
} | ||
} | ||
@@ -329,3 +331,15 @@ } | ||
}; | ||
/** | ||
* Check whether an operation should clear the redos stack. | ||
*/ | ||
var shouldClear = function shouldClear(op) { | ||
if (op.type === 'set_selection') { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
exports.HISTORY = HISTORY; | ||
@@ -332,0 +346,0 @@ exports.History = History; |
@@ -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)};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],d=p(e,a),y=u.isSaving(t),c=u.isMerging(t);if(null==y&&(y=f(e)),y){if(null==c&&(c=null!=s&&(0!==o.length||(l(e,a)||d))),s&&c)d&&s.pop(),s.push(e);else{var h=[e];i.push(h)}for(;i.length>100;)i.shift();r.redos=[]}}n(e)},t},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
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})})); |
@@ -228,3 +228,5 @@ import isPlainObject from 'is-plain-object'; | ||
history.redos = []; | ||
if (shouldClear(op)) { | ||
history.redos = []; | ||
} | ||
} | ||
@@ -281,4 +283,16 @@ } | ||
}; | ||
/** | ||
* Check whether an operation should clear the redos stack. | ||
*/ | ||
var shouldClear = function shouldClear(op) { | ||
if (op.type === 'set_selection') { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
export { HISTORY, History, HistoryCommand, HistoryEditor, MERGING, SAVING, withHistory }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -234,3 +234,5 @@ 'use strict'; | ||
history.redos = []; | ||
if (shouldClear(op)) { | ||
history.redos = []; | ||
} | ||
} | ||
@@ -287,3 +289,15 @@ } | ||
}; | ||
/** | ||
* Check whether an operation should clear the redos stack. | ||
*/ | ||
var shouldClear = function shouldClear(op) { | ||
if (op.type === 'set_selection') { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
exports.HISTORY = HISTORY; | ||
@@ -290,0 +304,0 @@ exports.History = History; |
{ | ||
"name": "slate-history", | ||
"description": "An operation-based history implementation for Slate editors.", | ||
"version": "0.50.4", | ||
"version": "0.50.5", | ||
"license": "MIT", | ||
@@ -41,3 +41,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git", | ||
], | ||
"gitHead": "f979332ea6cff91049316a4fd569c8ab34fb33dc" | ||
"gitHead": "012d5d5086ee9c2a008f80eedaa2315ca37cf9a4" | ||
} |
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
71325
1006