JSPM

  • Created
  • Published
  • Downloads 94659
  • Score
    100M100P100Q156511F
  • License MIT

Codemirror component for Vue.js

Package Exports

  • vue-codemirror

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-codemirror) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

GitHub issues GitHub forks GitHub stars Twitter

NPM

Vue-Codemirror

Codemirror components for Vue.js

Example

Demos

Use Setup

# install vue-codemirror
npm install vue-codemirror


# Vue use

## import with ES6
import Vue from 'vue'
...
import CodeMirror from 'vue-codemirror'


## require with Webpack
var Vue = require('vue')
...
var CodeMirror = require('vue-codemirror')

## use
Vue.use(CodeMirror)


# use in components
<codemirror></codemirror>


# component data bind
<codemirror :code.sync="code"></codemirror>


# component config example 1
<codemirror :code.sync="code" :options="editorOption"></codemirror>

data () {
  return {
    code: 'const a = 10',
    editorOption: {
      tabSize: 4,
      mode: 'text/javascript',
      theme: 'base16-dark',
      lineNumbers: true, 
      line: true,
      ...
    }
  }
}


# editorOption mode types:

// string mode
mode: 'text/javascript'

// object mode
mode: {
  name: 'javascript',
  json: true
}


# component config example 2
<codemirror :code.sync="css" :options="{ tabSize: 2, mode: 'css' }"></codemirror>

data () {
  return {
    css: '.class { display: block }'
  }
}

More Config

Code example

More codemirror configs

More codemirror themes

More codemirror language modes

Author Blog

Surmon