CodeMirror Field

Component ID

2290211

Component name

CodeMirror Field

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

1339

Component created

Component changed

Component body

CodeMirror Field integrates CodeMirror editor as an attachable field (http://codemirror.net/).

Main Features:

- Attach code snippet fields to entities (includes customizable field widget and formatter)
- Autocomplete for the supported modes

Available options:

- Currently the widget supports 4 modes: [text/html, css, less, javascript] but it can be extended easily for other languages supported by codemirror.
- Unique syntax highlighting themes for each field instance.

For the following options see the official codemirror documentation (http://codemirror.net/doc/manual.html)
- Indent Unit
- Smart indent
- Indent with tabs
- Electric characters
- Auto clear empty lines
- Line wrapping
- Line numbers
- Gutter
- Fixed gutter
- Show cursor when selecting
- Read only
- Cursor blink rate
- Undo depth
- Auto focus
- Drag and drop

Installation instructions & Dependencies:

Drupal7:

dependencies:
- codemirror library (https://github.com/marijnh/CodeMirror)
- libraries (https://www.drupal.org/project/libraries)

installation:
* Download the library from github into sites/all/libraries (the library should be cloned as codemirror or rename the directory to codemirror).

* Download and enable the libraries module.

* Enable the codemirror_field module.

Drupal8:

dependencies:
- codemirror library

installation:
* Move into the module's directory and run composer require codemirror/CodeMirror

* Enable the codemirror_field module.

Similar Projects

CodeMirror editor
- also implements a field widget and a formatter for the code snippets.

Wysiwyg CodeMagic
- totally different concept. Works with wysiwyg and requires tinymce.