cms-block-editor 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 [Your Name]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # CMS Block Editor
2
+
3
+ A powerful, feature-rich block editor for CMS applications built with Lexical and React. Create beautiful, responsive content with an intuitive editing experience.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/cms-block-editor.svg)](https://www.npmjs.com/package/cms-block-editor)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ ✨ **Rich Text Editing** - Full formatting support (bold, italic, underline, headings, lists, etc.)
11
+ 🎨 **Sections** - 10 pre-designed section templates (hero, features, pricing, testimonials, etc.)
12
+ 📐 **Layouts** - Flexbox and CSS Grid support with visual controls
13
+ 🖼️ **Images** - Upload, resize, and drag-and-drop images
14
+ 🎥 **Embeds** - YouTube, Facebook, Instagram, Twitter, TikTok, Vimeo, Spotify, SoundCloud
15
+ 🔗 **Links** - Custom link insertion with labels and options
16
+ 🎨 **Styling** - Background colors, images, gradients, opacity controls
17
+ 📱 **Responsive** - Mobile-first design with automatic responsive behavior
18
+ 💾 **Export/Import** - HTML and Markdown support
19
+ 🎯 **Section Editor** - Full control over section layout, spacing, and styling
20
+ ⚡ **Performance** - Optimized rendering and minimal bundle size
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install cms-block-editor
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```tsx
31
+ import { CMSBlockEditor } from 'cms-block-editor';
32
+ import 'cms-block-editor/dist/index.css';
33
+
34
+ function App() {
35
+ const [content, setContent] = useState('');
36
+
37
+ return (
38
+ <CMSBlockEditor
39
+ value={content}
40
+ onChange={(editorState) => {
41
+ setContent(JSON.stringify(editorState));
42
+ }}
43
+ />
44
+ );
45
+ }
46
+ ```
47
+
48
+ ## Rendering Content
49
+
50
+ ```tsx
51
+ import { CMSRenderer } from 'cms-block-editor';
52
+ import 'cms-block-editor/dist/index.css';
53
+
54
+ function BlogPost({ content }) {
55
+ return (
56
+ <article>
57
+ <CMSRenderer content={content} />
58
+ </article>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ## Core Components
64
+
65
+ ### CMSBlockEditor
66
+
67
+ Main editor component with full editing capabilities.
68
+
69
+ **Props:**
70
+ - `value?: string` - Initial editor state (JSON string)
71
+ - `onChange?: (state: any) => void` - Callback fired when content changes
72
+
73
+ ### CMSRenderer
74
+
75
+ Read-only renderer for displaying saved content.
76
+
77
+ **Props:**
78
+ - `content: string` - Serialized editor state (JSON string)
79
+ - `className?: string` - Additional CSS classes
80
+
81
+ ## Available Features
82
+
83
+ ### Text Formatting
84
+ - Headings (H1, H2, H3)
85
+ - Bold, Italic, Underline, Strikethrough
86
+ - Inline code
87
+ - Text alignment (left, center, right, justify)
88
+ - Bullet and numbered lists
89
+ - Blockquotes
90
+ - Code blocks
91
+
92
+ ### Media
93
+ - **Images**: Upload from computer, resize with 8-point handles, drag-and-drop positioning
94
+ - **YouTube**: Embed videos with custom sizing
95
+ - **Embeds**: Support for 8+ platforms with automatic URL detection
96
+
97
+ ### Sections
98
+ 10 pre-designed templates:
99
+ - Hero Section
100
+ - Features Grid
101
+ - Call to Action
102
+ - Testimonial
103
+ - Pricing Table
104
+ - Team Members
105
+ - Statistics
106
+ - FAQ Section
107
+ - Contact Form
108
+ - Newsletter Signup
109
+
110
+ ### Section Controls
111
+ - Background colors (30 presets + custom)
112
+ - Background images with gradient overlays
113
+ - Layout types (Block, Flex, Grid)
114
+ - Flexbox controls (direction, wrap, align, justify)
115
+ - CSS Grid controls (columns, rows)
116
+ - Spacing controls (padding, margin, gap)
117
+ - Text alignment
118
+ - Opacity control
119
+
120
+ ### Export & Import
121
+ - Export to HTML (clean or with styles)
122
+ - Export to Markdown
123
+ - Import from HTML
124
+ - Import from Markdown
125
+ - Download as files
126
+ - Copy to clipboard
127
+
128
+ ## Advanced Usage
129
+
130
+ ### With Persistence
131
+
132
+ ```tsx
133
+ import { CMSBlockEditor } from 'cms-block-editor';
134
+
135
+ function Editor() {
136
+ const [content, setContent] = useState(() => {
137
+ return localStorage.getItem('content') || '';
138
+ });
139
+
140
+ const handleChange = (state) => {
141
+ const serialized = JSON.stringify(state);
142
+ setContent(serialized);
143
+ localStorage.setItem('content', serialized);
144
+ };
145
+
146
+ return <CMSBlockEditor value={content} onChange={handleChange} />;
147
+ }
148
+ ```
149
+
150
+ ### Export Utilities
151
+
152
+ ```tsx
153
+ import {
154
+ exportToHTML,
155
+ exportToMarkdown,
156
+ downloadHTML,
157
+ downloadMarkdown
158
+ } from 'cms-block-editor';
159
+
160
+ // Export to HTML string
161
+ const html = exportToHTML(editor);
162
+
163
+ // Export to Markdown string
164
+ const markdown = exportToMarkdown(editor);
165
+
166
+ // Download as file
167
+ downloadHTML(editor, 'content.html', { includeStyles: true });
168
+ downloadMarkdown(editor, 'content.md');
169
+ ```
170
+
171
+ ### Import Utilities
172
+
173
+ ```tsx
174
+ import {
175
+ importFromHTML,
176
+ importFromMarkdown
177
+ } from 'cms-block-editor';
178
+
179
+ // Import HTML
180
+ importFromHTML(editor, '<h1>Hello World</h1>');
181
+
182
+ // Import Markdown
183
+ importFromMarkdown(editor, '# Hello World');
184
+ ```
185
+
186
+ ## Styling
187
+
188
+ The editor comes with default styles. Import the CSS file:
189
+
190
+ ```tsx
191
+ import 'cms-block-editor/dist/index.css';
192
+ ```
193
+
194
+ ### Custom Styling
195
+
196
+ Override default styles with your own CSS:
197
+
198
+ ```css
199
+ .cms-editor-shell {
200
+ border: 2px solid #your-color;
201
+ border-radius: 8px;
202
+ }
203
+
204
+ .cms-toolbar {
205
+ background: #your-color;
206
+ }
207
+
208
+ .cms-section {
209
+ /* Custom section styles */
210
+ }
211
+ ```
212
+
213
+ ## Browser Support
214
+
215
+ - Chrome/Edge (latest)
216
+ - Firefox (latest)
217
+ - Safari (latest)
218
+ - Mobile browsers (iOS Safari, Chrome Mobile)
219
+
220
+ ## TypeScript Support
221
+
222
+ Full TypeScript support with type definitions included.
223
+
224
+ ```tsx
225
+ import { CMSBlockEditor, CMSRenderer } from 'cms-block-editor';
226
+ import type { SerializedEditorState } from 'lexical';
227
+ ```
228
+
229
+ ## Performance
230
+
231
+ - Optimized rendering with Lexical
232
+ - Minimal re-renders
233
+ - Lazy loading of plugins
234
+ - Small bundle size (~200KB minified)
235
+ - Tree-shakeable exports
236
+
237
+ ## Examples
238
+
239
+ Check out the [example app](./example-app) for a complete implementation with:
240
+ - Basic editor
241
+ - Persistence with localStorage
242
+ - Custom styling
243
+ - All features demonstrated
244
+
245
+ ## Documentation
246
+
247
+ Comprehensive guides available:
248
+ - [Section Creator Guide](./SECTION-CREATOR-GUIDE.md)
249
+ - [Section Editing Guide](./SECTION-EDITING-GUIDE.md)
250
+ - [Background Image Guide](./BACKGROUND-IMAGE-GUIDE.md)
251
+ - [Embed Guide](./EMBED-GUIDE.md)
252
+ - [Responsive Rendering Guide](./RESPONSIVE-RENDERING-GUIDE.md)
253
+
254
+ ## Contributing
255
+
256
+ Contributions are welcome! Please feel free to submit a Pull Request.
257
+
258
+ ## License
259
+
260
+ MIT © [Your Name]
261
+
262
+ ## Support
263
+
264
+ For issues and questions:
265
+ - [GitHub Issues](https://github.com/yourusername/cms-block-editor/issues)
266
+ - [Documentation](https://github.com/yourusername/cms-block-editor#readme)
267
+
268
+ ## Acknowledgments
269
+
270
+ Built with:
271
+ - [Lexical](https://lexical.dev/) - Extensible text editor framework
272
+ - [React](https://react.dev/) - UI library
273
+ - [React Icons](https://react-icons.github.io/react-icons/) - Icon library