Fix popup window opened with cmd+click is blank (#253)

This commit is contained in:
Quang Lam 2020-05-12 18:04:42 +07:00 committed by GitHub
parent 4991cb6f33
commit 5d7686bda1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 50 deletions

View file

@ -25,7 +25,7 @@
"cheerio": "1.0.0-rc.3",
"darkreader": "4.9.2",
"download": "8.0.0",
"electron-context-menu": "2.0.0",
"electron-context-menu": "2.0.1",
"electron-is-dev": "1.2.0",
"electron-settings": "3.2.0",
"electron-updater": "4.3.1",
@ -43,7 +43,7 @@
},
"devDependencies": {
"@date-io/date-fns": "1.3.13",
"@material-ui/core": "4.9.13",
"@material-ui/core": "4.9.14",
"@material-ui/icons": "4.9.1",
"@material-ui/pickers": "3.2.10",
"ace-builds": "1.4.11",

View file

@ -130,15 +130,16 @@ const addView = (browserWindow, workspace) => {
ses.setSpellCheckerLanguages(spellcheckLanguages);
}
const sharedWebPreferences = {
spellcheck,
nativeWindowOpen: true,
nodeIntegration: false,
contextIsolation: true,
session: ses,
preload: path.join(__dirname, '..', 'preload', 'view.js'),
};
const view = new BrowserView({
webPreferences: {
spellcheck,
nativeWindowOpen: true,
nodeIntegration: false,
contextIsolation: true,
session: ses,
preload: path.join(__dirname, '..', 'preload', 'view.js'),
},
webPreferences: sharedWebPreferences,
});
// background needs to explictly set
// if not, by default, the background of BrowserView is transparent
@ -338,9 +339,17 @@ const addView = (browserWindow, workspace) => {
const openInNewWindow = () => {
// https://gist.github.com/Gvozd/2cec0c8c510a707854e439fb15c561b0
e.preventDefault();
const newOptions = {
...options,
};
// if 'new-window' is triggered with Cmd+Click
// options is undefined
// https://github.com/atomery/webcatalog/issues/842
const cmdClick = Boolean(!options);
const newOptions = cmdClick ? {
show: true,
width: 800,
height: 600,
webPreferences: sharedWebPreferences,
} : options;
const popupWin = new BrowserWindow(newOptions);
// WebCatalog internal value to determine whether BrowserWindow is popup
popupWin.isPopup = true;
@ -363,6 +372,13 @@ const addView = (browserWindow, workspace) => {
}
});
// if 'new-window' is triggered with Cmd+Click
// url is not loaded automatically
// https://github.com/atomery/webcatalog/issues/842
if (cmdClick) {
popupWin.loadURL(nextUrl);
}
e.newGuest = popupWin;
};

View file

@ -1680,16 +1680,15 @@
core-js "^3.4.1"
regenerator-runtime "^0.13.3"
"@material-ui/core@4.9.13":
version "4.9.13"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.9.13.tgz#024962bcdda05139e1bad17a1815bf4088702b15"
integrity sha512-GEXNwUr+laZ0N+F1efmHB64Fyg+uQIRXLqbSejg3ebSXgLYNpIjnMOPRfWdu4rICq0dAIgvvNXGkKDMcf3AMpA==
"@material-ui/core@4.9.14":
version "4.9.14"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.9.14.tgz#4388f82cf94554cd3a935774fc12820f3c607a8a"
integrity sha512-71oYrOpInx5honJ9GzZlygPjmsFhn7Bui61/SWLJsPTkMnfvuZfU3qVqlEHjXyDsnZ+uKmLAIdsrOYnphJxxXw==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/react-transition-group" "^4.3.0"
"@material-ui/styles" "^4.9.13"
"@material-ui/system" "^4.9.13"
"@material-ui/types" "^5.0.1"
"@material-ui/styles" "^4.9.14"
"@material-ui/system" "^4.9.14"
"@material-ui/types" "^5.1.0"
"@material-ui/utils" "^4.9.12"
"@types/react-transition-group" "^4.2.0"
clsx "^1.0.4"
@ -1697,7 +1696,7 @@
popper.js "^1.16.1-lts"
prop-types "^15.7.2"
react-is "^16.8.0"
react-transition-group "^4.3.0"
react-transition-group "^4.4.0"
"@material-ui/icons@4.9.1":
version "4.9.1"
@ -1718,24 +1717,14 @@
react-transition-group "^4.0.0"
rifm "^0.7.0"
"@material-ui/react-transition-group@^4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@material-ui/react-transition-group/-/react-transition-group-4.3.0.tgz#92529142addb5cc179dbf42d246c7e3fe4d6104b"
integrity sha512-CwQ0aXrlUynUTY6sh3UvKuvye1o92en20VGAs6TORnSxUYeRmkX8YeTUN3lAkGiBX1z222FxLFO36WWh6q73rQ==
dependencies:
"@babel/runtime" "^7.5.5"
dom-helpers "^5.0.1"
loose-envify "^1.4.0"
prop-types "^15.6.2"
"@material-ui/styles@^4.9.13":
version "4.9.13"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.9.13.tgz#08b3976bdd21c38bc076693d95834f97539f3b15"
integrity sha512-lWlXJanBdHQ18jW/yphedRokHcvZD1GdGzUF/wQxKDsHwDDfO45ZkAxuSBI202dG+r1Ph483Z3pFykO2obeSRA==
"@material-ui/styles@^4.9.14":
version "4.9.14"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.9.14.tgz#0a9e93a2bf24e8daa0811411a6f3dabdafbe9a07"
integrity sha512-zecwWKgRU2VzdmutNovPB4s5LKI0TWyZKc/AHfPu9iY8tg4UoLjpa4Rn9roYrRfuTbBZHI6b0BXcQ8zkis0nzQ==
dependencies:
"@babel/runtime" "^7.4.4"
"@emotion/hash" "^0.8.0"
"@material-ui/types" "^5.0.1"
"@material-ui/types" "^5.1.0"
"@material-ui/utils" "^4.9.6"
clsx "^1.0.4"
csstype "^2.5.2"
@ -1750,19 +1739,20 @@
jss-plugin-vendor-prefixer "^10.0.3"
prop-types "^15.7.2"
"@material-ui/system@^4.9.13":
version "4.9.13"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.9.13.tgz#adefb3b6a5ddf0b00fe4e82ac63bb48276e9749d"
integrity sha512-6AlpvdW6KJJ5bF1Xo2OD13sCN8k+nlL36412/bWnWZOKIfIMo/Lb8c8d1DOIaT/RKWxTEUaWnKZjabVnA3eZjA==
"@material-ui/system@^4.9.14":
version "4.9.14"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.9.14.tgz#4b00c48b569340cefb2036d0596b93ac6c587a5f"
integrity sha512-oQbaqfSnNlEkXEziDcJDDIy8pbvwUmZXWNqlmIwDqr/ZdCK8FuV3f4nxikUh7hvClKV2gnQ9djh5CZFTHkZj3w==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.9.6"
csstype "^2.5.2"
prop-types "^15.7.2"
"@material-ui/types@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.0.1.tgz#c4954063cdc196eb327ee62c041368b1aebb6d61"
integrity sha512-wURPSY7/3+MAtng3i26g+WKwwNE3HEeqa/trDBR5+zWKmcjO+u9t7Npu/J1r+3dmIa/OeziN9D/18IrBKvKffw==
"@material-ui/types@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@material-ui/types/-/types-5.1.0.tgz#efa1c7a0b0eaa4c7c87ac0390445f0f88b0d88f2"
integrity sha512-7cqRjrY50b8QzRSYyhSpx4WRw2YuO0KKIGQEVk5J8uoz2BanawykgZGoWEqKm7pVIbzFDN0SpPcVV4IhOFkl8A==
"@material-ui/utils@^4.9.12":
version "4.9.12"
@ -5472,10 +5462,10 @@ electron-builder@22.6.0:
update-notifier "^4.1.0"
yargs "^15.3.1"
electron-context-menu@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/electron-context-menu/-/electron-context-menu-2.0.0.tgz#ea4d389b950425fe689e169eae9085187fe1f1b6"
integrity sha512-z6OQlUDgcu6wQ34JHEF1Y6QNXkEzOuEXdM4Tew853/4DsaCthKBbAo2BH+4y+49f89WjG9WOUTwGhEO4tY5mUw==
electron-context-menu@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/electron-context-menu/-/electron-context-menu-2.0.1.tgz#d44e421bbe2b58d2292ff442a9e0a5b8eeeb9d5e"
integrity sha512-klE6+PErH/l9IzoIm9PCcOaKvRtCuyjG8IYKcT376cEBhQwYtp3RsVKvLZ5jLhSLY0+rwgEl0LprBcW3NhM0+w==
dependencies:
cli-truncate "^2.0.0"
electron-dl "^3.0.0"
@ -11321,7 +11311,7 @@ react-sortable-hoc@1.11.0:
invariant "^2.2.4"
prop-types "^15.5.7"
react-transition-group@^4.0.0, react-transition-group@^4.3.0:
react-transition-group@^4.0.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.3.0.tgz#fea832e386cf8796c58b61874a3319704f5ce683"
integrity sha512-1qRV1ZuVSdxPlPf4O8t7inxUGpdyO5zG9IoNfJxSO0ImU2A1YWkEQvFPuIPZmMLkg5hYs7vv5mMOyfgSkvAwvw==
@ -11331,6 +11321,16 @@ react-transition-group@^4.0.0, react-transition-group@^4.3.0:
loose-envify "^1.4.0"
prop-types "^15.6.2"
react-transition-group@^4.4.0:
version "4.4.1"
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9"
integrity sha512-Djqr7OQ2aPUiYurhPalTrVy9ddmFCCzwhqQmtN+J3+3DzLO209Fdr70QrN8Z3DsglWql6iY1lDWAfpFiBtuKGw==
dependencies:
"@babel/runtime" "^7.5.5"
dom-helpers "^5.0.1"
loose-envify "^1.4.0"
prop-types "^15.6.2"
react@16.13.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e"