react-mathtype-editor 1.0.5 → 1.0.6
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 +49 -2
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +120 -102
- package/dist/types/MathTypeEditor.d.ts +6 -1
- package/dist/types/MathTypeEditor.d.ts.map +1 -1
- package/dist/types/index.types.d.ts +1 -1
- package/dist/types/index.types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,8 @@ const MathTypeEditor = dynamic(
|
|
|
77
77
|
|------|------|--------|------|
|
|
78
78
|
| defaultValue | string | '' | 默认的 LaTeX 公式 |
|
|
79
79
|
| onChange | (value: string) => void | - | 公式变化时的回调函数 |
|
|
80
|
-
|
|
|
80
|
+
| className | string | - | 附加到组件根节点的类名 |
|
|
81
|
+
| style | MathTypeEditorStyle | - | 根节点样式,支持 `--mathtype-*` CSS 变量 |
|
|
81
82
|
|
|
82
83
|
## 功能说明
|
|
83
84
|
|
|
@@ -181,4 +182,50 @@ npm run build
|
|
|
181
182
|
|
|
182
183
|
## 许可证
|
|
183
184
|
|
|
184
|
-
MIT
|
|
185
|
+
MIT
|
|
186
|
+
## 主题配置
|
|
187
|
+
|
|
188
|
+
使用带 `--mathtype-` 前缀的 CSS 自定义属性,不依赖宿主 UI 框架或全局 `--primary`。
|
|
189
|
+
默认值写在变量的回退值中,因此可以从父容器继承,也可以使用 `className` 或 `style` 为单个实例设置主题。
|
|
190
|
+
不需要覆盖内部类名或使用 `!important`。主题变量只控制编辑器;弹窗和确认按钮由宿主负责。
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import MathTypeEditor, { type MathTypeEditorStyle } from 'react-mathtype-editor'
|
|
194
|
+
|
|
195
|
+
const editorStyle: MathTypeEditorStyle = {
|
|
196
|
+
width: '100%',
|
|
197
|
+
'--mathtype-primary': '#00cc7e',
|
|
198
|
+
'--mathtype-primary-hover': '#00b26e',
|
|
199
|
+
'--mathtype-focus-ring': 'rgba(0, 204, 126, 0.18)',
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
<MathTypeEditor className="course-formula-editor" style={editorStyle} />
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
也可在应用样式表中设置(不同实例互不影响):
|
|
206
|
+
|
|
207
|
+
```css
|
|
208
|
+
.course-formula-editor {
|
|
209
|
+
--mathtype-primary: #00cc7e;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* 在父容器设置后,内部所有编辑器都会继承。 */
|
|
213
|
+
.course-panel {
|
|
214
|
+
--mathtype-primary: #00cc7e;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
| 变量 | 默认值 | 用途 |
|
|
219
|
+
|------|--------|------|
|
|
220
|
+
| `--mathtype-primary` | `#1677ff` | 分类选中、下划线、公式 hover 和 MathLive 光标 |
|
|
221
|
+
| `--mathtype-primary-hover` | 跟随 primary | 分类 hover 和 LaTeX 输入边框 |
|
|
222
|
+
| `--mathtype-focus-ring` | primary 的 18% 透明色 | LaTeX 聚焦光环 |
|
|
223
|
+
| `--mathtype-primary-surface` | primary 的 10% 透明色(MathLive 选择区为 18%) | 分类翻页 hover 背景和 MathLive 选择区 |
|
|
224
|
+
| `--mathtype-text` | `rgba(0, 0, 0, 0.88)` | 正文文字 |
|
|
225
|
+
| `--mathtype-muted` | 各控件原有次要文字颜色 | 提示和次要文字 |
|
|
226
|
+
| `--mathtype-background` | `#fff` | 编辑器和输入区域背景 |
|
|
227
|
+
| `--mathtype-surface` | 各控件原有浅灰色 | 模式切换和分类翻页背景 |
|
|
228
|
+
| `--mathtype-border` | 各控件原有浅灰色 | 输入框边框和分类分隔线 |
|
|
229
|
+
|
|
230
|
+
透明色默认使用标准 `color-mix()` 推导。需要支持不具备该 CSS 能力的旧浏览器时,请显式传入 `--mathtype-focus-ring` 和 `--mathtype-primary-surface` 的 `rgba()` 值。
|
|
231
|
+
组件自身样式均限定在 `.react-mathtype-editor` 内。
|