Skip to content

atassis/react-codemirror-ts

Repository files navigation

react-codemirror-ts

npm deps licenses downloads size

Codemirror react wrapper made with typescript

Installation

npm i react-codemirror-ts

Usage

import { Codemirror } from 'react-codemirror-ts';
import React, { useState } from 'react';

import 'codemirror/mode/javascript/javascript';
import 'codemirror/addon/edit/matchbrackets';
import 'codemirror/lib/codemirror.css';

function CodemirrorExample() {
  const [value, setValue] = useState<string>('');
  return (
    <Codemirror
      defaultValue=""
      value=""
      name="example"
      path="example"
      options={{
        lineNumbers: true,
        lineWrapping: true,
        matchBrackets: true,
        mode: 'javascript',
        tabSize: 2,
      }}
      onChange={(value, options) => {
        setValue(value);
      }}
    />
  );
}

export { CodemirrorExample };

License

Refer to LICENSE file