RD17 / react-trumbowyg

React wrapper for lightweight WYSIWYG editor Trumbowyg
MIT License
146 stars 21 forks source link

Add plugin support in Trumbowyg editor in reactjs #3

Closed Dannybrown2710 closed 7 years ago

Dannybrown2710 commented 7 years ago

Hi there, can you help me how to import the color plugin for Trumbowyg editor in react js? Thanks in advance

sochix commented 7 years ago

Download the plugin, and import it somewhere before react-trymbowyg

Dannybrown2710 commented 7 years ago

But where do I import? trumbowyg is imported as a package but colors plugin wont be available as package?

Alex-D commented 7 years ago

Idk how ReactJS works, but plugins are in the main repository so if you install trumbowyg, you get plugins at the same time. Maybe you just need to expose them?

ashleydb commented 7 years ago

It does work today. It may not look pretty, but it works. For example, I needed to add the tables plugin:

import React from 'react';

import Trumbowyg from 'react-trumbowyg';
// ADD THIS LINE. ADJUST THE BEGINNING OF THE PATH AS NEEDED FOR YOUR PROJECT
import '../../node_modules/trumbowyg/dist/plugins/table/trumbowyg.table';

export default class MyComponent extends React.Component {
    constructor(props) {
        super(props);
    }
    render() {
        return (
            <div>
                    <Trumbowyg id='react-trumbowyg'
                        buttons={
                            [
                                ['viewHTML'],
                                ['formatting'],
                                'btnGrp-semantic',
                                ['link'],
                                ['insertImage'],
                                'btnGrp-justify',
                                'btnGrp-lists',
                                ['table'], // I ADDED THIS FOR THE TABLE PLUGIN BUTTON
                                ['fullscreen']
                            ]
                        }
                        data={this.props.someData}
                        placeholder='Type your text!'
                        onChange={this.props.someCallback}
                        ref="trumbowyg"
                    />
            </div>
        );
    }
}
sochix commented 7 years ago

Awesome job @ashleydb !

sahar922 commented 6 years ago

@ashleydb I copied the same code as you wrote, the table icon does appear but after clicking nothing happened. any suggestions?

ashleydb commented 6 years ago

Hard to say. Code may have changed since last year. Check your JavaScript console in your browser for errors?

sahar922 commented 6 years ago

nop. no errors at all :|

tejash-jl commented 5 years ago

nop. no errors at all :| I faced the same issue, when I tried to import the following, it works:


import 'react-trumbowyg/dist/trumbowyg.min.css';
import 'trumbowyg/dist/trumbowyg.js';
import 'trumbowyg/dist/plugins/table/ui/trumbowyg.table.css';
import 'trumbowyg/dist/plugins/table/trumbowyg.table.js';```