Anandu c s
Anandu c s

Reputation: 73

Is there a way to convert FlutterQuill to HTML content?

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

Do we have a Dart plugin for converting FlutterQuill to HTML content?

Upvotes: 6

Views: 6357

Answers (2)

David Sedlář
David Sedlář

Reputation: 777

Recently there was an issue in their GitHub account and someone found a workaround via Markdown.

But keep in mind that it is not entirely correct yet and as far as I know there isn't any straightforward conversion into HTML yet.

Another thing you can try is to create a fork of the zefyr HTML editor, use their Delta converter, and update it to work with Quill deltas. I tried that for myself. It worked in simple cases, but in our project there were harder cases, so we ditched this solution.

Upvotes: 5

BLKKKBVSIK
BLKKKBVSIK

Reputation: 3566

Using packages delta_markdown and markdown:

You may want to convert your delta to HTML with a method like so:

import 'dart:convert';

import 'package:delta_markdown/delta_markdown.dart';
import 'package:flutter_quill/models/quill_delta.dart';
import 'package:markdown/markdown.dart';

String quillDeltaToHtml(Delta delta) {
  final convertedValue = jsonEncode(delta.toJson());
  final markdown = deltaToMarkdown(convertedValue);
  final html = markdownToHtml(markdown);

  return html;
}

You can learn an alternative solution that needs to be implemented in FlutterQuill on this issue: Support conversion of Delta to HTML and Markdown #15

Upvotes: 4

Related Questions