This post shows how you can customise the list of styles that are available inside a RichHtmlField control in SharePoint 2007.
As I mentioned in
an earlier post the RichHtmlField has several properties that you can set to restrict users from entering certain types of markup (images, tables, styles etc). You also have the ability to define the styles that are allowed. For example if you wanted the following styles...
- Title
- Sub-Title
- Caption
- Emphasis
- Quote
...there are a couple of things you need to do.
1. Set the PrefixStyleSheet attribute to some custom name that we will prefix our styles with. For example I might use
<PublishingWebControls:RichHtmlField
FieldName="PublishingPageContent"
PrefixStyleSheet="myStyles"
runat="server"/>
2. Add entries in one of the CSS style sheets that start with myStylesCustom- (note the word 'Custom' has been appended) that contain the style definition. For example:
.myStylesCustom-Title
{
font-weight: bold;
font-family: Georgia;
font-size: 14pt;
color: #aa0000;
}
.myStylesCustom-Sub-Title
{
font-family: Arial;
font-size: 10pt;
color: #999999;
}
.myStylesCustom-Caption
...
Now we have a custom list of styles as follows: