import { Transforms, Text, Node } from "slate";
import deepEqual from "../../utils/deepEqual";
function isTextEqual(a, b) {
  const { text: aText, ...aRest } = a;
  const { text: bText, ...bRest } = b;
  return deepEqual(aRest, bRest);
}
function normalizeSimilarText(editor, entry) {
  const [node, path] = entry;
  if (Text.isText(node))
    return false;
  let hasMergedNodes = false;
  for (let i = node.children.length; i > 0; i--) {
    const currentNode = Node.get(editor, path);
    if (Text.isText(currentNode))
      continue;
    const child = currentNode.children[i];
    const prev = currentNode.children[i - 1];
    if (Text.isText(child) && prev != null && Text.isText(prev) && isTextEqual(child, prev)) {
      Transforms.mergeNodes(editor, { at: path.concat(i), voids: true });
      hasMergedNodes = true;
    }
  }
  return hasMergedNodes;
}
export {
  normalizeSimilarText
};
//# sourceMappingURL=normalizeSimilarText.js.map