cms-block-editor 1.0.7 → 1.0.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 [Your Name]
3
+ Copyright (c) 2024 Samuel Clinton
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -11,7 +11,8 @@ A powerful, feature-rich block editor for CMS applications built with Lexical an
11
11
  ✨ **Rich Text Editing** - Full formatting support (bold, italic, underline, headings, lists, etc.)
12
12
  🎨 **Sections** - 10 pre-designed section templates (hero, features, pricing, testimonials, etc.)
13
13
  📐 **Layouts** - Flexbox and CSS Grid support with visual controls
14
- 🖼️ **Images** - Upload, resize, and drag-and-drop images
14
+ 🖼️ **Images** - Upload, resize, drag-and-drop, and advanced editing with filters
15
+ 🎨 **Image Filters** - 7 adjustable filters with 6 professional presets
15
16
  🎥 **Embeds** - YouTube, Facebook, Instagram, Twitter, TikTok, Vimeo, Spotify, SoundCloud
16
17
  🔗 **Links** - Custom link insertion with labels and options
17
18
  📊 **Tables** - Visual table builder with configurable rows/columns and professional styling
@@ -71,6 +72,8 @@ Main editor component with full editing capabilities.
71
72
  **Props:**
72
73
  - `value?: string` - Initial editor state (JSON string)
73
74
  - `onChange?: (state: any) => void` - Callback fired when content changes
75
+ - `onImageAdded?: (file: File) => Promise<string>` - Custom image upload handler that returns the image URL
76
+ - `useBase64Url?: boolean` - Use base64 encoding for images (default: `true`)
74
77
 
75
78
  ### CMSRenderer
76
79
 
@@ -92,7 +95,8 @@ Read-only renderer for displaying saved content.
92
95
  - Code blocks
93
96
 
94
97
  ### Media
95
- - **Images**: Upload from computer, resize with 8-point handles, drag-and-drop positioning
98
+ - **Images**: Upload from computer, resize with 8-point handles, drag-and-drop positioning, custom upload handler support, advanced editing with filters
99
+ - **Image Filters**: Brightness, contrast, saturation, blur, grayscale, sepia, hue rotation with 6 presets
96
100
  - **YouTube**: Embed videos with custom sizing
97
101
  - **Embeds**: Support for 8+ platforms with automatic URL detection
98
102
  - **Tables**: Visual builder with configurable dimensions, header rows, and professional styling
@@ -130,6 +134,47 @@ Read-only renderer for displaying saved content.
130
134
 
131
135
  ## Advanced Usage
132
136
 
137
+ ### Custom Image Upload
138
+
139
+ Upload images to your server instead of using base64 encoding:
140
+
141
+ ```tsx
142
+ import { CMSBlockEditor } from 'cms-block-editor';
143
+
144
+ function Editor() {
145
+ const [content, setContent] = useState('');
146
+
147
+ const handleImageUpload = async (file: File): Promise<string> => {
148
+ // Upload to your server
149
+ const formData = new FormData();
150
+ formData.append('image', file);
151
+
152
+ const response = await fetch('/api/upload', {
153
+ method: 'POST',
154
+ body: formData,
155
+ });
156
+
157
+ const data = await response.json();
158
+ return data.url; // Return the uploaded image URL
159
+ };
160
+
161
+ return (
162
+ <CMSBlockEditor
163
+ value={content}
164
+ onChange={(state) => setContent(JSON.stringify(state))}
165
+ onImageAdded={handleImageUpload}
166
+ useBase64Url={false}
167
+ />
168
+ );
169
+ }
170
+ ```
171
+
172
+ **Image Upload Options:**
173
+
174
+ - **With `onImageAdded`**: Provide a custom upload handler that uploads the file to your server and returns the URL
175
+ - **With `useBase64Url={true}`** (default): Images are encoded as base64 strings (no server upload needed)
176
+ - **With `useBase64Url={false}` and no `onImageAdded`**: Image upload will be disabled
177
+
133
178
  ### With Persistence
134
179
 
