import * as React from 'react'; import JqxEditor, { IEditorProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxeditor'; class App extends React.PureComponent<{}, IEditorProps> { private myEditor = React.createRef(); constructor(props: {}) { super(props); const createCommand = (name: string): any => { switch (name) { case 'datetime': return { action: (widget: any, editor: any): any => { const widgetValue = widget.val(); const date = new Date(); // return object with command and value members. return { command: 'inserthtml', value: widgetValue === 'Insert Time' ? date.getHours() + ':' + date.getMinutes() : date.getDate() + '-' + date.getMonth() + '-' + date.getFullYear() }; }, init: (widget: any): void => { widget.jqxDropDownList({ placeHolder: 'Insert Custom HTML', width: 170, source: ['Insert Time', 'Insert Date'], autoDropDownHeight: true }); }, refresh: (widget: any, style: any): void => { // do something here when the selection is changed. widget.jqxDropDownList('clearSelection'); }, tooltip: 'Insert Date/Time', type: 'list' } case 'print': return { action: (widget: any, editor: any): void => { // return nothing and perform a custom action. this.myEditor.current!.print(); }, init: (widget: any): void => { widget.jqxButton({ height: 25, width: 40 }); widget.html('Print'); }, refresh: (widget: any, style: any): void => { // do something here when the selection is changed. }, tooltip: 'Print', type: 'button' } case 'clear': return { action: (widget: any, editor: any): void => { // return nothing and perform a custom action. this.myEditor.current!.val(''); }, init: (widget: any): void => { widget.jqxButton({ height: 25, width: 40 }); widget.html('Clear'); }, refresh: (widget: any, style: any): void => { // do something here when the selection is changed. }, tooltip: 'Clear', type: 'button' } case 'backcolor': return { action: (widget: any, editor: any): void => { // return nothing and perform a custom action. const color = widget.val(); editor.css('background', color); }, init: (widget: any): void => { widget.jqxDropDownButton({ width: 170 }); widget.jqxDropDownButton('setContent', 'Choose Background'); }, refresh: (widget: any, style: any): void => { // do something here when the selection is changed. }, tooltip: 'Background', type: 'colorPicker' } } } this.state = { createCommand, tools: 'datetime | print | clear | backcolor | font | bold italic underline' } } public render() { return ( ); } } export default App;