cms-block-editor 1.0.5 → 1.0.9
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 +1 -1
- package/README.md +47 -1
- package/dist/index.css +317 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +791 -494
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A powerful, feature-rich block editor for CMS applications built with Lexical an
|
|
|
14
14
|
🖼️ **Images** - Upload, resize, and drag-and-drop images
|
|
15
15
|
🎥 **Embeds** - YouTube, Facebook, Instagram, Twitter, TikTok, Vimeo, Spotify, SoundCloud
|
|
16
16
|
🔗 **Links** - Custom link insertion with labels and options
|
|
17
|
+
📊 **Tables** - Visual table builder with configurable rows/columns and professional styling
|
|
17
18
|
🎨 **Styling** - Background colors, images, gradients, opacity controls
|
|
18
19
|
📱 **Responsive** - Mobile-first design with automatic responsive behavior
|
|
19
20
|
💾 **Export/Import** - HTML and Markdown support
|
|
@@ -70,6 +71,8 @@ Main editor component with full editing capabilities.
|
|
|
70
71
|
**Props:**
|
|
71
72
|
- `value?: string` - Initial editor state (JSON string)
|
|
72
73
|
- `onChange?: (state: any) => void` - Callback fired when content changes
|
|
74
|
+
- `onImageAdded?: (file: File) => Promise<string>` - Custom image upload handler that returns the image URL
|
|
75
|
+
- `useBase64Url?: boolean` - Use base64 encoding for images (default: `true`)
|
|
73
76
|
|
|
74
77
|
### CMSRenderer
|
|
75
78
|
|
|
@@ -91,9 +94,10 @@ Read-only renderer for displaying saved content.
|
|
|
91
94
|
- Code blocks
|
|
92
95
|
|
|
93
96
|
### Media
|
|
94
|
-
- **Images**: Upload from computer, resize with 8-point handles, drag-and-drop positioning
|
|
97
|
+
- **Images**: Upload from computer, resize with 8-point handles, drag-and-drop positioning, custom upload handler support
|
|
95
98
|
- **YouTube**: Embed videos with custom sizing
|
|
96
99
|
- **Embeds**: Support for 8+ platforms with automatic URL detection
|
|
100
|
+
- **Tables**: Visual builder with configurable dimensions, header rows, and professional styling
|
|
97
101
|
|
|
98
102
|
### Sections
|
|
99
103
|
10 pre-designed templates:
|
|
@@ -128,6 +132,47 @@ Read-only renderer for displaying saved content.
|
|
|
128
132
|
|
|
129
133
|
## Advanced Usage
|
|
130
134
|
|
|
135
|
+
### Custom Image Upload
|
|
136
|
+
|
|
137
|
+
Upload images to your server instead of using base64 encoding:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { CMSBlockEditor } from 'cms-block-editor';
|
|
141
|
+
|
|
142
|
+
function Editor() {
|
|
143
|
+
const [content, setContent] = useState('');
|
|
144
|
+
|
|
145
|
+
const handleImageUpload = async (file: File): Promise<string> => {
|
|
146
|
+
// Upload to your server
|
|
147
|
+
const formData = new FormData();
|
|
148
|
+
formData.append('image', file);
|
|
149
|
+
|
|
150
|
+
const response = await fetch('/api/upload', {
|
|
151
|
+
method: 'POST',
|
|
152
|
+
body: formData,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const data = await response.json();
|
|
156
|
+
return data.url; // Return the uploaded image URL
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<CMSBlockEditor
|
|
161
|
+
value={content}
|
|
162
|
+
onChange={(state) => setContent(JSON.stringify(state))}
|
|
163
|
+
onImageAdded={handleImageUpload}
|
|
164
|
+
useBase64Url={false}
|
|
165
|
+
/>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Image Upload Options:**
|
|
171
|
+
|
|
172
|
+
- **With `onImageAdded`**: Provide a custom upload handler that uploads the file to your server and returns the URL
|
|
173
|
+
- **With `useBase64Url={true}`** (default): Images are encoded as base64 strings (no server upload needed)
|
|
174
|
+
- **With `useBase64Url={false}` and no `onImageAdded`**: Image upload will be disabled
|
|
175
|
+
|
|
131
176
|
### With Persistence
|
|
132
177
|
|
|
133
178
|
```tsx
|
|
@@ -250,6 +295,7 @@ Comprehensive guides available:
|
|
|
250
295
|
- [Section Editing Guide](./SECTION-EDITING-GUIDE.md)
|
|
251
296
|
- [Background Image Guide](./BACKGROUND-IMAGE-GUIDE.md)
|
|
252
297
|
- [Embed Guide](./EMBED-GUIDE.md)
|
|
298
|
+
- [Table Guide](./TABLE-GUIDE.md)
|
|
253
299
|
- [Responsive Rendering Guide](./RESPONSIVE-RENDERING-GUIDE.md)
|
|
254
300
|
|
|
255
301
|
## Contributing
|
package/dist/index.css
CHANGED
|
@@ -2058,6 +2058,247 @@
|
|
|
2058
2058
|
width: 100%;
|
|
2059
2059
|
}
|
|
2060
2060
|
}
|
|
2061
|
+
.cms-table-plugin {
|
|
2062
|
+
position: relative;
|
|
2063
|
+
display: inline-block;
|
|
2064
|
+
}
|
|
2065
|
+
.cms-table-modal {
|
|
2066
|
+
position: fixed;
|
|
2067
|
+
background: white;
|
|
2068
|
+
border: 1px solid #e0e0e0;
|
|
2069
|
+
border-radius: 12px;
|
|
2070
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
|
|
2071
|
+
width: 450px;
|
|
2072
|
+
max-width: 90vw;
|
|
2073
|
+
max-height: 85vh;
|
|
2074
|
+
overflow-y: auto;
|
|
2075
|
+
z-index: 10002;
|
|
2076
|
+
animation: slideDown 0.2s ease-out;
|
|
2077
|
+
top: 50%;
|
|
2078
|
+
left: 50%;
|
|
2079
|
+
transform: translate(-50%, -50%);
|
|
2080
|
+
}
|
|
2081
|
+
.cms-table-modal-header {
|
|
2082
|
+
padding: 16px 20px;
|
|
2083
|
+
border-bottom: 1px solid #e0e0e0;
|
|
2084
|
+
background:
|
|
2085
|
+
linear-gradient(
|
|
2086
|
+
135deg,
|
|
2087
|
+
#667eea 0%,
|
|
2088
|
+
#764ba2 100%);
|
|
2089
|
+
color: white;
|
|
2090
|
+
border-radius: 12px 12px 0 0;
|
|
2091
|
+
font-weight: 600;
|
|
2092
|
+
font-size: 14px;
|
|
2093
|
+
}
|
|
2094
|
+
.cms-table-modal-content {
|
|
2095
|
+
padding: 20px;
|
|
2096
|
+
display: flex;
|
|
2097
|
+
flex-direction: column;
|
|
2098
|
+
gap: 20px;
|
|
2099
|
+
}
|
|
2100
|
+
.cms-table-preview {
|
|
2101
|
+
background: #f8f9fa;
|
|
2102
|
+
padding: 20px;
|
|
2103
|
+
border-radius: 8px;
|
|
2104
|
+
display: flex;
|
|
2105
|
+
flex-direction: column;
|
|
2106
|
+
align-items: center;
|
|
2107
|
+
gap: 12px;
|
|
2108
|
+
}
|
|
2109
|
+
.cms-table-preview-grid {
|
|
2110
|
+
display: flex;
|
|
2111
|
+
flex-direction: column;
|
|
2112
|
+
gap: 2px;
|
|
2113
|
+
background: #dee2e6;
|
|
2114
|
+
border: 2px solid #dee2e6;
|
|
2115
|
+
border-radius: 4px;
|
|
2116
|
+
overflow: hidden;
|
|
2117
|
+
}
|
|
2118
|
+
.cms-table-preview-row {
|
|
2119
|
+
display: flex;
|
|
2120
|
+
gap: 2px;
|
|
2121
|
+
}
|
|
2122
|
+
.cms-table-preview-cell {
|
|
2123
|
+
width: 40px;
|
|
2124
|
+
height: 32px;
|
|
2125
|
+
background: white;
|
|
2126
|
+
transition: background 0.2s;
|
|
2127
|
+
}
|
|
2128
|
+
.cms-table-preview-cell.header {
|
|
2129
|
+
background: #667eea;
|
|
2130
|
+
}
|
|
2131
|
+
.cms-table-preview-label {
|
|
2132
|
+
font-size: 13px;
|
|
2133
|
+
font-weight: 600;
|
|
2134
|
+
color: #495057;
|
|
2135
|
+
}
|
|
2136
|
+
.cms-number-input-group {
|
|
2137
|
+
display: flex;
|
|
2138
|
+
gap: 8px;
|
|
2139
|
+
align-items: center;
|
|
2140
|
+
}
|
|
2141
|
+
.cms-number-button {
|
|
2142
|
+
width: 36px;
|
|
2143
|
+
height: 36px;
|
|
2144
|
+
background: #f8f9fa;
|
|
2145
|
+
border: 2px solid #e0e0e0;
|
|
2146
|
+
border-radius: 6px;
|
|
2147
|
+
font-size: 18px;
|
|
2148
|
+
font-weight: 600;
|
|
2149
|
+
color: #495057;
|
|
2150
|
+
cursor: pointer;
|
|
2151
|
+
transition: all 0.2s;
|
|
2152
|
+
display: flex;
|
|
2153
|
+
align-items: center;
|
|
2154
|
+
justify-content: center;
|
|
2155
|
+
}
|
|
2156
|
+
.cms-number-button:hover {
|
|
2157
|
+
background: #667eea;
|
|
2158
|
+
border-color: #667eea;
|
|
2159
|
+
color: white;
|
|
2160
|
+
}
|
|
2161
|
+
.cms-number-input {
|
|
2162
|
+
flex: 1;
|
|
2163
|
+
padding: 10px 12px;
|
|
2164
|
+
border: 2px solid #e0e0e0;
|
|
2165
|
+
border-radius: 8px;
|
|
2166
|
+
font-size: 14px;
|
|
2167
|
+
color: #2c3e50;
|
|
2168
|
+
text-align: center;
|
|
2169
|
+
font-weight: 600;
|
|
2170
|
+
transition: border-color 0.2s;
|
|
2171
|
+
}
|
|
2172
|
+
.cms-number-input:hover {
|
|
2173
|
+
border-color: #667eea;
|
|
2174
|
+
}
|
|
2175
|
+
.cms-number-input:focus {
|
|
2176
|
+
outline: none;
|
|
2177
|
+
border-color: #667eea;
|
|
2178
|
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
2179
|
+
}
|
|
2180
|
+
.cms-checkbox-label {
|
|
2181
|
+
display: flex;
|
|
2182
|
+
align-items: center;
|
|
2183
|
+
gap: 10px;
|
|
2184
|
+
cursor: pointer;
|
|
2185
|
+
user-select: none;
|
|
2186
|
+
}
|
|
2187
|
+
.cms-checkbox {
|
|
2188
|
+
width: 20px;
|
|
2189
|
+
height: 20px;
|
|
2190
|
+
cursor: pointer;
|
|
2191
|
+
accent-color: #667eea;
|
|
2192
|
+
}
|
|
2193
|
+
.cms-checkbox-label span {
|
|
2194
|
+
font-size: 14px;
|
|
2195
|
+
color: #2c3e50;
|
|
2196
|
+
font-weight: 500;
|
|
2197
|
+
}
|
|
2198
|
+
.cms-table-presets {
|
|
2199
|
+
background: #f8f9fa;
|
|
2200
|
+
padding: 15px;
|
|
2201
|
+
border-radius: 8px;
|
|
2202
|
+
}
|
|
2203
|
+
.cms-table-presets-title {
|
|
2204
|
+
margin: 0 0 10px 0;
|
|
2205
|
+
font-size: 12px;
|
|
2206
|
+
font-weight: 600;
|
|
2207
|
+
color: #6c757d;
|
|
2208
|
+
text-transform: uppercase;
|
|
2209
|
+
letter-spacing: 0.5px;
|
|
2210
|
+
}
|
|
2211
|
+
.cms-table-preset-buttons {
|
|
2212
|
+
display: grid;
|
|
2213
|
+
grid-template-columns: repeat(4, 1fr);
|
|
2214
|
+
gap: 8px;
|
|
2215
|
+
}
|
|
2216
|
+
.cms-preset-button {
|
|
2217
|
+
padding: 8px 12px;
|
|
2218
|
+
background: white;
|
|
2219
|
+
border: 2px solid #e0e0e0;
|
|
2220
|
+
border-radius: 6px;
|
|
2221
|
+
font-size: 13px;
|
|
2222
|
+
font-weight: 600;
|
|
2223
|
+
color: #495057;
|
|
2224
|
+
cursor: pointer;
|
|
2225
|
+
transition: all 0.2s;
|
|
2226
|
+
}
|
|
2227
|
+
.cms-preset-button:hover {
|
|
2228
|
+
background: #667eea;
|
|
2229
|
+
border-color: #667eea;
|
|
2230
|
+
color: white;
|
|
2231
|
+
transform: translateY(-1px);
|
|
2232
|
+
}
|
|
2233
|
+
.cms-editor-content table {
|
|
2234
|
+
border-collapse: collapse;
|
|
2235
|
+
width: 100%;
|
|
2236
|
+
margin: 20px 0;
|
|
2237
|
+
border: 1px solid #dee2e6;
|
|
2238
|
+
border-radius: 8px;
|
|
2239
|
+
overflow: hidden;
|
|
2240
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
2241
|
+
}
|
|
2242
|
+
.cms-editor-content th,
|
|
2243
|
+
.cms-editor-content td {
|
|
2244
|
+
border: 1px solid #dee2e6;
|
|
2245
|
+
padding: 12px 16px;
|
|
2246
|
+
text-align: left;
|
|
2247
|
+
min-width: 100px;
|
|
2248
|
+
position: relative;
|
|
2249
|
+
}
|
|
2250
|
+
.cms-editor-content th {
|
|
2251
|
+
background: #667eea;
|
|
2252
|
+
color: white;
|
|
2253
|
+
font-weight: 600;
|
|
2254
|
+
font-size: 14px;
|
|
2255
|
+
text-transform: uppercase;
|
|
2256
|
+
letter-spacing: 0.5px;
|
|
2257
|
+
}
|
|
2258
|
+
.cms-editor-content td {
|
|
2259
|
+
background: white;
|
|
2260
|
+
font-size: 14px;
|
|
2261
|
+
color: #2c3e50;
|
|
2262
|
+
}
|
|
2263
|
+
.cms-editor-content tr:nth-child(even) td {
|
|
2264
|
+
background: #f8f9fa;
|
|
2265
|
+
}
|
|
2266
|
+
.cms-editor-content tr:hover td {
|
|
2267
|
+
background: #e9ecef;
|
|
2268
|
+
}
|
|
2269
|
+
.cms-editor-content td:focus,
|
|
2270
|
+
.cms-editor-content th:focus {
|
|
2271
|
+
outline: 2px solid #667eea;
|
|
2272
|
+
outline-offset: -2px;
|
|
2273
|
+
background: #fff;
|
|
2274
|
+
}
|
|
2275
|
+
.cms-editor-content .TableNode__cell--selected {
|
|
2276
|
+
background: rgba(102, 126, 234, 0.1) !important;
|
|
2277
|
+
outline: 2px solid #667eea;
|
|
2278
|
+
outline-offset: -2px;
|
|
2279
|
+
}
|
|
2280
|
+
@media (max-width: 768px) {
|
|
2281
|
+
.cms-table-modal {
|
|
2282
|
+
width: 90vw;
|
|
2283
|
+
max-width: 400px;
|
|
2284
|
+
}
|
|
2285
|
+
.cms-table-preview-cell {
|
|
2286
|
+
width: 32px;
|
|
2287
|
+
height: 28px;
|
|
2288
|
+
}
|
|
2289
|
+
.cms-table-preset-buttons {
|
|
2290
|
+
grid-template-columns: repeat(2, 1fr);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
@media (max-width: 480px) {
|
|
2294
|
+
.cms-table-modal {
|
|
2295
|
+
width: 95vw;
|
|
2296
|
+
}
|
|
2297
|
+
.cms-table-preview-cell {
|
|
2298
|
+
width: 28px;
|
|
2299
|
+
height: 24px;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2061
2302
|
|
|
2062
2303
|
/* src/styles/renderer.css */
|
|
2063
2304
|
.cms-renderer {
|
|
@@ -2630,4 +2871,80 @@
|
|
|
2630
2871
|
height: 250px;
|
|
2631
2872
|
}
|
|
2632
2873
|
}
|
|
2874
|
+
.cms-renderer-content table {
|
|
2875
|
+
border-collapse: collapse;
|
|
2876
|
+
width: 100%;
|
|
2877
|
+
margin: 20px 0;
|
|
2878
|
+
border: 1px solid #dee2e6;
|
|
2879
|
+
border-radius: 8px;
|
|
2880
|
+
overflow: hidden;
|
|
2881
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
2882
|
+
background: white;
|
|
2883
|
+
}
|
|
2884
|
+
.cms-renderer-content th,
|
|
2885
|
+
.cms-renderer-content td {
|
|
2886
|
+
border: 1px solid #dee2e6;
|
|
2887
|
+
padding: 12px 16px;
|
|
2888
|
+
text-align: left;
|
|
2889
|
+
}
|
|
2890
|
+
.cms-renderer-content th {
|
|
2891
|
+
background: #667eea;
|
|
2892
|
+
color: white;
|
|
2893
|
+
font-weight: 600;
|
|
2894
|
+
font-size: 14px;
|
|
2895
|
+
text-transform: uppercase;
|
|
2896
|
+
letter-spacing: 0.5px;
|
|
2897
|
+
}
|
|
2898
|
+
.cms-renderer-content td {
|
|
2899
|
+
background: white;
|
|
2900
|
+
font-size: 14px;
|
|
2901
|
+
color: #2c3e50;
|
|
2902
|
+
}
|
|
2903
|
+
.cms-renderer-content tr:nth-child(even) td {
|
|
2904
|
+
background: #f8f9fa;
|
|
2905
|
+
}
|
|
2906
|
+
.cms-renderer-content tr:hover td {
|
|
2907
|
+
background: #e9ecef;
|
|
2908
|
+
transition: background 0.2s;
|
|
2909
|
+
}
|
|
2910
|
+
@media (max-width: 768px) {
|
|
2911
|
+
.cms-renderer-content table {
|
|
2912
|
+
display: block;
|
|
2913
|
+
overflow-x: auto;
|
|
2914
|
+
white-space: nowrap;
|
|
2915
|
+
-webkit-overflow-scrolling: touch;
|
|
2916
|
+
}
|
|
2917
|
+
.cms-renderer-content th,
|
|
2918
|
+
.cms-renderer-content td {
|
|
2919
|
+
padding: 10px 12px;
|
|
2920
|
+
font-size: 13px;
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
@media (max-width: 480px) {
|
|
2924
|
+
.cms-renderer-content th,
|
|
2925
|
+
.cms-renderer-content td {
|
|
2926
|
+
padding: 8px 10px;
|
|
2927
|
+
font-size: 12px;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
@media (prefers-color-scheme: dark) {
|
|
2931
|
+
.cms-renderer-content table {
|
|
2932
|
+
border-color: #3e3e3e;
|
|
2933
|
+
background: #2a2a2a;
|
|
2934
|
+
}
|
|
2935
|
+
.cms-renderer-content th {
|
|
2936
|
+
background: #667eea;
|
|
2937
|
+
}
|
|
2938
|
+
.cms-renderer-content td {
|
|
2939
|
+
background: #2a2a2a;
|
|
2940
|
+
color: #e0e0e0;
|
|
2941
|
+
border-color: #3e3e3e;
|
|
2942
|
+
}
|
|
2943
|
+
.cms-renderer-content tr:nth-child(even) td {
|
|
2944
|
+
background: #333;
|
|
2945
|
+
}
|
|
2946
|
+
.cms-renderer-content tr:hover td {
|
|
2947
|
+
background: #3a3a3a;
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2633
2950
|
/*# sourceMappingURL=index.css.map */
|