slate 0.82.1 → 0.84.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../packages/slate/src/interfaces/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;GAIG;AAEH,oBAAY,IAAI,GAAG,MAAM,EAAE,CAAA;AAE3B,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,IAAI,EAAE,CAAA;IACjE,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,IAAI,CAAA;IAC3C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAClD,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAA;IACjD,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAA;IAC9C,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAA;IAClD,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAAO,CAAA;IA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CAAA;IAC9B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,IAAI,CAAA;IAC9C,SAAS,EAAE,CACT,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,oBAAoB,KAC3B,IAAI,GAAG,IAAI,CAAA;CACjB;AAGD,eAAO,MAAM,IAAI,EAAE,aAwblB,CAAA"}
package/dist/slate.js CHANGED
@@ -4682,6 +4682,7 @@
4682
4682
  }
4683
4683
  };
4684
4684
 
4685
+ // eslint-disable-next-line no-redeclare
4685
4686
  var Path = {
4686
4687
  /**
4687
4688
  * Get a list of ancestor paths for a given path.
@@ -4965,120 +4966,120 @@
4965
4966
  */
4966
4967
  transform: function transform(path, operation) {
4967
4968
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4968
- return fn(path, function (p) {
4969
- var _options$affinity = options.affinity,
4970
- affinity = _options$affinity === void 0 ? 'forward' : _options$affinity; // PERF: Exit early if the operation is guaranteed not to have an effect.
4969
+ if (!path) return null; // PERF: use destructing instead of immer
4971
4970
 
4972
- if (!path || (path === null || path === void 0 ? void 0 : path.length) === 0) {
4973
- return;
4974
- }
4971
+ var p = _toConsumableArray(path);
4975
4972
 
4976
- if (p === null) {
4977
- return null;
4978
- }
4973
+ var _options$affinity = options.affinity,
4974
+ affinity = _options$affinity === void 0 ? 'forward' : _options$affinity; // PERF: Exit early if the operation is guaranteed not to have an effect.
4979
4975
 
4980
- switch (operation.type) {
4981
- case 'insert_node':
4982
- {
4983
- var op = operation.path;
4976
+ if (path.length === 0) {
4977
+ return p;
4978
+ }
4984
4979
 
4985
- if (Path.equals(op, p) || Path.endsBefore(op, p) || Path.isAncestor(op, p)) {
4986
- p[op.length - 1] += 1;
4987
- }
4980
+ switch (operation.type) {
4981
+ case 'insert_node':
4982
+ {
4983
+ var op = operation.path;
4988
4984
 
4989
- break;
4985
+ if (Path.equals(op, p) || Path.endsBefore(op, p) || Path.isAncestor(op, p)) {
4986
+ p[op.length - 1] += 1;
4990
4987
  }
4991
4988
 
4992
- case 'remove_node':
4993
- {
4994
- var _op = operation.path;
4989
+ break;
4990
+ }
4995
4991
 
4996
- if (Path.equals(_op, p) || Path.isAncestor(_op, p)) {
4997
- return null;
4998
- } else if (Path.endsBefore(_op, p)) {
4999
- p[_op.length - 1] -= 1;
5000
- }
4992
+ case 'remove_node':
4993
+ {
4994
+ var _op = operation.path;
5001
4995
 
5002
- break;
4996
+ if (Path.equals(_op, p) || Path.isAncestor(_op, p)) {
4997
+ return null;
4998
+ } else if (Path.endsBefore(_op, p)) {
4999
+ p[_op.length - 1] -= 1;
5003
5000
  }
5004
5001
 
5005
- case 'merge_node':
5006
- {
5007
- var _op2 = operation.path,
5008
- position = operation.position;
5009
-
5010
- if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
5011
- p[_op2.length - 1] -= 1;
5012
- } else if (Path.isAncestor(_op2, p)) {
5013
- p[_op2.length - 1] -= 1;
5014
- p[_op2.length] += position;
5015
- }
5002
+ break;
5003
+ }
5016
5004
 
5017
- break;
5005
+ case 'merge_node':
5006
+ {
5007
+ var _op2 = operation.path,
5008
+ position = operation.position;
5009
+
5010
+ if (Path.equals(_op2, p) || Path.endsBefore(_op2, p)) {
5011
+ p[_op2.length - 1] -= 1;
5012
+ } else if (Path.isAncestor(_op2, p)) {
5013
+ p[_op2.length - 1] -= 1;
5014
+ p[_op2.length] += position;
5018
5015
  }
5019
5016
 
5020
- case 'split_node':
5021
- {
5022
- var _op3 = operation.path,
5023
- _position = operation.position;
5017
+ break;
5018
+ }
5024
5019
 
5025
- if (Path.equals(_op3, p)) {
5026
- if (affinity === 'forward') {
5027
- p[p.length - 1] += 1;
5028
- } else if (affinity === 'backward') ; else {
5029
- return null;
5030
- }
5031
- } else if (Path.endsBefore(_op3, p)) {
5032
- p[_op3.length - 1] += 1;
5033
- } else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
5034
- p[_op3.length - 1] += 1;
5035
- p[_op3.length] -= _position;
5036
- }
5020
+ case 'split_node':
5021
+ {
5022
+ var _op3 = operation.path,
5023
+ _position = operation.position;
5037
5024
 
5038
- break;
5025
+ if (Path.equals(_op3, p)) {
5026
+ if (affinity === 'forward') {
5027
+ p[p.length - 1] += 1;
5028
+ } else if (affinity === 'backward') ; else {
5029
+ return null;
5030
+ }
5031
+ } else if (Path.endsBefore(_op3, p)) {
5032
+ p[_op3.length - 1] += 1;
5033
+ } else if (Path.isAncestor(_op3, p) && path[_op3.length] >= _position) {
5034
+ p[_op3.length - 1] += 1;
5035
+ p[_op3.length] -= _position;
5039
5036
  }
5040
5037
 
5041
- case 'move_node':
5042
- {
5043
- var _op4 = operation.path,
5044
- onp = operation.newPath; // If the old and new path are the same, it's a no-op.
5045
-
5046
- if (Path.equals(_op4, onp)) {
5047
- return;
5048
- }
5038
+ break;
5039
+ }
5049
5040
 
5050
- if (Path.isAncestor(_op4, p) || Path.equals(_op4, p)) {
5051
- var copy = onp.slice();
5041
+ case 'move_node':
5042
+ {
5043
+ var _op4 = operation.path,
5044
+ onp = operation.newPath; // If the old and new path are the same, it's a no-op.
5052
5045
 
5053
- if (Path.endsBefore(_op4, onp) && _op4.length < onp.length) {
5054
- copy[_op4.length - 1] -= 1;
5055
- }
5046
+ if (Path.equals(_op4, onp)) {
5047
+ return p;
5048
+ }
5056
5049
 
5057
- return copy.concat(p.slice(_op4.length));
5058
- } else if (Path.isSibling(_op4, onp) && (Path.isAncestor(onp, p) || Path.equals(onp, p))) {
5059
- if (Path.endsBefore(_op4, p)) {
5060
- p[_op4.length - 1] -= 1;
5061
- } else {
5062
- p[_op4.length - 1] += 1;
5063
- }
5064
- } else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
5065
- if (Path.endsBefore(_op4, p)) {
5066
- p[_op4.length - 1] -= 1;
5067
- }
5050
+ if (Path.isAncestor(_op4, p) || Path.equals(_op4, p)) {
5051
+ var copy = onp.slice();
5068
5052
 
5069
- p[onp.length - 1] += 1;
5070
- } else if (Path.endsBefore(_op4, p)) {
5071
- if (Path.equals(onp, p)) {
5072
- p[onp.length - 1] += 1;
5073
- }
5053
+ if (Path.endsBefore(_op4, onp) && _op4.length < onp.length) {
5054
+ copy[_op4.length - 1] -= 1;
5055
+ }
5074
5056
 
5057
+ return copy.concat(p.slice(_op4.length));
5058
+ } else if (Path.isSibling(_op4, onp) && (Path.isAncestor(onp, p) || Path.equals(onp, p))) {
5059
+ if (Path.endsBefore(_op4, p)) {
5060
+ p[_op4.length - 1] -= 1;
5061
+ } else {
5062
+ p[_op4.length - 1] += 1;
5063
+ }
5064
+ } else if (Path.endsBefore(onp, p) || Path.equals(onp, p) || Path.isAncestor(onp, p)) {
5065
+ if (Path.endsBefore(_op4, p)) {
5075
5066
  p[_op4.length - 1] -= 1;
5076
5067
  }
5077
5068
 
5078
- break;
5069
+ p[onp.length - 1] += 1;
5070
+ } else if (Path.endsBefore(_op4, p)) {
5071
+ if (Path.equals(onp, p)) {
5072
+ p[onp.length - 1] += 1;
5073
+ }
5074
+
5075
+ p[_op4.length - 1] -= 1;
5079
5076
  }
5080
- }
5081
- });
5077
+
5078
+ break;
5079
+ }
5080
+ }
5081
+
5082
+ return p;
5082
5083
  }
5083
5084
  };
5084
5085
 
@@ -7766,15 +7767,15 @@
7766
7767
 
7767
7768
  var _entry = _slicedToArray(entry, 2),
7768
7769
  _node2 = _entry[0],
7769
- _path3 = _entry[1];
7770
+ _path2 = _entry[1];
7770
7771
 
7771
- if (lastPath && Path.compare(_path3, lastPath) === 0) {
7772
+ if (lastPath && Path.compare(_path2, lastPath) === 0) {
7772
7773
  continue;
7773
7774
  }
7774
7775
 
7775
- if (!voids && Editor.isVoid(editor, _node2) || !Path.isCommon(_path3, start.path) && !Path.isCommon(_path3, end.path)) {
7776
+ if (!voids && Editor.isVoid(editor, _node2) || !Path.isCommon(_path2, start.path) && !Path.isCommon(_path2, end.path)) {
7776
7777
  matches.push(entry);
7777
- lastPath = _path3;
7778
+ lastPath = _path2;
7778
7779
  }
7779
7780
  }
7780
7781
  } catch (err) {
@@ -7816,16 +7817,16 @@
7816
7817
  }
7817
7818
  }
7818
7819
 
7819
- for (var _i = 0, _pathRefs = pathRefs; _i < _pathRefs.length; _i++) {
7820
- var pathRef = _pathRefs[_i];
7821
-
7822
- var _path = pathRef.unref();
7823
-
7824
- Transforms.removeNodes(editor, {
7825
- at: _path,
7820
+ pathRefs.reverse().map(function (r) {
7821
+ return r.unref();
7822
+ }).filter(function (r) {
7823
+ return r !== null;
7824
+ }).forEach(function (p) {
7825
+ return Transforms.removeNodes(editor, {
7826
+ at: p,
7826
7827
  voids: voids
7827
7828
  });
7828
- }
7829
+ });
7829
7830
 
7830
7831
  if (!endVoid) {
7831
7832
  var _point2 = endRef.current;
@@ -7834,7 +7835,7 @@
7834
7835
  _Editor$leaf4 = _slicedToArray(_Editor$leaf3, 1),
7835
7836
  _node = _Editor$leaf4[0];
7836
7837
 
7837
- var _path2 = _point2.path;
7838
+ var _path = _point2.path;
7838
7839
 
7839
7840
  var _offset = isSingleText ? start.offset : 0;
7840
7841
 
@@ -7843,7 +7844,7 @@
7843
7844
  if (_text.length > 0) {
7844
7845
  editor.apply({
7845
7846
  type: 'remove_text',
7846
- path: _path2,
7847
+ path: _path,
7847
7848
  offset: _offset,
7848
7849
  text: _text
7849
7850
  });
@@ -8037,8 +8038,8 @@
8037
8038
  var starting = true;
8038
8039
  var hasBlocks = false;
8039
8040
 
8040
- for (var _i2 = 0, _matches = matches; _i2 < _matches.length; _i2++) {
8041
- var _matches$_i = _slicedToArray(_matches[_i2], 1),
8041
+ for (var _i = 0, _matches = matches; _i < _matches.length; _i++) {
8042
+ var _matches$_i = _slicedToArray(_matches[_i], 1),
8042
8043
  node = _matches$_i[0];
8043
8044
 
8044
8045
  if (Element.isElement(node) && !editor.isInline(node)) {