slate 0.76.1 → 0.77.0-202231217352

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/index.es.js CHANGED
@@ -4893,92 +4893,98 @@ var NodeTransforms = {
4893
4893
  var beforeRef = Editor.pointRef(editor, at, {
4894
4894
  affinity: 'backward'
4895
4895
  });
4896
- var [highest] = Editor.nodes(editor, {
4897
- at,
4898
- match,
4899
- mode,
4900
- voids
4901
- });
4896
+ var afterRef;
4902
4897
 
4903
- if (!highest) {
4904
- return;
4905
- }
4898
+ try {
4899
+ var [highest] = Editor.nodes(editor, {
4900
+ at,
4901
+ match,
4902
+ mode,
4903
+ voids
4904
+ });
4906
4905
 
4907
- var voidMatch = Editor.void(editor, {
4908
- at,
4909
- mode: 'highest'
4910
- });
4911
- var nudge = 0;
4906
+ if (!highest) {
4907
+ return;
4908
+ }
4909
+
4910
+ var voidMatch = Editor.void(editor, {
4911
+ at,
4912
+ mode: 'highest'
4913
+ });
4914
+ var nudge = 0;
4912
4915
 
4913
- if (!voids && voidMatch) {
4914
- var [voidNode, voidPath] = voidMatch;
4916
+ if (!voids && voidMatch) {
4917
+ var [voidNode, voidPath] = voidMatch;
4915
4918
 
4916
- if (Element.isElement(voidNode) && editor.isInline(voidNode)) {
4917
- var after = Editor.after(editor, voidPath);
4919
+ if (Element.isElement(voidNode) && editor.isInline(voidNode)) {
4920
+ var after = Editor.after(editor, voidPath);
4918
4921
 
4919
- if (!after) {
4920
- var text = {
4921
- text: ''
4922
- };
4923
- var afterPath = Path.next(voidPath);
4924
- Transforms.insertNodes(editor, text, {
4925
- at: afterPath,
4926
- voids
4927
- });
4928
- after = Editor.point(editor, afterPath);
4922
+ if (!after) {
4923
+ var text = {
4924
+ text: ''
4925
+ };
4926
+ var afterPath = Path.next(voidPath);
4927
+ Transforms.insertNodes(editor, text, {
4928
+ at: afterPath,
4929
+ voids
4930
+ });
4931
+ after = Editor.point(editor, afterPath);
4932
+ }
4933
+
4934
+ at = after;
4935
+ always = true;
4929
4936
  }
4930
4937
 
4931
- at = after;
4938
+ var siblingHeight = at.path.length - voidPath.length;
4939
+ height = siblingHeight + 1;
4932
4940
  always = true;
4933
4941
  }
4934
4942
 
4935
- var siblingHeight = at.path.length - voidPath.length;
4936
- height = siblingHeight + 1;
4937
- always = true;
4938
- }
4939
-
4940
- var afterRef = Editor.pointRef(editor, at);
4941
- var depth = at.path.length - height;
4942
- var [, highestPath] = highest;
4943
- var lowestPath = at.path.slice(0, depth);
4944
- var position = height === 0 ? at.offset : at.path[depth] + nudge;
4943
+ afterRef = Editor.pointRef(editor, at);
4944
+ var depth = at.path.length - height;
4945
+ var [, highestPath] = highest;
4946
+ var lowestPath = at.path.slice(0, depth);
4947
+ var position = height === 0 ? at.offset : at.path[depth] + nudge;
4945
4948
 
4946
- for (var [node, _path2] of Editor.levels(editor, {
4947
- at: lowestPath,
4948
- reverse: true,
4949
- voids
4950
- })) {
4951
- var split = false;
4949
+ for (var [node, _path2] of Editor.levels(editor, {
4950
+ at: lowestPath,
4951
+ reverse: true,
4952
+ voids
4953
+ })) {
4954
+ var split = false;
4952
4955
 
4953
- if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {
4954
- break;
4955
- }
4956
+ if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {
4957
+ break;
4958
+ }
4956
4959
 
4957
- var _point = beforeRef.current;
4958
- var isEnd = Editor.isEnd(editor, _point, _path2);
4960
+ var _point = beforeRef.current;
4961
+ var isEnd = Editor.isEnd(editor, _point, _path2);
4962
+
4963
+ if (always || !beforeRef || !Editor.isEdge(editor, _point, _path2)) {
4964
+ split = true;
4965
+ var properties = Node.extractProps(node);
4966
+ editor.apply({
4967
+ type: 'split_node',
4968
+ path: _path2,
4969
+ position,
4970
+ properties
4971
+ });
4972
+ }
4959
4973
 
4960
- if (always || !beforeRef || !Editor.isEdge(editor, _point, _path2)) {
4961
- split = true;
4962
- var properties = Node.extractProps(node);
4963
- editor.apply({
4964
- type: 'split_node',
4965
- path: _path2,
4966
- position,
4967
- properties
4968
- });
4974
+ position = _path2[_path2.length - 1] + (split || isEnd ? 1 : 0);
4969
4975
  }
4970
4976
 
4971
- position = _path2[_path2.length - 1] + (split || isEnd ? 1 : 0);
4972
- }
4977
+ if (options.at == null) {
4978
+ var _point2 = afterRef.current || Editor.end(editor, []);
4973
4979
 
4974
- if (options.at == null) {
4975
- var _point2 = afterRef.current || Editor.end(editor, []);
4980
+ Transforms.select(editor, _point2);
4981
+ }
4982
+ } finally {
4983
+ var _afterRef;
4976
4984
 
4977
- Transforms.select(editor, _point2);
4985
+ beforeRef.unref();
4986
+ (_afterRef = afterRef) === null || _afterRef === void 0 ? void 0 : _afterRef.unref();
4978
4987
  }
4979
-
4980
- beforeRef.unref();
4981
- afterRef.unref();
4982
4988
  });
4983
4989
  },
4984
4990
 
@@ -5619,7 +5625,9 @@ var TextTransforms = {
5619
5625
  });
5620
5626
  }
5621
5627
 
5622
- var point = reverse ? startRef.unref() || endRef.unref() : endRef.unref() || startRef.unref();
5628
+ var startUnref = startRef.unref();
5629
+ var endUnref = endRef.unref();
5630
+ var point = reverse ? startUnref || endUnref : endUnref || startUnref;
5623
5631
 
5624
5632
  if (options.at == null && point) {
5625
5633
  Transforms.select(editor, point);