Skip to content

Commit e426aa5

Browse files
committed
fix: copy link and code style
1 parent ceb309a commit e426aa5

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

frontend/app_flowy/packages/appflowy_editor/lib/src/infra/html_converter.dart

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ class HTMLToNodesConverter {
241241
} else if (element.localName == HTMLTag.del) {
242242
delta.insert(element.text,
243243
attributes: {BuiltInAttributeKey.strikethrough: true});
244+
} else if (element.localName == HTMLTag.code) {
245+
delta.insert(element.text, attributes: {BuiltInAttributeKey.code: true});
244246
} else {
245247
delta.insert(element.text);
246248
}
@@ -276,11 +278,13 @@ class HTMLToNodesConverter {
276278
}
277279
}
278280

279-
final textNode = TextNode(delta: delta, attributes: attributes);
280-
if (isCheckbox) {
281-
textNode.attributes["subtype"] = BuiltInAttributeKey.checkbox;
282-
textNode.attributes["checkbox"] = checked;
283-
}
281+
final textNode = TextNode(delta: delta, attributes: {
282+
if (attributes != null) ...attributes,
283+
if (isCheckbox) ...{
284+
BuiltInAttributeKey.subtype: BuiltInAttributeKey.checkbox,
285+
BuiltInAttributeKey.checkbox: checked,
286+
}
287+
});
284288
return textNode;
285289
}
286290

@@ -557,6 +561,17 @@ class NodesToHTMLConverter {
557561
final strong = html.Element.tag(HTMLTag.del);
558562
strong.append(html.Text(op.text));
559563
childNodes.add(strong);
564+
} else if (attributes.length == 1 &&
565+
attributes[BuiltInAttributeKey.code] == true) {
566+
final code = html.Element.tag(HTMLTag.code);
567+
code.append(html.Text(op.text));
568+
childNodes.add(code);
569+
} else if (attributes.length == 1 &&
570+
attributes[BuiltInAttributeKey.href] != null) {
571+
final anchor = html.Element.tag(HTMLTag.anchor);
572+
anchor.attributes["href"] = attributes[BuiltInAttributeKey.href];
573+
anchor.append(html.Text(op.text));
574+
childNodes.add(anchor);
560575
} else {
561576
final span = html.Element.tag(HTMLTag.span);
562577
final cssString = _attributesToCssStyle(attributes);

0 commit comments

Comments
 (0)