Code Monkey home page Code Monkey logo

flutter-quill's Introduction

Flutter Quill

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 (What You See Is What You Get) editor built for the modern Android, iOS, web and desktop platforms. Check out our Youtube Playlist or Code Introduction to take a detailed walkthrough of the code base. You can join our Slack Group for discussion.

Pub page: FlutterQuill
If you are viewing this page from pub.dev page, then you might have some issues with opening some links, please open it's in the GitHub repo instead.

Table of contents

Screenshots

Tap to show/hide screenshots
Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4

Installation

dependencies:
  flutter_quill: ^<latest-version-here>

OR

dependencies:
  flutter_quill:
    git: https://github.com/singerdmx/flutter-quill.git

Note: At this time, we are making too many changes to the library, and you might see a new version almost every day

Using the latest version and reporting any issues you encounter on GitHub will greatly contribute to the improvement of the library. Your input and insights are valuable in shaping a stable and reliable version for all our users. Thank you for being part of the open-source community!

Platform Specific Configurations

Before using the package, we must inform you the package use the following plugins:

url_launcher
flutter_keyboard_visibility
device_info_plus
super_clipboard

All of them doesn't require any platform specific setup, except super_clipboard which needs some setup on Android only, it's used to support copying images and pasting them into editor then you must setup it, open the page in pub.dev and read the README.md to get the instructions.

The minSdkVersion is 23 as super_clipboard requires it

Usage

First, you need to instantiate a controller

QuillController _controller = QuillController.basic();

And then use the QuillEditor, QuillToolbar widgets, connect the QuillController to them

QuillToolbar.simple(
  configurations: QuillSimpleToolbarConfigurations(
    controller: _controller,
    sharedConfigurations: const QuillSharedConfigurations(
      locale: Locale('de'),
    ),
  ),
),
Expanded(
  child: QuillEditor.basic(
    configurations: QuillEditorConfigurations(
      controller: _controller,
      readOnly: false,
      sharedConfigurations: const QuillSharedConfigurations(
        locale: Locale('de'),
      ),
    ),
  ),
)

Depending on your use case, you might want to dispose of the _controller in dispose method

in most cases, it's better to.

Check out Sample Page for more advanced usage.

Migration

Starting from version 8.0.0 We have added Migration Guide for migration from different versions

Input / Output

This library uses Quill Delta to represent the document content. The Delta format is a compact and versatile way to describe document changes. It consists of a series of operations, each representing an insertion, deletion, or formatting change within the document.

Don’t be confused by its name Delta—Deltas represents both documents and changes to documents. If you think of Deltas as the instructions for going from one document to another, the way Deltas represents a document is by expressing the instructions starting from an empty document.

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

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

final 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:

final json = jsonDecode(r'{"insert":"hello\n"}');

_controller.document = Document.fromJson(json);

Links

Configurations

The QuillToolbar and QuillEditor widgets let you customize a lot of things Sample Page provides sample code for advanced usage and configuration.

Links

Font Family

To use your own fonts, update your assets folder and pass in fontFamilyValues. More details on this commit, this article and this.

Embed Blocks

As of version 6.0, embed blocks are not provided by default as part of this package. Instead, this package provides an interface for all the users to provide their own implementations for embed blocks. Implementations for image, video, and formula embed blocks are proved in a separate package flutter_quill_extensions.

Provide a list of embed

Using the embed blocks from flutter_quill_extensions

To see how to use the extension package, please take a look at the README of FlutterQuill Extensions

Links

Conversion to HTML

Having your document stored in Quill Delta format is sometimes not enough. Often you'll need to convert it to other formats such as HTML to publish it, or send an email.

Note: This package support converting from HTML back to Quill delta but it's experimental and used internally when pasting Html content from the cliboard to the Quill Editor

You have two options:

  1. Using quill_html_converter to convert to HTML, the package can convert the Quill delta to HTML well (it uses vsc_quill_delta_to_html), it just a handy extension to do it more quickly
  2. Another option is to use vsc_quill_delta_to_html to convert your document to HTML. This package has full support for all Quill operations—including images, videos, formulas, tables, and mentions. Conversion can be performed in vanilla Dart (i.e., server-side or CLI) or in Flutter. It is a complete Dart part of the popular and mature quill-delta-to-html Typescript/Javascript package. this package doesn't convert the HTML back to Quill Delta as far as we know

Translation

The package offers translations for the quill toolbar and editor, it will follow the system locale unless you set your own locale.

Open this page for more info

Testing

Please use flutter_quill_test for testing

Contributors

Special thanks to everyone who has contributed to this project...


Made with contrib.rocks.

We welcome contributions!

Please follow these guidelines when contributing to the project. See CONTRIBUTING.md for more details.

We must mention that the CONTRIBUTING.md has development notes, so if you're planning on contributing to the repo, please consider reading it.

You can check the Todo list if you want to

flutter-quill's People

Contributors

adil192 avatar appflowy avatar arjanaswal avatar bambinoua avatar blquinn avatar cierra-runis avatar develeste avatar egork0rshun avatar ellet0 avatar foreverpw avatar friebetill avatar garv-shah avatar gtyhn avatar huqigu avatar hyouuu avatar jon-salmon avatar kevindespoulains avatar li3317 avatar macdeveloper1 avatar magtuxgit avatar mark8044 avatar mtallenca avatar pengw00 avatar richardmarshall avatar rish07 avatar s0nerik avatar singerdmx avatar spchief avatar theachoem avatar xinyuezhang0402 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter-quill's Issues

Issues with the quill editor on Flutter Web 2.0

I am currently experiencing issues with the quill editor on Flutter 2.0. If I use the basic QuillEditor example from https://github.com/singerdmx/flutter-quill/blob/master/example/main.dart I can only type a few letters before the editor freezes. Unfortunately there are no console logs out of the ordinary I could post here, the editor just becomes unresponsive.
To reproduce the issues I am experiencing just run the example code (https://github.com/singerdmx/flutter-quill/blob/master/example/main.dart) in Flutter 2.0 on Chrome.

Flutter Doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.0, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Community Edition (version 2020.3)
[✓] Connected device (1 available)

Links like tel:

Please remove the check for the correctness of the link when you click on it.
This check can and should be done in the onLaunchUrl handler

[web] Does flutter-quill support web application now?

Hi, @singerdmx I am a user from Zefyr package. I saw you actively answering the question there. Thank you, your answer helps me too. Since the Zefyr is not maintaining now.... ( is at dev 2.0) for a while... Initially, flutter-quill is not supporting the web, only on a mobile. Now it does🎉, I saw the tag under the package name and I am really glad to see that. I am wondering how does the package work on the web currently? Is it still in an early phase or it has all the basic functions working on the web as in mobile? Thanks again for the great package.👍

Newline character ("\n") takes a lot of space.

The newline character takes a lot of space and fills the entire screen pretty quickly.
In my opinion it should take as much space as the normal line in a paragraph does.
Right now it is taking twice as much.

Is there a way to get or load html content

Hello,

I really like this package, it looks promising. I only have one question:
is there an Html converter? what if we want to get or load html content in editor?

Thanks.

How to get only String to Display it in TextField ?

This is not an issue. Just a doubt. I just store data from quill editor as json in sqflite database and retrieve it, show it in Text widget. But what happens, it shows unknown characters when image or something stored in data. when extracted through toPlainText() method.

So how to get only text which typed not any customizations. Thanks

Save Written Data to firebase

I am trying to build an article app and I need to save the data inputted to firebase or any server then retrieve it back. How can this be done?

Incompatibility flutter_quill with dio,validators - Important

Hello sir
I When
flutter_quill: ^1.0.5

I use with
dio: ^3.0.10
validators: ^2.0.1

It is inconsistent and I have a lot of problems, please solve it

Because flutter_quill >=1.0.1 depends on image_picker ^0.7.2 which depends on image_picker_platform_interface ^2.0.0, flutter_quill >=1.0.1 requires image_picker_platform_interface ^2.0.0.
And because image_picker_platform_interface >=2.0.0 depends on http ^0.13.0 which depends on http_parser ^4.0.0, flutter_quill >=1.0.1 requires http_parser ^4.0.0.
And because dio 3.0.10 depends on http_parser >=0.0.1 <4.0.0 and no versions of dio match >3.0.10 <4.0.0, flutter_quill >=1.0.1 is incompatible with dio ^3.0.10.
So, because myapp depends on both dio ^3.0.10 and flutter_quill ^1.0.5, version solving failed.
pub get failed (1; So, because myapp depends on both dio ^3.0.10 and flutter_quill ^1.0.5, version solving failed.)

This is a big problem for me, please help me as soon as possible
Thanks

how to get First image link from QuillEditor ?

Hi, I just want to get the first image link from the data that the user entered in quillEditor. My app stores images in device storage using the path provider package. I printed the data and got this insert⟨ {image: /data/user/0/com.example.notes/app_flutter/image_picker8603960138221828112.jpg} ⟩

but don't know how to get the first image link from this line. is there any idea?

Help | Suggestion

Need to display the document (part say 5 to 6 lines) in listview. Basically want to show some glimpses of the document and then when user clicks on particular row, we will show the full document

Question : Value

What's the best way to get the exact value from QuillEditor then save to firebase or something?

And also, how to display the exact value back from Firebase or some sort of backend?

I am using _controller.document.toPlainText(); and saving only simple string

Add Support for adding custom attributes.

Can we add Custom Attributes without editing the source? custom Attribute does not necessarily mean that it is a styling attribute. it can be a non-styling attribute as well.

Is there any best practice to render the quill to read only on flutter?

Hi, im using flutter-quill for a simple article reading app. I successfully render the quill delta on the flutter with the help of QuillEditor.basic() or setting up the QuillEditor via readOnly parameter.

But somehow, i figure that _getIndentWidth on the EditableTextBlock class always returning 32px left padding. This behaviour resulting in our app to have look like this.
Screen Shot 2021-02-13 at 20 09 26

Is there any way for me to override this behaviour? Or maybe you guys have a way to render the quill delta just for reading purpose?

Thanks.

Error: The non-abstract class 'RawEditorState' is missing implementations for these members:

Stack trace:

Launching lib/main-dev.dart on Google Pixel 3 in debug mode...
../../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_quill-1.0.2/lib/widgets/raw_editor.dart:112:7: Error: The non-abstract class 'RawEditorState' is missing implementations for these members:
 - TextSelectionDelegate.userUpdateTextEditingValue                     
Try to either                                                           
 - provide an implementation,                                           
 - inherit an implementation from a superclass or mixin,                
 - mark the class as abstract, or                                       
 - provide a 'noSuchMethod' implementation.                             
                                                                        
class RawEditorState extends EditorState                                
      ^^^^^^^^^^^^^^                                                    
../../../../flutter/packages/flutter/lib/src/services/text_input.dart:822:8: Context: 'TextSelectionDelegate.userUpdateTextEditingValue' is defined here.
  void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause cause);
       ^^^^^^^^^^^^^^^^^^^^^^^^^^                                       
../../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_quill-1.0.2/lib/widgets/raw_editor.dart:1019:8: Error: The method 'RawEditorState.hideToolbar' has fewer positional arguments than those of overridden method 'TextSelectionDelegate.hideToolbar'.
  void hideToolbar() {                                                  
       ^                                                                
../../../../flutter/packages/flutter/lib/src/services/text_input.dart:829:8: Context: This is the overridden method ('hideToolbar').
  void hideToolbar([bool hideHandles = true]);                          
       ^                                                                
                                                                        
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/home/mehrdad/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1029
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildDevDebug'.           
> Process 'command '/home/mehrdad/flutter/bin/flutter'' finished with non-zero exit value 1
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 1m 45s

pubspec.yml
flutter_quill: ^1.0.2

flutter doctor

▶ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.1.0-11.0.pre.145, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2)
[✓] VS Code (version 1.54.1)
[✓] Connected device (2 available)

• No issues found!


[web] Cursor error when click bold

Hello! I'm using your plugin on web and I found some bug.
v.0.2.2 (last for now).

  1. Type some text. Cursor must be at end of text
  2. Select bold, italic, etc...
    Expected result:
  3. Cursor still at the end and next text become bold, italic, etc
    Actual result:
  4. Cursor move at start of text but next typed text become bold, italic, etc and its position right on the end
  5. And after that there is some strange behaviour about delete some letters, some times delete button delete 2 or more letters...

Screenshot 2021-01-29 at 09 35 49

The method 'findRenderObject' was called on null.

I found another Bug in Flutter-quill.

This is the error message:

I/flutter (32301): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (32301): The following NoSuchMethodError was thrown during a scheduler callback:
I/flutter (32301): The method 'findRenderObject' was called on null.
I/flutter (32301): Receiver: null
I/flutter (32301): Tried calling: findRenderObject()
I/flutter (32301): 
I/flutter (32301): When the exception was thrown, this was the stack:
I/flutter (32301): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
I/flutter (32301): #1      RawEditorState.getRenderEditor (package:flutter_quill/widgets/raw_editor.dart:1001:38)
I/flutter (32301): #2      RawEditorState._showCaretOnScreen.<anonymous closure> (package:flutter_quill/widgets/raw_editor.dart:977:50)
I/flutter (32301): #3      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
I/flutter (32301): #4      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1090:9)
I/flutter (32301): #5      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:998:5)
I/flutter (32301): #9      _invoke (dart:ui/hooks.dart:161:10)
I/flutter (32301): #10     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:253:5)
I/flutter (32301): #11     _drawFrame (dart:ui/hooks.dart:120:31)
I/flutter (32301): (elided 3 frames from dart:async)

I'm not quite sure why this happens - maybe nullsafety (just a guess)? I'm on Flutter Channel beta, 2.0.0, on macOS 11.2.1 20D74 darwin-arm, locale de-DE.

Create the attributeBuilder method

Is it possible to create an attributeBuilder method that works just like embedBuilder? I have the code below, but I can't customize the view

{ "attributes": { "list": "checked" }, "insert": "\n" }, { "attributes": { "list": "unchecked" }, "insert": "\n" }

how to set placeholder?

hello, I don't know how to set placeholder, I don't find document and properties about it

Default keyboard has no auto-correction etc.

Hello!

Can I change the default keyboard type that Flutter Quill is using? It's current one seems quite strange.

The default keyboard doesn't seem to understand the language I'm typing in. In general, I'd expect to see auto-correction etc. as one does when types in a box.

In a Flutter textfield, I can specify a keyboard type to use with keyboardType: TextInputType.text,.

Searching this repo, I don't even find the word "keyboard".

Any advice appreciated!

UX Improvements

There are 3 areas where the UX of editor can be improved :

  1. When checking / unchecking the checkboxes, the text line moves up / down.

  2. Keyboard pops when clicking the heading dropdown button unnecessarily.

  3. Tab button doesn't moves the text to the far right end and stops mid-way.

How to add custom Text Styles, Embed images from device storage?

I am porting my app from Zeyfr Editor to this wonderful plugin and I am stuck with a couple of problems.

1] How can I add custom styles to the text. I looked at QuillStyles() but didn't understand anything.

2] Whenever I open Notus document files (created by Zeyfr) with your package, it shows an error :
Invalid argument (key "heading" not found.): "heading".
Any idea how to fix it?

3] How can I embed images from device storage? My current implementation (not working) is this :

Future<String> uploadImageCallBack(File file) async {
    if (file == null) return null;
    return file.path;
}

Again Thank you for this wonderful package.

Get and set the reading reading position of the editor

What is the best way to get (and then later set again) the current position the user has scrolled to? I have very long texts in my app and when the user starts reading, then closes the app and reopens it later again, the app should have "remembered" the reading progress and automatically scroll to the last position.
So in other words I need something like an index of the current visible part of the text.
Such a thing as the scroll position in pixels is not sufficient, because this would only be correct again on the same device, but e.g. wrong on the other devices of the user (the reading progress will be saved in the cloud in order to allow seamless reading across multiple devices).
An answer would be highly appreciated.

Editor view bounces in 0.3.1

In the new 0.3.1 release, unfortunately, the view always jumps up. Probably it scrolls to the bottom every time a letter is entered. This brings a constant scrolling effect.

RPReplay_Final1614032720.mp4

I think it has to do with the following commit: 471c1cb

In version 0.3.0 the problem does not occur and therefore I went back to this release. So no stress.

Multiple Errors on a new project with latest master for both iOS and Web

I just created a new project using the example from the package in the latest master (1.27.0-5.0.pre.92) and latest version (flutter_quill: ^0.2.12) but I'm getting the following errors (same errors in both iOS and Web):

../../.pub-cache/hosted/pub.dartlang.org/flutter_quill-0.2.12/lib/widgets/raw_editor.dart:110:7: Error: The non-abstract class 'RawEditorState' is missing implementations for these members:
 - TextSelectionDelegate.userUpdateTextEditingValue
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class RawEditorState extends EditorState
      ^^^^^^^^^^^^^^
../../fvm/versions/master/packages/flutter/lib/src/services/text_input.dart:822:8: Context: 'TextSelectionDelegate.userUpdateTextEditingValue' is defined here.
  void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause cause);
       ^^^^^^^^^^^^^^^^^^^^^^^^^^

../../.pub-cache/hosted/pub.dartlang.org/flutter_quill-0.2.12/lib/widgets/text_selection.dart:201:43: Error: Too few positional arguments: 8 required, 7 given.
        child: selectionCtrls.buildToolbar(
                                          ^
../../.pub-cache/hosted/pub.dartlang.org/flutter_quill-0.2.12/lib/widgets/text_line.dart:63:41: Error: No named parameter with the name 'nullOk'.
        Localizations.localeOf(context, nullOk: true),
                                        ^^^^^^
../../fvm/versions/master/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.

  static Locale localeOf(BuildContext context) {
                ^^^^^^^^
Failed to compile application.
Exited (sigterm)

I believe the nullOk error is related to this issue in flutter repo:
flutter/flutter#74519

Bug: setState() called after dispose()

I found a bug when using QuillEditor inside a Stepper-Widget.

I also have a suggestion for fixing: After adding if (!mounted) return; before setState() inside raw_editor.dart in line 904 & 960 the issue did not come up again.

Here is the error message:
E/flutter (24393): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: setState() called after dispose(): RawEditorState#669f3(lifecycle state: defunct, not mounted, tickers: tracking 0 tickers) E/flutter (24393): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter (24393): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter (24393): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). E/flutter (24393): #0 State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1231:9) E/flutter (24393): #1 State.setState (package:flutter/src/widgets/framework.dart:1266:6) E/flutter (24393): #2 RawEditorState._onChangeTextEditingValue (package:flutter_quill/widgets/raw_editor.dart:905:5) E/flutter (24393): #3 RawEditorState.initState.<anonymous closure> (package:flutter_quill/widgets/raw_editor.dart:704:9) E/flutter (24393): #4 _rootRunUnary (dart:async/zone.dart:1362:47) E/flutter (24393): #5 _CustomZone.runUnary (dart:async/zone.dart:1265:19) E/flutter (24393): #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7) E/flutter (24393): #7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11) E/flutter (24393): #8 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) E/flutter (24393): #9 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:25) E/flutter (24393): #10 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5) E/flutter (24393): #11 _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:475:11) E/flutter (24393): #12 _rootRunUnary (dart:async/zone.dart:1362:47) E/flutter (24393): #13 _CustomZone.runUnary (dart:async/zone.dart:1265:19) E/flutter (24393): #14 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7) E/flutter (24393): #15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11) E/flutter (24393): #16 _DelayedData.perform (dart:async/stream_impl.dart:591:14) E/flutter (24393): #17 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11) E/flutter (24393): #18 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7) E/flutter (24393): #19 _rootRun (dart:async/zone.dart:1346:47) E/flutter (24393): #20 _CustomZone.run (dart:async/zone.dart:1258:19) E/flutter (24393): #21 _CustomZone.runGuarded (dart:async/zone.dart:1162:7) E/flutter (24393): #22 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23) E/flutter (24393): #23 _rootRun (dart:async/zone.dart:1354:13) E/flutter (24393): #24 _CustomZone.run (dart:async/zone.dart:1258:19) E/flutter (24393): #25 _CustomZone.runGuarded (dart:async/zone.dart:1162:7) E/flutter (24393): #26 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23) E/flutter (24393): #27 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) E/flutter (24393): #28 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

cursor position error after dynamic insert

My requirement is when user tap enter then auto insert two space. and my code as follows.
when I auto insert space, I expect cursor appear after space but now it appear before space
May be my code is wrong. please give me some suggestion Thank you.

I wish you can provide more examples.

@OverRide
void initState() {
this._controller.addListener(() {
this._controller.changes.first.then((value) {
if (value.item2.length >= 2 &&
value.item2[1].isInsert &&
value.item2[1].data == "\n") {
final index = this._controller.selection.baseOffset;
this._controller.document.insert(index, "  ");
}
});
});
}

type 'double' is not a subtype of type 'int'

Operation next([num length = double.infinity]) {
    assert(length != null);

    if (_modificationCount != delta._modificationCount) {
      throw ConcurrentModificationError(delta);
    }

    if (_index < delta.length) {
      final op = delta.elementAt(_index);
      final opKey = op.key;
      final opAttributes = op.attributes;
      final _currentOffset = _offset;
      final actualLength = math.min(op.length - _currentOffset, length);
      if (actualLength == op.length - _currentOffset) {
        _index++;
        _offset = 0;
      } else {
        _offset += actualLength;
      }
      final opData = op.isInsert && op.data is String
          ? (op.data as String)
              .substring(_currentOffset, _currentOffset + actualLength)
          : op.data;
      final opIsNotEmpty =
          opData is String ? opData.isNotEmpty : true; // embeds are never empty
      final opLength = opData is String ? opData.length : 1;
      final int opActualLength = opIsNotEmpty ? opLength : actualLength;
      return Operation._(opKey, opActualLength, opData, opAttributes);
    }
    return Operation.retain(length);
  }

next([num length = double.infinity]) length default is a double
but Operation.retain need a int

And assert(length != null); is useless

Support conversion of Delta to HTML and Markdown

This Library converts Zeyfr documents to HTML.
There are many plugins that can help with the conversion of HTML to markdown. I was thinking that with some tweaking we can create our own converter too.

Or we can take another approach, we can first convert Delta to markdown like here and then to HTML.
Again, this requires just some minor tweaking.

List items cut off before text is added

Hi,

I'm enjoying using this library so far - great work. I did spot a small bug when adding new lines. The screenshot sums it up - when adding a new line in a list item, the leading indicators (e.g. 1., 2.) are cut off vertically before text is added. When text is added, they are no longer cut off.

Simulator Screen Shot - iPhone 12 Pro Max - 2021-02-27 at 13 48 13

Simulator Screen Shot - iPhone 12 Pro Max - 2021-02-27 at 13 49 52

Null safety

Hi ! I'm hoping this issue can be used to follow updates on nullsafety. Currently, there are still several dependencies that are not migrated and might be considered blocking.

dart pub outdated --mode=null-safety

Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
[✓] indicates versions opting in to null safety.

Package Name                 Current    Upgradable  Resolvable           Latest               

direct dependencies:        
file_picker                  ✗2.1.6     ✗2.1.6      ✓3.0.0-nullsafety.2  ✓3.0.0-nullsafety.2  
flutter_colorpicker          ✗0.3.5     ✗0.3.5      ✓0.4.0-nullsafety.0  ✓0.4.0-nullsafety.0  
flutter_keyboard_visibility  ✗4.0.4     ✗4.0.4      ✓5.0.0-nullsafety.2  ✓5.0.0-nullsafety.2  
image_picker                 ✗0.6.7+22  ✗0.6.7+22   ✓0.7.0               ✓0.7.0               
photo_view                   ✗0.10.3    ✗0.10.3     ✗0.10.3              ✗0.10.3              
quill_delta                  ✗2.0.0     ✗2.0.0      ✗2.0.0               ✗2.0.0               
quiver_hashcode              ✗2.0.0     ✗2.0.0      ✗2.0.0               ✗2.0.0               
string_validator             ✗0.1.4     ✗0.1.4      ✓0.2.0-nullsafety.0  ✓0.2.0-nullsafety.0  
tuple                        ✗1.0.3     ✗1.0.3      ✓2.0.0-nullsafety.0  ✓2.0.0-nullsafety.0  
universal_html               ✗1.2.4     ✗1.2.4      ✗1.2.4               ✗1.2.4               
url_launcher                 ✗5.7.10    ✗5.7.10     ✓6.0.0               ✓6.0.0               

7  dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.

quill_delta has a active pull request for null safety here. photo_view also has an active pr for null safety. As for quiver_hashcode, here is a comment that says people should instead rely on quiver instead which is already migrated to null safety. This just leaves universal_html without an active PR.

Edit

With quill_delta removed that leaves just:

  • photo_view
  • quiver_hashcode -> quiver
  • universal_html

[web] Some problems and weird effect on editing text

Hi, @singerdmx I give it a quick test and found some problems.

  1. The backspace is not working as intended, it is deleting two characters at a time.

demo1

  1. When typing and deleting the character several times the "enter" key to the new line will not trigger the first time and will go two lines in the second trigger. The backspace of going back a line will go back two lines at a time.

demo2

  1. When mixing typing and deleting the character several times, the typing functionality will also not trigger the first time and will output two characters the second time. See the "rrrr" part at the end.

demo3

  1. Changing text heading is not working as intended.

demo4

  1. Does add a check box to the numbered line replace the number or add the check box after the number? Seems to add after the number works more logically (just my personal thoughts)?

demo5

  1. Maybe adding a check box should disable some of the functionalities. For example, code block ...etc, cause it will cause some weird effect. Below are some demos.

demo6

demo7

  1. Selecting of character through the cursor works fine. However, through keyboard "Shift+left arrow" is not working. Shift+right arrow is working.

demo8

Above are some problems I encounter after testing on the web application. Thank you for the hard work and make the package better!

Ken

The _keyboardVisibilityController.onChange.listen should be close in dispose

使用push和pop二次(以及多次)打开编辑器后,会报错,_keyboardVisibilityController.onChange.listen回调会被调用多次,被调用的次数和编辑器打开的次数一致,在dispose中释放掉监听报错消失。

报错:

[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: setState() called after dispose(): RawEditorState#c3ee0(lifecycle state: defunct, not mounted, tickers: tracking 0 tickers)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
#0      State.setState.<anonymous closure>
package:flutter/…/widgets/framework.dart:1208
#1      State.setState
package:flutter/…/widgets/framework.dart:1243
#2      RawEditorState._onChangeTextEditingValue
package:flutter_quill/widgets/raw_editor.dart:910
#3      RawEditorState.initState.<anonymous closure>
package:flutter_quill/widgets/raw_editor.dart:708
#4      _rootRunUnary (dart:async/zone.dart:1198:47)

改动:lib/widgets/raw_deitor.dart

StreamSubscription<bool> _keyboardVisibilitySubscription;
//initState()中
_keyboardVisibilityController = KeyboardVisibilityController();
    _keyboardVisibilitySubscription =
        _keyboardVisibilityController.onChange.listen((bool visible) {
      _keyboardVisible = visible;
      if (visible) {
        _onChangeTextEditingValue();
      }
    });
@override
  void dispose() {
    closeConnectionIfNeeded();
    _keyboardVisibilitySubscription.cancel();
....

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.