简体   繁体   English

如何在Codemirror中删除新行上的缩进

[英]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. 在角5 +电子。

html: HTML:

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

ts: 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');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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