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.
@@ -1 +1 @@
1
- {"version":3,"file":"create-editor.d.ts","sourceRoot":"","sources":["packages/slate/src/create-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAYP,MAAM,IAAI,CAAA;AAMX;;GAEG;AAEH,eAAO,MAAM,YAAY,QAAO,MA4Y/B,CAAA"}
1
+ {"version":3,"file":"create-editor.d.ts","sourceRoot":"","sources":["packages/slate/src/create-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAYP,MAAM,IAAI,CAAA;AAIX;;GAEG;AAEH,eAAO,MAAM,YAAY,QAAO,MA2Y/B,CAAA"}
package/dist/index.es.js CHANGED
@@ -27,7 +27,6 @@ var RANGE_REFS = new WeakMap();
27
27
  function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
28
28
 
29
29
  function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
30
- var nextEditorId = 0;
31
30
  /**
32
31
  * Create a new Slate `Editor` object.
33
32
  */
@@ -38,7 +37,6 @@ var createEditor = () => {
38
37
  operations: [],
39
38
  selection: null,
40
39
  marks: null,
41
- id: nextEditorId++,
42
40
  isInline: () => false,
43
41
  isVoid: () => false,
44
42
  markableVoid: () => false,
@@ -1082,7 +1080,7 @@ var Editor = {
1082
1080
  * Check if a node has block children.
1083
1081
  */
1084
1082
  hasBlocks(editor, element) {
1085
- return element.children.some(n => Editor.isBlock(editor, n));
1083
+ return element.children.some(n => Element.isElement(n) && Editor.isBlock(editor, n));
1086
1084
  },
1087
1085
 
1088
1086
  /**
@@ -1148,7 +1146,7 @@ var Editor = {
1148
1146
  * Check if a value is a block `Element` object.
1149
1147
  */
1150
1148
  isBlock(editor, value) {
1151
- return Element.isElement(value) && !editor.isInline(value);
1149
+ return !editor.isInline(value);
1152
1150
  },
1153
1151
 
1154
1152
  /**
@@ -1200,7 +1198,7 @@ var Editor = {
1200
1198
  * Check if a value is an inline `Element` object.
1201
1199
  */
1202
1200
  isInline(editor, value) {
1203
- return Element.isElement(value) && editor.isInline(value);
1201
+ return editor.isInline(value);
1204
1202
  },
1205
1203
 
1206
1204
  /**
@@ -1228,7 +1226,7 @@ var Editor = {
1228
1226
  * Check if a value is a void `Element` object.
1229
1227
  */
1230
1228
  isVoid(editor, value) {
1231
- return Element.isElement(value) && editor.isVoid(value);
1229
+ return editor.isVoid(value);
1232
1230
  },
1233
1231
 
1234
1232
  /**
@@ -1283,7 +1281,7 @@ var Editor = {
1283
1281
 
1284
1282
  levels.push([n, p]);
1285
1283
 
1286
- if (!voids && Editor.isVoid(editor, n)) {
1284
+ if (!voids && Element.isElement(n) && Editor.isVoid(editor, n)) {
1287
1285
  break;
1288
1286
  }
1289
1287
  }
@@ -1342,12 +1340,12 @@ var Editor = {
1342
1340
  match: Text.isText
1343
1341
  });
1344
1342
  var markedVoid = Editor.above(editor, {
1345
- match: n => Editor.isVoid(editor, n) && editor.markableVoid(n)
1343
+ match: n => Element.isElement(n) && Editor.isVoid(editor, n) && editor.markableVoid(n)
1346
1344
  });
1347
1345
 
1348
1346
  if (!markedVoid) {
1349
1347
  var block = Editor.above(editor, {
1350
- match: n => Editor.isBlock(editor, n)
1348
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n)
1351
1349
  });
1352
1350
 
1353
1351
  if (prev && block) {
@@ -1471,7 +1469,7 @@ var Editor = {
1471
1469
  to,
1472
1470
  pass: _ref => {
1473
1471
  var [n] = _ref;
1474
- return voids ? false : Editor.isVoid(editor, n);
1472
+ return voids ? false : Element.isElement(n) && Editor.isVoid(editor, n);
1475
1473
  }
1476
1474
  });
1477
1475
  var matches = [];
@@ -2183,7 +2181,7 @@ var Editor = {
2183
2181
 
2184
2182
  var endBlock = Editor.above(editor, {
2185
2183
  at: end,
2186
- match: n => Editor.isBlock(editor, n),
2184
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n),
2187
2185
  voids
2188
2186
  });
2189
2187
  var blockPath = endBlock ? endBlock[1] : [];
@@ -2226,7 +2224,7 @@ var Editor = {
2226
2224
  void(editor) {
2227
2225
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2228
2226
  return Editor.above(editor, _objectSpread$8(_objectSpread$8({}, options), {}, {
2229
- match: n => Editor.isVoid(editor, n)
2227
+ match: n => Element.isElement(n) && Editor.isVoid(editor, n)
2230
2228
  }));
2231
2229
  },
2232
2230
 
@@ -4419,7 +4417,7 @@ var NodeTransforms = {
4419
4417
  } else if (editor.isInline(node)) {
4420
4418
  match = n => Text.isText(n) || Editor.isInline(editor, n);
4421
4419
  } else {
4422
- match = n => Editor.isBlock(editor, n);
4420
+ match = n => Element.isElement(n) && Editor.isBlock(editor, n);
4423
4421
  }
4424
4422
  }
4425
4423
 
@@ -4497,7 +4495,7 @@ var NodeTransforms = {
4497
4495
  } = options;
4498
4496
 
4499
4497
  if (match == null) {
4500
- match = Path.isPath(at) ? matchPath(editor, at) : n => Editor.isBlock(editor, n);
4498
+ match = Path.isPath(at) ? matchPath(editor, at) : n => Element.isElement(n) && Editor.isBlock(editor, n);
4501
4499
  }
4502
4500
 
4503
4501
  if (!at) {
@@ -4600,7 +4598,7 @@ var NodeTransforms = {
4600
4598
 
4601
4599
  match = n => parent.children.includes(n);
4602
4600
  } else {
4603
- match = n => Editor.isBlock(editor, n);
4601
+ match = n => Element.isElement(n) && Editor.isBlock(editor, n);
4604
4602
  }
4605
4603
  }
4606
4604
 
@@ -4750,7 +4748,7 @@ var NodeTransforms = {
4750
4748
  }
4751
4749
 
4752
4750
  if (match == null) {
4753
- match = Path.isPath(at) ? matchPath(editor, at) : n => Editor.isBlock(editor, n);
4751
+ match = Path.isPath(at) ? matchPath(editor, at) : n => Element.isElement(n) && Editor.isBlock(editor, n);
4754
4752
  }
4755
4753
 
4756
4754
  var toRef = Editor.pathRef(editor, to);
@@ -4810,7 +4808,7 @@ var NodeTransforms = {
4810
4808
  }
4811
4809
 
4812
4810
  if (match == null) {
4813
- match = Path.isPath(at) ? matchPath(editor, at) : n => Editor.isBlock(editor, n);
4811
+ match = Path.isPath(at) ? matchPath(editor, at) : n => Element.isElement(n) && Editor.isBlock(editor, n);
4814
4812
  }
4815
4813
 
4816
4814
  if (!hanging && Range.isRange(at)) {
@@ -4869,7 +4867,7 @@ var NodeTransforms = {
4869
4867
  }
4870
4868
 
4871
4869
  if (match == null) {
4872
- match = Path.isPath(at) ? matchPath(editor, at) : n => Editor.isBlock(editor, n);
4870
+ match = Path.isPath(at) ? matchPath(editor, at) : n => Element.isElement(n) && Editor.isBlock(editor, n);
4873
4871
  }
4874
4872
 
4875
4873
  if (!hanging && Range.isRange(at)) {
@@ -4980,7 +4978,7 @@ var NodeTransforms = {
4980
4978
  } = options;
4981
4979
 
4982
4980
  if (match == null) {
4983
- match = n => Editor.isBlock(editor, n);
4981
+ match = n => Element.isElement(n) && Editor.isBlock(editor, n);
4984
4982
  }
4985
4983
 
4986
4984
  if (Range.isRange(at)) {
@@ -5068,7 +5066,7 @@ var NodeTransforms = {
5068
5066
  })) {
5069
5067
  var split = false;
5070
5068
 
5071
- if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Editor.isVoid(editor, node)) {
5069
+ if (_path2.length < highestPath.length || _path2.length === 0 || !voids && Element.isElement(node) && Editor.isVoid(editor, node)) {
5072
5070
  break;
5073
5071
  }
5074
5072
 
@@ -5144,7 +5142,7 @@ var NodeTransforms = {
5144
5142
  }
5145
5143
 
5146
5144
  if (match == null) {
5147
- match = Path.isPath(at) ? matchPath(editor, at) : n => Editor.isBlock(editor, n);
5145
+ match = Path.isPath(at) ? matchPath(editor, at) : n => Element.isElement(n) && Editor.isBlock(editor, n);
5148
5146
  }
5149
5147
 
5150
5148
  if (Path.isPath(at)) {
@@ -5217,9 +5215,9 @@ var NodeTransforms = {
5217
5215
  if (Path.isPath(at)) {
5218
5216
  match = matchPath(editor, at);
5219
5217
  } else if (editor.isInline(element)) {
5220
- match = n => Editor.isInline(editor, n) || Text.isText(n);
5218
+ match = n => Element.isElement(n) && Editor.isInline(editor, n) || Text.isText(n);
5221
5219
  } else {
5222
- match = n => Editor.isBlock(editor, n);
5220
+ match = n => Element.isElement(n) && Editor.isBlock(editor, n);
5223
5221
  }
5224
5222
  }
5225
5223
 
@@ -5247,7 +5245,7 @@ var NodeTransforms = {
5247
5245
 
5248
5246
  var roots = Array.from(Editor.nodes(editor, {
5249
5247
  at,
5250
- match: editor.isInline(element) ? n => Editor.isBlock(editor, n) : n => Editor.isEditor(n),
5248
+ match: editor.isInline(element) ? n => Element.isElement(n) && Editor.isBlock(editor, n) : n => Editor.isEditor(n),
5251
5249
  mode: 'lowest',
5252
5250
  voids
5253
5251
  }));
@@ -5624,12 +5622,12 @@ var TextTransforms = {
5624
5622
 
5625
5623
  var [start, end] = Range.edges(at);
5626
5624
  var startBlock = Editor.above(editor, {
5627
- match: n => Editor.isBlock(editor, n),
5625
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n),
5628
5626
  at: start,
5629
5627
  voids
5630
5628
  });
5631
5629
  var endBlock = Editor.above(editor, {
5632
- match: n => Editor.isBlock(editor, n),
5630
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n),
5633
5631
  at: end,
5634
5632
  voids
5635
5633
  });
@@ -5675,7 +5673,7 @@ var TextTransforms = {
5675
5673
  continue;
5676
5674
  }
5677
5675
 
5678
- if (!voids && Editor.isVoid(editor, node) || !Path.isCommon(path, start.path) && !Path.isCommon(path, end.path)) {
5676
+ if (!voids && Element.isElement(node) && Editor.isVoid(editor, node) || !Path.isCommon(path, start.path) && !Path.isCommon(path, end.path)) {
5679
5677
  matches.push(entry);
5680
5678
  lastPath = path;
5681
5679
  }
@@ -5822,7 +5820,7 @@ var TextTransforms = {
5822
5820
 
5823
5821
  var inlineElementMatch = Editor.above(editor, {
5824
5822
  at,
5825
- match: n => Editor.isInline(editor, n),
5823
+ match: n => Element.isElement(n) && Editor.isInline(editor, n),
5826
5824
  mode: 'highest',
5827
5825
  voids
5828
5826
  });
@@ -5840,7 +5838,7 @@ var TextTransforms = {
5840
5838
  }
5841
5839
 
5842
5840
  var blockMatch = Editor.above(editor, {
5843
- match: n => Editor.isBlock(editor, n),
5841
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n),
5844
5842
  at,
5845
5843
  voids
5846
5844
  });
@@ -5922,7 +5920,7 @@ var TextTransforms = {
5922
5920
  var endRef = Editor.pathRef(editor, isInlineEnd ? Path.next(inlinePath) : inlinePath);
5923
5921
  Transforms.splitNodes(editor, {
5924
5922
  at,
5925
- match: n => hasBlocks ? Editor.isBlock(editor, n) : Text.isText(n) || Editor.isInline(editor, n),
5923
+ match: n => hasBlocks ? Element.isElement(n) && Editor.isBlock(editor, n) : Text.isText(n) || Editor.isInline(editor, n),
5926
5924
  mode: hasBlocks ? 'lowest' : 'highest',
5927
5925
  always: hasBlocks && (!isBlockStart || starts.length > 0) && (!isBlockEnd || ends.length > 0),
5928
5926
  voids
@@ -5944,7 +5942,7 @@ var TextTransforms = {
5944
5942
 
5945
5943
  Transforms.insertNodes(editor, middles, {
5946
5944
  at: middleRef.current,
5947
- match: n => Editor.isBlock(editor, n),
5945
+ match: n => Element.isElement(n) && Editor.isBlock(editor, n),
5948
5946
  mode: 'lowest',
5949
5947
  voids
5950
5948
  });