From d51a372d316f04a737a068fde60d0b9fce8aa303 Mon Sep 17 00:00:00 2001 From: bschmalb Date: Wed, 26 Jun 2024 15:22:32 +0200 Subject: [PATCH] feat: bump flutter_quill to 9.4.6, sdk to 3.1.0 < 4.0.0 and fix errors --- lib/src/delta_markdown_decoder.dart | 20 +++++++++++--------- lib/src/delta_markdown_encoder.dart | 14 ++++++-------- pubspec.yaml | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/src/delta_markdown_decoder.dart b/lib/src/delta_markdown_decoder.dart index bbaed8d9..e2d42188 100644 --- a/lib/src/delta_markdown_decoder.dart +++ b/lib/src/delta_markdown_decoder.dart @@ -1,8 +1,8 @@ import 'dart:collection'; import 'dart:convert'; -import 'package:flutter_quill/flutter_quill.dart' - show Attribute, AttributeScope, Delta, LinkAttribute; +import 'package:flutter_quill/flutter_quill.dart' show Attribute, AttributeScope, LinkAttribute; +import 'package:flutter_quill/quill_delta.dart' show Delta; import 'ast.dart' as ast; import 'document.dart'; @@ -19,8 +19,7 @@ class DeltaMarkdownDecoder extends Converter { } class _DeltaVisitor implements ast.NodeVisitor { - static final _blockTags = - RegExp('h1|h2|h3|h4|h5|h6|hr|pre|ul|ol|blockquote|p|pre'); + static final _blockTags = RegExp('h1|h2|h3|h4|h5|h6|hr|pre|ul|ol|blockquote|p|pre'); static final _embedTags = RegExp('hr|img'); @@ -174,9 +173,7 @@ class _DeltaVisitor implements ast.NodeVisitor { @override void visitElementAfter(ast.Element element) { - if (element.tag == 'li' && - (previousToplevelElement.tag == 'ol' || - previousToplevelElement.tag == 'ul')) { + if (element.tag == 'li' && (previousToplevelElement.tag == 'ol' || previousToplevelElement.tag == 'ul')) { delta.insert('\n', activeBlockAttribute?.toJson()); } @@ -247,9 +244,14 @@ class _DeltaVisitor implements ast.NodeVisitor { } class ImageAttribute extends Attribute { - ImageAttribute(String? val) : super('image', AttributeScope.EMBEDS, val); + const ImageAttribute(String? val) + : super( + 'image', + AttributeScope.embeds, + val, + ); } class DividerAttribute extends Attribute { - DividerAttribute() : super('divider', AttributeScope.EMBEDS, 'hr'); + const DividerAttribute() : super('divider', AttributeScope.embeds, 'hr'); } diff --git a/lib/src/delta_markdown_encoder.dart b/lib/src/delta_markdown_encoder.dart index e771f54b..88d0f41e 100644 --- a/lib/src/delta_markdown_encoder.dart +++ b/lib/src/delta_markdown_encoder.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter_quill/flutter_quill.dart' show Attribute, AttributeScope, BlockEmbed, Delta, DeltaIterator, Style; +import 'package:flutter_quill/quill_delta.dart'; class DeltaMarkdownEncoder extends Converter { static const _lineFeedAsciiCode = 0x0A; @@ -63,10 +64,9 @@ class DeltaMarkdownEncoder extends Converter { // First close any current styles if needed final markedForRemoval = []; // Close the styles in reverse order, e.g. **_ for _**Test**_. - for (final value - in currentInlineStyle.attributes.values.toList().reversed) { + for (final value in currentInlineStyle.attributes.values.toList().reversed) { // TODO(tillf): Is block correct? - if (value.scope == AttributeScope.BLOCK) { + if (value.scope == AttributeScope.block) { continue; } if (style.containsKey(value.key)) { @@ -89,7 +89,7 @@ class DeltaMarkdownEncoder extends Converter { // Now open any new styles. for (final attribute in style.attributes.values) { // TODO(tillf): Is block correct? - if (attribute.scope == AttributeScope.BLOCK) { + if (attribute.scope == AttributeScope.block) { continue; } if (currentInlineStyle.containsKey(attribute.key)) { @@ -121,10 +121,8 @@ class DeltaMarkdownEncoder extends Converter { // Close any open inline styles. _handleInline(lineBuffer, '', null); - final lineBlock = Style.fromJson(attributes) - .attributes - .values - .singleWhereOrNull((a) => a.scope == AttributeScope.BLOCK); + final lineBlock = + Style.fromJson(attributes).attributes.values.singleWhereOrNull((a) => a.scope == AttributeScope.block); if (lineBlock == currentBlockStyle) { currentBlockLines.add(lineBuffer.toString()); diff --git a/pubspec.yaml b/pubspec.yaml index c7ccc86d..11dd8ecb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,13 +6,13 @@ description: A library for converting between Markdown and Delta of the homepage: https://github.com/friebetill/notus_markdown environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=3.1.0 <4.0.0" dependencies: args: ^2.0.0 charcode: ^1.2.0 collection: ^1.15.0 - flutter_quill: ^7.0.0 + flutter_quill: ^9.4.6 dev_dependencies: build_runner: ^2.0.0