setting style_formats

136 views
Skip to first unread message

tvdeyen

unread,
Mar 29, 2010, 2:38:40 PM3/29/10
to tinymce_hammer
For custom formats one has to pass this configuration to tinyMCE.init
function:

// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
]

How do set this in the tinymce_hammer.rb initializer file?

Trevor Rowe

unread,
Mar 30, 2010, 12:02:22 PM3/30/10
to tinymce...@googlegroups.com
Its not a pretty solution but you should be able to do something like this:
Tinymce::Hammer.init = [
 
[:style_formats, "[{title:'Bold text', inline:'b'}, {title:'Red header', block:'h1', styles:{color:'#fff'} ....]"],
  ...
]
I've been planning to revisit the configuration interface.  I will probably modify it to allow for:
- a traditional (unordered hash)
- a javascript string
The string version would make this simpler.  There really isn't much benefit to the arbitrary method of settings it through ruby code as its is never used by ruby and is converted straight to javascript.   I'll try to put this in with the next update.
--
You received this message because you are subscribed to the Google Groups "tinymce_hammer" group.
To post to this group, send email to tinymce...@googlegroups.com.
To unsubscribe from this group, send email to tinymce_hamme...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tinymce_hammer?hl=en.


tvdeyen

unread,
Apr 6, 2010, 7:03:18 AM4/6/10
to tinymce_hammer
Ok, thanks i will try that.
For now i discovered a bug in ajax saving the content. I'll post a new
thread for this.

tvdeyen

unread,
Apr 7, 2010, 10:09:39 AM4/7/10
to tinymce_hammer
Sorry, this does not work. I got a long list of 'undefined' entries in
the SelectBox.

But it works to just pass a ruby hash or array. Strange, but good ;)

[:style_formats, [ {:title => 'Bold text', :inline => 'b'} ]] does the
trick!

Funky. Nice. Working.

Thanks and regards

Thomas

On 30 Mrz., 18:02, Trevor Rowe <trevorr...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages