react-froala-wysiwyg
react-froala-wysiwyg copied to clipboard
manual controller.getEditor() object doesn't contain ENTER_BR
Hello, I used an hook (useState) to init Froala manualy with handleManualController method. Like this :
const [controller, setController] = useState(null);
const handleManualController = initControls => {
initControls.initialize();
setController(initControls.getEditor());
};
<FroalaEditor
...
onManualControllerReady={handleManualController}
/>
It works, and controler
returns an object (getEditor).
But this doesn't contain ENTER_BR
to change the default enter
config :
const config = {
...
enter: controller.ENTER_BR
}
Can anyone help me please ? Thanks
same problem here, any reason why the enter config doesn't work?
okay I found a solution for my problem. My issue is a bit different - inside TD
element, a <br>
is used for new lines by default, when I wanted a <p>
.
I fixed it by setting the multiLine
to false
in the config:
<FroalaEditor config={{ multiLine:false}}
Then I handle the enter key manually in the keydown
event:
//13 is enter key
if (keydownEvent.keyCode == '13') {
//get the selection
var selection = (this.selection.get())
//check what the tagname is
if (selection.anchorNode.parentNode.tagName == "TD") {
//manually insert p tag instead of BR
this.html.insert('<p>');
this.cursor.del();
}
else {
//otherwise trigger regular enter
this.cursor.enter();
}
}
},```
i've the same problem, really annoying.