1.1.0 • Published 5 years ago

codeui-js v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

codeui-js

A full-featured node package providing code editor ui to be embedded in webpages/webapps.

Install

npm install codeui-js

or

yarn add codeui-js

Features

  1. Line Number
  2. File name
  3. Toogle code editing
  4. Line Highlight
  5. Customizing style properties
  6. Theme Selection

Usage

import React from "react";
import ReactDOM from "react-dom";

import { Codeui } from "codeui-js";

function App() {
  const data = `return (
        <>
          <h1 style={{ textAlign: "center" }}>codeui-js</h1>
          <Codeui data={data} />
        </>
      );`;

  return (
    <Codeui
      data={data}
      contentEditable={false}
      fileName="index.html"
      lineNumbering={true}
      lineToHighlight="3,4"
      wrap={false}
      borderRadius="1rem"
      lineHeight="1.6"
      fontSize="16"
      /* backgroundColor=""
      textColor=""
      highlighterColor=""
      highlighterLeftColor=""
      theme="" */
    />
  );
}

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById("root")
);

Output:

Output Image

Attributes:

NameDescriptionRequiredData typePossible ValuesDefault ValueExample
dataAccepts the string representing the code/portion of text to be displayedtruestringAny stringNULL<>codeui-js</>
contentEditableAllows to enable or disable the text editing on webpagefalsebooleantrue, falsefalse{true}
fileNameAccepts a string containing the filename to be displayed at bottomfalsestringAny stringNULLindex.html
lineNumberingAllows to choose either to display line numbers or notfalsebooleantrue, falsetrue{true}
lineToHighlightAccepts a string conatining line numbers to be highlighted by comma sepratedfalsestringAny string with numbers seprated by commaNULL"1,2,3,6"
wrapAllows to chose either the words should be wrapped or notfalsebooleantrue, falsefalse{true}
borderRadiusAccepts a string or a numberic value for representing the amount of corners to be roundedfalsestring or numericAny string or number (int,float)0.5rem"1rem" or {1}
lineHeightAccepts a string or a numberic value for representing the vertical spacing to be applied between linesfalsestring or numericAny string or number (int,float)1.6"1rem" or {1.6}
fontSizeAccepts a string or a numeric value representing the size of textfalsestring or numericAny string or number16px"1rem" or {16}
backgroundColorAccepts a string representing a color value to be applied as background to the editor uifalsestringAny string containing acceptable color valuergb(1, 22, 39)"black" or "#00000" or "rgb(1,22,39,0.5)" or "hsl(217,34%,29%)"
textColorAccepts a string representing a color value to be applied as foreground text colorfalsestringAny string containing acceptable color valuergb(214, 222, 235)"white" or "#ffffff" or "rbb(1,22,39,0.5)" or "hsl(217,34%,29%)"
highlighterColorAccepts a string representing a color value to be applied as line highlighter colorfalsestringAny string containing acceptable color valuergb(2, 42, 75)"blue" or "#00ff00" or "rgb(1,22,39,0.5)" or "hsl(217,34%,29%)"
highlighterLeftColorAccepts a string representing a color value to be applied as line highlighter left border colorfalsestringAny string containing acceptable color valuergb(239, 83, 80)"red" or "#ff0000" or "rgb(1,22,39,0.5)" or "hsl(217,34%,29%)"
themeAccepts a string representing the theme namefalsestringlight, bitLight, solarizedLight, purple, dark, solarizedDark, red, pinkGrey, whiteGrey, crimsonNULL(defalut theme)"light"

Theme's:

1. light

light

2. bitLight

bitLight

3. solarizedLight

solarizedLight

4. purple

purple

5. dark

dark

6. solarizedDark

solarizedDark

7. red

red

8. pinkGrey

pinkGrey

9. whiteGrey

whiteGrey

10. crimson

crimson