1.1.14 • Published 9 years ago

simple-draftjs v1.1.14

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

Simple Draft-js

Minimal wysiwyg rich editor using draftjs (Rich editor framework for React).

Demo

http://platzidev.github.io/simple-draftjs/

Install

npm i -S simple-draftjs

How to use?

import React from 'react';
import { render } from 'react-dom';
import Editor from 'simple-draftjs';

const buttons = [
  { name: 'bold' },
  { name: 'italic' },
  { name: 'underline' },
  { name: 'separator' },
  { name: 'unordered-list' },
  { name: 'separator' },
  { name: 'image' },
  { name: 'link' },
  { name: 'unlink' },
  { name: 'separator' },
  { name: 'code' },
];

/** optional css icons:
const buttons = [
  { name: 'bold' },
  { name: 'italic' },
  { name: 'underline' },
  { name: 'separator' },
  { name: 'unordered-list', icon: 'icon-list' },
  { name: 'separator' },
  { name: 'image', icon: 'icon-image'},
  { name: 'link', icon: 'icon-link'},
  { name: 'unlink', icon: 'icon-unlink' },
  { name: 'separator' },
  { name: 'code', , icon: 'icon-code' },
];
**/


render(
  <Editor
    getContentAction={printHTML}
    hideButtonAction={closeEditor}
    placeholder={"do somenthing!"}
    controls={controls}
  />,
  document.getElementById('root')
);

function printHTML(content) {
  console.log("func ok");
}

function closeEditor() {
  console.log("close");
}

Options

Options should be set via props

Option (prop)typedescriptionrequired
getContentActionfunctioncallback that return html or markdown content when "send" button is clicked or the state change*
placeholderstringPlaceholder for empty editor-
controlsarraylist of elements to show as button options-
exportstirngFormat for return. options: HTML, Markdown-
messagesObjecttext for buttons-
inactivebooleanblock editor if it is true-
inactiveStyleobjectCSS React object for inactive state-
hideButtonActionfunccallback for 'cancel' button click event-

getContentAction (required)

function callback that return html or markdown content when "send" button is clicked or the state change

function getContent(content) {
    console.log("html content", content); // <p>something</p>
}
<Editor getContentAction={getContent} />

placeholder (optional)

string placeholder.

controls (optional)

array list of elements to show as button options Note: separator is the line for serparate items "|"

export default [
  { name: 'bold' },
  { name: 'italic' },
  { name: 'underline' },
  { name: 'separator' },
  { name: 'unordered-list' },
  { name: 'separator' },
  { name: 'image' },
  { name: 'link' },
  { name: 'unlink' },
  { name: 'separator' },
  { name: 'code' },
];

<Editor controls={controls} />

export (optional)

option: "html", "markdown" default: "html"

messages (optional)

default:

messages: {
  buttons: {
    send: 'Send',
    cancel: 'Cancel',
  }
},

How to Run?

npm install
npm start
open http://localhost:3002

Contribute: https://github.com/jhta/simple-draftjs

Dependencies

1.1.14

9 years ago

1.1.13

9 years ago

1.1.12

9 years ago

1.1.11

9 years ago

1.1.10

9 years ago

1.1.9

9 years ago

1.1.8

9 years ago

1.1.7

9 years ago

1.1.6

9 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.0.20

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago