|
@@ -159,10 +159,8 @@ class HTMLToNodesConverter {
|
|
}
|
|
}
|
|
|
|
|
|
final textDecorationStr = cssMap["text-decoration"];
|
|
final textDecorationStr = cssMap["text-decoration"];
|
|
- if (textDecorationStr == "line-through") {
|
|
|
|
- attrs[StyleKey.strikethrough] = true;
|
|
|
|
- } else if (textDecorationStr == "underline") {
|
|
|
|
- attrs[StyleKey.underline] = true;
|
|
|
|
|
|
+ if (textDecorationStr != null) {
|
|
|
|
+ _assignTextDecorations(attrs, textDecorationStr);
|
|
}
|
|
}
|
|
|
|
|
|
final backgroundColorStr = cssMap["background-color"];
|
|
final backgroundColorStr = cssMap["background-color"];
|
|
@@ -179,6 +177,17 @@ class HTMLToNodesConverter {
|
|
return attrs.isEmpty ? null : attrs;
|
|
return attrs.isEmpty ? null : attrs;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ _assignTextDecorations(Attributes attrs, String decorationStr) {
|
|
|
|
+ final decorations = decorationStr.split(" ");
|
|
|
|
+ for (final d in decorations) {
|
|
|
|
+ if (d == "line-through") {
|
|
|
|
+ attrs[StyleKey.strikethrough] = true;
|
|
|
|
+ } else if (d == "underline") {
|
|
|
|
+ attrs[StyleKey.underline] = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// Try to parse the `rgba(red, greed, blue, alpha)`
|
|
/// Try to parse the `rgba(red, greed, blue, alpha)`
|
|
/// from the string.
|
|
/// from the string.
|
|
Color? _tryParseCssColorString(String? colorString) {
|
|
Color? _tryParseCssColorString(String? colorString) {
|
|
@@ -424,6 +433,18 @@ class NodesToHTMLConverter {
|
|
checked: textNode.attributes["checkbox"] == true);
|
|
checked: textNode.attributes["checkbox"] == true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ String _textDecorationsFromAttributes(Attributes attributes) {
|
|
|
|
+ var textDecoration = <String>[];
|
|
|
|
+ if (attributes[StyleKey.strikethrough] == true) {
|
|
|
|
+ textDecoration.add("line-through");
|
|
|
|
+ }
|
|
|
|
+ if (attributes[StyleKey.underline] == true) {
|
|
|
|
+ textDecoration.add("underline");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return textDecoration.join(" ");
|
|
|
|
+ }
|
|
|
|
+
|
|
String _attributesToCssStyle(Map<String, dynamic> attributes) {
|
|
String _attributesToCssStyle(Map<String, dynamic> attributes) {
|
|
final cssMap = <String, String>{};
|
|
final cssMap = <String, String>{};
|
|
if (attributes[StyleKey.backgroundColor] != null) {
|
|
if (attributes[StyleKey.backgroundColor] != null) {
|
|
@@ -441,12 +462,12 @@ class NodesToHTMLConverter {
|
|
if (attributes[StyleKey.bold] == true) {
|
|
if (attributes[StyleKey.bold] == true) {
|
|
cssMap["font-weight"] = "bold";
|
|
cssMap["font-weight"] = "bold";
|
|
}
|
|
}
|
|
- if (attributes[StyleKey.strikethrough] == true) {
|
|
|
|
- cssMap["text-decoration"] = "line-through";
|
|
|
|
- }
|
|
|
|
- if (attributes[StyleKey.underline] == true) {
|
|
|
|
- cssMap["text-decoration"] = "underline";
|
|
|
|
|
|
+
|
|
|
|
+ final textDecoration = _textDecorationsFromAttributes(attributes);
|
|
|
|
+ if (textDecoration.isNotEmpty) {
|
|
|
|
+ cssMap["text-decoration"] = textDecoration;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (attributes[StyleKey.italic] == true) {
|
|
if (attributes[StyleKey.italic] == true) {
|
|
cssMap["font-style"] = "italic";
|
|
cssMap["font-style"] = "italic";
|
|
}
|
|
}
|