mailcraft-editor-iwell 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +63 -2
- package/dist/index.cjs +2562 -0
- package/dist/index.mjs +2532 -0
- package/dist/style.css +1 -0
- package/package.json +22 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Excel Net Solutions Private Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mailcraft-editor-iwell
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Classic rich text editor for email templates, as a React component. It edits inside an iframe, sanitizes its HTML with DOMPurify, and has no third-party editor code.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install mailcraft-editor-iwell
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Needs `react` and `react-dom` 18 in the app. Import the stylesheet once, anywhere in the app.
|
|
12
|
+
|
|
13
|
+
Browser only: the component and `sanitizeHtml` need a DOM. Importing the package on a server is safe, but calling `sanitizeHtml` there throws rather than returning unsanitized HTML.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import RichTextEditor from 'mailcraft-editor-iwell'
|
|
19
|
+
import 'mailcraft-editor-iwell/style.css'
|
|
20
|
+
|
|
21
|
+
<RichTextEditor
|
|
22
|
+
initialValue={html} // read once, when the editor loads
|
|
23
|
+
onChange={(html) => ...} // sanitized body HTML, on every edit
|
|
24
|
+
height={715}
|
|
25
|
+
toolbar={[['bold', 'italic'], ['link']]} // optional, groups of button ids
|
|
26
|
+
readOnly={false}
|
|
27
|
+
contentStyle="body { line-height: 1.15; }" // optional extra CSS inside the editing iframe
|
|
28
|
+
imageAccept=".jpg,.jpeg,.png"
|
|
29
|
+
onImageFileSelect={(file) => Promise<url | null>} // Browse / paste / drop
|
|
30
|
+
onImageUrlChange={(url) => Promise<url>} // URL typed or pasted in the image dialog
|
|
31
|
+
onSourceCodeSave={(html) => Promise<html> | html} // before source code is applied
|
|
32
|
+
/>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Prop | Default | Description |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `initialValue` | `''` | Starting HTML. It is sanitized. Later changes to the prop are ignored. To load new content, remount with a `key` or call `ref.setContent`. |
|
|
38
|
+
| `onChange(html)` | – | Called on typing and on every toolbar, dialog, undo or redo change. Not called on load. |
|
|
39
|
+
| `height` | `400` | Pixel height of the whole editor (toolbar + content). |
|
|
40
|
+
| `toolbar` | `DEFAULT_TOOLBAR` (exported) | Array of button groups. Pass `false` to hide the toolbar. Button ids: `undo redo blocks fontfamily fontsize lineheight bold italic underline strikethrough superscript subscript alignleft aligncenter alignright alignjustify bullist numlist outdent indent link image table forecolor backcolor emoticons blockquote removeformat code preview print fullscreen mergetags`. |
|
|
41
|
+
| `readOnly` | `false` | Not editable, and no toolbar. |
|
|
42
|
+
| `mergeTags` | `[]` | Items for the Merge tags dropdown, `{ value, label }`. The button is hidden when empty. |
|
|
43
|
+
| `logoTag` | none | Tag inserted by **Use company logo** in the image dialog. |
|
|
44
|
+
| `contentStyle` | – | CSS appended inside the editing iframe. |
|
|
45
|
+
| `imageAccept` | `image/*` | `accept` for the Browse file input. |
|
|
46
|
+
| `onImageFileSelect(file)` | – | Upload the file and resolve with its URL. Resolve `null` to skip it, or reject with an `Error` to show its message. Without this prop there is no Browse button, and pasted image files are ignored. |
|
|
47
|
+
| `onImageUrlChange(url)` | – | Called when a URL is entered in the image dialog. Resolve with the URL to use (for example a re-hosted copy). The dialog shows "Uploading image..." while it waits. |
|
|
48
|
+
| `onSourceCodeSave(html)` | – | Change the HTML from the source code dialog before it is applied. A rejected promise shows its message in the dialog. |
|
|
49
|
+
| `className` | `''` | Extra class on the root element. |
|
|
50
|
+
|
|
51
|
+
**Ref API** (`ref` via `forwardRef`): `getContent()`, `setContent(html)` (also resets undo history),
|
|
52
|
+
`getText()`, `focus()`.
|
|
53
|
+
|
|
54
|
+
## Other exports
|
|
55
|
+
|
|
56
|
+
| Export | Purpose |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `sanitizeHtml(html)` | The sanitizer the editor uses. Use it before rendering saved HTML with `dangerouslySetInnerHTML`. |
|
|
59
|
+
| `formatHtml(html)` | Indents HTML for display in a source view. |
|
|
60
|
+
| `DEFAULT_TOOLBAR`, `DEFAULT_CONTENT_STYLE`, `FONT_FAMILIES` | Defaults, for building a custom toolbar or content style. |
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|