import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
/**
 * Convert a block node to inline content suitable for task items
 */
export var convertBlockToInlineContent = function convertBlockToInlineContent(node, schema) {
  var _schema$nodes = schema.nodes,
    paragraph = _schema$nodes.paragraph,
    hardBreak = _schema$nodes.hardBreak;
  if (node.type === paragraph) {
    return _toConsumableArray(node.content.content);
  }
  if (node.isBlock) {
    var textContent = node.textContent;
    var lines = textContent.split('\n');
    var newText = [];
    lines.forEach(function (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];
};