From 3a8e8ac94b0b68f277a494d14bbffe6a7a12565e Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Wed, 10 Sep 2025 15:18:48 +0200 Subject: [PATCH 1/2] add webPreferences to docs --- .../docs/desktop/1/the-basics/menu-bar.md | 15 ++++++++++ .../docs/desktop/1/the-basics/windows.md | 30 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/resources/views/docs/desktop/1/the-basics/menu-bar.md b/resources/views/docs/desktop/1/the-basics/menu-bar.md index 6f1ec98d..d63b8665 100644 --- a/resources/views/docs/desktop/1/the-basics/menu-bar.md +++ b/resources/views/docs/desktop/1/the-basics/menu-bar.md @@ -252,6 +252,21 @@ MenuBar::create() To learn more about the `Menu` facade, please refer to the [Application Menu](/docs/the-basics/application-menu) documentation. +### Setting webpage features + +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. + +```php +MenuBar::create() + ->webPreferences([ + 'nodeIntegration' => true, + 'spellcheck' => true, + 'backgroundThrottling' => true, + ]); +``` + +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). + ## Events NativePHP provides a simple way to listen for menu bar events. diff --git a/resources/views/docs/desktop/1/the-basics/windows.md b/resources/views/docs/desktop/1/the-basics/windows.md index 9809bddf..253eeb8e 100644 --- a/resources/views/docs/desktop/1/the-basics/windows.md +++ b/resources/views/docs/desktop/1/the-basics/windows.md @@ -468,6 +468,36 @@ In order to keep the window draggable, you should add an HTML element with the f ``` +### Setting webpage features + +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. + +```php +Window::open() + ->webPreferences([ + 'nodeIntegration' => true, + 'spellcheck' => true, + 'backgroundThrottling' => true, + ]); +``` + +#### Default Settings + +NativePHP sets the following defaults for security and compatibility: + +```php +[ + 'sandbox' => false, // locked + 'preload' => '{preload-path}', // locked + 'contextIsolation' => true, // locked + 'spellcheck' => false, + 'nodeIntegration' => false, + 'backgroundThrottling' => false, +] +``` + +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. + ## Events NativePHP provides a simple way to listen for native window events. From 6622b3308ba4293f06d1c3f3951f391f2ab8da93 Mon Sep 17 00:00:00 2001 From: gwleuverink Date: Tue, 30 Sep 2025 16:28:12 +0200 Subject: [PATCH 2/2] target v2 branch --- .../docs/desktop/1/the-basics/menu-bar.md | 17 +---------- .../docs/desktop/1/the-basics/windows.md | 30 ------------------- .../docs/desktop/2/the-basics/menu-bar.md | 15 ++++++++++ .../docs/desktop/2/the-basics/windows.md | 30 +++++++++++++++++++ 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/resources/views/docs/desktop/1/the-basics/menu-bar.md b/resources/views/docs/desktop/1/the-basics/menu-bar.md index d63b8665..ca9df764 100644 --- a/resources/views/docs/desktop/1/the-basics/menu-bar.md +++ b/resources/views/docs/desktop/1/the-basics/menu-bar.md @@ -252,21 +252,6 @@ MenuBar::create() To learn more about the `Menu` facade, please refer to the [Application Menu](/docs/the-basics/application-menu) documentation. -### Setting webpage features - -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. - -```php -MenuBar::create() - ->webPreferences([ - 'nodeIntegration' => true, - 'spellcheck' => true, - 'backgroundThrottling' => true, - ]); -``` - -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). - ## Events NativePHP provides a simple way to listen for menu bar events. @@ -313,4 +298,4 @@ The `Native\Laravel\Events\MenuBar\MenuBarContextMenuOpened` event will be dispa Show only the context menu without opening a window when the menu bar icon is clicked: ```php MenuBar::onlyShowContextMenu(); -``` +``` \ No newline at end of file diff --git a/resources/views/docs/desktop/1/the-basics/windows.md b/resources/views/docs/desktop/1/the-basics/windows.md index 253eeb8e..9809bddf 100644 --- a/resources/views/docs/desktop/1/the-basics/windows.md +++ b/resources/views/docs/desktop/1/the-basics/windows.md @@ -468,36 +468,6 @@ In order to keep the window draggable, you should add an HTML element with the f ``` -### Setting webpage features - -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. - -```php -Window::open() - ->webPreferences([ - 'nodeIntegration' => true, - 'spellcheck' => true, - 'backgroundThrottling' => true, - ]); -``` - -#### Default Settings - -NativePHP sets the following defaults for security and compatibility: - -```php -[ - 'sandbox' => false, // locked - 'preload' => '{preload-path}', // locked - 'contextIsolation' => true, // locked - 'spellcheck' => false, - 'nodeIntegration' => false, - 'backgroundThrottling' => false, -] -``` - -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. - ## Events NativePHP provides a simple way to listen for native window events. diff --git a/resources/views/docs/desktop/2/the-basics/menu-bar.md b/resources/views/docs/desktop/2/the-basics/menu-bar.md index 65591a32..bd306d45 100644 --- a/resources/views/docs/desktop/2/the-basics/menu-bar.md +++ b/resources/views/docs/desktop/2/the-basics/menu-bar.md @@ -252,6 +252,21 @@ MenuBar::create() To learn more about the `Menu` facade, please refer to the [Application Menu](/docs/the-basics/application-menu) documentation. +### Setting webpage features + +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. + +```php +MenuBar::create() + ->webPreferences([ + 'nodeIntegration' => true, + 'spellcheck' => true, + 'backgroundThrottling' => true, + ]); +``` + +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). + ## Events NativePHP provides a simple way to listen for menu bar events. diff --git a/resources/views/docs/desktop/2/the-basics/windows.md b/resources/views/docs/desktop/2/the-basics/windows.md index bb0b7aed..f49c3628 100644 --- a/resources/views/docs/desktop/2/the-basics/windows.md +++ b/resources/views/docs/desktop/2/the-basics/windows.md @@ -469,6 +469,36 @@ In order to keep the window draggable, you should add an HTML element with the f ``` +### Setting webpage features + +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. + +```php +Window::open() + ->webPreferences([ + 'nodeIntegration' => true, + 'spellcheck' => true, + 'backgroundThrottling' => true, + ]); +``` + +#### Default Settings + +NativePHP sets the following defaults for security and compatibility: + +```php +[ + 'sandbox' => false, // locked + 'preload' => '{preload-path}', // locked + 'contextIsolation' => true, // locked + 'spellcheck' => false, + 'nodeIntegration' => false, + 'backgroundThrottling' => false, +] +``` + +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. + ## Events NativePHP provides a simple way to listen for native window events.