/*
  isPositionNearTableRow()
  Returns true when a sibling node, or any  of the parent's sibling
  nodes are a tableRow
 */
/**
 *
 * @param pos
 * @param schema
 * @param direction
 * @example
 */
export function isPositionNearTableRow(pos, schema, direction) {
  if (!schema.nodes.tableRow) {
    return false;
  }
  var doc = pos.doc;
  var resolved = pos;
  var sibling = direction === 'before' ? 'nodeBefore' : 'nodeAfter';
  while (resolved.depth > 0) {
    var _resolved$sibling;
    var siblingType = (_resolved$sibling = resolved[sibling]) === null || _resolved$sibling === void 0 ? void 0 : _resolved$sibling.type;
    if (siblingType === schema.nodes.tableRow) {
      return true;
    }
    resolved = doc.resolve(resolved[direction]());
  }
  return false;
}