react-draft-wysiwyg
Version:
A wysiwyg on top of DraftJS.
44 lines (37 loc) • 963 B
JavaScript
export default class FocusHandler {
inputFocused = false;
editorMouseDown = false;
onEditorMouseDown = ():void => {
this.editorFocused = true;
}
onInputMouseDown = ():void => {
this.inputFocused = true;
}
isEditorBlur = (event):void => {
if ((event.target.tagName === 'INPUT' || event.target.tagName === 'LABEL')
&& !this.editorFocused) {
this.inputFocused = false;
return true;
} else if ((event.target.tagName !== 'INPUT' || event.target.tagName !== 'LABEL')
&& !this.inputFocused) {
this.editorFocused = false;
return true;
}
return false;
}
isEditorFocused = ():void => {
if (!this.inputFocused) {
return true;
}
this.inputFocused = false;
return false;
}
isToolbarFocused = ():void => {
if (!this.editorFocused) {
return true;
}
this.editorFocused = false;
return false;
}
isInputFocused = ():void => this.inputFocused;
}