0.10.0 • Published 3 months ago

@opentf/react-code-editor v0.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months 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

3 months ago

0.9.0

12 months ago

0.8.0

12 months ago

0.7.0

12 months ago

0.6.0

12 months ago

0.5.1

12 months ago

0.5.0

12 months ago

0.4.0

12 months ago

0.3.0

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago