GithubHelp home page GithubHelp logo

cusspvz / draft-js-basic-html-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dburrows/draft-js-basic-html-editor

0.0 3.0 0.0 477 KB

Basic HTML editor using draft.js - html in, html out

License: MIT License

HTML 1.45% CSS 10.41% JavaScript 88.15%

draft-js-basic-html-editor's Introduction

draft-js-BasicHtmlEditor

Basic HTML editor using draft.js - html in, html out

Proof of concept currently, not production ready! PR's welcome.

Extends the Rich example from the Draft repo to accept html as its input format, and return html to an onChange handler.

Tag Support

Block tags: <p> <h1> <h2> <blockquote> <ul> <ol> <code>

Inline tags: <strong> <em> <u> <code> <del>

Install

$ npm install draft-js-basic-html-editor

Note: You'll also need to install react and react-dom if you don't already have them

Webpack

The component is built without react or react-dom so you'll need to make sure that Webpack can resolve copies of both those modules. Either add your projects node_modules as fallback path:

resolve: {
  fallback:  path.resolve('./node_modules')
}

or create an alias for just those 2 modules

resolve: {
  alias: {
    'react': path.resolve('./node_modules/react'),
    'react-dom': path.resolve('./node_modules/react-dom'),
  }

Usage

import BasicHtmlEditor from 'draft-js-basic-html-editor';

const MyEditor = () => {
  const initialHtml = 'hello, <b>World</b>';
  const onChange = html => console.log('updated', html);

  return (
    <BasicHtmlEditor
      value={ initialHtml }
      onChange={ onChange }
      debounce={ 500 }
    />
  )
}

Demo

http://dburrows.github.io/draft-js-basic-html-editor/example-dist/

Development

$ npm install
$ webpack-dev-server

To Do

  • Block support ✔️
  • Inline tag support ✔️
  • Handle Lists with more than one element ✔️
  • Tests ✔️
  • Links ✔️
  • Images
  • Prod build ✔️

draft-js-basic-html-editor's People

Contributors

dburrows avatar guncha avatar

Watchers

James Cloos avatar José Moreira avatar  avatar

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.