@xsolla/xui-markdown 0.150.0 → 0.151.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -188
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,154 +1,103 @@
|
|
|
1
1
|
# Markdown
|
|
2
2
|
|
|
3
|
-
A React component that renders markdown content with
|
|
3
|
+
A React component that renders markdown content with theme-aware typography (web only — built on `react-markdown` and `styled-components`).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @xsolla/xui-markdown
|
|
9
|
-
# or
|
|
10
|
-
yarn add @xsolla/xui-markdown
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
### Basic Markdown
|
|
11
|
+
## Imports
|
|
16
12
|
|
|
17
13
|
```tsx
|
|
18
|
-
import * as React from 'react';
|
|
19
14
|
import { Markdown } from '@xsolla/xui-markdown';
|
|
20
|
-
|
|
21
|
-
export default function BasicMarkdown() {
|
|
22
|
-
const content = `
|
|
23
|
-
# Hello World
|
|
24
|
-
|
|
25
|
-
This is a paragraph with **bold** and *italic* text.
|
|
26
|
-
|
|
27
|
-
- Item one
|
|
28
|
-
- Item two
|
|
29
|
-
- Item three
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
return <Markdown>{content}</Markdown>;
|
|
33
|
-
}
|
|
34
15
|
```
|
|
35
16
|
|
|
36
|
-
|
|
17
|
+
## Quick start
|
|
37
18
|
|
|
38
19
|
```tsx
|
|
39
20
|
import * as React from 'react';
|
|
40
21
|
import { Markdown } from '@xsolla/xui-markdown';
|
|
41
22
|
|
|
42
|
-
export default function
|
|
43
|
-
|
|
44
|
-
# Heading 1
|
|
45
|
-
## Heading 2
|
|
46
|
-
### Heading 3
|
|
47
|
-
#### Heading 4
|
|
48
|
-
|
|
49
|
-
This is a regular paragraph with some text content.
|
|
50
|
-
|
|
51
|
-
Another paragraph following the first one.
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
return <Markdown>{content}</Markdown>;
|
|
23
|
+
export default function QuickStart() {
|
|
24
|
+
return <Markdown>{`# Hello\n\nThis is **bold** text.`}</Markdown>;
|
|
55
25
|
}
|
|
56
26
|
```
|
|
57
27
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```tsx
|
|
61
|
-
import * as React from 'react';
|
|
62
|
-
import { Markdown } from '@xsolla/xui-markdown';
|
|
28
|
+
## API Reference
|
|
63
29
|
|
|
64
|
-
|
|
65
|
-
const content = `
|
|
66
|
-
Inline code: \`const x = 1;\`
|
|
30
|
+
### `<Markdown>` (web only)
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
\`\`\`
|
|
74
|
-
`;
|
|
32
|
+
| Prop | Type | Default | Description |
|
|
33
|
+
| --- | --- | --- | --- |
|
|
34
|
+
| `children` | `string` | — | **Required.** Markdown source to render. |
|
|
35
|
+
| `className` | `string` | — | CSS class for the container. |
|
|
75
36
|
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
```
|
|
37
|
+
Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
|
|
79
38
|
|
|
80
|
-
|
|
39
|
+
The component pulls heading and body fonts from the resolved theme (`theme.fonts.heading`, `theme.fonts.body`, falling back to `theme.fonts.primary`) and uses `theme.colors.content.primary`, `theme.colors.border.brand`, and `theme.colors.control.link.primary` for styling.
|
|
81
40
|
|
|
82
|
-
|
|
83
|
-
import { Markdown } from '@xsolla/xui-markdown';
|
|
41
|
+
### Supported syntax
|
|
84
42
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
43
|
+
| Element | Syntax |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| Headings (h1–h4) | `# text` … `#### text` |
|
|
46
|
+
| Bold | `**text**` |
|
|
47
|
+
| Italic | `*text*` |
|
|
48
|
+
| Link | `[text](https://example.com)` |
|
|
49
|
+
| Image | `` |
|
|
50
|
+
| Inline code | `` `code` `` |
|
|
51
|
+
| Code block | ` ```language ` |
|
|
52
|
+
| Blockquote | `> quote` |
|
|
53
|
+
| Unordered list | `- item` |
|
|
54
|
+
| Ordered list | `1. item` |
|
|
91
55
|
|
|
92
56
|
## Examples
|
|
93
57
|
|
|
94
|
-
### Rich
|
|
58
|
+
### Rich content
|
|
95
59
|
|
|
96
60
|
```tsx
|
|
97
61
|
import * as React from 'react';
|
|
98
62
|
import { Markdown } from '@xsolla/xui-markdown';
|
|
99
63
|
|
|
100
64
|
export default function RichContent() {
|
|
101
|
-
const content =
|
|
102
|
-
# Product Documentation
|
|
103
|
-
|
|
104
|
-
## Getting Started
|
|
65
|
+
const content = `# Product documentation
|
|
105
66
|
|
|
106
|
-
|
|
67
|
+
## Getting started
|
|
107
68
|
|
|
108
69
|
1. Install the package
|
|
109
70
|
2. Configure your API keys
|
|
110
|
-
3.
|
|
111
|
-
|
|
112
|
-
> **Note:** Make sure to keep your API keys secure and never commit them to version control.
|
|
71
|
+
3. Initialise the SDK
|
|
113
72
|
|
|
114
|
-
|
|
73
|
+
> **Note:** keep keys out of source control.
|
|
115
74
|
|
|
116
75
|
\`\`\`javascript
|
|
117
76
|
import { SDK } from '@example/sdk';
|
|
118
|
-
|
|
119
|
-
const client = new SDK({
|
|
120
|
-
apiKey: process.env.API_KEY,
|
|
121
|
-
});
|
|
122
|
-
|
|
77
|
+
const client = new SDK({ apiKey: process.env.API_KEY });
|
|
123
78
|
await client.initialize();
|
|
124
79
|
\`\`\`
|
|
125
80
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Visit our [documentation](https://docs.example.com) for more details.
|
|
129
|
-
|
|
130
|
-

|
|
131
|
-
`;
|
|
81
|
+
Visit our [documentation](https://docs.example.com).`;
|
|
132
82
|
|
|
133
83
|
return <Markdown>{content}</Markdown>;
|
|
134
84
|
}
|
|
135
85
|
```
|
|
136
86
|
|
|
137
|
-
###
|
|
87
|
+
### Live preview
|
|
138
88
|
|
|
139
89
|
```tsx
|
|
140
90
|
import * as React from 'react';
|
|
141
91
|
import { Markdown } from '@xsolla/xui-markdown';
|
|
142
92
|
|
|
143
|
-
export default function
|
|
93
|
+
export default function LivePreview() {
|
|
144
94
|
const [content, setContent] = React.useState('# Hello\n\nStart typing...');
|
|
145
|
-
|
|
146
95
|
return (
|
|
147
96
|
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
|
|
148
97
|
<textarea
|
|
149
98
|
value={content}
|
|
150
99
|
onChange={(e) => setContent(e.target.value)}
|
|
151
|
-
style={{ height:
|
|
100
|
+
style={{ height: 240, fontFamily: 'monospace' }}
|
|
152
101
|
/>
|
|
153
102
|
<div style={{ background: '#1a1a1a', padding: 16, borderRadius: 8 }}>
|
|
154
103
|
<Markdown>{content}</Markdown>
|
|
@@ -158,106 +107,9 @@ export default function DynamicContent() {
|
|
|
158
107
|
}
|
|
159
108
|
```
|
|
160
109
|
|
|
161
|
-
### Article Display
|
|
162
|
-
|
|
163
|
-
```tsx
|
|
164
|
-
import * as React from 'react';
|
|
165
|
-
import { Markdown } from '@xsolla/xui-markdown';
|
|
166
|
-
|
|
167
|
-
export default function ArticleDisplay() {
|
|
168
|
-
const article = `
|
|
169
|
-
# Understanding Game Monetization
|
|
170
|
-
|
|
171
|
-
## Introduction
|
|
172
|
-
|
|
173
|
-
Game monetization is a critical aspect of game development that determines how a game generates revenue.
|
|
174
|
-
|
|
175
|
-
## Key Strategies
|
|
176
|
-
|
|
177
|
-
### In-App Purchases
|
|
178
|
-
|
|
179
|
-
In-app purchases (IAP) allow players to buy virtual goods:
|
|
180
|
-
|
|
181
|
-
- Cosmetic items
|
|
182
|
-
- Power-ups
|
|
183
|
-
- Premium currency
|
|
184
|
-
- Battle passes
|
|
185
|
-
|
|
186
|
-
### Subscription Models
|
|
187
|
-
|
|
188
|
-
Subscription models provide ongoing value:
|
|
189
|
-
|
|
190
|
-
1. **Monthly subscriptions** - Regular content updates
|
|
191
|
-
2. **Season passes** - Time-limited content access
|
|
192
|
-
3. **Premium tiers** - Enhanced features
|
|
193
|
-
|
|
194
|
-
> "The best monetization strategies provide value to players while generating sustainable revenue."
|
|
195
|
-
|
|
196
|
-
## Conclusion
|
|
197
|
-
|
|
198
|
-
Choose a monetization strategy that aligns with your game design and player expectations.
|
|
199
|
-
`;
|
|
200
|
-
|
|
201
|
-
return (
|
|
202
|
-
<article style={{ maxWidth: 800, margin: '0 auto' }}>
|
|
203
|
-
<Markdown>{article}</Markdown>
|
|
204
|
-
</article>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## API Reference
|
|
210
|
-
|
|
211
|
-
### Markdown
|
|
212
|
-
|
|
213
|
-
**MarkdownProps:**
|
|
214
|
-
|
|
215
|
-
| Prop | Type | Default | Description |
|
|
216
|
-
| :--- | :--- | :------ | :---------- |
|
|
217
|
-
| children | `string` | - | Markdown content to render. |
|
|
218
|
-
| className | `string` | - | CSS class name for the container. |
|
|
219
|
-
|
|
220
|
-
## Supported Markdown Syntax
|
|
221
|
-
|
|
222
|
-
| Element | Syntax |
|
|
223
|
-
| :------ | :----- |
|
|
224
|
-
| Heading 1 | `# Heading` |
|
|
225
|
-
| Heading 2 | `## Heading` |
|
|
226
|
-
| Heading 3 | `### Heading` |
|
|
227
|
-
| Heading 4 | `#### Heading` |
|
|
228
|
-
| Bold | `**text**` |
|
|
229
|
-
| Italic | `*text*` |
|
|
230
|
-
| Link | `[text](url)` |
|
|
231
|
-
| Image | `` |
|
|
232
|
-
| Inline code | `` `code` `` |
|
|
233
|
-
| Code block | ```` ```language ```` |
|
|
234
|
-
| Blockquote | `> quote` |
|
|
235
|
-
| Unordered list | `- item` |
|
|
236
|
-
| Ordered list | `1. item` |
|
|
237
|
-
|
|
238
|
-
## Typography Styles
|
|
239
|
-
|
|
240
|
-
| Element | Font Size | Line Height | Weight |
|
|
241
|
-
| :------ | :-------- | :---------- | :----- |
|
|
242
|
-
| h1 | 40px | 48px | 700 |
|
|
243
|
-
| h2 | 32px | 38px | 700 |
|
|
244
|
-
| h3 | 28px | 34px | 700 |
|
|
245
|
-
| h4 | 24px | 28px | 700 |
|
|
246
|
-
| p | 16px | 22px | 400 |
|
|
247
|
-
| li | 16px | 22px | 400 |
|
|
248
|
-
|
|
249
|
-
## Theming
|
|
250
|
-
|
|
251
|
-
The Markdown component automatically uses theme colors from `XUIProvider`:
|
|
252
|
-
|
|
253
|
-
- Text color from `content.primary`
|
|
254
|
-
- Link color from `control.link.primary`
|
|
255
|
-
- Blockquote border from `border.brand`
|
|
256
|
-
- Code background with subtle transparency
|
|
257
|
-
|
|
258
110
|
## Accessibility
|
|
259
111
|
|
|
260
|
-
- Headings
|
|
261
|
-
- Links
|
|
262
|
-
-
|
|
263
|
-
- Code blocks
|
|
112
|
+
- Headings produce a proper document outline.
|
|
113
|
+
- Links inherit the theme's link colour and underline on hover/focus.
|
|
114
|
+
- Provide alt text via standard markdown image syntax.
|
|
115
|
+
- Code blocks use semantic `<pre><code>` for screen readers.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-core": "0.
|
|
14
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-core": "0.151.0",
|
|
14
|
+
"@xsolla/xui-primitives-core": "0.151.0",
|
|
15
15
|
"react-markdown": "^9.0.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|