notra-editor 0.1.0 → 0.3.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 +95 -0
- package/dist/index.cjs +1195 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.mjs +1182 -8
- package/dist/index.mjs.map +1 -1
- package/dist/styles/globals.css +1141 -0
- package/dist/themes/default/editor.css +238 -0
- package/package.json +17 -5
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# notra-editor
|
|
2
|
+
|
|
3
|
+
A Markdown-first rich text editor for React, built on [Tiptap](https://tiptap.dev/).
|
|
4
|
+
|
|
5
|
+
- **Markdown as source of truth** - stores and outputs Markdown, renders as rich text
|
|
6
|
+
- **Two components** - `NotraEditor` for editing, `NotraReader` for static rendering
|
|
7
|
+
- **Lightweight** - minimal API surface, easy to integrate
|
|
8
|
+
- **React 18 & 19** compatible
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install notra-editor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### Editor
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { NotraEditor } from 'notra-editor';
|
|
22
|
+
import 'notra-editor/themes/default/shared.css';
|
|
23
|
+
import 'notra-editor/themes/default/editor.css';
|
|
24
|
+
import { useState } from 'react';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
const [content, setContent] = useState('# Hello\n\nStart writing...');
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<NotraEditor
|
|
31
|
+
value={content}
|
|
32
|
+
onChange={setContent}
|
|
33
|
+
placeholder="Start writing..."
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Reader
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { NotraReader } from 'notra-editor';
|
|
43
|
+
import 'notra-editor/themes/default/shared.css';
|
|
44
|
+
import 'notra-editor/themes/default/reader.css';
|
|
45
|
+
|
|
46
|
+
function Article({ markdown }: { markdown: string }) {
|
|
47
|
+
return <NotraReader content={markdown} />;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
### `<NotraEditor />`
|
|
54
|
+
|
|
55
|
+
| Prop | Type | Default | Description |
|
|
56
|
+
| ------------- | ------------------------- | ------- | ----------------------------- |
|
|
57
|
+
| `value` | `string` | - | Markdown content (controlled) |
|
|
58
|
+
| `onChange` | `(value: string) => void` | - | Called when content changes |
|
|
59
|
+
| `placeholder` | `string` | - | Placeholder text when empty |
|
|
60
|
+
| `readOnly` | `boolean` | `false` | Disable editing |
|
|
61
|
+
| `className` | `string` | - | Additional CSS class |
|
|
62
|
+
|
|
63
|
+
### `<NotraReader />`
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
| ----------- | -------- | ------- | -------------------------- |
|
|
67
|
+
| `content` | `string` | - | Markdown content to render |
|
|
68
|
+
| `className` | `string` | - | Additional CSS class |
|
|
69
|
+
|
|
70
|
+
## Supported Markdown
|
|
71
|
+
|
|
72
|
+
- Headings, paragraphs, blockquotes, horizontal rules
|
|
73
|
+
- **Bold**, _italic_, ~~strikethrough~~, `inline code`
|
|
74
|
+
- Ordered lists, bullet lists, task lists
|
|
75
|
+
- Code blocks
|
|
76
|
+
- Links
|
|
77
|
+
|
|
78
|
+
## Themes
|
|
79
|
+
|
|
80
|
+
Import theme CSS files to style the editor and reader:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// Shared styles (required for both editor and reader)
|
|
84
|
+
import 'notra-editor/themes/default/shared.css';
|
|
85
|
+
|
|
86
|
+
// Editor-specific styles
|
|
87
|
+
import 'notra-editor/themes/default/editor.css';
|
|
88
|
+
|
|
89
|
+
// Reader-specific styles
|
|
90
|
+
import 'notra-editor/themes/default/reader.css';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|