Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Replace or Remove HTML Editor styles in the Sharepoint 2010 Ribbon

I want to replace the HTML Editor styles in the HTML Style dropdown on the editor ribbon with styles of my own creation. According to this MSDN article http://msdn.microsoft.com/en-gb/library/ms551040.aspx as soon as I start putting classes that begin with the pattern ms-rteCustom-XXXX(XXXX being a custom name) into CSS that's loaded in the page, the existing styles should be replaced. I would expect this to leave only my styles in the drop-down, however I can see all of the original Sharepoint styles, and then my styles.

Am I missing something in the documentation, or is it lying to me? As far as I can tell, the original styles come from the corev4.css that's also loaded by the master page, however as my CSS is loaded later, it seems like any styles already in the drop down should be cleared.

Here is one of the new/custom styles in the CSS I'm using;

H3.ms-rteElement-H3CompanyName
{
    -ms-name:"Heading 3";
}
.ms-rteElement-H3CompanyName
{
    font-family: Arial, Helvetica, sans-serif;
    font-size: small;
    font-style: normal;
    line-height: normal;
    font-weight: bold;
    font-variant: normal;
    text-transform: none;
    color: #000000;
}
like image 620
Stark Avatar asked Dec 29 '22 09:12

Stark


1 Answers

The best way to remove the styles, assuming this is a publishing page, is to modify the control within your page layout.

<PublishingWebControls:RichHtmlField FieldName="PublishingPageContent" HasInitialFocus="True" MinimumEditHeight="400px" runat="server" PrefixStyleSheet="customPrefix"/>

By declaring a new PrefixStyleSheet it will remove all of the default styles so that you can only provide your own.

like image 85
Cory Peters Avatar answered Dec 31 '22 00:12

Cory Peters