import ContextMenuBuilder from 'electron-spellchecker/src/context-menu-builder.js'
ContextMenuBuilder
ContextMenuBuilder creates context menus based on the content clicked - this information is derived from https://github.com/electron/electron/blob/master/docs/api/web-contents.md#event-context-menu, which we use to generate the menu. We also use the spell-check information to generate suggestions.
Static Method Summary
Static Public Methods | ||
public static |
Override the default logger for this class. |
Constructor Summary
Public Constructor | ||
public |
constructor(spellCheckHandler: SpellCheckHandler, windowOrWebView: BrowserWindow | WebView, debugMode: Boolean) Creates an instance of ContextMenuBuilder |
Method Summary
Public Methods | ||
public |
addCopy(menu: *, menuInfo: *): * Adds the Copy menu item. |
|
public |
addCut(menu: *, menuInfo: *): * Adds the Cut menu item |
|
public |
addImageItems(menu: *, menuInfo: *): * Adds "Copy Image" and "Copy Image URL" items when |
|
public |
addInspectElement(menu: *, menuInfo: *, needsSeparator: boolean): * Adds the "Inspect Element" menu item. |
|
public |
addPaste(menu: *, menuInfo: *): * Adds the Paste menu item. |
|
public |
addSearchItems(menu: *, menuInfo: *): * Adds search-related menu items. |
|
public |
addSeparator(menu: *): * Adds a separator item. |
|
public |
addSpellingItems(menu: *, menuInfo: *): * Checks if the current text selection contains a single misspelled word and if so, adds suggested spellings as individual menu items. |
|
public |
buildMenuForElement(info: *): Menu Builds a context menu specific to the given info that would be shown immediately by {{showPopupMenu}}. |
|
public |
buildMenuForImage(menuInfo: *): Menu Builds a menu applicable to an image. |
|
public |
buildMenuForLink(menuInfo: *): Menu Builds a menu applicable to a link element. |
|
public |
buildMenuForText(menuInfo: *): Menu Builds a menu applicable to a text field. |
|
public |
buildMenuForTextInput(menuInfo: *): Menu Builds a menu applicable to a text input field. |
|
public |
convertImageToBase64(url: String, callback: Function, outputFormat: String) Converts an image to a base-64 encoded string. |
|
public |
showPopupMenu(contextInfo: Object): Promise Shows a popup menu given the information returned from the context-menu event. |
Static Public Methods
Public Constructors
public constructor(spellCheckHandler: SpellCheckHandler, windowOrWebView: BrowserWindow | WebView, debugMode: Boolean) source
Creates an instance of ContextMenuBuilder
Params:
Name | Type | Attribute | Description |
spellCheckHandler | SpellCheckHandler | The spell checker to generate recommendations for. |
|
windowOrWebView | BrowserWindow | WebView | The hosting window/WebView |
|
debugMode | Boolean | If true, display the "Inspect Element" menu item. |
Public Members
public debugMode: * source
public menu: * source
public spellCheckHandler: * source
public windowOrWebView: * source
Public Methods
public addCopy(menu: *, menuInfo: *): * source
Adds the Copy menu item.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public addCut(menu: *, menuInfo: *): * source
Adds the Cut menu item
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public addImageItems(menu: *, menuInfo: *): * source
Adds "Copy Image" and "Copy Image URL" items when src
is valid.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public addInspectElement(menu: *, menuInfo: *, needsSeparator: boolean): * source
Adds the "Inspect Element" menu item.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * | ||
needsSeparator | boolean |
|
Return:
* |
public addPaste(menu: *, menuInfo: *): * source
Adds the Paste menu item.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public addSearchItems(menu: *, menuInfo: *): * source
Adds search-related menu items.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public addSeparator(menu: *): * source
Adds a separator item.
Params:
Name | Type | Attribute | Description |
menu | * |
Return:
* |
public addSpellingItems(menu: *, menuInfo: *): * source
Checks if the current text selection contains a single misspelled word and if so, adds suggested spellings as individual menu items.
Params:
Name | Type | Attribute | Description |
menu | * | ||
menuInfo | * |
Return:
* |
public buildMenuForElement(info: *): Menu source
Builds a context menu specific to the given info that would be shown immediately by {{showPopupMenu}}. Use this to add your own menu items to the list but use most of the default behavior.
Params:
Name | Type | Attribute | Description |
info | * |
Return:
Menu | The newly created |
public buildMenuForImage(menuInfo: *): Menu source
Builds a menu applicable to an image.
Params:
Name | Type | Attribute | Description |
menuInfo | * |
Return:
Menu | The |
public buildMenuForLink(menuInfo: *): Menu source
Builds a menu applicable to a link element.
Params:
Name | Type | Attribute | Description |
menuInfo | * |
Return:
Menu | The |
public buildMenuForText(menuInfo: *): Menu source
Builds a menu applicable to a text field.
Params:
Name | Type | Attribute | Description |
menuInfo | * |
Return:
Menu | The |
public buildMenuForTextInput(menuInfo: *): Menu source
Builds a menu applicable to a text input field.
Params:
Name | Type | Attribute | Description |
menuInfo | * |
Return:
Menu | The |
public convertImageToBase64(url: String, callback: Function, outputFormat: String) source
Converts an image to a base-64 encoded string.
public showPopupMenu(contextInfo: Object): Promise source
Shows a popup menu given the information returned from the context-menu event. This is probably the only method you need to call in this class.
Params:
Name | Type | Attribute | Description |
contextInfo | Object | The object returned from the 'context-menu' Electron event. |