@ryzeup/richtexteditor 1.0.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 +249 -0
- package/dist/index.es.js +1511 -0
- package/dist/index.umd.js +22 -0
- package/dist/richtexteditor.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# π texteditor β A Modern React Rich Text Editor
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
> β¨ A lightweight, fully customizable **Rich Text Editor for React** β built with **TypeScript**, **Vite**, and **React 19**.
|
|
10
|
+
> Create visually appealing messages with custom fonts, colors, media, and more β in just a few lines of code.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## π Features
|
|
15
|
+
|
|
16
|
+
β
Built with **React + TypeScript**
|
|
17
|
+
β
Bundled using **Vite** (super fast builds)
|
|
18
|
+
β
Customizable toolbar β bold, italic, underline, color, alignment, etc.
|
|
19
|
+
β
Supports **images**, **links**, **videos**, and **emojis**
|
|
20
|
+
β
Includes **TypeScript types**
|
|
21
|
+
β
CSS bundled or importable separately
|
|
22
|
+
β
Lightweight & dependency-minimal
|
|
23
|
+
β
Plug-and-play usage
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## π¦ Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Using npm
|
|
31
|
+
npm install @shaikabdularshad/texteditor
|
|
32
|
+
|
|
33
|
+
# Or yarn
|
|
34
|
+
yarn add @shaikabdularshad/texteditor
|
|
35
|
+
|
|
36
|
+
# Or pnpm
|
|
37
|
+
pnpm add @shaikabdularshad/texteditor
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## βοΈ Peer Dependencies
|
|
42
|
+
|
|
43
|
+
Make sure your project includes React:
|
|
44
|
+
|
|
45
|
+
npm install react react-dom
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## π§© Usage
|
|
51
|
+
|
|
52
|
+
1οΈβ£ Import the component
|
|
53
|
+
import React from 'react';
|
|
54
|
+
import { RichTextEditor } from 'texteditor';
|
|
55
|
+
import 'texteditor/dist/style.css'; // import styles if not auto-bundled
|
|
56
|
+
|
|
57
|
+
2οΈβ£ Use it in your app
|
|
58
|
+
function App() {
|
|
59
|
+
return (
|
|
60
|
+
<RichTextEditor
|
|
61
|
+
atSuggestions={["@Arshad", "@Irfan", "@Meera"]}
|
|
62
|
+
showOutput={true}
|
|
63
|
+
showPreview={true}
|
|
64
|
+
toolbarConfig={{
|
|
65
|
+
link: true,
|
|
66
|
+
image: true,
|
|
67
|
+
emoji: true,
|
|
68
|
+
table: true,
|
|
69
|
+
color: true,
|
|
70
|
+
fontFamily: true,
|
|
71
|
+
fontSize: true,
|
|
72
|
+
}}
|
|
73
|
+
classNames={{
|
|
74
|
+
wrapper: "custom-wrapper",
|
|
75
|
+
editor: "custom-editor",
|
|
76
|
+
}}
|
|
77
|
+
styles={{
|
|
78
|
+
editor: {
|
|
79
|
+
border: "1px solid #ccc",
|
|
80
|
+
padding: "12px",
|
|
81
|
+
minHeight: "200px",
|
|
82
|
+
borderRadius: "8px",
|
|
83
|
+
},
|
|
84
|
+
}}
|
|
85
|
+
handleGetHtml={(html) => console.log("Editor HTML:", html)}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default App;
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## π§ Props Reference
|
|
95
|
+
|
|
96
|
+
The RichTextEditor component is fully customizable via the following props:
|
|
97
|
+
|
|
98
|
+
Prop Type Default Description
|
|
99
|
+
atSuggestions string[] [] List of mention suggestions (e.g., ["@Arshad", "@Irfan", "@Meera""]). When the user types β@β, a popup appears showing these names.
|
|
100
|
+
showOutput boolean false Displays a live HTML preview of the editorβs content below the editor box. Useful for debugging or data preview.
|
|
101
|
+
showPreview boolean false Displays a rendered HTML preview beside the editor (using <RtePreview />).
|
|
102
|
+
toolbarConfig ToolbarConfig All false Controls which toolbar actions are visible. Example: { link: true, image: true, emoji: true }.
|
|
103
|
+
classNames { wrapper?: string; toolbar?: string; editor?: string; preview?: string; output?: string } {} Custom class names for different sections of the editor (useful for applying your own CSS).
|
|
104
|
+
styles { wrapper?: React.CSSProperties; toolbar?: React.CSSProperties; editor?: React.CSSProperties; preview?: React.CSSProperties; output?: React.CSSProperties } {} Inline styles for each section (wrapper, toolbar, editor, etc.).
|
|
105
|
+
handleGetHtml (html: string) => void () => {} Callback triggered whenever the editorβs HTML content changes. Returns sanitized HTML.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### π§° ToolbarConfig Type
|
|
111
|
+
|
|
112
|
+
You can control toolbar buttons selectively via this object:
|
|
113
|
+
|
|
114
|
+
Key Type Default Description
|
|
115
|
+
link boolean false Enables inserting hyperlinks.
|
|
116
|
+
image boolean false Enables inserting images (from local files).
|
|
117
|
+
emoji boolean false Enables emoji picker.
|
|
118
|
+
table boolean false Enables inserting and resizing tables.
|
|
119
|
+
color boolean false Enables text color picker.
|
|
120
|
+
fontFamily boolean false Enables font family dropdown.
|
|
121
|
+
fontSize boolean false Enables font size dropdown.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## π§° Build & Development
|
|
126
|
+
|
|
127
|
+
If you cloned or downloaded this repository, use the following scripts:
|
|
128
|
+
|
|
129
|
+
# Install dependencies
|
|
130
|
+
npm install
|
|
131
|
+
|
|
132
|
+
# Start dev server
|
|
133
|
+
npm run dev
|
|
134
|
+
|
|
135
|
+
# Build the library (for npm publish)
|
|
136
|
+
npm run build
|
|
137
|
+
|
|
138
|
+
# Lint code
|
|
139
|
+
npm run lint
|
|
140
|
+
|
|
141
|
+
# Preview the build
|
|
142
|
+
npm run preview
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
The build will output into the dist/ folder:
|
|
146
|
+
|
|
147
|
+
dist/
|
|
148
|
+
βββ index.js (CommonJS build)
|
|
149
|
+
βββ index.esm.js (ES Module build)
|
|
150
|
+
βββ index.d.ts (TypeScript types)
|
|
151
|
+
βββ style.css (Editor styles)
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## π Folder Structure
|
|
156
|
+
texteditor/
|
|
157
|
+
βββ src/
|
|
158
|
+
β βββ components/
|
|
159
|
+
β β βββ RteToolbar.tsx
|
|
160
|
+
β β βββ RtePreview.tsx
|
|
161
|
+
β β βββ ...
|
|
162
|
+
β βββ data/
|
|
163
|
+
β β βββ emojis.json
|
|
164
|
+
β βββ RichTextEditor.tsx
|
|
165
|
+
β βββ index.ts
|
|
166
|
+
β βββ style.css
|
|
167
|
+
βββ dist/
|
|
168
|
+
β βββ index.js
|
|
169
|
+
β βββ index.esm.js
|
|
170
|
+
β βββ style.css
|
|
171
|
+
βββ package.json
|
|
172
|
+
βββ tsconfig.json
|
|
173
|
+
βββ vite.config.ts
|
|
174
|
+
βββ README.md
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## βοΈ Tech Stack
|
|
179
|
+
|
|
180
|
+
React 19
|
|
181
|
+
|
|
182
|
+
TypeScript
|
|
183
|
+
|
|
184
|
+
Vite 7
|
|
185
|
+
|
|
186
|
+
ESLint
|
|
187
|
+
|
|
188
|
+
React Icons
|
|
189
|
+
|
|
190
|
+
Rollup (via Vite) for library bundling
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## π¨ Styling
|
|
195
|
+
Option 1 β Manual Import
|
|
196
|
+
|
|
197
|
+
If your build does not automatically include styles:
|
|
198
|
+
|
|
199
|
+
import 'texteditor/dist/style.css';
|
|
200
|
+
|
|
201
|
+
Option 2 β Automatic Bundling
|
|
202
|
+
|
|
203
|
+
If you import your CSS in src/index.ts:
|
|
204
|
+
|
|
205
|
+
import './style.css';
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Vite will automatically bundle your styles in the JS build.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## π§ͺ Example Output
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## π Troubleshooting
|
|
217
|
+
Issue Solution
|
|
218
|
+
CSS not applied Import texteditor/dist/style.css in your app
|
|
219
|
+
Cannot find module '../data/emojis.json' Add "resolveJsonModule": true to tsconfig.json
|
|
220
|
+
TypeScript import error (.tsx) Remove .tsx from imports (use import App from './App')
|
|
221
|
+
Toolbar icons missing Ensure react-icons is installed
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## π€ Contributing
|
|
226
|
+
|
|
227
|
+
Contributions, issues, and feature requests are welcome!
|
|
228
|
+
Feel free to open a PR or create an issue in the repository.
|
|
229
|
+
|
|
230
|
+
git clone https://github.com/<your-username>/texteditor.git
|
|
231
|
+
cd texteditor
|
|
232
|
+
npm install
|
|
233
|
+
npm run dev
|
|
234
|
+
|
|
235
|
+
π§Ύ License
|
|
236
|
+
|
|
237
|
+
This project is licensed under the MIT License β free for personal and commercial use.
|
|
238
|
+
|
|
239
|
+
π¬ Author
|
|
240
|
+
|
|
241
|
+
π¨βπ» Arshad Babblu
|
|
242
|
+
π Portfolio
|
|
243
|
+
|
|
244
|
+
π Support
|
|
245
|
+
|
|
246
|
+
If you find this project useful, please β it on GitHub
|
|
247
|
+
!
|
|
248
|
+
Your support motivates continued updates and improvements.
|
|
249
|
+
```
|