moveSelectedToLayer = layerName => {
  const { BatchCommand, MoveElementCommand } = svgCanvas.history
  // find the layer
  const drawing = svgCanvas.getCurrentDrawing()
  const layer = drawing.getLayerByName(layerName)
  if (!layer) {
    return false
  }

  const batchCmd = new BatchCommand('Move Elements to Layer')

  // loop for each selected element and move it
  const selElems = svgCanvas.getSelectedElements()
  let i = selElems.length
  while (i--) {
    const elem = selElems[i]
    if (!elem) {
      continue
    }
    const oldNextSibling = elem.nextSibling
    // TODO: this is pretty brittle!
    const oldLayer = elem.parentNode
    layer.append(elem)
    batchCmd.addSubCommand(
      new MoveElementCommand(elem, oldNextSibling, oldLayer)
    )
  }

  svgCanvas.addCommandToHistory(batchCmd)

  return true
}
Moves the selected elements to layerName. If the name is not a valid layer name, then `false`
is returned. Otherwise it returns `true`. This is an undo-able action.
@function module:draw.moveSelectedToLayer
@param {string} layerName - The name of the layer you want to which you want to move the selected elements
@returns {boolean} Whether the selected elements were moved to the layer.