From cc22e00d6f69ae407e4b512a7e80d8409d2053b0 Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 10 Jul 2024 12:34:13 +0300 Subject: [PATCH] chore: drop the support for DeltaX.fromHtml and DeltaX.fromMarkdown and will be only used internally --- lib/src/models/documents/delta_x.dart | 12 ++++++++++++ lib/src/models/documents/document.dart | 6 ++++++ lib/src/widgets/quill/quill_controller.dart | 2 ++ test/utils/delta_x_test.dart | 2 ++ 4 files changed, 22 insertions(+) diff --git a/lib/src/models/documents/delta_x.dart b/lib/src/models/documents/delta_x.dart index d30e3f4d..c2609273 100644 --- a/lib/src/models/documents/delta_x.dart +++ b/lib/src/models/documents/delta_x.dart @@ -14,6 +14,12 @@ class DeltaX { /// This api is **experimental** and designed to be used **internally** and shouldn't /// used for **production applications**. @experimental + @Deprecated( + ''' + The experimental support for Markdown conversion has been dropped and will be removed in future releases, + consider using alternatives such as https://pub.dev/packages/markdown_quill + ''', + ) static Delta fromMarkdown(String markdownText) { final mdDocument = md.Document(encodeHtml: false); final mdToDelta = MarkdownToDelta(markdownDocument: mdDocument); @@ -22,6 +28,12 @@ class DeltaX { /// Convert the HTML Raw string to [Delta] @experimental + @Deprecated( + ''' + The experimental support for HTML conversion has been dropped and will be removed in future releases, + consider using alternatives such as https://pub.dev/packages/flutter_quill_delta_from_html + ''', + ) static Delta fromHtml(String htmlText, {List? customBlocks}) { final htmlToDelta = HtmlToDelta(customBlocks: customBlocks); return htmlToDelta.convert(htmlText); diff --git a/lib/src/models/documents/document.dart b/lib/src/models/documents/document.dart index 95036ca1..c20ab27d 100644 --- a/lib/src/models/documents/document.dart +++ b/lib/src/models/documents/document.dart @@ -480,6 +480,12 @@ class Document { /// Convert the HTML Raw string to [Document] @experimental + @Deprecated( + ''' + The experimental support for HTML conversion has been dropped and will be removed in future releases, + consider using alternatives such as https://pub.dev/packages/flutter_quill_delta_from_html + ''', + ) static Document fromHtml(String html) { return Document.fromDelta(DeltaX.fromHtml(html)); } diff --git a/lib/src/widgets/quill/quill_controller.dart b/lib/src/widgets/quill/quill_controller.dart index 33e11c20..bf21c8f4 100644 --- a/lib/src/widgets/quill/quill_controller.dart +++ b/lib/src/widgets/quill/quill_controller.dart @@ -583,6 +583,7 @@ class QuillController extends ChangeNotifier { final htmlText = await getHTML(); if (htmlText != null) { final htmlBody = html_parser.parse(htmlText).body?.outerHtml; + // ignore: deprecated_member_use_from_same_package final deltaFromClipboard = DeltaX.fromHtml(htmlBody ?? htmlText); _pasteUsingDelta(deltaFromClipboard); @@ -608,6 +609,7 @@ class QuillController extends ChangeNotifier { final markdownText = await getMarkdown(); if (markdownText != null) { + // ignore: deprecated_member_use_from_same_package final deltaFromClipboard = DeltaX.fromMarkdown(markdownText); _pasteUsingDelta(deltaFromClipboard); diff --git a/test/utils/delta_x_test.dart b/test/utils/delta_x_test.dart index e4367da8..cf867df3 100644 --- a/test/utils/delta_x_test.dart +++ b/test/utils/delta_x_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use_from_same_package + import 'package:flutter_quill/quill_delta.dart'; import 'package:flutter_quill/src/models/documents/delta_x.dart'; import 'package:test/test.dart';