Typescript 如何使用angular2项目安装tinymce?

Typescript 如何使用angular2项目安装tinymce?,typescript,angular,tinymce,Typescript,Angular,Tinymce,我需要在我的项目angular2中集成一个编辑器 我选择tinymce,但我不知道如何安装它 我发现了类似于: tinymce.init({ selector: '.tinymce-editor', schema: 'html5', }); 使用ngForm、ControlGroup、NgZone:执行指令 从'@angular/core'导入{ElementRef,指令,NgZone}; 从“@angular/common”导入{ControlGroup,Control}

我需要在我的项目angular2中集成一个编辑器

我选择tinymce,但我不知道如何安装它

我发现了类似于:

tinymce.init({
    selector: '.tinymce-editor',
    schema: 'html5',
  });
使用ngForm、ControlGroup、NgZone:执行指令

从'@angular/core'导入{ElementRef,指令,NgZone};
从“@angular/common”导入{ControlGroup,Control}”;
@指示({
输入:['tinyMce'],
选择器:“[tinyMce]”
})
导出类TinyEditor{
公共场所:对照组;
私人专区:NgZone ;;
私有id:string=Math.random().toString(36).substr(2,5);
私有控件名:字符串;
私人控制:控制;
公共构造函数(私有elRef:ElementRef,私有区域:NgZone){
}
public ngOnInit():void{
此.zone.runOutsideAngular(()=>{
this.controlName=this.elRef.nativeElement.getAttribute('ngControl');
this.theControl=this.tinMce.find(this.controlName);
this.elRef.nativeElement.setAttribute('tiny-id',id);
});
}
public ngAfterViewInit():void{
此.zone.runOutsideAngular(()=>{
tinymce.init({
有效的_元素:'*[*]',
选择器:'[tiny id='+this.id+']',
模式:“html5”,
身高:400,
设置:(编辑器):void=>{
编辑器.on('keyup change',()=>{
此.zone.run(()=>{
let值:Object=editor.getContent();
this.theControl.updateValue(值,{emitEvent:true});
this.theControl.markAsDirty();
this.theControl.markAsTouched();
this.theControl.updateValue和validity();
});
});
}
});
});
}
公共Ngondestory():void{
试一试{
tinymce.remove('[tinyid='+this.id+']);
}捕获(e){
console.error('error:',e);
}
}
}
用法:



这样,您也可以在一个页面上拥有任意多的实例。

看看这篇文章:我已经回答了另一个问题