@kontakto/email-template-editor 2.7.0 → 2.8.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 +52 -0
- package/dist/index.cjs +758 -735
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +552 -529
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,6 +186,58 @@ const uploadImage = async (file: File) => {
|
|
|
186
186
|
|
|
187
187
|
Newly uploaded images get their `width` / `height` set on the resulting Image block — important for Outlook, which needs explicit dimensions to lay the email out before images load.
|
|
188
188
|
|
|
189
|
+
#### Example PostgreSQL schema
|
|
190
|
+
|
|
191
|
+
A minimal schema that maps directly onto `SavePayload`, `TemplateListItem`, and the image-library callbacks. The editor itself is backend-agnostic — this is just a reference starting point.
|
|
192
|
+
|
|
193
|
+
```sql
|
|
194
|
+
-- Email templates (user-editable rows + org-wide read-only samples)
|
|
195
|
+
create table email_templates (
|
|
196
|
+
id uuid primary key default gen_random_uuid(),
|
|
197
|
+
slug text not null, -- primary label shown in the drawer
|
|
198
|
+
kind text not null check (kind in ('template', 'sample')),
|
|
199
|
+
description text,
|
|
200
|
+
subject text, -- mirrors editor_config.root.data.subject
|
|
201
|
+
variables jsonb not null default '[]'::jsonb, -- [{ name, description?, sampleValue? }]
|
|
202
|
+
tags text[] not null default '{}',
|
|
203
|
+
thumbnail_url text,
|
|
204
|
+
|
|
205
|
+
-- Source of truth: full TEditorConfiguration from SavePayload.editorConfig
|
|
206
|
+
editor_config jsonb not null,
|
|
207
|
+
|
|
208
|
+
-- Pre-rendered output from the save pipeline; usually what you ship to the sender
|
|
209
|
+
body_html text not null,
|
|
210
|
+
body_text text not null,
|
|
211
|
+
|
|
212
|
+
-- null for org-wide samples, set for user/tenant-owned templates
|
|
213
|
+
owner_id uuid references users(id) on delete cascade,
|
|
214
|
+
|
|
215
|
+
created_at timestamptz not null default now(),
|
|
216
|
+
updated_at timestamptz not null default now(),
|
|
217
|
+
|
|
218
|
+
unique (owner_id, slug)
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
create index email_templates_owner_kind_idx on email_templates (owner_id, kind);
|
|
222
|
+
create index email_templates_tags_gin_idx on email_templates using gin (tags);
|
|
223
|
+
|
|
224
|
+
-- Image library backing uploadImage / loadImages / deleteImage
|
|
225
|
+
create table email_images (
|
|
226
|
+
id uuid primary key default gen_random_uuid(),
|
|
227
|
+
url text not null unique,
|
|
228
|
+
thumbnail_url text,
|
|
229
|
+
width int,
|
|
230
|
+
height int,
|
|
231
|
+
alt text,
|
|
232
|
+
owner_id uuid references users(id) on delete cascade,
|
|
233
|
+
uploaded_at timestamptz not null default now()
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
create index email_images_owner_uploaded_idx on email_images (owner_id, uploaded_at desc);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
`loadTemplates` typically scopes to `owner_id = :user` with `kind = 'template'`; `loadSamples` returns `kind = 'sample'` (often ignoring `owner_id`, or scoping to an org). The `kind` column — not which endpoint returned the row — decides which drawer section a template appears in.
|
|
240
|
+
|
|
189
241
|
| `theme` | object | theme.ts | Custom theme for the EmailEditor, must be a Material UI theme object |
|
|
190
242
|
|
|
191
243
|
#### Imperative API
|