CodeMirror

codemirror#

Type: false | object

Default: false

Enables CodeMirror for code-editing surfaces in the editor: HTML source mode, embed code input, and the Block Code plugin.

When false, those inputs stay plain <textarea> elements.

const app = Redactor('#entry', {
  codemirror: {
    mode: 'htmlmixed',
    lineNumbers: true
  }
});

Load CodeMirror on the page before Redactor, or provide a custom instance via codemirrorSrc.

codemirrorSrc#

Type: false | CodeMirror

Default: false

Custom CodeMirror constructor. Use when CodeMirror is bundled as a module instead of exposed as window.CodeMirror.

import CodeMirror from 'codemirror';

const app = Redactor('#entry', {
  codemirror: {
    mode: 'htmlmixed',
    lineNumbers: true
  },
  codemirrorSrc: CodeMirror
});

Only one CodeMirror instance is active at a time; opening a new surface destroys the previous instance.