@lit-pigeon/core 0.3.2 → 0.4.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 +44 -17
- package/dist/gallery.cjs +1 -0
- package/dist/gallery.d.ts +317 -0
- package/dist/gallery.js +407 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.ts +212 -12
- package/dist/index.js +373 -265
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,26 +17,33 @@ npm install @lit-pigeon/core
|
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import {
|
|
20
|
-
createDefaultDocument,
|
|
21
20
|
EditorState,
|
|
21
|
+
createBlock,
|
|
22
|
+
createColumn,
|
|
23
|
+
createDefaultDocument,
|
|
22
24
|
createHistoryPlugin,
|
|
25
|
+
createRow,
|
|
26
|
+
getStarterTemplate,
|
|
27
|
+
insertRow,
|
|
28
|
+
undo,
|
|
23
29
|
validateDocument,
|
|
24
|
-
getStarterTemplates,
|
|
25
30
|
} from '@lit-pigeon/core';
|
|
26
31
|
|
|
27
|
-
// Start from a blank document, or a starter template
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
32
|
+
// Start from a blank document, or a starter template
|
|
33
|
+
// (starter-welcome, starter-newsletter, starter-transactional, starter-promo).
|
|
34
|
+
const doc = createDefaultDocument('Welcome email');
|
|
35
|
+
const welcome = getStarterTemplate('starter-welcome')?.document;
|
|
31
36
|
|
|
32
|
-
//
|
|
37
|
+
// Edits are commands that dispatch transactions; state is immutable.
|
|
33
38
|
let state = EditorState.create({ doc, plugins: [createHistoryPlugin()] });
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const dispatch = (tr: Parameters<typeof state.apply>[0]) => {
|
|
40
|
+
state = state.apply(tr);
|
|
41
|
+
};
|
|
42
|
+
insertRow(createRow([createColumn([createBlock('text')])]), 0)(state, dispatch);
|
|
43
|
+
undo(state, dispatch);
|
|
37
44
|
|
|
38
|
-
// Validate before rendering
|
|
39
|
-
const errors = validateDocument(
|
|
45
|
+
// Validate untrusted input before rendering or storing it.
|
|
46
|
+
const errors = validateDocument(welcome); // [] when valid; [{ path, message }] otherwise
|
|
40
47
|
```
|
|
41
48
|
|
|
42
49
|
`PigeonDocument` is a plain JSON tree (`body → rows → columns → blocks`), so it
|
|
@@ -44,11 +51,31 @@ serialises anywhere. Render it to email HTML with
|
|
|
44
51
|
[`@lit-pigeon/renderer-mjml`](../renderer-mjml) or
|
|
45
52
|
[`@lit-pigeon/ssr`](../ssr).
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`
|
|
54
|
+
## API summary
|
|
55
|
+
|
|
56
|
+
- **Types**: `PigeonDocument`, `RowNode`, `ColumnNode`, the nine built-in block
|
|
57
|
+
types (`TextBlock`, `ImageBlock`, `ButtonBlock`, `DividerBlock`,
|
|
58
|
+
`SpacerBlock`, `SocialBlock`, `HtmlBlock`, `HeroBlock`, `NavBarBlock`),
|
|
59
|
+
`CustomBlock`/`AnyBlock`, `EditorConfig` and its parts (`AssetManagerConfig`,
|
|
60
|
+
`MergeTagConfig`, `FontDefinition`, `LinkType`), `PigeonPlugin`,
|
|
61
|
+
`BlockDefinition`, `Renderer`/`RenderOptions`/`RenderResult`.
|
|
62
|
+
- **State**: `EditorState`, `Transaction`, `createDocStep`, selection helpers.
|
|
63
|
+
- **Commands**: `insertBlock`, `deleteBlock`, `updateBlock`, `moveBlock`,
|
|
64
|
+
`duplicateBlock`, `insertRow`, `deleteRow`, `moveRow`, `duplicateRow`,
|
|
65
|
+
`updateRowAttributes`, `addColumn`, `removeColumn`, `resizeColumns`.
|
|
66
|
+
- **History**: `createHistoryPlugin`, `undo`, `redo`, `canUndo`, `canRedo`.
|
|
67
|
+
- **Factories and schema**: `createDefaultDocument`, `createBlock` (built-in or
|
|
68
|
+
registered types), `createRow`, `createColumn`, `validateDocument`,
|
|
69
|
+
`isValidDocument`. Validation accepts only the built-in block types.
|
|
70
|
+
- **Block registry**: `registerBlock`, `getBlockDefinition`,
|
|
71
|
+
`getAllBlockDefinitions`, `isKnownBlockType`.
|
|
72
|
+
- **Templates and storage**: `getStarterTemplates`, `getStarterTemplate`,
|
|
73
|
+
storage interfaces and in-memory implementations (`InMemoryTemplateStorage`,
|
|
74
|
+
`InMemoryBrandKitStorage`, `InMemoryAssetStorage`,
|
|
75
|
+
`InMemoryRowLibraryStorage`), `cloneRowWithNewIds`, `SYSTEM_LINK_TYPES`.
|
|
76
|
+
|
|
77
|
+
See the [developer guide](../../docs/guide/README.md) for how these fit
|
|
78
|
+
together.
|
|
52
79
|
|
|
53
80
|
Part of [Lit Pigeon](https://github.com/snxstudio/lit-pigeon) — open-source drag-and-drop email editor.
|
|
54
81
|
|
package/dist/gallery.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u="2026-09-23T10:00:00.000Z",v="Inter, Helvetica, Arial, sans-serif",f="#0f172a",i="#64748b",k="#e2e8f0",r=(t,e=t,n=t,o=e)=>({top:t,right:e,bottom:n,left:o}),m=r(0);function g(t,e){return{id:`starter-${t.id}`,name:t.name,description:t.description,category:t.category,createdAt:u,updatedAt:u,document:{version:"1.0",metadata:{name:t.name,previewText:t.previewText,createdAt:u,updatedAt:u},body:{attributes:{width:600,backgroundColor:t.background,fontFamily:v,contentAlignment:"center"},rows:e(w(t.id))}}}}function w(t){let e=0;const n=p=>`${t}-${p}${++e}`,o=(p,c={})=>({id:n("r"),type:"row",locked:!1,attributes:{...c.background?{backgroundColor:c.background}:{},padding:c.padding??r(16,32),fullWidth:c.fullWidth??!1},columnRatios:c.ratios??[12],columns:p.map(d=>({id:n("c"),type:"column",attributes:{padding:m,verticalAlign:c.align??"top"},blocks:d}))}),a=(p,c="left",d=m)=>({id:n("b"),type:"text",values:{content:p,padding:d,lineHeight:"1.6",textAlign:c}}),s=(p,c,d={})=>({id:n("b"),type:"button",values:{content:`<p>${p}</p>`,href:c,backgroundColor:d.color??f,textColor:"#ffffff",borderRadius:6,padding:r(16,0),innerPadding:r(14,28),fontSize:16,fontWeight:"600",alignment:d.align??"left",fullWidth:d.fullWidth??!1}}),l=(p,c,d={})=>({id:n("b"),type:"image",values:{src:p,alt:c,width:d.width??"auto",...d.href?{href:d.href}:{},padding:m,alignment:"center",...d.radius?{borderRadius:d.radius}:{}}}),x=(p=r(8,0))=>({id:n("b"),type:"divider",values:{borderColor:k,borderWidth:1,borderStyle:"solid",padding:p,width:"100%"}}),y=()=>({id:n("b"),type:"social",values:{icons:[{type:"instagram",href:"https://instagram.com/"},{type:"linkedin",href:"https://linkedin.com/"},{type:"youtube",href:"https://youtube.com/"}],iconSize:24,spacing:8,alignment:"center",padding:r(8,0)}});return{row:o,text:a,button:s,image:l,divider:x,social:y,logo:(p=f)=>o([[a(`<p style="margin:0;font-size:18px;font-weight:700;color:${p};">{{company}}</p>`)]],{padding:r(24,32,8)}),serviceFooter:p=>o([[a(`<p style="margin:0;color:${i};font-size:12px;">${p}<br>{{company}} · {{companyAddress}}</p>`,"center")]],{padding:r(24,32)}),marketingFooter:()=>o([[y(),a(`<p style="margin:0;color:${i};font-size:12px;">You're receiving this because you subscribed to {{company}}.<br><a href="{{unsubscribeUrl}}" style="color:${i};">Unsubscribe</a> · <a href="{{webViewUrl}}" style="color:${i};">View in browser</a></p>`,"center")]],{padding:r(24,32)}),line:(p,c,d={})=>{const h=b=>d.strong?`<strong>${b}</strong>`:b;return o([[a(`<p style="margin:0;">${h(p)}</p>`)],[a(`<p style="margin:0;">${h(c)}</p>`,"right")]],{ratios:[8,4],background:d.background??"#ffffff",padding:r(6,32)})}}}const z=g({id:"order-confirmation",name:"Order confirmation",description:"Itemised receipt with totals, delivery address and a link to the order.",category:"transactional",previewText:"We have your order {{orderNumber}}.",background:"#f1f5f9"},({row:t,text:e,button:n,divider:o,logo:a,serviceFooter:s,line:l})=>[a(),t([[e(`<h1 style="margin:0 0 8px;font-size:26px;color:${f};">Thanks for your order, {{firstName}}</h1><p style="margin:0;color:${i};">Order <strong>{{orderNumber}}</strong> · placed {{orderDate}}</p>`)]],{background:"#ffffff",padding:r(32,32,16)}),t([[o()]],{background:"#ffffff",padding:r(0,32)}),l("Linen shirt × 1","$48.00"),l("Wool jumper × 1","$84.00"),t([[o()]],{background:"#ffffff",padding:r(0,32)}),l("Subtotal","{{subtotal}}"),l("Shipping","{{shipping}}"),l("Total","{{total}}",{strong:!0}),t([[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};text-transform:uppercase;letter-spacing:1px;">Delivering to</p><p style="margin:0;">{{shippingName}}<br>{{shippingAddress}}</p>`)],[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};text-transform:uppercase;letter-spacing:1px;">Estimated delivery</p><p style="margin:0;">{{deliveryDate}}</p>`)]],{ratios:[6,6],background:"#f8fafc",padding:r(20,32)}),t([[n("View your order","{{orderUrl}}")]],{background:"#ffffff",padding:r(24,32,32)}),s("Questions about your order? Reply to this email.")]),$=g({id:"shipping-update",name:"Shipping update",description:"Dispatch notice with carrier, tracking number and a progress line.",category:"transactional",previewText:"Order {{orderNumber}} has shipped.",background:"#f1f5f9"},({row:t,text:e,button:n,logo:o,serviceFooter:a})=>[o(),t([[e(`<p style="margin:0 0 8px;font-size:12px;color:#2563eb;font-weight:600;text-transform:uppercase;letter-spacing:1px;">On its way</p><h1 style="margin:0 0 8px;font-size:26px;color:${f};">Your order has shipped</h1><p style="margin:0;color:${i};">Good news, {{firstName}}: order <strong>{{orderNumber}}</strong> left our warehouse today.</p>`)]],{background:"#ffffff",padding:r(32,32,16)}),t([[e('<p style="margin:0;color:#2563eb;font-weight:600;">● Ordered</p>',"left")],[e('<p style="margin:0;color:#2563eb;font-weight:600;">● Shipped</p>',"center")],[e(`<p style="margin:0;color:${i};">○ Delivered</p>`,"right")]],{ratios:[4,4,4],background:"#ffffff",padding:r(8,32)}),t([[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};">Carrier</p><p style="margin:0;"><strong>{{carrier}}</strong></p>`)],[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};">Tracking number</p><p style="margin:0;"><strong>{{trackingNumber}}</strong></p>`)],[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};">Expected</p><p style="margin:0;"><strong>{{deliveryDate}}</strong></p>`)]],{ratios:[4,4,4],background:"#f8fafc",padding:r(20,32)}),t([[n("Track your parcel","{{trackingUrl}}",{color:"#2563eb"})]],{background:"#ffffff",padding:r(24,32,32)}),a("Tracking can take up to 24 hours to show the first scan.")]),T=g({id:"password-reset",name:"Password reset",description:"Short, single-action reset email with an expiry note and a safety line.",category:"transactional",previewText:"Reset your {{company}} password.",background:"#f1f5f9"},({row:t,text:e,button:n,divider:o,logo:a,serviceFooter:s})=>[a(),t([[e(`<h1 style="margin:0 0 12px;font-size:24px;color:${f};">Reset your password</h1><p style="margin:0;">Hi {{firstName}}, we received a request to reset the password for <strong>{{email}}</strong>. Choose a new one with the button below.</p>`),n("Choose a new password","{{resetUrl}}"),e(`<p style="margin:0;color:${i};font-size:14px;">This link expires in {{expiryMinutes}} minutes and can only be used once.</p>`),o(r(16,0)),e(`<p style="margin:0;color:${i};font-size:13px;">Didn't ask for this? You can ignore this email; your password won't change. If you think someone else is trying to access your account, <a href="{{supportUrl}}" style="color:${i};">contact support</a>.</p>`)]],{background:"#ffffff",padding:r(32)}),s("This is an automated security message.")]),N=g({id:"invoice",name:"Invoice / receipt",description:"Invoice with billing details, line items, tax, total due and a pay button.",category:"transactional",previewText:"Invoice {{invoiceNumber}} for {{total}}.",background:"#f1f5f9"},({row:t,text:e,button:n,divider:o,serviceFooter:a,line:s})=>[t([[e(`<p style="margin:0;font-size:18px;font-weight:700;color:${f};">{{company}}</p>`)],[e(`<p style="margin:0;font-size:22px;font-weight:700;color:${i};letter-spacing:2px;">INVOICE</p>`,"right")]],{ratios:[6,6],padding:r(24,32,8),align:"middle"}),t([[e(`<p style="margin:0 0 4px;font-size:12px;color:${i};">Billed to</p><p style="margin:0;">{{customerName}}<br>{{billingAddress}}</p>`)],[e('<p style="margin:0;font-size:14px;">Invoice <strong>{{invoiceNumber}}</strong><br>Issued {{invoiceDate}}<br>Due {{dueDate}}</p>',"right")]],{ratios:[6,6],background:"#ffffff",padding:r(28,32,16)}),t([[e(`<p style="margin:0;font-size:12px;color:${i};text-transform:uppercase;letter-spacing:1px;">Description</p>`)],[e(`<p style="margin:0;font-size:12px;color:${i};text-transform:uppercase;letter-spacing:1px;">Amount</p>`,"right")]],{ratios:[8,4],background:"#f8fafc",padding:r(10,32)}),s("Pro plan, monthly","$49.00"),s("Additional seats × 3","$27.00"),t([[o()]],{background:"#ffffff",padding:r(0,32)}),s("Subtotal","{{subtotal}}"),s("Tax","{{tax}}"),s("Total due","{{total}}",{strong:!0}),t([[n("Pay this invoice","{{paymentUrl}}",{color:"#16a34a"})]],{background:"#ffffff",padding:r(24,32,32)}),a("Keep this email for your records. A PDF copy is available from your billing page.")]),A=g({id:"event-invite",name:"Event invitation",description:"Invitation with date, time and venue, an agenda and an RSVP button.",category:"announcement",previewText:"You are invited: {{eventName}}.",background:"#faf5ff"},({row:t,text:e,button:n,image:o,divider:a,marketingFooter:s})=>[t([[o("https://placehold.co/600x260/6d28d9/ffffff?text=You%27re+invited","You're invited")]],{padding:m,fullWidth:!0}),t([[e(`<h1 style="margin:0 0 12px;font-size:28px;color:${f};">{{eventName}}</h1><p style="margin:0;">Hi {{firstName}}, join us for an evening of short talks, demos and conversation with the people building {{company}}.</p>`)]],{background:"#ffffff",padding:r(32,32,16)}),t([[e('<p style="margin:0 0 4px;font-size:12px;color:#6d28d9;font-weight:600;">DATE</p><p style="margin:0;">{{eventDate}}</p>')],[e('<p style="margin:0 0 4px;font-size:12px;color:#6d28d9;font-weight:600;">TIME</p><p style="margin:0;">{{eventTime}}</p>')],[e('<p style="margin:0 0 4px;font-size:12px;color:#6d28d9;font-weight:600;">WHERE</p><p style="margin:0;">{{venue}}</p>')]],{ratios:[4,4,4],background:"#f5f3ff",padding:r(20,32)}),t([[e('<p style="margin:0 0 8px;"><strong>Agenda</strong></p><p style="margin:0;">18:00 · Doors and drinks<br>18:30 · Talks<br>19:30 · Demos and Q&A<br>20:30 · Close</p>'),a(r(16,0)),n("RSVP now","{{rsvpUrl}}",{color:"#6d28d9",align:"center",fullWidth:!0}),e(`<p style="margin:0;color:${i};font-size:13px;">Places are limited. Please reply by {{rsvpDeadline}}.</p>`,"center",r(8,0,0))]],{background:"#ffffff",padding:r(24,32,32)}),s()]),S=g({id:"product-launch",name:"Product launch",description:"Launch announcement with a hero, three feature highlights and a primary CTA.",category:"announcement",previewText:"Introducing {{productName}}.",background:"#0f172a"},({row:t,text:e,button:n,image:o,marketingFooter:a})=>[t([[e('<p style="margin:0 0 12px;font-size:12px;color:#38bdf8;font-weight:600;letter-spacing:2px;">NEW</p><h1 style="margin:0 0 12px;font-size:34px;color:#ffffff;">Meet {{productName}}</h1><p style="margin:0;color:#cbd5e1;font-size:17px;">The fastest way to ship the thing your team keeps putting off.</p>',"center"),n("See what’s new","{{productUrl}}",{color:"#0284c7",align:"center"})]],{padding:r(48,32,24)}),t([[o("https://placehold.co/560x320/1e293b/94a3b8?text=Product+screenshot","Product screenshot",{radius:8})]],{padding:r(0,20,32)}),t([[e('<p style="margin:0 0 6px;font-size:16px;"><strong>Faster</strong></p><p style="margin:0;color:#475569;font-size:14px;">Starts in under a second, even on large projects.</p>')],[e('<p style="margin:0 0 6px;font-size:16px;"><strong>Simpler</strong></p><p style="margin:0;color:#475569;font-size:14px;">One settings page instead of twelve.</p>')],[e('<p style="margin:0 0 6px;font-size:16px;"><strong>Yours</strong></p><p style="margin:0;color:#475569;font-size:14px;">Export everything, any time, in open formats.</p>')]],{ratios:[4,4,4],background:"#ffffff",padding:r(32,24)}),t([[e('<p style="margin:0;">{{firstName}}, existing customers get {{productName}} at no extra cost from today.</p>',"center"),n("Try it now","{{productUrl}}",{align:"center"})]],{background:"#ffffff",padding:r(0,32,32)}),a()]),I=g({id:"abandoned-cart",name:"Abandoned cart",description:"Friendly reminder with the saved item, price and a return-to-cart button.",category:"promo",previewText:"You left something in your cart.",background:"#fdf6ee"},({row:t,text:e,button:n,image:o,divider:a,logo:s,marketingFooter:l})=>[s("#9a3412"),t([[e(`<h1 style="margin:0 0 12px;font-size:26px;color:${f};">Still thinking it over?</h1><p style="margin:0;">Hi {{firstName}}, you left something in your cart. We've saved it for you, but stock is limited.</p>`)]],{background:"#ffffff",padding:r(32,32,16)}),t([[o("https://placehold.co/200x200/fed7aa/9a3412?text=Item","{{cartItemName}}",{width:160,radius:6,href:"{{cartUrl}}"})],[e('<p style="margin:0 0 4px;font-size:18px;"><strong>{{cartItemName}}</strong></p><p style="margin:0 0 4px;color:#64748b;">Qty {{cartItemQuantity}}</p><p style="margin:0;font-size:18px;">{{cartItemPrice}}</p>')]],{ratios:[5,7],background:"#ffffff",padding:r(8,32),align:"middle"}),t([[a(r(16,0)),n("Return to your cart","{{cartUrl}}",{color:"#ea580c",fullWidth:!0}),e(`<p style="margin:0;color:${i};font-size:13px;">Free returns within 30 days. Need help? Reply to this email.</p>`,"center",r(8,0,0))]],{background:"#ffffff",padding:r(8,32,32)}),l()]),D=g({id:"monthly-digest",name:"Monthly digest",description:"Round-up with a lead story, two secondary stories and a numbers strip.",category:"newsletter",previewText:"Your {{month}} round-up from {{company}}.",background:"#f8fafc"},({row:t,text:e,button:n,image:o,divider:a,logo:s,marketingFooter:l})=>[s(),t([[e(`<p style="margin:0;color:${i};font-size:13px;">{{month}} digest · Issue {{issueNumber}}</p>`)]],{padding:r(0,32,16)}),t([[o("https://placehold.co/536x240/cbd5e1/334155?text=Lead+story","Lead story",{radius:6,href:"https://example.com/lead"}),e(`<h2 style="margin:16px 0 8px;font-size:22px;color:${f};">What we shipped this month</h2><p style="margin:0;">A faster editor, a cleaner export and a long-requested dark mode. Here is the short version, {{firstName}}.</p>`),n("Read the full story","https://example.com/lead")]],{background:"#ffffff",padding:r(32)}),t([[o("https://placehold.co/260x160/e2e8f0/475569?text=Story+two","Story two",{radius:6,href:"https://example.com/two"}),e('<p style="margin:12px 0 4px;"><strong>How one team halved its send time</strong></p><p style="margin:0;color:#475569;font-size:14px;">A customer story in five charts.</p>')],[o("https://placehold.co/260x160/e2e8f0/475569?text=Story+three","Story three",{radius:6,href:"https://example.com/three"}),e('<p style="margin:12px 0 4px;"><strong>Five layouts that work in every inbox</strong></p><p style="margin:0;color:#475569;font-size:14px;">Tested in Outlook, Gmail and Apple Mail.</p>')]],{ratios:[6,6],background:"#ffffff",padding:r(0,32,24)}),t([[a()]],{background:"#ffffff",padding:r(0,32)}),t([[e(`<p style="margin:0;font-size:24px;font-weight:700;color:${f};">{{stat1}}</p><p style="margin:0;color:${i};font-size:13px;">emails sent</p>`,"center")],[e(`<p style="margin:0;font-size:24px;font-weight:700;color:${f};">{{stat2}}</p><p style="margin:0;color:${i};font-size:13px;">new customers</p>`,"center")],[e(`<p style="margin:0;font-size:24px;font-weight:700;color:${f};">{{stat3}}</p><p style="margin:0;color:${i};font-size:13px;">uptime</p>`,"center")]],{ratios:[4,4,4],background:"#ffffff",padding:r(16,32,32)}),l()]),E=Object.freeze([z,$,T,N,A,S,I,D]);exports.GALLERY_TEMPLATES=E;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A border applied to all four sides. Structured here and serialised to the
|
|
3
|
+
* CSS shorthand at the MJML boundary, the same way {@link Spacing} is.
|
|
4
|
+
* Per-side borders are deliberately not modelled until something needs them.
|
|
5
|
+
*/
|
|
6
|
+
declare interface Border {
|
|
7
|
+
width: number;
|
|
8
|
+
style: 'solid' | 'dashed' | 'dotted';
|
|
9
|
+
color: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare interface ButtonBlock {
|
|
13
|
+
id: string;
|
|
14
|
+
type: 'button';
|
|
15
|
+
values: DeviceVisibility & {
|
|
16
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
17
|
+
condition?: string;
|
|
18
|
+
content: string;
|
|
19
|
+
href: string;
|
|
20
|
+
backgroundColor: string;
|
|
21
|
+
textColor: string;
|
|
22
|
+
borderRadius: number;
|
|
23
|
+
/** Omitted for a borderless button; MJML's own default is `border: none`. */
|
|
24
|
+
border?: Border;
|
|
25
|
+
padding: Spacing;
|
|
26
|
+
innerPadding: Spacing;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
fontWeight: string;
|
|
29
|
+
alignment: 'left' | 'center' | 'right';
|
|
30
|
+
fullWidth: boolean;
|
|
31
|
+
/** Written out as MJML `css-class`. */
|
|
32
|
+
cssClass?: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare interface ColumnNode {
|
|
37
|
+
id: string;
|
|
38
|
+
type: 'column';
|
|
39
|
+
attributes: DeviceVisibility & {
|
|
40
|
+
backgroundColor?: string;
|
|
41
|
+
padding: Spacing;
|
|
42
|
+
borderRadius?: number;
|
|
43
|
+
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
44
|
+
/** Written out as MJML `css-class`. */
|
|
45
|
+
cssClass?: string;
|
|
46
|
+
};
|
|
47
|
+
blocks: ContentBlock[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare type ContentBlock = TextBlock | ImageBlock | ButtonBlock | DividerBlock | SpacerBlock | SocialBlock | HtmlBlock | HeroBlock | NavBarBlock;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Hides a block or column at one breakpoint. Rendered as an MJML `css-class`
|
|
54
|
+
* (`pigeon-hide-mobile` / `pigeon-hide-desktop`) plus a media query.
|
|
55
|
+
*/
|
|
56
|
+
declare type DeviceVisibility = {
|
|
57
|
+
hideOnMobile?: boolean;
|
|
58
|
+
hideOnDesktop?: boolean;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
declare interface DividerBlock {
|
|
62
|
+
id: string;
|
|
63
|
+
type: 'divider';
|
|
64
|
+
values: DeviceVisibility & {
|
|
65
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
66
|
+
condition?: string;
|
|
67
|
+
borderColor: string;
|
|
68
|
+
borderWidth: number;
|
|
69
|
+
borderStyle: 'solid' | 'dashed' | 'dotted';
|
|
70
|
+
padding: Spacing;
|
|
71
|
+
width: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export declare const GALLERY_TEMPLATES: readonly Template[];
|
|
76
|
+
|
|
77
|
+
declare interface HeroBlock {
|
|
78
|
+
id: string;
|
|
79
|
+
type: 'hero';
|
|
80
|
+
values: DeviceVisibility & {
|
|
81
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
82
|
+
condition?: string;
|
|
83
|
+
backgroundUrl: string;
|
|
84
|
+
backgroundPosition: 'center center' | 'top center' | 'bottom center' | 'left center' | 'right center';
|
|
85
|
+
mode: 'fixed-height' | 'fluid-height';
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
89
|
+
padding: Spacing;
|
|
90
|
+
innerPadding: Spacing;
|
|
91
|
+
backgroundColor: string;
|
|
92
|
+
content: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare interface HtmlBlock {
|
|
97
|
+
id: string;
|
|
98
|
+
type: 'html';
|
|
99
|
+
values: DeviceVisibility & {
|
|
100
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
101
|
+
condition?: string;
|
|
102
|
+
content: string;
|
|
103
|
+
padding: Spacing;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare interface ImageBlock {
|
|
108
|
+
id: string;
|
|
109
|
+
type: 'image';
|
|
110
|
+
values: DeviceVisibility & {
|
|
111
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
112
|
+
condition?: string;
|
|
113
|
+
src: string;
|
|
114
|
+
alt: string;
|
|
115
|
+
width: number | 'auto';
|
|
116
|
+
href?: string;
|
|
117
|
+
padding: Spacing;
|
|
118
|
+
alignment: 'left' | 'center' | 'right';
|
|
119
|
+
borderRadius?: number;
|
|
120
|
+
/** Written out as MJML `css-class`. */
|
|
121
|
+
cssClass?: string;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Document-level link styling. A brand setting rather than a per-link
|
|
127
|
+
* decision, so it lives on the body and is rendered as one `<mj-style>` rule
|
|
128
|
+
* targeting `a`. Each part is optional; whatever is unset stays at the
|
|
129
|
+
* client's default.
|
|
130
|
+
*/
|
|
131
|
+
declare interface LinkStyle_2 {
|
|
132
|
+
color?: string;
|
|
133
|
+
underline?: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare interface NavBarBlock {
|
|
137
|
+
id: string;
|
|
138
|
+
type: 'navbar';
|
|
139
|
+
values: DeviceVisibility & {
|
|
140
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
141
|
+
condition?: string;
|
|
142
|
+
links: NavLink[];
|
|
143
|
+
hamburger: 'hamburger' | 'none';
|
|
144
|
+
alignment: 'left' | 'center' | 'right';
|
|
145
|
+
padding: Spacing;
|
|
146
|
+
linkColor: string;
|
|
147
|
+
linkFontSize: number;
|
|
148
|
+
linkPadding: string;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare interface NavLink {
|
|
153
|
+
href: string;
|
|
154
|
+
text: string;
|
|
155
|
+
color?: string;
|
|
156
|
+
fontWeight?: string;
|
|
157
|
+
textDecoration?: string;
|
|
158
|
+
padding?: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
declare interface PigeonDocument {
|
|
162
|
+
version: '1.0';
|
|
163
|
+
metadata: {
|
|
164
|
+
name: string;
|
|
165
|
+
previewText?: string;
|
|
166
|
+
createdAt: string;
|
|
167
|
+
updatedAt: string;
|
|
168
|
+
};
|
|
169
|
+
body: {
|
|
170
|
+
attributes: {
|
|
171
|
+
width: number;
|
|
172
|
+
backgroundColor: string;
|
|
173
|
+
fontFamily: string;
|
|
174
|
+
contentAlignment: 'center' | 'left';
|
|
175
|
+
/**
|
|
176
|
+
* Link colour and underline for the whole document. Omitted, or with a
|
|
177
|
+
* part omitted, links fall back to whatever each client defaults to —
|
|
178
|
+
* blue and underlined in most, purple once visited in some.
|
|
179
|
+
*/
|
|
180
|
+
linkStyle?: LinkStyle_2;
|
|
181
|
+
/**
|
|
182
|
+
* BCP 47 tag, e.g. `"en"`, `"pt-BR"`. Written out as `lang` on `<mjml>`,
|
|
183
|
+
* which MJML copies onto `<html>` and the `role="article"` wrapper.
|
|
184
|
+
* Left unset, the output keeps MJML's own `lang="und"`.
|
|
185
|
+
*/
|
|
186
|
+
language?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Written out as `dir` on `<mjml>`. Defaults to the natural direction of
|
|
189
|
+
* `language`, so it only needs setting to override that.
|
|
190
|
+
*/
|
|
191
|
+
direction?: 'ltr' | 'rtl';
|
|
192
|
+
/** Document-level CSS, written out as a non-inline `<mj-style>`. */
|
|
193
|
+
css?: string;
|
|
194
|
+
};
|
|
195
|
+
rows: RowNode[];
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare interface RowNode {
|
|
200
|
+
id: string;
|
|
201
|
+
type: 'row';
|
|
202
|
+
attributes: DeviceVisibility & {
|
|
203
|
+
backgroundColor?: string;
|
|
204
|
+
backgroundImage?: string;
|
|
205
|
+
/**
|
|
206
|
+
* MJML `background-repeat` for {@link backgroundImage}. Absent means the
|
|
207
|
+
* legacy `no-repeat`; see {@link resolveRowBackground}.
|
|
208
|
+
*/
|
|
209
|
+
backgroundRepeat?: 'repeat' | 'no-repeat';
|
|
210
|
+
/** MJML `background-size`: `cover`, `contain`, `auto` or a CSS length. */
|
|
211
|
+
backgroundSize?: string;
|
|
212
|
+
/** MJML `background-position`, e.g. `top center`. */
|
|
213
|
+
backgroundPosition?: string;
|
|
214
|
+
padding: Spacing;
|
|
215
|
+
fullWidth: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Optional display condition. When set, the row only renders when the
|
|
218
|
+
* expression is truthy in the sending platform's template engine. The
|
|
219
|
+
* renderer wraps the section in `{{#if <condition>}} … {{/if}}` (Handlebars
|
|
220
|
+
* / Liquid-style, passed through verbatim), e.g. `condition: "user.premium"`.
|
|
221
|
+
*/
|
|
222
|
+
condition?: string;
|
|
223
|
+
/**
|
|
224
|
+
* Optional array merge-tag path. When set, the row repeats once per item:
|
|
225
|
+
* the renderer wraps the section in `{{#each <repeat>}} … {{/each}}`
|
|
226
|
+
* (Handlebars), inside any `condition`, e.g. `repeat: "order.items"`.
|
|
227
|
+
* Merge tags inside the row then resolve against the item (`{{name}}`).
|
|
228
|
+
*/
|
|
229
|
+
repeat?: string;
|
|
230
|
+
/** Written out as MJML `css-class`. */
|
|
231
|
+
cssClass?: string;
|
|
232
|
+
/**
|
|
233
|
+
* When true, the columns keep their widths on mobile instead of stacking.
|
|
234
|
+
* Rendered as MJML `<mj-group>`, which is what holds a logo beside a nav
|
|
235
|
+
* on a phone. Off by default: columns stack.
|
|
236
|
+
*/
|
|
237
|
+
noStackOnMobile?: boolean;
|
|
238
|
+
};
|
|
239
|
+
columns: ColumnNode[];
|
|
240
|
+
columnRatios: number[];
|
|
241
|
+
locked: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare interface SocialBlock {
|
|
245
|
+
id: string;
|
|
246
|
+
type: 'social';
|
|
247
|
+
values: DeviceVisibility & {
|
|
248
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
249
|
+
condition?: string;
|
|
250
|
+
icons: SocialIcon[];
|
|
251
|
+
iconSize: number;
|
|
252
|
+
spacing: number;
|
|
253
|
+
alignment: 'left' | 'center' | 'right';
|
|
254
|
+
padding: Spacing;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare interface SocialIcon {
|
|
259
|
+
type: 'facebook' | 'twitter' | 'instagram' | 'linkedin' | 'youtube' | 'tiktok' | 'custom';
|
|
260
|
+
href: string;
|
|
261
|
+
label?: string;
|
|
262
|
+
iconUrl?: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
declare interface SpacerBlock {
|
|
266
|
+
id: string;
|
|
267
|
+
type: 'spacer';
|
|
268
|
+
values: DeviceVisibility & {
|
|
269
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
270
|
+
condition?: string;
|
|
271
|
+
height: number;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
declare interface Spacing {
|
|
276
|
+
top: number;
|
|
277
|
+
right: number;
|
|
278
|
+
bottom: number;
|
|
279
|
+
left: number;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare interface Template {
|
|
283
|
+
/** Stable, URL-safe slug. Doubles as filename when persisted. */
|
|
284
|
+
id: string;
|
|
285
|
+
/** Display name shown in pickers. */
|
|
286
|
+
name: string;
|
|
287
|
+
/** One-line summary used in template galleries. */
|
|
288
|
+
description?: string;
|
|
289
|
+
/** Optional category for grouping in UI. */
|
|
290
|
+
category?: TemplateCategory;
|
|
291
|
+
/** Optional preview image — base64 data URL or absolute URL. */
|
|
292
|
+
thumbnail?: string;
|
|
293
|
+
/** The full PigeonDocument the template materialises. */
|
|
294
|
+
document: PigeonDocument;
|
|
295
|
+
/** ISO-8601 timestamps. */
|
|
296
|
+
createdAt: string;
|
|
297
|
+
updatedAt: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare type TemplateCategory = 'welcome' | 'newsletter' | 'transactional' | 'promo' | 'announcement' | 'other';
|
|
301
|
+
|
|
302
|
+
declare interface TextBlock {
|
|
303
|
+
id: string;
|
|
304
|
+
type: 'text';
|
|
305
|
+
values: DeviceVisibility & {
|
|
306
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
307
|
+
condition?: string;
|
|
308
|
+
content: string;
|
|
309
|
+
padding: Spacing;
|
|
310
|
+
lineHeight: string;
|
|
311
|
+
textAlign: 'left' | 'center' | 'right';
|
|
312
|
+
/** Written out as MJML `css-class`. */
|
|
313
|
+
cssClass?: string;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export { }
|