在Angular ngx编辑器中添加填空选项



我在Angular 11/12中使用ngx编辑器。我需要在光标位置添加一个填空选项。

本质上,我希望在单击按钮时在光标位置添加HTML标记。

有什么帮助吗?

我做了一个外部输入和按钮来复制。输入获取文本,复制按钮意味着,如果启用了复制,在单击编辑器时,输入中的文本将在下次单击时添加到编辑器的单击位置。

myInput: string;
isCopy = false;
@HostListener('click', ['$event.target']) onClick(e){
console.log(e);
if (this.isCopy) {
e.innerText = e.innerText + this.myInput
}
}
My input: <input [(ngModel)]="myInput"> 
<button (click)="isCopy = !isCopy" [ngStyle]="{'background-color': isCopy ? 'red' : '' }">copy!</button>

工作示例:https://stackblitz.com/edit/ngx-editor-qydmny?file=src%2Fapp%2Fapp.component.html

最新更新