Preventing line breaks - ENTER keypresses. Instead - fire custom event

47 views Asked by At

I'd like to use Aloha to WYSIWYG-edit single-line headlines.

For that I need to intercept ENTER keypress (to prevent line-break) and fire custom save event.

Is there a way to do that?

Thanks!

1

There are 1 answers

0
temuri On BEST ANSWER

Here's what worked for me on "hotfix" branch:

Aloha.bind('aloha-smart-content-changed', function(e, data) {
    value = data.editable.getContents();
    // save it to database.
});
Aloha.bind('aloha-command-will-execute', function(e, data) {
    if (data.commandId == 'insertlinebreak') {
        data.preventDefault = true;
    }
});

More info here:

https://github.com/alohaeditor/Aloha-Editor/issues/1502