RichEditor
richEditor · Components · interactive
A rich text editor: blocks of text, marks over ranges, and a toolbar.
Import
#include "gbui/widgets/richEditor.hpp"Example
RichEditorResult richEditor(Ui& ui, const Interaction& input, std::string_view id, RichDocument& document, RichEditorState& state, const RichEditorOptions& options = {});Draws the editor and edits document in place. What this is and is not. It is a block editor: paragraphs, headings, lists, quotes and code blocks, with bold, italic, underline, strikethrough, inline code and links over ranges within a block. Typing, splitting a block with Return and merging with Backspace all work, and the toolbar is the caller's to compose. It is not finished, and the gaps are worth naming rather than discovering: no images — the painter cannot decode one yet; no undo; the caret moves by character and by block, not by visual line, so a block that wraps is edited by a caret that does not know where the lines are; and there is no nesting of lists. Each of those is a piece of work of its own, and three of them want engine features that do not exist.
API
RichEditorOptions
| Option | Type | Default | What it does |
|---|---|---|---|
toolbar | std::vector<ToolbarItem> | Empty takes defaultToolbar(). Anything else is exactly what is drawn, in that order — which is how a caller adds its own buttons, drops the ones it does not want, or reorders the rest. | |
blockChoices | std::vector<BlockChoice> | What the BlockStyle dropdown lists. Empty takes defaultBlockChoices(). | |
showToolbar | bool | true | Off leaves the keys and the document and nothing to click, which is what an editor whose buttons live somewhere else wants. |
placeholder | std::string_view | "Write something…" | |
minHeight | float | 220.0f | |
height | float | kAuto | |
grow | float | 0.0f | |
name | std::string_view | What is being written — "Release notes", "Comment". An editor with no name is the largest unlabelled thing on most screens. |