slate-react 0.76.0-20222247328 → 0.76.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":"with-react.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/plugin/with-react.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAc5C;;;;;;;GAOG;AAEH,eAAO,MAAM,SAAS,uDAsOrB,CAAA"}
1
+ {"version":3,"file":"with-react.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/plugin/with-react.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAc5C;;;;;;;GAOG;AAEH,eAAO,MAAM,SAAS,uDAkOrB,CAAA"}
@@ -1450,21 +1450,6 @@
1450
1450
  return editor;
1451
1451
  };
1452
1452
 
1453
- /**
1454
- * A React context for sharing the `decorate` prop of the editable.
1455
- */
1456
-
1457
- var DecorateContext = /*#__PURE__*/React.createContext(function () {
1458
- return [];
1459
- });
1460
- /**
1461
- * Get the current `decorate` prop of the editable.
1462
- */
1463
-
1464
- var useDecorate = function useDecorate() {
1465
- return React.useContext(DecorateContext);
1466
- };
1467
-
1468
1453
  /**
1469
1454
  * A React context for sharing the `selected` state of an element.
1470
1455
  */
@@ -1489,7 +1474,6 @@
1489
1474
  renderPlaceholder = props.renderPlaceholder,
1490
1475
  renderLeaf = props.renderLeaf,
1491
1476
  selection = props.selection;
1492
- useDecorate();
1493
1477
  var editor = useSlateStatic();
1494
1478
  var path = ReactEditor.findPath(editor, node);
1495
1479
  var children = [];
@@ -1501,9 +1485,11 @@
1501
1485
  var key = ReactEditor.findKey(editor, n);
1502
1486
  var range = slate.Editor.range(editor, p);
1503
1487
  var sel = selection && slate.Range.intersection(range, selection);
1504
- var ds = decorations.filter(function (dec) {
1505
- return slate.Range.intersection(dec, range);
1506
- });
1488
+ var ds = decorations.reduce(function (acc, dec) {
1489
+ var intersection = slate.Range.intersection(dec, range);
1490
+ if (intersection) acc.push(intersection);
1491
+ return acc;
1492
+ }, []);
1507
1493
 
1508
1494
  if (slate.Element.isElement(n)) {
1509
1495
  children.push( /*#__PURE__*/React__default['default'].createElement(SelectedContext.Provider, {
@@ -1924,6 +1910,14 @@
1924
1910
  return editor;
1925
1911
  };
1926
1912
 
1913
+ /**
1914
+ * A React context for sharing the `decorate` prop of the editable.
1915
+ */
1916
+
1917
+ var DecorateContext = /*#__PURE__*/React.createContext(function () {
1918
+ return [];
1919
+ });
1920
+
1927
1921
  /**
1928
1922
  * Returns the host window of a DOM node
1929
1923
  */
@@ -32838,7 +32832,9 @@
32838
32832
  }
32839
32833
  }
32840
32834
  }
32841
- };
32835
+ }; // This attempts to reset the NODE_TO_KEY entry to the correct value
32836
+ // as apply() changes the object reference and hence invalidates the NODE_TO_KEY entry
32837
+
32842
32838
 
32843
32839
  e.apply = function (op) {
32844
32840
  var matches = [];
@@ -32847,82 +32843,30 @@
32847
32843
  case 'insert_text':
32848
32844
  case 'remove_text':
32849
32845
  case 'set_node':
32846
+ case 'split_node':
32850
32847
  {
32851
- var _iterator = _createForOfIteratorHelper(slate.Editor.levels(e, {
32852
- at: op.path
32853
- })),
32854
- _step;
32855
-
32856
- try {
32857
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
32858
- var _step$value = _slicedToArray(_step.value, 2),
32859
- node = _step$value[0],
32860
- path = _step$value[1];
32861
-
32862
- var key = ReactEditor.findKey(e, node);
32863
- matches.push([path, key]);
32864
- }
32865
- } catch (err) {
32866
- _iterator.e(err);
32867
- } finally {
32868
- _iterator.f();
32869
- }
32870
-
32848
+ matches.push.apply(matches, _toConsumableArray(getMatches(e, op.path)));
32871
32849
  break;
32872
32850
  }
32873
32851
 
32874
32852
  case 'insert_node':
32875
32853
  case 'remove_node':
32876
- case 'merge_node':
32877
- case 'split_node':
32878
32854
  {
32879
- var _iterator2 = _createForOfIteratorHelper(slate.Editor.levels(e, {
32880
- at: slate.Path.parent(op.path)
32881
- })),
32882
- _step2;
32883
-
32884
- try {
32885
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
32886
- var _step2$value = _slicedToArray(_step2.value, 2),
32887
- _node = _step2$value[0],
32888
- _path = _step2$value[1];
32889
-
32890
- var _key = ReactEditor.findKey(e, _node);
32891
-
32892
- matches.push([_path, _key]);
32893
- }
32894
- } catch (err) {
32895
- _iterator2.e(err);
32896
- } finally {
32897
- _iterator2.f();
32898
- }
32855
+ matches.push.apply(matches, _toConsumableArray(getMatches(e, slate.Path.parent(op.path))));
32856
+ break;
32857
+ }
32899
32858
 
