@evolution-james/evolution-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 +13 -0
- package/README.md +241 -0
- package/dist/index.esm.js +1665 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1672 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2026 James Evolution (Evolution Coding Academy)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, and distribute the Software in source or binary forms, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
1. Commercial Use Restriction: The Software may not be sold, sublicensed, or otherwise distributed as a standalone product, or as a substantially similar derivative, for direct commercial gain. You may not offer the Software, with or without modification, as a paid product or as part of a paid library, toolkit, or component collection.
|
|
6
|
+
|
|
7
|
+
2. Permitted Commercial Use: The Software may be used as part of a larger application, product, or service, including commercial products, provided that the Software is not the primary, sole, or core component being sold or licensed. The Software must not be the main value or selling point of the product.
|
|
8
|
+
|
|
9
|
+
3. Attribution: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
|
|
11
|
+
4. No Warranty: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
12
|
+
|
|
13
|
+
For questions or commercial licensing, contact: james-evolution (at) example.com
|
package/README.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
|
|
2
|
+
# Evolution Editor (Overview)
|
|
3
|
+
|
|
4
|
+
Evolution Editor is a standalone, rich text editor React component designed for easy integration into any React project. It supports both read-only and editable modes, JSON import/export, and theming via CSS variables.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
- [Features](#features)
|
|
10
|
+
- [Installation & Import](#installation--import)
|
|
11
|
+
- [Props](#props)
|
|
12
|
+
- [Styling Guidelines](#styling-guidelines)
|
|
13
|
+
- [Example Usage](#example-usage)
|
|
14
|
+
- [Example handleSave Function](#example-handlesave-function)
|
|
15
|
+
- [Read-Only vs Edit Modes](#read-only-vs-edit-modes)
|
|
16
|
+
- [JSON Exporting](#json-exporting)
|
|
17
|
+
- [JSON Export Structure](#json-export-structure)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
**User Features**
|
|
24
|
+
- π Paragraph & Heading blocks (H1, H2, H3)
|
|
25
|
+
- π¨ Text color & font size customization
|
|
26
|
+
- π Ordered & unordered lists (with nesting)
|
|
27
|
+
- πΌοΈ Image embeds via URL
|
|
28
|
+
- π₯ YouTube video embeds via URL (share-link URL, not embed HTML)
|
|
29
|
+
- β Horizontal dividers
|
|
30
|
+
- πΎ JSON import/export
|
|
31
|
+
- π§© Customizable styles, colors, and font sizes
|
|
32
|
+
|
|
33
|
+
**Developer Features**
|
|
34
|
+
- Modular, block-based architecture
|
|
35
|
+
- Extensible: add new block types easily
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Requirements
|
|
40
|
+
|
|
41
|
+
Evolution Editor is a React component library. To use it in your project (whether installed from npm or otherwise), your project must be a React project with `react` and `react-dom` as dependencies.
|
|
42
|
+
|
|
43
|
+
### Quick Start: Create a React Project
|
|
44
|
+
|
|
45
|
+
If you need to create a new React project, you can use Create React App:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx create-react-app my-app
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Replace `my-app` with your desired project name. Once your React project is set up, you can install Evolution Editor from npm and start using it as described below.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Installation & Import
|
|
56
|
+
|
|
57
|
+
### Install from npm
|
|
58
|
+
```bash
|
|
59
|
+
npm install @evolution-james/evolution-editor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Import the component
|
|
63
|
+
```jsx
|
|
64
|
+
import { EvolutionEditor } from '@evolution-james/evolution-editor';
|
|
65
|
+
import '@evolution-james/evolution-editor/dist/styles.css';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Props
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Required | Description |
|
|
73
|
+
|----------------|------------|----------|-----------------------------------------------------------------------------|
|
|
74
|
+
| `initialData` | `object` | No | JSON object representing the editor's initial content. |
|
|
75
|
+
| `onSave` | `function` | No | Callback invoked with JSON when the user saves (edit mode only). |
|
|
76
|
+
| `editable` | `boolean` | No | If true, enables editing. If false/omitted, editor is read-only. |
|
|
77
|
+
| `placeholder` | `string` | No | Placeholder text for empty editor (edit mode only). |
|
|
78
|
+
| `showBranding` | `boolean` | No | If true (default), displays the Evolution Editor brand/logo at the top, during edit mode. If false, branding is hidden. In read-only mode, branding is always hidden regardless. |
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## Styling Guidelines
|
|
83
|
+
|
|
84
|
+
### Parent Container CSS Classes
|
|
85
|
+
|
|
86
|
+
To constrain the size of your editor, I recommend wrapping it in a container element.
|
|
87
|
+
For example, a <div> with the class .container
|
|
88
|
+
You can then apply styling as you'd like. For example, if you wish to restrict its width to 80% of the viewport
|
|
89
|
+
and it's height to 800 pixels, and you wish to center it, you could do this:
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
.container {
|
|
93
|
+
height: 800px !important;
|
|
94
|
+
width: 80%; !important;
|
|
95
|
+
margin: auto;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### CSS Variables Used
|
|
101
|
+
|
|
102
|
+
Evolution Editor uses the following CSS variables for theming. Define these in your global CSS or :root for custom themes:
|
|
103
|
+
|
|
104
|
+
- `--color-bg` β Editor background
|
|
105
|
+
- `--color-text` β Editor text color
|
|
106
|
+
- `--color-card-bg` β Toolbar and block background
|
|
107
|
+
- `--color-card-border` β Toolbar and block border
|
|
108
|
+
- `--color-divider` β Toolbar divider
|
|
109
|
+
- `--color-btn-light-bg` β Toolbar button hover
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Example Usage
|
|
114
|
+
|
|
115
|
+
```jsx
|
|
116
|
+
<div className="container">
|
|
117
|
+
<EvolutionEditor
|
|
118
|
+
initialData={myJson}
|
|
119
|
+
onSave={handleSave}
|
|
120
|
+
editable={true}
|
|
121
|
+
placeholder="Start writing..."
|
|
122
|
+
showBranding={false} // Hide branding/logo (optional)
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## Example handleSave Function
|
|
130
|
+
|
|
131
|
+
A typical usage pattern is to keep the editor's content in React state and update it whenever the user saves. This ensures the editor always displays the latest content:
|
|
132
|
+
|
|
133
|
+
```jsx
|
|
134
|
+
import React, { useState } from 'react';
|
|
135
|
+
import { EvolutionEditor } from './evolution-editor';
|
|
136
|
+
|
|
137
|
+
function MyEditorContainer() {
|
|
138
|
+
const [editorContent, setEditorContent] = useState(initialJson); // initialJson is your starting data
|
|
139
|
+
|
|
140
|
+
function handleSave(newJson) {
|
|
141
|
+
setEditorContent(newJson); // Update state with the new content
|
|
142
|
+
// Optionally, persist to server/localStorage here
|
|
143
|
+
// localStorage.setItem('myEditorContent', JSON.stringify(newJson));
|
|
144
|
+
// fetch('/api/save', { method: 'POST', body: JSON.stringify(newJson) });
|
|
145
|
+
console.log('Editor content saved:', newJson);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<div className="container">
|
|
150
|
+
<EvolutionEditor
|
|
151
|
+
initialData={editorContent}
|
|
152
|
+
onSave={handleSave}
|
|
153
|
+
editable={true}
|
|
154
|
+
placeholder="Start writing..."
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
This pattern keeps the editorβs content in sync with your appβs state and ensures the latest content is always shown.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## Read-Only vs Edit Modes
|
|
166
|
+
|
|
167
|
+
- **Edit Mode (`editable={true}`):**
|
|
168
|
+
- User can type, format, and manipulate content.
|
|
169
|
+
- Toolbar is visible.
|
|
170
|
+
- `onSave` callback is available.
|
|
171
|
+
- **Read-Only Mode (`editable={false}` or omitted):**
|
|
172
|
+
- Content is rendered as static HTML.
|
|
173
|
+
- Toolbar and editing controls are hidden.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## JSON Exporting
|
|
177
|
+
|
|
178
|
+
- The editor's content is stored as a JSON object.
|
|
179
|
+
- To export, use the `onSave` callback, which receives the current JSON when the user saves.
|
|
180
|
+
- You can also access the editor's state via ref if needed (see advanced usage).
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
## JSON Export Structure
|
|
184
|
+
|
|
185
|
+
Evolution Editor exports/imports content as a JSON object with the following structure:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"version": "1.0.0",
|
|
190
|
+
"time": 1645123456789,
|
|
191
|
+
"blocks": [
|
|
192
|
+
{
|
|
193
|
+
"id": "block_unique_id",
|
|
194
|
+
"type": "heading",
|
|
195
|
+
"data": {
|
|
196
|
+
"level": 1,
|
|
197
|
+
"text": "My Title",
|
|
198
|
+
"htmlTag": "h1",
|
|
199
|
+
"styles": {
|
|
200
|
+
"color": "#000000",
|
|
201
|
+
"fontSize": "32px",
|
|
202
|
+
"marginTop": "0px",
|
|
203
|
+
"marginBottom": "16px",
|
|
204
|
+
"marginLeft": "0px",
|
|
205
|
+
"marginRight": "0px",
|
|
206
|
+
"paddingTop": "0px",
|
|
207
|
+
"paddingBottom": "0px",
|
|
208
|
+
"paddingLeft": "0px",
|
|
209
|
+
"paddingRight": "0px"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "block_2",
|
|
215
|
+
"type": "image",
|
|
216
|
+
"data": {
|
|
217
|
+
"url": "https://example.com/image.jpg",
|
|
218
|
+
"alt": "Alt text",
|
|
219
|
+
"styles": {
|
|
220
|
+
"maxWidth": "100%"
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"id": "block_3",
|
|
226
|
+
"type": "youtube",
|
|
227
|
+
"data": {
|
|
228
|
+
"videoId": "VIDEO_ID",
|
|
229
|
+
"styles": {
|
|
230
|
+
"width": "560px",
|
|
231
|
+
"height": "315px"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// ...other blocks
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Each block type has its own `data` structure. See the source code for more details on each block's properties.
|
|
241
|
+
|