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

How do you enable 'style_formats'? #9

Open
atmmarketing opened this issue May 1, 2014 · 1 comment
Open

How do you enable 'style_formats'? #9

atmmarketing opened this issue May 1, 2014 · 1 comment

Comments

@atmmarketing
Copy link

If you add it as a property, then the value is wrapped in double quotes. This is wrong, since the value is a native JS array.

@atmmarketing
Copy link
Author

I figured out a workaround: edit the file /core/components/tinymce/templates/script.tpl

Right after:

Tiny.config = <?php echo $this->modx->toJSON($this->properties); ?>;

Add something like:

Tiny.config.style_formats = [ ...my javascript array values here...  ];

Or you can be a little tricky and add a property called style_formats and then correctly add it yourself:

<?php 
if($this->properties['style_formats']){
    echo 'Tiny.config.style_formats = ' . $this->properties['style_formats'] .';';  
}
?>

This is what I've done and it works, however be aware that the property is also included in the first line above.

I would actually suggest completely ditching modx->toJSON(), it's far too aggressive for what needs to be done with TinyMCE properties. A simple for loop echoing out the array as a JSON object literal would suffice. At least then you could do a quick check for control characters like [ or look at the key and leave off the quotes for things that require javascript array literals.

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

0 participants