I'm trying to use the TinyMCE-Elfinder integrator (https://github.com/nao-pon/tinymceElfinder) in my Angular project, where I already have my TinyMCE capsule component working.
The problem is that, in order to get the integrator working, I need to import some JS scripts. I have tried defining them in the same html file as my TinyMCE editor, like this:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css"/>
<!-- elFinder (load latest nightly) -->
<script type="text/javascript" src="https://studio-42.github.io/elFinder/demo/js/elfinder.min.js"></script>
<!-- tinyMCE -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.2.0/tinymce.min.js"></script>
<!-- tinymceElfinder -->
<script type="text/javascript" src="https://nao-pon.github.io/tinymceElfinder/tinymceElfinder.js"></script>
<editor
[(ngModel)]="content"
[init]="{
base_url: '/tinymce',
suffix: '.min',
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount'
],
toolbar:
'undo redo | formatselect | bold italic backcolor link image media | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help | mkdir',
file_picker_callback : mceElf.browser,
images_upload_handler: mceElf.uploadHandler
}"
(onKeyUp)="onKeyUp($event)"
></editor>
And then, as can be seen in the code, defined a file_picker_callback and an image_upload_handler for the editor.
After this, I declared the object used to pass the file_picker_callback and image_upload_handler (mceElf) to my TS file, following the library instructions. Said code looks like this:
...
declare const tinymceElfinder : any;
...
@Component({
})
export class RichEditorComponent {
mceElf = new tinymceElfinder({
url: 'php/connector.minimal.php',
uploadTargetHash: 'l1_lw',
nodeId: 'elfinder'
});
...
}
However, when I try to run my app, I get the following error:
ERROR Error: "Uncaught (in promise): ReferenceError: tinymceElfinder is not defined
My guess is that Angular is ignoring the HTML imports. I'm fairly new to Angular so I really don't know how to deal with this properly. Does anybody have a solution?