slate 0.47.7 → 0.47.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/slate.js CHANGED
@@ -7926,7 +7926,7 @@ Commands$3.save = function (editor, operation) {
7926
7926
  save = _editor$tmp.save,
7927
7927
  merge = _editor$tmp.merge;
7928
7928
 
7929
- if (save === false) return;
7929
+ if (save === false || !isValidOperation(operation)) return;
7930
7930
 
7931
7931
  var undos = data.get('undos') || immutable.List();
7932
7932
  var lastBatch = undos.last();
@@ -7987,13 +7987,13 @@ Commands$3.redo = function (editor) {
7987
7987
  batch.forEach(function (op) {
7988
7988
  var _op = op,
7989
7989
  type = _op.type,
7990
- properties = _op.properties;
7990
+ newProperties = _op.newProperties;
7991
7991
 
7992
7992
  // When the operation mutates the selection, omit its `isFocused` value to
7993
7993
  // prevent the editor focus from changing during redoing.
7994
7994
 
7995
7995
  if (type === 'set_selection') {
7996
- op = op.set('properties', omit(properties, 'isFocused'));
7996
+ op = op.set('newProperties', omit(newProperties, 'isFocused'));
7997
7997
  }
7998
7998
 
7999
7999
  editor.applyOperation(op);
@@ -8031,13 +8031,13 @@ Commands$3.undo = function (editor) {
8031
8031
  }).forEach(function (inverse) {
8032
8032
  var _inverse = inverse,
8033
8033
  type = _inverse.type,
8034
- properties = _inverse.properties;
8034
+ newProperties = _inverse.newProperties;
8035
8035
 
8036
8036
  // When the operation mutates the selection, omit its `isFocused` value to
8037
8037
  // prevent the editor focus from changing during undoing.
8038
8038
 
8039
8039
  if (type === 'set_selection') {
8040
- inverse = inverse.set('properties', omit(properties, 'isFocused'));
8040
+ inverse = inverse.set('newProperties', omit(newProperties, 'isFocused'));
8041
8041
  }
8042
8042
 
8043
8043
  editor.applyOperation(inverse);
@@ -8098,6 +8098,28 @@ function shouldMerge(o, p) {
8098
8098
  return merge;
8099
8099
  }
8100
8100
 
8101
+ /**
8102
+ * Check weather an operation needs to be saved to the history
8103
+ * @param {Object} o - operation
8104
+ * @returns {Boolean}
8105
+ */
8106
+
8107
+ function isValidOperation(o) {
8108
+ if (o.type === 'set_selection') {
8109
+ var _o$newProperties = o.newProperties,
8110
+ isFocused = _o$newProperties.isFocused,
8111
+ anchor = _o$newProperties.anchor,
8112
+ focus = _o$newProperties.focus;
8113
+
8114
+ // this is blur/focus operation, dont need to store it into the history
8115
+
8116
+ if (isFocused !== undefined && !anchor && !focus) {
8117
+ return false;
8118
+ }
8119
+ }
8120
+ return true;
8121
+ }
8122
+
8101
8123
  var Commands$4 = {};
8102
8124
 
8103
8125
  Commands$4.blur = function (editor) {