October: Custom Froala plug-in doesn't initiate

Created on 29 May 2019  路  11Comments  路  Source: octobercms/october

  • OctoberCMS Build: 455
  • PHP Version: 7.3
  • Plugins Installed: Multiple but also tested on a clean install

Description:

I have a plug-in which extends the Froala editor. Everything worked fine until I updated from version 447 to the latest version (455). Since the update my Froala plug-in doesn't seem to initiate anymore. As seen in the code below I'd expect a console log with 'init works' but it never happens. I have also tested versions 448, 449, 450, 451, 452 453 and 454 and it seems to break when updating to 455 (454 works fine).

Steps To Reproduce:

In Plugin.php

    public function boot()
    {
        RichEditor::extend(function ($widget) {
            $widget->addJs('/path/to/assets/js/froalaPlugin.js');
        });
    }

in froalaPlugin.js

(function ($) {
    $.FroalaEditor.PLUGINS.froalaPlugin = function (editor) {
        // The start point for your plugin.
        function _init () {
            console.log('init works');
            // ... more code ... 
        }
        return {
            _init: _init,
        }
    }
})(jQuery);

A thing to note is that I also have another Froala extension that doesn't rely on being a plug-in but rather just adds a couple of commands. This still seems to work fine:

(function ($) {
    $.FroalaEditor.DefineIcon('insertUlCheck', {NAME: 'check'});
    $.FroalaEditor.RegisterCommand('insertUlCheck', {
        title: 'Insert ul check',
        focus: true,
        undo: true,
        refreshAfterCallback: true,
        callback: function () {
            this.html.insert('<ul class="list-icon list-icon--check"><li></li></ul>');
        }
    });
})(jQuery);

After some further digging it seems to be related to this commit: https://github.com/octobercms/october/commit/8448d4b972b08078e6572e538c8437feb1564539

Completed Bug

All 11 comments

@NathanBastiaans Based on that commit, do your user have permissions to access media manager (media.manage_media)?

Yes, even as a super user my custom plug-in doesn't work.

Could @NathanBastiaans you try removing js part from that pr, build assets and retry.

Pushing plug-ins, seems like a problem here, should do the extend.

I don't think I have time to do that today but I'll definitely do this sometime this weekend!

Hopefully, will get this fix soon 馃憤 Should be a quick one.

@NathanBastiaans can you test PR #4356 ? I used the procedure you provided above to test and it restores original behavior in my case. Make sure you rebuild assets if you hack the code manually, otherwise the minified JS code has been checked in with the PR.

Thanks.

Did a couple of tests with my froala plug-ins and everything seems to work fine after fetching your PR! Thanks!

@w20k you can close this one now.

Thanks.

@mjauvin no need, will be closed automatically after merge to master.

@w20k auto closing only works when a key word (fixes, resolves, etc) is used in connection with the issue link / number in a commit message when that commit gets merged to master. Since that's not present in https://github.com/octobercms/october/commit/30f4d4c5af180efb21a6e53f023b3b01b76fa891 this issue won't auto close FYI

Thanks, @LukeTowers for pointing it out. Always thought it was @LukeTowers magic 馃槃

Was this page helpful?
0 / 5 - 0 ratings