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
5
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.109.0 to 0.110.3-20241021120038

12

dist/history-editor.d.ts

@@ -9,2 +9,3 @@ import { BaseEditor } from 'slate';

export declare const MERGING: WeakMap<BaseEditor, boolean | undefined>;
export declare const SPLITTING_ONCE: WeakMap<BaseEditor, boolean | undefined>;
/**

@@ -29,2 +30,7 @@ * `HistoryEditor` contains helpers for history-enabled editors.

/**
* Get the splitting once flag's current value.
*/
isSplittingOnce(editor: HistoryEditor): boolean | undefined;
setSplittingOnce(editor: HistoryEditor, value: boolean | undefined): void;
/**
* Get the saving flag's current value.

@@ -47,2 +53,8 @@ */

/**
* Apply a series of changes inside a synchronous `fn`, ensuring that the first
* operation starts a new batch in the history. Subsequent operations will be
* merged as usual.
*/
withNewBatch(editor: HistoryEditor, fn: () => void): void;
/**
* Apply a series of changes inside a synchronous `fn`, without merging any of

@@ -49,0 +61,0 @@ * the new operations into previous save point in the history.

29

dist/index.es.js

@@ -20,2 +20,3 @@ import { isPlainObject } from 'is-plain-object';

var MERGING = new WeakMap();
var SPLITTING_ONCE = new WeakMap();
// eslint-disable-next-line no-redeclare

@@ -36,2 +37,11 @@ var HistoryEditor = {

/**
* Get the splitting once flag's current value.
*/
isSplittingOnce(editor) {
return SPLITTING_ONCE.get(editor);
},
setSplittingOnce(editor, value) {
SPLITTING_ONCE.set(editor, value);
},
/**
* Get the saving flag's current value.

@@ -65,2 +75,15 @@ */

/**
* Apply a series of changes inside a synchronous `fn`, ensuring that the first
* operation starts a new batch in the history. Subsequent operations will be
* merged as usual.
*/
withNewBatch(editor, fn) {
var prev = HistoryEditor.isMerging(editor);
MERGING.set(editor, true);
SPLITTING_ONCE.set(editor, true);
fn();
MERGING.set(editor, prev);
SPLITTING_ONCE.delete(editor);
},
/**
* Apply a series of changes inside a synchronous `fn`, without merging any of

@@ -177,2 +200,6 @@ * the new operations into previous save point in the history.

}
if (HistoryEditor.isSplittingOnce(e)) {
merge = false;
HistoryEditor.setSplittingOnce(e, undefined);
}
if (lastBatch && merge) {

@@ -221,3 +248,3 @@ lastBatch.operations.push(op);

export { HISTORY, History, HistoryEditor, MERGING, SAVING, withHistory };
export { HISTORY, History, HistoryEditor, MERGING, SAVING, SPLITTING_ONCE, withHistory };
//# sourceMappingURL=index.es.js.map

@@ -22,2 +22,3 @@ 'use strict';

var MERGING = new WeakMap();
var SPLITTING_ONCE = new WeakMap();
// eslint-disable-next-line no-redeclare

@@ -38,2 +39,11 @@ var HistoryEditor = {

/**
* Get the splitting once flag's current value.
*/
isSplittingOnce: function isSplittingOnce(editor) {
return SPLITTING_ONCE.get(editor);
},
setSplittingOnce: function setSplittingOnce(editor, value) {
SPLITTING_ONCE.set(editor, value);
},
/**
* Get the saving flag's current value.

@@ -67,2 +77,15 @@ */

