Handsontable example
HTML
<div id="example1" class="hot">
</div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://cdn.jsdelivr.net/npm/handsontable@8.0.0/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@8.0.0/dist/handsontable.full.min.css">
<script src="https://handsontable.com/docs/8.0.0/scripts/jsfiddle-fixer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react@16/umd/react.development.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@4.0.0/dist/react-handsontable.js"></script>
Babel + JSX
import React from 'react';
import ReactDOM from 'react-dom';
import { HotTable } from '@handsontable/react';
import Handsontable from 'handsontable';
class EditorComponent extends Handsontable.editors.TextEditor {
constructor(props) {
super(props);
this.mainElementRef = React.createRef();
this.containerStyle = {
display: "none",
position: "absolute",
left: 0,
top: 0,
background: "#fff",
border: "1px solid #000",
padding: "15px",
zIndex: 999
};
this.state = {
value: ""
};
}
setValue(value, callback) {
this.setState((state, props) => {
return { value: value };
}, callback);
}
getValue() {
return this.state.value;
}
open() {
this.mainElementRef.current.style.display = "block";
}
close() {
this.mainElementRef.current.style.display = "none";
}
prepare(row, col, prop, td, originalValue, cellProperties) {
// We'll need to call the `prepare` method from
// the `BaseEditorComponent` class, as it provides
// the component with the information needed to use the editor
// (hotInstance, row, col, prop, TD, originalValue, cellProperties)
super.prepare(row, col, prop, td, originalValue, cellProperties);
const tdPosition = td.getBoundingClientRect();
// As the `prepare` method is triggered after selecting
// any cell, we're updating the styles for the editor element,
// so it shows up in the correct position.
this.mainElementRef.current.style.left = tdPosition.left + "px";
this.mainElementRef.current.style.top = tdPosition.top + "px";
}
setLowerCase() {
this.setState(
(state, props) => {
return { value: this.state.value.toString().toLowerCase() };
},
() => {
this.finishEditing();
}
);
}
setUpperCase() {
this.setState(
(state, props) => {
return { value: this.state.value.toString().toUpperCase() };
},
() =>...