function copySelection (doc, selection) {
  if (!selection) throw new Error("'selection' is mandatory.")
  let copy = null
  if (!selection.isNull() && !selection.isCollapsed()) {
    // return a simplified version if only a piece of text is selected
    if (selection.isPropertySelection()) {
      copy = _copyPropertySelection(doc, selection)
    } else if (selection.isContainerSelection()) {
      copy = _copyContainerSelection(doc, selection)
    } else if (selection.isNodeSelection()) {
      copy = _copyNodeSelection(doc, selection)
    } else {
      console.error('Copy is not yet supported for selection type.')
    }
  }
  return copy
}
Creates a new document instance containing only the selected content

  @param {Object} args object with `selection`
  @return {Object} with a `doc` property that has a fresh doc with the copied content