Skip to main content

Configure N1ED dynamically using API

The Dashboard is the best way to configure N1ED, but it holds one configuration per API key. What if some values depend on who is editing? For example, you want a separate upload folder for every user, or some features only for some user roles.

For that, pass the parameters in the config of the editor itself, the same place where you enable N1ED. They are the same parameters the Dashboard sets, and a value you pass there wins over the Dashboard's. Everything you don't pass still comes from the Dashboard.

Every parameter in this documentation is shown in a box like this one:

Example parameter​

Some parameter for sample

API parameter
example.param
Type
string
Default
null
Dashboard
where the Dashboard sets it, if it does

Some description

The dots in the name are levels of objects: Flmngr.urlFiles is urlFiles inside a Flmngr object in your config.

The samples below pass one parameter, Flmngr.urlFiles: the files of the user who is logged in, in a folder of their own (see Individual folders for different users or websites).

Passing parameters to TinyMCE​

If you use TinyMCE as a base editor (or Editor42, where editor42.init() works the same way), there is one correct place to pass parameters: the tinymce.init() call that you already use to enable N1ED.

tinymce.init({
selector: "#editor",
plugins: "n1ed",
apiKey: "YOUR-API-KEY",

Flmngr: {
urlFiles: "https://example.com/files/user-42/"
}
});

With the CDN script, the API key is in the script's URL and N1ED is already enabled, so your tinymce.init() has only your own parameters:

<script>
window.onEditorLoaded = function() {
tinymce.init({
selector: "#editor",
Flmngr: {
urlFiles: "https://example.com/files/user-42/"
}
});
}
</script>
<script src="https://cloud.n1ed.com/v/latest/sdk/n1ed.js?apiKey=YOUR-API-KEY"></script>

Passing parameters to CKEditor​

There are two ways to pass a parameter to CKEditor 4. The first one is the same as with TinyMCE: add it to the config you pass to CKEDITOR.replace(). Its first argument is the id (or name) of your textarea, without #:

CKEDITOR.replace("editor", {
extraPlugins: "N1ED-editor",
skin: "n1theme",
allowedContent: true,
removePlugins: "iframe,magicline",
apiKey: "YOUR-API-KEY",

Flmngr: {
urlFiles: "https://example.com/files/user-42/"
}
});

The second one is for when you call replace() without parameters and keep them in CKEditor's config.js file:

CKEDITOR.editorConfig = function(config) {
config.extraPlugins = "N1ED-editor";
config.skin = "n1theme";
config.allowedContent = true;
config.removePlugins = "iframe,magicline";
config.apiKey = "YOUR-API-KEY";

config.Flmngr = {
urlFiles: "https://example.com/files/user-42/"
};
};

When you use both, CKEditor takes each top-level object from replace() as a whole: a Flmngr object there replaces the one in config.js instead of adding to it.

What cannot be passed this way​

A few keys are used by our servers, not by the editor in the browser, so they work only when they are saved in the Dashboard:

Keep in mind that everything you put into the editor's config is visible to anyone who can open the page with the editor, so leave passwords and secret keys out of it.