From 690ec5cc94c08070414090f606426d10f1627b64 Mon Sep 17 00:00:00 2001 From: Vincent Chan Date: Fri, 12 Aug 2022 15:29:12 +0800 Subject: [PATCH] feat: italic --- .../flowy_editor/lib/src/infra/html_converter.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 `` 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);