function splitTextToDocs(node) {
    const text = getUnencodedText(node);
    let docs = text.split(/[\t\n\f\r ]+/);
    docs = join(line, docs).parts.filter((s) => s !== '');
    if (startsWithLinebreak(text)) {
        docs[0] = hardline;
    }
    if (startsWithLinebreak(text, 2)) {
        docs = [hardline, ...docs];
    }
    if (endsWithLinebreak(text)) {
        docs[docs.length - 1] = hardline;
    }
    if (endsWithLinebreak(text, 2)) {
        docs = [...docs, hardline];
    }
    return docs;
}
Split the text into words separated by whitespace. Replace the whitespaces by lines,
collapsing multiple whitespaces into a single line.

If the text starts or ends with multiple newlines, two of those should be kept.