1.1.1 • Published 3 years ago

@pohfy/react-prism-editor v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Prism Editor

A dead simple code editor with theme,syntax highlighting,line numbers.

Demo

react-prism-editor

Features

  • Theme
  • Copy to dashboard
  • Code Editing ^^
  • Syntax highlighting
  • Undo / Redo
  • Copy / Paste
  • The spaces/tabs of the previous line is preserved when a new line is added
  • Works on mobile (thanks to contenteditable)
  • Resize to parent width and height
  • Support for line numbers
  • Support for autosizing the editor
  • Autostyling the linenumbers

Install

npm install react-prism-editor

or

yarn add react-prism-editor

Usage

import ReactPrismEditor from "react-prism-editor";

<ReactPrismEditor
  language={language}
  theme={theme}
  code={code}
  lineNumber={lineNumber}
  readOnly={readOnly}
  clipboard={true}
  changeCode={code => {
    this.code = code
    console.log(code)
  }}
/>

Props

NameTypeDefaultOptionsDescription
codestring""-the code
languageString"javascript"json,javascript,jsx,tsx,typescripthtml,vue,angular,css,sass,markupjava,php,csharp,c,cpp,sql,xml,yamllanguage of the code
lineNumbersBooleanfalse-Whether to show line numbers or not
readonlyBooleanfalse-Indicates if the editor is read only or not
clipboardBooleanfalse-Whether to show clipboard or not
showLanguageBooleanfalse-Whether to show language or not

Events

NameParametersDescription
changeCode(code)Fires when the code is changed.

Thanks

inspired by react-live.

License

MIT