// List type utilities
export const isBulletOrOrderedList = nodeType => {
  return nodeType.name === 'bulletList' || nodeType.name === 'orderedList';
};
export const isTaskList = nodeType => {
  return nodeType.name === 'taskList';
};
export const getSupportedListTypes = nodes => {
  return [nodes.bulletList, nodes.orderedList, nodes.taskList].filter(Boolean);
};
export const getSupportedListTypesSet = nodes => {
  return new Set(getSupportedListTypes(nodes));
};

/**
 * Convert a block node to inline content suitable for task items
 */
export const convertBlockToInlineContent = (node, schema) => {
  const {
    paragraph,
    hardBreak
  } = schema.nodes;
  if (node.type === paragraph) {
    return [...node.content.content];
  }
  if (node.isBlock) {
    const textContent = node.textContent;
    const lines = textContent.split('\n');
    const newText = [];
    lines.forEach((line, index) => {
      if (line !== '') {
        newText.push(line ? schema.text(line) : schema.text(' '));
      }
      if (lines.length > 1 && index !== lines.length - 1) {
        newText.push(hardBreak.create());
      }
    });
    return newText;
  }
  return [node];
};