Skip to content

Commit 53a5cef

Browse files
feat: support style attributes on inline elements (like <strong>)
1 parent bcf4634 commit 53a5cef

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/parser/html_to_operation.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import 'package:dart_quill_delta/dart_quill_delta.dart';
22
import 'package:flutter_quill_delta_from_html/parser/extensions/node_ext.dart';
33
import 'package:flutter_quill_delta_from_html/parser/html_utils.dart';
4+
import 'package:flutter_quill_delta_from_html/parser/node_processor.dart';
45
import 'package:html/dom.dart' as dom;
6+
57
import 'custom_html_part.dart';
6-
import 'package:flutter_quill_delta_from_html/parser/node_processor.dart';
78

89
/// Operations for converting supported HTML elements to Delta operations.
910
///
@@ -44,6 +45,16 @@ abstract class HtmlOperations {
4445
if (element.isStrike) attributes['strike'] = true;
4546
if (element.isSubscript) attributes['script'] = 'sub';
4647
if (element.isSuperscript) attributes['script'] = 'super';
48+
if (element.attributes.containsKey('style')) {
49+
final styleAttributes = parseStyleAttribute(
50+
element.localName!,
51+
element.attributes['style']!,
52+
);
53+
if (styleAttributes.containsKey('align')) {
54+
styleAttributes.remove('align');
55+
}
56+
attributes.addAll(styleAttributes);
57+
}
4758
for (final node in element.nodes) {
4859
processNode(node, attributes, delta, customBlocks: customBlocks);
4960
}

0 commit comments

Comments
 (0)