2

I'm trying to create my own character counter plugin for the tinymce editor in Joomla 3, which would look exactly like the wordcount plugin. I already have the javascript code for the plugin, and this file is saved in its own folder in "/media/editors/tinymce/plugins/nameofplugin/". Following this tutorial I should add it to the tinymce.init as a plugin option inside the "/media/editors/tinymce/tinymce.min.js" but I don't find the tinymce.init field in there. Also I doubt if I should create a for the Character count label, but I don't know how to modify the article html file.

Thank you!

1 Answer 1

1

Though I am not TinyMCE expert, looking into the unminified version of tinymce.min.js I would say all plugins are loaded automatically (with themes and languages) if they follow the convention of storing them under plugins directory:

/plugins/{plugin_name}/plugin.min.js

Here is the piece of code I think is responsible for loading:

function t() {
    var e = m.ScriptLoader;
    if (r.language && "en" != r.language && !r.language_url && (r.language_url = n.editorManager.baseURL + "/langs/" + r.language + ".js"), r.language_url && e.add(r.language_url), r.theme && "function" != typeof r.theme && "-" != r.theme.charAt(0) && !S.urls[r.theme]) {
        var t = r.theme_url;
        t = t ? n.documentBaseURI.toAbsolute(t) : "themes/" + r.theme + "/theme" + o + ".js", S.load(r.theme, t)
    }
    w.isArray(r.plugins) && (r.plugins = r.plugins.join(" ")), A(r.external_plugins, function(e, t) {
        T.load(t, e), r.plugins += " " + t
    }), A(r.plugins.split(/[ ,]/), function(e) {
        if (e = L(e), e && !T.urls[e])
            if ("-" == e.charAt(0)) {
                e = e.substr(1, e.length);
                var t = T.dependencies(e);
                A(t, function(e) {
                    var t = {
                        prefix: "plugins/",
                        resource: e,
                        suffix: "/plugin" + o + ".js"
                    };
                    e = T.createUrl(t, e), T.load(e.resource, e)
                })
            } else T.load(e, {
                prefix: "plugins/",
                resource: e,
                suffix: "/plugin" + o + ".js"
            })
    }), e.loadQueue(function() {
        n.removed || n.init()
    })
}
11
  • Thanks for the answer! I already have my plugin inside that folder but nothing happens. Not even the "Character> " string prints. Do you think there should be something else done?
    – republicca
    Commented Jul 8, 2015 at 14:16
  • I am not sure, seems that you should add it also to TinyMCE plugins parameters to enable. See Editor - TinyMCE plugin. But it requires to modify XML-manifest for this plugin. Commented Jul 9, 2015 at 6:07
  • You are totally right! By adding the folder to the plugins folder and modifying the xml manifest file the plugin is done! Thank you!!
    – republicca
    Commented Jul 9, 2015 at 7:21
  • The bad side of this that XML-manifest could be reverted on next CMS update... Commented Jul 9, 2015 at 7:35
  • 1
    Hmm, can you try to use "Custom Plugin" field in Editor - TinyMCE settings? I found this in the code: $custom_plugin = $this->params->get('custom_plugin', ''); $plugins[] = $custom_plugin; Seems that you should write your plugin name there and it will be loaded. Commented Jul 9, 2015 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.