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

Plugins not registered #128

Open
marcomarsella opened this issue Dec 11, 2016 · 0 comments
Open

Plugins not registered #128

marcomarsella opened this issue Dec 11, 2016 · 0 comments

Comments

@marcomarsella
Copy link

The issue is in line 104-106 of ImperaviRedactorWidget.php, where it says:

if (!empty($this->_plugins)) {
  $this->options['plugins'] = array_keys($this->_plugins);
}

This block should be replaced with:

if(isset($this->options['plugins'])){
  $this->setPlugins($this->options['plugins']);
  $this->options['plugins'] = array_keys($this->_plugins);
}

The correct syntax for the configuration in this case would be:

'plugins' => array(
	'fontcolor'=>array('js'=>array('fontcolor.js')),
	'fontsize'=>array('js'=>array('fontsize.js')),
	'fontfamily'=>array('js'=>array('fontfamily.js'))
),

However, this seems a bit complicated to me, so I would propose to replace the setPlugins method with:

public function setPlugins(array $plugins) {
	foreach ($plugins as $id => $plugin) {
		if (is_array($plugin)) {
			if (!isset($plugin['baseUrl']) && !isset($plugin['basePath'])) {
				$plugin['baseUrl'] = $this->getAssetsUrl() . '/plugins/' . $id;
				$this->_plugins[$id] = $plugin;
			}
		} else {
			$tmp = array();
			$tmp['baseUrl'] = $this->getAssetsUrl() . '/plugins/' . $plugin;
			$tmp['js']      = array($plugin . '.js');
			$this->_plugins[$plugin] = $tmp;
		}

	}
}

Which would also support the following, much simpler configuration:

'plugins' => array('fontcolor', 'fontsize', 'fontfamily’),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant