moly_kit/widgets/
message_markdown.rs

1use makepad_widgets::*;
2script_mod! {
3    use mod.prelude.widgets.*
4    use mod.widgets.*
5
6    mod.widgets.MessageMarkdown = Markdown {
7        padding: 0
8        margin: 0
9        paragraph_spacing: 16
10        heading_base_scale: 1.6
11
12        font_color: #000
13        width: Fill, height: Fit
14        font_size: 11.0
15        code_block := View {
16            width: Fill
17            height: Fit
18            flow: Down
19            RoundedView {
20                draw_bg +: {
21                    border_radius: 0.0
22                    border_size: 1.2
23                    border_color: #1d2330
24                }
25                width: Fill
26                height: Fit
27                align: Align { x: 1.0 }
28
29                copy_code_button := ButtonFlat {
30                    margin: Inset { right: 2 }
31                    draw_bg +: {
32                        border_size: 0.0
33                    }
34                    icon_walk +: { width: 12, height: Fit, margin: Inset { left: 10 } }
35                    draw_icon +: {
36                        color: #x0
37                        color_hover: #3c3c3c
38                        color_down: #x0
39                        color_focus: #x0
40                        svg: crate_resource("self://resources/copy.svg")
41                    }
42                }
43            }
44            code_view := CodeView {
45                editor +: {
46                    margin: Inset { top: -2, bottom: 2 }
47                    pad_left_top: vec2(10.0 10.0)
48                    width: Fill
49                    height: Fit
50                    draw_bg +: { color: #1d2330 }
51                    draw_text +: {
52                        text_style +: {
53                            font_size: 10
54                        }
55                    }
56
57                    token_colors +: {
58                        whitespace: #xa8b5d1
59                        delimiter: #xa8b5d1
60                        delimiter_highlight: #xc5cee0
61                        error_decoration: #f44747
62                        warning_decoration: #cd9731
63
64                        unknown: #xa8b5d1
65                        branch_keyword: #xd2a6ef
66                        constant: #ffd9af
67                        identifier: #xa8b5d1
68                        loop_keyword: #xd2a6ef
69                        number: #ffd9af
70                        other_keyword: #xd2a6ef
71                        punctuator: #xa8b5d1
72                        string: #x58ffc7
73                        function: #x82aaff
74                        typename: #xfcf9c3
75                        comment: #x506686
76                    }
77                }
78            }
79        }
80        use_code_block_widget: true
81
82        use_math_widget: true
83        inline_math := MathView {
84            color: #000
85            font_size: 11.0
86        }
87        display_math := MathView {
88            color: #000
89            font_size: 11.0
90        }
91
92        list_item_layout: Layout { padding: Inset { left: 10.0, right: 10, top: 6.0, bottom: 0 } }
93        list_item_walk: Walk { margin: 0, height: Fit, width: Fill }
94        code_layout: Layout { padding: Inset { top: 10.0, bottom: 10.0 } }
95        quote_layout: Layout { padding: Inset { top: 10.0, bottom: 10.0 } }
96
97        link +: {
98            padding: Inset { top: 1, bottom: 0 }
99            draw_text +: {
100                color: #00f
101                color_pressed: #f00
102                color_hover: #0f0
103            }
104        }
105
106        text_style_normal +: {
107            line_spacing: 1.5
108        }
109        text_style_italic +: {
110            line_spacing: 1.5
111        }
112        text_style_bold +: {
113            line_spacing: 1.5
114        }
115        text_style_bold_italic +: {
116            line_spacing: 1.5
117        }
118        text_style_fixed +: {
119            line_spacing: 1.5
120        }
121        draw_block +: {
122            line_color: #000
123            sep_color: #xEDEDED
124            quote_bg_color: #xEDEDED
125            quote_fg_color: #x969696
126            code_color: #xEDEDED
127        }
128    }
129}