@mbs-dev/react-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
@@ -1 +1,139 @@
1
- # react-editor
1
+
2
+ # @mbs-dev/react-editor
3
+
4
+ A lightweight, typed React wrapper around **Jodit** rich-text editor, designed for real-world CRUD forms (blogs, products, CMS pages, etc.).
5
+
6
+ It provides:
7
+
8
+ - A **simple React component** `<ReactEditor />`
9
+ - A reusable **`config()` helper** for configuration
10
+ - An optional **`uploaderConfig()` helper** to handle image uploads and automatic insertion into the editor
11
+
12
+ ---
13
+
14
+ [![npm version](https://img.shields.io/npm/v/@mbs-dev/react-editor.svg)](https://www.npmjs.com/package/@mbs-dev/react-editor)
15
+ [![npm downloads](https://img.shields.io/npm/dm/@mbs-dev/react-editor.svg)](https://www.npmjs.com/package/@mbs-dev/react-editor)
16
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/@mbs-dev/react-editor.svg)](https://bundlephobia.com/package/@mbs-dev/react-editor)
17
+
18
+ ---
19
+
20
+ ## ✨ Features
21
+
22
+ - 🧩 **Simple React API**: controlled `value` + `onChange`
23
+ - βš™οΈ **Helper config**: `config()` to quickly build configuration
24
+ - πŸ–ΌοΈ **Image upload integration**: optional `uploaderConfig()` for file uploading + auto-insert `<img />`
25
+ - πŸ§ͺ **TypeScript-ready**: ships with types & TSX-friendly usage
26
+ - 🧱 **Library-friendly**: minimal surface area, built to be reused across apps
27
+
28
+ ---
29
+
30
+ ## πŸ“¦ Installation
31
+
32
+ ```bash
33
+ npm install @mbs-dev/react-editor
34
+ ```
35
+
36
+ ---
37
+
38
+ ## πŸš€ Quick Start
39
+
40
+ ```tsx
41
+ import React, { useMemo, useState } from 'react';
42
+ import ReactEditor, { config } from '@mbs-dev/react-editor';
43
+
44
+ const MyPage = () => {
45
+ const [content, setContent] = useState('');
46
+
47
+ const editorConfig = useMemo(() => config(false), []);
48
+
49
+ return (
50
+ <ReactEditor
51
+ config={editorConfig}
52
+ value={content}
53
+ onChange={(value) => setContent(value)}
54
+ />
55
+ );
56
+ };
57
+ ```
58
+
59
+ ---
60
+
61
+ ## πŸ”§ Configuration Helpers
62
+
63
+ ### `config(includeUploader?: boolean, apiUrl?: string, imageUrl?: string)`
64
+
65
+ ### `uploaderConfig(apiUrl?: string, imageUrl?: string)`
66
+
67
+ Both helpers simplify setting up configuration and upload support.
68
+
69
+ ---
70
+
71
+ ## 🧩 Symfony API Platform Example (Recommended Integration)
72
+
73
+ If your backend is **Symfony + API Platform**, here is the **most common real‑world setup**:
74
+
75
+ ### **πŸ“Œ 1. Expose your upload endpoint**
76
+
77
+ In your Symfony API (`config/routes.yaml`):
78
+
79
+ ```yaml
80
+ upload_image:
81
+ path: /upload
82
+ controller: App\Controller\ImageUploadController
83
+ methods: [POST]
84
+ ```
85
+
86
+ ### **πŸ“Œ 2. Store uploaded images in `/public/uploads/images`**
87
+
88
+ ```php
89
+ // App/Controller/ImageUploadController.php
90
+
91
+ public function __invoke(Request $request): JsonResponse
92
+ {
93
+ $files = $request->files->get('files');
94
+ $storedFiles = [];
95
+
96
+ foreach ($files as $file) {
97
+ $newName = uniqid().'.'.$file->guessExtension();
98
+ $file->move($this->getParameter('kernel.project_dir').'/public/uploads/images', $newName);
99
+ $storedFiles[] = $newName;
100
+ }
101
+
102
+ return new JsonResponse([
103
+ 'success' => true,
104
+ 'data' => [
105
+ 'files' => $storedFiles,
106
+ 'messages' => [],
107
+ ],
108
+ 'msg' => 'Upload successful'
109
+ ]);
110
+ }
111
+ ```
112
+
113
+ ### **πŸ“Œ 3. Front-end React configuration**
114
+
115
+ ```ts
116
+ export const uploadUrl = `${apiUrl}/upload`;
117
+ export const blogPostImgUrl = `${uploadUrl}/images`;
118
+
119
+ const editorConfig = useMemo(
120
+ () => config(
121
+ true, // enable uploader
122
+ `${apiUrl}/upload`, // Symfony upload endpoint
123
+ blogPostImgUrl // URL to access public images
124
+ ),
125
+ []
126
+ );
127
+ ```
128
+
129
+ This will automatically insert images as:
130
+
131
+ ```html
132
+ <img src="https://your-domain.com/uploads/images/filename.webp" />
133
+ ```
134
+
135
+ ---
136
+
137
+ ## πŸ“ License
138
+
139
+ MIT β€” feel free to use it in commercial and private applications.
package/dist/Editor.js CHANGED
@@ -80,6 +80,7 @@ var config = function (includeUploader, apiUrl, imageUrl) { return ({
80
80
  'ol',
81
81
  '|',
82
82
  'image',
83
+ 'file',
83
84
  '|',
84
85
  'video',
85
86
  '|',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbs-dev/react-editor",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "react editor",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
package/src/Editor.tsx CHANGED
@@ -93,7 +93,7 @@ export const config = (includeUploader?: boolean | undefined, apiUrl?: string |
93
93
  'ol',
94
94
  '|',
95
95
  'image',
96
- // 'file',
96
+ 'file',
97
97
  '|',
98
98
  'video',
99
99
  '|',