function clearTextLayer(layer) {
  // get original text
  let originalText = getOriginalText(layer)

  // check if there is original text stored for the layer
  if (originalText) {
    // set original text
    layer.setStringValue(originalText)

    // refresh and resize
    Layers.refreshTextLayer(layer)
  }

  // clear any data populator metadata
  removeLayerMetadata(layer)
}
Clears the text layer.

@param {MSTextLayer} layer