math-rich-editor-pack 0.1.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.md +69 -0
- package/dist-lib/math-rich-editor-pack.css +1 -0
- package/dist-lib/math-rich-editor.cjs +3685 -0
- package/dist-lib/math-rich-editor.js +45188 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Math Rich Editor Pack
|
|
2
|
+
|
|
3
|
+
Reusable React editor with rich-text + inline math insertion (MathLive + Tiptap).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install math-rich-editor-pack
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { MathRichEditor } from 'math-rich-editor-pack'
|
|
15
|
+
import 'math-rich-editor-pack/style.css'
|
|
16
|
+
|
|
17
|
+
export default function QuestionForm() {
|
|
18
|
+
return (
|
|
19
|
+
<MathRichEditor
|
|
20
|
+
onChange={({ html, json, text, latexList }) => {
|
|
21
|
+
// Save the formats you need
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Callback API
|
|
29
|
+
|
|
30
|
+
- `onChange(payload)`
|
|
31
|
+
- `payload.html`
|
|
32
|
+
- `payload.json`
|
|
33
|
+
- `payload.text`
|
|
34
|
+
- `payload.latexList`
|
|
35
|
+
- `onHtmlChange(html)`
|
|
36
|
+
- `onJsonChange(json)`
|
|
37
|
+
- `onTextChange(text)`
|
|
38
|
+
- `onLatexChange(latexList)`
|
|
39
|
+
- `onMathInsert(latex)`
|
|
40
|
+
|
|
41
|
+
## Main Props
|
|
42
|
+
|
|
43
|
+
- `initialContent` (HTML string or JSON doc)
|
|
44
|
+
- `placeholder`
|
|
45
|
+
- `toolbarOptions`
|
|
46
|
+
- default: `['bold','italic','underline','h1','h2','ul','ol','undo','redo','math']`
|
|
47
|
+
- `mathShortcutEnabled` (default `true`)
|
|
48
|
+
- `mathShortcutKey` (default `'m'`, used with Ctrl/Cmd)
|
|
49
|
+
- `className`, `toolbarClassName`, `editorClassName`
|
|
50
|
+
- `composerTitle`, `composerDescription`, `composerInsertLabel`, `composerCancelLabel`
|
|
51
|
+
|
|
52
|
+
## Local Dev
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install
|
|
56
|
+
npm run dev
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Build Library
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm run build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Pack Tarball (local test)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm run pack:local
|
|
69
|
+
```
|