export var canLinkBeCreatedInRange = function canLinkBeCreatedInRange(from, to) {
  return function (state) {
    if (!state.doc.rangeHasMark(from, to, state.schema.marks.link)) {
      var $from = state.doc.resolve(from);
      var $to = state.doc.resolve(to);
      var link = state.schema.marks.link;
      if ($from.parent === $to.parent && $from.parent.isTextblock) {
        if ($from.parent.type.allowsMarkType(link)) {
          var allowed = true;
          state.doc.nodesBetween(from, to, function (node) {
            var hasInlineCard = node.type === state.schema.nodes.inlineCard;
            allowed = allowed && !node.marks.some(function (m) {
              return m.type.excludes(link);
            }) && !hasInlineCard;
            return allowed;
          });
          return allowed;
        }
      }
    }
    return false;
  };
};