mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: blockquote
This commit is contained in:
parent
8c2cca7d7b
commit
81d4c8d23b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user