如何在 CKEditor 5 中保留新行?
How to preserve new lines in CKEditor 5?
我正在使用 Angular 2+ 和 CKEditor 5。
当我使用字符串:"foo\r\nbar"
时,编辑器中的文本没有应用新行。使用 CSS 规则:white-space: pre-line;
在页面上其他元素的文本上有效,但在 CKEditor 中无效。如何在 CKEditor 5 中保留新行?
这是我的组件:
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
@Component({
selector: 'test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss']
})
export class TestComponent {
public editor = ClassicEditor;
testString = "foo\r\nbar";
constructor(){}
}
这是我的 html:
<ckeditor [editor]="editor" [(ngModel)]="testString"></ckeditor>
您需要使用 javascript 将字符串中的“\r\n”替换为 "<br />"
,然后再将其提供给 ckeditor。
我正在使用 Angular 2+ 和 CKEditor 5。
当我使用字符串:"foo\r\nbar"
时,编辑器中的文本没有应用新行。使用 CSS 规则:white-space: pre-line;
在页面上其他元素的文本上有效,但在 CKEditor 中无效。如何在 CKEditor 5 中保留新行?
这是我的组件:
import * as ClassicEditor from '@ckeditor/ckeditor5-build-classic';
@Component({
selector: 'test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss']
})
export class TestComponent {
public editor = ClassicEditor;
testString = "foo\r\nbar";
constructor(){}
}
这是我的 html:
<ckeditor [editor]="editor" [(ngModel)]="testString"></ckeditor>
您需要使用 javascript 将字符串中的“\r\n”替换为 "<br />"
,然后再将其提供给 ckeditor。