0.10.0 • Published 1 year ago

@opentf/react-code-editor v0.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

 OPEN TECH FOUNDATION

React Code Editor

Screenshot

A simple code editor for React JS, useful for form code input.

Features

  • Simple Editor (HTML Textarea based)

  • Syntax Highlighting

  • Multiple languages & themes are supported.

  • Format code with Prettier

  • Syntax Errors via Prettier formating

  • Line numbers

Installation

npm install @opentf/react-code-editor
yarn add @opentf/react-code-editor
pnpm add @opentf/react-code-editor
bun add @opentf/react-code-editor

Usage

import { Editor } from '@opentf/react-code-editor';

export default function App() {
  const code = `export default function App() {
      return <h1>Hello world</h1>
    }
  `;

  return <Editor value={code} onChange={handleChange} />;
}

Props

NameTypeRequiredDefaultDescription
valuestringYes''The value of the editor.
onChangeFunctionNoundefinedThe handler function for the value change event.
themesTheme[]No[]You can pass aditional themes to the editor via this prop.
languagesLang[]No[]By default only limited set of languages supported, you can extend additional languages support via this prop.
langstringNo'Plain Text'The language syntax highlighting.
themestringNo'Light'The theme name to apply a theme. See list of themes below.
styleobjectNo{}The styles will be applied to the root element of the editor component.
titlestringNo'Untitled'The editor title. Eg: Config.json
configobjectNo{}See the below table for config object.

Config:

NameTypeRequiredDefaultDescription
indentstringNo'Space'Indent code using "Space" or "Tab"
indentSizenumberNo2The indent size.
textAreaobjectNo{}Any additional props for the code editor textarea element.

Supported Languages (With formatting)

✔️ JSON

⏳ HTML

⏳ JavaScript

⏳ TypeScript

⏳ CSS

⏳ GraphQL

⏳ TOML

⏳ YAML

Supported Languages (Without formatting)

✔️ Plain Text

⏳ Bash

⏳ Dockerfile

Supported Themes

  • Dark

  • Light (Default)

💡You can create your own themes easily, please refer any existing theme objects in the repo.

License

Copyright (c) Thanga Ganapathy (MIT License).

0.10.0

1 year ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago