@neovici/cosmoz-utils 6.17.1 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,10 @@ export type Info = {
|
|
|
4
4
|
title: string;
|
|
5
5
|
description: string;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type BindingOptions = {
|
|
8
|
+
allowInEditable?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type KeyBinding = readonly [Matcher, Activity[], Info, BindingOptions?];
|
|
8
11
|
export type ActivityHandler = {
|
|
9
12
|
activity: Activity;
|
|
10
13
|
callback: () => void;
|
|
@@ -11,10 +11,10 @@ export const useKeybindings = (bindings) => {
|
|
|
11
11
|
const binding = meta.bindings.find(matches(e));
|
|
12
12
|
if (!binding)
|
|
13
13
|
return;
|
|
14
|
-
|
|
14
|
+
const [, activities, , options] = binding;
|
|
15
|
+
if (!options?.allowInEditable && focusIsInEditableArea())
|
|
15
16
|
return;
|
|
16
|
-
const
|
|
17
|
-
const handlers = activities.flatMap((activity) => meta[activity]);
|
|
17
|
+
const handlers = activities.flatMap((activity) => meta[activity] ?? []);
|
|
18
18
|
if (handlers.length === 0)
|
|
19
19
|
return;
|
|
20
20
|
// find first actionable handler
|
|
@@ -3,7 +3,7 @@ export const isInteractive = (el) => {
|
|
|
3
3
|
if (el == null)
|
|
4
4
|
return false;
|
|
5
5
|
const bounds = el.getBoundingClientRect(), root = el.getRootNode(), topEl = root.elementFromPoint(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
|
|
6
|
-
return el === topEl;
|
|
6
|
+
return topEl != null && (el === topEl || el.contains(topEl));
|
|
7
7
|
};
|
|
8
8
|
const getActiveElement = (root = document) => {
|
|
9
9
|
const activeEl = root.activeElement;
|