Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-ace

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ace

A react component for Ace Editor

  • 9.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
408K
increased by0.92%
Maintainers
1
Weekly downloads
 
Created

What is react-ace?

The react-ace package is a React component for the Ace editor, which is a powerful code editor written in JavaScript. It allows you to embed the Ace editor into your React applications, providing a rich set of features for code editing, syntax highlighting, and more.

What are react-ace's main functionalities?

Basic Usage

This code demonstrates the basic usage of the react-ace package. It imports the necessary modules and sets up an Ace editor with JavaScript mode and the GitHub theme.

import React from 'react';
import AceEditor from 'react-ace';
import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-github';

function MyEditor() {
  return (
    <AceEditor
      mode="javascript"
      theme="github"
      name="editor"
      editorProps={{ $blockScrolling: true }}
    />
  );
}

export default MyEditor;

Customizing Editor Options

This code sample shows how to customize various options of the Ace editor, such as font size, print margin, gutter, active line highlighting, and enabling autocompletion and snippets.

import React from 'react';
import AceEditor from 'react-ace';
import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-github';

function MyEditor() {
  return (
    <AceEditor
      mode="javascript"
      theme="github"
      name="editor"
      fontSize={14}
      showPrintMargin={true}
      showGutter={true}
      highlightActiveLine={true}
      setOptions={{
        enableBasicAutocompletion: true,
        enableLiveAutocompletion: true,
        enableSnippets: true,
        showLineNumbers: true,
        tabSize: 2,
      }}
    />
  );
}

export default MyEditor;

Handling Editor Events

This example demonstrates how to handle events in the Ace editor. The onChange event is used to log the new value of the editor whenever it changes.

import React from 'react';
import AceEditor from 'react-ace';
import 'ace-builds/src-noconflict/mode-javascript';
import 'ace-builds/src-noconflict/theme-github';

function MyEditor() {
  const onChange = (newValue) => {
    console.log('change', newValue);
  };

  return (
    <AceEditor
      mode="javascript"
      theme="github"
      name="editor"
      onChange={onChange}
    />
  );
}

export default MyEditor;

Other packages similar to react-ace

Keywords

FAQs

Package last updated on 24 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc