UNPKG

@atlaskit/editor-plugin-toolbar

Version:

Toolbar plugin for @atlaskit/editor-core

25 lines (23 loc) 940 B
export const isEventInContainer = (event, containerSelector) => { const target = event.target instanceof Element ? event.target : null; if (!target) { return false; } return !!target.closest(containerSelector); }; export const isShortcutToFocusToolbar = event => { return event.altKey && event.key === 'F10'; }; export const getFocusableElements = rootNode => { if (!rootNode) { return []; } const focusableElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || []; const focusableElementsArray = Array.from(focusableElements); // filter out focusable elements from child components such as dropdown menus / popups return focusableElementsArray.filter(elm => { const style = window.getComputedStyle(elm); // filter out invisible elements return style.visibility !== 'hidden' && style.display !== 'none'; }); };