luwes / craft-codemirror
Add the awesome in-browser code editor CodeMirror as a field type.
Installs: 8 138
Dependents: 0
Suggesters: 0
Security: 0
Stars: 18
Watchers: 5
Forks: 10
Open Issues: 11
Language:JavaScript
Type:craft-plugin
Requires
- php: ^8.0
- craftcms/cms: ^3.0.0-beta.20 || ^4.0.0
Requires (Dev)
- craftcms/rector: dev-main
README
Add the awesome in-browser code editor CodeMirror as a field type.
Installation
To install CodeMirror, follow these steps:
- Install with Composer via
composer require luwes/craft-codemirror
- Install plugin in the Craft Control Panel under Settings > Plugins
CodeMirror works on Craft 3.x and 4.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