# @matthamlin/react-code-editor

> `@matthamlin/react-code-editor` is an opinionated package built on top of React Hooks and react-simple-code-editor.

Latest version **1.0.1** (published 2019-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @matthamlin/react-code-editor
pnpm add @matthamlin/react-code-editor
yarn add @matthamlin/react-code-editor
bun add @matthamlin/react-code-editor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-12-30 |
| First published | 2019-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matthew Hamlin |
| Maintainers | matthamlin |

## Links

- npm: https://www.npmjs.com/package/@matthamlin/react-code-editor
- Repository: https://github.com/hamlim/projects
- npm.io page: https://npm.io/package/@matthamlin/react-code-editor

## Recent versions

- 1.0.1 (latest) — 2019-12-30
- 1.0.0 — 2019-12-23
- 0.1.0 — 2019-12-21
- 0.0.1 — 2019-02-17

## README

# React Code Editor

`@matthamlin/react-code-editor` is an opinionated package built on top of React Hooks and react-simple-code-editor.

It implements a lightweight code editor component that supports the following enhancements:

- Line commenting via `Cmd + /` or `Ctrl + /`
- Format on Save via `Cmd + s` or `Ctrl + s` - with `formatOnSave` prop
- Format code via `Cmd + f` or `Ctrl + f`
- maybe more soon???

## Usage

```jsx
import React from 'react'
import Editor from '@matthamlin/react-code-editor'
import { highlight, languages } from 'prismjs/components/prism-core'
import 'prismjs/components/prism-clike'
import 'prismjs/components/prism-javascript'
import prettier from 'prettier/standalone'
import babelPlugin from 'prettier/parser-babylon'

const code = `import React from "react";
import ReactDOM from "react-dom";
function App() {
  return (
    <h1>Hello world</h1>
  );
}
ReactDOM.render(<App />, document.getElementById("root"));`

function App() {
  return (
    <Editor
      initialValue={code}
      highlight={code => highlight(code, languages.jsx)}
      padding={10}
      style={{
        fontFamily: '"Fira code", "Fira Mono", monospace',
        fontSize: 12,
      }}
      formatOnSave
      formatCode={code =>
        prettier.format(code, { parser: 'babel', plugins: [babelPlugin] })
      }
    />
  )
}
```

---
_Source: https://npm.io/package/@matthamlin/react-code-editor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
