Ad

Ace Editor Pressing Enter Key Does Not Add A Newline

No newline is inserted when pressing the enter key in the editor field of an ace editor instance. Nothing happens.

Example initiation:

let codeEditor = ace.edit('someElementId', {
    minLines: 6,
    maxLines: 20,
    showLineNumbers: false,
    readOnly: false,
    newLineMode: 'auto',
});
codeEditor.setTheme('ace/theme/chrome');
codeEditor.session.setMode('ace/mode/json');
Ad

Answer

Something else on your page is catching the event On a page without other code your example works

<form>
    <div id="someElementId"></div>
</form>

<script src=https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.3/ace.js></script>
<script>
let codeEditor = ace.edit('someElementId', {
    minLines: 6,
    maxLines: 20,
    showLineNumbers: false,
    readOnly: false,
    newLineMode: 'auto',
});
codeEditor.setTheme('ace/theme/chrome');
codeEditor.session.setMode('ace/mode/json');
</script>

Ad
source: stackoverflow.com
Ad