react-mathtype-editor 1.0.3 → 1.0.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.md CHANGED
@@ -16,22 +16,21 @@
16
16
  ## 安装
17
17
 
18
18
  ```bash
19
- npm install react-mathtype-editor
19
+ npm install react-mathtype-editor katex mathlive
20
20
  ```
21
21
 
22
22
  ## 使用方法
23
23
 
24
- ```
24
+ ```tsx
25
25
  import React, { useState } from 'react';
26
26
  import MathTypeEditor from 'react-mathtype-editor';
27
- import 'react-mathtype-editor/dist/style.css';
28
27
 
29
28
  function App() {
30
29
  const [formula, setFormula] = useState('');
31
30
 
32
31
  return (
33
32
  <div>
34
- <MathTypeEditor
33
+ <MathTypeEditor
35
34
  defaultValue={formula}
36
35
  onChange={(value) => setFormula(value)}
37
36
  style={{ width: '100%' }}
@@ -43,6 +42,33 @@ function App() {
43
42
  export default App;
44
43
  ```
45
44
 
45
+ ## 在 SSR 框架中使用(Next.js 等)
46
+
47
+ 该组件依赖 MathLive(Web Component),需要浏览器环境,**不支持服务端渲染**。在 Next.js 中需使用动态导入并禁用 SSR:
48
+
49
+ **App Router:**
50
+
51
+ ```tsx
52
+ 'use client'
53
+ import dynamic from 'next/dynamic'
54
+
55
+ const MathTypeEditor = dynamic(
56
+ () => import('react-mathtype-editor'),
57
+ { ssr: false }
58
+ )
59
+ ```
60
+
61
+ **Pages Router:**
62
+
63
+ ```tsx
64
+ import dynamic from 'next/dynamic'
65
+
66
+ const MathTypeEditor = dynamic(
67
+ () => import('react-mathtype-editor'),
68
+ { ssr: false }
69
+ )
70
+ ```
71
+
46
72
  ## API
47
73
 
48
74
  ### Props