我正在使用一个在ckeditor中填充on-paste(paste)=“ onPaste($ event)”的函数。在此功能中,我使用了settimeout函数。但是在ngmodel中设置了任何值之后,光标就会在开始位置处跳跃。 (我正在使用CKeditor)
以HTML
<ckeditor #editorInstance tagName="textarea" [ngClass]="{'ckactive': editordata }" [editor]="editor"
[(ngModel)]="editordata" [config]="config" (change)="onChangeCK($event)" (ready)="onready($event)" (paste)="onPaste($event)">
</ckeditor>
.ts文件中的
onPaste(event: ClipboardEvent) {
setTimeout(() => {
this.editordata = "hello" // here I want to put some dynamic content
this.elmRef.nativeElement.querySelector('ckeditor').querySelector('textarea').setSelectionRange(-1,-1)
},250);
}
我尝试了setSelectionRange(),但对我没有用。 :(