slate-react 0.147.0 → 0.147.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.js CHANGED
@@ -1731,6 +1731,14 @@ var getEmptyBlockDirection = function getEmptyBlockDirection(element) {
1731
1731
  var after = parent.children.slice(index + 1);
1732
1732
  return (_findSiblingDirection = findSiblingDirection(before)) !== null && _findSiblingDirection !== void 0 ? _findSiblingDirection : findSiblingDirection(after);
1733
1733
  };
1734
+ var getMountedChildren = function getMountedChildren(editor, element) {
1735
+ return slate.Editor.isVoid(editor, element) ? [slate.Node.texts(element).next().value[0]] : element.children;
1736
+ };
1737
+ var findUnmountedChild = function findUnmountedChild(editor, element) {
1738
+ return getMountedChildren(editor, element).findIndex(function (child) {
1739
+ return !slateDom.NODE_TO_ELEMENT.has(child);
1740
+ });
1741
+ };
1734
1742
  var defaultRenderElement = function defaultRenderElement(props) {
1735
1743
  return /*#__PURE__*/React.createElement(DefaultElement, _objectSpread$3({}, props));
1736
1744
  };
@@ -1763,6 +1771,14 @@ var Element = function Element(props) {
1763
1771
  slateDom.NODE_TO_ELEMENT["delete"](element);
1764
1772
  }
1765
1773
  }, [editor, key, element]);
1774
+ useIsomorphicLayoutEffect(function () {
1775
+ var index = findUnmountedChild(editor, element);
1776
+ if (index !== -1) {
1777
+ var type = element.type;
1778
+ var path = ReactEditor.findPath(editor, element);
1779
+ editor.onDOMError(new Error("renderElement didn't render the children of the ".concat(typeof type === 'string' ? "\"".concat(type, "\" ") : '', "element at path ").concat(JSON.stringify(path), ": child ").concat(index, " has no DOM node. Render the `children` prop inside the element.")));
1780
+ }
1781
+ }, [editor, element]);
1766
1782
  var children = useChildren({
1767
1783
  decorations: decorations,
1768
1784
  node: element,