TinyMCE file manager API
File manager TinyMCE add-on adds some buttons to the toolbar, and you can use it right after it is installed and configured. But sometimes you need to implement custom logic (as another TinyMCE plugin or in a script outside of TinyMCE but on the same page).
Flmngr API is available to you when you use the TinyMCE plugin. This means you do not need to manually embed any other scripts. For example, if you have a file field below the WYSIWYG editor, call the method getFlmngr
of the TinyMCE instance always if you wish to get a link to the API (or save the Flmngr object returned in the callback and call it directly each time).
Note: the new API is passed in the callback only (at the first argument). The return value of the method and the second argument of the callback (omit if do you not need it) contain a link to the legacy API. Such a link to the old API exists for backward compatibility only.
tinymce.activeEditor.getFlmngr(
(Flmngr) => {
// Flmngr argument contains Flmngr API,
// for example you can open the file manager and let user pick a file:
Flmngr.open({
// There is no need to set 'apiKey', 'urlFileManager' or 'urlFiles' here
// due to you already set them in the config of TinyMCE.
// Also there is not need to call Flmngr.load() API method
// because TinyMCE already loaded the file manager.
isMultiple: false, // let selecting a single file
onFinish: (files) => {
console.log("User picked:");
console.log(files);
}
});
}
);
See an example of such use here: