How to use draft-js-toolbar-plugin - 2 common examples

To help you get started, we’ve selected a few draft-js-toolbar-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github draft-js-plugins / draft-js-plugins / docs / client / components / pages / Toolbar / SimpleToolbarEditor / index.js View on Github external
import React, { Component } from 'react';
import Editor, { createEditorStateWithText } from 'draft-js-plugins-editor';
import TextToolbar from 'draft-js-toolbar-plugin/components/text-toolbar';
import createToolbarPlugin from 'draft-js-toolbar-plugin';
import styles from './styles.css';

const toolbarPlugin = createToolbarPlugin({});
const text = `Cool, we can have all sorts of Emojis here. 🙌
🌿☃️🎉🙈 aaaand maybe a few more here 🐲☀️🗻 Quite fun!`;

class SimpleToolbarEditor extends Component {
  state = {
    editorState: createEditorStateWithText(text),
    draggingOver: false,
  };

  onChange = (editorState) => {
    // console.log(convertToRaw(editorState.getCurrentContent()));
    this.setState({
      editorState,
    });
  };
github draft-js-plugins / draft-js-plugins / docs / client / components / pages / Dnd / CustomDndEditor / index.js View on Github external
import React, {Component} from 'react';
import Image from './Image';
import {EditorState} from 'draft-js';
import Editor from 'draft-js-plugins-editor';
import createUploadPlugin from 'draft-js-dnd-plugin';
import createToolbarPlugin from 'draft-js-toolbar-plugin';
import TextToolbar from 'draft-js-toolbar-plugin/components/text-toolbar';
import styles from './styles.css';
import mockUpload from '../utils/mockUpload';
import DndWrapper from 'draft-js-dnd-plugin/components/dnd-wrapper';
import decorateWithProps from 'decorate-component-with-props';

const toolbarPlugin = createToolbarPlugin({});
const uploadPlugin = createUploadPlugin({
  Image: decorateWithProps(Image, { toolbarTheme: toolbarPlugin.theme }),
  upload: (data, success, failed, progress) =>
    mockUpload(data, success, failed, progress),
});

class SimpleDndEditor extends Component {
  state = {
    editorState: EditorState.createEmpty(),
    draggingOver: false,
  };

  onChange = (editorState) => {
    this.setState({
      editorState,
    });

draft-js-toolbar-plugin

Toolbar Plugin for DraftJS

MIT
Latest version published 8 years ago

Package Health Score

69 / 100
Full package analysis

Popular draft-js-toolbar-plugin functions