Code Monkey home page Code Monkey logo

react-mui-draft-wysiwyg's Introduction

react-mui-draft-wysiwyg

React component that allows to use a rich editor based on Material UI and Draft-js

NPM JavaScript Style Guide

Hi, I'm a rich text editor based on MUI and Draft.js

Install

if you don't have Material UI installed yet:

https://material-ui.com/getting-started/installation/

Then install the editor:

With npm:

npm install --save @material-ui/icons draft-js react-mui-draft-wysiwyg

Or with yarn:

yarn add @material-ui/icons draft-js react-mui-draft-wysiwyg

Usage

import React from 'react'
import MUIEditor, { MUIEditorState } from 'react-mui-draft-wysiwyg'

function Example() {
  const [editorState, setEditorState] = React.useState(MUIEditorState.createEmpty());

  const onChange = (newState) => {
    setEditorState(newState);
  };

  <MUIEditor editorState={editorState} onChange={onChange} />
}

Full documentation here:

https://kelsier90.github.io/react-mui-draft-wysiwyg/

License

MIT ยฉ Kelsier90

react-mui-draft-wysiwyg's People

Contributors

kelsier90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-mui-draft-wysiwyg's Issues

Upgrade to material ui v5

This package doesn't support material ui v5. Material ui v5 was released a long time ago and the packages were changed from @material-ui/* to @mui/*.

Add typescript typings

When working with mui and typescript, I have errors with this package since it doesn't have any typescript typings.

MUIEditor How to set limit chars

Hi,
I'm struggling since a couple days to trying to set a limit characters to the Editor. But it's seems that the handleBeforeInput doesn't works ?? How could I firgure this out ?? Please!! Please !!! any Idea ? or example. Have look below. Thank you!!
`
const [editorState, setEditorState] = useState(MUIEditorState.createEmpty());
const { maxLength } = props

/**
 *
 * @returns {string}
 */
const handleBeforeInput = () => {
    const currentContent = editorState.getCurrentContent();
    const currentContentLength = currentContent.getPlainText("").length;

    if (currentContentLength <= maxLength) {
        console.log("not-handled")
        return 'not-handled';
    }
    return "handled";
};

<MUIEditor
            editorState={editorState}
            onChange={(newState) => onChange(newState)}
            handleBeforeInput={handleBeforeInput()}
            config={props.invalid && props.errorState ? errorConfig : config }
        />

`

your toHTML() method data not returning properlly

Hi @Kelsier90
I am using your dependency in my react application, but this toHTML() method not returning the correct data, it's appending some JS function with every tag.

Can you please help me with how can I solve this?
Or is it paid? due to the free version not working properly.

for example:

<p>Amit Ranjan function (params) {
  var newString = `this;`
  Object.entries(params).forEach(function (_ref) {
    var _ref2 = Object(_home_amit_Downloads_coach_app_coachbetter_ch_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_slicedToArray__WEBPACK_IMPORTED_MODULE_0__["default"])(_ref, 2),
        key = _ref2[0],
        value = _ref2[1];

    newString = newString.replace(":".concat(key), value);
  });
  return newString;
}</p>

image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.