简体   繁体   中英

How to remove indentation on new line in Codemirror

In my case, cursor jump through one empty line. How fix this? Thanks in advance.

In Angular 5 + Electron.

html:

   <codemirror
     [config]="{
       lineWrapping: true, 
       autofocus: true, 
       showCursorWhenSelecting: true,
       smartIndent: false
     }"
     (keyup.enter)="removeIndentation()"
     #novelEditor>
   </codemirror>

ts:

import { CodemirrorComponent } from 'ng2-codemirror';
...
@ViewChild('novelEditor') private novelEditor: CodemirrorComponent;
...
  removeIndentation() {
    const cm = this.novelEditor.instance;
    cm.replaceSelection("\n");
  }

在此处输入图片说明

I solved it

removeIndentation() {
   const cm = this.novelEditor.instance;
   cm.execCommand('delLineLeft');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM