A rich text editor for Flutter

MIT License PRs Welcome Watch on GitHub Star on GitHub Watch on GitHub

FlutterQuill is a rich text editor and a Quill component for Flutter.

This library is a WYSIWYG editor built for the modern mobile platform, with web compatibility under development. You can join our Slack Group for discussion.

Demo App: https://bulletjournal.us/home/index.html

Pub: https://pub.dev/packages/flutter_quill

Usage

See the example directory for a minimal example of how to use FlutterQuill. You typically just need to instantiate a controller:

QuillController _controller = QuillController.basic();

and then embed the toolbar and the editor, within your app. For example:

Column(
  children: [
    QuillToolbar.basic(controller: _controller),
    Expanded(
      child: Container(
        child: QuillEditor.basic(
          controller: _controller,
          readOnly: false, // true for view only mode
        ),
      ),
    )
  ],
)

Check out Sample Page for advanced usage.

Input / Output

This library uses Quill as an internal data format.

  • Use _controller.document.toDelta() to extract the deltas.
  • Use _controller.document.toPlainText() to extract plain text.

FlutterQuill provides some JSON serialisation support, so that you can save and open documents. To save a document as JSON, do something like the following:

var json = jsonEncode(_controller.document.toDelta().toJson());

You can then write this to storage.

To open a FlutterQuill editor with an existing JSON representation that you've previously stored, you can do something like this:

var myJSON = jsonDecode(incomingJSONText);
_controller = QuillController(
          document: Document.fromJson(myJSON),
          selection: TextSelection.collapsed(offset: 0));

Configuration

The QuillToolbar class lets you customise which formatting options are available. Sample Page provides sample code for advanced usage and configuration.

Web

For web development, use flutter config --enable-web for flutter and use ReactQuill for React.

It is required to provide EmbedBuilder, e.g. defaultEmbedBuilderWeb. Also it is required to provide webImagePickImpl, e.g. Sample Page.

Desktop

It is required to provide filePickImpl for toolbar image button, e.g. Sample Page.

Custom Size Image for Mobile

Define mobileWidth, mobileHeight, mobileMargin, mobileAlignment as follows:

{
      "insert": {
         "image": "https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png"
      },
      "attributes":{
         "style":"mobileWidth: 50; mobileHeight: 50; mobileMargin: 10; mobileAlignment: topLeft"
      }
}

Translation of toolbar

The package offers translations for the quill toolbar, it will follow the system locale unless you set your own locale with:

QuillToolbar(locale: Locale('fr'), ...)

Currently, translations are available for these locales:

  • Locale('en')
  • Locale('de')
  • Locale('fr')
  • Locale('zh', 'CN')

Contributing to translations

The translation file is located at lib/src/translations/toolbar.i18n.dart. Feel free to contribute your own translations, just copy the English translations map and replace the values with your translations. Then open a pull request so everyone can benefit from your translations!

Migrate Zefyr Data

Check out code and doc.


1 1

1 1

Sponsors

Libraries

attribute
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
block
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
box
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
color
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
container
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
controller
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
cursor
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
default_styles
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
delegate
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
delete
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
diff_delta
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
document
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
editor
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
embed
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
flutter_quill
format
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
history
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
image
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
insert
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
keyboard_listener
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
leaf
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
line
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
node
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
proxy
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
quill_delta
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
raw_editor
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
raw_editor_state_keyboard_mixin
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
raw_editor_state_selection_delegate_mixin
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
raw_editor_state_text_input_client_mixin
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
rule
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
simple_viewer
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
style
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
text_block
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
text_line
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
text_selection
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.
toolbar
TODO: Remove this file in the next breaking release, because implementation files should be located in the src folder, https://bit.ly/3fA23Yz.