Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FroalaEditorAsset throws yii\base\Exception #37

Open
floor12 opened this issue Oct 10, 2019 · 0 comments
Open

FroalaEditorAsset throws yii\base\Exception #37

floor12 opened this issue Oct 10, 2019 · 0 comments
Labels

Comments

@floor12
Copy link
Contributor

floor12 commented Oct 10, 2019

Hi!
When i try to use this widget i get the yii\base\Exception with this message: plugin 'align' is not supported, if you trying to set custom plugin, please set 'js' and 'css' options for your plugin.
When i read a source code i found next two fragments of code:

$this->registerPlugins(array_diff($this->froalaPlugins, $excludedPlugins ?: []), false, true);

and

 public function registerPlugin($pluginName, $checkJs = true, $checkCss = true)
    {
        $jsFile = "js/plugins/$pluginName.min.js";
        if ($checkJs && $this->isPluginJsFileExist($pluginName)) {
            $this->addJs($jsFile);
            $cssFile = "css/plugins/$pluginName.min.css";
            if (!$checkCss || $this->isPluginCssFileExist($pluginName)) {
                $this->addCss($cssFile);
            }
        } else {
            $thirdPartyJsFile = "js/third_party/$pluginName.min.js";
            if($checkJs && $this->isThirdPartyPluginJsFileExist($pluginName)) {
                $this->addJs($thirdPartyJsFile);
                $thirdPartyCssFile = "css/third_party/$pluginName.min.css";
                if (!$checkCss || $this->isThirdPartyPluginCssFileExist($pluginName)) {
                    $this->addCss($thirdPartyCssFile);
                }
            }
            else {
                throw new Exception("plugin '$pluginName' is not supported, if you trying to set custom plugin, please set 'js' and 'css' options for your plugin");
            }
            
        }
    }

In method registerPlugin, when we call it with $checkJs = false we will always throw an exception.
I think, we can change the registerPlugins call to use $checkJs = true:

$this->registerPlugins(array_diff($this->froalaPlugins, $excludedPlugins ?: []), true, true);

After this changing plugins starts ti work. I can make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants