slate-history
Advanced tools
Comparing version 0.86.0 to 0.93.0-202333232243
@@ -16,2 +16,3 @@ import { BaseEditor } from 'slate'; | ||
redo: () => void; | ||
writeHistory: (stack: 'undos' | 'redos', batch: any) => void; | ||
} | ||
@@ -18,0 +19,0 @@ export declare const HistoryEditor: { |
@@ -125,3 +125,3 @@ import { isPlainObject } from 'is-plain-object'; | ||
history.redos.pop(); | ||
history.undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -153,3 +153,3 @@ }; | ||
}); | ||
history.redos.push(batch); | ||
e.writeHistory('redos', batch); | ||
history.undos.pop(); | ||
@@ -194,3 +194,3 @@ } | ||
}; | ||
undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -208,2 +208,6 @@ | ||
e.writeHistory = (stack, batch) => { | ||
e.history[stack].push(batch); | ||
}; | ||
return e; | ||
@@ -210,0 +214,0 @@ }; |
@@ -136,3 +136,3 @@ 'use strict'; | ||
history.redos.pop(); | ||
history.undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -170,3 +170,3 @@ }; | ||
}); | ||
history.redos.push(batch); | ||
e.writeHistory('redos', batch); | ||
history.undos.pop(); | ||
@@ -207,3 +207,3 @@ } | ||
}; | ||
undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -221,2 +221,6 @@ | ||
e.writeHistory = function (stack, batch) { | ||
e.history[stack].push(batch); | ||
}; | ||
return e; | ||
@@ -223,0 +227,0 @@ }; |
@@ -168,3 +168,3 @@ (function (global, factory) { | ||
history.redos.pop(); | ||
history.undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -202,3 +202,3 @@ }; | ||
}); | ||
history.redos.push(batch); | ||
e.writeHistory('redos', batch); | ||
history.undos.pop(); | ||
@@ -239,3 +239,3 @@ } | ||
}; | ||
undos.push(batch); | ||
e.writeHistory('undos', batch); | ||
} | ||
@@ -253,2 +253,6 @@ | ||
e.writeHistory = function (stack, batch) { | ||
e.history[stack].push(batch); | ||
}; | ||
return e; | ||
@@ -255,0 +259,0 @@ }; |
@@ -7,2 +7,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="undefined"!=typeof globalThis?globalThis:t||self).SlateHistory={},t.Slate)}(this,(function(t,e){"use strict"; | ||
* Released under the MIT License. | ||
*/function n(t){return"[object Object]"===Object.prototype.toString.call(t)}var r={isHistory:function(t){return!1!==n(r=t)&&(void 0===(o=r.constructor)||!1!==n(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].operations))&&(0===t.undos.length||e.Operation.isOperationList(t.undos[0].operations));var r,o,i}},o=new WeakMap,i=new WeakMap,s=new WeakMap,a={isHistoryEditor:function(t){return r.isHistory(t.history)&&e.Editor.isEditor(t)},isMerging:function(t){return s.get(t)},isSaving:function(t){return i.get(t)},redo:function(t){t.redo()},undo:function(t){t.undo()},withoutMerging:function(t,e){var n=a.isMerging(t);s.set(t,!1),e(),s.set(t,n)},withoutSaving:function(t,e){var n=a.isSaving(t);i.set(t,!1),e(),i.set(t,n)}};function u(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var l=function(t,n){return!(!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))},p=function(t,e){return"set_selection"!==t.type};t.HISTORY=o,t.History=r,t.HistoryEditor=a,t.MERGING=s,t.SAVING=i,t.withHistory=function(t){var n=t,r=n.apply;return n.history={undos:[],redos:[]},n.redo=function(){var t=n.history,r=t.redos;if(r.length>0){var o=r[r.length-1];o.selectionBefore&&e.Transforms.setSelection(n,o.selectionBefore),a.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,e=u(o.operations);try{for(e.s();!(t=e.n()).done;){var r=t.value;n.apply(r)}}catch(t){e.e(t)}finally{e.f()}}))})),t.redos.pop(),t.undos.push(o)}},n.undo=function(){var t=n.history,r=t.undos;if(r.length>0){var o=r[r.length-1];a.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,r=u(o.operations.map(e.Operation.inverse).reverse());try{for(r.s();!(t=r.n()).done;){var i=t.value;n.apply(i)}}catch(t){r.e(t)}finally{r.f()}o.selectionBefore&&e.Transforms.setSelection(n,o.selectionBefore)}))})),t.redos.push(o),t.undos.pop()}},n.apply=function(t){var e=n.operations,o=n.history,i=o.undos,s=i[i.length-1],u=s&&s.operations[s.operations.length-1],f=a.isSaving(n),c=a.isMerging(n);if(null==f&&(f=p(t)),f){if(null==c&&(c=null!=s&&(0!==e.length||l(t,u))),s&&c)s.operations.push(t);else{var y={operations:[t],selectionBefore:n.selection};i.push(y)}for(;i.length>100;)i.shift();o.redos=[]}r(t)},n},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
*/function n(t){return"[object Object]"===Object.prototype.toString.call(t)}var r={isHistory:function(t){return!1!==n(r=t)&&(void 0===(o=r.constructor)||!1!==n(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].operations))&&(0===t.undos.length||e.Operation.isOperationList(t.undos[0].operations));var r,o,i}},o=new WeakMap,i=new WeakMap,s=new WeakMap,a={isHistoryEditor:function(t){return r.isHistory(t.history)&&e.Editor.isEditor(t)},isMerging:function(t){return s.get(t)},isSaving:function(t){return i.get(t)},redo:function(t){t.redo()},undo:function(t){t.undo()},withoutMerging:function(t,e){var n=a.isMerging(t);s.set(t,!1),e(),s.set(t,n)},withoutSaving:function(t,e){var n=a.isSaving(t);i.set(t,!1),e(),i.set(t,n)}};function u(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,i=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw i}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var l=function(t,n){return!(!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))},c=function(t,e){return"set_selection"!==t.type};t.HISTORY=o,t.History=r,t.HistoryEditor=a,t.MERGING=s,t.SAVING=i,t.withHistory=function(t){var n=t,r=n.apply;return n.history={undos:[],redos:[]},n.redo=function(){var t=n.history,r=t.redos;if(r.length>0){var o=r[r.length-1];o.selectionBefore&&e.Transforms.setSelection(n,o.selectionBefore),a.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,e=u(o.operations);try{for(e.s();!(t=e.n()).done;){var r=t.value;n.apply(r)}}catch(t){e.e(t)}finally{e.f()}}))})),t.redos.pop(),n.writeHistory("undos",o)}},n.undo=function(){var t=n.history,r=t.undos;if(r.length>0){var o=r[r.length-1];a.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,r=u(o.operations.map(e.Operation.inverse).reverse());try{for(r.s();!(t=r.n()).done;){var i=t.value;n.apply(i)}}catch(t){r.e(t)}finally{r.f()}o.selectionBefore&&e.Transforms.setSelection(n,o.selectionBefore)}))})),n.writeHistory("redos",o),t.undos.pop()}},n.apply=function(t){var e=n.operations,o=n.history,i=o.undos,s=i[i.length-1],u=s&&s.operations[s.operations.length-1],f=a.isSaving(n),p=a.isMerging(n);if(null==f&&(f=c(t)),f){if(null==p&&(p=null!=s&&(0!==e.length||l(t,u))),s&&p)s.operations.push(t);else{var y={operations:[t],selectionBefore:n.selection};n.writeHistory("undos",y)}for(;i.length>100;)i.shift();o.redos=[]}r(t)},n.writeHistory=function(t,e){n.history[t].push(e)},n},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "slate-history", | ||
"description": "An operation-based history implementation for Slate editors.", | ||
"version": "0.86.0", | ||
"version": "0.93.0-202333232243", | ||
"license": "MIT", | ||
@@ -22,8 +22,8 @@ "repository": "git://github.com/ianstormtaylor/slate.git", | ||
"lodash": "^4.17.21", | ||
"slate": "^0.86.0", | ||
"slate-hyperscript": "^0.81.3", | ||
"slate": "^0.93.0-202333232243", | ||
"slate-hyperscript": "^0.81.3-202333232243", | ||
"source-map-loader": "^4.0.0" | ||
}, | ||
"peerDependencies": { | ||
"slate": ">=0.65.3" | ||
"slate": ">=0.93.0-202333232243" | ||
}, | ||
@@ -30,0 +30,0 @@ "umdGlobals": { |
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
58623
774