Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

feat: italic

Vincent Chan690ec5cc94c0
diff --git a/frontend/app_flowy/packages/flowy_editor/lib/src/infra/html_converter.dart b/frontend/app_flowy/packages/flowy_editor/lib/src/infra/html_converter.dart
index 2ec4bd382e..f5f37f4c4e 100644
--- a/frontend/app_flowy/packages/flowy_editor/lib/src/infra/html_converter.dart
+++ b/frontend/app_flowy/packages/flowy_editor/lib/src/infra/html_converter.dart
@@ -17,6 +17,7 @@ const String tagList = "li";
const String tagParagraph = "p";
const String tagImage = "img";
const String tagAnchor = "a";
+const String tagItalic = "i";
const String tagBold = "b";
const String tagUnderline = "u";
const String tagStrong = "strong";
@@ -56,7 +57,8 @@ class HTMLToNodesConverter {
child.localName == tagSpan ||
child.localName == tagCode ||
child.localName == tagStrong ||
- child.localName == tagUnderline) {
+ child.localName == tagUnderline ||
+ child.localName == tagItalic) {
_handleRichTextElement(delta, child);
} else if (child.localName == tagBold) {
// Google docs wraps the the content inside the `<b></b>` tag.
@@ -207,6 +209,8 @@ class HTMLToNodesConverter {
delta.insert(element.text, {"bold": true});
} else if (element.localName == tagUnderline) {
delta.insert(element.text, {"underline": true});
+ } else if (element.localName == tagItalic) {
+ delta.insert(element.text, {"italic": true});
} else {
delta.insert(element.text);
}
@@ -463,6 +467,11 @@ class NodesToHTMLConverter {
final strong = html.Element.tag(tagUnderline);
strong.append(html.Text(op.content));
childNodes.add(strong);
+ } else if (attributes.length == 1 &&
+ attributes[StyleKey.italic] == true) {
+ final strong = html.Element.tag(tagItalic);
+ strong.append(html.Text(op.content));
+ childNodes.add(strong);
} else {
final span = html.Element.tag(tagSpan);
final cssString = _attributesToCssStyle(attributes);