Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
MatDialog triggered from tinymce not getting initialized until window resize

I am trying to open MatDialog from tinymce custom button but that matdialog is not getting initialized until I resize the window. I am aware that it is due to the method is written inside tinymce init json object and hence causing problem but don't know what to do:

in component class, I mentioned it like this:

tinyMceConfig: any = {
    menubar: false, plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak','searchreplace wordcount visualblocks visualchars code fullscreen','insertdatetime media nonbreaking save table contextmenu directionality','emoticons template paste textcolor colorpicker textpattern'], toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | code | link Upload',
    setup: (editor) => {
      editor.ui.registry.addButton('Upload', {
        icon: 'browse',
        onAction: ()=> {
          const dialogRef: MatDialogRef<any> = this.dialog.open(UploadmediaComponent, { width: '95vw', disableClose: true, panelClass: 'uploadPanel'});
            dialogRef.afterClosed().subscribe(res => {
              if (!res) {
                return;
              }
              res.forEach(image => {
                console.log(image.url);
                editor.insertContent(image.url);
              });
            });
        }
      });
    }
  };

In component:

<editor formControlName="popupText" name="popupText" apiKey="xxxx" 
                                    [init]="tinyMceConfig"></editor>

I had borken down this code further and separated setup part in ngOnInit but that made no difference.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Just to wrap the initialization of the dialog with ngZone.run and it worked perfect for me:

onAction: ()=> {
            this.ngZone.run(()=> {
              const dialogRef: MatDialogRef<any> = this.dialog.open(UploadmediaComponent, { 
                width: '95vw', disableClose: true, panelClass: 'uploadPanel'});
                dialogRef.afterClosed().subscribe(res => {
                  if (!res) {
                    return;
                  }
                  res.forEach(image => {
                    editor.insertContent('<img src="' + image.url + '">');
                  });
                });
            });
            }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!