Layouts

Rich text editor

A basic rich text editor for your application. Built using ProseMirror and Tiptap.

Because of large external dependencies, the editor's JavaScript is not included in the core Flux bundle. It will be loaded on-the-fly as a separate JS file when you use the flux:editor component.

Release notes Explain what’s new in this release.
Styles
Text
Heading 1
Heading 2
Heading 3
Bold ⌘B
Italic ⌘I
Strikethrough ⌘+Shift+S
Bullet list
Ordered list
Blockquote ⌘+Shift+B
Insert link ⌘K
Insert link
Unlink
Align
Left
Center
Right

What’s changed

  • Markdown notation support
  • Accessible toolbar
  • Shortcut keys
Full changelog: v1.0.25...v1.0.26

Toolbar

Flux's editor toolbar is both keyboard/screen-reader accessible and completely customizable to suit your application's needs.

Configuring items

You can configure which toolbar items are visible, and in what order, by passing in a space-separated list of items to the
toolbar
prop.
Styles
Text
Heading 1
Heading 2
Heading 3
Bold ⌘B
Italic ⌘I
Underline ⌘U
Align
Left
Center
Right
Undo ⌘Z
Redo ⌘+Shift+Z
You may have noticed the | and ~ characters in the toolbar configuration. These are shorthand for separator and spacer respectively.

The following toolbar items are available:

  • heading
  • bold
  • italic
  • strike
  • underline
  • bullet
  • ordered
  • blockquote
  • subscript
  • superscript
  • highlight
  • link
  • code
  • undo
  • redo

Custom items

You can add your own toolbar items by adding new files to the
resources/views/flux/editor
directory in your project.

Here's an example of what a custom "Copy to clipboard" item in a blade file might look like:

Copy to clipboard

Now you can reference your new component by name in any toolbar configuration like so:

Styles
Text
Heading 1
Heading 2
Heading 3
Bold ⌘B
Italic ⌘I
Strikethrough ⌘+Shift+S
Bullet list
Ordered list
Blockquote ⌘+Shift+B
Insert link ⌘K
Insert link
Unlink
Align
Left
Center
Right
Copy to clipboard

Customization

If you have deeper customization needs, you can compose your own editor component. Here's an example of putting a custom dropdown menu in an editor's toolbar:
Styles
Text
Heading 1
Heading 2
Heading 3
Bold ⌘B
Italic ⌘I
Strikethrough ⌘+Shift+S
Bullet list
Ordered list
Blockquote ⌘+Shift+B
Insert link ⌘K
Insert link
Unlink
Align
Left
Center
Right
More

Height

By default, the editor will have a minimum height of 200px, and a maximum height of 500px. If you want to customize this behavior, you can use Tailwind utilties to target the content slot and set your own min/max height and overflow behavior.

Styles
Text
Heading 1
Heading 2
Heading 3
Bold ⌘B
Italic ⌘I
Strikethrough ⌘+Shift+S
Bullet list
Ordered list
Blockquote ⌘+Shift+B
Insert link ⌘K
Insert link
Unlink
Align
Left
Center
Right

The [&_[data-slot=content]]: selector targets a child element with a data-slot="content" attribute.

This is an advanced Tailwind technique used to style a nested element inline without needing direct access to it.

Shortcut keys

Flux's editor uses Tiptap's default shortcut keys which are common amongst most rich text editors.

Operation
Windows/Linux
Mac
Apply paragraph style Ctrl+Alt+0 Cmd+Alt+0
Apply heading level 1 Ctrl+Alt+1 Cmd+Alt+1
Apply heading level 2 Ctrl+Alt+2 Cmd+Alt+2
Apply heading level 3 Ctrl+Alt+3 Cmd+Alt+3
Bold Ctrl+B Cmd+B
Italic Ctrl+I Cmd+I
Underline Ctrl+U Cmd+U
Strikethrough Ctrl+Shift+X Cmd+Shift+X
Bullet list Ctrl+Shift+8 Cmd+Shift+8
Ordered list Ctrl+Shift+7 Cmd+Shift+7
Blockquote Ctrl+Shift+B Cmd+Shift+B
Code Ctrl+E Cmd+E
Highlight Ctrl+Shift+H Cmd+Shift+H
Align left Ctrl+Shift+L Cmd+Shift+L
Align center Ctrl+Shift+E Cmd+Shift+E
Align right Ctrl+Shift+R Cmd+Shift+R
Paste without formatting Ctrl+Shift+V Cmd+Shift+V
Add a line break Ctrl+Shift+Enter Cmd+Shift+Enter
Undo Ctrl+Z Cmd+Z
Redo Ctrl+Shift+Z Cmd+Shift+Z

Markdown syntax

Although Flux's editor isn't a markdown editor itself, it allows you to use markdown syntax to trigger styling changes while authoring your content.

Markdown
Operation
# Apply heading level 1
## Apply heading level 2
### Apply heading level 3
** Bold
* Italic
~~ Strikethrough
- Bullet list
1. Ordered list
> Blockquote
` Inline code
``` Code block
```? Code block (with class="language-?")
--- Horizontal rule

Localization

If you need to localize the editor's aria-label or tooltip copy, you'll need to register the following translation keys in one of your app's lang files.

Here's an example of supporting Spanish localization:

Copyright © 2024 Wireable LLC ·Terms of Service
Built with by
Caleb Porzio and Hugo Sainte-Marie