Giter VIP home page Giter VIP logo

editorjs-flutter's Introduction

EditorJS viewer for Flutter

A viewer and editor compatible with the EditorJS schema.

DISCLAIMER

This library is still under development, so critical bugs are expected and should not be used right now for a production environment.

Also, right now this plugin is compatible with Flutter 1 and 2. We are working in Flutter v3 compatibility and will come soon.

Installation

Add these lines in your pubspec.yaml file on the dependencies level:

  editorjs_flutter: any

After that just execute flutter pub get in Terminal as always.

Usage

Viewer

For Viewer, you must ensure you have as input an EditorJS JSON as shown in EditorJS documentation at https://editorjs.io/.

Also, you need to create a JSON file with the following schema for CSS styles:

{
  "cssTags": [
    {
      "tag" : "code",
      "backgroundColor" : "#33ff0000",
      "color" : "#ffff0000",
      "padding" : 5.0
    },
    {
      "tag" : "mark",
      "backgroundColor" : "#ffffff00",
      "padding" : 5.0
    }
  ],
  "defaultFont" : "Roboto"
}

After that, you may use the viewer as follows:

    EditorJSView editorJSView; // Set your EditorJSView instance.

    // Substitute as the way of getting your JSON
    String data = await DefaultAssetBundle.of(context).loadString("example_asset/example.json");
    String styles = await DefaultAssetBundle.of(context).loadString("example_asset/editorjsstyles.json");

    setState(() { // Recommended for async environments.
      editorJSView = EditorJSView(editorJSData: data);
    });

Finally, assign it to your widget as you wish. The Viewer has the same features as a common column.

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Your app title"),
      ),
      body: SingleChildScrollView(
          child: Column(children: [
            (editorJSView != null) ? editorJSView : Text("Please wait...")
          ],)
      ),
    );
  }

Editor

Editor is available right now as an alpha preview and is still under development. You may use it as follows:

  EditorJSEditor editorJSEditor; 

  @override
  void initState() {
    super.initState();
    setState(() {
      editorJSEditor = EditorJSEditor();
    });
  }

Finally, assign it to your widget as you wish. The Editor has the same features as a common column.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Create Note"),
      ),
      body: SingleChildScrollView(
        child: Column(children: [
          (editorJSEditor != null) ? editorJSEditor : Text("Please wait")
        ],)
      )
    );
  }

Collaborators

I want to say thank you to all collaborators on this development. Kudos for you :D

@Dhi13man - Flutter 2 compatibility and Null Safety.

@mnomanmemon - H1 to H6 behavior for the framework and Flutter v3 compatibility.

Want to Collaborate?

Please send me a message to Twitter (@RZEROSTERN) or an email to [email protected] for getting in touch.

Also if you have an issue or want to propose a fix, please leave it in the Issues tab on Github. I'll fix it ASAP.

Made in Mexico with love by RZEROSTERN

editorjs-flutter's People

Contributors

rzerostern avatar mukhtarfauzi avatar dhi13man avatar mnomanmemon 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.