SelectionContextMenu

A context menu for word-selection operations. Shown when the user right-clicks on a word that belongs to an active word selection. Provides "Add link" and "Search text" actions.

Constructor

new SelectionContextMenu(x, y, callbacks)

Parameters:
NameTypeDescription
xnumberPreferred left position in viewport pixels.
ynumberPreferred top position in viewport pixels.
callbacksobjectCallback functions for menu actions.
Properties
NameTypeAttributesDescription
onAddLinkfunction<optional>
Called when "Add link" is clicked.
onSearchTextfunction<optional>
Called when "Search text" is clicked.
onGenerateLiveQuotefunction<optional>
Called when "Generate Live Quote" is clicked. Pass null to hide the item.
onDismissfunction<optional>
Called when the menu is dismissed.
Example
const menu = new SelectionContextMenu(event.clientX, event.clientY, {
  onAddLink:          () => { handleHyperlink(); },
  onSearchText:       () => { handleSearch(); },
  onGenerateLiveQuote: () => { handleEmbed(); },  // null to hide
  onDismiss:          () => { menu.close(); },
});

// Later:
menu.close();

Classes

SelectionContextMenu

Methods

close()

Removes the menu from the DOM.