src/document/doc-utils.js/stripTrailingHardline
function stripTrailingHardline(doc, withInnerParts = false) {
  // HACK remove ending hardline, original PR: #1984
  if (doc.type === "concat" && doc.parts.length !== 0) {
    const parts = withInnerParts ? getInnerParts(doc) : doc.parts;
    const lastPart = parts[parts.length - 1];
    if (lastPart.type === "concat") {
      if (
        lastPart.parts.length === 2 &&
        lastPart.parts[0].hard &&
        lastPart.parts[1].type === "break-parent"
      ) {
        return { type: "concat", parts: parts.slice(0, -1) };
      }

      return {
        type: "concat",
        parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart)),
      };
    }
  }

  return doc;
}