Terry Windwalker
Terry Windwalker

Reputation: 1888

images_upload_handler in TinyMCE not working on Angular 8

I was trying to use images_upload_handler in my Angular project. I built my editor in this way:

            <editor
                apiKey="7ep8ch9d1u9a3i9k70tuuxzt68xm7a3un2vrgj6y7mr4b2ta"
                initialValue=""
                formControlName="purpose"
                [init]="{
                  height: 310,
                  selector: '#purpose', 
                  plugins: [
                    'advlist autolink lists link image imagetools charmap print',
                    'preview anchor searchreplace visualblocks',
                    'fullscreen insertdatetime media table paste',
                    'wordcount'
                  ],
                  codesample_global_prismjs: true, 
                  toolbar:
                  'undo redo | formatselect | bold italic | \
                  alignleft aligncenter alignright alignjustify | \
                  bullist numlist image ', 
                  image_title: true,
                  automatic_uploads: true,
                  imagetools_toolbar: 'rotateleft rotateright | flipv fliph | editimage imageoptions',
                  file_picker_types: 'image',
                  images_upload_handler: imageupload(blobInfo, success, failure)
                }"
              >
              </editor>

Although imageupload(a, b, c) is triggered successfully, all of bolbInfo, success and failure are undefined. I tried an example on Angular 6 which works normally and can receive blobInfo normally as well.

Please tell me if I have done anything wrong. BTW, my tinymce's version is 4.6.1.

Upvotes: 1

Views: 1415

Answers (1)

Terry Windwalker
Terry Windwalker

Reputation: 1888

images_upload_handler: imageupload(blobInfo, success, failure) turns out to be wrong. It should be images_upload_handler: (blobInfo, success, failure) => imageupload(blobInfo, success, failure) but this is not accepted in the HTML file. So I put the whole init settings to the ts file stored as 'init1'. Now it works normally.

Hope it could help someone.

Upvotes: 1

Related Questions