Skip to Content

Rich text editor

One editor for every rich text, with no network code of its own.

RichTextEditor is one editor for every rich text: documents, descriptions, comments and richtext fields. It is ProseMirror with one schema, richTextSchema. It binds to a collaborative Yjs document (provider) or to a JSON value (value and onChange).

A page, in plain modevalue and onChange; the writing assistant, dictation and uploads use mock services here.
Open the example ↗

What it has

  • Block handles and a block menu
  • The / insert menu
  • A format bar, with the writing assistant
  • @ mentions and [[ page links
  • Markdown shortcuts, and Markdown on paste
  • Tables, images and files
  • Block types the app adds
  • Remote cursors
  • A read-only mode
  • page, field and comment variants
  • A phone layout
Two people in one documentEach editor has its own Yjs document; updates and awareness pass between them, as through a sync server.
Open the example ↗
Field and commentThe same editor as an issue's description field and as a reply.
Open the example ↗

Block widths

Top-level blocks of a page editor are reading, wide or full, from src/editor/width.ts. The host sets the text column with --nc-editor-measure and the side space with --nc-editor-inset.

Block widthsThe text column is the host's --nc-editor-measure, centred. The table is wide and the image full width: choose another width from a block's menu (its handle). A code block may be wide; text stays in the column.
Open the example ↗

Services

The editor has no network code. These come from EditorServices, through EditorServicesProvider or the services prop:

  • mentions, chips and previews
  • uploads
  • the call to the model of the writing assistant, and its wording, aiCopy
  • dictation
  • block types the app adds

Markdown

toMarkdown and parseMarkdown convert documents to and from Markdown.

Styles

The styles are in src/styles/editor.css. The classes are nc-editor, nc-editor__content and nc-editor-*, for callouts, code blocks, images, cursors and the rest.

Read only
Open the example ↗
RichTextEditor in the gallery ↗
Edit on GitHub

Last updated on

On this page