Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mike 90 posts 258 karma points
    Mar 20, 2015 @ 16:27
    mike
    0

    tinyMCE style_formats not working

    Hi,

    If I specify in tinyMceConfig.config:

    <config key="style_formats">
            [
            {"title": "Bold text", "inline": "b"},
            {"title": "Red text", "inline": "span", "styles": {"color": "#ff0000"}}
    
            ]
          config>

    Then is doesn't work. I have tried all sorts of different versions of it. I'n the debugger I can see that an escaped string is being passed to the init function. I checked the format against the codemirror value and it looks the same but it doesnt work.

    The styles created from the umbraco style sheets "var styleFormats = [];" are passed as an object inside the javascript code and work fine.

    I tried setting the object in "umbraco.controller.js" instead of reading from inputted string:

    style_formats: [
        { title: 'Bold text', inline: 'b' },
        { title: 'Red text', inline: 'span', styles: { color: '#ff0000' } },
        { title: 'Red header', block: 'h1', styles: { color: '#ff0000' } }
    ]

     and it works fine although the extend function did not merge the styles as extend() doesnt support deep merge:

    if (tinyMceConfig.customConfig) {
                        angular.extend(baseLineConfigObj, tinyMceConfig.customConfig);
                    }

    The "customConfig" is being passed to the tinyMceService but I cannot see anywhere the code for grabbing the data from the actual config file.

    I am reluctant to modify the core.  Should I just create a regex to strip all the escape sequences and parse as a json object inside the if statement above?  I feel like I should be modyfing the code that reads the xml.

    ** sorry about code background, I pasted from dark themed vs.

  • mike 90 posts 258 karma points
    Mar 20, 2015 @ 21:05
    mike
    100

    My input was not valid json which was the issue.  Changed that and added a line of code to umbraco.controller.js to serialize it so I can build submenus on format drop down and it works nicely now.

Please Sign in or register to post replies

Write your reply to:

Draft