markdown-editor

Side-by-side markdown editor with live preview. Composes a textarea with markdown-viewer.

Overview

A split-pane markdown editor that pairs a <textarea> with a <markdown-viewer> for live preview. Part of the Extras Pack.

Progressive enhancement: without JavaScript the <textarea> is fully usable. The preview pane appears only after the component upgrades.

Usage

Basic

Wrap a <textarea> with initial content. The editor adopts it and builds the preview pane.

With Syntax Highlighting

Add the highlight attribute to pass through to the preview viewer. Bring your own highlighter via the markdown-viewer:highlight event.

Form Integration

The name attribute is reflected to the internal textarea, so it works as a standard form field.

Tab Indentation

Add data-tab-indent to make the Tab key insert two spaces instead of moving focus.

Attributes

AttributeValuesDefaultDescription
namestringForm field name reflected to the textarea
placeholderstringTextarea placeholder text
rowsstring10Textarea rows
highlightbooleanPass highlight attribute to the preview viewer
data-tab-indentbooleanTab key inserts spaces instead of moving focus
data-themestringTheme propagated to the preview pane

Events

EventDetailDescription
markdown-editor:input{ value }Fired on each keystroke
markdown-editor:change{ value }Fired on blur after content changed

JavaScript API

PropertyTypeDescription
.valuestringGet or set the current markdown content. Setting updates the preview.
.textareaHTMLTextAreaElementReference to the internal textarea element for direct access.

Progressive Enhancement

Before the component upgrades, the <textarea> renders at full width with monospace styling. After upgrade, the split layout appears with the live preview pane. Content is never lost.