Add custom styles to Editor
- Applies to:
- All MindTouch Versions
- Role required:
- Admin
The editor includes preformatted styles by default, but site administrators can configure custom options to appear in the Style drop-down menu in the Editor.
Create inline custom styles to:
- Apply a certain style to text or tables
- Reuse a text style across your site
- Modify style through a global CSS change
Part 1: Add custom style options to the editor
- Navigate to Site tools > Control panel > System Settings > Editor.
- In the Set editor configuration field, add the following sample code:
CKEDITOR.editorConfig = function( config ) { config.stylesSet.push({ name : 'Custom div 1', element : 'div', wrap:true, attributes : { 'class' : 'custom1', 'title' :'Custom_Class1' } }); config.stylesSet.push({ name : 'Custom span 2', element : 'span', wrap:false, attributes : { 'class' : 'custom2', 'title' :'Custom_Class2' } }); };
- Modify the sample code for your custom styles, adding additional lines as needed.
- name: The name that you want to appear in the Styles drop-down menu (Custom div 1 and Custom span 2 in the sample code).
- element: The designated element the style is applied to.
- wrap: Denotes that the element is a block level element, which applies to <div> or <paragraph> elements. For non-block level elements such as <span> or <code>, set this attribute to false or omit the wrap component entirely.
- attributes: The sample code identifies a class (custom1, custom2) and a title (Custom_Class1, Custom_Class2) for the style.
- Click Save to add the custom styles to the editor configuration.
Part 2: Define the CSS format
- Navigate to Site tools > Control panel > Branding > Custom Site CSS.
- Add your custom CSS to style your custom classes.
Part 3: Use your custom styles
- Open a page in Edit mode.
- Highlight text or an element on the page
- Select your custom class from, the Style drop-down menu.
To remove the custom style from the text, highlight the text and select the custom style again or select a different style.