@lvce-editor/renderer-process 30.53.0 → 30.53.1
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/rendererProcessMain.js +28 -0
- package/package.json +1 -1
|
@@ -9656,6 +9656,30 @@ const setDragData = (viewletId, dragData) => {
|
|
|
9656
9656
|
const getDragData = () => {
|
|
9657
9657
|
return getCurrent();
|
|
9658
9658
|
};
|
|
9659
|
+
const preserveComponentDomFocus = $Viewlet => {
|
|
9660
|
+
const $Active = document.activeElement;
|
|
9661
|
+
const hadFocus = $Active instanceof HTMLElement && $Viewlet.contains($Active);
|
|
9662
|
+
const hadRootFocus = $Active === $Viewlet;
|
|
9663
|
+
const name = $Active?.getAttribute('name');
|
|
9664
|
+
return $Replacement => {
|
|
9665
|
+
if (!hadFocus || !($Active instanceof HTMLElement)) {
|
|
9666
|
+
return;
|
|
9667
|
+
}
|
|
9668
|
+
let $Target;
|
|
9669
|
+
if ($Replacement.contains($Active)) {
|
|
9670
|
+
$Target = $Active;
|
|
9671
|
+
} else if (hadRootFocus) {
|
|
9672
|
+
$Target = $Replacement;
|
|
9673
|
+
} else if (name) {
|
|
9674
|
+
$Target = [...$Replacement.querySelectorAll('[name]')].find(element => element.getAttribute('name') === name);
|
|
9675
|
+
} else if ($Active.getAttribute('role') === 'tree') {
|
|
9676
|
+
$Target = $Replacement.querySelector('[role="tree"]');
|
|
9677
|
+
}
|
|
9678
|
+
$Target?.focus({
|
|
9679
|
+
preventScroll: true
|
|
9680
|
+
});
|
|
9681
|
+
};
|
|
9682
|
+
};
|
|
9659
9683
|
|
|
9660
9684
|
// Keep the actual patch baseline intact while a component DOM preview is displayed.
|
|
9661
9685
|
const restoreComponentDom = viewletId => {
|
|
@@ -9664,6 +9688,7 @@ const restoreComponentDom = viewletId => {
|
|
|
9664
9688
|
if (!$Original) {
|
|
9665
9689
|
return;
|
|
9666
9690
|
}
|
|
9691
|
+
const restoreFocus = preserveComponentDomFocus(instance.state.$Viewlet);
|
|
9667
9692
|
const references = instance.componentDomReferences || [];
|
|
9668
9693
|
for (const {
|
|
9669
9694
|
placeholder,
|
|
@@ -9687,6 +9712,7 @@ const restoreComponentDom = viewletId => {
|
|
|
9687
9712
|
$Viewlet: $Original
|
|
9688
9713
|
}
|
|
9689
9714
|
});
|
|
9715
|
+
restoreFocus($Original);
|
|
9690
9716
|
};
|
|
9691
9717
|
const setComponentDom = (viewletId, dom) => {
|
|
9692
9718
|
const instance = get$a(viewletId);
|
|
@@ -9696,6 +9722,7 @@ const setComponentDom = (viewletId, dom) => {
|
|
|
9696
9722
|
const {
|
|
9697
9723
|
$Viewlet
|
|
9698
9724
|
} = instance.state;
|
|
9725
|
+
const restoreFocus = preserveComponentDomFocus($Viewlet);
|
|
9699
9726
|
const $Original = instance.componentDomOriginal || $Viewlet;
|
|
9700
9727
|
const references = [...(instance.componentDomReferences || [])];
|
|
9701
9728
|
const newReferences = [];
|
|
@@ -9747,6 +9774,7 @@ const setComponentDom = (viewletId, dom) => {
|
|
|
9747
9774
|
$Viewlet: $Preview
|
|
9748
9775
|
}
|
|
9749
9776
|
});
|
|
9777
|
+
restoreFocus($Preview);
|
|
9750
9778
|
};
|
|
9751
9779
|
const getComponentDom = viewletId => get$a(viewletId)?.componentDom;
|
|
9752
9780
|
const setDom = (viewletId, dom) => {
|