@@ -58,6 +58,23 @@ Works for both BrowserWindows and BrowserViews.
5858- ` isBrowserWindow ` - Whether the webContents belong to a BrowserWindow or not (the other option is a BrowserView)
5959- ` path ` - Absolute path to the CSS file location
6060
61+ #### 🧊 ` Task<string> InsertCSSAsync(string css, string cssOrigin = null) `
62+ Injects CSS into the current web page and returns a unique key for the inserted style sheet.
63+
64+ ** Parameters:**
65+ - ` css ` - The style sheet to inject
66+ - ` cssOrigin ` - Can be either ` user ` or ` author ` , defaults to ` author `
67+
68+ ** Returns:**
69+
70+ The key of the inserted style sheet, to be used with ` RemoveInsertedCSSAsync ` .
71+
72+ #### 🧊 ` Task RemoveInsertedCSSAsync(string key) `
73+ Removes a previously inserted style sheet from the current web page.
74+
75+ ** Parameters:**
76+ - ` key ` - The key returned by ` InsertCSSAsync `
77+
6178#### 🧊 ` Task LoadURLAsync(string url) `
6279Loads the url in the window. The url must contain the protocol prefix.
6380
@@ -138,6 +155,66 @@ Sets the maximum and minimum pinch-to-zoom level.
138155- ` minimumLevel ` - The minimum pinch-to-zoom level
139156- ` maximumLevel ` - The maximum pinch-to-zoom level
140157
158+ #### 🧊 ` Task LoadFileAsync(string filePath, LoadFileOptions options = null) `
159+ Loads the given HTML file, relative to the root of the application.
160+
161+ ** Parameters:**
162+ - ` filePath ` - Path to the HTML file
163+ - ` options ` - Optional ` Query ` , ` Search ` and ` Hash ` parts of the resulting URL
164+
165+ #### 🧊 ` Task<bool> IsLoadingAsync() `
166+ Whether the web page is still loading resources.
167+
168+ #### 🧊 ` Task<bool> IsLoadingMainFrameAsync() `
169+ Whether the main frame (and not just iframes or frames within it) is still loading.
170+
171+ #### 🧊 ` Task<bool> IsWaitingForResponseAsync() `
172+ Whether the web page is waiting for a first response from the main resource of the page.
173+
174+ #### 🧊 ` void Reload() `
175+ Reloads the current web page.
176+
177+ #### 🧊 ` void ReloadIgnoringCache() `
178+ Reloads the current web page and ignores the cache.
179+
180+ #### 🧊 ` void Stop() `
181+ Stops any pending navigation.
182+
183+ #### 🧊 ` void Undo() ` / ` void Redo() `
184+ Executes the ` undo ` / ` redo ` editing command in the web page.
185+
186+ #### 🧊 ` void Cut() ` / ` void Copy() ` / ` void Paste() ` / ` void PasteAndMatchStyle() ` / ` void Delete() `
187+ Executes the corresponding editing command in the web page.
188+
189+ #### 🧊 ` void CopyImageAt(int x, int y) `
190+ Copies the image at the given position to the clipboard.
191+
192+ #### 🧊 ` void SelectAll() ` / ` void Unselect() ` / ` void CenterSelection() `
193+ Selects all content, clears the selection, or scrolls to the current selection.
194+
195+ #### 🧊 ` void AdjustSelection(AdjustSelectionOptions options) `
196+ Adjusts the start and end points of the current text selection by the given amounts. Negative amounts move towards the beginning of the document.
197+
198+ #### 🧊 ` Task InsertTextAsync(string text) `
199+ Inserts text into the focused element.
200+
201+ #### 🧊 ` void Replace(string text) ` / ` void ReplaceMisspelling(string text) `
202+ Replaces the current selection, or the currently misspelled word, with the given text.
203+
204+ #### 🧊 ` Task<int> FindInPageAsync(string text, FindInPageOptions options = null) `
205+ Starts a request to find all matches for the text in the web page. Results are reported via the ` OnFoundInPage ` event.
206+
207+ ** Parameters:**
208+ - ` text ` - Content to be searched, must not be empty
209+ - ` options ` - Optional ` Forward ` , ` FindNext ` and ` MatchCase ` flags
210+
211+ ** Returns:**
212+
213+ The request id of the find request.
214+
215+ #### 🧊 ` void StopFindInPage(StopFindInPageAction action) `
216+ Stops any ` FindInPageAsync ` request with the given action (` ClearSelection ` , ` KeepSelection ` or ` ActivateSelection ` ).
217+
141218## Events
142219
143220#### ⚡ ` InputEvent `
@@ -170,6 +247,9 @@ Emitted when a server side redirect occurs during navigation.
170247#### ⚡ ` OnZoomChanged `
171248Emitted when the user changes the zoom level using the mouse wheel or the keyboard. The handler receives the ` ZoomDirection ` (` In ` or ` Out ` ).
172249
250+ #### ⚡ ` OnFoundInPage `
251+ Emitted when a result is available for a ` FindInPageAsync ` request. The handler receives a ` FoundInPageResult ` .
252+
173253## Usage Examples
174254
175255### Page Loading
@@ -331,6 +411,41 @@ webContents.OnZoomChanged += (direction) =>
331411
332412> ** Note:** The zoom factor is shared by all windows using the same session partition. Assign a unique ` WebPreferences.Partition ` per window if each window should keep its own zoom.
333413
414+ ### Dynamic CSS
415+
416+ ``` csharp
417+ var key = await webContents .InsertCSSAsync (" body { background-color: #202020; }" );
418+
419+ // ... later
420+ await webContents .RemoveInsertedCSSAsync (key );
421+ ```
422+
423+ ### Editing and Selection
424+
425+ ``` csharp
426+ await webContents .InsertTextAsync (" Hello from .NET" );
427+
428+ webContents .SelectAll ();
429+ webContents .Copy ();
430+ webContents .Unselect ();
431+ ```
432+
433+ ### Find in Page
434+
435+ ``` csharp
436+ webContents .OnFoundInPage += (result ) =>
437+ {
438+ Console .WriteLine ($" {result .ActiveMatchOrdinal }/{result .Matches } matches" );
439+
440+ if (result .FinalUpdate )
441+ {
442+ webContents .StopFindInPage (StopFindInPageAction .ClearSelection );
443+ }
444+ };
445+
446+ var requestId = await webContents .FindInPageAsync (" electron" , new FindInPageOptions { MatchCase = false });
447+ ```
448+
334449## Related APIs
335450
336451- [ Electron.WindowManager] ( WindowManager.md ) - Windows containing web contents
0 commit comments