react-froala-wysiwyg icon indicating copy to clipboard operation
react-froala-wysiwyg copied to clipboard

manual controller.getEditor() object doesn't contain ENTER_BR

Open jeremiepassebon opened this issue 5 years ago • 3 comments

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

jeremiepassebon avatar Jul 31 '19 13:07 jeremiepassebon

same problem here, any reason why the enter config doesn't work?

GraemeFulton avatar Sep 19 '19 22:09 GraemeFulton

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();
                  }
                }

              },```

GraemeFulton avatar Sep 20 '19 09:09 GraemeFulton

i've the same problem, really annoying.

timglabisch avatar Feb 01 '21 10:02 timglabisch