32859
+ case 'merge_node':
32860
+ {
32861
+ var prevPath = slate.Path.previous(op.path);
32862
+ matches.push.apply(matches, _toConsumableArray(getMatches(e, prevPath)));
32900
32863
  break;
32901
32864
  }
32902
32865
 
32903
32866
  case 'move_node':
32904
32867
  {
32905
- var _iterator3 = _createForOfIteratorHelper(slate.Editor.levels(e, {
32906
- at: slate.Path.common(slate.Path.parent(op.path), slate.Path.parent(op.newPath))
32907
- })),
32908
- _step3;
32909
-
32910
- try {
32911
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
32912
- var _step3$value = _slicedToArray(_step3.value, 2),
32913
- _node2 = _step3$value[0],
32914
- _path2 = _step3$value[1];
32915
-
32916
- var _key2 = ReactEditor.findKey(e, _node2);
32917
-
32918
- matches.push([_path2, _key2]);
32919
- }
32920
- } catch (err) {
32921
- _iterator3.e(err);
32922
- } finally {
32923
- _iterator3.f();
32924
- }
32925
-
32868
+ var commonPath = slate.Path.common(slate.Path.parent(op.path), slate.Path.parent(op.newPath));
32869
+ matches.push.apply(matches, _toConsumableArray(getMatches(e, commonPath)));
32926
32870
  break;
32927
32871
  }
32928
32872
  }
@@ -32931,14 +32875,14 @@
32931
32875
 
32932
32876
  for (var _i = 0, _matches = matches; _i < _matches.length; _i++) {
32933
32877
  var _matches$_i = _slicedToArray(_matches[_i], 2),
32934
- _path3 = _matches$_i[0],
32935
- _key3 = _matches$_i[1];
32878
+ path = _matches$_i[0],
32879
+ key = _matches$_i[1];
32936
32880
 
32937
- var _Editor$node = slate.Editor.node(e, _path3),
32881
+ var _Editor$node = slate.Editor.node(e, path),
32938
32882
  _Editor$node2 = _slicedToArray(_Editor$node, 1),
32939
- _node3 = _Editor$node2[0];
32883
+ node = _Editor$node2[0];
32940
32884
 
32941
- NODE_TO_KEY.set(_node3, _key3);
32885
+ NODE_TO_KEY.set(node, key);
32942
32886
  }
32943
32887
  };
32944
32888
 
@@ -33061,12 +33005,12 @@
33061
33005
  var lines = text.split(/\r\n|\r|\n/);
33062
33006
  var split = false;
33063
33007
 
33064
- var _iterator4 = _createForOfIteratorHelper(lines),
33065
- _step4;
33008
+ var _iterator = _createForOfIteratorHelper(lines),
33009
+ _step;
33066
33010
 
33067
33011
  try {
33068
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
33069
- var line = _step4.value;
33012
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33013
+ var line = _step.value;
33070
33014
 
33071
33015
  if (split) {
33072
33016
  slate.Transforms.splitNodes(e, {
@@ -33078,9 +33022,9 @@
33078
33022
  split = true;
33079
33023
  }
33080
33024
  } catch (err) {
33081
- _iterator4.e(err);
33025
+ _iterator.e(err);
33082
33026
  } finally {
33083
- _iterator4.f();
33027
+ _iterator.f();
33084
33028
  }
33085
33029
 
33086
33030
  return true;
@@ -33108,6 +33052,32 @@
33108
33052
  return e;
33109
33053
  };
33110
33054
 
33055
+ var getMatches = function getMatches(e, path) {
33056
+ var matches = [];
33057
+
33058
+ var _iterator2 = _createForOfIteratorHelper(slate.Editor.levels(e, {
33059
+ at: path
33060
+ })),
33061
+ _step2;
33062
+
33063
+ try {
33064
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
33065
+ var _step2$value = _slicedToArray(_step2.value, 2),
33066
+ n = _step2$value[0],
33067
+ p = _step2$value[1];
33068
+
33069
+ var key = ReactEditor.findKey(e, n);
33070
+ matches.push([p, key]);
33071
+ }
33072
+ } catch (err) {
33073
+ _iterator2.e(err);
33074
+ } finally {
33075
+ _iterator2.f();
33076
+ }
33077
+
33078
+ return matches;
33079
+ };
33080
+
33111
33081
  // Components
33112
33082
  var Editable = IS_ANDROID ? AndroidEditable : Editable$1;
33113
33083