singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.58k stars 829 forks source link

If div in html - html to quill won't render anything #1994

Closed HeropolisDa2ny closed 3 months ago

HeropolisDa2ny commented 3 months ago

Is there an existing issue for this?

Flutter Quill version

flutter_quill: ^9.5.12 quill_html_converter: ^9.5.12 flutter_quill_extensions: ^9.5.12

Steps to reproduce

  1. Init the controller : final QuillController _controller = QuillController.basic();
  2. Init the document controller :
    _controller.document = Document.fromDelta(
        Document.fromHtml('<html><body><div>Name : Test</div></body></html>')
            .toDelta());
  3. log(_controller.document.isEmpty().toString());
  4. Result: true

If we remove the div from the HTML it works fine. (but I need the divs)

Expected results

Screenshot 2024-07-09 at 9 34 01

Actual results

Screenshot 2024-07-09 at 9 34 08

Code sample

Code sample ```dart final QuillController _controller = QuillController.basic( configurations: QuillControllerConfigurations(), ); @override void initState() { _controller.document = Document.fromDelta( Document.fromHtml('
Name : Test
').toDelta(), ); _controller.readOnly = false; log(_controller.document.toPlainText().toString()); super.initState(); } @override Widget build(BuildContext context) { return QuillEditor.basic( configurations: QuillEditorConfigurations( controller: _controller, enableScribble: false, enableInteractiveSelection: false, sharedConfigurations: QuillSharedConfigurations( locale: Locale(Localizations.localeOf(context).languageCode), ), embedBuilders: kIsWeb ? FlutterQuillEmbeds.editorWebBuilders() : FlutterQuillEmbeds.editorBuilders(), ), ); } ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```
CatHood0 commented 3 months ago

@HeropolisDa2ny this isn't directly related with the package. The issue comes from flutter_quill_delta_from_html that not support <div> tags. At this moment there is a opened issue related with <div> and HTML elements wrapped within it issue

CatHood0 commented 3 months ago

I already made a PR to resolve this