diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 08fb95b79..cec4cf867 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -109,6 +109,15 @@ app.on('ready', () => { mainWindow.webContents.executeJavaScript('return true;'); mainWindow.webContents.executeJavaScript('return true;', true); mainWindow.webContents.executeJavaScript('return true;', true, (result: boolean) => console.log(result)); + mainWindow.webContents.insertText('blah, blah, blah'); + mainWindow.webContents.findInPage('blah'); + mainWindow.webContents.findInPage('blah', { + forward: true, + matchCase: false, + }); + mainWindow.webContents.stopFindInPage('clearSelection'); + mainWindow.webContents.stopFindInPage('keepSelection'); + mainWindow.webContents.stopFindInPage('activateSelection'); }); // Locale diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index c5c60b355..b0cb21fc3 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -537,6 +537,14 @@ declare namespace Electron { height?: number; } + interface FindInPageOptions { + forward?: boolean; + findNext?: boolean; + matchCase?: boolean; + wordStart?: boolean; + medialCapitalAsWordStart?: boolean; + } + /** * A WebContents is responsible for rendering and controlling a web page. */ @@ -677,6 +685,26 @@ declare namespace Electron { * Executes Edit -> Replace Misspelling command in page. */ replaceMisspelling(text: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Starts a request to find all matches for the text in the web page and + * returns an Integer representing the request id used for the request. + * The result of the request can be obtained by subscribing to + * found-in-page event. + */ + findInPage(text: string, options?: FindInPageOptions): void; + /** + * Stops any findInPage request for the webContents with the provided + * action. + * @param action Specifies the action to take place when ending webContents.findInPage request. + * 'clearSelection' - Translate the selection into a normal selection. + * 'keepSelection' - Clear the selection. + * 'activateSelection' - Focus and click the selection node. + */ + stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void; /** * Checks if any serviceworker is registered. */