-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathRenderMarkdown.ts
More file actions
106 lines (90 loc) · 2.86 KB
/
RenderMarkdown.ts
File metadata and controls
106 lines (90 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import CSSTokens from '../CSSTokens';
import { FORCED_COLORS_SELECTOR, NOT_FORCED_COLORS_SELECTOR } from './Constants';
// This style is for accompanying result of `renderMarkdown()`.
// Mostly, it should only styles elements that are generated/modified during `renderMarkdown()`.
// For example, "open in new window" icon, which is done by `betterLink`.
export default function createMarkdownStyle() {
return {
'&.webchat__render-markdown': {
display: 'contents',
// Copied from Adaptive Cards inline styling.
'&.webchat__render-markdown--adaptive-cards > *:first-child': {
marginTop: 0,
width: '100%',
overflow: 'hidden',
textOverflow: 'ellipsis'
},
// Copied from Adaptive Cards inline styling.
'&.webchat__render-markdown--adaptive-cards > *:last-child': {
marginBottom: 0
},
'&.webchat__render-markdown--message-activity > *:first-child': {
marginTop: 0
},
'&.webchat__render-markdown--message-activity > *:last-child': {
marginBottom: 0
},
'& .webchat__render-markdown__external-link-icon': {
backgroundImage: CSSTokens.IconURLExternalLink,
height: '.75em',
marginLeft: '.25em'
},
'& .webchat__render-markdown__citation': {
background: 'transparent',
border: 0,
cursor: 'pointer',
display: 'inline-block',
fontFamily: 'unset',
fontSize: 'unset',
overflow: 'hidden',
padding: 0,
textDecoration: 'underline',
textOverflow: 'ellipsis',
verticalAlign: 'bottom',
whiteSpace: 'nowrap',
[FORCED_COLORS_SELECTOR]: {
color: 'LinkText'
},
[NOT_FORCED_COLORS_SELECTOR]: {
color: CSSTokens.ColorAccent
}
},
'& .webchat__render-markdown__pure-identifier': {
display: 'inline-block',
maxWidth: '100%',
overflow: 'hidden',
textOverflow: 'ellipsis',
verticalAlign: 'bottom',
whiteSpace: 'nowrap'
},
'& .webchat__render-markdown__pure-identifier::after': {
content: "']'"
},
'& .webchat__render-markdown__pure-identifier::before': {
content: "'['"
},
'& [data-math-type=block]': {
alignItems: 'center',
display: 'flex',
flexDirection: 'column',
marginBottom: '-4px',
paddingBottom: '4px',
outlineOffset: '2px',
overflowX: 'auto',
overflowY: 'clip',
scrollbarWidth: 'thin'
},
'& span[data-math-type=block]': {
display: 'inline-flex'
},
'& [data-math-type=inline]': {
alignItems: 'center',
display: 'inline-flex',
flexDirection: 'column'
},
'& :is([data-math-type=block], [data-math-type=inline]) > span': {
display: 'contents'
}
}
};
}