Skip to content

Add the awesome in-browser code editor CodeMirror as a field type.

License

Notifications You must be signed in to change notification settings

lewisjenkins/craft3-codemirror

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeMirror plugin for Craft CMS 3.x

Add the awesome in-browser code editor CodeMirror as a field type.

Screenshot

Installation

To install CodeMirror, follow these steps:

  1. Install with Composer via composer require luwes/craft3-codemirror
  2. Install plugin in the Craft Control Panel under Settings > Plugins

CodeMirror works on Craft 3.x.

CodeMirror Overview

https://github.com/codemirror/codemirror

Configuring CodeMirror

Copy the code below, create a file named code-mirror.php and place it in the craft config folder to override the default options.

return [
    'jsOptions' => [
        'theme' => 'default',
        'lineNumbers' => true,
        'lineWrapping' => true,
        'viewportMargin' => new JsExpression('Infinity'),
    ],
    'modes' => [
        'gfm', // the first mode is enabled by default
        'markdown',
        'htmlmixed',
        'javascript',
        'css',
        'xml',
    ],
    'addons' => [
        'mode/overlay', // needed for gfm (github flavored) mode
    ]
];

Brought to you by Wesley Luyten

About

Add the awesome in-browser code editor CodeMirror as a field type.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 76.1%
  • HTML 18.9%
  • CSS 4.7%
  • PHP 0.3%