@twelvemonday/blog-editor 1.0.3

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 ADDED
@@ -0,0 +1,104 @@
1
+ # @twelvemonday/blog-editor
2
+
3
+ WordPress-style block blog editor for React. Drag-and-drop blocks, rich paste, SEO panel, image resize, custom theming, and HTML serialization.
4
+
5
+ Published by [Twelve Monday](https://12monday.net).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @twelvemonday/blog-editor
11
+ ```
12
+
13
+ Peer dependencies:
14
+
15
+ ```bash
16
+ npm install react react-dom @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities lucide-react
17
+ ```
18
+
19
+ ## Image upload (`onUploadImage`)
20
+
21
+ Editor **kahan upload kare** ye tum decide karte ho. Sirf ek function pass karo — editor `File` bhejega, tum URL return karo.
22
+
23
+ Works for **featured image** and **image blocks**.
24
+
25
+ ```tsx
26
+ <BlogEditor
27
+ onUploadImage={async (file) => {
28
+ // S3, Cloudinary, apni API — jo marzi
29
+ const form = new FormData();
30
+ form.append('file', file);
31
+ const res = await fetch('https://your-api.com/upload', { method: 'POST', body: form });
32
+ const { url } = await res.json();
33
+ return url; // public image URL string
34
+ }}
35
+ // ...
36
+ />
37
+ ```
38
+
39
+ Agar `onUploadImage` nahi doge to file picker hide rahega — user image **URL** se add kar sakta hai.
40
+
41
+ `uploadFile` prop ab deprecated hai — `onUploadImage` use karo.
42
+
43
+ ## Quick start
44
+
45
+ ```tsx
46
+ 'use client';
47
+
48
+ import '@twelvemonday/blog-editor/styles.css';
49
+ import { BlogEditor, type EditorDocument } from '@twelvemonday/blog-editor';
50
+
51
+ export function AdminEditor({ post }: { post: EditorDocument }) {
52
+ return (
53
+ <BlogEditor
54
+ initial={post}
55
+ backHref="/admin/posts"
56
+ previewUrl={(slug) => `/blogs/${slug}`}
57
+ siteName="My Site"
58
+ baseUrl="https://example.com"
59
+ theme={{ primary: '#04644A', primaryHover: '#035239' }}
60
+ onUploadImage={async (file) => {
61
+ const form = new FormData();
62
+ form.append('file', file);
63
+ const res = await fetch('/api/upload', { method: 'POST', body: form });
64
+ const { url } = await res.json();
65
+ return url;
66
+ }}
67
+ onSave={async (doc) => {
68
+ await fetch('/api/posts', {
69
+ method: 'POST',
70
+ headers: { 'Content-Type': 'application/json' },
71
+ body: JSON.stringify(doc),
72
+ });
73
+ return { slug: doc.slug };
74
+ }}
75
+ />
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Theming
81
+
82
+ | Key | Default | Description |
83
+ |-----|---------|-------------|
84
+ | `primary` | `#04644A` | Buttons, accents, focus |
85
+ | `primaryHover` | `#035239` | Primary hover |
86
+ | `primaryMuted` | `#f0fdf4` | Light backgrounds |
87
+ | `background` | `#f0f0f1` | Editor chrome |
88
+ | `surface` | `#ffffff` | Canvas / panels |
89
+
90
+ ## HTML utilities
91
+
92
+ ```ts
93
+ import { htmlToBlocks, blocksToHtml } from '@twelvemonday/blog-editor';
94
+ ```
95
+
96
+ ## Tailwind
97
+
98
+ ```css
99
+ @source "../node_modules/@twelvemonday/blog-editor/dist/**/*.js";
100
+ ```
101
+
102
+ ## License
103
+
104
+ MIT