-
-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support inline code blocks on markdown rich text
- Loading branch information
1 parent
7c40034
commit 5bd5f15
Showing
6 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flame/src/text/nodes/inline_text_node.dart'; | ||
import 'package:flame/text.dart'; | ||
|
||
class CodeTextNode extends InlineTextNode { | ||
CodeTextNode(this.child); | ||
|
||
CodeTextNode.simple(String text) : child = PlainTextNode(text); | ||
|
||
CodeTextNode.group(List<InlineTextNode> children) | ||
: child = GroupTextNode(children); | ||
|
||
final InlineTextNode child; | ||
|
||
static final defaultStyle = InlineTextStyle(fontFamily: 'monospace'); | ||
|
||
@override | ||
void fillStyles(DocumentStyle stylesheet, InlineTextStyle parentTextStyle) { | ||
style = FlameTextStyle.merge(parentTextStyle, stylesheet.codeText)!; | ||
child.fillStyles(stylesheet, style); | ||
} | ||
|
||
@override | ||
TextNodeLayoutBuilder get layoutBuilder => child.layoutBuilder; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters