Coder Social home page Coder Social logo

newsiberian / meteor-universe-react-markdown-wysiwyg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cristo-rabani/meteor-universe-react-markdown-wysiwyg

0.0 3.0 0.0 13 KB

A few of react components, that providing visual editor of markdown and Html for Meteor

Home Page: https://atmospherejs.com/universe/react-markdown-wysiwyg

JavaScript 32.91% CSS 67.09%

meteor-universe-react-markdown-wysiwyg's Introduction

Universe Markdown Wysiwyg

A few of react components, that providing visual editor of markdown. As an editor engine this package use medium editor.

All is made as a es6 module and it's works with universe:modules Translations of labels can be changed with universe:i18n

check here: DEMO

Installation

Just add this package to your app:

meteor add universe:react-markdown-wysiwyg
//And if you not have yet:
meteor add universe:modules

DoubleEditor (Visual and Textarea for markdown code)

Props:

  • className - additional class name
  • markdown - markdown text to show
  • onChange - function call on data changed
  • options - options for medium editor
import DoubleEditor from '{universe:react-markdown-wysiwyg}/DoubleMarkdownComponent';

In your component: 
...
 <DoubleEditor markdown='# Hello' onChange={console.log.bind(console)}/>;
...

VisualEditor

Props:

  • tag (default div)
  • className - additional class name
  • markdown - markdown text to show
  • onChange - function call on data changed
  • options - options for medium editor
import ReactMarkdownMediumEditor from '{universe:react-markdown-wysiwyg}/ReactMarkdownMediumEditor';

In your component: 
...
 <ReactMarkdownMediumEditor markdown='# Hello' onChange={console.log.bind(console)}/>;
...

VisualHtmlEditor

Props:

  • tag (default div)
  • className - additional class name
  • html - html to show
  • onChange - function call on data changed
  • options - options for medium editor
import ReactHtmlMediumEditor from '{universe:react-markdown-wysiwyg}/ReactHtmlMediumEditor';

In your component: 
...
 <ReactHtmlMediumEditor html='<h1>Hello</h1>' onChange={console.log.bind(console)}/>;
...

default options for medium editor

options = {
    toolbar: {
        /* These are the default options for the toolbar,
         if nothing is passed this is what is used */
        allowMultiParagraphSelection: true,
        buttons: ['bold', 'italic', 'underline', 'anchor', 'h1', 'h2', 'h3', 'h4', 'orderedlist', 'unorderedlist', 'indent', 'outdent', 'quote', 'pre'],
        diffLeft: 0,
        diffTop: -10,
        firstButtonClass: 'medium-editor-button-first',
        lastButtonClass: 'medium-editor-button-last',
        standardizeSelectionStart: false,
        static: false,
        relativeContainer: null,
        buttonLabels: true
    },
    paste: {
        cleanAttrs: ['class', 'style', 'dir'],
        cleanTags: ['meta', 'span']
    },
    placeholder: {
        text: T.__('typeYourText')
    }

};

Additional in package

  • onResizeMixin
import onResize from '{universe:react-markdown-wysiwyg}/mixins/on-resize';
React.createClass({
  mixins: [onResize],
  render () {
    // By default, sets dimensions of window and docks to state 
    window: {height: window.innerHeight, width: window.innerWidth},
    document: {height: document.body.clientHeight, width: document.body.clientWidth}
    
    let {width, height} = this.state.window;
    return <div style={{ width, height }}>{children}</div>;
  }
}

or you can definied your own onResize function


React.createClass({
  mixins: [onResize],
  render () { 
    let {width, height} = this.state;
    return <div style={{ width, height }}>{children}</div>;
  },
  onResize () {
    this.setState({height: Math.max(React.findDOMNode(this).clientHeight, 100)});
  }
}

import Tabs, {TabPane} from '{universe:react-markdown-wysiwyg}/editor/rc-tabs';
import mediumEditor from '{universe:react-markdown-wysiwyg}/editor/medium-editor';
import toMarkdown from '{universe:react-markdown-wysiwyg}/editor/to-markdown';

meteor-universe-react-markdown-wysiwyg's People

Watchers

 avatar  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.