angular2 wysiwyg tinymce implementation and 2-way-binding

后端 未结 4 824
独厮守ぢ
独厮守ぢ 2020-12-06 19:25

Hi I\'m trying to implement tinymce into an angular 2 component for a small forum to create a new thread. I want the content of the textarea (tinymce) be 2-way-binded to a v

4条回答
  •  时光取名叫无心
    2020-12-06 19:37

    Or do it like this, using tmce's change event and NgZone

    constructor(public zone:NgZone) {}
    
    ngOnInit():any {
        tinymce.init(
          {
            selector: ".tinyMCE",
            setup: (ed) => {
              ed.on('keyup change', (ed, l) => {
                this.zone.run(()=> {
                  this.text = tinymce.activeEditor.getContent();
                });
              });
    
            }
          })
      }
    

    This would fail once you have more than one instance on tmce in one component. Put this logic in a directive like Thierry's implementation.

提交回复
热议问题