Adds a block control button for editing the raw HTML of the current block in a textarea. Replaces the block content on save.
Select a block, open the control dropdown, and choose Edit Code to view and edit the block HTML source. When the editor codemirror option is enabled, the textarea is upgraded to CodeMirror automatically.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/block-code/block-code.js"></script>
const app = Redactor('#entry', {
plugins: ['blockCode']
});
string)
Block Code uses a plain <textarea> by default.
To enable syntax-aware editing, set the editor-level codemirror option — the plugin upgrades the field when CodeMirror is available.
Redactor('#entry', {
plugins: ['blockCode'],
codemirror: {
mode: 'htmlmixed',
lineNumbers: true
}
});
en: {
blockCode: {
'edit-code': 'Edit Code'
}
}
This plugin does not emit events.
This plugin does not expose a public API.