135
180
  ```tsx
@@ -248,6 +293,7 @@ Check out the [example app](./example-app) for a complete implementation with:
248
293
  ## Documentation
249
294
 
250
295
  Comprehensive guides available:
296
+ - [Image Editing Guide](./docs/IMAGE-EDITING-GUIDE.md) - Advanced image filters and effects
251
297
  - [Section Creator Guide](./SECTION-CREATOR-GUIDE.md)
252
298
  - [Section Editing Guide](./SECTION-EDITING-GUIDE.md)
253
299
  - [Background Image Guide](./BACKGROUND-IMAGE-GUIDE.md)
package/dist/index.css CHANGED
@@ -2299,6 +2299,229 @@
2299
2299
  height: 24px;
2300
2300
  }
2301
2301
  }
2302
+ .cms-image-editor-modal {
2303
+ position: fixed;
2304
+ top: 0;
2305
+ left: 0;
2306
+ right: 0;
2307
+ bottom: 0;
2308
+ z-index: 10000;
2309
+ display: flex;
2310
+ align-items: center;
2311
+ justify-content: center;
2312
+ }
2313
+ .cms-image-editor-overlay {
2314
+ position: absolute;
2315
+ top: 0;
2316
+ left: 0;
2317
+ right: 0;
2318
+ bottom: 0;
2319
+ background: rgba(0, 0, 0, 0.7);
2320
+ backdrop-filter: blur(4px);
2321
+ }
2322
+ .cms-image-editor-content {
2323
+ position: relative;
2324
+ background: white;
2325
+ border-radius: 12px;
2326
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
2327
+ max-width: 1200px;
2328
+ width: 90%;
2329
+ max-height: 90vh;
2330
+ display: flex;
2331
+ flex-direction: column;
2332
+ overflow: hidden;
2333
+ }
2334
+ .cms-image-editor-header {
2335
+ display: flex;
2336
+ justify-content: space-between;
2337
+ align-items: center;
2338
+ padding: 20px 24px;
2339
+ border-bottom: 1px solid #e5e7eb;
2340
+ }
2341
+ .cms-image-editor-header h2 {
2342
+ margin: 0;
2343
+ font-size: 20px;
2344
+ font-weight: 600;
2345
+ color: #1f2937;
2346
+ }
2347
+ .cms-close-btn {
2348
+ background: none;
2349
+ border: none;
2350
+ font-size: 32px;
2351
+ color: #6b7280;
2352
+ cursor: pointer;
2353
+ padding: 0;
2354
+ width: 32px;
2355
+ height: 32px;
2356
+ display: flex;
2357
+ align-items: center;
2358
+ justify-content: center;
2359
+ border-radius: 4px;
2360
+ transition: all 0.2s;
2361
+ }
2362
+ .cms-close-btn:hover {
2363
+ background: #f3f4f6;
2364
+ color: #1f2937;
2365
+ }
2366
+ .cms-image-editor-body {
2367
+ display: grid;
2368
+ grid-template-columns: 1fr 400px;
2369
+ gap: 24px;
2370
+ padding: 24px;
2371
+ overflow-y: auto;
2372
+ flex: 1;
2373
+ }
2374
+ .cms-image-editor-preview {
2375
+ display: flex;
2376
+ align-items: center;
2377
+ justify-content: center;
2378
+ background: #f9fafb;
2379
+ border-radius: 8px;
2380
+ padding: 24px;
2381
+ min-height: 400px;
2382
+ }
2383
+ .cms-image-editor-preview img {
2384
+ max-width: 100%;
2385
+ max-height: 500px;
2386
+ border-radius: 4px;
2387
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
2388
+ }
2389
+ .cms-image-editor-controls {
2390
+ display: flex;
2391
+ flex-direction: column;
2392
+ gap: 24px;
2393
+ overflow-y: auto;
2394
+ }
2395
+ .cms-editor-section {
2396
+ background: #f9fafb;
2397
+ padding: 16px;
2398
+ border-radius: 8px;
2399
+ }
2400
+ .cms-editor-section h3 {
2401
+ margin: 0 0 16px 0;
2402
+ font-size: 14px;
2403
+ font-weight: 600;
2404
+ color: #374151;
2405
+ text-transform: uppercase;
2406
+ letter-spacing: 0.5px;
2407
+ }
2408
+ .cms-preset-buttons {
2409
+ display: grid;
2410
+ grid-template-columns: repeat(3, 1fr);
2411
+ gap: 8px;
2412
+ }
2413
+ .cms-preset-buttons button {
2414
+ padding: 8px 12px;
2415
+ background: white;
2416
+ border: 1px solid #d1d5db;
2417
+ border-radius: 6px;
2418
+ font-size: 13px;
2419
+ font-weight: 500;
2420
+ color: #374151;
2421
+ cursor: pointer;
2422
+ transition: all 0.2s;
2423
+ }
2424
+ .cms-preset-buttons button:hover {
2425
+ background: #667eea;
2426
+ color: white;
2427
+ border-color: #667eea;
2428
+ }
2429
+ .cms-filter-control {
2430
+ margin-bottom: 16px;
2431
+ }
2432
+ .cms-filter-control:last-child {
2433
+ margin-bottom: 0;
2434
+ }
2435
+ .cms-filter-control label {
2436
+ display: block;
2437
+ font-size: 13px;
2438
+ font-weight: 500;
2439
+ color: #374151;
2440
+ margin-bottom: 8px;
2441
+ }
2442
+ .cms-filter-control input[type=range] {
2443
+ width: 100%;
2444
+ height: 6px;
2445
+ border-radius: 3px;
2446
+ background: #e5e7eb;
2447
+ outline: none;
2448
+ -webkit-appearance: none;
2449
+ }
2450
+ .cms-filter-control input[type=range]::-webkit-slider-thumb {
2451
+ -webkit-appearance: none;
2452
+ appearance: none;
2453
+ width: 18px;
2454
+ height: 18px;
2455
+ border-radius: 50%;
2456
+ background: #667eea;
2457
+ cursor: pointer;
2458
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
2459
+ }
2460
+ .cms-filter-control input[type=range]::-moz-range-thumb {
2461
+ width: 18px;
2462
+ height: 18px;
2463
+ border-radius: 50%;
2464
+ background: #667eea;
2465
+ cursor: pointer;
2466
+ border: none;
2467
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
2468
+ }
2469
+ .cms-crop-info {
2470
+ padding: 12px;
2471
+ background: white;
2472
+ border-radius: 6px;
2473
+ border: 1px solid #d1d5db;
2474
+ }
2475
+ .cms-crop-info p {
2476
+ margin: 0;
2477
+ font-size: 13px;
2478
+ color: #6b7280;
2479
+ }
2480
+ .cms-image-editor-footer {
2481
+ display: flex;
2482
+ justify-content: space-between;
2483
+ align-items: center;
2484
+ padding: 16px 24px;
2485
+ border-top: 1px solid #e5e7eb;
2486
+ background: #f9fafb;
2487
+ }
2488
+ .cms-image-editor-footer > div {
2489
+ display: flex;
2490
+ gap: 12px;
2491
+ }
2492
+ .cms-btn-primary,
2493
+ .cms-btn-secondary {
2494
+ padding: 10px 20px;
2495
+ border-radius: 6px;
2496
+ font-size: 14px;
2497
+ font-weight: 500;
2498
+ cursor: pointer;
2499
+ transition: all 0.2s;
2500
+ border: none;
2501
+ }
2502
+ .cms-btn-primary {
2503
+ background: #667eea;
2504
+ color: white;
2505
+ }
2506
+ .cms-btn-primary:hover {
2507
+ background: #5568d3;
2508
+ }
2509
+ .cms-btn-secondary {
2510
+ background: white;
2511
+ color: #374151;
2512
+ border: 1px solid #d1d5db;
2513
+ }
2514
+ .cms-btn-secondary:hover {
2515
+ background: #f3f4f6;
2516
+ }
2517
+ @media (max-width: 768px) {
2518
+ .cms-image-editor-body {
2519
+ grid-template-columns: 1fr;
2520
+ }
2521
+ .cms-preset-buttons {
2522
+ grid-template-columns: repeat(2, 1fr);
2523
+ }
2524
+ }
2302
2525
 
2303
2526
  /* src/styles/renderer.css */
2304
2527
  .cms-renderer {