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.10.0.pre.alpha.PLAY705phonenumberreturn372 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.10.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.1.pre.alpha.play664tiptapinvestigation353 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.1.pre.alpha.PLAY689bugtxtinputlabel346 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.1.pre.alpha.menucleanup345 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.1.pre.alpha.menucleanup342 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.9.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark301 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark300 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.PLAY649mapkitstyles299 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep298 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep297 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease296 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease295 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0.pre.alpha.rubyandnpmalpharelease294 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.8.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease293 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease292 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease291 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js