Skip to content

Commit 0afd89b

Browse files
authored
Merge pull request #209 from NativePHP/add-webPreferences-docs
add webPreferences to docs
2 parents dfbb61e + 6622b33 commit 0afd89b

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,4 @@ The `Native\Laravel\Events\MenuBar\MenuBarContextMenuOpened` event will be dispa
298298
Show only the context menu without opening a window when the menu bar icon is clicked:
299299
```php
300300
MenuBar::onlyShowContextMenu();
301-
```
301+
```

resources/views/docs/desktop/2/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/2/the-basics/windows.md

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

472+
### Setting webpage features
473+
474+
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.
475+
476+
```php
477+
Window::open()
478+
->webPreferences([
479+
'nodeIntegration' => true,
480+
'spellcheck' => true,
481+
'backgroundThrottling' => true,
482+
]);
483+
```
484+
485+
#### Default Settings
486+
487+
NativePHP sets the following defaults for security and compatibility:
488+
489+
```php
490+
[
491+
'sandbox' => false, // locked
492+
'preload' => '{preload-path}', // locked
493+
'contextIsolation' => true, // locked
494+
'spellcheck' => false,
495+
'nodeIntegration' => false,
496+
'backgroundThrottling' => false,
497+
]
498+
```
499+
500+
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.
501+
472502
## Events
473503

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

0 commit comments

Comments
 (0)