import React from 'react'; import { SessionIconButton, SessionIconSize, SessionIconType } from './icon'; import { ContextMenu, ContextMenuTrigger, MenuItem } from 'react-contextmenu'; interface Props { searchString: string; onChange: any; handleNavigation?: any; placeholder: string; } export class SessionSearchInput extends React.Component { public constructor(props: Props) { super(props); this.handleKeyDown = this.handleKeyDown.bind(this); this.handleUndo = this.handleUndo.bind(this); this.handleRedo = this.handleRedo.bind(this); this.handleCut = this.handleCut.bind(this); this.handleCopy = this.handleCopy.bind(this); this.handlePast = this.handlePast.bind(this); this.handleSelectAll = this.handleSelectAll.bind(this); } public render() { const { searchString } = this.props; const triggerId = `session-search-input-context`; return ( <>
this.props.onChange(e.target.value)} onKeyDown={this.handleKeyDown} placeholder={this.props.placeholder} />
{window.i18n('editMenuUndo')} {window.i18n('editMenuRedo')}
{window.i18n('editMenuCut')} {window.i18n('editMenuCopy')} {window.i18n('editMenuPaste')} {window.i18n('editMenuSelectAll')}
); } public handleKeyDown(e: any) { if (e.keyCode === 38 || e.keyCode === 40 || e.key === 'Enter') { // Up or Bottom arrow pressed if (this.props.handleNavigation) { e.stopPropagation(); this.props.handleNavigation(e); } } } public handleUndo() { document.execCommand('undo'); } public handleRedo() { document.execCommand('redo'); } public handleCut() { document.execCommand('cut'); } public handleCopy() { document.execCommand('copy'); } public handlePast() { document.execCommand('paste'); } public handleSelectAll() { document.execCommand('selectAll'); } }