tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
324 stars 93 forks source link

image_list setting does not update view #132

Closed ReinierGielen closed 4 years ago

ReinierGielen commented 4 years ago

The image_list in the setting object does not update the view.

This is my current settings code:

this.options = {
  base_url: environment.rootdir_tinymce + '/tinymce',
  suffix: '.min',
  toolbar: 'bold italic removeformat| forecolor backcolor hr | alignleft aligncenter alignright alignjustify| bullist numlist|' +
    ' formatselect fontsizeselect | link | outdent indent | undo redo | preview image code',
  plugins: 'hr lists link preview image code',
  menubar: false,
  statusbar: false,
  relative_urls : false,
  remove_script_host : true,
  document_base_url : environment.server_url + '/img/uploaded/',
  image_list:  this.getImagesList(),
  images_upload_handler: (blobInfo, success, failure) => {
    this.uploadService.uploadBlob(blobInfo);
    success(blobInfo.filename());
  }
};

As you can see I fill teh image_list with a function. This works fine. When I upload a new image to the server the image_list function is triggered and it retreives the new images list. The local variables are filled with the new list. But the dorpdownlist on the screen is NOT updated.

So ther is something wrong with the binding of the view with the model.

When I leave the component and reenter te component so that the onint is triggered again the list is updated in the view.

Can this please be fixed.

SimonFc commented 4 years ago

This is already possible to do if the argument you provide to the image_list setting is a function, not an array with objects which I think is what you're providing now by invoking this.getImageLists(). Take a look at the third example provided to the image_list setting.

In your case I think you would do something similar to:

image_list: (success) => success(this.getImagesList())

Hope this answer helps you!