chore: print error when removed webview attribute is used (#14230)
* chore: print error when removed webview attribute is used * docs: document removed webview features
This commit is contained in:
parent
82b75f863d
commit
cd8bb1d3b4
7 changed files with 48 additions and 76 deletions
|
@ -182,6 +182,10 @@ tray.setHighlightMode('off')
|
|||
webContents.openDevTools({detach: true})
|
||||
// Replace with
|
||||
webContents.openDevTools({mode: 'detach'})
|
||||
|
||||
// Removed
|
||||
webContents.setSize(options)
|
||||
// There is no replacement for this API
|
||||
```
|
||||
|
||||
## `webFrame`
|
||||
|
@ -198,6 +202,18 @@ webFrame.registerURLSchemeAsPrivileged('app', {secure: true})
|
|||
protocol.registerStandardSchemes(['app'], {secure: true})
|
||||
```
|
||||
|
||||
## `<webview>`
|
||||
|
||||
```js
|
||||
// Removed
|
||||
webview.setAttribute('disableguestresize', '')
|
||||
// There is no replacement for this API
|
||||
|
||||
// Removed
|
||||
webview.setAttribute('guestinstance', instanceId)
|
||||
// There is no replacement for this API
|
||||
```
|
||||
|
||||
## Node Headers URL
|
||||
|
||||
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
|
||||
|
|
|
@ -1385,23 +1385,6 @@ win.webContents.on('did-finish-load', () => {
|
|||
|
||||
Shows pop-up dictionary that searches the selected word on the page.
|
||||
|
||||
#### `contents.setSize(options)`
|
||||
|
||||
Set the size of the page. This is only supported for `<webview>` guest contents.
|
||||
|
||||
* `options` Object
|
||||
* `enableAutoSize` Boolean (optional) - true to make the webview container automatically
|
||||
resize within the bounds specified by the attributes normal, min and max.
|
||||
* `normal` [Size](structures/size.md) (optional) - Normal size of the page. This can be used in
|
||||
combination with the [`disableguestresize`](webview-tag.md#disableguestresize)
|
||||
attribute to manually resize the webview guest contents.
|
||||
* `min` [Size](structures/size.md) (optional) - Minimum size of the page. This can be used in
|
||||
combination with the [`disableguestresize`](webview-tag.md#disableguestresize)
|
||||
attribute to manually resize the webview guest contents.
|
||||
* `max` [Size](structures/size.md) (optional) - Maximium size of the page. This can be used in
|
||||
combination with the [`disableguestresize`](webview-tag.md#disableguestresize)
|
||||
attribute to manually resize the webview guest contents.
|
||||
|
||||
#### `contents.isOffscreen()`
|
||||
|
||||
Returns `Boolean` - Indicates whether *offscreen rendering* is enabled.
|
||||
|
|
|
@ -244,59 +244,6 @@ A list of strings which specifies the blink features to be disabled separated by
|
|||
The full list of supported feature strings can be found in the
|
||||
[RuntimeEnabledFeatures.json5][runtime-enabled-features] file.
|
||||
|
||||
### `guestinstance`
|
||||
|
||||
```html
|
||||
<webview src="https://www.github.com/" guestinstance="3"></webview>
|
||||
```
|
||||
|
||||
A value that links the webview to a specific webContents. When a webview
|
||||
first loads a new webContents is created and this attribute is set to its
|
||||
instance identifier. Setting this attribute on a new or existing webview
|
||||
connects it to the existing webContents that currently renders in a different
|
||||
webview.
|
||||
|
||||
The existing webview will see the `destroy` event and will then create a new
|
||||
webContents when a new url is loaded.
|
||||
|
||||
### `disableguestresize`
|
||||
|
||||
```html
|
||||
<webview src="https://www.github.com/" disableguestresize></webview>
|
||||
```
|
||||
|
||||
When this attribute is present the `webview` contents will be prevented from
|
||||
resizing when the `webview` element itself is resized.
|
||||
|
||||
This can be used in combination with
|
||||
[`webContents.setSize`](web-contents.md#contentssetsizeoptions) to manually
|
||||
resize the webview contents in reaction to a window size change. This can
|
||||
make resizing faster compared to relying on the webview element bounds to
|
||||
automatically resize the contents.
|
||||
|
||||
```javascript
|
||||
const {webContents} = require('electron')
|
||||
|
||||
// We assume that `win` points to a `BrowserWindow` instance containing a
|
||||
// `<webview>` with `disableguestresize`.
|
||||
|
||||
win.on('resize', () => {
|
||||
const [width, height] = win.getContentSize()
|
||||
for (let wc of webContents.getAllWebContents()) {
|
||||
// Check if `wc` belongs to a webview in the `win` window.
|
||||
if (wc.hostWebContents &&
|
||||
wc.hostWebContents.id === win.webContents.id) {
|
||||
wc.setSize({
|
||||
normal: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
The `webview` tag has the following methods:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue