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