Sha256: 19d9f225c58ccaf4b3b41dbac1661d2408c3952fe05cdd235d3cc50d02d438fc

Contents?: true

Size: 675 Bytes

Versions: 300

Compression:

Stored size: 675 Bytes

Contents

const useFocus = () => {
  const allTrixEditors = document.querySelectorAll(
    '.focus-editor-targets trix-editor'
  )
  allTrixEditors.forEach((editorElement) => {
    const toolbarElement = editorElement.toolbarElement
    if (editorElement == document.activeElement) {
      editorElement.classList.add('focused-editor')
      toolbarElement.style.display = 'block'
    } else {
      // don't hide the toolbar if we've unfocused to focus on the link dialog.
      if (!toolbarElement.contains(document.activeElement)) {
        editorElement.classList.remove('focused-editor')
        toolbarElement.style.display = 'none'
      }
    }
  })
}

export default useFocus

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
playbook_ui-12.7.1.pre.alpha.alpharubyrelease281 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1.pre.alpha.menu2 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1.pre.alpha.menu1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.6.0.pre.alpha.sectionseparator1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.6.0.pre.alpha.menuyml1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.6.0.pre.alpha.collapsible1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.6.0.pre.alpha.cssphone1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.6.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.5.0.pre.alpha.datepickerinput1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.5.0.pre.alpha.phonerails1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.5.0.pre.alpha.filter1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.5.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.4.0.pre.alpha.map1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.4.0.pre.alpha.devdocstest1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.4.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.3.1.pre.alpha.phone1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.3.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js