Skip to content

Commit 829572d

Browse files
committed
docs: Update changelog and version
1 parent 5f62db0 commit 829572d

File tree

4 files changed

+113
-11
lines changed

4 files changed

+113
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v0.3.1 (12-06-2025)
2+
3+
**Fixed:**
4+
- Fixed and improved markdown wrapper component
5+
16
## v0.3.0 (11-06-2025)
27

38
**Added:**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"files": [
1414
"./dist"
1515
],
16-
"version": "0.3.0",
16+
"version": "0.3.1",
1717
"description": "A simple plugin for rendering markdown messages in React ChatBotify.",
1818
"type": "module",
1919
"main": "./dist/index.cjs",

src/components/MarkdownWrapper.tsx

Lines changed: 105 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,113 @@ import ReactMarkdown from 'react-markdown';
66
* @param children markdown text to render
77
*/
88
const MarkdownWrapper = ({ children }: { children: React.ReactNode }) => {
9-
// ensures that markdownText is a string
9+
// Ensure children is a string
1010
const markdownText = typeof children === 'string' ? children : '';
11+
1112
return (
12-
<ReactMarkdown
13-
components={{
14-
p: ({ ...props }) => <>{props.children}</>,
15-
}}
16-
>
17-
{markdownText}
18-
</ReactMarkdown>
13+
<div style={{ whiteSpace: 'normal' }}>
14+
<ReactMarkdown
15+
components={{
16+
p: ({ ...props }) => (
17+
<p
18+
style={{
19+
margin: 0,
20+
marginBottom: '0.5em',
21+
lineHeight: 1.4,
22+
textAlign: 'left',
23+
}}
24+
>
25+
{props.children}
26+
</p>
27+
),
28+
29+
ul: ({ ...props }) => (
30+
<ul
31+
style={{
32+
paddingLeft: 'clamp(8px, 3.5vw, 16px)',
33+
margin: 0,
34+
listStylePosition: 'inside', // KEY CHANGE
35+
}}
36+
>
37+
{props.children}
38+
</ul>
39+
),
40+
41+
ol: ({ ...props }) => (
42+
<ol
43+
style={{
44+
paddingLeft: 'clamp(8px, 3.5vw, 16px)',
45+
margin: 0,
46+
listStylePosition: 'inside', // KEY CHANGE
47+
}}
48+
>
49+
{props.children}
50+
</ol>
51+
),
52+
53+
// KEY CHANGE: Remove custom bullet rendering, let browser handle bullets & numbers
54+
li: ({ ...props }) => (
55+
<li
56+
style={{
57+
marginBottom: '1px',
58+
lineHeight: 1.4,
59+
}}
60+
>
61+
{props.children}
62+
</li>
63+
),
64+
65+
code({ inline, children, ...props }: React.HTMLAttributes<HTMLElement> & { inline?: boolean }) {
66+
if (inline) {
67+
return (
68+
<code
69+
style={{
70+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
71+
padding: '2px 4px',
72+
borderRadius: '4px',
73+
fontFamily: 'inherit',
74+
fontSize: '0.95em',
75+
}}
76+
>
77+
{children}
78+
</code>
79+
);
80+
}
81+
82+
return (
83+
<pre
84+
style={{
85+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
86+
padding: '8px',
87+
borderRadius: '4px',
88+
overflowX: 'auto',
89+
margin: '0.5em 0',
90+
whiteSpace: 'pre-wrap', // preserve line breaks
91+
}}
92+
>
93+
<code>{children}</code>
94+
</pre>
95+
);
96+
},
97+
98+
blockquote: ({ ...props }) => (
99+
<blockquote
100+
style={{
101+
margin: 0,
102+
paddingLeft: '10px',
103+
borderLeft: '2px solid #ccc',
104+
color: '#666',
105+
fontStyle: 'italic',
106+
}}
107+
>
108+
{props.children}
109+
</blockquote>
110+
),
111+
}}
112+
>
113+
{markdownText}
114+
</ReactMarkdown>
115+
</div>
19116
);
20117
};
21118

0 commit comments

Comments
 (0)