All Projects → uiwjs → react-textarea-code-editor

uiwjs / react-textarea-code-editor

Licence: MIT license
A simple code editor with syntax highlighting.

Programming Languages

typescript
32286 projects
Less
1899 projects
HTML
75241 projects
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to react-textarea-code-editor

Friendly Code Editor
Try this Friendly Code Editor. You'll love it. I made it with a lot of effort. It has some great features. I will update it adequately later. Very helpful for developers. Enjoy and share.
Stars: ✭ 20 (-91.9%)
Mutual labels:  code-editor, textarea
react-dates
An easily internationalizable, mobile-friendly datepicker library for the web
Stars: ✭ 12,032 (+4771.26%)
Mutual labels:  react-component
shared-react-components-example
An example of a mono-repository of shared React components libraries!
Stars: ✭ 85 (-65.59%)
Mutual labels:  react-component
react-mason
React Masonry grid
Stars: ✭ 13 (-94.74%)
Mutual labels:  react-component
dockside
Dockside is a tool for provisioning lightweight access-controlled IDEs, staging environments and sandboxes - aka 'devtainers' - on local machine, on-premises raw metal or VM, or in the cloud
Stars: ✭ 205 (-17%)
Mutual labels:  code-editor
react-scroll-trigger
📜 React component that monitors scroll events to trigger callbacks when it enters, exits and progresses through the viewport. All callback include the progress and velocity of the scrolling, in the event you want to manipulate stuff based on those values.
Stars: ✭ 126 (-48.99%)
Mutual labels:  react-component
griding
🧱 lean grid & responsive for react
Stars: ✭ 18 (-92.71%)
Mutual labels:  react-component
react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (-83.4%)
Mutual labels:  react-component
react-timer-wrapper
Composable React Timer component that passes status props to children, in addition to some basic callbacks. Can be used at a countdown timer ⏲ or as stopwatch ⏱ to track time while active.
Stars: ✭ 14 (-94.33%)
Mutual labels:  react-component
React-Express-JWT-UserPortal
React.js & Express.js User portal Using Core UI, JWT, JWT Token, Refresh Token, Role & Permission management, User manamgenet, Event Log.
Stars: ✭ 22 (-91.09%)
Mutual labels:  react-component
vscode-exts
Visual Studio Code Extensions
Stars: ✭ 33 (-86.64%)
Mutual labels:  react-component
picker
📅 All Date Pickers you need.
Stars: ✭ 185 (-25.1%)
Mutual labels:  react-component
autoexpand
Autoexpanding textarea in Elm
Stars: ✭ 15 (-93.93%)
Mutual labels:  textarea
best-of-react
🏆 A ranked list of awesome React open-source libraries and tools. Updated weekly.
Stars: ✭ 364 (+47.37%)
Mutual labels:  react-component
fongshen-editor
A highly customizable code-inserting editor for markdown or other languages
Stars: ✭ 35 (-85.83%)
Mutual labels:  code-editor
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-86.64%)
Mutual labels:  react-component
angular-lazy-loading
Angular 15 & React 18 Examples Lazy Loading
Stars: ✭ 39 (-84.21%)
Mutual labels:  react18
git-issue-react-electronjs
⚙️. ⚛️. A desktop application created with Electronjs and Reactjs to be cross-platform to manage and track GitHub issues.
Stars: ✭ 21 (-91.5%)
Mutual labels:  react-component
Registration-and-Login-using-MERN-stack
Simple Registration and Login component with MERN stack
Stars: ✭ 210 (-14.98%)
Mutual labels:  react-component
react-grid
react grid component
Stars: ✭ 17 (-93.12%)
Mutual labels:  react-component

React Textarea Code Editor

Build & Deploy Coverage Status NPM Download jsDelivr CDN Open in unpkg npm bundle size npm version

A simple code editor with syntax highlighting. This library aims to provide a simple code editor with syntax highlighting support without any of the extra features, perfect for simple embeds and forms where users can submit code.

Features:

  • 🌒 Support dark-mode/night-mode @v2.
  • ☕️ Automatic syntax highlighting.
  • 🐲 Automatic indent on new lines.
  • 🩲 Indent line or selected text by pressing tab key, with customizable indentation.
  • 🌸 Wrap selected text in parens, [], (), <>, {}, "", '', "", ``
  • 💡 Support next.js, Use examples in next.js.

Install

$ npm i @uiw/react-textarea-code-editor

Usage

Open in CodeSandbox Open in Github gh-pages

import CodeEditor from '@uiw/react-textarea-code-editor';

function App() {
  const [code, setCode] = React.useState(
    `function add(a, b) {\n  return a + b;\n}`
  );
  return (
    <CodeEditor
      value={code}
      language="js"
      placeholder="Please enter JS code."
      onChange={(evn) => setCode(evn.target.value)}
      padding={15}
      style={{
        fontSize: 12,
        backgroundColor: "#f5f5f5",
        fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace',
      }}
    />
  );
}

Support Nextjs

Use examples in nextjs. #31

Open in CodeSandbox

npm install next-remove-imports
npm install @uiw/[email protected]
// next.config.js
const removeImports = require("next-remove-imports")();
module.exports = removeImports({
  experimental: { esmExternals: true }
});
import React from "react";
import dynamic from "next/dynamic";
import "@uiw/react-textarea-code-editor/dist.css";

const CodeEditor = dynamic(
  () => import("@uiw/react-textarea-code-editor").then((mod) => mod.default),
  { ssr: false }
);

function HomePage() {
  const [code, setCode] = React.useState(
    `function add(a, b) {\n  return a + b;\n}`
  );
  return (
    <div>
      <CodeEditor
        value={code}
        language="js"
        placeholder="Please enter JS code."
        onChange={(evn) => setCode(evn.target.value)}
        padding={15}
        style={{
          fontSize: 12,
          backgroundColor: "#f5f5f5",
          fontFamily:
            "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace"
        }}
      />
    </div>
  );
}

export default HomePage;

Support dark-mode/night-mode

By default, the dark-mode is automatically switched according to the system. If you need to switch manually, just set the data-color-mode="dark" parameter for html Element.

<html data-color-mode="dark">
document.documentElement.setAttribute('data-color-mode', 'dark')
document.documentElement.setAttribute('data-color-mode', 'light')

Inherit custom color variables by adding .w-tc-editor-var selector.

const Demo = () => {
  return (
    <div>
      <div className="w-tc-editor-var"> </div>
      <CodeEditor value={code} />
    </div>
  )
}

Props

interface TextareaCodeEditorProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
  prefixCls?: string;
  /**
   * Set what programming language the code belongs to.
   */
  language?: string;
  /**
   * Optional padding for code. Default: `10`.
   */
  padding?: number;
  /**
   * rehypePlugins (Array.<Plugin>, default: `[[rehypePrism, { ignoreMissing: true }]]`)  
   * List of [rehype plugins](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins) to use. See the next section for examples on how to pass options
   */
  rehypePlugins?: PluggableList;
  /**
   * The minimum height of the editor. Default: `16`.
   */
  minHeight?: number;
  onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void | boolean;
}

List of supported languages can be found here

Demo

https://uiwjs.github.io/react-textarea-code-editor/

Development

Runs the project in development mode.

# Step 1, run first, listen to the component compile and output the .js file
# listen for compilation output type .d.ts file
npm run watch
# Step 2, development mode, listen to compile preview website instance
npm run start

production

Builds the app for production to the build folder.

npm run build

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

See Also

Contributors

As always, thanks to our amazing contributors!

Made with github-action-contributors.

License

Licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].