feat: make async webContents / <webview> methods return a Promise (#18792)

This commit is contained in:
Milan Burda 2019-06-17 11:10:02 +02:00 committed by Alexey Kuzmin
parent 632bbf948d
commit deebde66f9
6 changed files with 32 additions and 35 deletions

View file

@ -987,6 +987,8 @@ Returns `String` - The user agent for this web page.
* `css` String
Returns `Promise<void>`
Injects CSS into the current web page.
```js
@ -1065,6 +1067,8 @@ Returns `Number` - the current zoom level.
* `minimumLevel` Number
* `maximumLevel` Number
Returns `Promise<void>`
Sets the maximum and minimum pinch-to-zoom level.
> **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call:
@ -1078,6 +1082,8 @@ Sets the maximum and minimum pinch-to-zoom level.
* `minimumLevel` Number
* `maximumLevel` Number
Returns `Promise<void>`
Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
#### `contents.undo()`
@ -1139,6 +1145,8 @@ Executes the editing command `replaceMisspelling` in web page.
* `text` String
Returns `Promise<void>`
Inserts `text` to the focused element.
#### `contents.findInPage(text[, options])`

View file

@ -379,6 +379,8 @@ Returns `String` - The user agent for guest page.
* `css` String
Returns `Promise<void>`
Injects CSS into the guest page.
### `<webview>.executeJavaScript(code[, userGesture])`
@ -490,6 +492,8 @@ Executes editing command `replaceMisspelling` in page.
* `text` String
Returns `Promise<void>`
Inserts `text` to the focused element.
### `<webview>.findInPage(text[, options])`
@ -531,6 +535,8 @@ Stops any `findInPage` request for the `webview` with the provided `action`.
the web page. Default is `false`.
* `deviceName` String (optional) - Set the printer device name to use. Default is `''`.
Returns `Promise<void>`
Prints `webview`'s web page. Same as `webContents.print([options])`.
### `<webview>.printToPDF(options)`
@ -562,6 +568,8 @@ Captures a snapshot of the page within `rect`. Omitting `rect` will capture the
* `channel` String
* `...args` any[]
Returns `Promise<void>`
Send an asynchronous message to renderer process via `channel`, you can also
send arbitrary arguments. The renderer process can handle the message by
listening to the `channel` event with the [`ipcRenderer`](ipc-renderer.md) module.
@ -573,6 +581,8 @@ examples.
* `event` Object
Returns `Promise<void>`
Sends an input `event` to the page.
See [webContents.sendInputEvent](web-contents.md#contentssendinputeventevent)
@ -607,6 +617,8 @@ Returns `Number` - the current zoom level.
* `minimumLevel` Number
* `maximumLevel` Number
Returns `Promise<void>`
Sets the maximum and minimum pinch-to-zoom level.
### `<webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`
@ -614,6 +626,8 @@ Sets the maximum and minimum pinch-to-zoom level.
* `minimumLevel` Number
* `maximumLevel` Number
Returns `Promise<void>`
Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
### `<webview>.showDefinitionForSelection()` _macOS_