/**
* Apply a series of changes inside a synchronous `fn`, ensuring that the first
* operation starts a new batch in the history. Subsequent operations will be
* merged as usual.
*/
withNewBatch: function withNewBatch(editor, fn) {
var prev = HistoryEditor.isMerging(editor);
MERGING.set(editor, true);
SPLITTING_ONCE.set(editor, true);
fn();
MERGING.set(editor, prev);
SPLITTING_ONCE["delete"](editor);
},
/**
* Apply a series of changes inside a synchronous `fn`, without merging any of

@@ -186,2 +209,6 @@ * the new operations into previous save point in the history.

}
if (HistoryEditor.isSplittingOnce(e)) {
merge = false;
HistoryEditor.setSplittingOnce(e, undefined);
}
if (lastBatch && merge) {

@@ -235,3 +262,4 @@ lastBatch.operations.push(op);

exports.SAVING = SAVING;
exports.SPLITTING_ONCE = SPLITTING_ONCE;
exports.withHistory = withHistory;
//# sourceMappingURL=index.js.map

@@ -56,2 +56,3 @@ (function (global, factory) {

var MERGING = new WeakMap();
var SPLITTING_ONCE = new WeakMap();
// eslint-disable-next-line no-redeclare

@@ -72,2 +73,11 @@ var HistoryEditor = {

/**
* Get the splitting once flag's current value.
*/
isSplittingOnce: function isSplittingOnce(editor) {
return SPLITTING_ONCE.get(editor);
},
setSplittingOnce: function setSplittingOnce(editor, value) {
SPLITTING_ONCE.set(editor, value);
},
/**
* Get the saving flag's current value.

@@ -101,2 +111,15 @@ */

/**
* Apply a series of changes inside a synchronous `fn`, ensuring that the first
* operation starts a new batch in the history. Subsequent operations will be
* merged as usual.
*/
withNewBatch: function withNewBatch(editor, fn) {
var prev = HistoryEditor.isMerging(editor);
MERGING.set(editor, true);
SPLITTING_ONCE.set(editor, true);
fn();
MERGING.set(editor, prev);
SPLITTING_ONCE["delete"](editor);
},
/**
* Apply a series of changes inside a synchronous `fn`, without merging any of

@@ -220,2 +243,6 @@ * the new operations into previous save point in the history.

}
if (HistoryEditor.isSplittingOnce(e)) {
merge = false;
HistoryEditor.setSplittingOnce(e, undefined);
}
if (lastBatch && merge) {

@@ -269,4 +296,5 @@ lastBatch.operations.push(op);

exports.SAVING = SAVING;
exports.SPLITTING_ONCE = SPLITTING_ONCE;
exports.withHistory = withHistory;
}));

2

dist/slate-history.min.js

@@ -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()},withMerging:function(t,e){var n=a.isMerging(t);s.set(t,!0),e(),s.set(t,n)},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}}));
*/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=new WeakMap,u={isHistoryEditor:function(t){return r.isHistory(t.history)&&e.Editor.isEditor(t)},isMerging:function(t){return s.get(t)},isSplittingOnce:function(t){return a.get(t)},setSplittingOnce:function(t,e){a.set(t,e)},isSaving:function(t){return i.get(t)},redo:function(t){t.redo()},undo:function(t){t.undo()},withMerging:function(t,e){var n=u.isMerging(t);s.set(t,!0),e(),s.set(t,n)},withNewBatch:function(t,e){var n=u.isMerging(t);s.set(t,!0),a.set(t,!0),e(),s.set(t,n),a.delete(t)},withoutMerging:function(t,e){var n=u.isMerging(t);s.set(t,!1),e(),s.set(t,n)},withoutSaving:function(t,e){var n=u.isSaving(t);i.set(t,!1),e(),i.set(t,n)}};function f(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 l(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 l(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 l(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 c=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=u,t.MERGING=s,t.SAVING=i,t.SPLITTING_ONCE=a,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),u.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,e=f(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];u.withoutSaving(n,(function(){e.Editor.withoutNormalizing(n,(function(){var t,r=f(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],a=s&&s.operations[s.operations.length-1],f=u.isSaving(n),l=u.isMerging(n);if(null==f&&(f=p(t)),f){if(null==l&&(l=null!=s&&(0!==e.length||c(t,a))),u.isSplittingOnce(n)&&(l=!1,u.setSplittingOnce(n,void 0)),s&&l)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}}));
{
"name": "slate-history",
"description": "An operation-based history implementation for Slate editors.",
"version": "0.109.0",
"version": "0.110.3-20241021120038",
"license": "MIT",

@@ -22,3 +22,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git",

"lodash": "^4.17.21",
"slate": "^0.103.0",
"slate": "^0.110.2",
"slate-hyperscript": "^0.100.0",

@@ -25,0 +25,0 @@ "source-map-loader": "^4.0.1"

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