node package manager

matreshka-binder-codemirror

matreshka-binder-codemirror npm version Build Status Coverage Status

CodeMirror binder creator for Matreshka.js

The binder creator returns a binder which initializes and binds CodeMirror instance created with fromTextArea function to a property.

Usage

In browser environment (or whatever environment where Matreshka is global variable) Matreshka.binders namespace is extended.

<script src="path/to/matreshka-binder-codemirror.min.js"></script>
const { codeMirror } = Matreshka.binders;
this.bindNode('code', textarea, codeMirror());
 
// if you don't want to create the variable 
this.bindNode('code', textarea, Matreshka.binders.codeMirror());
 
obj.code = 'alert("Hello World!");';

The bundle can be downloaded at gh-pages branch


In CJS environment Matreshka.binders is not extended.

npm install --save matreshka-binder-codemirror
const codeMirror = require('matreshka-binder-codemirror');
 
// ... 
 
this.bindNode('code', textarea, codeMirror());

Configuration

The function accepts one argument: configuration object which is passed into internal call of CodeMirror.fromTextArea. Read the CodeMirror documentation for more info.

this.bindNode('code', textarea, codeMirror({
    lineNumbers: true,
    mode: 'htmlmixed'
}));