Skip to content

Commit 3a8e8ac

Browse files
committed
add webPreferences to docs
1 parent 2cdc57e commit 3a8e8ac

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

resources/views/docs/desktop/1/the-basics/menu-bar.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,21 @@ MenuBar::create()
252252

253253
To learn more about the `Menu` facade, please refer to the [Application Menu](/docs/the-basics/application-menu) documentation.
254254

255+
### Setting webpage features
256+
257+
You may control various web page features by passing an optional `webPreferences` configuration array, similar to how it works with [Windows](/docs/the-basics/windows#setting-webpage-features). This allows you to customize how the menu bar window behaves and what features are available to the web content.
258+
259+
```php
260+
MenuBar::create()
261+
->webPreferences([
262+
'nodeIntegration' => true,
263+
'spellcheck' => true,
264+
'backgroundThrottling' => true,
265+
]);
266+
```
267+
268+
The same defaults and restrictions apply as with Windows. For more details about available options and default settings, see the [Windows documentation](/docs/the-basics/windows#setting-webpage-features).
269+
255270
## Events
256271

257272
NativePHP provides a simple way to listen for menu bar events.

resources/views/docs/desktop/1/the-basics/windows.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,36 @@ In order to keep the window draggable, you should add an HTML element with the f
468468
</div>
469469
```
470470

471+
### Setting webpage features
472+
473+
You may control various web page features by passing an optional `webPreferences` configuration array. This allows you to customize how the Electron window behaves and what features are available to the web content.
474+
475+
```php
476+
Window::open()
477+
->webPreferences([
478+
'nodeIntegration' => true,
479+
'spellcheck' => true,
480+
'backgroundThrottling' => true,
481+
]);
482+
```
483+
484+
#### Default Settings
485+
486+
NativePHP sets the following defaults for security and compatibility:
487+
488+
```php
489+
[
490+
'sandbox' => false, // locked
491+
'preload' => '{preload-path}', // locked
492+
'contextIsolation' => true, // locked
493+
'spellcheck' => false,
494+
'nodeIntegration' => false,
495+
'backgroundThrottling' => false,
496+
]
497+
```
498+
499+
The `preload`, `contextIsolation`, and `sandbox` options are locked and cannot be changed for security reasons. All other options from the [Electron WebPreferences documentation](https://www.electronjs.org/docs/latest/api/structures/web-preferences) may be passed and will override the defaults.
500+
471501
## Events
472502

473503
NativePHP provides a simple way to listen for native window events.

0 commit comments

Comments
 (0)