Code Sample Plugin
CodeSamplePlugin inserts structured code blocks and keeps editing dialog-driven for consistent formatting.
Install and import
import { CodeSamplePlugin } from "@editora/plugins";
// or: import { CodeSamplePlugin } from "@editora/plugins/code-sample";
Usage
const plugins = [CodeSamplePlugin()];
Command Matrix
| Action | Command | Shortcut | Toolbar |
|---|---|---|---|
| Insert code block | insertCodeBlock | Mod-Shift-C | Insert Code |
Config Options
This plugin does not expose plugin-level runtime config. Syntax highlighting is optional via host-provided Prism integration.
Behavior
- Inserts code blocks with language metadata (
data-lang) - Supports edit/update workflow through a code dialog
- Supports copy action for code block contents
- Preserves whitespace and line structure
Validation checklist
- Insert/edit cycles preserve exact code text
- Language metadata updates on edit
- Copy action works for long snippets
- Undo/redo restores code block changes