Rich Text Editor

The rich text editor (RTE) is a complex control for data input and editing.
It allows users to format the text and insert different types of elements within the text, such as hyperlinks or code blocks.

 

Anatomy

 

Main Component

Anatomy_Main Component
  1. RTE Toolbar: Options to show more buttons and button groups
  2. RTE Container: State styles are the same as for Text Inputs
  3. Content Block: Options for headings, text, code, and quote blocks

RTE Toolbar

Anatomy_RTE Toolbar
  1. RTE Toolbar Button Group
  2. RTE Button - uses the Button component, main options: icon-only, text dropdown
  3. Divider - option to show or hide on the right or left side of the group
  4. Slot - enables including more components

 

 

Best Practices - RTE Toolbar

 

Ordering and Grouping Buttons

Grouping buttons meaningfully and ordering them according to relevance can help users find formatting options more easily.

Don't

Avoid mixing formatting options that belong to different contexts.

Do

Identify groups that can represent formatting options in a meaningful way.

Tooltips for dropdown options

To keep the experience consistent, besides icon-only components, dropdown options should also have tooltips on hover.
Instead of repeating the chosen option, show a group name for all the options.

Don't

Avoid repeating the currently selected optionโ€™s name in the tooltip.

Do

Use a group name for all the options. In this example, weโ€™ve named all the options within the dropdown (heading 1, heading 2, paragraph, etc.) โ€œRich Styleโ€.

 

Responsive Guidelines

 

Context Menu for hidden options

In case the toolbar doesnโ€™t fit the available space horizontally, the options should be included in a Context Menu.
In the coded component, entire Button Groups get transferred under the Context Menu (instead of leaving a fraction of Button Group visible), except for the insert link button.
The insert link button opens.

context-menu

๐Ÿ’ก Use the button instance property on the .RTE Button subcomponent to swap for the Context Menu Button quickly.

 

Inserting a link requires further inputs (display name and URL). To avoid multiple menu and popover levels, this action should always remain visible.

context-menu-link

 

Multi-level menu

To show options that are parents, - for eg. rich style - it is recommended to place a Menu component next to the Context Menu.

multi-level menu

Menu Placement

  • Aligned to the Context Menu, spacing: 4xs (4px)
  • Depending on the available space, the secondary menu can either be on the right or left-hand side.

Naming the parent option
Use a name that describes all the options, eg. Rich style includes headings and paragraphs.


Tweaking the width of the Context Menu

  • Set the label_subtext layer to hug
  • Set the Menu to hug
  • Change the horizontal gap between options to Auto for the parent option(s)
  • Add some right (eg. 40px) padding to one of the options

๐Ÿ“ The coded component already has this responsive behavior, there is no need to spec this in designs.

 

 

Examples and Options

 

Content

There are preset content variants in the RTE:

  • Heading (1,2,3 levels)
  • Paragraph
  • Code block
  • Quote block
  • Link

The spacing between two content blocks (any variant) is spacing-xs (16px).

content

 

Adding custom content

To add custom content, use the slot within the content area.
The slot enables you to add any type of custom component with custom sizing, and you can also use the content blocks to display more content than the preset.

Frame 167689

 

Discarding draft

It is recommended to give users an option to discard the draft theyโ€™ve been editing.
Placing this action on the right of the toolbar - via the global action property - separates it from other options.

Frame 167689

 

 

Inserting with Popover and Form

Use the combination of a Popover and a Form for inserting options that require inputs from the users.

Frame 167689

 

 

Rich Text Editor-Specific Base Components

In order to accelerate the design process for standard RTE options, we have included some out-of-the-box base components.

๐Ÿ“ These components are restricted for the Rich Text Editor.

 

RTE Menu

The RTE Menu component enables including custom components within the menu via a slot. โ€จ
You can also use base components from the preferred instances.

In the below examples the slot is replaced by the RTE Rich Style List and the RTE Color Palette base components.

RTE Menu

 

Menu

Text Area

Tooltip

Popover

Modal

Forms