Copied to clipboard

Flag this post as spam?

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


  • William Charlton 171 posts 218 karma points
    Jan 30, 2013 @ 14:28
    William Charlton
    0

    Getting styles in the RT Editor when using uLess

    uLess is great but the only way I can find of adding styles to the RT Editor is to create a dummy CSS file and add styles to that which match styles used in the .less file(s).

    Is there any way to get the Editor to see styles added to the .less files?

  • Justin Spradlin 139 posts 347 karma points
    Jan 30, 2013 @ 18:18
    Justin Spradlin
    0

    I may be a little confused. What do you mean by "RT Editor"? Are you talking about the ability to customize the site while looking at the front end like you do when you install some of the default starter kits? If so I have never used that feature and can't seem to find the documentation on how to make it work. I think I have seen it before and it depends on specific CSS syntax being in your file. If this is the feature, do you have the link to the docs?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 30, 2013 @ 18:34
    Jan Skovgaard
    0

    Hi William

    In order to be able to style the styles defined for use in the rich text editor you should simply just create the styles in the settings section in the "stylesheet" folder. But you don't need to add the styles in here.

    You can define them in your "styles.less" or whatever the filename you're using.

    When the defined styles in the "styles" dropdown have been selected the classname is usually added in the source so you can target them from any CSS file.

    Hope my explanation makes sense.

    /Jan

  • Justin Spradlin 139 posts 347 karma points
    Jan 30, 2013 @ 18:39
    Justin Spradlin
    0

    I'm sorry, I totally didn't think that RT Editor meant rich text editor. Sorry for the random post above. :)

    I found this wiki page about adding styles to the drop down in the editor. http://our.umbraco.org/wiki/how-tos/customizing-the-wysiwyg-rich-text-editor-(tinymce)/add-styles-to-the-drop-down-menu-for-editors-to-use

    I hope it helps.

    Justin

  • William Charlton 171 posts 218 karma points
    Jan 31, 2013 @ 09:44
    William Charlton
    0

    @Justin - Yes, I know about the method for adding styles to the Richtext Editor (RTE). The only problem with this is that now I have a CSS stylesheet that is just there so that I can have styles available in the RTE styles dropdown, unless I reference this css in my template which rather misses the point of using .less. It's no huge deal but it is duplication and isn't very elegant

    @Jan - I'm using uLess for all my styling; are you saying I can somehow modify the RTE datatype to use .less files in the list under "Related stylesheets:"? At the moment the only options I get here are files stored under /css whereas the .less files are stored under /less

  • Justin Spradlin 139 posts 347 karma points
    Jan 31, 2013 @ 14:51
    Justin Spradlin
    0

    I am not sure that this will be possible without alterations to the core umbraco code. I just looked at the latest and I found this class http://umbraco.codeplex.com/SourceControl/changeset/view/a94f28d74a53#src/umbraco.editorControls/tinyMCE3/TinyMCE.cs

     

    It looks like the behavior to use the CSS directory and .css files is hard coded. Also, the tree control in uLess doesn't allow you to right click and "add" new styles to the .less file.

     (sorry, I can't get the formatting right, but look in the constructor about half way down for the code for the stylesheets.)

    // Styles string cssFiles = String.Empty; string styles = string.Empty; foreach (string styleSheetId in _stylesheets) { if (styleSheetId.Trim() != "") try { var s = StyleSheet.GetStyleSheet(int.Parse(styleSheetId), false, false); if (s.nodeObjectType == StyleSheet.ModuleObjectType) { cssFiles += IOHelper.ResolveUrl(SystemDirectories.Css + "/" + s.Text + ".css"); foreach (StylesheetProperty p in s.Properties) { if (styles != string.Empty) { styles += ";"; } if (p.Alias.StartsWith(".")) styles += p.Text + "=" + p.Alias; else styles += p.Text + "=" + p.Alias; } cssFiles += ","; } } catch (Exception ee) { Log.Add(LogTypes.Error, -1, string.Format( string.Format("Error adding stylesheet to tinymce (id: {{0}}). {0}", ee), styleSheetId)); } } // remove any ending comma (,)if (!string.IsNullOrEmpty(cssFiles)) { cssFiles = cssFiles.TrimEnd(','); }
    
  • William Charlton 171 posts 218 karma points
    Jan 31, 2013 @ 14:57
    William Charlton
    0

    Thanks Justin, I thought that would be the case. Hey ho, I'll just keep to my duplicate stylesheet ;)

Please Sign in or register to post replies

Write your reply to:

Draft