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/dist/slate.js +27 -5
- package/dist/slate.min.js +1 -1
- package/lib/slate.es.js +27 -5
- package/lib/slate.es.js.map +1 -1
- package/lib/slate.js +27 -5
- package/lib/slate.js.map +1 -1
- package/package.json +2 -2
package/lib/slate.es.js
CHANGED
|
@@ -7920,7 +7920,7 @@ Commands$3.save = function (editor, operation) {
|
|
|
7920
7920
|
save = _editor$tmp.save,
|
|
7921
7921
|
merge = _editor$tmp.merge;
|
|
7922
7922
|
|
|
7923
|
-
if (save === false) return;
|
|
7923
|
+
if (save === false || !isValidOperation(operation)) return;
|
|
7924
7924
|
|
|
7925
7925
|
var undos = data.get('undos') || List();
|
|
7926
7926
|
var lastBatch = undos.last();
|
|
@@ -7981,13 +7981,13 @@ Commands$3.redo = function (editor) {
|
|
|
7981
7981
|
batch.forEach(function (op) {
|
|
7982
7982
|
var _op = op,
|
|
7983
7983
|
type = _op.type,
|
|
7984
|
-
|
|
7984
|
+
newProperties = _op.newProperties;
|
|
7985
7985
|
|
|
7986
7986
|
// When the operation mutates the selection, omit its `isFocused` value to
|
|
7987
7987
|
// prevent the editor focus from changing during redoing.
|
|
7988
7988
|
|
|
7989
7989
|
if (type === 'set_selection') {
|
|
7990
|
-
op = op.set('
|
|
7990
|
+
op = op.set('newProperties', omit(newProperties, 'isFocused'));
|
|
7991
7991
|
}
|
|
7992
7992
|
|
|
7993
7993
|
editor.applyOperation(op);
|
|
@@ -8025,13 +8025,13 @@ Commands$3.undo = function (editor) {
|
|
|
8025
8025
|
}).forEach(function (inverse) {
|
|
8026
8026
|
var _inverse = inverse,
|
|
8027
8027
|
type = _inverse.type,
|
|
8028
|
-
|
|
8028
|
+
newProperties = _inverse.newProperties;
|
|
8029
8029
|
|
|
8030
8030
|
// When the operation mutates the selection, omit its `isFocused` value to
|
|
8031
8031
|
// prevent the editor focus from changing during undoing.
|
|
8032
8032
|
|
|
8033
8033
|
if (type === 'set_selection') {
|
|
8034
|
-
inverse = inverse.set('
|
|
8034
|
+
inverse = inverse.set('newProperties', omit(newProperties, 'isFocused'));
|
|
8035
8035
|
}
|
|
8036
8036
|
|
|
8037
8037
|
editor.applyOperation(inverse);
|
|
@@ -8092,6 +8092,28 @@ function shouldMerge(o, p) {
|
|
|
8092
8092
|
return merge;
|
|
8093
8093
|
}
|
|
8094
8094
|
|
|
8095
|
+
/**
|
|
8096
|
+
* Check weather an operation needs to be saved to the history
|
|
8097
|
+
* @param {Object} o - operation
|
|
8098
|
+
* @returns {Boolean}
|
|
8099
|
+
*/
|
|
8100
|
+
|
|
8101
|
+
function isValidOperation(o) {
|
|
8102
|
+
if (o.type === 'set_selection') {
|
|
8103
|
+
var _o$newProperties = o.newProperties,
|
|
8104
|
+
isFocused = _o$newProperties.isFocused,
|
|
8105
|
+
anchor = _o$newProperties.anchor,
|
|
8106
|
+
focus = _o$newProperties.focus;
|
|
8107
|
+
|
|
8108
|
+
// this is blur/focus operation, dont need to store it into the history
|
|
8109
|
+
|
|
8110
|
+
if (isFocused !== undefined && !anchor && !focus) {
|
|
8111
|
+
return false;
|
|
8112
|
+
}
|
|
8113
|
+
}
|
|
8114
|
+
return true;
|
|
8115
|
+
}
|
|
8116
|
+
|
|
8095
8117
|
var Commands$4 = {};
|
|
8096
8118
|
|
|
8097
8119
|
Commands$4.blur = function (editor) {
|