slate 0.88.1 → 0.90.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.
package/dist/index.js CHANGED
@@ -199,7 +199,6 @@ function _createForOfIteratorHelper$7(o, allowArrayLike) { var it = typeof Symbo
199
199
  function _unsupportedIterableToArray$7(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$7(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen); }
200
200
 
201
201
  function _arrayLikeToArray$7(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
202
- var nextEditorId = 0;
203
202
  /**
204
203
  * Create a new Slate `Editor` object.
205
204
  */
@@ -210,7 +209,6 @@ var createEditor = function createEditor() {
210
209
  operations: [],
211
210
  selection: null,
212
211
  marks: null,
213
- id: nextEditorId++,
214
212
  isInline: function isInline() {
215
213
  return false;
216
214
  },
@@ -1413,7 +1411,7 @@ var Editor = {
1413
1411
  */
1414
1412
  hasBlocks: function hasBlocks(editor, element) {
1415
1413
  return element.children.some(function (n) {
1416
- return Editor.isBlock(editor, n);
1414
+ return Element.isElement(n) && Editor.isBlock(editor, n);
1417
1415
  });
1418
1416
  },
1419
1417
 
@@ -1484,7 +1482,7 @@ var Editor = {
1484
1482
  * Check if a value is a block `Element` object.
1485
1483
  */
1486
1484
  isBlock: function isBlock(editor, value) {
1487
- return Element.isElement(value) && !editor.isInline(value);
1485
+ return !editor.isInline(value);
1488
1486
  },
1489
1487
 
1490
1488
  /**
@@ -1537,7 +1535,7 @@ var Editor = {
1537
1535
  * Check if a value is an inline `Element` object.
1538
1536
  */
1539
1537
  isInline: function isInline(editor, value) {
1540
- return Element.isElement(value) && editor.isInline(value);
1538
+ return editor.isInline(value);
1541
1539
  },
1542
1540
 
1543
1541
  /**
@@ -1565,7 +1563,7 @@ var Editor = {
1565
1563
  * Check if a value is a void `Element` object.
1566
1564
  */
1567
1565
  isVoid: function isVoid(editor, value) {
1568
- return Element.isElement(value) && editor.isVoid(value);
1566
+ return editor.isVoid(value);
1569
1567
  },
1570
1568
 
1571
1569
  /**
@@ -1629,7 +1627,7 @@ var Editor = {
1629
1627
 
1630
1628
  levels.push([n, p]);
1631
1629
 
1632
- if (!voids && Editor.isVoid(editor, n)) {
1630
+ if (!voids && Element.isElement(n) && Editor.isVoid(editor, n)) {
1633
1631
  break;
1634
1632
  }
1635
1633
  }
@@ -1695,14 +1693,14 @@ var Editor = {
1695
1693
  });
1696
1694
  var markedVoid = Editor.above(editor, {
1697
1695
  match: function match(n) {
1698
- return Editor.isVoid(editor, n) && editor.markableVoid(n);
1696
+ return Element.isElement(n) && Editor.isVoid(editor, n) && editor.markableVoid(n);
1699
1697
  }
1700
1698
  });
1701
1699
 
1702
1700
  if (!markedVoid) {
1703
1701
  var block = Editor.above(editor, {
1704
1702
  match: function match(n) {
1705
- return Editor.isBlock(editor, n);
1703
+ return Element.isElement(n) && Editor.isBlock(editor, n);
1706
1704
  }
1707
1705
  });
1708
1706
 
@@ -1850,7 +1848,7 @@ var Editor = {
1850
1848
  var _ref2 = _slicedToArray(_ref, 1),
1851
1849
  n = _ref2[0];
1852
1850
 
1853
- return voids ? false : Editor.isVoid(editor, n);
1851
+ return voids ? false : Element.isElement(n) && Editor.isVoid(editor, n);
1854
1852
  }
1855
1853
  });
1856
1854
  var matches = [];
@@ -2641,7 +2639,7 @@ var Editor = {
2641
2639
  var endBlock = Editor.above(editor, {
2642
2640
  at: end,
2643
2641
  match: function match(n) {
2644
- return Editor.isBlock(editor, n);
2642
+ return Element.isElement(n) && Editor.isBlock(editor, n);
2645
2643
  },
2646
2644
  voids: voids
2647
2645
  });
@@ -2699,7 +2697,7 @@ var Editor = {
2699
2697
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2700
2698
  return Editor.above(editor, _objectSpread$8(_objectSpread$8({}, options), {}, {
2701
2699
  match: function match(n) {
2702
- return Editor.isVoid(editor, n);
2700
+ return Element.isElement(n) && Editor.isVoid(editor, n);
2703
2701
  }
2704
2702
  }));
2705
2703
  },
@@ -5100,7 +5098,7 @@ var NodeTransforms = {
5100
5098
  };
5101
5099
  } else {
5102
5100
  match = function match(n) {
5103
- return Editor.isBlock(editor, n);
5101
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5104
5102
  };
5105
5103
  }
5106
5104
  }
@@ -5194,7 +5192,7 @@ var NodeTransforms = {
5194
5192
 
5195
5193
  if (match == null) {
5196
5194
  match = Path.isPath(at) ? matchPath(editor, at) : function (n) {
5197
- return Editor.isBlock(editor, n);
5195
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5198
5196
  };
5199
5197
  }
5200
5198
 
@@ -5308,7 +5306,7 @@ var NodeTransforms = {
5308
5306
  };
5309
5307
  } else {
5310
5308
  match = function match(n) {
5311
- return Editor.isBlock(editor, n);
5309
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5312
5310
  };
5313
5311
  }
5314
5312
  }
@@ -5476,7 +5474,7 @@ var NodeTransforms = {
5476
5474
 
5477
5475
  if (match == null) {
5478
5476
  match = Path.isPath(at) ? matchPath(editor, at) : function (n) {
5479
- return Editor.isBlock(editor, n);
5477
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5480
5478
  };
5481
5479
  }
5482
5480
 
@@ -5541,7 +5539,7 @@ var NodeTransforms = {
5541
5539
 
5542
5540
  if (match == null) {
5543
5541
  match = Path.isPath(at) ? matchPath(editor, at) : function (n) {
5544
- return Editor.isBlock(editor, n);
5542
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5545
5543
  };
5546
5544
  }
5547
5545
 
@@ -5609,7 +5607,7 @@ var NodeTransforms = {
5609
5607
 
5610
5608
  if (match == null) {
5611
5609
  match = Path.isPath(at) ? matchPath(editor, at) : function (n) {
5612
- return Editor.isBlock(editor, n);
5610
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5613
5611
  };
5614
5612
  }
5615
5613
 
@@ -5743,7 +5741,7 @@ var NodeTransforms = {
5743
5741
 
5744
5742
  if (match == null) {
5745
5743
  match = function match(n) {
5746
- return Editor.isBlock(editor, n);
5744
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5747
5745
  };
5748
5746
  }
5749
5747
 
@@ -5852,7 +5850,7 @@ var NodeTransforms = {
5852
5850
 
5853
5851
  var split = false;
5854
5852
 
5855
- if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {
5853
+ if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Element.isElement(node) && Editor.isVoid(editor, node)) {
5856
5854
  break;
5857
5855
  }
5858
5856
 
@@ -5944,7 +5942,7 @@ var NodeTransforms = {
5944
5942
 
5945
5943
  if (match == null) {
5946
5944
  match = Path.isPath(at) ? matchPath(editor, at) : function (n) {
5947
- return Editor.isBlock(editor, n);
5945
+ return Element.isElement(n) && Editor.isBlock(editor, n);
5948
5946
  };
5949
5947
  }
5950
5948
 
@@ -6037,11 +6035,11 @@ var NodeTransforms = {
6037
6035
  match = matchPath(editor, at);
6038
6036
  } else if (editor.isInline(element)) {
6039
6037
  match = function match(n) {
6040
- return Editor.isInline(editor, n) || Text.isText(n);
6038
+ return Element.isElement(n) && Editor.isInline(editor, n) || Text.isText(n);
6041
6039
  };
6042
6040
  } else {
6043
6041
  match = function match(n) {
6044
- return Editor.isBlock(editor, n);
6042
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6045
6043
  };
6046
6044
  }
6047
6045
  }
@@ -6075,7 +6073,7 @@ var NodeTransforms = {
6075
6073
  var roots = Array.from(Editor.nodes(editor, {
6076
6074
  at: at,
6077
6075
  match: editor.isInline(element) ? function (n) {
6078
- return Editor.isBlock(editor, n);
6076
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6079
6077
  } : function (n) {
6080
6078
  return Editor.isEditor(n);
6081
6079
  },
@@ -6479,14 +6477,14 @@ var TextTransforms = {
6479
6477
 
6480
6478
  var startBlock = Editor.above(editor, {
6481
6479
  match: function match(n) {
6482
- return Editor.isBlock(editor, n);
6480
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6483
6481
  },
6484
6482
  at: start,
6485
6483
  voids: voids
6486
6484
  });
6487
6485
  var endBlock = Editor.above(editor, {
6488
6486
  match: function match(n) {
6489
- return Editor.isBlock(editor, n);
6487
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6490
6488
  },
6491
6489
  at: end,
6492
6490
  voids: voids
@@ -6541,7 +6539,7 @@ var TextTransforms = {
6541
6539
  continue;
6542
6540
  }
6543
6541
 
6544
- if (!voids && Editor.isVoid(editor, _node2) || !Path.isCommon(_path2, start.path) && !Path.isCommon(_path2, end.path)) {
6542
+ if (!voids && Element.isElement(_node2) && Editor.isVoid(editor, _node2) || !Path.isCommon(_path2, start.path) && !Path.isCommon(_path2, end.path)) {
6545
6543
  matches.push(entry);
6546
6544
  lastPath = _path2;
6547
6545
  }
@@ -6705,7 +6703,7 @@ var TextTransforms = {
6705
6703
  var inlineElementMatch = Editor.above(editor, {
6706
6704
  at: at,
6707
6705
  match: function match(n) {
6708
- return Editor.isInline(editor, n);
6706
+ return Element.isElement(n) && Editor.isInline(editor, n);
6709
6707
  },
6710
6708
  mode: 'highest',
6711
6709
  voids: voids
@@ -6726,7 +6724,7 @@ var TextTransforms = {
6726
6724
 
6727
6725
  var blockMatch = Editor.above(editor, {
6728
6726
  match: function match(n) {
6729
- return Editor.isBlock(editor, n);
6727
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6730
6728
  },
6731
6729
  at: at,
6732
6730
  voids: voids
@@ -6844,7 +6842,7 @@ var TextTransforms = {
6844
6842
  Transforms.splitNodes(editor, {
6845
6843
  at: at,
6846
6844
  match: function match(n) {
6847
- return hasBlocks ? Editor.isBlock(editor, n) : Text.isText(n) || Editor.isInline(editor, n);
6845
+ return hasBlocks ? Element.isElement(n) && Editor.isBlock(editor, n) : Text.isText(n) || Editor.isInline(editor, n);
6848
6846
  },
6849
6847
  mode: hasBlocks ? 'lowest' : 'highest',
6850
6848
  always: hasBlocks && (!isBlockStart || starts.length > 0) && (!isBlockEnd || ends.length > 0),
@@ -6870,7 +6868,7 @@ var TextTransforms = {
6870
6868
  Transforms.insertNodes(editor, middles, {
6871
6869
  at: middleRef.current,
6872
6870
  match: function match(n) {
6873
- return Editor.isBlock(editor, n);
6871
+ return Element.isElement(n) && Editor.isBlock(editor, n);
6874
6872
  },
6875
6873
  mode: 'lowest',
6876
6874
  voids: voids