jodit / jodit-angular

Angular wrapper for Jodit && Hey. Due to the fact that I do not use Angular in my projects, I cannot fix plugin errors in a timely manner. If you want the plugin to develop, send PR or better become a contributor
MIT License
48 stars 35 forks source link

Get editor upon component init #104

Open crlsmsq opened 2 years ago

crlsmsq commented 2 years ago

Hi I would like to get the editor upon initialization. is there any way i could do this?

jpakulski commented 2 years ago

You can try the following.

In your template:

<jodit-editor #editor></jodit-editor>

in your component:

import { Component, OnInit, ViewChild } from '@angular/core';
import { JoditAngularComponent } from 'jodit-angular';

@Component({
  selector: 'app-foo',
  templateUrl: './foo.component.html',
  styleUrls: ['./foo.component.scss']
})
export class FooComponent implements OnInit {
  @ViewChild('editor', { static: true }) editor: JoditAngularComponent;

  ngOnInit(): void {
    this.editor.value = 'Hello from foo.';
  }
}

An editor loaded event with the editor as a param to the callback would be awesome, but I don't think it's implemented :(

Cheers.