Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

defijs/codemirror-binder

Repository files navigation

The repository is no longer updated. Defi is turned into a monorepo: https://github.com/finom/defi

codemirror-binder npm version Build Status Coverage Status

CodeMirror binder creator for defi.js

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

Usage

npm i codemirror-binder
import { bindNode } from 'defi';
import codeMirrorBinder from 'codemirror-binder';

// ...
bindNode(obj, 'code', textarea, codeMirrorBinder());

Usage in a browser environment

For non-CJS environment the bundle can be downloaded at gh-pages branch.

In the browser environment the script exports a global variable codeMirrorBinder.

<script src="path/to/codemirror-binder.min.js"></script>

Configuration

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

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