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-7.16.0.pre.alpha1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.14.0.pre.alpha1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.16.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.15.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.15.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.14.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.13.0.pre.alpha1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.13.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.12.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.12.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.11.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.11.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.11.0.pre.alpha1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.10.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.9.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.8.4 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.8.3 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.8.2 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.8.1 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
playbook_ui-7.8.0 app/pb_kits/playbook/pb_rich_text_editor/useFocus.js