Code Sample
Plugin alias: codesample
editor42.init({
plugins: 'codesample'
});
Enables inserting and editing syntax-highlighted code snippets in the editor content. Code blocks are rendered as <pre> elements with a language-* class and highlighted using Prism.js (either bundled or a global instance). Code samples are non-editable in the editor; double-click to open the edit dialog.
Options
| Option | Type | Default | Description |
|---|---|---|---|
codesample_languages | object[] | HTML/XML, JavaScript, CSS, PHP, Ruby, Python, Java, C, C#, C++ | Array of { text, value } objects defining available languages. |
codesample_global_prismjs | boolean | false | Use a globally loaded Prism.js instance instead of the bundled one. |
Commands
| Command | Description |
|---|---|
codesample | Opens insert/edit dialog when cursor is in a code sample or selection is collapsed; toggles inline code format otherwise. |
Toolbar buttons
| Name | Type | Description |
|---|---|---|
codesample | Toggle button | Active when cursor is in a code sample. |
Menu items
| Name | Description |
|---|---|
codesample | Code sample. |