ds-markdown 0.0.10-beta.4 โ 0.0.11-beta.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.en.md +491 -0
- package/README.ja.md +491 -0
- package/README.ko.md +491 -0
- package/README.md +346 -239
- package/dist/cjs/MarkdownCMD/index.js +1 -1
- package/dist/cjs/MarkdownCMD/index.js.map +1 -1
- package/dist/esm/MarkdownCMD/index.js +1 -1
- package/dist/esm/MarkdownCMD/index.js.map +1 -1
- package/package.json +10 -11
package/README.ko.md
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
# ds-markdown
|
|
2
|
+
|
|
3
|
+
> ๐ ๊ณ ์ฑ๋ฅ React Markdown ํ์ดํ ์ ๋๋ฉ์ด์
์ปดํฌ๋ํธ, DeepSeek ์ฑํ
์ธํฐํ์ด์ค ํจ๊ณผ ์๋ฒฝ ์ฌํ
|
|
4
|
+
|
|
5
|
+
**[๐จ๐ณ ไธญๆ](./README.md) | [๐บ๐ธ English](./README.en.md) | [๐ฏ๐ต ๆฅๆฌ่ช](./README.ja.md) | ๐ฐ๐ท ํ๊ตญ์ด**
|
|
6
|
+
|
|
7
|
+
ํ๋ AI ์ ํ๋ฆฌ์ผ์ด์
์ ์ํด ํน๋ณํ ์ค๊ณ๋ React ์ปดํฌ๋ํธ๋ก, ๋ถ๋๋ฌ์ด ์ค์๊ฐ ํ์ดํ ์ ๋๋ฉ์ด์
๊ณผ ์์ ํ Markdown ๋ ๋๋ง ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/ds-markdown)
|
|
10
|
+
[](https://www.npmjs.com/package/ds-markdown)
|
|
11
|
+
[](https://bundlephobia.com/package/ds-markdown)
|
|
12
|
+
[](https://react.dev)
|
|
13
|
+
[](https://www.typescriptlang.org/)
|
|
14
|
+
|
|
15
|
+
[๐ ๋ผ์ด๋ธ ๋ฐ๋ชจ](https://onshinpei.github.io/ds-markdown/) | [๐ง StackBlitz ์ฒดํ](https://stackblitz.com/edit/vitejs-vite-ddfw8avb?file=src%2FApp.tsx)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## โจ ํต์ฌ ๊ธฐ๋ฅ
|
|
20
|
+
|
|
21
|
+
### ๐ฏ **์๋ฒฝํ ์ฌํ**
|
|
22
|
+
|
|
23
|
+
- [DeepSeek ์น์ฌ์ดํธ](https://chat.deepseek.com/) ์ฑํ
์๋ต ํจ๊ณผ 1:1 ์ฌํ
|
|
24
|
+
- ์ฌ๊ณ ๊ณผ์ (`thinking`)๊ณผ ๋ต๋ณ ๋ด์ฉ(`answer`) ๋์ผ ๋ชจ๋ ์ง์
|
|
25
|
+
- ์ฝ๋ ํ์ด๋ผ์ดํธ, ํ
์ด๋ธ, ๋ฆฌ์คํธ ๋ฑ์ ํฌํจํ ๋ค์ดํฐ๋ธ Markdown ๊ตฌ๋ฌธ ์ง์
|
|
26
|
+
|
|
27
|
+
### โก **๊ทนํ์ ์ฑ๋ฅ**
|
|
28
|
+
|
|
29
|
+
- ์ค๋งํธ ๋ฐฐ์น ์ฒ๋ฆฌ๋ก ๋์ฉ๋ ๋ฌธ์๋ ์ง์ฐ ์๋ ๋ ๋๋ง
|
|
30
|
+
- ๋์ผ ํ์ด๋จธ ๋ชจ๋: `requestAnimationFrame` + `setTimeout`
|
|
31
|
+
- ๋ด์ฅ ์คํธ๋ฆฌ๋ฐ ๊ตฌ๋ฌธ ๋ฒํผ๋ง์ผ๋ก ๋ถ์์ ํ Markdown ๋ ๋๋ง ์ค๋ฅ ๋ฐฉ์ง
|
|
32
|
+
|
|
33
|
+
### ๐ฌ **๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
**
|
|
34
|
+
|
|
35
|
+
- ๊ณ ์ฃผํ ํ์ดํ ์ง์(`requestAnimationFrame` ๋ชจ๋์์ `0ms`์ ๊ฐ๊น์ด ํ์ดํ ๊ฐ๊ฒฉ ์ง์)
|
|
36
|
+
- ํ๋ ์ ๋๊ธฐํ ๋ ๋๋ง์ผ๋ก ๋ธ๋ผ์ฐ์ 60fps์ ์๋ฒฝ ๋งค์นญ
|
|
37
|
+
- ์ค๋งํธ ๋ฌธ์ ๋ฐฐ์น ์ฒ๋ฆฌ๋ก ๋ ์์ฐ์ค๋ฌ์ด ์๊ฐ์ ํจ๊ณผ
|
|
38
|
+
|
|
39
|
+
### ๐ง **์ ์ฐํ๊ณ ์ฌ์ฉํ๊ธฐ ์ฌ์**
|
|
40
|
+
|
|
41
|
+
- **์ ์ธ์ API**: ๊ฐ๋จํ ์๋๋ฆฌ์ค์ ์ ํฉ, React ์คํ์ผ
|
|
42
|
+
- **๋ช
๋ นํ API**: ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ์ ์ ํฉ, ๋ ๋์ ์ฑ๋ฅ
|
|
43
|
+
- **๋ค์ดํฐ๋ธ TypeScript ์ง์**: ์์ ํ ํ์
ํํธ
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ๐ฆ ๋น ๋ฅธ ์ค์น
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# npm
|
|
51
|
+
npm install ds-markdown
|
|
52
|
+
|
|
53
|
+
# yarn
|
|
54
|
+
yarn add ds-markdown
|
|
55
|
+
|
|
56
|
+
# pnpm
|
|
57
|
+
pnpm add ds-markdown
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### ESM CDN์ผ๋ก ์ฌ์ฉํ๊ธฐ
|
|
61
|
+
|
|
62
|
+
์ค์น ์์ด ๋ธ๋ผ์ฐ์ ์์ ์ง์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<!-- ์คํ์ผ ๊ฐ์ ธ์ค๊ธฐ -->
|
|
66
|
+
<link rel="stylesheet" href="https://esm.sh/ds-markdown/style.css" />
|
|
67
|
+
|
|
68
|
+
<!-- ์ปดํฌ๋ํธ ๊ฐ์ ธ์ค๊ธฐ -->
|
|
69
|
+
<script type="importmap">
|
|
70
|
+
{
|
|
71
|
+
"imports": {
|
|
72
|
+
"react": "https://esm.sh/react@19.1.0",
|
|
73
|
+
"react-dom/client": "https://esm.sh/react-dom@19.1.0/client",
|
|
74
|
+
"ds-markdown": "https://esm.sh/ds-markdown@0.0.10"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
<script type="module" src="https://esm.sh/tsx"></script>
|
|
79
|
+
|
|
80
|
+
<script type="text/babel">
|
|
81
|
+
import { createRoot } from 'react-dom/client';
|
|
82
|
+
import DsMarkdown from 'ds-markdown';
|
|
83
|
+
|
|
84
|
+
const markdown = `
|
|
85
|
+
# Hello ds-markdown
|
|
86
|
+
|
|
87
|
+
์ด๊ฒ์ **๊ณ ์ฑ๋ฅ** ํ์ดํ ์ ๋๋ฉ์ด์
์ปดํฌ๋ํธ์
๋๋ค!
|
|
88
|
+
|
|
89
|
+
## ํน์ง
|
|
90
|
+
- โก ์ง์ฐ ์๋ ์คํธ๋ฆฌ๋ฐ
|
|
91
|
+
- ๐ฌ ๋ถ๋๋ฌ์ด ํ์ดํ ์ ๋๋ฉ์ด์
|
|
92
|
+
- ๐ฏ ์๋ฒฝํ ๊ตฌ๋ฌธ ์ง์
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
const root = createRoot(document.getElementById('root'));
|
|
96
|
+
root.render(<DsMarkdown interval={20}>{markdown}</DsMarkdown>);
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## ๐ 5๋ถ ๋น ๋ฅธ ์์
|
|
101
|
+
|
|
102
|
+
### ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import DsMarkdown from 'ds-markdown';
|
|
106
|
+
import 'ds-markdown/style.css';
|
|
107
|
+
|
|
108
|
+
function App() {
|
|
109
|
+
return (
|
|
110
|
+
<DsMarkdown interval={20} answerType="answer">
|
|
111
|
+
# Hello ds-markdown ์ด๊ฒ์ **๊ณ ์ฑ๋ฅ** ํ์ดํ ์ ๋๋ฉ์ด์
์ปดํฌ๋ํธ์
๋๋ค! ## ๊ธฐ๋ฅ - โก ์ง์ฐ ์๋ ์คํธ๋ฆฌ๋ฐ ์ฒ๋ฆฌ - ๐ฌ ๋ถ๋๋ฌ์ด ํ์ดํ ์ ๋๋ฉ์ด์
- ๐ฏ ์๋ฒฝํ ๊ตฌ๋ฌธ ์ง์
|
|
112
|
+
</DsMarkdown>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### AI ๋ํ ์๋๋ฆฌ์ค
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
function ChatDemo() {
|
|
121
|
+
const [thinking, setThinking] = useState('');
|
|
122
|
+
const [answer, setAnswer] = useState('');
|
|
123
|
+
|
|
124
|
+
const handleAsk = () => {
|
|
125
|
+
setThinking('๐ค ์ง๋ฌธ์ ๋ถ์ ์ค์
๋๋ค...');
|
|
126
|
+
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
setAnswer(`# React 19์ ๋ํด
|
|
129
|
+
|
|
130
|
+
React 19๋ ๋ง์ ํฅ๋ฏธ๋ก์ด ์ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค:
|
|
131
|
+
|
|
132
|
+
## ๐ ์ฃผ์ ์
๋ฐ์ดํธ
|
|
133
|
+
1. **React Compiler** - ์๋ ์ฑ๋ฅ ์ต์ ํ
|
|
134
|
+
2. **Actions** - ํผ ์ฒ๋ฆฌ ๊ฐ์ํ
|
|
135
|
+
3. **Document Metadata** - ๋ด์ฅ SEO ์ง์
|
|
136
|
+
|
|
137
|
+
์ด๋ฌํ ์ ๊ธฐ๋ฅ๋ค์ ํจ๊ป ํํํด๋ด
์๋ค!`);
|
|
138
|
+
}, 2000);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div>
|
|
143
|
+
<button onClick={handleAsk}>AI์๊ฒ ์ง๋ฌธํ๊ธฐ</button>
|
|
144
|
+
|
|
145
|
+
{thinking && (
|
|
146
|
+
<DsMarkdown answerType="thinking" interval={30}>
|
|
147
|
+
{thinking}
|
|
148
|
+
</DsMarkdown>
|
|
149
|
+
)}
|
|
150
|
+
|
|
151
|
+
{answer && (
|
|
152
|
+
<DsMarkdown answerType="answer" interval={15}>
|
|
153
|
+
{answer}
|
|
154
|
+
</DsMarkdown>
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## ๐ ์์ API ๋ฌธ์
|
|
164
|
+
|
|
165
|
+
### ์ ์ธ์ API (์ด๋ณด์ ์ถ์ฒ)
|
|
166
|
+
|
|
167
|
+
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
168
|
+
| ------------- | ------------------------------------------- | -------------------------------- | ------------------------------------------------------------------------ |
|
|
169
|
+
| `interval` | `number` | ํ์ดํ ๊ฐ๊ฒฉ (๋ฐ๋ฆฌ์ด) | `30` |
|
|
170
|
+
| `timerType` | `'setTimeout'` \| `'requestAnimationFrame'` | ํ์ด๋จธ ํ์
| ํ์ฌ ๊ธฐ๋ณธ๊ฐ์ `setTimeout`, ๋์ค์ `requestAnimationFrame`์ผ๋ก ๋ณ๊ฒฝ ์์ |
|
|
171
|
+
| `answerType` | `'thinking'` \| `'answer'` | ์ฝํ
์ธ ํ์
(์คํ์ผ ํ
๋ง์ ์ํฅ) | `'answer'` |
|
|
172
|
+
| `onEnd` | `(data: EndData) => void` | ํ์ดํ ์๋ฃ ์ฝ๋ฐฑ | - |
|
|
173
|
+
| `onStart` | `(data: StartData) => void` | ํ์ดํ ์์ ์ฝ๋ฐฑ | - |
|
|
174
|
+
| `onTypedChar` | `(data: CharData) => void` | ๋ฌธ์๋ณ ํ์ดํ ์ฝ๋ฐฑ | - |
|
|
175
|
+
|
|
176
|
+
### ๋ช
๋ นํ API (์คํธ๋ฆฌ๋ฐ ์๋๋ฆฌ์ค ์ถ์ฒ)
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { MarkdownCMD, MarkdownRef } from 'ds-markdown';
|
|
180
|
+
|
|
181
|
+
interface MarkdownRef {
|
|
182
|
+
push: (content: string, answerType: AnswerType) => void;
|
|
183
|
+
clear: () => void;
|
|
184
|
+
triggerWholeEnd: () => void;
|
|
185
|
+
flushBuffer: (answerType?: AnswerType) => void;
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
| ๋ฉ์๋ | ๋งค๊ฐ๋ณ์ | ์ค๋ช
|
|
|
190
|
+
| ----------------- | ------------------------------------------- | -------------------------- |
|
|
191
|
+
| `push` | `(content: string, answerType: AnswerType)` | ์ฝํ
์ธ ์ถ๊ฐ ๋ฐ ํ์ดํ ์์ |
|
|
192
|
+
| `clear` | - | ๋ชจ๋ ์ฝํ
์ธ ์ ์ํ ์ด๊ธฐํ |
|
|
193
|
+
| `triggerWholeEnd` | - | ์๋์ผ๋ก ์๋ฃ ์ฝ๋ฐฑ ํธ๋ฆฌ๊ฑฐ |
|
|
194
|
+
| `flushBuffer` | `answerType?: AnswerType` | ๋ฒํผ ์ฝํ
์ธ ๊ฐ์ ํ๋ฌ์ |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## ๐๏ธ ํ์ด๋จธ ๋ชจ๋ ์์ธ ์ค๋ช
|
|
199
|
+
|
|
200
|
+
### `requestAnimationFrame` ๋ชจ๋ ๐ (์ถ์ฒ)
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
// ๐ฏ ํน์ง
|
|
204
|
+
- ์๊ฐ ๊ธฐ๋ฐ: ์ค์ ๊ฒฝ๊ณผ ์๊ฐ์ ๊ธฐ๋ฐ์ผ๋ก ๋ฌธ์ ์ ๊ณ์ฐ
|
|
205
|
+
- ๋ฐฐ์น ์ฒ๋ฆฌ: ๋จ์ผ ํ๋ ์ ๋ด์์ ์ฌ๋ฌ ๋ฌธ์ ์ฒ๋ฆฌ ๊ฐ๋ฅ
|
|
206
|
+
- ํ๋ ์ ๋๊ธฐํ: ๋ธ๋ผ์ฐ์ 60fps ์๋ก๊ณ ์นจ ์๋์ ๋๊ธฐํ
|
|
207
|
+
- ๊ณ ์ฃผํ ์ต์ ํ: interval < 16ms ๊ณ ์ ํ์ดํ ์๋ฒฝ ์ง์
|
|
208
|
+
|
|
209
|
+
// ๐ฏ ์ ์ฉ ์๋๋ฆฌ์ค
|
|
210
|
+
- ํ๋ ์น ์ ํ๋ฆฌ์ผ์ด์
์ ๊ธฐ๋ณธ ์ ํ
|
|
211
|
+
- ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
ํจ๊ณผ ์ถ๊ตฌ
|
|
212
|
+
- ๊ณ ์ฃผํ ํ์ดํ (interval > 0์ด๋ฉด ์ถฉ๋ถ)
|
|
213
|
+
- AI ์ค์๊ฐ ๋ํ ์๋๋ฆฌ์ค
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `setTimeout` ๋ชจ๋ ๐ (ํธํ์ฑ)
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// ๐ฏ ํน์ง
|
|
220
|
+
- ๋จ์ผ ๋ฌธ์: ํ ๋ฒ์ ์ ํํ ํ๋์ ๋ฌธ์ ์ฒ๋ฆฌ
|
|
221
|
+
- ๊ณ ์ ๊ฐ๊ฒฉ: ์ค์ ๋ ์๊ฐ์ ๋ฐ๋ผ ์๊ฒฉํ๊ฒ ์คํ
|
|
222
|
+
- ๋ฆฌ๋ฌ๊ฐ: ํด๋์ ํ์๊ธฐ์ ๋ฆฌ๋ฌ
|
|
223
|
+
- ์ ๋ฐ ์ ์ด: ํน์ ํ์ด๋ฐ ์๊ตฌ์ฌํญ์ ์ ํฉ
|
|
224
|
+
|
|
225
|
+
// ๐ฏ ์ ์ฉ ์๋๋ฆฌ์ค
|
|
226
|
+
- ์ ๋ฐํ ์๊ฐ ์ ์ด๊ฐ ํ์
|
|
227
|
+
- ๋ ํธ๋ก ํ์๊ธฐ ํจ๊ณผ ์์ฑ
|
|
228
|
+
- ํธํ์ฑ ์๊ตฌ์ฌํญ์ด ๋์ ์๋๋ฆฌ์ค
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### ๐ ์ฑ๋ฅ ๋น๊ต
|
|
232
|
+
|
|
233
|
+
| ๊ธฐ๋ฅ | requestAnimationFrame | setTimeout |
|
|
234
|
+
| ----------------- | ---------------------------------- | -------------------- |
|
|
235
|
+
| **๋ฌธ์ ์ฒ๋ฆฌ** | ํ๋ ์๋น ์ฌ๋ฌ ๋ฌธ์ ์ฒ๋ฆฌ ๊ฐ๋ฅ | ํ ๋ฒ์ ํ ๋ฌธ์ ์ฒ๋ฆฌ |
|
|
236
|
+
| **๊ณ ์ฃผํ ๊ฐ๊ฒฉ** | โ
์ฐ์ (5ms โ ํ๋ ์๋น 3๋ฌธ์) | โ ์ง์ฐ ๊ฐ๋ฅ์ฑ |
|
|
237
|
+
| **์ ์ฃผํ ๊ฐ๊ฒฉ** | โ
์ ์ (100ms โ 6ํ๋ ์ ํ 1๋ฌธ์) | โ
์ ๋ฐ |
|
|
238
|
+
| **์๊ฐ์ ํจ๊ณผ** | ๐ฌ ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
๋๋ | โก ์ ๋ฐํ ๋ฆฌ๋ฌ๊ฐ |
|
|
239
|
+
| **์ฑ๋ฅ ์ค๋ฒํค๋** | ๐ข ๋ฎ์ (ํ๋ ์ ๋๊ธฐํ) | ๐ก ์ค๊ฐ (ํ์ด๋จธ) |
|
|
240
|
+
|
|
241
|
+
๊ณ ์ฃผํ๋ `requestAnimationFrame`, ์ ์ฃผํ๋ `setTimeout` ์ถ์ฒ
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## ๐ก ์ค์ ์์
|
|
246
|
+
|
|
247
|
+
### ๐ AI ์คํธ๋ฆฌ๋ฐ ๋ํ
|
|
248
|
+
|
|
249
|
+
````tsx
|
|
250
|
+
import { useRef } from 'react';
|
|
251
|
+
import { MarkdownCMD, MarkdownRef } from 'ds-markdown';
|
|
252
|
+
|
|
253
|
+
function StreamingChat() {
|
|
254
|
+
const markdownRef = useRef<MarkdownRef>(null);
|
|
255
|
+
|
|
256
|
+
// AI ์คํธ๋ฆฌ๋ฐ ์๋ต ์๋ฎฌ๋ ์ด์
|
|
257
|
+
const simulateAIResponse = async () => {
|
|
258
|
+
markdownRef.current?.clear();
|
|
259
|
+
|
|
260
|
+
// ์ฌ๊ณ ๋จ๊ณ
|
|
261
|
+
markdownRef.current?.push('๐ค ์ง๋ฌธ์ ๋ถ์ํ๊ณ ์์ต๋๋ค...', 'thinking');
|
|
262
|
+
await delay(1000);
|
|
263
|
+
markdownRef.current?.push('\n\nโ
๋ถ์ ์๋ฃ, ๋ต๋ณ์ ์์ํฉ๋๋ค', 'thinking');
|
|
264
|
+
|
|
265
|
+
// ์คํธ๋ฆฌ๋ฐ ๋ต๋ณ
|
|
266
|
+
const chunks = [
|
|
267
|
+
'# React 19 ์ ๊ธฐ๋ฅ ๋ถ์\n\n',
|
|
268
|
+
'## ๐ React Compiler\n',
|
|
269
|
+
'React 19์ ๊ฐ์ฅ ํฐ ํ์ด๋ผ์ดํธ๋ **React Compiler** ๋์
์
๋๋ค:\n\n',
|
|
270
|
+
'- ๐ฏ **์๋ ์ต์ ํ**: ์๋ memo์ useMemo ๋ถํ์\n',
|
|
271
|
+
'- โก **์ฑ๋ฅ ํฅ์**: ์ปดํ์ผ ํ์ ์ต์ ํ, ๋ฐํ์ ์ค๋ฒํค๋ ์ ๋ก\n',
|
|
272
|
+
'- ๐ง **ํ์ ํธํ์ฑ**: ๊ธฐ์กด ์ฝ๋ ์์ ๋ถํ์\n\n',
|
|
273
|
+
'## ๐ Actions๋ก ํผ ๊ฐ์ํ\n',
|
|
274
|
+
'์๋ก์ด Actions API๋ก ํผ ์ฒ๋ฆฌ๊ฐ ๋ ๊ฐ๋จํด์ง๋๋ค:\n\n',
|
|
275
|
+
'```tsx\n',
|
|
276
|
+
'function ContactForm({ action }) {\n',
|
|
277
|
+
' const [state, formAction] = useActionState(action, null);\n',
|
|
278
|
+
' return (\n',
|
|
279
|
+
' <form action={formAction}>\n',
|
|
280
|
+
' <input name="email" type="email" />\n',
|
|
281
|
+
' <button>์ ์ถ</button>\n',
|
|
282
|
+
' </form>\n',
|
|
283
|
+
' );\n',
|
|
284
|
+
'}\n',
|
|
285
|
+
'```\n\n',
|
|
286
|
+
'์ด ๋ต๋ณ์ด ๋์์ด ๋์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค! ๐',
|
|
287
|
+
];
|
|
288
|
+
|
|
289
|
+
for (const chunk of chunks) {
|
|
290
|
+
await delay(100);
|
|
291
|
+
markdownRef.current?.push(chunk, 'answer');
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<div className="chat-container">
|
|
297
|
+
<button onClick={simulateAIResponse}>๐ค React 19 ๊ธฐ๋ฅ์ ๋ํด ์ง๋ฌธํ๊ธฐ</button>
|
|
298
|
+
|
|
299
|
+
<MarkdownCMD ref={markdownRef} interval={10} timerType="requestAnimationFrame" onEnd={(data) => console.log('๋จ๋ฝ ์๋ฃ:', data)} />
|
|
300
|
+
</div>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
305
|
+
````
|
|
306
|
+
|
|
307
|
+
### ๐ ์คํธ๋ฆฌ๋ฐ Markdown ๊ตฌ๋ฌธ ์ฒ๋ฆฌ
|
|
308
|
+
|
|
309
|
+
**ํต์ฌ ๋ฌธ์ **: ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ ์ ๋ถ์์ ํ Markdown ๊ตฌ๋ฌธ์ด ๋ ๋๋ง ์ค๋ฅ๋ฅผ ์ผ์ผํฌ ์ ์์
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
// ๐จ ๋ฌธ์ ์๋๋ฆฌ์ค
|
|
313
|
+
push('#'); // "# "
|
|
314
|
+
push(' '); // "# "
|
|
315
|
+
push('์ ๋ชฉ'); // "# ์ ๋ชฉ"
|
|
316
|
+
push('\n'); // "# ์ ๋ชฉ\n"
|
|
317
|
+
push('1'); // "# ์ ๋ชฉ\n1" โ ์ด๊ฒ์ ๋จ๋ฝ์ผ๋ก ์๋ชป ํด์๋จ
|
|
318
|
+
push('.'); // "# ์ ๋ชฉ\n1." โ ์ฌ๋ฐ๋ฅธ ๋ฆฌ์คํธ ํ์ฑ
|
|
319
|
+
push(' ํญ๋ชฉ'); // "# ์ ๋ชฉ\n1. ํญ๋ชฉ"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**โ
์ค๋งํธ ์๋ฃจ์
**: ์ปดํฌ๋ํธ ๋ด์ฅ ๋๊ธฐ ๋ฒํผ๋ง ๋ฉ์ปค๋์ฆ
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
// ์ปดํฌ๋ํธ๊ฐ ๊ตฌ๋ฌธ ๊ฒฝ๊ณ๋ฅผ ์ง๋ฅ์ ์ผ๋ก ์ฒ๋ฆฌ
|
|
326
|
+
const handleStreamingMarkdown = () => {
|
|
327
|
+
const chunks = ['#', ' ', '์ฌ์ฉ', '๊ธฐ์ ', '\n', '1', '.', ' ', '๊ธฐ์ 1', '\n', '2', '.', ' ๊ธฐ์ 2'];
|
|
328
|
+
|
|
329
|
+
chunks.forEach((chunk) => {
|
|
330
|
+
markdownRef.current?.push(chunk, 'answer');
|
|
331
|
+
// ์ง์ฐ ๋ถํ์, ์ปดํฌ๋ํธ ๋ด๋ถ์์ ์ง๋ฅ์ ๋ฒํผ๋ง
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// ์ ํ์ฌํญ: ๋จ์ ๋ฒํผ ์ฝํ
์ธ ์๋ ํ๋ฌ์
|
|
335
|
+
markdownRef.current?.flushBuffer();
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// ๐ง ์ค๋งํธ ์ฒ๋ฆฌ ํ๋ก์ฐ:
|
|
339
|
+
// 1. "# ์ฌ์ฉ๊ธฐ์ \n1" ๊ตฌ๋ฌธ ๋ถ์์ ์ค์๊ฐ ๊ฐ์ง
|
|
340
|
+
// 2. ์ค๋งํธ ๋ฒํผ๋ง, ๋ ๋ง์ ๋ฌธ์ ๋๊ธฐ
|
|
341
|
+
// 3. "."์ ๋ฐ์ "1." ํ์ฑ ํ ์ฆ์ ์ฒ๋ฆฌ
|
|
342
|
+
// 4. ์ง์ฐ ์์, ์์ ๋๊ธฐ ์ฒ๋ฆฌ
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**๋ฒํผ ๋ฉ์ปค๋์ฆ ํน์ง**:
|
|
346
|
+
|
|
347
|
+
- โก **์ง์ฐ ์์**: setTimeout ์์, ์์ ๋๊ธฐ ์ค์๊ฐ ์ฒ๋ฆฌ
|
|
348
|
+
- ๐ง **์ค๋งํธ ๊ฒฝ๊ณ**: Markdown ๊ตฌ๋ฌธ ๊ท์น ๊ธฐ๋ฐ ๊ฒฝ๊ณ ๊ฐ์ง
|
|
349
|
+
- ๐ **์ค์๊ฐ ๋ถํ **: ์์ ํ ๊ตฌ๋ฌธ ๋ง๋ ๋ ์ฆ์ ์ฒ๋ฆฌ, ๋ถ์์ ํ ๋ ์ค๋งํธ ๋ฒํผ๋ง
|
|
350
|
+
- ๐ก๏ธ **์์ ๋ณด์ฅ**: ๋จ์ ์ฝํ
์ธ ์ฒ๋ฆฌ๋ฅผ ์ํ `flushBuffer()` ๋ฉ์๋ ์ ๊ณต
|
|
351
|
+
|
|
352
|
+
**์ง์๋๋ ๊ตฌ๋ฌธ ๊ฐ์ง**:
|
|
353
|
+
|
|
354
|
+
````typescript
|
|
355
|
+
// โ
์์ ํ ๊ตฌ๋ฌธ (์ฆ์ ์ฒ๋ฆฌ)
|
|
356
|
+
'## ์ ๋ชฉ'; // ์์ ํ ์ ๋ชฉ
|
|
357
|
+
'1. ๋ฆฌ์คํธ ํญ๋ชฉ'; // ์์ ํ ๋ฆฌ์คํธ ํญ๋ชฉ
|
|
358
|
+
'- ํญ๋ชฉ'; // ์์ ํ ๋ฌด์์ ๋ฆฌ์คํธ
|
|
359
|
+
'> ์ธ์ฉ ์ฝํ
์ธ '; // ์์ ํ ์ธ์ฉ
|
|
360
|
+
'```javascript'; // ์ฝ๋ ๋ธ๋ก ์์
|
|
361
|
+
'```'; // ์ฝ๋ ๋ธ๋ก ๋
|
|
362
|
+
'๊ฐํ์ผ๋ก ๋๋๋ ์ฝํ
์ธ \n'; // ๊ฐํ ๊ฒฝ๊ณ
|
|
363
|
+
|
|
364
|
+
// ๐ ๋ถ์์ ํ ๊ตฌ๋ฌธ (์ค๋งํธ ๋ฒํผ๋ง)
|
|
365
|
+
'##'; // ์ ๋ชฉ ๊ธฐํธ๋ง
|
|
366
|
+
'1'; // ์ซ์๋ง
|
|
367
|
+
'```java'; // ๊ฐ๋ฅํ ์ฝ๋ ๋ธ๋ก ์์
|
|
368
|
+
````
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## ๐ง ๋ชจ๋ฒ ์ฌ๋ก
|
|
373
|
+
|
|
374
|
+
### 1. ์ฑ๋ฅ ์ต์ ํ
|
|
375
|
+
|
|
376
|
+
```tsx
|
|
377
|
+
// โ
์ถ์ฒ ๊ตฌ์ฑ
|
|
378
|
+
<DsMarkdown
|
|
379
|
+
timerType="requestAnimationFrame"
|
|
380
|
+
interval={15} // 15-30ms๊ฐ ์ต์ ๊ฒฝํ
|
|
381
|
+
/>
|
|
382
|
+
|
|
383
|
+
// โ ๋๋ฌด ์์ ๊ฐ๊ฒฉ ํผํ๊ธฐ
|
|
384
|
+
<DsMarkdown interval={1} /> // ์ฑ๋ฅ ๋ฌธ์ ๋ฅผ ์ผ์ผํฌ ์ ์์
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### 2. ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ ์ฒ๋ฆฌ
|
|
388
|
+
|
|
389
|
+
```tsx
|
|
390
|
+
// โ
์ถ์ฒ: ๋ช
๋ นํ API
|
|
391
|
+
const ref = useRef<MarkdownRef>(null);
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
ref.current?.push(newChunk, 'answer');
|
|
394
|
+
}, [newChunk]);
|
|
395
|
+
|
|
396
|
+
// โ ํผํ๊ธฐ: ๋น๋ฒํ children ์
๋ฐ์ดํธ
|
|
397
|
+
const [content, setContent] = useState('');
|
|
398
|
+
// ๊ฐ ์
๋ฐ์ดํธ๋ง๋ค ์ ์ฒด ์ฝํ
์ธ ๋ฅผ ๋ค์ ํ์ฑ
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### 3. ํ์
์์ ์ฑ
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
import { MarkdownRef } from 'ds-markdown';
|
|
405
|
+
|
|
406
|
+
const ref = useRef<MarkdownRef>(null);
|
|
407
|
+
// ์์ ํ TypeScript ํ์
ํํธ
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### 4. ์คํ์ผ ์ปค์คํฐ๋ง์ด์ง
|
|
411
|
+
|
|
412
|
+
```css
|
|
413
|
+
/* ์ฌ๊ณ ์์ญ ์คํ์ผ */
|
|
414
|
+
.ds-markdown-thinking {
|
|
415
|
+
background: rgba(255, 193, 7, 0.1);
|
|
416
|
+
border-left: 3px solid #ffc107;
|
|
417
|
+
padding: 12px;
|
|
418
|
+
border-radius: 6px;
|
|
419
|
+
margin: 8px 0;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/* ๋ต๋ณ ์์ญ ์คํ์ผ */
|
|
423
|
+
.ds-markdown-answer {
|
|
424
|
+
color: #333;
|
|
425
|
+
line-height: 1.6;
|
|
426
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/* ์ฝ๋ ๋ธ๋ก ์คํ์ผ */
|
|
430
|
+
.ds-markdown pre {
|
|
431
|
+
background: #f8f9fa;
|
|
432
|
+
border-radius: 8px;
|
|
433
|
+
padding: 16px;
|
|
434
|
+
overflow-x: auto;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* ํ
์ด๋ธ ์คํ์ผ */
|
|
438
|
+
.ds-markdown-table {
|
|
439
|
+
border-collapse: collapse;
|
|
440
|
+
width: 100%;
|
|
441
|
+
margin: 16px 0;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.ds-markdown-table th,
|
|
445
|
+
.ds-markdown-table td {
|
|
446
|
+
border: 1px solid #ddd;
|
|
447
|
+
padding: 8px 12px;
|
|
448
|
+
text-align: left;
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## ๐ ํธํ์ฑ
|
|
455
|
+
|
|
456
|
+
| ํ๊ฒฝ | ๋ฒ์ ์๊ตฌ์ฌํญ | ์ค๋ช
|
|
|
457
|
+
| -------------- | ----------------------------------- | --------------------- |
|
|
458
|
+
| **React** | 16.8.0+ | Hooks ์ง์ ํ์ |
|
|
459
|
+
| **TypeScript** | 4.0+ | ์ ํ์ฌํญ, ํ์ง๋ง ์ถ์ฒ |
|
|
460
|
+
| **๋ธ๋ผ์ฐ์ ** | Chrome 60+, Firefox 55+, Safari 12+ | ๋ชจ๋ ๋ธ๋ผ์ฐ์ |
|
|
461
|
+
| **Node.js** | 14.0+ | ๋น๋ ํ๊ฒฝ |
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## ๐ค ๊ธฐ์ฌ ๊ฐ์ด๋
|
|
466
|
+
|
|
467
|
+
Issue์ Pull Request ์ ์ถ์ ํ์ํฉ๋๋ค!
|
|
468
|
+
|
|
469
|
+
1. ์ด ๋ฆฌํฌ์งํ ๋ฆฌ ํฌํฌ
|
|
470
|
+
2. ๊ธฐ๋ฅ ๋ธ๋์น ์์ฑ: `git checkout -b feature/amazing-feature`
|
|
471
|
+
3. ๋ณ๊ฒฝ์ฌํญ ์ปค๋ฐ: `git commit -m 'Add amazing feature'`
|
|
472
|
+
4. ๋ธ๋์น ํธ์: `git push origin feature/amazing-feature`
|
|
473
|
+
5. Pull Request ์ ์ถ
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## ๐ ๋ผ์ด์ ์ค
|
|
478
|
+
|
|
479
|
+
MIT ยฉ [onshinpei](https://github.com/onshinpei)
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
<div align="center">
|
|
484
|
+
<strong>์ด ํ๋ก์ ํธ๊ฐ ๋์์ด ๋์๋ค๋ฉด, โญ๏ธ Star๋ก ์ง์ํด์ฃผ์ธ์!</strong>
|
|
485
|
+
|
|
486
|
+
<br><br>
|
|
487
|
+
|
|
488
|
+
[๐ ๋ฌธ์ ๋ณด๊ณ ](https://github.com/onshinpei/ds-markdown/issues) |
|
|
489
|
+
[๐ก ๊ธฐ๋ฅ ์ ์](https://github.com/onshinpei/ds-markdown/issues) |
|
|
490
|
+
[๐ ๋ฌธ์ ๋ณด๊ธฐ](https://onshinpei.github.io/ds-markdown/)
|
|
491
|
+
</div>
|