mirror of
https://github.com/electron/electron.git
synced 2026-01-08 15:13:52 -05:00
docs: recommend calling renderer process modules from preload script (#48427)
This commit is contained in:
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) (non-sandboxed only)
|
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) (non-sandboxed only)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
On Linux, there is also a `selection` clipboard. To manipulate it
|
On Linux, there is also a `selection` clipboard. To manipulate it
|
||||||
you need to pass `selection` to each method:
|
you need to pass `selection` to each method:
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
The following is an example of setting up Electron to automatically submit
|
The following is an example of setting up Electron to automatically submit
|
||||||
crash reports to a remote server:
|
crash reports to a remote server:
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ changes:
|
|||||||
|
|
||||||
Process: [Renderer](../glossary.md#renderer-process)
|
Process: [Renderer](../glossary.md#renderer-process)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
The `ipcRenderer` module is an [EventEmitter][event-emitter]. It provides a few
|
The `ipcRenderer` module is an [EventEmitter][event-emitter]. It provides a few
|
||||||
methods so you can send synchronous and asynchronous messages from the render
|
methods so you can send synchronous and asynchronous messages from the render
|
||||||
process (web page) to the main process. You can also receive replies from the
|
process (web page) to the main process. You can also receive replies from the
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
The `nativeImage` module provides a unified interface for manipulating
|
The `nativeImage` module provides a unified interface for manipulating
|
||||||
system images. These can be handy if you want to provide multiple scaled
|
system images. These can be handy if you want to provide multiple scaled
|
||||||
versions of the same icon or take advantage of macOS [template images][template-image].
|
versions of the same icon or take advantage of macOS [template images][template-image].
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Process: [Renderer](../glossary.md#renderer-process)
|
Process: [Renderer](../glossary.md#renderer-process)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
`webFrame` export of the Electron module is an instance of the `WebFrame`
|
`webFrame` export of the Electron module is an instance of the `WebFrame`
|
||||||
class representing the current frame. Sub-frames can be retrieved by
|
class representing the current frame. Sub-frames can be retrieved by
|
||||||
certain properties and methods (e.g. `webFrame.firstChild`).
|
certain properties and methods (e.g. `webFrame.firstChild`).
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Process: [Renderer](../glossary.md#renderer-process)
|
Process: [Renderer](../glossary.md#renderer-process)
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If you want to call this API from a renderer process with context isolation enabled,
|
||||||
|
> place the API call in your preload script and
|
||||||
|
> [expose](../tutorial/context-isolation.md#after-context-isolation-enabled) it using the
|
||||||
|
> [`contextBridge`](context-bridge.md) API.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
The `webUtils` module has the following methods:
|
The `webUtils` module has the following methods:
|
||||||
|
|||||||
Reference in New Issue
Block a user