【发布时间】:2018-02-25 07:22:52
【问题描述】:
我正在使用angular2-tinymce 库在我的 Ionic/Angular 项目中使用 tinymce 编辑器。现在我想根据一些逻辑来梳理编辑器的内容。我的尝试如下:
尝试 1:
我尝试将strikethrough css 类分配给app-tinymce。
// .html file
<app-tinymce class="note-input-textarea" [(ngModel)]='noteText'
[ngClass]="{
strikethrough: isDeleted
}"
[disabled]="canUpdateNoteDetail">
</app-tinymce>
// .scss file
.strikethrough {
text-decoration: line-through;
}
但是没有用。
尝试 2:
// .ts file
export class UpdateProgressNotePage {
@ViewChild(TinymceComponent) private tinyMce: TinymceComponent;
isDeleted: boolean = true;
noteText: string = "Sample Note";
constructor(){
this.initialize();
}
initialize() {
if(isDeleted) {
this.tinyMce.editor.execCommand('Strikethrough', false);
this.tinyMce.editor.execCommand('Strikethrough', false, this.noteText); // Tried with this also but didn't work
}
}
}
但这对我不起作用。我在这个link 中发现Strikethrough 命令可以应用于tinyMce 编辑器。
【问题讨论】:
-
要执行命令,您需要选择一些文本。
-
您能详细说明一下吗?假设我的编辑器内容为
noteText。如何穿透内容?我试过this.tinyMce.editor.execCommand('Strikethrough', false, this.noteText);.. 但它没有用
标签: angular ionic-framework tinymce