ds-markdown 0.1.4-beta.1 โ 0.1.4
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 +3 -1
- package/README.md +3 -1
- package/package.json +2 -2
- package/README.ja.md +0 -942
- package/README.ko.md +0 -805
package/README.ko.md
DELETED
|
@@ -1,805 +0,0 @@
|
|
|
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/)
|
|
16
|
-
|
|
17
|
-
[DEMO๏ผ๐ง StackBlitz ์ฒดํ](https://stackblitz.com/edit/vitejs-vite-ddfw8avb?file=src%2FApp.tsx)
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## ๐ ๋ชฉ์ฐจ
|
|
22
|
-
|
|
23
|
-
- [โจ ํต์ฌ ๊ธฐ๋ฅ](#-ํต์ฌ-๊ธฐ๋ฅ)
|
|
24
|
-
- [๐ฆ ๋น ๋ฅธ ์ค์น](#-๋น ๋ฅธ-์ค์น)
|
|
25
|
-
- [๐ 5๋ถ ๋น ๋ฅธ ์์](#-5๋ถ-๋น ๋ฅธ-์์)
|
|
26
|
-
- [๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ](#๊ธฐ๋ณธ-์ฌ์ฉ๋ฒ)
|
|
27
|
-
- [ํ์ดํ ์ ๋๋ฉ์ด์
๋นํ์ฑํ](#ํ์ดํ-์ ๋๋ฉ์ด์
-๋นํ์ฑํ)
|
|
28
|
-
- [์ํ ๊ณต์ ์ง์](#์ํ-๊ณต์-์ง์)
|
|
29
|
-
- [AI ๋ํ ์๋๋ฆฌ์ค](#ai-๋ํ-์๋๋ฆฌ์ค)
|
|
30
|
-
- [๐ฏ ๊ณ ๊ธ ์ฝ๋ฐฑ ์ ์ด](#-๊ณ ๊ธ-์ฝ๋ฐฑ-์ ์ด)
|
|
31
|
-
- [๐ ์ ๋๋ฉ์ด์
์ฌ์์ ๋ฐ๋ชจ](#-์ ๋๋ฉ์ด์
-์ฌ์์-๋ฐ๋ชจ)
|
|
32
|
-
- [โถ๏ธ ์๋ ์์ ์ ๋๋ฉ์ด์
๋ฐ๋ชจ](#๏ธ-์๋-์์-์ ๋๋ฉ์ด์
-๋ฐ๋ชจ)
|
|
33
|
-
- [๐ ์์ API ๋ฌธ์](#-์์ -api-๋ฌธ์)
|
|
34
|
-
- [๐งฎ ์ํ ๊ณต์ ์ฌ์ฉ ๊ฐ์ด๋](#-์ํ-๊ณต์-์ฌ์ฉ-๊ฐ์ด๋)
|
|
35
|
-
- [๐ ํ๋ฌ๊ทธ์ธ ์์คํ
](#-ํ๋ฌ๊ทธ์ธ-์์คํ
)
|
|
36
|
-
- [๐๏ธ ํ์ด๋จธ ๋ชจ๋ ์์ธ](#๏ธ-ํ์ด๋จธ-๋ชจ๋-์์ธ)
|
|
37
|
-
- [๐ก ์ค์ ์์ ](#-์ค์ -์์ )
|
|
38
|
-
- [๐ง ๋ชจ๋ฒ ์ฌ๋ก](#-๋ชจ๋ฒ-์ฌ๋ก)
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## โ ์ ds-markdown์ ์จ์ผ ํ๋์?
|
|
43
|
-
|
|
44
|
-
- **AI ์ฑํ
๊ฒฝํ ์๋ฒฝ ์ฌํ**
|
|
45
|
-
DeepSeek ๋ฑ ์ฃผ์ AI ์ฑํ
UI์ ํ์ดํ ์ ๋๋ฉ์ด์
๊ณผ ์คํธ๋ฆฌ๋ฐ ์๋ต์ 1:1๋ก ์ฌํ, "AI๊ฐ ์๊ฐ/๋ต๋ณ ์ค"์ธ ์ง์ง ๊ฐ์ ๊ฒฝํ์ ์ ๊ณตํฉ๋๋ค.
|
|
46
|
-
|
|
47
|
-
- **๋ฐฑ์๋ ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ ์๋ฒฝ ๋์**
|
|
48
|
-
๋ง์ AI/LLM ๋ฐฑ์๋(OpenAI, DeepSeek ๋ฑ)๋ ํ ๋ฒ์ ์ฌ๋ฌ ๊ธ์๊ฐ ํฌํจ๋ chunk๋ฅผ ๋ณด๋
๋๋ค.
|
|
49
|
-
**ds-markdown์ ๊ฐ chunk๋ฅผ ์๋์ผ๋ก ํ ๊ธ์์ฉ ๋ถ๋ฆฌํด, ๋ฐฑ์๋๊ฐ ์ฌ๋ฌ ๊ธ์๋ฅผ ํ ๋ฒ์ ๋ณด๋ด๋ ํญ์ ๋ถ๋๋ฝ๊ฒ ํ ๊ธ์์ฉ ํ์ดํ ์ ๋๋ฉ์ด์
์ ๋ณด์ฌ์ค๋๋ค.**
|
|
50
|
-
|
|
51
|
-
- **์๋ฒฝํ Markdown & ์์ ์ง์**
|
|
52
|
-
KaTeX ๋ด์ฅ, ๋ชจ๋ ์ฃผ์ Markdown ๊ตฌ๋ฌธ๊ณผ ์์ ์ง์โ๊ธฐ์ Q&A, ๊ต์ก, ์ง์๋ฒ ์ด์ค์ ์ต์ .
|
|
53
|
-
|
|
54
|
-
- **์ต๊ณ ์ ๊ฐ๋ฐ ๊ฒฝํ**
|
|
55
|
-
ํ๋ถํ ๋ช
๋ นํ API, ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ, ๋น๋๊ธฐ ์ฝ๋ฐฑ, ํ๋ฌ๊ทธ์ธ ํ์ฅ ๋ฑ์ผ๋ก ์ ์ฐํ ์ ์ด ๊ฐ๋ฅ.
|
|
56
|
-
|
|
57
|
-
- **๊ฐ๋ณ๊ณ ๊ณ ์ฑ๋ฅ**
|
|
58
|
-
์์ ์ฉ๋, ๋น ๋ฅธ ์๋, ๋ชจ๋ฐ์ผ/๋ฐ์คํฌํ ๋ชจ๋ ์ง์. ํต์ฌ ์์กด์ฑ์ [react-markdown](https://github.com/remarkjs/react-markdown) (์
๊ณ ํ์ค์ ์ฑ์ํ Markdown ๋ ๋๋ฌ) ํ๋๋ฟ์ด๋ฉฐ, ๊ทธ ์ธ ๋ฌด๊ฑฐ์ด ์์กด์ฑ์ ์์ต๋๋ค. ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
|
|
59
|
-
|
|
60
|
-
- **๋ค์ค ํ
๋ง ๋ฐ ํ๋ฌ๊ทธ์ธ ์ํคํ
์ฒ**
|
|
61
|
-
๋ผ์ดํธ/๋คํฌ ํ
๋ง ์ ํ, remark/rehype ํ๋ฌ๊ทธ์ธ ํธํ, ๊ณ ๊ธ ํ์ฅ์ฑ.
|
|
62
|
-
|
|
63
|
-
- **๋ค์ํ ํ์ฉ ์ฌ๋ก**
|
|
64
|
-
- AI ์ฑ๋ด/์ด์์คํดํธ
|
|
65
|
-
- ์ค์๊ฐ Q&A/์ง์๋ฒ ์ด์ค
|
|
66
|
-
- ๊ต์ก/์ํ/ํ๋ก๊ทธ๋๋ฐ ์ฝํ
์ธ
|
|
67
|
-
- ์ ํ ๋ฐ๋ชจ, ์ธํฐ๋ํฐ๋ธ ๋ฌธ์
|
|
68
|
-
- "ํ์๊ธฐ" ์ ๋๋ฉ์ด์
๊ณผ ์คํธ๋ฆฌ๋ฐ Markdown์ด ํ์ํ ๋ชจ๋ ์ํฉ
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## โจ ํต์ฌ ๊ธฐ๋ฅ
|
|
73
|
-
|
|
74
|
-
### ๐ค **AI ๋ํ ์๋๋ฆฌ์ค**
|
|
75
|
-
|
|
76
|
-
- [DeepSeek ์น์ฌ์ดํธ](https://chat.deepseek.com/) ์ฑํ
์๋ต ํจ๊ณผ๋ฅผ 1:1๋ก ์ฌํ
|
|
77
|
-
- ์ฌ๊ณ ๊ณผ์ (`thinking`)๊ณผ ๋ต๋ณ ๋ด์ฉ(`answer`) ๋ ๊ฐ์ง ๋ชจ๋ ์ง์
|
|
78
|
-
- ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ์ ์๋ฒฝํ๊ฒ ์ ์, ์ฌ์ฉ์ ์
๋ ฅ์ ๋ํ ์ง์ฐ ์๋ ์๋ต
|
|
79
|
-
|
|
80
|
-
### ๐ **์ฝํ
์ธ ํ์ ์๋๋ฆฌ์ค**
|
|
81
|
-
|
|
82
|
-
- ์ฝ๋ ํ์ด๋ผ์ดํ
, ํ
์ด๋ธ, ๋ชฉ๋ก ๋ฑ์ ํฌํจํ ์์ ํ Markdown ๊ตฌ๋ฌธ ์ง์
|
|
83
|
-
- ์์ ๋ ๋๋ง (KaTeX), `$...$` ๋ฐ `\[...\]` ๊ตฌ๋ฌธ ์ง์
|
|
84
|
-
- ๋ผ์ดํธ/๋คํฌ ํ
๋ง ์ง์, ๋ค์ํ ์ ํ ์คํ์ผ์ ์ ์
|
|
85
|
-
- remark/rehype ํ๋ฌ๊ทธ์ธ ํ์ฅ์ ์ง์ํ๋ ํ๋ฌ๊ทธ์ธ ์ํคํ
์ฒ
|
|
86
|
-
|
|
87
|
-
### ๐ง **๊ฐ๋ฐ์ ๊ฒฝํ**
|
|
88
|
-
|
|
89
|
-
- ํ์ดํ ์ค๋จ `stop` ๋ฐ ์ฌ๊ฐ `resume` ์ง์
|
|
90
|
-
- ํ์ดํ ๋นํ์ฑํ ๋ฐ ํ์ฑํ ์ง์
|
|
91
|
-
|
|
92
|
-
### ๐ฌ **๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
**
|
|
93
|
-
|
|
94
|
-
- ๋์ผ ํ์ด๋จธ ๋ชจ๋ ์ต์ ํ, `requestAnimationFrame` ๋ฐ `setTimeout` ๋ชจ๋ ์ง์
|
|
95
|
-
- ๊ณ ์ฃผํ ํ์ดํ ์ง์(`requestAnimationFrame` ๋ชจ๋์์ `0ms`์ ๊ฐ๊น์ด ํ์ดํ ๊ฐ๊ฒฉ ์ง์)
|
|
96
|
-
- ํ๋ ์ ๋๊ธฐํ ๋ ๋๋ง์ผ๋ก ๋ธ๋ผ์ฐ์ ์๋ก๊ณ ์นจ ์๋์ ์๋ฒฝ ๋งค์นญ
|
|
97
|
-
- ์ค๋งํธ ๋ฌธ์ ๋ฐฐ์น ์ฒ๋ฆฌ๋ก ๋ ์์ฐ์ค๋ฌ์ด ์๊ฐ์ ํจ๊ณผ
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## ๐ฆ ๋น ๋ฅธ ์ค์น
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# npm
|
|
105
|
-
npm install ds-markdown
|
|
106
|
-
|
|
107
|
-
# yarn
|
|
108
|
-
yarn add ds-markdown
|
|
109
|
-
|
|
110
|
-
# pnpm
|
|
111
|
-
pnpm add ds-markdown
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### ESM CDN์ผ๋ก ์ฌ์ฉํ๊ธฐ
|
|
115
|
-
|
|
116
|
-
์ค์น ์์ด ๋ธ๋ผ์ฐ์ ์์ ์ง์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
|
|
117
|
-
|
|
118
|
-
[DEMO](https://stackblitz.com/edit/stackblitz-starters-7vcclcw7?file=index.html)
|
|
119
|
-
|
|
120
|
-
```html
|
|
121
|
-
<!-- ์คํ์ผ ๊ฐ์ ธ์ค๊ธฐ, ํ์ -->
|
|
122
|
-
<link rel="stylesheet" href="https://esm.sh/ds-markdown/dist/style.css" />
|
|
123
|
-
|
|
124
|
-
<!-- katex ์ํ ๊ณต์ ์คํ์ผ ๊ฐ์ ธ์ค๊ธฐ, ํ์ํ ๊ฒฝ์ฐ๋ง -->
|
|
125
|
-
<link rel="stylesheet" href="https://esm.sh/ds-markdown/dist/katex.css" />
|
|
126
|
-
|
|
127
|
-
<!-- ์ปดํฌ๋ํธ ๊ฐ์ ธ์ค๊ธฐ -->
|
|
128
|
-
<script type="module">
|
|
129
|
-
import Markdown from 'https://esm.sh/ds-markdown';
|
|
130
|
-
</script>
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## ๐ 5๋ถ ๋น ๋ฅธ ์์
|
|
134
|
-
|
|
135
|
-
### ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
|
|
136
|
-
|
|
137
|
-
[DEMO](https://stackblitz.com/edit/vitejs-vite-z94syu8j?file=src%2FApp.tsx)
|
|
138
|
-
|
|
139
|
-
```tsx
|
|
140
|
-
import DsMarkdown from 'ds-markdown';
|
|
141
|
-
import 'ds-markdown/style.css';
|
|
142
|
-
|
|
143
|
-
function App() {
|
|
144
|
-
return (
|
|
145
|
-
<DsMarkdown interval={20} answerType="answer">
|
|
146
|
-
# Hello ds-markdown ์ด๊ฒ์ **๊ณ ์ฑ๋ฅ** ํ์ดํ ์ ๋๋ฉ์ด์
์ปดํฌ๋ํธ์
๋๋ค! ## ๊ธฐ๋ฅ - โก ์ง์ฐ ์๋ ์คํธ๋ฆฌ๋ฐ ์ฒ๋ฆฌ - ๐ฌ ๋ถ๋๋ฌ์ด ํ์ดํ ์ ๋๋ฉ์ด์
- ๐ฏ ์๋ฒฝํ ๊ตฌ๋ฌธ ์ง์
|
|
147
|
-
</DsMarkdown>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### ํ์ดํ ์ ๋๋ฉ์ด์
๋นํ์ฑํ
|
|
153
|
-
|
|
154
|
-
```tsx
|
|
155
|
-
import DsMarkdown from 'ds-markdown';
|
|
156
|
-
import 'ds-markdown/style.css';
|
|
157
|
-
|
|
158
|
-
function StaticDemo() {
|
|
159
|
-
const [disableTyping, setDisableTyping] = useState(false);
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<div>
|
|
163
|
-
<button onClick={() => setDisableTyping(!disableTyping)}>{disableTyping ? 'ํ์ฑํ' : '๋นํ์ฑํ'}ํ์ดํ ํจ๊ณผ</button>
|
|
164
|
-
|
|
165
|
-
<DsMarkdown interval={20} answerType="answer" disableTyping={disableTyping}>
|
|
166
|
-
# ์ ์ ํ์ ๋ชจ๋ `disableTyping`์ด `true`์ผ ๋, ์ฝํ
์ธ ๋ ํ์ดํ ์ ๋๋ฉ์ด์
ํจ๊ณผ ์์ด ์ฆ์ ๋ชจ๋ ํ์๋ฉ๋๋ค. ์ด๋ ํน์ ์๋๋ฆฌ์ค์์ ๋งค์ฐ ์ ์ฉํฉ๋๋ค: - ๐ ์ ์ ๋ฌธ์ ํ์ - ๐ ํ์ ๋ชจ๋ ์ ํ - โก
|
|
167
|
-
์ฝํ
์ธ ๋น ๋ฅธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
|
|
168
|
-
</DsMarkdown>
|
|
169
|
-
</div>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### ์ํ ๊ณต์ ์ง์
|
|
175
|
-
|
|
176
|
-
```tsx
|
|
177
|
-
import DsMarkdown from 'ds-markdown';
|
|
178
|
-
// ๊ณต์์ ํ์ํด์ผ ํ๋ ๊ฒฝ์ฐ ๊ณต์ ๋ณํ ํ๋ฌ๊ทธ์ธ์ ๊ฐ์ ธ์ต๋๋ค
|
|
179
|
-
import { katexPlugin } from 'ds-markdown/plugins';
|
|
180
|
-
import 'ds-markdown/style.css';
|
|
181
|
-
// ๊ณต์์ ํ์ํด์ผ ํ๋ ๊ฒฝ์ฐ ์ํ ๊ณต์ ์คํ์ผ์ ๊ฐ์ ธ์ต๋๋ค
|
|
182
|
-
import 'ds-markdown/katex.css';
|
|
183
|
-
|
|
184
|
-
function MathDemo() {
|
|
185
|
-
return (
|
|
186
|
-
<DsMarkdown interval={20} answerType="answer" plugins={[katexPlugin]} math={{ splitSymbol: 'dollar' }}>
|
|
187
|
-
# ํผํ๊ณ ๋ผ์ค ์ ๋ฆฌ ์ง๊ฐ์ผ๊ฐํ์์ ๋น๋ณ์ ์ ๊ณฑ์ ๋ ์ง๊ฐ๋ณ์ ์ ๊ณฑ์ ํฉ๊ณผ ๊ฐ์ต๋๋ค: $a^2 + b^2 = c^2$ ์ฌ๊ธฐ์: - $a$์ $b$๋ ์ง๊ฐ๋ณ - $c$๋ ๋น๋ณ ๊ณ ์ ์ ์ธ "๊ตฌ์ผ๊ณ ์ฌํ์ค"์ ๊ฒฝ์ฐ: $c = \sqrt
|
|
188
|
-
{3 ^ (2 + 4) ^ 2} = \sqrt{25} = 5$
|
|
189
|
-
</DsMarkdown>
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### AI ๋ํ ์๋๋ฆฌ์ค
|
|
195
|
-
|
|
196
|
-
```tsx
|
|
197
|
-
function ChatDemo() {
|
|
198
|
-
const [thinking, setThinking] = useState('');
|
|
199
|
-
const [answer, setAnswer] = useState('');
|
|
200
|
-
|
|
201
|
-
const handleAsk = () => {
|
|
202
|
-
setThinking('๐ค ์ง๋ฌธ์ ๋ถ์ ์ค์
๋๋ค...');
|
|
203
|
-
|
|
204
|
-
setTimeout(() => {
|
|
205
|
-
setAnswer(`# React 19์ ๋ํด
|
|
206
|
-
|
|
207
|
-
React 19๋ ๋ง์ ํฅ๋ฏธ๋ก์ด ์ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค:
|
|
208
|
-
|
|
209
|
-
## ๐ ์ฃผ์ ์
๋ฐ์ดํธ
|
|
210
|
-
1. **React Compiler** - ์๋ ์ฑ๋ฅ ์ต์ ํ
|
|
211
|
-
2. **Actions** - ํผ ์ฒ๋ฆฌ ๊ฐ์ํ
|
|
212
|
-
3. **Document Metadata** - ๋ด์ฅ SEO ์ง์
|
|
213
|
-
|
|
214
|
-
์ด๋ฌํ ์ ๊ธฐ๋ฅ๋ค์ ํจ๊ป ํํํด๋ด
์๋ค!`);
|
|
215
|
-
}, 2000);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
return (
|
|
219
|
-
<div>
|
|
220
|
-
<button onClick={handleAsk}>AI์๊ฒ ์ง๋ฌธํ๊ธฐ</button>
|
|
221
|
-
|
|
222
|
-
{thinking && (
|
|
223
|
-
<DsMarkdown answerType="thinking" interval={30}>
|
|
224
|
-
{thinking}
|
|
225
|
-
</DsMarkdown>
|
|
226
|
-
)}
|
|
227
|
-
|
|
228
|
-
{answer && (
|
|
229
|
-
<DsMarkdown answerType="answer" interval={15}>
|
|
230
|
-
{answer}
|
|
231
|
-
</DsMarkdown>
|
|
232
|
-
)}
|
|
233
|
-
</div>
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
## ๐ ์์ API ๋ฌธ์
|
|
241
|
-
|
|
242
|
-
### ๊ธฐ๋ณธ ๋ด๋ณด๋ด๊ธฐ DsMarkdown ๋ฐ MarkdownCMD props
|
|
243
|
-
|
|
244
|
-
```js
|
|
245
|
-
import DsMarkdown, { MarkdownCMD } from 'ds-markdown';
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
249
|
-
| ------------------- | ------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
250
|
-
| `interval` | `number` | ํ์ดํ ๊ฐ๊ฒฉ (๋ฐ๋ฆฌ์ด) | `30` |
|
|
251
|
-
| `timerType` | `'setTimeout'` \| `'requestAnimationFrame'` | ํ์ด๋จธ ํ์
| ํ์ฌ ๊ธฐ๋ณธ๊ฐ์ `setTimeout`, ๋์ค์ `requestAnimationFrame`๋ก ๋ณ๊ฒฝ ์์ |
|
|
252
|
-
| `answerType` | `'thinking'` \| `'answer'` | ์ฝํ
์ธ ํ์
(์คํ์ผ ์ํฅ) | `'answer'` |
|
|
253
|
-
| `theme` | `'light'` \| `'dark'` | ํ
๋ง ํ์
| `'light'` |
|
|
254
|
-
| `plugins` | `IMarkdownPlugin[]` | ํ๋ฌ๊ทธ์ธ ์ค์ | `[]` |
|
|
255
|
-
| `math` | [IMarkdownMath](#IMarkdownMath) | ์ํ ๊ณต์ ์ค์ | `{ splitSymbol: 'dollar' }` |
|
|
256
|
-
| `onEnd` | `(data: EndData) => void` | ํ์ดํ ์๋ฃ ์ฝ๋ฐฑ | - |
|
|
257
|
-
| `onStart` | `(data: StartData) => void` | ํ์ดํ ์์ ์ฝ๋ฐฑ | - |
|
|
258
|
-
| `onBeforeTypedChar` | `(data: IBeforeTypedChar) => Promise<void>` | ๋ฌธ์ ํ์ดํ ์ ์ฝ๋ฐฑ, ๋น๋๊ธฐ ์์
์ง์, ํ์ ํ์ดํ ์ฐจ๋จ | - |
|
|
259
|
-
| `onTypedChar` | `(data: ITypedChar) => void` | ๋ฌธ์ ํ์ดํ ํ ์ฝ๋ฐฑ | - |
|
|
260
|
-
| `disableTyping` | `boolean` | ํ์ดํ ์ ๋๋ฉ์ด์
๋นํ์ฑํ | `false` |
|
|
261
|
-
| `autoStartTyping` | `boolean` | ํ์ดํ ์ ๋๋ฉ์ด์
์๋ ์์ ์ฌ๋ถ, false์ธ ๊ฒฝ์ฐ ์๋ ํธ๋ฆฌ๊ฑฐ | `true` |
|
|
262
|
-
|
|
263
|
-
> ์ฐธ๊ณ : ํ์ดํ ์ค์ `disableTyping`์ด `true`์์ `false`๋ก ๋ณ๊ฒฝ๋๋ฉด ๋ค์ ํ์ดํ ํธ๋ฆฌ๊ฑฐ ์ ๋จ์ ๋ชจ๋ ๋ฌธ์๊ฐ ํ ๋ฒ์ ํ์๋ฉ๋๋ค.
|
|
264
|
-
|
|
265
|
-
### IBeforeTypedChar
|
|
266
|
-
|
|
267
|
-
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
268
|
-
| -------------- | ------------ | ------------------------------ | ------ |
|
|
269
|
-
| `currentIndex` | `number` | ์ ์ฒด ๋ฌธ์์ด์์ ํ์ฌ ์ธ๋ฑ์ค | `0` |
|
|
270
|
-
| `currentChar` | `string` | ํ์ดํ ์์ ๋ฌธ์ | - |
|
|
271
|
-
| `answerType` | `AnswerType` | ์ฝํ
์ธ ํ์
(thinking/answer) | - |
|
|
272
|
-
| `prevStr` | `string` | ํ์ฌ ํ์
์ฝํ
์ธ ์ ์ด์ ๋ฌธ์์ด | - |
|
|
273
|
-
| `percent` | `number` | ํ์ดํ ์งํ๋ฅ ๋ฐฑ๋ถ์จ (0-100) | `0` |
|
|
274
|
-
|
|
275
|
-
### ITypedChar
|
|
276
|
-
|
|
277
|
-
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
278
|
-
| -------------- | ------------ | -------------------------------- | ------ |
|
|
279
|
-
| `currentIndex` | `number` | ์ ์ฒด ๋ฌธ์์ด์์ ํ์ฌ ์ธ๋ฑ์ค | `0` |
|
|
280
|
-
| `currentChar` | `string` | ํ์ดํ๋ ๋ฌธ์ | - |
|
|
281
|
-
| `answerType` | `AnswerType` | ์ฝํ
์ธ ํ์
(thinking/answer) | - |
|
|
282
|
-
| `prevStr` | `string` | ํ์ฌ ํ์
์ฝํ
์ธ ์ ์ด์ ๋ฌธ์์ด | - |
|
|
283
|
-
| `currentStr` | `string` | ํ์ฌ ํ์
์ฝํ
์ธ ์ ์์ ํ ๋ฌธ์์ด | - |
|
|
284
|
-
| `percent` | `number` | ํ์ดํ ์งํ๋ฅ ๋ฐฑ๋ถ์จ (0-100) | `0` |
|
|
285
|
-
|
|
286
|
-
#### IMarkdownMath
|
|
287
|
-
|
|
288
|
-
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
289
|
-
| ------------- | ------------------------- | ---------------- | ---------- |
|
|
290
|
-
| `splitSymbol` | `'dollar'` \| `'bracket'` | ์ํ ๊ณต์ ๊ตฌ๋ถ์ | `'dollar'` |
|
|
291
|
-
|
|
292
|
-
**๊ตฌ๋ถ์ ์ค๋ช
:**
|
|
293
|
-
|
|
294
|
-
- `'dollar'`: `$...$` ๋ฐ `$$...$$` ๊ตฌ๋ฌธ ์ฌ์ฉ
|
|
295
|
-
- `'bracket'`: `\(...\)` ๋ฐ `\[...\]` ๊ตฌ๋ฌธ ์ฌ์ฉ
|
|
296
|
-
|
|
297
|
-
#### IMarkdownPlugin
|
|
298
|
-
|
|
299
|
-
| ์์ฑ | ํ์
| ์ค๋ช
| ๊ธฐ๋ณธ๊ฐ |
|
|
300
|
-
| -------------- | ------------------------- | ---------------- | ------ |
|
|
301
|
-
| `remarkPlugin` | `unknown` | remark ํ๋ฌ๊ทธ์ธ | - |
|
|
302
|
-
| `rehypePlugin` | `unknown` | rehype ํ๋ฌ๊ทธ์ธ | - |
|
|
303
|
-
| `type` | `'buildIn'` \| `'custom'` | ํ๋ฌ๊ทธ์ธ ํ์
| - |
|
|
304
|
-
| `id` | `any` | ํ๋ฌ๊ทธ์ธ ๊ณ ์ ID | - |
|
|
305
|
-
|
|
306
|
-
### ์ปดํฌ๋ํธ ๋
ธ์ถ ๋ฉ์๋
|
|
307
|
-
|
|
308
|
-
#### ๊ธฐ๋ณธ ๋ด๋ณด๋ด๊ธฐ DsMarkdown
|
|
309
|
-
|
|
310
|
-
| ๋ฉ์๋ | ๋งค๊ฐ๋ณ์ | ์ค๋ช
|
|
|
311
|
-
| --------- | -------- | ----------------------------------------------------- |
|
|
312
|
-
| `start` | - | ํ์ดํ ์ ๋๋ฉ์ด์
์์ |
|
|
313
|
-
| `stop` | - | ํ์ดํ ์ผ์์ ์ง |
|
|
314
|
-
| `resume` | - | ํ์ดํ ์ฌ๊ฐ |
|
|
315
|
-
| `restart` | - | ํ์ดํ ์ ๋๋ฉ์ด์
์ฌ์์, ํ์ฌ ์ฝํ
์ธ ๋ฅผ ์ฒ์๋ถํฐ ์ฌ์ |
|
|
316
|
-
|
|
317
|
-
#### MarkdownCMD ๋
ธ์ถ ๋ฉ์๋
|
|
318
|
-
|
|
319
|
-
| ๋ฉ์๋ | ๋งค๊ฐ๋ณ์ | ์ค๋ช
|
|
|
320
|
-
| ----------------- | ------------------------------------------- | ----------------------------------------------------- |
|
|
321
|
-
| `push` | `(content: string, answerType: AnswerType)` | ์ฝํ
์ธ ์ถ๊ฐ ๋ฐ ํ์ดํ ์์ |
|
|
322
|
-
| `clear` | - | ๋ชจ๋ ์ฝํ
์ธ ๋ฐ ์ํ ์ง์ฐ๊ธฐ |
|
|
323
|
-
| `triggerWholeEnd` | - | ์๋์ผ๋ก ์๋ฃ ์ฝ๋ฐฑ ํธ๋ฆฌ๊ฑฐ |
|
|
324
|
-
| `start` | - | ํ์ดํ ์ ๋๋ฉ์ด์
์์ |
|
|
325
|
-
| `stop` | - | ํ์ดํ ์ผ์์ ์ง |
|
|
326
|
-
| `resume` | - | ํ์ดํ ์ฌ๊ฐ |
|
|
327
|
-
| `restart` | - | ํ์ดํ ์ ๋๋ฉ์ด์
์ฌ์์, ํ์ฌ ์ฝํ
์ธ ๋ฅผ ์ฒ์๋ถํฐ ์ฌ์ |
|
|
328
|
-
|
|
329
|
-
**์ฌ์ฉ ์:**
|
|
330
|
-
|
|
331
|
-
```tsx
|
|
332
|
-
markdownRef.current?.start(); // ์ ๋๋ฉ์ด์
์์
|
|
333
|
-
markdownRef.current?.stop(); // ์ ๋๋ฉ์ด์
์ผ์์ ์ง
|
|
334
|
-
markdownRef.current?.resume(); // ์ ๋๋ฉ์ด์
์ฌ๊ฐ
|
|
335
|
-
markdownRef.current?.restart(); // ์ ๋๋ฉ์ด์
์ฌ์์
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## ๐งฎ ์ํ ๊ณต์ ์ฌ์ฉ ๊ฐ์ด๋
|
|
341
|
-
|
|
342
|
-
[DEMO1: ํผํ๊ณ ๋ผ์ค ์ ๋ฆฌ](https://stackblitz.com/edit/vitejs-vite-z94syu8j?file=src%2FApp.tsx)
|
|
343
|
-
|
|
344
|
-
[DEMO2: ๋ฌธ์ ํด๋ต](https://stackblitz.com/edit/vitejs-vite-xk9lxagc?file=README.md)
|
|
345
|
-
|
|
346
|
-
### ๊ธฐ๋ณธ ๊ตฌ๋ฌธ
|
|
347
|
-
|
|
348
|
-
```tsx
|
|
349
|
-
import { katexPlugin } from 'ds-markdown/plugins';
|
|
350
|
-
|
|
351
|
-
// 1. ์ํ ๊ณต์ ์ง์ ํ์ฑํ
|
|
352
|
-
<DsMarkdown plugins={[katexPlugin]}>
|
|
353
|
-
# ์ํ ๊ณต์ ์์
|
|
354
|
-
|
|
355
|
-
// ์ธ๋ผ์ธ ๊ณต์
|
|
356
|
-
์ด๊ฒ์ ์ธ๋ผ์ธ ๊ณต์์
๋๋ค: $E = mc^2$
|
|
357
|
-
|
|
358
|
-
// ๋ธ๋ก ๊ณต์
|
|
359
|
-
$$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$
|
|
360
|
-
</DsMarkdown>
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
### ๊ตฌ๋ถ์ ์ ํ
|
|
364
|
-
|
|
365
|
-
```tsx
|
|
366
|
-
// ๋ฌ๋ฌ ๊ธฐํธ ๊ตฌ๋ถ์ ์ฌ์ฉ (๊ธฐ๋ณธ๊ฐ)
|
|
367
|
-
<DsMarkdown
|
|
368
|
-
plugins={[katexPlugin]}
|
|
369
|
-
math={{ splitSymbol: 'dollar' }}
|
|
370
|
-
>
|
|
371
|
-
์ธ๋ผ์ธ: $a + b = c$
|
|
372
|
-
๋ธ๋ก: $$\sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n$$
|
|
373
|
-
</DsMarkdown>
|
|
374
|
-
|
|
375
|
-
// ๊ดํธ ๊ตฌ๋ถ์ ์ฌ์ฉ
|
|
376
|
-
<DsMarkdown
|
|
377
|
-
plugins={[katexPlugin]}
|
|
378
|
-
math={{ splitSymbol: 'bracket' }}
|
|
379
|
-
>
|
|
380
|
-
์ธ๋ผ์ธ: \(a + b = c\)
|
|
381
|
-
๋ธ๋ก: \[\sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n\]
|
|
382
|
-
</DsMarkdown>
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
### ์คํธ๋ฆฌ๋ฐ ์ํ ๊ณต์
|
|
386
|
-
|
|
387
|
-
```tsx
|
|
388
|
-
// ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ์์ ์ํ ๊ณต์์ ์๋ฒฝํ๊ฒ ์ง์
|
|
389
|
-
const mathContent = [
|
|
390
|
-
'ํผํ๊ณ ๋ผ์ค ์ ๋ฆฌ:',
|
|
391
|
-
'$a^2 + b^2 = c^2$',
|
|
392
|
-
'\n\n',
|
|
393
|
-
'์ฌ๊ธฐ์:',
|
|
394
|
-
'- $a$์ $b$๋ ์ง๊ฐ๋ณ\n',
|
|
395
|
-
'- $c$๋ ๋น๋ณ\n\n',
|
|
396
|
-
'๊ณ ์ ์ ์ธ "๊ตฌ์ผ๊ณ ์ฌํ์ค"์ ๊ฒฝ์ฐ:\n',
|
|
397
|
-
'$c = \\sqrt{3^2 + 4^2} = \\sqrt{25} = 5$\n\n',
|
|
398
|
-
'์ด ์ ๋ฆฌ๋ ๊ธฐํํ์์ ๊ด๋ฒ์ํ๊ฒ ์์ฉ๋ฉ๋๋ค!',
|
|
399
|
-
];
|
|
400
|
-
|
|
401
|
-
mathContent.forEach((chunk) => {
|
|
402
|
-
markdownRef.current?.push(chunk, 'answer');
|
|
403
|
-
});
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### ์คํ์ผ ์ปค์คํฐ๋ง์ด์ง
|
|
407
|
-
|
|
408
|
-
```css
|
|
409
|
-
/* ์ํ ๊ณต์ ์คํ์ผ ์ปค์คํฐ๋ง์ด์ง */
|
|
410
|
-
.katex {
|
|
411
|
-
font-size: 1.1em;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
.katex-display {
|
|
415
|
-
margin: 1em 0;
|
|
416
|
-
text-align: center;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/* ๋คํฌ ํ
๋ง ์ ์ */
|
|
420
|
-
[data-theme='dark'] .katex {
|
|
421
|
-
color: #e1e1e1;
|
|
422
|
-
}
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
---
|
|
426
|
-
|
|
427
|
-
## ๐ ํ๋ฌ๊ทธ์ธ ์์คํ
|
|
428
|
-
|
|
429
|
-
### ๋ด์ฅ ํ๋ฌ๊ทธ์ธ
|
|
430
|
-
|
|
431
|
-
#### KaTeX ์ํ ๊ณต์ ํ๋ฌ๊ทธ์ธ
|
|
432
|
-
|
|
433
|
-
```tsx
|
|
434
|
-
import { katexPlugin } from 'ds-markdown/plugins';
|
|
435
|
-
|
|
436
|
-
// ์ํ ๊ณต์ ์ง์ ํ์ฑํ
|
|
437
|
-
<DsMarkdown plugins={[katexPlugin]}>์ํ ๊ณต์: $E = mc^2$</DsMarkdown>;
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
### ์ปค์คํ
ํ๋ฌ๊ทธ์ธ
|
|
441
|
-
|
|
442
|
-
```tsx
|
|
443
|
-
import { createBuildInPlugin } from 'ds-markdown/plugins';
|
|
444
|
-
|
|
445
|
-
// ์ปค์คํ
ํ๋ฌ๊ทธ์ธ ์์ฑ
|
|
446
|
-
const customPlugin = createBuildInPlugin({
|
|
447
|
-
remarkPlugin: yourRemarkPlugin,
|
|
448
|
-
rehypePlugin: yourRehypePlugin,
|
|
449
|
-
id: Symbol('custom-plugin'),
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
// ์ปค์คํ
ํ๋ฌ๊ทธ์ธ ์ฌ์ฉ
|
|
453
|
-
<DsMarkdown plugins={[katexPlugin, customPlugin]}>์ฝํ
์ธ </DsMarkdown>;
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
---
|
|
457
|
-
|
|
458
|
-
## ๐๏ธ ํ์ด๋จธ ๋ชจ๋ ์์ธ
|
|
459
|
-
|
|
460
|
-
### `requestAnimationFrame` ๋ชจ๋ ๐ (๊ถ์ฅ)
|
|
461
|
-
|
|
462
|
-
```typescript
|
|
463
|
-
// ๐ฏ ํน์ง
|
|
464
|
-
- ์๊ฐ ๊ธฐ๋ฐ: ์ค์ ๊ฒฝ๊ณผ ์๊ฐ์ ๋ฐํ์ผ๋ก ๋ฌธ์ ์ ๊ณ์ฐ
|
|
465
|
-
- ๋ฐฐ์น ์ฒ๋ฆฌ: ๋จ์ผ ํ๋ ์ ๋ด์์ ์ฌ๋ฌ ๋ฌธ์ ์ฒ๋ฆฌ ๊ฐ๋ฅ
|
|
466
|
-
- ํ๋ ์ ๋๊ธฐํ: ๋ธ๋ผ์ฐ์ 60fps ์๋ก๊ณ ์นจ ์๋์ ๋๊ธฐํ
|
|
467
|
-
- ๊ณ ์ฃผํ ์ต์ ํ: interval < 16ms์ ๊ณ ์ ํ์ดํ์ ์๋ฒฝํ๊ฒ ์ง์
|
|
468
|
-
|
|
469
|
-
// ๐ฏ ์ ์ฉ ์๋๋ฆฌ์ค
|
|
470
|
-
- ํ๋ ์น ์ ํ๋ฆฌ์ผ์ด์
์ ๊ธฐ๋ณธ ์ ํ
|
|
471
|
-
- ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
ํจ๊ณผ ์ถ๊ตฌ
|
|
472
|
-
- ๊ณ ์ฃผํ ํ์ดํ (interval > 0์ผ๋ก ์ถฉ๋ถ)
|
|
473
|
-
- AI ์ค์๊ฐ ๋ํ ์๋๋ฆฌ์ค
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
### `setTimeout` ๋ชจ๋ ๐ (ํธํ)
|
|
477
|
-
|
|
478
|
-
```typescript
|
|
479
|
-
// ๐ฏ ํน์ง
|
|
480
|
-
- ๋จ์ผ ๋ฌธ์: ๋งค๋ฒ ์ ํํ ํ ๋ฌธ์์ฉ ์ฒ๋ฆฌ
|
|
481
|
-
- ๊ณ ์ ๊ฐ๊ฒฉ: ์ค์ ๋ ์๊ฐ์ ๋ฐ๋ผ ์๊ฒฉํ๊ฒ ์คํ
|
|
482
|
-
- ๋ฆฌ๋ฌ๊ฐ: ํด๋์ ํ์๊ธฐ์ ๋ฆฌ๋ฌ๊ฐ
|
|
483
|
-
- ์ ๋ฐ ์ ์ด: ํน์ ํ์ด๋ฐ ์๊ตฌ์ฌํญ์ ์ ํฉ
|
|
484
|
-
|
|
485
|
-
// ๐ฏ ์ ์ฉ ์๋๋ฆฌ์ค
|
|
486
|
-
- ์ ๋ฐํ ์๊ฐ ์ ์ด๊ฐ ํ์ํ ๊ฒฝ์ฐ
|
|
487
|
-
- ๋ ํธ๋ก ํ์๊ธฐ ํจ๊ณผ ์ฐ์ถ
|
|
488
|
-
- ํธํ์ฑ ์๊ตฌ์ฌํญ์ด ๋์ ์๋๋ฆฌ์ค
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
### ๐ ์ฑ๋ฅ ๋น๊ต
|
|
492
|
-
|
|
493
|
-
| ํน์ง | requestAnimationFrame | setTimeout |
|
|
494
|
-
| ----------------- | ---------------------------------- | ---------------- |
|
|
495
|
-
| **๋ฌธ์ ์ฒ๋ฆฌ** | ํ๋ ์๋น ์ฌ๋ฌ ๋ฌธ์ | ํ ๋ฒ์ ํ ๋ฌธ์ |
|
|
496
|
-
| **๊ณ ์ฃผํ** | โ
์ฐ์ (5ms โ ํ๋ ์๋น 3๋ฌธ์) | โ ์ง์ฐ ๊ฐ๋ฅ์ฑ |
|
|
497
|
-
| **์ ์ฃผํ** | โ
์ ์ (100ms โ 6ํ๋ ์ ํ 1๋ฌธ์) | โ
์ ๋ฐ |
|
|
498
|
-
| **์๊ฐ์ ํจ๊ณผ** | ๐ฌ ๋ถ๋๋ฌ์ด ์ ๋๋ฉ์ด์
๊ฐ๊ฐ | โก ์ ๋ฐํ ๋ฆฌ๋ฌ๊ฐ |
|
|
499
|
-
| **์ฑ๋ฅ ์ค๋ฒํค๋** | ๐ข ๋ฎ์ (ํ๋ ์ ๋๊ธฐํ) | ๐ก ๋ณดํต (ํ์ด๋จธ) |
|
|
500
|
-
|
|
501
|
-
๊ณ ์ฃผํ๋ `requestAnimationFrame` ๊ถ์ฅ, ์ ์ฃผํ๋ `setTimeout` ๊ถ์ฅ
|
|
502
|
-
|
|
503
|
-
---
|
|
504
|
-
|
|
505
|
-
## ๐ก ์ค์ ์์
|
|
506
|
-
|
|
507
|
-
### ๐ AI ์คํธ๋ฆฌ๋ฐ ๋ํ
|
|
508
|
-
|
|
509
|
-
[DEMO: ๐ง StackBlitz ์ฒดํ](https://stackblitz.com/edit/vitejs-vite-2ri8kex3?file=src%2FApp.tsx)
|
|
510
|
-
|
|
511
|
-
````tsx
|
|
512
|
-
import { useRef } from 'react';
|
|
513
|
-
import { MarkdownCMD, MarkdownCMDRef } from 'ds-markdown';
|
|
514
|
-
|
|
515
|
-
function StreamingChat() {
|
|
516
|
-
const markdownRef = useRef<MarkdownCMDRef>(null);
|
|
517
|
-
|
|
518
|
-
// AI ์คํธ๋ฆฌ๋ฐ ์๋ต ์๋ฎฌ๋ ์ด์
|
|
519
|
-
const simulateAIResponse = async () => {
|
|
520
|
-
markdownRef.current?.clear();
|
|
521
|
-
|
|
522
|
-
// ์ฌ๊ณ ๋จ๊ณ
|
|
523
|
-
markdownRef.current?.push('๐ค ์ง๋ฌธ์ ๋ถ์ ์ค์
๋๋ค...', 'thinking');
|
|
524
|
-
await delay(1000);
|
|
525
|
-
markdownRef.current?.push('\n\nโ
๋ถ์ ์๋ฃ, ๋ต๋ณ ์์', 'thinking');
|
|
526
|
-
|
|
527
|
-
// ์คํธ๋ฆฌ๋ฐ ๋ต๋ณ
|
|
528
|
-
const chunks = [
|
|
529
|
-
'# React 19 ์ ๊ธฐ๋ฅ ๋ถ์\n\n',
|
|
530
|
-
'## ๐ React Compiler\n',
|
|
531
|
-
'React 19์ ๊ฐ์ฅ ํฐ ํ์ด๋ผ์ดํธ๋ **React Compiler** ๋์
์
๋๋ค:\n\n',
|
|
532
|
-
'- ๐ฏ **์๋ ์ต์ ํ**: ์๋ memo์ useMemo ๋ถํ์\n',
|
|
533
|
-
'- โก **์ฑ๋ฅ ํฅ์**: ์ปดํ์ผ ํ์ ์ต์ ํ, ๋ฐํ์ ์ ๋ก ์ค๋ฒํค๋\n',
|
|
534
|
-
'- ๐ง **ํ๋ฐฉ ํธํ์ฑ**: ๊ธฐ์กด ์ฝ๋ ์์ ๋ถํ์\n\n',
|
|
535
|
-
'## ๐ Actions๋ก ํผ ๊ฐ์ํ\n',
|
|
536
|
-
'์๋ก์ด Actions API๋ก ํผ ์ฒ๋ฆฌ๊ฐ ๋ ๊ฐ๋จํด์ง๋๋ค:\n\n',
|
|
537
|
-
'```tsx\n',
|
|
538
|
-
'function ContactForm({ action }) {\n',
|
|
539
|
-
' const [state, formAction] = useActionState(action, null);\n',
|
|
540
|
-
' return (\n',
|
|
541
|
-
' <form action={formAction}>\n',
|
|
542
|
-
' <input name="email" type="email" />\n',
|
|
543
|
-
' <button>์ ์ถ</button>\n',
|
|
544
|
-
' </form>\n',
|
|
545
|
-
' );\n',
|
|
546
|
-
'}\n',
|
|
547
|
-
'```\n\n',
|
|
548
|
-
'์ด ๋ต๋ณ์ด ๋์์ด ๋์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค! ๐',
|
|
549
|
-
];
|
|
550
|
-
|
|
551
|
-
for (const chunk of chunks) {
|
|
552
|
-
await delay(100);
|
|
553
|
-
markdownRef.current?.push(chunk, 'answer');
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
return (
|
|
558
|
-
<div className="chat-container">
|
|
559
|
-
<button onClick={simulateAIResponse}>๐ค React 19 ์ ๊ธฐ๋ฅ์ ๋ํด ์ง๋ฌธ</button>
|
|
560
|
-
|
|
561
|
-
<MarkdownCMD ref={markdownRef} interval={10} timerType="requestAnimationFrame" onEnd={(data) => console.log('์น์
์๋ฃ:', data)} />
|
|
562
|
-
</div>
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
567
|
-
````
|
|
568
|
-
|
|
569
|
-
### ๐งฎ ์ํ ๊ณต์ ์คํธ๋ฆฌ๋ฐ ๋ ๋๋ง
|
|
570
|
-
|
|
571
|
-
```tsx
|
|
572
|
-
import { katexPlugin } from 'ds-markdown/plugins';
|
|
573
|
-
|
|
574
|
-
function MathStreamingDemo() {
|
|
575
|
-
const markdownRef = useRef<MarkdownCMDRef>(null);
|
|
576
|
-
|
|
577
|
-
const simulateMathResponse = async () => {
|
|
578
|
-
markdownRef.current?.clear();
|
|
579
|
-
|
|
580
|
-
const mathChunks = [
|
|
581
|
-
'# ํผํ๊ณ ๋ผ์ค ์ ๋ฆฌ ์์ธ ์ค๋ช
\n\n',
|
|
582
|
-
'์ง๊ฐ์ผ๊ฐํ์์ ๋น๋ณ์ ์ ๊ณฑ์ ๋ ์ง๊ฐ๋ณ์ ์ ๊ณฑ์ ํฉ๊ณผ ๊ฐ์ต๋๋ค:\n\n',
|
|
583
|
-
'$a^2 + b^2 = c^2$\n\n',
|
|
584
|
-
'์ฌ๊ธฐ์:\n',
|
|
585
|
-
'- $a$์ $b$๋ ์ง๊ฐ๋ณ\n',
|
|
586
|
-
'- $c$๋ ๋น๋ณ\n\n',
|
|
587
|
-
'๊ณ ์ ์ ์ธ "๊ตฌ์ผ๊ณ ์ฌํ์ค"์ ๊ฒฝ์ฐ:\n',
|
|
588
|
-
'$c = \\sqrt{3^2 + 4^2} = \\sqrt{25} = 5$\n\n',
|
|
589
|
-
'์ด ์ ๋ฆฌ๋ ๊ธฐํํ์์ ๊ด๋ฒ์ํ๊ฒ ์์ฉ๋ฉ๋๋ค!',
|
|
590
|
-
];
|
|
591
|
-
|
|
592
|
-
for (const chunk of mathChunks) {
|
|
593
|
-
await delay(150);
|
|
594
|
-
markdownRef.current?.push(chunk, 'answer');
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
return (
|
|
599
|
-
<div>
|
|
600
|
-
<button onClick={simulateMathResponse}>๐ ํผํ๊ณ ๋ผ์ค ์ ๋ฆฌ ์ค๋ช
</button>
|
|
601
|
-
|
|
602
|
-
<MarkdownCMD ref={markdownRef} interval={20} timerType="requestAnimationFrame" plugins={[katexPlugin]} math={{ splitSymbol: 'dollar' }} />
|
|
603
|
-
</div>
|
|
604
|
-
);
|
|
605
|
-
}
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
## ๐ง ๋ชจ๋ฒ ์ฌ๋ก
|
|
609
|
-
|
|
610
|
-
### 1. ์ฑ๋ฅ ์ต์ ํ
|
|
611
|
-
|
|
612
|
-
```tsx
|
|
613
|
-
// โ
๊ถ์ฅ ๊ตฌ์ฑ
|
|
614
|
-
<DsMarkdown
|
|
615
|
-
timerType="requestAnimationFrame"
|
|
616
|
-
interval={15} // 15-30ms๊ฐ ์ต์ ๊ฒฝํ
|
|
617
|
-
/>
|
|
618
|
-
|
|
619
|
-
// โ ๋๋ฌด ์์ ๊ฐ๊ฒฉ ํผํ๊ธฐ
|
|
620
|
-
<DsMarkdown interval={1} /> // ์ฑ๋ฅ ๋ฌธ์ ์ผ๊ธฐ ๊ฐ๋ฅ
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
### 2. ์คํธ๋ฆฌ๋ฐ ๋ฐ์ดํฐ ์ฒ๋ฆฌ
|
|
624
|
-
|
|
625
|
-
```tsx
|
|
626
|
-
// โ
๊ถ์ฅ: ๋ช
๋ นํ API
|
|
627
|
-
const ref = useRef<MarkdownCMDRef>(null);
|
|
628
|
-
useEffect(() => {
|
|
629
|
-
ref.current?.push(newChunk, 'answer');
|
|
630
|
-
}, [newChunk]);
|
|
631
|
-
|
|
632
|
-
// โ ํผํ๊ธฐ: ๋น๋ฒํ children ์
๋ฐ์ดํธ
|
|
633
|
-
const [content, setContent] = useState('');
|
|
634
|
-
// ๊ฐ ์
๋ฐ์ดํธ๋ง๋ค ์ ์ฒด ๋ด์ฉ์ ์ฌ๋ถ์
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
### 3. ์ํ ๊ณต์ ์ต์ ํ
|
|
638
|
-
|
|
639
|
-
```tsx
|
|
640
|
-
// โ
๊ถ์ฅ: ํ์์ ์ํ ๊ณต์ ์คํ์ผ ๋ก๋
|
|
641
|
-
import 'ds-markdown/style.css';
|
|
642
|
-
import 'ds-markdown/katex.css'; // ํ์ํ ๋๋ง ๊ฐ์ ธ์ค๊ธฐ
|
|
643
|
-
|
|
644
|
-
// โ
๊ถ์ฅ: ์ ์ ํ ๊ตฌ๋ถ์ ์ฌ์ฉ
|
|
645
|
-
// ๊ฐ๋จํ ๊ณต์์๋ $...$๊ฐ ๋ ๊ฐ๊ฒฐ
|
|
646
|
-
// ๋ณต์กํ ๊ณต์์๋ $$...$$๊ฐ ๋ ๋ช
ํ
|
|
647
|
-
|
|
648
|
-
// โ
๊ถ์ฅ: ํ๋ฌ๊ทธ์ธ ๊ตฌ์ฑ
|
|
649
|
-
import { katexPlugin } from 'ds-markdown/plugins';
|
|
650
|
-
<DsMarkdown plugins={[katexPlugin]}>์ํ ๊ณต์ ๋ด์ฉ</DsMarkdown>;
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
### 4. ํ์
์์ ์ฑ
|
|
654
|
-
|
|
655
|
-
```tsx
|
|
656
|
-
import { MarkdownCMDRef } from 'ds-markdown';
|
|
657
|
-
|
|
658
|
-
const ref = useRef<MarkdownCMDRef>(null);
|
|
659
|
-
// ์์ ํ TypeScript ํ์
ํํธ
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
### ๐ ์ ๋๋ฉ์ด์
์ฌ์์ ๋ฐ๋ชจ
|
|
663
|
-
|
|
664
|
-
```tsx
|
|
665
|
-
import { useRef, useState } from 'react';
|
|
666
|
-
import { MarkdownCMD, MarkdownCMDRef } from 'ds-markdown';
|
|
667
|
-
|
|
668
|
-
function RestartDemo() {
|
|
669
|
-
const markdownRef = useRef<MarkdownCMDRef>(null);
|
|
670
|
-
const [isPlaying, setIsPlaying] = useState(false);
|
|
671
|
-
const [hasStarted, setHasStarted] = useState(false);
|
|
672
|
-
|
|
673
|
-
const startContent = () => {
|
|
674
|
-
markdownRef.current?.clear();
|
|
675
|
-
markdownRef.current?.push(
|
|
676
|
-
'# ์ ๋๋ฉ์ด์
์ฌ์์ ๋ฐ๋ชจ\n\n' +
|
|
677
|
-
'์ด ์์ ๋ `restart()` ๋ฉ์๋์ ์ฌ์ฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:\n\n' +
|
|
678
|
-
'- ๐ **์ฌ์์**: ํ์ฌ ์ฝํ
์ธ ๋ฅผ ์ฒ์๋ถํฐ ์ฌ์\n' +
|
|
679
|
-
'- โธ๏ธ **์ผ์์ ์ง/์ฌ๊ฐ**: ์ธ์ ๋ ์ง ์ผ์์ ์ง์ ์ฌ๊ฐ ๊ฐ๋ฅ\n' +
|
|
680
|
-
'- ๐ฏ **์ ๋ฐ ์ ์ด**: ์ ๋๋ฉ์ด์
์ฌ์ ์ํ์ ์์ ํ ์ ์ด\n\n' +
|
|
681
|
-
'ํ์ฌ ์ํ: ' +
|
|
682
|
-
(isPlaying ? '์ฌ์ ์ค' : '์ผ์์ ์ง') +
|
|
683
|
-
'\n\n' +
|
|
684
|
-
'์ด๋ ๋งค์ฐ ์ค์ฉ์ ์ธ ๊ธฐ๋ฅ์
๋๋ค!',
|
|
685
|
-
'answer',
|
|
686
|
-
);
|
|
687
|
-
setIsPlaying(true);
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
const handleStart = () => {
|
|
691
|
-
if (hasStarted) {
|
|
692
|
-
// ์ด๋ฏธ ์์๋ ๊ฒฝ์ฐ ์ฌ์์
|
|
693
|
-
markdownRef.current?.restart();
|
|
694
|
-
} else {
|
|
695
|
-
// ์ฒซ ๋ฒ์งธ ์์
|
|
696
|
-
markdownRef.current?.start();
|
|
697
|
-
setHasStarted(true);
|
|
698
|
-
}
|
|
699
|
-
setIsPlaying(true);
|
|
700
|
-
};
|
|
701
|
-
|
|
702
|
-
const handleStop = () => {
|
|
703
|
-
markdownRef.current?.stop();
|
|
704
|
-
setIsPlaying(false);
|
|
705
|
-
};
|
|
706
|
-
|
|
707
|
-
const handleResume = () => {
|
|
708
|
-
markdownRef.current?.resume();
|
|
709
|
-
setIsPlaying(true);
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
const handleRestart = () => {
|
|
713
|
-
markdownRef.current?.restart();
|
|
714
|
-
setIsPlaying(true);
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
const handleEnd = () => {
|
|
718
|
-
setIsPlaying(false);
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
return (
|
|
722
|
-
<div>
|
|
723
|
-
<div style={{ marginBottom: '10px', display: 'flex', gap: '10px', flexWrap: 'wrap' }}>
|
|
724
|
-
<button onClick={startContent}>๐ ์ฝํ
์ธ ์์</button>
|
|
725
|
-
<button onClick={handleStart} disabled={isPlaying}>
|
|
726
|
-
{hasStarted ? '๐ ์ฌ์์' : 'โถ๏ธ ์์'}
|
|
727
|
-
</button>
|
|
728
|
-
<button onClick={handleStop} disabled={!isPlaying}>
|
|
729
|
-
โธ๏ธ ์ผ์์ ์ง
|
|
730
|
-
</button>
|
|
731
|
-
<button onClick={handleResume} disabled={isPlaying}>
|
|
732
|
-
โถ๏ธ ์ฌ๊ฐ
|
|
733
|
-
</button>
|
|
734
|
-
<button onClick={handleRestart}>๐ ์ฌ์์</button>
|
|
735
|
-
</div>
|
|
736
|
-
|
|
737
|
-
<div style={{ margin: '10px 0', padding: '10px', background: '#f5f5f5', borderRadius: '4px' }}>
|
|
738
|
-
<strong>์ ๋๋ฉ์ด์
์ํ:</strong> {isPlaying ? '๐ข ์ฌ์ ์ค' : '๐ด ์ผ์์ ์ง'}
|
|
739
|
-
</div>
|
|
740
|
-
|
|
741
|
-
<MarkdownCMD ref={markdownRef} interval={25} onEnd={handleEnd} />
|
|
742
|
-
</div>
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
```
|
|
746
|
-
|
|
747
|
-
### โถ๏ธ ์๋ ์์ ์ ๋๋ฉ์ด์
๋ฐ๋ชจ
|
|
748
|
-
|
|
749
|
-
```tsx
|
|
750
|
-
import { useRef, useState } from 'react';
|
|
751
|
-
import { MarkdownCMD, MarkdownCMDRef } from 'ds-markdown';
|
|
752
|
-
|
|
753
|
-
function StartDemo() {
|
|
754
|
-
const markdownRef = useRef<MarkdownCMDRef>(null);
|
|
755
|
-
const [isPlaying, setIsPlaying] = useState(false);
|
|
756
|
-
const [hasStarted, setHasStarted] = useState(false);
|
|
757
|
-
|
|
758
|
-
const loadContent = () => {
|
|
759
|
-
markdownRef.current?.clear();
|
|
760
|
-
markdownRef.current?.push(
|
|
761
|
-
'# ์๋ ์์ ์ ๋๋ฉ์ด์
๋ฐ๋ชจ\n\n' +
|
|
762
|
-
'์ด ์์ ๋ `start()` ๋ฉ์๋์ ์ฌ์ฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:\n\n' +
|
|
763
|
-
'- ๐ฏ **์๋ ์ ์ด**: `autoStartTyping=false`์ผ ๋ ์๋์ผ๋ก `start()`๋ฅผ ํธ์ถํด์ผ ํฉ๋๋ค\n' +
|
|
764
|
-
'- โฑ๏ธ **์ง์ฐ ์์**: ์ฌ์ฉ์ ์ํธ์์ฉ ํ ์ ๋๋ฉ์ด์
์ ์์ํ ์ ์์ต๋๋ค\n' +
|
|
765
|
-
'- ๐ฎ **๊ฒ์ํ**: ์ฌ์ฉ์์ ์ ๊ทน์ฑ์ด ํ์ํ ์๋๋ฆฌ์ค์ ์ ํฉํฉ๋๋ค\n\n' +
|
|
766
|
-
'"์ ๋๋ฉ์ด์
์์" ๋ฒํผ์ ํด๋ฆญํ์ฌ ํ์ดํ ํจ๊ณผ๋ฅผ ์๋์ผ๋ก ํธ๋ฆฌ๊ฑฐํ์ธ์!',
|
|
767
|
-
'answer',
|
|
768
|
-
);
|
|
769
|
-
setIsPlaying(false);
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
const handleStart = () => {
|
|
773
|
-
if (hasStarted) {
|
|
774
|
-
// ์ด๋ฏธ ์์๋ ๊ฒฝ์ฐ ์ฌ์์
|
|
775
|
-
markdownRef.current?.restart();
|
|
776
|
-
} else {
|
|
777
|
-
// ์ฒซ ๋ฒ์งธ ์์
|
|
778
|
-
markdownRef.current?.start();
|
|
779
|
-
setHasStarted(true);
|
|
780
|
-
}
|
|
781
|
-
setIsPlaying(true);
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
const handleEnd = () => {
|
|
785
|
-
setIsPlaying(false);
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
return (
|
|
789
|
-
<div>
|
|
790
|
-
<div style={{ marginBottom: '10px', display: 'flex', gap: '10px', flexWrap: 'wrap' }}>
|
|
791
|
-
<button onClick={loadContent}>๐ ์ฝํ
์ธ ๋ก๋</button>
|
|
792
|
-
<button onClick={handleStart} disabled={isPlaying}>
|
|
793
|
-
{hasStarted ? '๐ ์ฌ์์' : 'โถ๏ธ ์ ๋๋ฉ์ด์
์์'}
|
|
794
|
-
</button>
|
|
795
|
-
</div>
|
|
796
|
-
|
|
797
|
-
<div style={{ margin: '10px 0', padding: '10px', background: '#f5f5f5', borderRadius: '4px' }}>
|
|
798
|
-
<strong>์ํ:</strong> {isPlaying ? '๐ข ์ ๋๋ฉ์ด์
์ฌ์ ์ค' : '๐ด ์์ ๋๊ธฐ ์ค'}
|
|
799
|
-
</div>
|
|
800
|
-
|
|
801
|
-
<MarkdownCMD ref={markdownRef} interval={30} autoStartTyping={false} onEnd={handleEnd} />
|
|
802
|
-
</div>
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
```
|