import { Range, Editor, Element, Node } from "slate";
const overrideDeleteBackward = (editor) => {
  const { deleteBackward } = editor;
  editor.deleteBackward = (unit) => {
    const selection = editor.selection;
    if (selection && Range.isCollapsed(selection)) {
      const [node, nodePath] = Editor.node(editor, [selection.focus.path[0]]);
      if (Element.isElement(node) && Node.string(node) === "") {
        const previous = Editor.previous(editor, {
          at: nodePath,
          voids: true
        });
        if (previous) {
          const [previousNode] = previous;
          if (Element.isElement(previousNode) && editor.isVoid(previousNode)) {
            editor.apply({
              type: "remove_node",
              path: nodePath,
              node
            });
            return;
          }
        }
      }
    }
    deleteBackward(unit);
  };
};
export { overrideDeleteBackward };
//# sourceMappingURL=overrideDeleteBackward.js.map
