customise-text-editor 1.0.0 → 1.0.2
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 +63 -19
- package/dist/customise-text-editor.es.js +93 -14574
- package/dist/customise-text-editor.umd.js +63 -139
- package/dist/index.d.ts +34 -0
- package/package.json +4 -15
package/README.md
CHANGED
|
@@ -4,13 +4,27 @@ A highly customizable, production-ready Rich Text Editor for React, powered by T
|
|
|
4
4
|
|
|
5
5
|
## 💎 Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- **
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- **Rich Text Formatting**:
|
|
8
|
+
- `Bold`, `Italic`, `Underline`, `Strikethrough` - Essential text styling.
|
|
9
|
+
- `Code`, `Code Block` - Inline and multi-line code support with syntax highlighting.
|
|
10
|
+
- `Headings` (H1, H2, H3) - Structured hierarchy for your content.
|
|
11
|
+
- **Advanced Tools**:
|
|
12
|
+
- `Links` - Easy URL management and persistent hyperlinks.
|
|
13
|
+
- `Text Color` & `Highlight` - Full spectrum color pickers for text and backgrounds.
|
|
14
|
+
- `Blockquote` - Stylish quote blocks.
|
|
15
|
+
- `Horizontal Rule` - Clean content separators.
|
|
16
|
+
- **Layout & UX**:
|
|
17
|
+
- **Toolbar Placement**: Choose between `top-bar` or `bottom-bar` layout.
|
|
18
|
+
- **Floating Menu**: Optional bubble menu for quick styling on selection.
|
|
19
|
+
- **Responsive Design**: Mobile-friendly toolbar with smooth horizontal scrolling.
|
|
20
|
+
- **Customization**:
|
|
21
|
+
- **Dynamic Theming**: Control primary colors, border styles, and border radius via a simple `theme` object.
|
|
22
|
+
- **Feature Toggling**: Choose exactly which tools to show using the `features` array.
|
|
23
|
+
- **Placeholders**: Custom placeholder text for empty states.
|
|
24
|
+
- **Pro Features**:
|
|
25
|
+
- **Character Count**: Built-in tracking with optional character limits.
|
|
26
|
+
- **Undo/Redo**: Full history management.
|
|
27
|
+
- **Type Safety**: Built with TypeScript for 100% type coverage.
|
|
14
28
|
|
|
15
29
|
## 🚀 Installation
|
|
16
30
|
|
|
@@ -24,6 +38,7 @@ yarn add customise-text-editor
|
|
|
24
38
|
|
|
25
39
|
```tsx
|
|
26
40
|
import { CustomEditor } from 'customise-text-editor';
|
|
41
|
+
import 'customise-text-editor/style.css'; // Don't forget to import styles!
|
|
27
42
|
|
|
28
43
|
function MyEditor() {
|
|
29
44
|
return (
|
|
@@ -37,34 +52,63 @@ function MyEditor() {
|
|
|
37
52
|
},
|
|
38
53
|
layout: 'top-bar',
|
|
39
54
|
placeholder: 'Start typing...',
|
|
40
|
-
features: ['bold', 'italic', 'underline', 'link', 'highlight', 'undo', 'redo']
|
|
55
|
+
features: ['bold', 'italic', 'underline', 'link', 'highlight', 'undo', 'redo'],
|
|
56
|
+
onChange: (content) => console.log(content)
|
|
41
57
|
}}
|
|
42
58
|
/>
|
|
43
59
|
);
|
|
44
60
|
}
|
|
45
61
|
```
|
|
46
62
|
|
|
47
|
-
##
|
|
63
|
+
## 🛠️ Configuration (Props)
|
|
48
64
|
|
|
65
|
+
The `CustomEditor` component accepts a `config` object with the following properties:
|
|
66
|
+
|
|
67
|
+
### Main Config
|
|
68
|
+
| Property | Type | Description |
|
|
69
|
+
| :--- | :--- | :--- |
|
|
70
|
+
| `layout` | `'top-bar' \| 'bottom-bar'` | Position of the toolbar. |
|
|
71
|
+
| `features` | `string[]` | Array of tools to display (e.g., `['bold', 'italic', 'link']`). |
|
|
72
|
+
| `theme` | `ThemeConfig` | Custom theme object (see section below). |
|
|
73
|
+
| `title` | `string` | Optional editor title. |
|
|
74
|
+
| `showTitle` | `boolean` | Toggle title visibility. |
|
|
75
|
+
| `placeholder` | `string` | Custom placeholder text. |
|
|
76
|
+
| `width` | `string \| number` | Number or string (e.g., `800` or `'100%'`). |
|
|
77
|
+
| `maxLength` | `number` | Maximum character limit. |
|
|
78
|
+
| `initialContent` | `string` | Initial HTML content for the editor. |
|
|
79
|
+
| `onChange` | `(content: string) => void` | Callback when content changes (returns HTML). |
|
|
80
|
+
| `onCharacterCountChange` | `(count: number) => void` | Callback when character count changes. |
|
|
81
|
+
|
|
82
|
+
### 🎨 Theme Configuration
|
|
49
83
|
| Property | Description | Default |
|
|
50
84
|
| :--- | :--- | :--- |
|
|
51
85
|
| `primaryColor` | Brand color for active states & borders | `#3b82f6` |
|
|
86
|
+
| `secondaryColor` | Secondary brand color | - |
|
|
52
87
|
| `backgroundColor` | Editor and toolbar background | `#ffffff` |
|
|
53
88
|
| `textColor` | Main text color | `#0f172a` |
|
|
89
|
+
| `accentColor` | Background for hovered buttons | `#f8fafc` |
|
|
54
90
|
| `borderColor` | Border color for the container | `#e2e8f0` |
|
|
55
91
|
| `borderRadius` | Main corner radius | `0.75rem` |
|
|
92
|
+
| `fontFamily` | Custom font family | `'Inter', sans-serif` |
|
|
56
93
|
|
|
57
|
-
## 🛠️
|
|
94
|
+
## 🛠️ Troubleshooting
|
|
58
95
|
|
|
59
|
-
|
|
96
|
+
### "Invalid hook call" or "Double React"
|
|
97
|
+
If you encounter an "Invalid hook call" error while using `npm link`, it's likely because React is being loaded twice (once from your project and once from the library's `node_modules`).
|
|
60
98
|
|
|
61
|
-
|
|
62
|
-
- `features`: Array of tools to display (e.g., `['bold', 'italic', 'link']`)
|
|
63
|
-
- `title`: Optional editor title
|
|
64
|
-
- `showTitle`: Toggle title visibility
|
|
65
|
-
- `placeholder`: Custom placeholder text
|
|
66
|
-
- `width`: Number or string (e.g., `800` or `'100%'`)
|
|
99
|
+
**Fix:** Update your project's `vite.config.ts` to alias React to your local version:
|
|
67
100
|
|
|
68
|
-
|
|
101
|
+
```typescript
|
|
102
|
+
// vite.config.ts
|
|
103
|
+
import path from 'path';
|
|
104
|
+
|
|
105
|
+
export default defineConfig({
|
|
106
|
+
resolve: {
|
|
107
|
+
alias: {
|
|
108
|
+
'react': path.resolve(__dirname, 'node_modules/react'),
|
|
109
|
+
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
69
114
|
|
|
70
|
-
MIT © [Your Name]
|