Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am looking for a way to control the rich text options availabe in the new SharePoint 2010 wiki sites - not the Enterprise Wikis, but the new wiki format that is the default team site template.

On our publishing site, I was able to easily do this by adding a few properties to the HTML Field Control in the page layout. For instance, using the PrefixStyleSheet property I was able to completely customize the items available in the Styles and Markup Styles menus.

However, I've been unable to locate any page layout-like file to modify these settings on the new wiki-based team sites.

If nothing else, I would like to be able to customize the items in the Markup Styles menu, removing some of the styles and adding a few new ones. I would prefer NOT to edit the OOTB styles to do this.

Can it be done?

share|improve this question

2 Answers 2

Insert this at the bottom of your masterpage before the </body> end tag:

<script type="text/javascript">
    $(document).ready(function () {
        $("div[RteRedirect]").each(function () {
            var id = $(this).attr("RteRedirect");
            editSettings = $("#" + id);
            if (editSettings.length > 0 && editSettings[0].PrefixStyleSheet != 'YOUR_PREFIX_HERE') {
                editSettings[0]['PrefixStyleSheet'] = 'YOUR_PREFIX_HERE';
            }
        });
    });
</script>

It requires jQuery though for the above to work.

share|improve this answer

I see you changed the scope of your question with your edit, but I have a solution that will change the content editor default. I've tried to summarize and show examples, but there is more good stuff here and here.

Changing the Default Text Style in the Content Editor

This will change the default font size in the wiki editor:

.ms-wikicontent, .ms-wikicontent p, 
.ms-rtestate-field, .ms-rtestate-field p,
.ms-rte-layoutszone-inner-editable, .ms-rte-layoutszone-inner-editable p, 
.ms-rtestate-write, .ms-rtestate-write p{
    font-size: 10pt;
    font-family: Verdana,Geneva,sans-serif;
    color: gray;
}

And if you want to change the default style for hyperlinks:

.ms-wikicontent a, 
.ms-rtestate-field a,
.ms-rtestate-write a,
.ms-rte-layoutszone-inner-editable a{
    color:#2572BC;
    text-decoration: none;
}
.ms-wikicontent a:hover, 
.ms-rtestate-write a:hover,
.ms-rtestate-field a:hover,
.ms-rte-layoutszone-inner-editable a:hover{
    color:#F37B00!important;
    text-decoration: none;
}

This will work on all wiki pages - both Team Site and Enterprise Wikis. If you want to not work on Enterprise wikis, then remove the .ms-rtestate-field classes from those declarations.

Just add it to your master page or to your custom css somewhere. Or you could even put it in a content editor for a particular page.

The declarations cover not only regular wiki content, but wiki content whilst in edit mode - both for the p element and for text without the p element. Apparently, the style class changes when you enter edit mode.


Customize the Existing Styles from the Dropdown

I want to rather select (as default) the second (or another) option from font-size drop down menu than change all with CSS.

Ah, to do this, I think you will need to use some javascript, OR (since you don't want to edit CoreV4.css, which means you can't remove them except with javascript) then you can at least CUSTOMIZE them. To do that, you copy all the .ms-rteElement- prepended entries from CoreV4.css and put them in your own css file and load it after CoreV4.css gets loaded so as to override them. NOW, without changing the names of the css classes (if you change the names you can't overide them) it would make sense that you should be able to change the names in the dropdown list to whatever you want, but I haven't figure out yet why it doesn't work. You CAN change the style, but the name won't change.

For example, here is the Heading 1 item from the dropdown menu:

H1.ms-rteElement-H1{
    -ms-name:"Heading 1";
    font-weight:normal;
    font-size: 10pt;
}
.ms-rteElement-H1{
    font-size:2em;
    font-weight:normal;
}

and you would customize it without changing the class name:

H1.ms-rteElement-H1{
    -ms-name:"My Custom Heading 1";  /*Actually, for some reason this won't change*/
    font-weight:normal;
    font-size: 15pt;
    color: green;
}
.ms-rteElement-H1{
    font-size:2em;
    font-weight:normal;
}

Adding Your Own Styles to the Existing Styles from the Dropdown

enter image description here

However, if you want to ADD your own styles, that's pretty easy. You can put any style you want here, and it will appear right in the dropdown menu. Remember that Markup Styles are more or less for blocks, while Text Styles are for styling pieces of the text within a Markup Styled block.

For a Markup Style, just prefix the style name with .ms-rteElement-mkg-

For a Text Style, use this prefix: .ms-rteStyle-

It's really easy; here's an example:

/*------Wiki Text Styles-------------------------------------------------------*/
/* You can put any style you want here, and it will appear right in the
dropdown menu.  Just prefix the style name with .ms-rteStyle-    */
.ms-rteStyle-my-comment{
    -ms-name: "My Comment Style";
    color: #7F94AA;
    font-weight: normal;
    font-style: italic;
}

/*This will put an icon just in front of the selected text.*/
.ms-rteStyle-my-icon-text{
    -ms-name: "My Icon Text";
    background: transparent url("/_layouts/my/images/anicon.png") no-repeat;
    background-position: left center;
    height:16px;            /*This is necessary for IE*/
    padding-left: 18px;
}


/*------Wiki Markup Styles---------------------------------------------*/
/* You can put any style you want here, and it will appear right in the
dropdown menu.  Just prefix the style name with .ms-rteElement-mkg-    */
DIV.ms-rteElement-mkg-my-CommentBlock-div{
    -ms-name:"My CommentBlock";
    font-style: italic;
    font-size: 8pt;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.