Style settings with dash in Tinymce v2 format meny

Vote:
 

Hi,

So the new tinymce editor, conveniently, all the examples of setting styles using anonymous objects in C# is using the example "color", but what do I do if I want to set another style, say text-align?

This will obviosuly not compile:

configuration.Default()
.StyleFormats(new {
   title = "Alignment",
   items = new[] {
      new {title = "Left", block = "p", styles = { text-align = "left"}},
      new {title = "Center", block = "p", styles = { text-align = "center"}}
   })...

I have tried various different strings with no success, like styles = "text-align: center". I am guessing there is one, but I am just not able to guess it.

Anyone have an idea how to achieve this?

#206536
Aug 23, 2019 12:25
Vote:
 

Hi Erik,

The following worked for me (although, to be honest, I wasn't really expecting it to!):

config.Default()
    .StyleFormats(new
    {
        title = "Alignment",
        items = new[]
        {
            new {title = "Left", block = "p", styles = new Dictionary<string, string> {{"text-align", "left"}}},
            new {title = "Center", block = "p", styles = new Dictionary<string, string> {{"text-align", "center"}}},
        }
    });
#206556
Edited, Aug 23, 2019 17:37
Vote:
 

hah,

Yes it worked, and I suppose that makes sense.

Thanks!

#206557
Edited, Aug 23, 2019 17:37