mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-03 14:17:29 +00:00
Add --browserwindow-options to completely expose Electron options (PR #835)
This adds a new flag `--browserwindow-options`, taking a stringified JSON object as input. It will be inserted directly into the options when BrowserConfig is initialized. This allows total configurability of the electron BrowserWindow configuration via nativefier. An example use case is added to the documentation, which modifies the default font family in the browser. #### References - https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions - See the following for electron v3.1.7 - https://github.com/electron/electron/blob/v3.1.7/docs/api/browser-window.md#new-browserwindowoptions
This commit is contained in:
parent
81c422d4e0
commit
d0a0614ba3
@ -104,6 +104,8 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const browserwindowOptions = Object.assign({}, options.browserwindowOptions);
|
||||||
|
|
||||||
const mainWindow = new BrowserWindow(
|
const mainWindow = new BrowserWindow(
|
||||||
Object.assign(
|
Object.assign(
|
||||||
{
|
{
|
||||||
@ -128,6 +130,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
|||||||
backgroundColor: options.backgroundColor,
|
backgroundColor: options.backgroundColor,
|
||||||
},
|
},
|
||||||
DEFAULT_WINDOW_OPTIONS,
|
DEFAULT_WINDOW_OPTIONS,
|
||||||
|
browserwindowOptions,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
16
docs/api.md
16
docs/api.md
@ -64,6 +64,7 @@
|
|||||||
- [[file-download-options]](#file-download-options)
|
- [[file-download-options]](#file-download-options)
|
||||||
- [[always-on-top]](#always-on-top)
|
- [[always-on-top]](#always-on-top)
|
||||||
- [[global-shortcuts]](#global-shortcuts)
|
- [[global-shortcuts]](#global-shortcuts)
|
||||||
|
- [[browserwindow-options]](#browserwindow-options)
|
||||||
- [[darwin-dark-mode-support]](#darwin-dark-mode-support)
|
- [[darwin-dark-mode-support]](#darwin-dark-mode-support)
|
||||||
- [[background-color]](#background-color)
|
- [[background-color]](#background-color)
|
||||||
- [Programmatic API](#programmatic-api)
|
- [Programmatic API](#programmatic-api)
|
||||||
@ -696,6 +697,21 @@ Example `shortcuts.json` for `https://deezer.com` & `https://soundcloud.com` to
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [browserwindow-options]
|
||||||
|
|
||||||
|
```
|
||||||
|
--browserwindow-options <json-string>
|
||||||
|
```
|
||||||
|
|
||||||
|
a JSON string that will be sent directly into electron BrowserWindow options.
|
||||||
|
See [Electron's BrowserWindow API Documentation](https://electronjs.org/docs/api/browser-window#new-browserwindowoptions) for the complete list of options.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nativefier <your-website> --browserwindow-options '{ "webPreferences": { "defaultFontFamily": { "standard": "Comic Sans MS", "serif": "Comic Sans MS" } } }'
|
||||||
|
```
|
||||||
|
|
||||||
#### [darwin-dark-mode-support]
|
#### [darwin-dark-mode-support]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -58,6 +58,7 @@ function selectAppArgs(options) {
|
|||||||
alwaysOnTop: options.alwaysOnTop,
|
alwaysOnTop: options.alwaysOnTop,
|
||||||
titleBarStyle: options.titleBarStyle,
|
titleBarStyle: options.titleBarStyle,
|
||||||
globalShortcuts: options.globalShortcuts,
|
globalShortcuts: options.globalShortcuts,
|
||||||
|
browserwindowOptions: options.browserwindowOptions,
|
||||||
backgroundColor: options.backgroundColor,
|
backgroundColor: options.backgroundColor,
|
||||||
darwinDarkModeSupport: options.darwinDarkModeSupport,
|
darwinDarkModeSupport: options.darwinDarkModeSupport,
|
||||||
};
|
};
|
||||||
|
@ -238,6 +238,11 @@ if (require.main === module) {
|
|||||||
'--global-shortcuts <value>',
|
'--global-shortcuts <value>',
|
||||||
'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts',
|
'JSON file with global shortcut configuration. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#global-shortcuts',
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
'--browserwindow-options <json-string>',
|
||||||
|
'a JSON string that will be sent directly into electron BrowserWindow options. See https://github.com/jiahaog/nativefier/blob/master/docs/api.md#browserwindow-options',
|
||||||
|
parseJson,
|
||||||
|
)
|
||||||
.option(
|
.option(
|
||||||
'--background-color <value>',
|
'--background-color <value>',
|
||||||
"Sets the background color (for seamless experience while the app is loading). Example value: '#2e2c29'",
|
"Sets the background color (for seamless experience while the app is loading). Example value: '#2e2c29'",
|
||||||
|
@ -77,6 +77,7 @@ export default function(inpOptions) {
|
|||||||
alwaysOnTop: inpOptions.alwaysOnTop || false,
|
alwaysOnTop: inpOptions.alwaysOnTop || false,
|
||||||
titleBarStyle: inpOptions.titleBarStyle || null,
|
titleBarStyle: inpOptions.titleBarStyle || null,
|
||||||
globalShortcuts: inpOptions.globalShortcuts || null,
|
globalShortcuts: inpOptions.globalShortcuts || null,
|
||||||
|
browserwindowOptions: inpOptions.browserwindowOptions,
|
||||||
backgroundColor: inpOptions.backgroundColor || null,
|
backgroundColor: inpOptions.backgroundColor || null,
|
||||||
darwinDarkModeSupport: inpOptions.darwinDarkModeSupport || false,
|
darwinDarkModeSupport: inpOptions.darwinDarkModeSupport || false,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user