GithubHelp home page GithubHelp logo

axel186 / charts-tinymce-plugin Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 850 KB

Add charts into your content (Tinymce plugin)

License: MIT License

JavaScript 85.66% HTML 2.83% CSS 11.51%
tinymce-plugin graph charts data-visualisation chartistjs

charts-tinymce-plugin's Introduction

Charts TinyMCE Plugin

With this plugin you able to add charts into your content. This plugin using Chartist.js libary for rendering graphs.

This plugin compatible with TinyMce 4.

Charts TinyMCE Plugin - Visual demo

Install

NPM:

npm install charts-tinymce-plugin --save

Bower:

bower install charts-tinymce-plugin --save

Download

Usage

Configure your TinyMce init settings by adding external_plugins and usage of chartsTinymcePlugin:

tinymce.init({
  selector: 'textarea',
  external_plugins: {'chartsTinymcePlugin': 'http://your-website/.../charts-tinymce-plugin/plugin.js'}, // Add plugin to Tinymce
  toolbar: 'chartsTinymcePlugin',
  content_css: 'http://your-website/.../charts-tinymce-plugin/app/scripts/chartist/chartist.css', // Add chartist styles or use your own.
  chart_uploader: function (file, cb) {
    // Here is your uploader logic, start to upload you image here like that:

    // yourUploader.sendIMG(file.blob)
    //   .then(function(url){
    //      // Take a look at "class='tinymce-chart'" and "charts-data='" + file.chartsData + "'", it is really important to keep it in the tag - that's way you able to edit your graph.
    //      cb("<img class='tinymce-chart' width='" + file.width + "' height='" + file.height + "' src='" + url + "' charts-data='" + file.chartsData + "' />");
    //   });

    // or just put SVG-html into your content. Example:
    cb(file.html);
  }
});

There are 2 options how to use this plugin:

  1. Add SVG tag width graph into your content, I found that is very hard to work with SVG into Tinymce. It's hard to align or edit because it contains a lot of tags inside.
  2. Is to upload "Blob file" that plugin returns to your own server and after that add the IMG tag with path to the file. If you are using this method, you able to edit the graph and update the changes. (Take a look at the screenshot above).

How to test it:

git clone https://github.com/Axel186/charts-tinymce-plugin.git
cd charts-tinymce-plugin
npm install
npm start

Now go to http://localhost:8080.

How to build the dist files:

npm run build

Now you got your own dist folder - minimized version of plugin already there.

The development server

By running the npm start command you start the development server and open a browser window with an instance of TinyMCE with your plugin added to it. This window will reload automatically whenever a change is detected in the index.html file in the static folder or in one of the JavaScript files in the src directory.

The production build

By running the npm run build command Webpack will create a dist directory with a child directory with the name of your plugin (charts-tinymce-plugin) containing three files:

  • plugin.js - the bundled plugin
  • plugin.min.js - the bundles, uglified and minified plugin
  • LICENSE - a file explaining the license of your plugin (copied over from src/LICENSE)

License - MIT

charts-tinymce-plugin's People

Contributors

axel186 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

ellisa1419

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.