Markdown Editor

Pro

A Markdown source editor on a native textarea — undo, IME, spellcheck and phone keyboards intact — with a toolbar that wraps and unwraps (heading, bold, italic, strikethrough, code, link, quote, bulleted / numbered / task lists, code block, table), Ctrl/Cmd+B/I/K, list-aware Enter and Tab, write / preview / split views with synced scroll, paste-to-link and HTML-to-Markdown paste. The preview is the kit’s safe renderer, so nothing typed can become markup.

</>sv-markdown-editor markdowneditormdpreviewsplit viewtextareadocscommentcanned replysource editor
import { SvMarkdownEditorComponent } from '@styloviz-pro/rich-editor';

Demo & usage

Basic usage

Pro

Usage example — open the gallery for the full interactive demo.

Pro

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Split view for a docs page

Pro

Source and rendered page side by side, scrolled together; stacks under 640px (`stackBelow`). `view` and `splitAt` are models, so a host can remember both.

A comment box

Pro

A short toolbar, Write and Preview only, a limit, and Ctrl/Cmd+Enter to send.

Reactive forms (CVA + validator)

Pro

Binds with formControl / formControlName / ngModel; reports `required` and `maxlength` in Angular’s error shapes. `[formField]` (Signal Forms) works through the same accessor.

Insert at the caret

Pro

`insertText()` replaces the selection with text as one undo step — a snippet, a template, a canned reply. A preview switches back to write first.

Your own toolbar

Pro

The edits are pure functions of (text, selection) — each returns the range to replace and where the selection lands.

Signal Forms

Pro

Bind it with `[formField]` from `@angular/forms/signals` — the control is a ControlValueAccessor, which Signal Forms drives on Angular 21 and 22 alike.

When to use

  • You store Markdown — docs pages, READMEs, release notes, knowledge-base articles, canned replies — and authors should see and own the syntax.
  • A comment or reply box where a few marks (bold, code, a link, a list) are enough and HTML would be a liability.
  • For formatted HTML with fonts, colours and merged cells, use the Rich Text Editor instead.

Compare with

  • Rich Text Editor — Rich Text Editor edits formatted HTML in place (fonts, colours, merged cells) and can show a Markdown view of it. Markdown Editor edits the Markdown itself in a plain textarea and previews it — pick it when Markdown is what you store.
  • Streaming Markdown — Streaming Markdown only renders. Markdown Editor is the writing side: a source editor whose preview IS a Streaming Markdown.
  • Smart Textarea — Smart Textarea is a plain textarea that suggests what comes next. Markdown Editor formats Markdown with a toolbar and a preview.

Async states

None — this component has nothing to load, so it has no loading, empty or error state to drive.

Inputs

