BlockEditor <pm-block-editor>
Block editor for long content: articles, blog posts, documentation and notes, written in blocks you can format, align and drag into a new order.
States
Each state is one attribute.
DisabledRead-onlyRequiredErrorOverview
Blocks: text, four heading levels, bulleted, numbered and check lists, quotes, callouts, code, images, videos, tables and dividers.
- Type
/for the block menu, or start a line with Markdown:#,-,1.,[]or>then a space; three backticks or---then Enter. - Select text for its formatting bar: bold, italic, underline, strikethrough, inline code, highlight, link.
- Each block has a handle: drag it to move the block, or press it for the block menu (turn into, align, width, tone, move, duplicate, delete). From the keyboard: Alt+Shift+↑/↓ moves the block.
- Paste or drop pictures to upload them (
upload), and paste a YouTube or Vimeo link on an empty line to embed it. - Its own undo and redo (Mod+Z, Mod+Shift+Z) cover typing, formatting and moves.
Form-associated: submits clean HTML (only the blocks and marks above; scripts and unknown markup never get in). Also as JSON blocks (blocks) and Markdown (markdown). Sanitise again on the server before storing or showing. For a comment or a short description, <pm-editor> is lighter.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
label | string | — | Visible label (required for accessibility). |
name | string | — | Form field name. |
value | string | — | Initial HTML. |
placeholder | string | — | Shown in an empty document (default: "Write, or press / for blocks"). |
hint | string | — | Help text under the editor. |
error | string | — | Error message; marks the editor invalid. |
required | boolean | — | Must have content. |
disabled | boolean | — | Not editable, not submitted. |
readonly | boolean | — | Not editable, still submitted. |
stats | boolean | — | Show the number of words and the reading time. |
toolbar | 'full' | 'minimal' | — | full (default), minimal (formatting bar and slash menu only). |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-upload-error | onPmUploadError | A picture could not be uploaded. detail.file, detail.error. |
pm-input | onPmInput | The content changed. |
pm-change | onPmChange | The content changed and the editor lost focus. |
Methods
checkValidity(), reportValidity(), focus(), undo(), redo()