Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details →
Socket
Book a DemoInstallSign in
Socket

react-codejar

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-codejar

React wrapper around the codejar library

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
171
-15.76%
Maintainers
1
Weekly downloads
 
Created
Source

react-codejar

NPM React wrapper around the CodeJar library

Install

npm install --save react-codejar

Features

You can customize codejar by passing the options prop, it also have a lineNumbers prop that will use codejar's withLineNumbers for you.

Usage

import React, { Component, useState } from "react";

// You can choose to use the component or the hook
import { ReactCodeJar, useCodeJar } from "react-codejar";

const highlight = editor => {
  let code = editor.textContent;
  code = code.replace(/\((\w+?)(\b)/g, '(<font color="#8a2be2">$1</font>$2');
  editor.innerHTML = code;
};

const ComponentExample = () => {
  const [code, setCode] = useState('(format t "lisp example")');

  return (
    <ReactCodeJar
      code={code} // Initial code value
      onUpdate={setCode} // Update the text
      highlight={highlight} // Highlight function, receive the editor
      lineNumbers={true} // Show line numbers
    />
  );
};

const HookExample = () => {
  const [code, setCode] = useState('(format t "lisp example")');

  const editorRef = useCodeJar({
    code, // Initial code value
    onUpdate: setCode, // Update the text
    highlight, // Highlight function, receive the editor
    lineNumbers: true // Show line numbers
  });

  return <div ref={editorRef}></div>;
};

License

GPL3 © guilhermelimak

FAQs

Package last updated on 15 Jul 2021

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