react-mathtype-editor 1.0.2 → 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
@@ -2,36 +2,35 @@
2
2
 
3
3
  一个独立的数学公式编辑器组件,基于 React 和 Ant Design 开发,提供两种公式编辑模式:基于 MathLive 的可视化编辑和基于 LaTeX 的文本编辑。
4
4
 
5
+ #### demo 演示:[demo](https\://math.yujun.cloud/)
6
+
5
7
  ## 特性
6
8
 
7
9
  - 🎨 **双模式编辑**:支持 MathLive 可视化编辑和 LaTeX 文本编辑
8
10
  - 🔍 **实时预览**:使用 KaTeX 进行高质量公式渲染
9
11
  - 📚 **丰富公式库**:内置数学、希腊字母、关系符号等多种预设公式
10
12
  - 📋 **智能粘贴**:自动处理粘贴的公式内容
11
- - 📱 **响应式设计**:适配不同屏幕尺寸
12
- - ⚡ **高性能**:优化的渲染和更新机制
13
13
 
14
14
  ![MathType Editor Screenshot](./assets/images/screenshot.png)
15
15
 
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