"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.hasNode = exports.hasMark = exports.hasBlock = exports.findSingleNode = exports.findParentNode = void 0;

var findSingleNode = function findSingleNode(value) {
  if (!value || !value.isCollapsed || !value.startKey) {
    return;
  }

  var inline = value.document.getClosestInline(value.startKey);

  if (inline) {
    return inline;
  }

  var block = value.document.getClosestBlock(value.startKey);

  if (block) {
    return block;
  }
};

exports.findSingleNode = findSingleNode;

var findParentNode = function findParentNode(value, node) {
  if (!value || !node) {
    return;
  }

  return value.document.getParent(node.key);
};

exports.findParentNode = findParentNode;

var hasMark = function hasMark(value, type) {
  return value && value.marks.some(function (mark) {
    return mark.type == type;
  });
};

exports.hasMark = hasMark;

var hasBlock = function hasBlock(value, type) {
  return value && value.blocks.some(function (node) {
    return node.type == type;
  });
};

exports.hasBlock = hasBlock;

var hasNode = function hasNode(_ref, type) {
  var document = _ref.document;
  return document && document.nodes.some(function (node) {
    return node.type == type;
  });
};

exports.hasNode = hasNode;
//# sourceMappingURL=utils.js.map