@crashbytes/contentful-richtext-editor 2.0.5 → 3.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 CHANGED
@@ -1,39 +1,46 @@
1
- # Contentful Rich Text Editor
1
+ # @crashbytes/contentful-richtext-editor
2
2
 
3
- A modern, Tiptap-based rich text editor that's fully compatible with Contentful's rich text format. Provides the same editing experience as Contentful's native editor while maintaining perfect compatibility with Contentful's document structure.
3
+ [![npm version](https://img.shields.io/npm/v/@crashbytes/contentful-richtext-editor.svg)](https://www.npmjs.com/package/@crashbytes/contentful-richtext-editor)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@crashbytes/contentful-richtext-editor.svg)](https://www.npmjs.com/package/@crashbytes/contentful-richtext-editor)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Security Audit](https://github.com/CrashBytes/contentful-richtext-editor/actions/workflows/security-audit.yml/badge.svg)](https://github.com/CrashBytes/contentful-richtext-editor/actions/workflows/security-audit.yml)
7
+ [![React Compatibility](https://github.com/CrashBytes/contentful-richtext-editor/actions/workflows/react-compat.yml/badge.svg)](https://github.com/CrashBytes/contentful-richtext-editor/actions/workflows/react-compat.yml)
8
+ [![npm package provenance](https://img.shields.io/badge/provenance-tracked-brightgreen)](https://www.npmjs.com/package/@crashbytes/contentful-richtext-editor)
9
+
10
+ A modern, Tiptap v3-based rich text editor that's fully compatible with Contentful's rich text format. Provides the same editing experience as Contentful's native editor while maintaining perfect compatibility with Contentful's document structure.
11
+
12
+ ## 🔒 Security & Trust
13
+
14
+ - ✅ **Zero Known Vulnerabilities** - Automated security audits via Dependabot
15
+ - ✅ **Supply Chain Security** - Package published with npm provenance via Trusted Publishing
16
+ - ✅ **CodeQL Analysis** - Continuous security scanning for vulnerabilities
17
+ - ✅ **React 18 & 19 Compatible** - Automated compatibility testing
18
+ - ✅ **Dependency Review** - Automated PR checks for vulnerable dependencies
19
+
20
+ See our [Security Policy](SECURITY.md) for vulnerability reporting.
4
21
 
5
22
  ## ✨ Features
6
23
 
7
24
  - ✅ **Full Contentful Compatibility** - Seamless conversion between Contentful and Tiptap formats
8
- - ✅ **Automatic Configuration** - Reads Contentful field settings to auto-configure the editor *(NEW in v2.0)*
9
- - ✅ **Modern UI** - Clean, intuitive interface matching Contentful's design
25
+ - ✅ **Tiptap v3** - Built on the latest Tiptap v3 for better performance
26
+ - ✅ **Modern UI** - Clean, intuitive interface matching Contentful's design
10
27
  - ✅ **TypeScript Support** - Complete type safety with Contentful's rich text types
11
- - ✅ **Extensible** - Built on Tiptap v2 for easy customization
28
+ - ✅ **Extensible** - Built on Tiptap v3 for easy customization
12
29
  - ✅ **Lightweight** - Tree-shakeable, only import what you need
13
30
  - ✅ **Responsive** - Works on desktop and mobile devices
14
- - ✅ **Keyboard Shortcuts** - Built-in shortcuts for common actions *(NEW in v2.0)*
15
-
16
- ### Supported Features
17
-
18
- - **Text Formatting**: Bold, italic, underline
19
- - **Headings**: H1 through H6
20
- - **Lists**: Ordered and unordered lists
21
- - **Links**: Hyperlinks with URL validation
22
- - **Tables**: Full table support with headers
23
- - **Quotes**: Blockquotes
24
- - **Embedded Content**: Callbacks for Contentful entries and assets
25
- - **Inline Entries**: Support for inline embedded entries *(NEW in v2.0)*
26
- - **Undo/Redo**: Full history support
31
+ - ✅ **Optional Border Control** - Customize editor appearance with `showBorder` prop
27
32
 
28
- ## 📦 Installation
33
+ ## 🚀 Installation
29
34
 
30
35
  ```bash
31
36
  npm install @crashbytes/contentful-richtext-editor
32
37
  ```
33
38
 
34
- ## 🚀 Quick Start
39
+ **Peer Dependencies:**
40
+ - React 18.3.1+ or React 19.x
41
+ - React DOM 18.3.1+ or React 19.x
35
42
 
36
- ### Basic Usage
43
+ ## 📖 Quick Start
37
44
 
38
45
  ```tsx
39
46
  import React, { useState } from 'react';
@@ -56,6 +63,7 @@ function App() {
56
63
  placeholder="Start writing your content..."
57
64
  onChange={handleChange}
58
65
  initialValue={content}
66
+ showBorder={true} // Optional: control border visibility
59
67
  />
60
68
  </div>
61
69
  );
@@ -64,41 +72,55 @@ function App() {
64
72
  export default App;
65
73
  ```
66
74
 
67
- ### Automatic Configuration (NEW in v2.0)
75
+ ## 🎨 Border Control
68
76
 
69
- The editor can automatically configure itself based on your Contentful field settings:
77
+ Control the editor's border appearance with the `showBorder` prop:
70
78
 
71
79
  ```tsx
72
- import {
73
- ContentfulRichTextEditor,
74
- fetchContentfulFieldConfig
75
- } from '@crashbytes/contentful-richtext-editor';
76
- import '@crashbytes/contentful-richtext-editor/dist/index.css';
80
+ // Default - with border (backward compatible)
81
+ <ContentfulRichTextEditor />
77
82
 
78
- function AutoConfiguredEditor() {
79
- const [fieldConfig, setFieldConfig] = useState();
83
+ // Borderless editor for custom layouts
84
+ <ContentfulRichTextEditor
85
+ showBorder={false}
86
+ className="my-custom-editor"
87
+ />
80
88
 
81
- useEffect(() => {
82
- // Fetch configuration from Contentful Management API
83
- fetchContentfulFieldConfig(
84
- 'your-space-id',
85
- 'your-content-type-id',
86
- 'your-field-id',
87
- 'your-management-token'
88
- ).then(setFieldConfig);
89
- }, []);
89
+ // Themed borderless editor
90
+ <ContentfulRichTextEditor
91
+ showBorder={false}
92
+ theme="minimal"
93
+ />
94
+ ```
90
95
 
91
- return (
92
- <ContentfulRichTextEditor
93
- fieldConfiguration={fieldConfig}
94
- placeholder="Auto-configured based on Contentful settings!"
95
- onChange={handleChange}
96
- />
97
- );
96
+ ### Custom Styling with Borderless Mode
97
+
98
+ ```css
99
+ /* Custom styling for borderless editor */
100
+ .my-custom-editor {
101
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
102
+ border-radius: 8px;
103
+ }
104
+
105
+ .my-custom-editor .contentful-toolbar {
106
+ background: linear-gradient(45deg, #667eea, #764ba2);
98
107
  }
99
108
  ```
100
109
 
101
- ### Advanced Usage with Embeds
110
+ ## 🎯 Supported Features
111
+
112
+ - **Text Formatting**: Bold, italic, underline
113
+ - **Headings**: H1 through H6
114
+ - **Lists**: Ordered and unordered lists
115
+ - **Links**: Hyperlinks with URL validation
116
+ - **Tables**: Full table support with headers
117
+ - **Quotes**: Blockquotes
118
+ - **Embedded Content**: Callbacks for Contentful entries and assets
119
+ - **Undo/Redo**: Full history support
120
+
121
+ ## 🔧 Advanced Usage
122
+
123
+ ### With Contentful Integration
102
124
 
103
125
  ```tsx
104
126
  import { ContentfulRichTextEditor } from '@crashbytes/contentful-richtext-editor';
@@ -112,31 +134,25 @@ function ContentfulEditor() {
112
134
  };
113
135
 
114
136
  const handleEmbedAsset = async () => {
115
- // Your logic to select a Contentful asset
137
+ // Your logic to select a Contentful asset
116
138
  const asset = await openAssetSelector();
117
139
  return asset;
118
140
  };
119
141
 
120
- const handleEmbedInlineEntry = async () => {
121
- // NEW v2.0 - Your logic to select an inline entry
122
- const entry = await openInlineEntrySelector();
123
- return entry;
124
- };
125
-
126
142
  return (
127
143
  <ContentfulRichTextEditor
128
144
  placeholder="Write your travel tip..."
129
145
  onChange={(doc) => saveToContentful(doc)}
130
146
  onEmbedEntry={handleEmbedEntry}
131
147
  onEmbedAsset={handleEmbedAsset}
132
- onEmbedInlineEntry={handleEmbedInlineEntry}
133
148
  theme="contentful"
149
+ showBorder={true}
134
150
  />
135
151
  );
136
152
  }
137
153
  ```
138
154
 
139
- ### Minimal Configuration
155
+ ### Customized Editor
140
156
 
141
157
  ```tsx
142
158
  <ContentfulRichTextEditor
@@ -149,58 +165,25 @@ function ContentfulEditor() {
149
165
  />
150
166
  ```
151
167
 
152
- ### With Initial Content
153
-
154
- ```tsx
155
- import { createEmptyDocument } from '@crashbytes/contentful-richtext-editor';
156
-
157
- const initialContent = {
158
- nodeType: 'document',
159
- data: {},
160
- content: [
161
- {
162
- nodeType: 'paragraph',
163
- data: {},
164
- content: [
165
- {
166
- nodeType: 'text',
167
- value: 'Hello world!',
168
- marks: [{ type: 'bold' }],
169
- data: {}
170
- }
171
- ]
172
- }
173
- ]
174
- };
175
-
176
- <ContentfulRichTextEditor
177
- initialValue={initialContent}
178
- onChange={handleChange}
179
- />
180
- ```
181
-
182
- ## 📋 API Reference
183
-
184
- ### ContentfulRichTextEditor Props
168
+ ## 📋 Props Reference
185
169
 
186
170
  | Prop | Type | Default | Description |
187
171
  |------|------|---------|-------------|
188
- | `availableHeadings` | `Array<1\|2\|3\|4\|5\|6>` | `[1,2,3,4,5,6]` | Available heading levels (fallback when no fieldConfiguration) |
189
- | `availableMarks` | `Array<'bold'\|'italic'\|'underline'>` | `['bold','italic','underline']` | Available text formatting marks (fallback when no fieldConfiguration) |
190
- | `className` | `string` | `''` | Additional CSS classes |
191
- | `disabledFeatures` | `Array<string>` | `[]` | Features to disable |
192
- | `fieldConfiguration` | `ContentfulFieldConfiguration` | `undefined` | **NEW v2.0** - Contentful field validation config (takes precedence over manual settings) |
172
+ | `showBorder` | `boolean` | `true` | Control editor border visibility |
193
173
  | `initialValue` | `Document` | `undefined` | Initial Contentful rich text document |
194
174
  | `onChange` | `(document: Document) => void` | `undefined` | Callback when content changes |
195
- | `onEmbedAsset` | `() => Promise<any> \| void` | `undefined` | Callback for embedding Contentful assets |
196
175
  | `onEmbedEntry` | `() => Promise<any> \| void` | `undefined` | Callback for embedding Contentful entries |
197
- | `onEmbedInlineEntry` | `() => Promise<any> \| void` | `undefined` | **NEW v2.0** - Callback for embedding inline entries |
176
+ | `onEmbedAsset` | `() => Promise<any> \| void` | `undefined` | Callback for embedding Contentful assets |
177
+ | `onEmbedInlineEntry` | `() => Promise<any> \| void` | `undefined` | Callback for embedding inline entries |
198
178
  | `placeholder` | `string` | `'Start writing...'` | Placeholder text |
199
179
  | `readonly` | `boolean` | `false` | Whether editor is read-only |
200
- | `showBorder` | `boolean` | `true` | Whether to show border around the editor |
180
+ | `className` | `string` | `''` | Additional CSS classes |
201
181
  | `theme` | `'default' \| 'minimal' \| 'contentful'` | `'contentful'` | Visual theme |
182
+ | `disabledFeatures` | `Array<string>` | `[]` | Features to disable |
183
+ | `availableHeadings` | `Array<1 \| 2 \| 3 \| 4 \| 5 \| 6>` | `[1,2,3,4,5,6]` | Available heading levels |
184
+ | `availableMarks` | `Array<'bold' \| 'italic' \| 'underline'>` | `['bold','italic','underline']` | Available text formatting |
202
185
 
203
- ### Disabled Features
186
+ ## 🚫 Disabling Features
204
187
 
205
188
  You can disable specific features by passing them in the `disabledFeatures` array:
206
189
 
@@ -214,20 +197,6 @@ You can disable specific features by passing them in the `disabledFeatures` arra
214
197
  - `'table'` - Tables
215
198
  - `'embed'` - Embedded content
216
199
 
217
- ### Configuration Types (NEW v2.0)
218
-
219
- ```tsx
220
- interface ContentfulFieldConfiguration {
221
- validations?: Array<{
222
- enabledMarks?: string[]; // ['bold', 'italic', 'underline', 'code']
223
- enabledNodeTypes?: string[]; // ['paragraph', 'heading-1', 'unordered-list', ...]
224
- }>;
225
- settings?: {
226
- helpText?: string;
227
- };
228
- }
229
- ```
230
-
231
200
  ## 🛠️ Utility Functions
232
201
 
233
202
  ```tsx
@@ -236,47 +205,23 @@ import {
236
205
  tiptapToContentful,
237
206
  validateContentfulDocument,
238
207
  createEmptyDocument,
239
- extractPlainText, // NEW v2.0
240
- countWords, // NEW v2.0
241
- findEmbeddedContent, // NEW v2.0
242
- sanitizeContentfulDocument // NEW v2.0
208
+ extractPlainText,
209
+ countWords,
210
+ findEmbeddedContent
243
211
  } from '@crashbytes/contentful-richtext-editor';
244
212
 
245
213
  // Convert between formats
246
214
  const tiptapJson = contentfulToTiptap(contentfulDocument);
247
215
  const contentfulDoc = tiptapToContentful(tiptapJson);
248
216
 
249
- // Validation
217
+ // Validation and utilities
250
218
  const isValid = validateContentfulDocument(someDocument);
251
-
252
- // Create empty document
253
219
  const emptyDoc = createEmptyDocument();
254
-
255
- // NEW v2.0 - Content analysis
256
- const plainText = extractPlainText(contentfulDocument);
257
- const wordCount = countWords(contentfulDocument);
258
- const embedded = findEmbeddedContent(contentfulDocument);
259
-
260
- // NEW v2.0 - Sanitize content
261
- const sanitized = sanitizeContentfulDocument(
262
- document,
263
- ['paragraph', 'heading-1', 'unordered-list'], // allowed nodes
264
- ['bold', 'italic'] // allowed marks
265
- );
220
+ const plainText = extractPlainText(document);
221
+ const wordCount = countWords(document);
222
+ const embedded = findEmbeddedContent(document);
266
223
  ```
267
224
 
268
- ## ⌨️ Keyboard Shortcuts (NEW v2.0)
269
-
270
- - `Cmd/Ctrl + B` - Bold
271
- - `Cmd/Ctrl + I` - Italic
272
- - `Cmd/Ctrl + U` - Underline
273
- - `Cmd/Ctrl + K` - Add/edit link
274
- - `Cmd/Ctrl + Shift + E` - Embed entry
275
- - `Cmd/Ctrl + Shift + A` - Embed asset
276
- - `Cmd/Ctrl + Shift + I` - Embed inline entry
277
- - `Cmd/Ctrl + Z` - Undo
278
- - `Cmd/Ctrl + Y` / `Cmd/Ctrl + Shift + Z` - Redo
279
-
280
225
  ## 🎨 Styling
281
226
 
282
227
  The editor comes with default styles that match Contentful's design. Import the CSS:
@@ -285,6 +230,8 @@ The editor comes with default styles that match Contentful's design. Import the
285
230
  import '@crashbytes/contentful-richtext-editor/dist/index.css';
286
231
  ```
287
232
 
233
+ ### Custom Styling
234
+
288
235
  You can override the default styles by targeting the CSS classes:
289
236
 
290
237
  ```css
@@ -300,27 +247,25 @@ You can override the default styles by targeting the CSS classes:
300
247
  font-family: 'Your Font', sans-serif;
301
248
  }
302
249
 
303
- /* NEW v2.0 - Inline entries */
304
- .contentful-inline-embedded-entry {
305
- background: #e8f4fd;
306
- padding: 2px 4px;
307
- border-radius: 3px;
308
- font-weight: 600;
250
+ /* Borderless editor styling */
251
+ .contentful-editor--borderless {
252
+ border: none;
253
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
309
254
  }
310
255
  ```
311
256
 
312
257
  ### Themes
313
258
 
314
- **`contentful`** (default)
259
+ **Contentful** (default)
315
260
  Matches Contentful's native editor appearance.
316
261
 
317
- **`minimal`**
262
+ **Minimal**
318
263
  Clean, minimal design with reduced visual elements.
319
264
 
320
- **`default`**
265
+ **Default**
321
266
  Standard rich text editor appearance with serif fonts.
322
267
 
323
- ## ⚛️ Next.js Integration
268
+ ## 🌐 Next.js Usage
324
269
 
325
270
  ```tsx
326
271
  // pages/editor.tsx or app/editor/page.tsx
@@ -337,13 +282,14 @@ export default function EditorPage() {
337
282
  <ContentfulEditor
338
283
  placeholder="Write something amazing..."
339
284
  onChange={(doc) => console.log(doc)}
285
+ showBorder={false}
340
286
  />
341
287
  </div>
342
288
  );
343
289
  }
344
290
  ```
345
291
 
346
- ## 🔷 TypeScript Support
292
+ ## 📝 TypeScript Support
347
293
 
348
294
  This package is written in TypeScript and includes full type definitions. All Contentful rich text types are re-exported for convenience:
349
295
 
@@ -353,9 +299,7 @@ import type {
353
299
  Block,
354
300
  Inline,
355
301
  Text,
356
- ContentfulRichTextEditorProps,
357
- ContentfulFieldConfiguration, // NEW v2.0
358
- ParsedEditorConfig // NEW v2.0
302
+ ContentfulRichTextEditorProps
359
303
  } from '@crashbytes/contentful-richtext-editor';
360
304
  ```
361
305
 
@@ -366,6 +310,51 @@ import type {
366
310
  - Safari 13+
367
311
  - Edge 80+
368
312
 
313
+ ## 🔄 Migration
314
+
315
+ ### From v2.x to v3.0.0
316
+
317
+ **Good News:** The public API is unchanged! Upgrade with no code changes:
318
+
319
+ ```bash
320
+ npm install @crashbytes/contentful-richtext-editor@latest
321
+ ```
322
+
323
+ Your existing code continues to work:
324
+
325
+ ```tsx
326
+ // This still works exactly the same
327
+ <ContentfulRichTextEditor
328
+ placeholder="Start writing..."
329
+ onChange={handleChange}
330
+ initialValue={content}
331
+ />
332
+ ```
333
+
334
+ **What Changed:** Internal upgrade to Tiptap v3 provides:
335
+ - Better performance
336
+ - Improved mobile support
337
+ - Enhanced transaction handling
338
+ - More efficient rendering
339
+
340
+ See [CHANGELOG.md](CHANGELOG.md) for complete details.
341
+
342
+ ### From v2.0.3 to v2.0.4+
343
+ No breaking changes! Simply update and optionally use the new `showBorder` prop.
344
+
345
+ ## 🔒 Security
346
+
347
+ We take security seriously. This package:
348
+
349
+ - ✅ **Automated Security Audits** - Weekly npm audit via GitHub Actions
350
+ - ✅ **Dependabot** - Automated dependency updates for security patches
351
+ - ✅ **CodeQL Analysis** - Advanced security vulnerability scanning
352
+ - ✅ **Dependency Review** - Automated checks on every PR
353
+ - ✅ **Trusted Publishing** - Package published with cryptographic provenance
354
+ - ✅ **Supply Chain Verification** - npm provenance proves package source
355
+
356
+ **Found a vulnerability?** Please report it via our [Security Policy](SECURITY.md).
357
+
369
358
  ## 🤝 Contributing
370
359
 
371
360
  Contributions are welcome! Please feel free to submit a Pull Request.
@@ -376,6 +365,12 @@ Contributions are welcome! Please feel free to submit a Pull Request.
376
365
  4. Push to the branch (`git push origin feature/amazing-feature`)
377
366
  5. Open a Pull Request
378
367
 
368
+ All PRs automatically run:
369
+ - Security audits
370
+ - Dependency vulnerability checks
371
+ - React 18 & 19 compatibility tests
372
+ - Full test suite (175 tests)
373
+
379
374
  ## 📄 License
380
375
 
381
376
  MIT © [CrashBytes](https://github.com/CrashBytes)
@@ -384,8 +379,17 @@ MIT © [CrashBytes](https://github.com/CrashBytes)
384
379
 
385
380
  - [@contentful/rich-text-react-renderer](https://www.npmjs.com/package/@contentful/rich-text-react-renderer) - For rendering Contentful rich text
386
381
  - [@contentful/rich-text-types](https://www.npmjs.com/package/@contentful/rich-text-types) - Contentful rich text type definitions
387
- - [@tiptap/react](https://www.npmjs.com/package/@tiptap/react) - The underlying editor framework
382
+ - [@tiptap/react](https://www.npmjs.com/package/@tiptap/react) - The underlying editor framework (v3)
383
+
384
+ ## 📈 Version History
385
+
386
+ - **v3.0.0** - Upgraded to Tiptap v3.15.3, added security enhancements
387
+ - **v2.0.6** - Dependency updates, bug fixes
388
+ - **v2.0.4** - Added optional border control with `showBorder` prop
389
+ - **v2.0.3** - Package made publicly accessible
390
+ - **v2.0.0** - Major feature update with automatic configuration
391
+ - **v1.x** - Initial releases
388
392
 
389
393
  ---
390
394
 
391
- Made with ❤️ for the Contentful community
395
+ Made with ❤️ for the Contentful community