createDocumentState = (markdownDocument, id = getUniqueId()) => {
  const docState = cloneObj(defaultFileState, true)
  const {
    markdown,
    filename,
    pathname,
    encoding,
    lineEnding,
    adjustLineEndingOnSave,
    trimTrailingNewline,
    cursor = null
  } = markdownDocument

  assertLineEnding(adjustLineEndingOnSave, lineEnding)

  return Object.assign(docState, {
    id,
    markdown,
    filename,
    pathname,
    encoding,
    lineEnding,
    cursor,
    adjustLineEndingOnSave,
    trimTrailingNewline
  })
}
Creates a internal document from the given document.

@param {IMarkdownDocument} markdownDocument Markdown document
@param {String} [id] Random identifier
@returns {IDocumentState} Returns a document state