CKEditor 4 file manager API
File manager CKEditor 4 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 CKEditor plugin or in a script outside of CKEditor but on the same page).
Flmngr API is available to you when you use the CKEditor 4 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 CKEditor 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.
CKEDITOR.instances["editorId"].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 CKEditor.
// Also there is not need to call Flmngr.load() API method
// because CKEditor 4 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: