Skip to main content

rc-markdown-editor

Rich/source Markdown editor with a formatting toolbar, backed by rc-textarea.

Package
@rcarls/rc-markdown-editor
Element
<rc-markdown-editor>
Native dependency
Requires a textarea child
State model
Native textarea value plus editor mode
Main events
rc-formatting-changerc-changerc-mode-change

Installation

npm install @rcarls/rc-markdown-editor
import '@rcarls/rc-markdown-editor/define';

Live demo

The editor composes its formatting surface from rc-toolbar, rc-button, and rc-select, allowing the selected theme to style the controls consistently with the rest of an application.

Theming

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

API

Properties

PropertyMarkupTypeDefaultDescription
defaultValuedefault-valuestringNot specifiedInitial uncontrolled Markdown value.
valuevaluestringNot specifiedCurrent Markdown value. Host writes are silent.
defaultSourceModedefault-source-modebooleanNot specifiedInitial uncontrolled source-mode state.
sourceModesource-modebooleanNot specifiedControlled: show the markdown source editor instead of the rich view. Host writes are silent; toolbar/keyboard toggles dispatch `rc-mode-change`.
toolbartoolbarbooleantrueShow the formatting toolbar.
readOnlyread-onlybooleanfalseMake the editor read-only.

Methods

No public methods are documented in the custom elements manifest.

Events

EventDetail typeDescription
rc-formatting-changeCustomEventActive formats at cursor changed. Detail: `ActiveFormats`.
rc-changeCustomEventValue changed. Detail: `{ value: string }`.
rc-mode-changeCustomEventMode toggled. Detail: `{ mode: EditorMode }`.

Slots

NameDescription
(default)Accepts a native `<textarea>` element (and optional `<label>`) for form wiring.

CSS Custom Properties

PropertyDefaultDescription
--rme-font-familyinheritFont family of the rich-text view
--rme-font-sizeinheritFont size of the rich-text view
--rme-line-height1.6Line height of the rich-text view
--rme-padding0.75em 1emPadding inside the rich-text view
--rme-backgroundCanvasBackground color of the rich-text view
--rme-colorCanvasTextText color of the rich-text view
--rme-border1px solid ButtonBorderBorder around the rich-text view
--rme-border-radius0 0 4px 4pxBorder radius of the rich-text view
--rme-focus-outline2px solid HighlightFocus ring outline on the rich-text view
--rme-src-font-family'Cascadia Code', 'Fira Code', ui-monospace, monospaceFont family of the source editor
--rme-toolbar-gap1pxGap between toolbar buttons
--rme-toolbar-button-size2remMinimum inline and block size of toolbar buttons
--rme-src-heading-colorlight-dark(#1d6fc4, #82b4f5)Source-mode heading token color
--rme-src-code-colorlight-dark(#c94a1a, #f09060)Source-mode inline/fenced code token color
--rme-src-link-colorlight-dark(#0370b0, #60b8e8)Source-mode link token color
--rme-src-blockquote-colorlight-dark(#2d7a42, #70b880)Source-mode blockquote token color
--rme-src-list-colorlight-dark(#7a5c0a, #d4ac48)Source-mode list marker token color
--rme-src-dim-colorGrayTextSource-mode strikethrough token color

CSS Parts

PartDescription
toolbarThe `<rc-editor-toolbar>` element.
rich-viewThe contenteditable rich-text view.