slate 0.134.0 → 0.134.1

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
@@ -1885,8 +1885,19 @@ const Text = {
1885
1885
 
1886
1886
  function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1887
1887
  function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1888
- const insertChildren = (xs, index, ...newValues) => [...xs.slice(0, index), ...newValues, ...xs.slice(index)];
1889
- const replaceChildren = (xs, index, removeCount, ...newValues) => [...xs.slice(0, index), ...newValues, ...xs.slice(index + removeCount)];
1888
+ const insertChildren = (children, index, ...newValues) => {
1889
+ return replaceChildren(children, index, 0, ...newValues);
1890
+ };
1891
+ const replaceChildren = (children, index, removeCount, ...newValues) => {
1892
+ const out = children.slice();
1893
+ out.splice(index, removeCount, ...newValues);
1894
+ return out;
1895
+ };
1896
+ const replaceChild = (children, index, newValue) => {
1897
+ const out = children.slice();
1898
+ out[index] = newValue;
1899
+ return out;
1900
+ };
1890
1901
  const removeChildren = replaceChildren;
1891
1902
  /**
1892
1903
  * Replace a descendant with a new node, replacing all ancestors
@@ -1902,11 +1913,11 @@ const modifyDescendant = (root, path, f) => {
1902
1913
  const _index = slicedPath.pop();
1903
1914
  const ancestorNode = Node.get(root, slicedPath);
1904
1915
  modifiedNode = _objectSpread$b(_objectSpread$b({}, ancestorNode), {}, {
1905
- children: replaceChildren(ancestorNode.children, _index, 1, modifiedNode)
1916
+ children: replaceChild(ancestorNode.children, _index, modifiedNode)
1906
1917
  });
1907
1918
  }
1908
- const index = slicedPath.pop();
1909
- root.children = replaceChildren(root.children, index, 1, modifiedNode);
1919
+ const index = slicedPath[0];
1920
+ root.children = replaceChild(root.children, index, modifiedNode);
1910
1921
  };
1911
1922
  /**
1912
1923
  * Replace the children of a node, replacing all ancestors