hazo_ui 2.2.3 → 2.3.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 +255 -0
- package/dist/index.cjs +2685 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -13
- package/dist/index.d.ts +60 -13
- package/dist/index.js +2650 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +41 -49
- package/package.json +29 -3
- package/tailwind.preset.js +6 -2
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ That's it! The components will now render correctly with proper styling.
|
|
|
55
55
|
|
|
56
56
|
- **[HazoUiFlexInput](#hazouiflexinput)** - An enhanced input component with type validation, character restrictions, and error messaging. Supports numeric, alpha, email, and mixed input types with built-in validation and formatting guides.
|
|
57
57
|
|
|
58
|
+
- **[HazoUiRte](#hazouirte)** - A comprehensive rich text editor for email template generation with variable insertion support, file attachments, and full formatting controls. Built on Tiptap with support for tables, lists, images, and multiple view modes (HTML, Plain Text, Raw HTML).
|
|
59
|
+
|
|
58
60
|
---
|
|
59
61
|
|
|
60
62
|
## HazoUiMultiFilterDialog
|
|
@@ -979,6 +981,259 @@ The component provides default error messages for common validation failures:
|
|
|
979
981
|
|
|
980
982
|
---
|
|
981
983
|
|
|
984
|
+
## HazoUiRte
|
|
985
|
+
|
|
986
|
+
A comprehensive rich text editor component designed for email template generation. Features variable insertion for dynamic content, file attachments, and a full-featured formatting toolbar. Built on [Tiptap](https://tiptap.dev/), a headless editor framework.
|
|
987
|
+
|
|
988
|
+
#### Features
|
|
989
|
+
|
|
990
|
+
- **Rich Text Formatting**: Bold, italic, underline, strikethrough, subscript, superscript
|
|
991
|
+
- **Block Types**: Paragraphs, headings (H1-H3), bullet lists, numbered lists, checklists, blockquotes, code blocks
|
|
992
|
+
- **Font Controls**: Font family selection, font size adjustment (8-72px)
|
|
993
|
+
- **Text Alignment**: Left, center, right, justify
|
|
994
|
+
- **Colors**: Text color and highlight/background color with color picker
|
|
995
|
+
- **Links**: Insert and edit hyperlinks
|
|
996
|
+
- **Images**: Insert images (supports base64 and URLs)
|
|
997
|
+
- **Tables**: Insert tables with custom size, add/remove rows and columns
|
|
998
|
+
- **Horizontal Rules**: Insert dividers
|
|
999
|
+
- **Variable Insertion**: Insert template variables (e.g., `{{first_name}}`) for email personalization
|
|
1000
|
+
- **File Attachments**: Attach files stored as base64-encoded data
|
|
1001
|
+
- **View Modes**: Switch between HTML editor, Plain Text view, and Raw HTML view
|
|
1002
|
+
- **Undo/Redo**: Full history support
|
|
1003
|
+
- **Indent/Outdent**: Control list indentation
|
|
1004
|
+
|
|
1005
|
+
> **Note**: HazoUiRte includes Tiptap and ~17 extension packages. This may impact your bundle size if you're not already using Tiptap in your project.
|
|
1006
|
+
|
|
1007
|
+
#### Type Definitions
|
|
1008
|
+
|
|
1009
|
+
```typescript
|
|
1010
|
+
interface HazoUiRteProps {
|
|
1011
|
+
// Initial HTML content
|
|
1012
|
+
html?: string;
|
|
1013
|
+
|
|
1014
|
+
// Initial plain text (typically not used directly)
|
|
1015
|
+
plain_text?: string;
|
|
1016
|
+
|
|
1017
|
+
// Initial file attachments
|
|
1018
|
+
attachments?: RteAttachment[];
|
|
1019
|
+
|
|
1020
|
+
// Template variables available for insertion
|
|
1021
|
+
variables?: RteVariable[];
|
|
1022
|
+
|
|
1023
|
+
// Callback fired when content changes (debounced 300ms)
|
|
1024
|
+
on_change?: (output: RteOutput) => void;
|
|
1025
|
+
|
|
1026
|
+
// Placeholder text when editor is empty
|
|
1027
|
+
placeholder?: string; // default: "Start typing..."
|
|
1028
|
+
|
|
1029
|
+
// Editor height constraints
|
|
1030
|
+
min_height?: string; // default: "200px"
|
|
1031
|
+
max_height?: string; // default: "400px"
|
|
1032
|
+
|
|
1033
|
+
// Disable editing
|
|
1034
|
+
disabled?: boolean; // default: false
|
|
1035
|
+
|
|
1036
|
+
// Additional CSS classes
|
|
1037
|
+
className?: string;
|
|
1038
|
+
|
|
1039
|
+
// Show view mode tabs (HTML, Plain Text, Raw HTML)
|
|
1040
|
+
show_output_viewer?: boolean; // default: false
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
interface RteAttachment {
|
|
1044
|
+
filename: string; // e.g., "document.pdf"
|
|
1045
|
+
mime_type: string; // e.g., "application/pdf"
|
|
1046
|
+
data: string; // base64 encoded content
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
interface RteVariable {
|
|
1050
|
+
name: string; // Variable name (e.g., "first_name")
|
|
1051
|
+
description: string; // Description shown in dropdown
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
interface RteOutput {
|
|
1055
|
+
html: string; // HTML content
|
|
1056
|
+
plain_text: string; // Plain text content (tags stripped)
|
|
1057
|
+
attachments: RteAttachment[]; // Current attachments
|
|
1058
|
+
}
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1061
|
+
#### Basic Usage
|
|
1062
|
+
|
|
1063
|
+
```tsx
|
|
1064
|
+
import { HazoUiRte, type RteOutput } from 'hazo_ui';
|
|
1065
|
+
import { useState } from 'react';
|
|
1066
|
+
|
|
1067
|
+
function BasicEditor() {
|
|
1068
|
+
const [content, setContent] = useState<RteOutput | null>(null);
|
|
1069
|
+
|
|
1070
|
+
return (
|
|
1071
|
+
<HazoUiRte
|
|
1072
|
+
placeholder="Start typing your content..."
|
|
1073
|
+
min_height="200px"
|
|
1074
|
+
max_height="400px"
|
|
1075
|
+
on_change={(output) => setContent(output)}
|
|
1076
|
+
/>
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
#### Email Template with Variables
|
|
1082
|
+
|
|
1083
|
+
```tsx
|
|
1084
|
+
import { HazoUiRte, type RteOutput, type RteVariable } from 'hazo_ui';
|
|
1085
|
+
import { useState } from 'react';
|
|
1086
|
+
|
|
1087
|
+
function EmailTemplateEditor() {
|
|
1088
|
+
const [content, setContent] = useState<RteOutput | null>(null);
|
|
1089
|
+
|
|
1090
|
+
// Define available template variables
|
|
1091
|
+
const variables: RteVariable[] = [
|
|
1092
|
+
{ name: "first_name", description: "Recipient's first name" },
|
|
1093
|
+
{ name: "last_name", description: "Recipient's last name" },
|
|
1094
|
+
{ name: "email", description: "Recipient's email address" },
|
|
1095
|
+
{ name: "company_name", description: "Company name" },
|
|
1096
|
+
{ name: "order_id", description: "Order ID number" },
|
|
1097
|
+
{ name: "order_date", description: "Date of order" },
|
|
1098
|
+
{ name: "total_amount", description: "Total order amount" },
|
|
1099
|
+
];
|
|
1100
|
+
|
|
1101
|
+
// Initial template HTML
|
|
1102
|
+
const initialHtml = `
|
|
1103
|
+
<h2>Order Confirmation</h2>
|
|
1104
|
+
<p>Dear <span data-variable="first_name">{{first_name}}</span>,</p>
|
|
1105
|
+
<p>Thank you for your order!</p>
|
|
1106
|
+
<p>Order ID: <span data-variable="order_id">{{order_id}}</span></p>
|
|
1107
|
+
<p>Total: <span data-variable="total_amount">{{total_amount}}</span></p>
|
|
1108
|
+
`;
|
|
1109
|
+
|
|
1110
|
+
return (
|
|
1111
|
+
<HazoUiRte
|
|
1112
|
+
html={initialHtml}
|
|
1113
|
+
variables={variables}
|
|
1114
|
+
placeholder="Compose your email template..."
|
|
1115
|
+
show_output_viewer={true}
|
|
1116
|
+
on_change={(output) => {
|
|
1117
|
+
setContent(output);
|
|
1118
|
+
console.log('HTML:', output.html);
|
|
1119
|
+
console.log('Plain text:', output.plain_text);
|
|
1120
|
+
}}
|
|
1121
|
+
/>
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
#### With File Attachments
|
|
1127
|
+
|
|
1128
|
+
```tsx
|
|
1129
|
+
import { HazoUiRte, type RteOutput, type RteAttachment } from 'hazo_ui';
|
|
1130
|
+
import { useState } from 'react';
|
|
1131
|
+
|
|
1132
|
+
function EditorWithAttachments() {
|
|
1133
|
+
const [content, setContent] = useState<RteOutput | null>(null);
|
|
1134
|
+
|
|
1135
|
+
// Pre-loaded attachments (if any)
|
|
1136
|
+
const initialAttachments: RteAttachment[] = [
|
|
1137
|
+
{
|
|
1138
|
+
filename: "terms.pdf",
|
|
1139
|
+
mime_type: "application/pdf",
|
|
1140
|
+
data: "JVBERi0xLjQK...", // base64 encoded PDF
|
|
1141
|
+
},
|
|
1142
|
+
];
|
|
1143
|
+
|
|
1144
|
+
return (
|
|
1145
|
+
<HazoUiRte
|
|
1146
|
+
html="<p>Please see the attached document.</p>"
|
|
1147
|
+
attachments={initialAttachments}
|
|
1148
|
+
on_change={(output) => {
|
|
1149
|
+
setContent(output);
|
|
1150
|
+
// Access attachments from output
|
|
1151
|
+
console.log('Attachments:', output.attachments);
|
|
1152
|
+
}}
|
|
1153
|
+
/>
|
|
1154
|
+
);
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
#### With Output Viewer Tabs
|
|
1159
|
+
|
|
1160
|
+
The `show_output_viewer` prop enables tabs to switch between different views:
|
|
1161
|
+
|
|
1162
|
+
- **HTML**: The rich text editor (default, editable)
|
|
1163
|
+
- **Plain Text**: Plain text version with HTML tags stripped (view-only)
|
|
1164
|
+
- **Raw HTML**: Formatted HTML source code (view-only)
|
|
1165
|
+
|
|
1166
|
+
```tsx
|
|
1167
|
+
import { HazoUiRte } from 'hazo_ui';
|
|
1168
|
+
|
|
1169
|
+
function EditorWithViewer() {
|
|
1170
|
+
return (
|
|
1171
|
+
<HazoUiRte
|
|
1172
|
+
html="<p>Hello <strong>World</strong>!</p>"
|
|
1173
|
+
show_output_viewer={true}
|
|
1174
|
+
min_height="300px"
|
|
1175
|
+
/>
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
When viewing Plain Text or Raw HTML tabs, the toolbar is disabled (grayed out) since those are view-only modes.
|
|
1181
|
+
|
|
1182
|
+
#### Disabled State
|
|
1183
|
+
|
|
1184
|
+
```tsx
|
|
1185
|
+
import { HazoUiRte } from 'hazo_ui';
|
|
1186
|
+
|
|
1187
|
+
function ReadOnlyEditor() {
|
|
1188
|
+
return (
|
|
1189
|
+
<HazoUiRte
|
|
1190
|
+
html="<p>This content cannot be edited.</p>"
|
|
1191
|
+
disabled={true}
|
|
1192
|
+
/>
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
#### Props Reference
|
|
1198
|
+
|
|
1199
|
+
| Prop | Type | Default | Description |
|
|
1200
|
+
|------|------|---------|-------------|
|
|
1201
|
+
| `html` | `string` | `""` | Initial HTML content |
|
|
1202
|
+
| `plain_text` | `string` | - | Initial plain text (rarely used) |
|
|
1203
|
+
| `attachments` | `RteAttachment[]` | `[]` | Initial file attachments |
|
|
1204
|
+
| `variables` | `RteVariable[]` | `[]` | Template variables for insertion |
|
|
1205
|
+
| `on_change` | `(output: RteOutput) => void` | - | Callback when content changes (debounced 300ms) |
|
|
1206
|
+
| `placeholder` | `string` | `"Start typing..."` | Placeholder text |
|
|
1207
|
+
| `min_height` | `string` | `"200px"` | Minimum editor height |
|
|
1208
|
+
| `max_height` | `string` | `"400px"` | Maximum editor height |
|
|
1209
|
+
| `disabled` | `boolean` | `false` | Disable editing |
|
|
1210
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
1211
|
+
| `show_output_viewer` | `boolean` | `false` | Show HTML/Plain Text/Raw HTML tabs |
|
|
1212
|
+
|
|
1213
|
+
#### Toolbar Controls
|
|
1214
|
+
|
|
1215
|
+
The toolbar includes the following controls (left to right):
|
|
1216
|
+
|
|
1217
|
+
1. **Undo/Redo** - History navigation
|
|
1218
|
+
2. **Block Type** - Paragraph, Headings, Lists, Code, Quote
|
|
1219
|
+
3. **Font Family** - Arial, Verdana, Times New Roman, Georgia, Courier New, Trebuchet MS
|
|
1220
|
+
4. **Font Size** - Decrease/Increase (8-72px)
|
|
1221
|
+
5. **Text Formatting** - Bold, Italic, Underline, Strikethrough, Subscript, Superscript
|
|
1222
|
+
6. **Link** - Insert/edit hyperlinks
|
|
1223
|
+
7. **Clear Formatting** - Remove all formatting
|
|
1224
|
+
8. **Text Color** - Color picker for text
|
|
1225
|
+
9. **Highlight Color** - Color picker for background
|
|
1226
|
+
10. **Text Alignment** - Left, Center, Right, Justify
|
|
1227
|
+
11. **Lists** - Bullet list, Numbered list, Checklist
|
|
1228
|
+
12. **Indent/Outdent** - Adjust list indentation
|
|
1229
|
+
13. **Horizontal Rule** - Insert divider
|
|
1230
|
+
14. **Image** - Insert image
|
|
1231
|
+
15. **Table** - Insert table with size picker, add/remove rows/columns
|
|
1232
|
+
16. **Variables** - Insert template variables (if `variables` prop provided)
|
|
1233
|
+
17. **Attachment** - Attach files
|
|
1234
|
+
|
|
1235
|
+
---
|
|
1236
|
+
|
|
982
1237
|
## Styling
|
|
983
1238
|
|
|
984
1239
|
Both components use Tailwind CSS and follow shadcn/ui design patterns. Make sure your project has Tailwind CSS configured with the following CSS variables:
|