1.0.4 • Published 4 years ago

@superdatascience/react-text-editor v1.0.4

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

Moved

This package has moved and is now available at @codifytools/react-text-editor. Please update your dependencies. This repository is no longer maintained.

React Text Editor

A small, simple and customizable text editor for React applications.

Table of Contents

Installation

To install, you can use npm or yarn:

npm install @superdatascience/react-text-editor

Usage

import React, { useState, Fragment } from 'react';
import ReactDOM from 'react-dom';
import Editor from '@superdatascience/react-text-editor';

const Example = () => {
  const [values, setValues] = useState({ text: '<p>Editor example text</p>' });

  const handleChange = (event) => {
    const { name, value } = event.target;
    setValues({ ...values, [name]: value });
  }

  return (
    <Fragment>
        <Editor
          field="text"
          html={values.text}
          saveCallback={handleChange}
          placeholder="custon placeholder text..."
       />

       <button onClick={() => console.log(values.text)}>Preview Text</button>
    </Fragment>
  );
};

ReactDOM.render(<Example />, document.body);

Props

PropTypeDescription
fieldStringField that callback event.target.name will replace
htmlStringCurrent html text value
saveCallbackFunctionSave changes function. The Editor returns a event with the updated information
placeholderStringText editor custom placeholder

Requirements

The minimum supported version of React is v16.13.1. If you use an older version, upgrade React to use this library.

Contributing

If you would like to contribute to React Text Editor, please make sure to read our contributor guidelines.

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago