Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 16, 2022
1 parent 157a5ad commit ddc4036
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ You can use this module directly in both the main and renderer process.
@example
```
const {app, BrowserWindow} = require('electron');
const contextMenu = require('electron-context-menu');
import {app, BrowserWindow} = require('electron');
import contextMenu = require('electron-context-menu');
contextMenu({
showSaveImageAs: true
Expand All @@ -339,7 +339,7 @@ let mainWindow;
@example
```
import {app, BrowserWindow} from 'electron';
import {app, BrowserWindow} = require('electron');
import contextMenu = require('electron-context-menu');
contextMenu({
Expand All @@ -348,6 +348,14 @@ contextMenu({
label: 'Rainbow',
// Only show it when right-clicking images
visible: parameters.mediaType === 'image'
},
{
label: 'Search Google for “{selection}”',
// Only show it when right-clicking text
visible: parameters.selectionText.trim().length > 0,
click: () => {
shell.openExternal(`https://google.com/search?q=${encodeURIComponent(parameters.selectionText)}`);
}
}
]
});
Expand All @@ -361,7 +369,7 @@ let mainWindow;
spellcheck: true
}
});
});
})();
```
The return value of `contextMenu()` is a function that disposes of the created event listeners:
Expand All @@ -372,7 +380,6 @@ const dispose = contextMenu();
dispose();
```
*/
declare function contextMenu(options?: contextMenu.Options): () => void; // eslint-disable-line no-redeclare

Expand Down

0 comments on commit ddc4036

Please sign in to comment.