@lvce-editor/virtual-dom 1.41.0 → 1.42.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.
package/dist/index.js
CHANGED
|
@@ -695,6 +695,20 @@ const getEventListenerMap = id => {
|
|
|
695
695
|
return map;
|
|
696
696
|
};
|
|
697
697
|
|
|
698
|
+
const getActiveElementInside = $Viewlet => {
|
|
699
|
+
if (!$Viewlet) {
|
|
700
|
+
return undefined;
|
|
701
|
+
}
|
|
702
|
+
const $ActiveElement = document.activeElement;
|
|
703
|
+
if (!$ActiveElement) {
|
|
704
|
+
return undefined;
|
|
705
|
+
}
|
|
706
|
+
if (!$Viewlet.contains($ActiveElement)) {
|
|
707
|
+
return undefined;
|
|
708
|
+
}
|
|
709
|
+
return $ActiveElement;
|
|
710
|
+
};
|
|
711
|
+
|
|
698
712
|
const queryInputs = $Viewlet => {
|
|
699
713
|
return [...$Viewlet.querySelectorAll('input, textarea')];
|
|
700
714
|
};
|
|
@@ -725,9 +739,7 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
|
|
|
725
739
|
const oldTop = $Viewlet.style.top;
|
|
726
740
|
const oldWidth = $Viewlet.style.width;
|
|
727
741
|
const oldHeight = $Viewlet.style.height;
|
|
728
|
-
const
|
|
729
|
-
activeElement
|
|
730
|
-
} = document;
|
|
742
|
+
const activeElement = getActiveElementInside($Viewlet);
|
|
731
743
|
const isTreeFocused = activeElement?.getAttribute('role') === 'tree';
|
|
732
744
|
const isRootTree = $Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet;
|
|
733
745
|
const focused = activeElement?.getAttribute('name');
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getActiveElementInside = (
|
|
2
|
+
$Viewlet: HTMLElement | undefined,
|
|
3
|
+
): HTMLElement | undefined => {
|
|
4
|
+
if (!$Viewlet) {
|
|
5
|
+
return undefined
|
|
6
|
+
}
|
|
7
|
+
const $ActiveElement = document.activeElement as HTMLElement
|
|
8
|
+
if (!$ActiveElement) {
|
|
9
|
+
return undefined
|
|
10
|
+
}
|
|
11
|
+
if (!$Viewlet.contains($ActiveElement)) {
|
|
12
|
+
return undefined
|
|
13
|
+
}
|
|
14
|
+
return $ActiveElement
|
|
15
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
|
|
2
2
|
import * as EventState from '../EventState/EventState.ts'
|
|
3
|
+
import { getActiveElementInside } from '../GetActiveElementInside/GetActiveElementInside.ts'
|
|
3
4
|
import * as QueryInputs from '../QueryInputs/QueryInputs.ts'
|
|
4
5
|
import * as RegisterEventListeners from '../RegisterEventListeners/RegisterEventListeners.ts'
|
|
5
6
|
import * as VirtualDom from '../VirtualDom/VirtualDom.ts'
|
|
@@ -15,7 +16,7 @@ export const rememberFocus = (
|
|
|
15
16
|
const oldTop = $Viewlet.style.top
|
|
16
17
|
const oldWidth = $Viewlet.style.width
|
|
17
18
|
const oldHeight = $Viewlet.style.height
|
|
18
|
-
const
|
|
19
|
+
const activeElement = getActiveElementInside($Viewlet)
|
|
19
20
|
const isTreeFocused = activeElement?.getAttribute('role') === 'tree'
|
|
20
21
|
const isRootTree =
|
|
21
22
|
$Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet
|