function setSelectionOffset (params) {
  if (document.createRange && window.getSelection) {
    const selection = window.getSelection()
    if (selection) {
      const range = document.createRange()

      if (!params.container.firstChild) {
        params.container.appendChild(document.createTextNode(''))
      }

      // TODO: do not suppose that the first child of the container is a textnode,
      //       but recursively find the textnodes
      range.setStart(params.container.firstChild, params.startOffset)
      range.setEnd(params.container.firstChild, params.endOffset)

      setSelection(range)
    }
  }
}
Set selected text range in given element
@param {Object} params   An object containing:
                             {Element} container
                             {Number} startOffset
                             {Number} endOffset