NameTypeDefaultDescription
valuestring (two-way)''The Markdown source. Two-way bindable with `[(value)]`; also a form control.
viewSvMarkdownEditorView (two-way)'write'What is shown: `'write'` (source), `'preview'` (rendered) or `'split'` (both). Two-way bindable.
splitAtnumber (two-way)50Share of the width (or height, stacked) the source takes in split view, in %. Two-way bindable.
toolbarreadonly SvMarkdownTool[]SV_MARKDOWN_TOOLSThe formatting tools to show, in toolbar order (as `sv-rich-text-editor`'s `toolbar` takes tool ids). `[]` leaves only the view switch. Shortcuts follow the list: Ctrl/Cmd+B does nothing when `bold` is not in it.
viewsreadonly SvMarkdownEditorView[]['write', 'preview', 'split']The views the switch offers, in order. One view hides the switch.
placeholderstring''Placeholder for an empty source. Not an accessible name — set `ariaLabel` or a `<label for>`.
ariaLabelstring''Accessible name of the source textarea. Falls back to "Markdown source".
ariaDescribedBystring''Ids of elements that describe the field (a hint, an error), joined to the editor's own keyboard hint.
inputIdstring''Id for the textarea, so an external `<label for>` can name it. Generated when empty.
heightstring'18rem'Height of the editing area, as a CSS length.
maxLengthnumber0Maximum characters (the native `maxlength`, and a counter). `0` is unlimited.
disabledbooleanfalseDisable the editor: no editing, no toolbar. A form control's `disable()` does the same.
readonlybooleanfalseRead-only: the source can be selected, copied and previewed, not changed.
requiredbooleanfalseMark the field required (`aria-required`, and a `required` error when bound to a form).
invalidbooleanfalseShow the field as invalid (`aria-invalid`, danger border) — bind your form's state.
spellcheckbooleantrueThe browser's spellcheck on the source.
showCountbooleantrueShow the word and character count under the editor.
syncScrollbooleantrueIn split view, scroll the preview with the source and the source with the preview.
stackBelownumber640Below this width (px) the split view stacks the preview under the source instead of beside it.
pasteHtmlSvMarkdownPasteMode'markdown'What an HTML paste becomes: `'markdown'` converts a pasted web page or document through `svHtmlToMarkdown` and reports what Markdown could not carry; `'text'` keeps the browser's plain-text paste. Code copied from an editor (`<pre>`, `white-space: pre`) always pastes as text.
headingOffsetnumber0Added to every heading level in the preview, so `#` becomes `<h3>` at 2.

Outputs

EventPayload typeDescription
linkClickMarkdownLinkClickA link in the preview was activated.
pasteConvertedSvMarkdownResultAn HTML paste was converted to Markdown — `lost` lists what Markdown could not carry.
submittedstringCtrl/Cmd+Enter in the source — the "send" chord of a comment box. Carries the value.
valueChangestringEmits the new `value` whenever it changes — the output half of `[(value)]`.
viewChangeSvMarkdownEditorViewEmits the new `view` whenever it changes — the output half of `[(view)]`.
splitAtChangenumberEmits the new `splitAt` whenever it changes — the output half of `[(splitAt)]`.

Customization & theming

  • `value`, `view` (`write` / `preview` / `split`) and `splitAt` are two-way models; `toolbar` takes tool ids in order (`SV_MARKDOWN_TOOLS` is all twelve), `views` the views the switch offers.
  • `height`, `placeholder`, `maxLength` (native `maxlength` + counter, amber from 90%), `required`, `invalid`, `disabled`, `readonly`, `spellcheck`, `showCount`, `syncScroll`, `stackBelow`, `headingOffset` (preview), `pasteHtml` (`markdown` or `text`).
  • Outputs: `submitted` (Ctrl/Cmd+Enter), `pasteConverted` (`{ markdown, lost }` from `svHtmlToMarkdown`), `linkClick` (a preview link). Methods `insertText()`, `format(tool)`, `focus()`.
  • Every visible string is a label in the `richEditorPro` namespace (the `md…` keys), in 12 language packs.
  • Print shows the rendered document, never the source.

Forms integration

  • sv-markdown-editor — ControlValueAccessor.[formControl], formControlName, [(ngModel)] and Signal Forms [formField] all work.

Best practices

  • Do: Give it a name: `ariaLabel`, or a `<label for>` with `inputId`. A placeholder is not an accessible name.
  • Do: Render stored Markdown with `sv-streaming-markdown` — the same parser and URL rules as the preview, so what the author saw is what readers get.
  • Don't: Don’t assign the textarea’s value yourself; bind `[(value)]` or a form control. The editor only writes the textarea when the value really differs, which is what keeps the browser’s undo history.
  • Tip: Use `[toolbar]` to keep a comment box short, and `[views]` to drop split view where there is no room for it.

Accessibility

  • The source is a native `<textarea>` — screen readers, dictation, IME composition, spellcheck and undo work as they do anywhere else. It carries `aria-required`, `aria-invalid`, `maxlength`, and an `aria-describedby` keyboard hint joined to the host’s own ids.
  • The toolbar is `role="toolbar"` with one tab stop: ←/→ move between buttons (mirrored under RTL), Home/End go to the ends. Tools that cannot act (read-only, preview) stay focusable with `aria-disabled`; view buttons expose `aria-pressed`; shortcuts are in `aria-keyshortcuts` and the tooltip.
  • Tab and Shift+Tab change a list item’s indent and nothing else: outside a list, or Shift+Tab at the margin, they move focus. Escape, then Tab, always leaves the editor — announced through a polite status region, so focus is never trapped.
  • The preview is a focusable, named `role="region"` so it can be scrolled from the keyboard; the split divider is the kit splitter’s `role="separator"` with arrow keys and step buttons. A refused edit (character limit) and a converted paste are announced, not silent.
  • Engine: the ADR-aria row asks for the `@angular/aria` toolbar. The package is not a dependency of the kit yet (adopted from 2.1, ADR rule 1), so the toolbar is an in-house WAI-ARIA toolbar on core’s `svRovingTarget`; moving to Aria later changes no input or output.

Feedback on Markdown Editor

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.