aelvan / RedactorStyles-Craft

Craft wrapper for the Styles Redactor plugin.
MIT License
19 stars 1 forks source link

Redactor fails to initialize if Styles JSON Object field is empty #4

Open alexroper opened 9 years ago

alexroper commented 9 years ago

I'm getting an error where Redactor fields will fail to initialize if the "Styles JSON Object" field is left blank in the plugin settings. Any Redactor fields are inaccessible then.

The console shows this error in Chrome:

Uncaught ReferenceError: RedactorStyles is not defined
bransinanderson commented 9 years ago

A quick fix is to put an empty JSON object in the plugins settings field

"Styles JSON Object" {}

Redactor Styles 0.3 Craft Client 2.4.2682

This would happen when using the Simple layout on a Rich text field. Simple.json { buttons: ['bold', 'italic'], plugins: ['styles'], toolbarFixed: true, stylesJson: RedactorStyles.stylesJson }

Looks like the problem occurs here: https://github.com/aelvan/RedactorStyles-Craft/blob/master/RedactorStylesPlugin.php#L40

$stylesJson is empty, therefore the RedactorStyles JSON object is not defined.