[英]Add a custom button | CK Editor Angular 2
我試圖在CKEditor中添加自定義按鈕。 我正在使用CKEditor ng2-ckeditor 。 一切正常。 但我想添加一個按鈕。 在單擊此按鈕時,將添加一個rails模板標簽
例:
我可以像下面的示例一樣添加按鈕,但是我不知道如何編寫其方法。 它將在CKEditor中文本的當前位置上插入<%= sender_name %>
標記。
<ckeditor
[(ngModel)]="ckeditorContent">
<ckbutton [name]="'saveButton'"
[command]="'saveCmd'"
(click)="save($event)"
[icon]="'save.png'"
[label]="'Save Document'"
[toolbar]="'clipboard,1'">
</ckbutton>
</ckeditor>
請幫我。 我該如何在angular2打字稿中做到這一點。
終於我找到了解決方案。 這很容易。 很容易。
在ckeditor.component.html中
<ckeditor
[(ngModel)]="ckeditorContent">
<ckbutton [name]="'saveButton'"
[command]="'insert_name'"
(click)="insert_name($event)"
[icon]="'./path/to/icon.png'"
[label]="'Insert User Name'"
[toolbar]="'clipboard,1'">
</ckbutton>
</ckeditor>
ckeditor.component.ts
insert_name(event){
event.insertText("#{user_name}");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.