Rich text toolbar
To deploy a rich-text toolbar, you define it as a class and then assign the class to a field.
Defining a toolbar class
You can deploy customized rich-text editors that have certain controls for marking up text. For example, the following class provides only the boldface, italics, underline, and hyperlink buttons.
showLineNumbers {5,8}
1import com.psddev.cms.rte.RichTextToolbar;2import com.psddev.cms.rte.RichTextToolbarItem;3import com.psddev.cms.rte.RichTextToolbarStyle;45public class CustomRichTextToolbar implements RichTextToolbar { 167@Override8public List<RichTextToolbarItem> getItems() { 29return Arrays.asList(10RichTextToolbarStyle.BOLD,11RichTextToolbarStyle.ITALIC,12RichTextToolbarStyle.UNDERLINE);13}14}
- 5. Specifies a class that implements
RichTextToolbar. - 8. Specifies the controls appearing in the toolbar.
Associating a toolbar class with a rich-text field
You associate a customized rich-text editor with a text field using the @ToolUi.RichTextannotation.
showLineNumbers {6}
1import com.psddev.cms.db.Content;2import com.psddev.cms.db.ToolUi;34public class Article extends Content {56@ToolUi.RichText(toolbar=CustomRichTextToolbar.class) 178private String body;910}
- 6. Applies the toolbar class created in Defining a toolbar class to the rich-text field body.
The following classes have controls which can be used in your customized rich-text toolbar's getItems method:
See also: