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: blockquote

Vincent Chan81d4c8d23bc7
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 0f8578b5c7..5963d5955d 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
@@ -24,6 +24,7 @@ const String tagDel = "del";
const String tagStrong = "strong";
const String tagSpan = "span";
const String tagCode = "code";
+const String tagBlockQuote = "blockquote";
extension on Color {
String toRgbaString() {
@@ -70,6 +71,8 @@ class HTMLToNodesConverter {
} else {
result.add(_handleRichText(child));
}
+ } else if (child.localName == tagBlockQuote) {
+ result.addAll(_handleBlockQuote(child));
} else {
result.addAll(_handleElement(child));
}
@@ -83,6 +86,18 @@ class HTMLToNodesConverter {
return result;
}
+ List<Node> _handleBlockQuote(html.Element element) {
+ final result = <Node>[];
+
+ for (final child in element.nodes.toList()) {
+ if (child is html.Element) {
+ result.addAll(_handleElement(child, {"subtype": "quote"}));
+ }
+ }
+
+ return result;
+ }
+
List<Node> _handleBTag(html.Element element) {
final childNodes = element.nodes;
return _handleContainer(childNodes);
@@ -527,6 +542,8 @@ class NodesToHTMLConverter {
} else if (heading == StyleKey.h3) {
tagName = tagH3;
}
+ } else if (subType == StyleKey.quote) {
+ tagName = tagBlockQuote;
}
for (final op in delta) {
@@ -567,10 +584,19 @@ class NodesToHTMLConverter {
}
}
- if (tagName != tagParagraph &&
+ if (tagName == tagBlockQuote) {
+ final p = html.Element.tag(tagParagraph);
+ for (final node in childNodes) {
+ p.append(node);
+ }
+ final blockQuote = html.Element.tag(tagName);
+ blockQuote.append(p);
+ return blockQuote;
+ } else if (tagName != tagParagraph &&
tagName != tagH1 &&
tagName != tagH2 &&
- tagName != tagH3) {
+ tagName != tagH3 &&
+ tagName != tagBlockQuote) {
final p = html.Element.tag(tagParagraph);
for (final node in childNodes) {
p.append(node);