使用 tinymce 的多个实例
import 'tinymce/tinymce.min.js';
import 'tinymce/themes/modern/theme';
import '../assets/emoticons/plugin.js';
import 'tinymce/plugins/paste/plugin.js';
import 'tinymce/plugins/link/plugin.js';
import 'tinymce/plugins/autoresize/plugin.js';
import 'tinymce/plugins/image/plugin.js';
import 'tinymce/plugins/imagetools/plugin.js';
import 'tinymce/plugins/searchreplace/plugin.js';
import 'tinymce/plugins/autolink/plugin.js';
import 'tinymce/plugins/fullscreen/plugin.js';
import 'tinymce/plugins/media/plugin.js';
import 'tinymce/plugins/table/plugin.js';
import 'tinymce/plugins/hr/plugin.js';
import 'tinymce/plugins/insertdatetime/plugin.js';
import 'tinymce/plugins/advlist/plugin.js';
import 'tinymce/plugins/lists/plugin.js';
import 'tinymce/plugins/textcolor/plugin.js';
import 'tinymce/plugins/contextmenu/plugin.js';
import 'tinymce/plugins/colorpicker/plugin.js';
import 'tinymce/plugins/help/plugin.js';
declare var tinymce: any;
public notes = {
selector: '#notes',
height: 500,
width: '40%',
skin_url: 'skins/lightgray',
plugins_url: '/test/',
document_base_url: 'assets',
plugins: [
'emoticons',
'paste',
'link',
'autoresize',
'image',
'imagetools',
'searchreplace',
'autolink',
'fullscreen',
'media',
'table',
'hr',
'insertdatetime',
'advlist',
'lists',
'textcolor',
'contextmenu',
'colorpicker',
'help'
],
toolbar1: 'newdocument fullscreen media | \
emoticons | undo redo cut copy paste pastetext | \
formatselect fontsizeselect subscript superscript | \
bold italic strikethrough forecolor backcolor | link | \
alignleft aligncenter alignright alignjustify | \
numlist bullist outdent indent | removeformat | image | help',
image_advtab: true,
imagetools_toolbar: 'rotateleft rotateright | flipv fliph | editimage imageoptions',
paste_data_images: true
};
public details = {
selector: '#opportunity',
height: 500,
width: '40%',
skin_url: 'skins/lightgray',
plugins_url: '/test/',
document_base_url: 'assets',
plugins: [
'emoticons',
'paste',
'link',
'autoresize',
'image',
'imagetools',
'searchreplace',
'autolink',
'fullscreen',
'media',
'table',
'hr',
'insertdatetime',
'advlist',
'lists',
'textcolor',
'contextmenu',
'colorpicker',
'help'
],
// tslint:disable-next-line:max-line-length
// toolbar2: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat',
toolbar1: 'newdocument fullscreen media | emoticons | undo redo cut copy paste pastetext | \
formatselect fontsizeselect subscript superscript | \
bold italic strikethrough forecolor backcolor | link | \
alignleft aligncenter alignright alignjustify | \
numlist bullist outdent indent | removeformat | image | help',
image_advtab: true,
imagetools_toolbar: 'rotateleft rotateright | flipv fliph | editimage imageoptions',
paste_data_images: true
};
public ngAfterViewInit(): void {
tinymce.init(this.details); //to show on first tab initially
}
在您的 mat-tab-group 中,使用选项卡更改功能将事件传递给它
<mat-tab-group #tabGroup (selectedTabChange)="tabSwitch($event)">
**然后处理事件的函数会在初始化另一个实例之前删除以前的实例*
tabSwitch(tabEvent: MatTabChangeEvent) {
switch (tabEvent.index) {
case (0):
tinymce.remove();
tinymce.init(this.details);
break;
case (2):
tinymce.remove();
tinymce.init(this.notes);
break;
default:
tinymce.remove();
break;
}
}