The Code Snippet component provides a powerful code editor powered by CodeMirror with syntax highlighting, theme support, and interactive editing capabilities.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/devscribe-team/webeditor/llms.txt
Use this file to discover all available pages before exploring further.
Node specification
The code snippet is a block-level node that contains text content with code formatting.The programming language for syntax highlighting. Supported:
javascript, typescript, html, css, python, rust, sqlOptional title for the code block (currently unused in UI)
The color theme. Available:
tokyoNight, githubDark, githubLight, vscodeDark, vscodeLightWhether to display a border around the code block. Automatically set to
false when inside tabs.Usage
Insert via command menu
Type/code or /snippet in the editor and select the Code Snippet option from the command menu.
Insert via input rule
Type three backticks to trigger code block creation:Attributes
The code snippet node spec defines the following attributes:Supported languages
The code snippet uses CodeMirror language extensions:JavaScript and TypeScript support includes JSX/TSX syntax highlighting.
Themes
Five color themes are available:Dark theme inspired by Tokyo Night color scheme
Dark theme matching GitHub’s dark mode
Light theme matching GitHub’s light mode
Dark theme matching VS Code’s default dark theme
Light theme matching VS Code’s default light theme
Editing features
The code snippet provides rich editing capabilities:Hover controls
When hovering over a code block, controls appear in the top-right corner:- Language selector: Dropdown to change syntax highlighting language
- Theme selector: Dropdown to change color theme
- Border toggle: Button to show/hide the border
- Copy button: Copies code to clipboard with visual feedback
Keyboard navigation
Special keyboard shortcuts for navigation between the code block and the surrounding document:When cursor is at the start of the first line, exit to ProseMirror before the code block
When cursor is at the end of the last line, exit to ProseMirror after the code block
Exit to ProseMirror after the code block and create a new paragraph if needed
When the code block is empty, delete the entire node and return to ProseMirror
Auto-focus behavior
When a new code snippet is created, the editor automatically focuses and positions the cursor at the end of the content.Custom styling
The code snippet applies custom styling to CodeMirror:Event handling
The code snippet usesuseStopEvent to prevent ProseMirror from capturing input events:
The code snippet debounces content updates by 100ms to avoid excessive ProseMirror transactions while typing.