Skip to content
Snippets Groups Projects
Commit 14ee631f authored by Chris Beer's avatar Chris Beer
Browse files

Handle focusing on the editor line ourselves :shrug:; fixes #39

parent 8b17aa80
Branches
No related tags found
2 merge requests!3Integrate upstream tests into gitlab ci,!2Update plugin code from upstream
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
"sort-keys": ["error", "asc", { "sort-keys": ["error", "asc", {
"caseSensitive": false, "caseSensitive": false,
"natural": false "natural": false
}] }],
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off"
} }
} }
...@@ -20,6 +20,16 @@ class TextEditor extends Component { ...@@ -20,6 +20,16 @@ class TextEditor extends Component {
this.onChange = this.onChange.bind(this); this.onChange = this.onChange.bind(this);
this.handleKeyCommand = this.handleKeyCommand.bind(this); this.handleKeyCommand = this.handleKeyCommand.bind(this);
this.handleFormating = this.handleFormating.bind(this); this.handleFormating = this.handleFormating.bind(this);
this.handleFocus = this.handleFocus.bind(this);
this.editorRef = React.createRef();
}
/**
* This is a kinda silly hack (but apparently recommended approach) to
* making sure the whole visible editor area, not just the first line.
*/
handleFocus() {
if (this.editorRef.current) this.editorRef.current.focus();
} }
/** */ /** */
...@@ -58,6 +68,7 @@ class TextEditor extends Component { ...@@ -58,6 +68,7 @@ class TextEditor extends Component {
const { classes } = this.props; const { classes } = this.props;
const { editorState } = this.state; const { editorState } = this.state;
const currentStyle = editorState.getCurrentInlineStyle(); const currentStyle = editorState.getCurrentInlineStyle();
return ( return (
<div> <div>
<ToggleButtonGroup <ToggleButtonGroup
...@@ -77,11 +88,13 @@ class TextEditor extends Component { ...@@ -77,11 +88,13 @@ class TextEditor extends Component {
<ItalicIcon /> <ItalicIcon />
</ToggleButton> </ToggleButton>
</ToggleButtonGroup> </ToggleButtonGroup>
<div className={classes.editorRoot}>
<div className={classes.editorRoot} onClick={this.handleFocus}>
<Editor <Editor
editorState={editorState} editorState={editorState}
handleKeyCommand={this.handleKeyCommand} handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange} onChange={this.onChange}
ref={this.editorRef}
/> />
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment