@lit-pigeon/core 0.3.3 → 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 +200 -12
- package/dist/index.js +373 -265
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -106,6 +106,17 @@ export declare interface BlockDefinition {
|
|
|
106
106
|
|
|
107
107
|
export declare type BlockType = ContentBlock['type'];
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* A border applied to all four sides. Structured here and serialised to the
|
|
111
|
+
* CSS shorthand at the MJML boundary, the same way {@link Spacing} is.
|
|
112
|
+
* Per-side borders are deliberately not modelled until something needs them.
|
|
113
|
+
*/
|
|
114
|
+
export declare interface Border {
|
|
115
|
+
width: number;
|
|
116
|
+
style: 'solid' | 'dashed' | 'dotted';
|
|
117
|
+
color: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
109
120
|
/**
|
|
110
121
|
* A single saved color in a brand kit. Hex (`#rrggbb`/`#rgb`) recommended;
|
|
111
122
|
* any CSS color string is accepted at storage time.
|
|
@@ -168,12 +179,16 @@ export declare interface BrandLogo {
|
|
|
168
179
|
export declare interface ButtonBlock {
|
|
169
180
|
id: string;
|
|
170
181
|
type: 'button';
|
|
171
|
-
values: {
|
|
182
|
+
values: DeviceVisibility & {
|
|
183
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
184
|
+
condition?: string;
|
|
172
185
|
content: string;
|
|
173
186
|
href: string;
|
|
174
187
|
backgroundColor: string;
|
|
175
188
|
textColor: string;
|
|
176
189
|
borderRadius: number;
|
|
190
|
+
/** Omitted for a borderless button; MJML's own default is `border: none`. */
|
|
191
|
+
border?: Border;
|
|
177
192
|
padding: Spacing;
|
|
178
193
|
innerPadding: Spacing;
|
|
179
194
|
fontSize: number;
|
|
@@ -199,7 +214,7 @@ export declare function cloneRowWithNewIds(row: RowNode): RowNode;
|
|
|
199
214
|
export declare interface ColumnNode {
|
|
200
215
|
id: string;
|
|
201
216
|
type: 'column';
|
|
202
|
-
attributes: {
|
|
217
|
+
attributes: DeviceVisibility & {
|
|
203
218
|
backgroundColor?: string;
|
|
204
219
|
padding: Spacing;
|
|
205
220
|
borderRadius?: number;
|
|
@@ -236,6 +251,12 @@ export declare function createRow(columns?: ColumnNode[], columnRatios?: number[
|
|
|
236
251
|
|
|
237
252
|
export declare function createRowSelection(rowId: string): Selection_2;
|
|
238
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Reads back what {@link linkStyleToCss} wrote. Returns undefined for anything
|
|
256
|
+
* that is not our own generated block, so hand-written CSS is left alone.
|
|
257
|
+
*/
|
|
258
|
+
export declare function cssToLinkStyle(css: string): LinkStyle_2 | undefined;
|
|
259
|
+
|
|
239
260
|
/**
|
|
240
261
|
* A block whose `type` was contributed at runtime via the block registry
|
|
241
262
|
* (`registerBlock`) rather than being one of the built-in {@link ContentBlock}
|
|
@@ -256,10 +277,21 @@ export declare function deleteBlock(rowId: string, columnId: string, blockId: st
|
|
|
256
277
|
|
|
257
278
|
export declare function deleteRow(rowId: string): Command;
|
|
258
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Hides a block or column at one breakpoint. Rendered as an MJML `css-class`
|
|
282
|
+
* (`pigeon-hide-mobile` / `pigeon-hide-desktop`) plus a media query.
|
|
283
|
+
*/
|
|
284
|
+
export declare type DeviceVisibility = {
|
|
285
|
+
hideOnMobile?: boolean;
|
|
286
|
+
hideOnDesktop?: boolean;
|
|
287
|
+
};
|
|
288
|
+
|
|
259
289
|
export declare interface DividerBlock {
|
|
260
290
|
id: string;
|
|
261
291
|
type: 'divider';
|
|
262
|
-
values: {
|
|
292
|
+
values: DeviceVisibility & {
|
|
293
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
294
|
+
condition?: string;
|
|
263
295
|
borderColor: string;
|
|
264
296
|
borderWidth: number;
|
|
265
297
|
borderStyle: 'solid' | 'dashed' | 'dotted';
|
|
@@ -311,6 +343,17 @@ export declare interface EditorConfig {
|
|
|
311
343
|
* (`SYSTEM_LINK_TYPES`). The host/SSR resolves any `{{…}}` templates at send.
|
|
312
344
|
*/
|
|
313
345
|
linkTypes?: LinkType[];
|
|
346
|
+
/**
|
|
347
|
+
* Block types this editor offers, in palette order. Unset means every
|
|
348
|
+
* registered block, which is the default. A type nobody registered is
|
|
349
|
+
* ignored.
|
|
350
|
+
*
|
|
351
|
+
* The restriction is enforced in the `insertBlock` command, not just in the
|
|
352
|
+
* palette, so the keyboard, the MCP server and the REST handler are held to
|
|
353
|
+
* it too. It gates insertion only — a document that already contains an
|
|
354
|
+
* omitted type still renders.
|
|
355
|
+
*/
|
|
356
|
+
blocks?: string[];
|
|
314
357
|
/** Active locale code (e.g. 'fr', 'ar'). Defaults to 'en'. */
|
|
315
358
|
locale?: string;
|
|
316
359
|
/** Host-supplied per-locale catalogs, merged over the built-in `en` baseline. */
|
|
@@ -351,10 +394,23 @@ export declare interface FontDefinition {
|
|
|
351
394
|
url?: string;
|
|
352
395
|
}
|
|
353
396
|
|
|
397
|
+
/** The comment that opens a generated style block. */
|
|
398
|
+
export declare function generatedStyleMarker(name: string): string;
|
|
399
|
+
|
|
400
|
+
/** The name in `css`'s marker, or undefined if the renderer did not write it. */
|
|
401
|
+
export declare function generatedStyleName(css: string): string | undefined;
|
|
402
|
+
|
|
354
403
|
export declare function generateId(): string;
|
|
355
404
|
|
|
356
405
|
export declare function getAllBlockDefinitions(): BlockDefinition[];
|
|
357
406
|
|
|
407
|
+
/**
|
|
408
|
+
* The definitions the palette offers: every registered block by default, or
|
|
409
|
+
* the host's list in its own order. A listed type nobody registered is
|
|
410
|
+
* skipped rather than rendered as a broken chip.
|
|
411
|
+
*/
|
|
412
|
+
export declare function getAvailableBlockDefinitions(): BlockDefinition[];
|
|
413
|
+
|
|
358
414
|
export declare function getBlockDefinition(type: string): BlockDefinition | undefined;
|
|
359
415
|
|
|
360
416
|
export declare function getDefaultValues(type: BlockType): ContentBlock['values'];
|
|
@@ -366,7 +422,9 @@ export declare function getStarterTemplates(): Template[];
|
|
|
366
422
|
export declare interface HeroBlock {
|
|
367
423
|
id: string;
|
|
368
424
|
type: 'hero';
|
|
369
|
-
values: {
|
|
425
|
+
values: DeviceVisibility & {
|
|
426
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
427
|
+
condition?: string;
|
|
370
428
|
backgroundUrl: string;
|
|
371
429
|
backgroundPosition: 'center center' | 'top center' | 'bottom center' | 'left center' | 'right center';
|
|
372
430
|
mode: 'fixed-height' | 'fluid-height';
|
|
@@ -396,7 +454,9 @@ export declare interface HistoryState {
|
|
|
396
454
|
export declare interface HtmlBlock {
|
|
397
455
|
id: string;
|
|
398
456
|
type: 'html';
|
|
399
|
-
values: {
|
|
457
|
+
values: DeviceVisibility & {
|
|
458
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
459
|
+
condition?: string;
|
|
400
460
|
content: string;
|
|
401
461
|
padding: Spacing;
|
|
402
462
|
};
|
|
@@ -405,7 +465,9 @@ export declare interface HtmlBlock {
|
|
|
405
465
|
export declare interface ImageBlock {
|
|
406
466
|
id: string;
|
|
407
467
|
type: 'image';
|
|
408
|
-
values: {
|
|
468
|
+
values: DeviceVisibility & {
|
|
469
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
470
|
+
condition?: string;
|
|
409
471
|
src: string;
|
|
410
472
|
alt: string;
|
|
411
473
|
width: number | 'auto';
|
|
@@ -485,15 +547,22 @@ export declare interface InMemoryRowLibraryStorageOptions {
|
|
|
485
547
|
*/
|
|
486
548
|
export declare class InMemoryTemplateStorage implements TemplateStorage {
|
|
487
549
|
private readonly _byId;
|
|
550
|
+
private readonly _includeGallery;
|
|
551
|
+
private _gallery?;
|
|
488
552
|
constructor(opts?: InMemoryTemplateStorageOptions);
|
|
489
553
|
list(): Promise<Template[]>;
|
|
490
554
|
get(id: string): Promise<Template | null>;
|
|
491
555
|
save(template: Template): Promise<void>;
|
|
492
556
|
delete(id: string): Promise<void>;
|
|
557
|
+
/** Merges the gallery once; seeded or saved templates with the same id win. */
|
|
558
|
+
private _ready;
|
|
493
559
|
}
|
|
494
560
|
|
|
495
561
|
export declare interface InMemoryTemplateStorageOptions {
|
|
496
|
-
/**
|
|
562
|
+
/**
|
|
563
|
+
* When true (default), the storage is seeded with the built-in starter
|
|
564
|
+
* templates, and the lazily loaded gallery is merged in on first access.
|
|
565
|
+
*/
|
|
497
566
|
includeStarters?: boolean;
|
|
498
567
|
/** Additional templates to seed alongside the starters. */
|
|
499
568
|
seed?: Template[];
|
|
@@ -503,6 +572,13 @@ export declare function insertBlock(rowId: string, columnId: string, block: Cont
|
|
|
503
572
|
|
|
504
573
|
export declare function insertRow(row: RowNode, index?: number): Command;
|
|
505
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Whether a block of `type` may be inserted. Enforced in `insertBlock`, so
|
|
577
|
+
* the palette, the keyboard, the MCP server and the REST handler are all held
|
|
578
|
+
* to it rather than only the palette.
|
|
579
|
+
*/
|
|
580
|
+
export declare function isBlockTypeAvailable(type: string): boolean;
|
|
581
|
+
|
|
506
582
|
export declare function isKnownBlockType(type: string): type is BlockType;
|
|
507
583
|
|
|
508
584
|
export declare function isValidDocument(doc: unknown): doc is PigeonDocument;
|
|
@@ -522,6 +598,32 @@ export declare interface LibraryEntry {
|
|
|
522
598
|
updatedAt: string;
|
|
523
599
|
}
|
|
524
600
|
|
|
601
|
+
/** The name this block carries in its generated-style marker. */
|
|
602
|
+
export declare const LINK_STYLE_NAME = "link-style";
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Document-level link styling. A brand setting rather than a per-link
|
|
606
|
+
* decision, so it lives on the body and is rendered as one `<mj-style>` rule
|
|
607
|
+
* targeting `a`. Each part is optional; whatever is unset stays at the
|
|
608
|
+
* client's default.
|
|
609
|
+
*/
|
|
610
|
+
declare interface LinkStyle_2 {
|
|
611
|
+
color?: string;
|
|
612
|
+
underline?: boolean;
|
|
613
|
+
}
|
|
614
|
+
export { LinkStyle_2 as LinkStyle }
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Builds the CSS for a document's link style, or undefined when neither part
|
|
618
|
+
* is set and there is nothing to say.
|
|
619
|
+
*
|
|
620
|
+
* Apple Mail is the client that will otherwise override this: it wraps dates,
|
|
621
|
+
* addresses and phone numbers in its own `<a x-apple-data-detectors>`, which
|
|
622
|
+
* would pick the brand link colour up from the rule above it, so those get
|
|
623
|
+
* reset to whatever text surrounds them.
|
|
624
|
+
*/
|
|
625
|
+
export declare function linkStyleToCss(style: LinkStyle_2): string | undefined;
|
|
626
|
+
|
|
525
627
|
/** A selectable "special link" surfaced in the link editor and button panel. */
|
|
526
628
|
export declare interface LinkType {
|
|
527
629
|
/** Stable id (also the picker option value). */
|
|
@@ -534,6 +636,13 @@ export declare interface LinkType {
|
|
|
534
636
|
prompt?: 'email' | 'tel';
|
|
535
637
|
}
|
|
536
638
|
|
|
639
|
+
/**
|
|
640
|
+
* The deeper gallery (order confirmation, shipping update, password reset,
|
|
641
|
+
* invoice, event invite, product launch, abandoned cart, monthly digest).
|
|
642
|
+
* Code-split so the documents only download when a picker asks for them.
|
|
643
|
+
*/
|
|
644
|
+
export declare function loadGalleryTemplates(): Promise<Template[]>;
|
|
645
|
+
|
|
537
646
|
export declare interface MergeTag {
|
|
538
647
|
name: string;
|
|
539
648
|
label: string;
|
|
@@ -553,7 +662,9 @@ export declare function moveRow(rowId: string, toIndex: number): Command;
|
|
|
553
662
|
export declare interface NavBarBlock {
|
|
554
663
|
id: string;
|
|
555
664
|
type: 'navbar';
|
|
556
|
-
values: {
|
|
665
|
+
values: DeviceVisibility & {
|
|
666
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
667
|
+
condition?: string;
|
|
557
668
|
links: NavLink[];
|
|
558
669
|
hamburger: 'hamburger' | 'none';
|
|
559
670
|
alignment: 'left' | 'center' | 'right';
|
|
@@ -587,6 +698,23 @@ export declare interface PigeonDocument {
|
|
|
587
698
|
backgroundColor: string;
|
|
588
699
|
fontFamily: string;
|
|
589
700
|
contentAlignment: 'center' | 'left';
|
|
701
|
+
/**
|
|
702
|
+
* Link colour and underline for the whole document. Omitted, or with a
|
|
703
|
+
* part omitted, links fall back to whatever each client defaults to —
|
|
704
|
+
* blue and underlined in most, purple once visited in some.
|
|
705
|
+
*/
|
|
706
|
+
linkStyle?: LinkStyle_2;
|
|
707
|
+
/**
|
|
708
|
+
* BCP 47 tag, e.g. `"en"`, `"pt-BR"`. Written out as `lang` on `<mjml>`,
|
|
709
|
+
* which MJML copies onto `<html>` and the `role="article"` wrapper.
|
|
710
|
+
* Left unset, the output keeps MJML's own `lang="und"`.
|
|
711
|
+
*/
|
|
712
|
+
language?: string;
|
|
713
|
+
/**
|
|
714
|
+
* Written out as `dir` on `<mjml>`. Defaults to the natural direction of
|
|
715
|
+
* `language`, so it only needs setting to override that.
|
|
716
|
+
*/
|
|
717
|
+
direction?: 'ltr' | 'rtl';
|
|
590
718
|
/** Document-level CSS, written out as a non-inline `<mj-style>`. */
|
|
591
719
|
css?: string;
|
|
592
720
|
};
|
|
@@ -695,6 +823,28 @@ export declare interface RenderResult {
|
|
|
695
823
|
|
|
696
824
|
export declare function resizeColumns(rowId: string, ratios: number[]): Command;
|
|
697
825
|
|
|
826
|
+
/**
|
|
827
|
+
* Resolve text direction for a BCP 47 tag: an explicit override wins, else the
|
|
828
|
+
* language subtag decides (`ar`, `pt-BR` → `rtl`, `ltr`). Shared by the editor
|
|
829
|
+
* chrome and the renderer so the RTL list is defined once.
|
|
830
|
+
*/
|
|
831
|
+
export declare function resolveDirection(language?: string, override?: 'ltr' | 'rtl'): 'ltr' | 'rtl';
|
|
832
|
+
|
|
833
|
+
/** A row's background image with every MJML attribute resolved. */
|
|
834
|
+
export declare interface ResolvedRowBackground {
|
|
835
|
+
url: string;
|
|
836
|
+
repeat: 'repeat' | 'no-repeat';
|
|
837
|
+
size: string;
|
|
838
|
+
position: string;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Resolves a row's background image to the values the renderer emits, so the
|
|
843
|
+
* canvas and the export cannot disagree about how the image is cropped.
|
|
844
|
+
* Returns undefined when the row has no background image.
|
|
845
|
+
*/
|
|
846
|
+
export declare function resolveRowBackground(row: RowNode): ResolvedRowBackground | undefined;
|
|
847
|
+
|
|
698
848
|
/** Pluggable persistence for the row library. Mirrors {@link TemplateStorage}. */
|
|
699
849
|
export declare interface RowLibraryStorage {
|
|
700
850
|
list(): Promise<LibraryEntry[]>;
|
|
@@ -706,9 +856,18 @@ export declare interface RowLibraryStorage {
|
|
|
706
856
|
export declare interface RowNode {
|
|
707
857
|
id: string;
|
|
708
858
|
type: 'row';
|
|
709
|
-
attributes: {
|
|
859
|
+
attributes: DeviceVisibility & {
|
|
710
860
|
backgroundColor?: string;
|
|
711
861
|
backgroundImage?: string;
|
|
862
|
+
/**
|
|
863
|
+
* MJML `background-repeat` for {@link backgroundImage}. Absent means the
|
|
864
|
+
* legacy `no-repeat`; see {@link resolveRowBackground}.
|
|
865
|
+
*/
|
|
866
|
+
backgroundRepeat?: 'repeat' | 'no-repeat';
|
|
867
|
+
/** MJML `background-size`: `cover`, `contain`, `auto` or a CSS length. */
|
|
868
|
+
backgroundSize?: string;
|
|
869
|
+
/** MJML `background-position`, e.g. `top center`. */
|
|
870
|
+
backgroundPosition?: string;
|
|
712
871
|
padding: Spacing;
|
|
713
872
|
fullWidth: boolean;
|
|
714
873
|
/**
|
|
@@ -718,8 +877,21 @@ export declare interface RowNode {
|
|
|
718
877
|
* / Liquid-style, passed through verbatim), e.g. `condition: "user.premium"`.
|
|
719
878
|
*/
|
|
720
879
|
condition?: string;
|
|
880
|
+
/**
|
|
881
|
+
* Optional array merge-tag path. When set, the row repeats once per item:
|
|
882
|
+
* the renderer wraps the section in `{{#each <repeat>}} … {{/each}}`
|
|
883
|
+
* (Handlebars), inside any `condition`, e.g. `repeat: "order.items"`.
|
|
884
|
+
* Merge tags inside the row then resolve against the item (`{{name}}`).
|
|
885
|
+
*/
|
|
886
|
+
repeat?: string;
|
|
721
887
|
/** Written out as MJML `css-class`. */
|
|
722
888
|
cssClass?: string;
|
|
889
|
+
/**
|
|
890
|
+
* When true, the columns keep their widths on mobile instead of stacking.
|
|
891
|
+
* Rendered as MJML `<mj-group>`, which is what holds a logo beside a nav
|
|
892
|
+
* on a phone. Off by default: columns stack.
|
|
893
|
+
*/
|
|
894
|
+
noStackOnMobile?: boolean;
|
|
723
895
|
};
|
|
724
896
|
columns: ColumnNode[];
|
|
725
897
|
columnRatios: number[];
|
|
@@ -736,10 +908,20 @@ export { Selection_2 as Selection }
|
|
|
736
908
|
|
|
737
909
|
export declare function selectionsEqual(a: Selection_2 | null, b: Selection_2 | null): boolean;
|
|
738
910
|
|
|
911
|
+
/**
|
|
912
|
+
* Restricts the editor to `types`, in the order given. Pass `undefined` to
|
|
913
|
+
* lift the restriction. Availability gates *insertion*, not rendering: a
|
|
914
|
+
* document that already contains a type the host left out still renders, so
|
|
915
|
+
* narrowing the palette never blanks a saved template.
|
|
916
|
+
*/
|
|
917
|
+
export declare function setAvailableBlockTypes(types: readonly string[] | undefined): void;
|
|
918
|
+
|
|
739
919
|
export declare interface SocialBlock {
|
|
740
920
|
id: string;
|
|
741
921
|
type: 'social';
|
|
742
|
-
values: {
|
|
922
|
+
values: DeviceVisibility & {
|
|
923
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
924
|
+
condition?: string;
|
|
743
925
|
icons: SocialIcon[];
|
|
744
926
|
iconSize: number;
|
|
745
927
|
spacing: number;
|
|
@@ -758,7 +940,9 @@ export declare interface SocialIcon {
|
|
|
758
940
|
export declare interface SpacerBlock {
|
|
759
941
|
id: string;
|
|
760
942
|
type: 'spacer';
|
|
761
|
-
values: {
|
|
943
|
+
values: DeviceVisibility & {
|
|
944
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
945
|
+
condition?: string;
|
|
762
946
|
height: number;
|
|
763
947
|
};
|
|
764
948
|
}
|
|
@@ -837,7 +1021,9 @@ export declare interface TemplateStorage {
|
|
|
837
1021
|
export declare interface TextBlock {
|
|
838
1022
|
id: string;
|
|
839
1023
|
type: 'text';
|
|
840
|
-
values: {
|
|
1024
|
+
values: DeviceVisibility & {
|
|
1025
|
+
/** Display condition; see {@link RowNode} `condition`. Wraps just this block. */
|
|
1026
|
+
condition?: string;
|
|
841
1027
|
content: string;
|
|
842
1028
|
padding: Spacing;
|
|
843
1029
|
lineHeight: string;
|
|
@@ -881,6 +1067,8 @@ export declare function undo(state: EditorStateSnapshot, dispatch?: (tr: Transac
|
|
|
881
1067
|
|
|
882
1068
|
export declare function updateBlock(rowId: string, columnId: string, blockId: string, values: Record<string, unknown>): Command;
|
|
883
1069
|
|
|
1070
|
+
export declare function updateColumnAttributes(rowId: string, columnId: string, attributes: Partial<ColumnNode['attributes']>): Command;
|
|
1071
|
+
|
|
884
1072
|
export declare function updateRowAttributes(rowId: string, attributes: Partial<RowNode['attributes']>): Command;
|
|
885
1073
|
|
|
886
1074
|
export declare function validateDocument(doc: unknown): ValidationError[];
|