@lvce-editor/main-process 6.39.0 → 6.40.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/mainProcessMain.js +34 -14
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -5497,32 +5497,47 @@ const getElectronCallbacks = () => {
|
|
|
5497
5497
|
};
|
|
5498
5498
|
};
|
|
5499
5499
|
|
|
5500
|
-
const
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5500
|
+
const editingActions = new Set(['undo', 'redo', 'cut', 'copy', 'paste', 'selectAll']);
|
|
5501
|
+
const getElectronMenuItems = (menuItems, click, contents) => {
|
|
5502
|
+
return menuItems.map(menuItem => {
|
|
5503
|
+
const {
|
|
5504
|
+
role,
|
|
5505
|
+
...options
|
|
5506
|
+
} = menuItem;
|
|
5507
|
+
if (contents && editingActions.has(role)) {
|
|
5508
|
+
return {
|
|
5509
|
+
...options,
|
|
5510
|
+
click(item) {
|
|
5511
|
+
if (!contents.isDestroyed()) contents[role]();
|
|
5512
|
+
click(item);
|
|
5513
|
+
}
|
|
5514
|
+
};
|
|
5515
|
+
}
|
|
5516
|
+
return {
|
|
5505
5517
|
...menuItem,
|
|
5506
5518
|
click
|
|
5507
|
-
}
|
|
5508
|
-
}
|
|
5509
|
-
return template;
|
|
5519
|
+
};
|
|
5520
|
+
});
|
|
5510
5521
|
};
|
|
5511
5522
|
|
|
5512
|
-
const openContextMenu = async (menuItems, x, y) => {
|
|
5523
|
+
const openContextMenu = async (menuItems, x, y, browserViewId) => {
|
|
5513
5524
|
array(menuItems);
|
|
5514
5525
|
number(x);
|
|
5515
5526
|
number(y);
|
|
5527
|
+
const origin = browserViewId === undefined ? undefined : get$4(browserViewId);
|
|
5528
|
+
if (browserViewId !== undefined && (!origin || origin.view.webContents.isDestroyed())) return {
|
|
5529
|
+
data: undefined,
|
|
5530
|
+
type: 'close'
|
|
5531
|
+
};
|
|
5516
5532
|
const {
|
|
5517
5533
|
handleClick,
|
|
5518
5534
|
handleClose,
|
|
5519
5535
|
promise
|
|
5520
5536
|
} = getElectronCallbacks();
|
|
5521
|
-
const template = getElectronMenuItems(menuItems, handleClick);
|
|
5537
|
+
const template = getElectronMenuItems(menuItems, handleClick, origin?.view.webContents);
|
|
5522
5538
|
const menu = Menu.buildFromTemplate(template);
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
if (!window) {
|
|
5539
|
+
const window = origin?.browserWindow || BrowserWindow.getFocusedWindow();
|
|
5540
|
+
if (!window || window.isDestroyed()) {
|
|
5526
5541
|
return {
|
|
5527
5542
|
data: undefined,
|
|
5528
5543
|
type: 'close'
|
|
@@ -7039,6 +7054,11 @@ const getSession = () => {
|
|
|
7039
7054
|
|
|
7040
7055
|
const attach$1 = (webContents, parentWebContents) => {
|
|
7041
7056
|
let shouldRestoreParentFocus = false;
|
|
7057
|
+
const cancel = () => {
|
|
7058
|
+
shouldRestoreParentFocus = false;
|
|
7059
|
+
};
|
|
7060
|
+
parentWebContents.on('blur', cancel);
|
|
7061
|
+
webContents.once('destroyed', () => parentWebContents.off('blur', cancel));
|
|
7042
7062
|
webContents.on(DidStartNavigation, (_event, _url, _isInPlace, isMainFrame) => {
|
|
7043
7063
|
if (!isMainFrame) {
|
|
7044
7064
|
return;
|
|
@@ -7046,7 +7066,7 @@ const attach$1 = (webContents, parentWebContents) => {
|
|
|
7046
7066
|
shouldRestoreParentFocus = parentWebContents.isFocused();
|
|
7047
7067
|
});
|
|
7048
7068
|
webContents.on(DidNavigate, () => {
|
|
7049
|
-
if (!shouldRestoreParentFocus) {
|
|
7069
|
+
if (!shouldRestoreParentFocus || parentWebContents.isDestroyed()) {
|
|
7050
7070
|
return;
|
|
7051
7071
|
}
|
|
7052
7072
|
shouldRestoreParentFocus = false;
|