簡體   English   中英

如何在Codemirror中刪除新行上的縮進

[英]How to remove indentation on new line in Codemirror

在我的情況下,光標跳過一條空行。 如何解決? 提前致謝。

在角5 +電子。

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

在此處輸入圖片說明

我解決了

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM