File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ app.on('ready', () => {
109109 mainWindow . webContents . executeJavaScript ( 'return true;' ) ;
110110 mainWindow . webContents . executeJavaScript ( 'return true;' , true ) ;
111111 mainWindow . webContents . executeJavaScript ( 'return true;' , true , ( result : boolean ) => console . log ( result ) ) ;
112+ mainWindow . webContents . insertText ( 'blah, blah, blah' ) ;
113+ mainWindow . webContents . findInPage ( 'blah' ) ;
114+ mainWindow . webContents . findInPage ( 'blah' , {
115+ forward : true ,
116+ matchCase : false ,
117+ } ) ;
118+ mainWindow . webContents . stopFindInPage ( 'clearSelection' ) ;
119+ mainWindow . webContents . stopFindInPage ( 'keepSelection' ) ;
120+ mainWindow . webContents . stopFindInPage ( 'activateSelection' ) ;
112121} ) ;
113122
114123// Locale
Original file line number Diff line number Diff line change @@ -537,6 +537,14 @@ declare namespace Electron {
537537 height ?: number ;
538538 }
539539
540+ interface FindInPageOptions {
541+ forward ?: boolean ;
542+ findNext ?: boolean ;
543+ matchCase ?: boolean ;
544+ wordStart ?: boolean ;
545+ medialCapitalAsWordStart ?: boolean ;
546+ }
547+
540548 /**
541549 * A WebContents is responsible for rendering and controlling a web page.
542550 */
@@ -677,6 +685,26 @@ declare namespace Electron {
677685 * Executes Edit -> Replace Misspelling command in page.
678686 */
679687 replaceMisspelling ( text : string ) : void ;
688+ /**
689+ * Inserts text to the focused element.
690+ */
691+ insertText ( text : string ) : void ;
692+ /**
693+ * Starts a request to find all matches for the text in the web page and
694+ * returns an Integer representing the request id used for the request.
695+ * The result of the request can be obtained by subscribing to
696+ * found-in-page event.
697+ */
698+ findInPage ( text : string , options ?: FindInPageOptions ) : void ;
699+ /**
700+ * Stops any findInPage request for the webContents with the provided
701+ * action.
702+ * @param action Specifies the action to take place when ending webContents.findInPage request.
703+ * 'clearSelection' - Translate the selection into a normal selection.
704+ * 'keepSelection' - Clear the selection.
705+ * 'activateSelection' - Focus and click the selection node.
706+ */
707+ stopFindInPage ( action : 'clearSelection' | 'keepSelection' | 'activateSelection' ) : void ;
680708 /**
681709 * Checks if any serviceworker is registered.
682710 */
You can’t perform that action at this time.
0 commit comments