Skip to main content

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

OptionTypeDefaultDescription
codesample_languagesobject[]HTML/XML, JavaScript, CSS, PHP, Ruby, Python, Java, C, C#, C++Array of { text, value } objects defining available languages.
codesample_global_prismjsbooleanfalseUse a globally loaded Prism.js instance instead of the bundled one.

Commands

CommandDescription
codesampleOpens insert/edit dialog when cursor is in a code sample or selection is collapsed; toggles inline code format otherwise.

Toolbar buttons

NameTypeDescription
codesampleToggle buttonActive when cursor is in a code sample.
NameDescription
codesampleCode sample.