@emabuild/types 0.4.0 → 0.6.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/dist/ai.d.ts +119 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/config.d.ts +309 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/design.d.ts +40 -0
- package/dist/design.d.ts.map +1 -1
- package/dist/images.d.ts +25 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +2 -0
- package/dist/images.js.map +1 -0
- package/dist/import.d.ts +66 -0
- package/dist/import.d.ts.map +1 -0
- package/dist/import.js +11 -0
- package/dist/import.js.map +1 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/operations.d.ts +118 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +2 -0
- package/dist/operations.js.map +1 -0
- package/dist/tool.d.ts +51 -0
- package/dist/tool.d.ts.map +1 -1
- package/package.json +9 -4
- package/schema/mail-editor-config.schema.json +1830 -0
package/dist/images.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A free stock image (Openverse: CC0 / public domain by default) */
|
|
2
|
+
export interface FreeImage {
|
|
3
|
+
/** Full-size image URL, used in the email */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Small preview URL for pickers */
|
|
6
|
+
thumbnail: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
title?: string;
|
|
10
|
+
creator?: string;
|
|
11
|
+
/** License code, e.g. "cc0", "pdm" */
|
|
12
|
+
license: string;
|
|
13
|
+
licenseUrl?: string;
|
|
14
|
+
/** Page of the image on its source site */
|
|
15
|
+
landingUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export type FreeImageOrientation = 'landscape' | 'portrait' | 'square';
|
|
18
|
+
export interface FreeImageSearchOptions {
|
|
19
|
+
orientation?: FreeImageOrientation;
|
|
20
|
+
/** Results per page (default 20) */
|
|
21
|
+
count?: number;
|
|
22
|
+
page?: number;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
package/dist/images.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":""}
|
package/dist/import.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type HtmlIssueSeverity = 'error' | 'warning' | 'info';
|
|
2
|
+
export interface HtmlIssue {
|
|
3
|
+
/** Stable identifier, e.g. "script", "relative-url" (also the i18n key `import.issue.<code>`) */
|
|
4
|
+
code: string;
|
|
5
|
+
severity: HtmlIssueSeverity;
|
|
6
|
+
/** English description */
|
|
7
|
+
message: string;
|
|
8
|
+
/** How many occurrences were found */
|
|
9
|
+
count?: number;
|
|
10
|
+
/** A short excerpt of the first occurrence */
|
|
11
|
+
sample?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* - `email-ready`: built for email, imports cleanly
|
|
15
|
+
* - `convertible`: usable, but some parts will be dropped or approximated
|
|
16
|
+
* - `not-recommended`: has constructs that do not work in email (scripts,
|
|
17
|
+
* iframes, external CSS, relative URLs…) or no content at all
|
|
18
|
+
*/
|
|
19
|
+
export type EmailHtmlVerdict = 'email-ready' | 'convertible' | 'not-recommended';
|
|
20
|
+
/**
|
|
21
|
+
* What produced the HTML: an Emabuild or legacy export (best fidelity),
|
|
22
|
+
* a table-based email, or a web page (div/CSS layout).
|
|
23
|
+
*/
|
|
24
|
+
export type EmailHtmlSource = 'emabuild' | 'unlayer' | 'email' | 'web';
|
|
25
|
+
export interface EmailHtmlReport {
|
|
26
|
+
verdict: EmailHtmlVerdict;
|
|
27
|
+
/** 0–100, higher is better */
|
|
28
|
+
score: number;
|
|
29
|
+
source: EmailHtmlSource;
|
|
30
|
+
issues: HtmlIssue[];
|
|
31
|
+
stats: {
|
|
32
|
+
/** UTF-8 size of the HTML */
|
|
33
|
+
bytes: number;
|
|
34
|
+
images: number;
|
|
35
|
+
links: number;
|
|
36
|
+
tables: number;
|
|
37
|
+
/** Visible text length */
|
|
38
|
+
textLength: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ImportHtmlOptions {
|
|
42
|
+
/** `replace` the current design (default) or `append` the rows to it */
|
|
43
|
+
mode?: 'replace' | 'append';
|
|
44
|
+
/** Row index for `append` (default: end) */
|
|
45
|
+
index?: number;
|
|
46
|
+
/** `parser` (default, offline) or `ai` (needs `options.ai`) */
|
|
47
|
+
engine?: 'parser' | 'ai';
|
|
48
|
+
/** Extra instructions for the AI engine */
|
|
49
|
+
prompt?: string;
|
|
50
|
+
/** Resolve relative image/link URLs against this base */
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
/** Import even when the check says `not-recommended` (an empty document is never imported) */
|
|
53
|
+
force?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface ImportHtmlResult {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
engine: 'parser' | 'ai';
|
|
58
|
+
report: EmailHtmlReport;
|
|
59
|
+
/** Rows added to the design */
|
|
60
|
+
rowsAdded: number;
|
|
61
|
+
/** Blocks that could not be mapped and were kept as `html` blocks */
|
|
62
|
+
htmlBlocks: number;
|
|
63
|
+
warnings: string[];
|
|
64
|
+
error?: string;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,iGAAiG;IACjG,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE;QACL,6BAA6B;QAC7B,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,0BAA0B;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/import.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// HTML import
|
|
3
|
+
//
|
|
4
|
+
// `checkEmailHtml()` tells whether an HTML document is fit for
|
|
5
|
+
// email before importing it; `importHtml()` turns it into the
|
|
6
|
+
// regular (legacy-compatible) design JSON, either with the
|
|
7
|
+
// built-in parser or with the AI connector. Anything that cannot
|
|
8
|
+
// be mapped to a native block becomes an editable `html` block.
|
|
9
|
+
// ============================================================
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../src/import.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,cAAc;AACd,EAAE;AACF,+DAA+D;AAC/D,8DAA8D;AAC9D,2DAA2D;AAC3D,iEAAiE;AACjE,gEAAgE;AAChE,+DAA+D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export type { EmailDesign, DesignBody, DesignRow, DesignColumn, DesignContent, MetaInfo, BackgroundImage, LinkStyle, PopupCloseButtonAction, FontFamily, Border, BodyValues, RowValues, ColumnValues, ContentValues, DisplayCondition, } from './design.js';
|
|
2
|
-
export type { DisplayMode, ToolDefinition, ToolRenderer, EditorRenderContext, ExportRenderContext, ToolPropertyGroup, ToolProperty, PropertyEditorDefinition, } from './tool.js';
|
|
3
|
-
export type { MailEditorConfig, AppearanceConfig, ToolConfig, ToolPropertyOverride, SavedBlock, FontConfig, MergeTagGroup, MergeTagDefinition, DesignTagConfig, TabConfig, TabItemConfig, EditorBehaviorConfig, FeaturesConfig, CustomTabDefinition, ExportOptions, ExportResult, ExportChunks, DesignUpdatedEvent, ImageUploadedEvent, DesignLoadedEvent, CallbackType, ImageUploadDone, ImageUploadCallback, DisplayConditionCallback, } from './config.js';
|
|
1
|
+
export type { EmailDesign, DesignBody, DesignRow, DesignColumn, DesignContent, MetaInfo, BackgroundImage, LinkStyle, PopupCloseButtonAction, FontFamily, Border, BodyValues, RowValues, ColumnValues, ContentValues, DisplayCondition, ValueOverrides, LockFlags, } from './design.js';
|
|
2
|
+
export type { DisplayMode, ToolDefinition, ToolRenderer, EditorRenderContext, ExportRenderContext, ToolPropertyGroup, ToolProperty, PropertyEditorDefinition, PropertyState, TransformerSource, } from './tool.js';
|
|
3
|
+
export type { MailEditorConfig, AppearanceConfig, AppearanceColors, AutosaveConfig, BrandKit, DesignVersion, ToolConfig, ToolPropertyOverride, SavedBlock, FontConfig, MergeTagGroup, MergeTagDefinition, DesignTagConfig, TabConfig, TabItemConfig, EditorBehaviorConfig, FeaturesConfig, CustomTabDefinition, CustomTabContext, LinkTypeConfig, SpecialLink, PlainTextResult, ExportOptions, ExportResult, ExportChunks, DesignUpdatedEvent, ImageUploadedEvent, DesignLoadedEvent, CallbackType, ImageUploadDone, ImageUploadCallback, DisplayConditionCallback, ColorGroup, ColorPickerConfig, ColumnsConfig, MergeTagsConfig, AuditError, AuditResult, ToolValidator, DesignValidator, } from './config.js';
|
|
4
|
+
export type { ContentSpec, ColumnSpec, RowSection, DesignOperation, OperationResult, EditorSelection, ToolSchemaProperty, ToolSchemaEntry, DesignSchema, } from './operations.js';
|
|
5
|
+
export type { AIAction, AIContext, AIRequest, AIStreamEvent, AIRunOptions, AIProvider, AIQuickAction, AIConfig, AIRunResult, AIUsage, } from './ai.js';
|
|
6
|
+
export type { HtmlIssueSeverity, HtmlIssue, EmailHtmlVerdict, EmailHtmlSource, EmailHtmlReport, ImportHtmlOptions, ImportHtmlResult, } from './import.js';
|
|
7
|
+
export type { FreeImage, FreeImageOrientation, FreeImageSearchOptions } from './images.js';
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,SAAS,EACT,sBAAsB,EACtB,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,SA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,aAAa,CAAC;AAErB,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { EmailDesign, BodyValues, RowValues, ColumnValues, ContentValues } from './design.js';
|
|
2
|
+
/** Content block description used when creating new content */
|
|
3
|
+
export interface ContentSpec {
|
|
4
|
+
/** Tool name, e.g. "text", "heading", "button", "image" */
|
|
5
|
+
type: string;
|
|
6
|
+
/** Tool values; missing keys are filled with the tool's defaults */
|
|
7
|
+
values?: Partial<ContentValues> & Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/** Column description used when creating a new row */
|
|
10
|
+
export interface ColumnSpec {
|
|
11
|
+
values?: Partial<ColumnValues>;
|
|
12
|
+
contents?: ContentSpec[];
|
|
13
|
+
}
|
|
14
|
+
/** Where a row lives in the body */
|
|
15
|
+
export type RowSection = 'rows' | 'headers' | 'footers';
|
|
16
|
+
export type DesignOperation = {
|
|
17
|
+
op: 'addRow';
|
|
18
|
+
/** Column proportions, e.g. [1] or [1, 1] or [2, 1] */
|
|
19
|
+
cells: number[];
|
|
20
|
+
/** Insert position (defaults to the end) */
|
|
21
|
+
index?: number;
|
|
22
|
+
section?: RowSection;
|
|
23
|
+
values?: Partial<RowValues>;
|
|
24
|
+
columns?: ColumnSpec[];
|
|
25
|
+
/** Optional client reference, returned in the result so later ops can target it */
|
|
26
|
+
ref?: string;
|
|
27
|
+
} | {
|
|
28
|
+
op: 'removeRow';
|
|
29
|
+
rowId: string;
|
|
30
|
+
} | {
|
|
31
|
+
op: 'moveRow';
|
|
32
|
+
rowId: string;
|
|
33
|
+
toIndex: number;
|
|
34
|
+
} | {
|
|
35
|
+
op: 'duplicateRow';
|
|
36
|
+
rowId: string;
|
|
37
|
+
} | {
|
|
38
|
+
op: 'updateRow';
|
|
39
|
+
rowId: string;
|
|
40
|
+
values: Partial<RowValues>;
|
|
41
|
+
} | {
|
|
42
|
+
op: 'updateColumn';
|
|
43
|
+
columnId: string;
|
|
44
|
+
values: Partial<ColumnValues>;
|
|
45
|
+
} | {
|
|
46
|
+
op: 'addContent';
|
|
47
|
+
/** Target column id, or a `ref` returned by an earlier addRow (`<ref>:<columnIndex>`) */
|
|
48
|
+
columnId: string;
|
|
49
|
+
index?: number;
|
|
50
|
+
type: string;
|
|
51
|
+
values?: Partial<ContentValues> & Record<string, unknown>;
|
|
52
|
+
ref?: string;
|
|
53
|
+
} | {
|
|
54
|
+
op: 'updateContent';
|
|
55
|
+
contentId: string;
|
|
56
|
+
values: Partial<ContentValues> & Record<string, unknown>;
|
|
57
|
+
} | {
|
|
58
|
+
op: 'removeContent';
|
|
59
|
+
contentId: string;
|
|
60
|
+
} | {
|
|
61
|
+
op: 'moveContent';
|
|
62
|
+
contentId: string;
|
|
63
|
+
columnId: string;
|
|
64
|
+
index: number;
|
|
65
|
+
} | {
|
|
66
|
+
op: 'duplicateContent';
|
|
67
|
+
contentId: string;
|
|
68
|
+
} | {
|
|
69
|
+
op: 'updateBody';
|
|
70
|
+
values: Partial<BodyValues>;
|
|
71
|
+
} | {
|
|
72
|
+
op: 'replaceDesign';
|
|
73
|
+
design: EmailDesign;
|
|
74
|
+
};
|
|
75
|
+
/** Outcome of a single operation */
|
|
76
|
+
export interface OperationResult {
|
|
77
|
+
ok: boolean;
|
|
78
|
+
op: DesignOperation['op'];
|
|
79
|
+
/** Id of the created/affected node */
|
|
80
|
+
id?: string;
|
|
81
|
+
/** Echo of the operation's `ref`, when provided */
|
|
82
|
+
ref?: string;
|
|
83
|
+
error?: string;
|
|
84
|
+
}
|
|
85
|
+
/** What is currently selected in the editor */
|
|
86
|
+
export interface EditorSelection {
|
|
87
|
+
kind: 'row' | 'column' | 'content';
|
|
88
|
+
id: string;
|
|
89
|
+
/** Tool name for content selections */
|
|
90
|
+
type?: string;
|
|
91
|
+
rowId?: string;
|
|
92
|
+
columnId?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ToolSchemaProperty {
|
|
95
|
+
key: string;
|
|
96
|
+
label: string;
|
|
97
|
+
widget: string;
|
|
98
|
+
defaultValue: unknown;
|
|
99
|
+
/** Allowed values for dropdowns */
|
|
100
|
+
options?: Array<{
|
|
101
|
+
label: string;
|
|
102
|
+
value: string;
|
|
103
|
+
}>;
|
|
104
|
+
group: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ToolSchemaEntry {
|
|
107
|
+
name: string;
|
|
108
|
+
label: string;
|
|
109
|
+
category?: string;
|
|
110
|
+
properties: ToolSchemaProperty[];
|
|
111
|
+
}
|
|
112
|
+
export interface DesignSchema {
|
|
113
|
+
tools: ToolSchemaEntry[];
|
|
114
|
+
row: ToolSchemaProperty[];
|
|
115
|
+
column: ToolSchemaProperty[];
|
|
116
|
+
body: ToolSchemaProperty[];
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACd,MAAM,aAAa,CAAC;AAQrB,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3D;AAED,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,oCAAoC;AACpC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,eAAe,GACvB;IACE,EAAE,EAAE,QAAQ,CAA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ClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,GAAG,EAAE,kBAAkB,EAAE,CAAC;IAC1B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":""}
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BodyValues, ContentValues } from './design.js';
|
|
2
|
+
import type { AuditError } from './config.js';
|
|
2
3
|
export type DisplayMode = 'email' | 'web' | 'popup';
|
|
3
4
|
/** Known widget types for the property panel */
|
|
4
5
|
export type WidgetType = 'text' | 'textarea' | 'rich_text' | 'color_picker' | 'toggle' | 'dropdown' | 'alignment' | 'padding' | 'number_unit' | 'image_upload';
|
|
@@ -14,12 +15,49 @@ export interface ToolDefinition<TEditorResult = unknown> {
|
|
|
14
15
|
options: Record<string, ToolPropertyGroup>;
|
|
15
16
|
defaultValues: Record<string, unknown>;
|
|
16
17
|
renderer: ToolRenderer<TEditorResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Show/hide/disable property editors from the current values
|
|
20
|
+
* (`propertyStates`). `enabled: false` or `hidden: true` hides the
|
|
21
|
+
* editor (legacy semantics); `disabled: true` shows it read-only.
|
|
22
|
+
*/
|
|
23
|
+
propertyStates?: (values: Record<string, unknown>) => Record<string, PropertyState> | undefined | void;
|
|
24
|
+
/**
|
|
25
|
+
* Called on every property change before it is saved; returns the values
|
|
26
|
+
* to store (`transformer`). `source` names the changed property.
|
|
27
|
+
*/
|
|
28
|
+
transformer?: (values: Record<string, unknown>, source: TransformerSource) => Record<string, unknown>;
|
|
29
|
+
/** Audit validator for this tool's blocks (legacy tool `validator`) */
|
|
30
|
+
validator?: (info: {
|
|
31
|
+
values: Record<string, unknown>;
|
|
32
|
+
defaultErrors: AuditError[];
|
|
33
|
+
}) => AuditError[] | Promise<AuditError[]>;
|
|
34
|
+
}
|
|
35
|
+
export interface PropertyState {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
hidden?: boolean;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface TransformerSource {
|
|
41
|
+
/** Changed property key */
|
|
42
|
+
name: string;
|
|
43
|
+
/** New value */
|
|
44
|
+
value: unknown;
|
|
45
|
+
/** Extra data passed by the property editor (`onChange(v, { data })`) */
|
|
46
|
+
data?: unknown;
|
|
17
47
|
}
|
|
18
48
|
export interface ToolRenderer<TEditorResult = unknown> {
|
|
19
49
|
/** Render the tool in the editor canvas (interactive) */
|
|
20
50
|
renderEditor(values: ContentValues, context: EditorRenderContext): TEditorResult;
|
|
21
51
|
/** Render the tool as email-safe HTML string */
|
|
22
52
|
renderHtml(values: ContentValues, context: ExportRenderContext): string;
|
|
53
|
+
/**
|
|
54
|
+
* Extra code for the exported document head (`renderer.head`).
|
|
55
|
+
* The CSS is emitted once per distinct output; JS only for `web`/`popup` display modes.
|
|
56
|
+
*/
|
|
57
|
+
head?: {
|
|
58
|
+
css?(values: ContentValues): string;
|
|
59
|
+
js?(values: ContentValues): string;
|
|
60
|
+
};
|
|
23
61
|
}
|
|
24
62
|
export interface EditorRenderContext {
|
|
25
63
|
isSelected: boolean;
|
|
@@ -40,6 +78,19 @@ export interface ToolPropertyGroup {
|
|
|
40
78
|
}
|
|
41
79
|
/** A single property within a group */
|
|
42
80
|
export interface ToolProperty {
|
|
81
|
+
/**
|
|
82
|
+
* Whether the property can have a per-device (mobile) value. Responsive
|
|
83
|
+
* properties are edited into `values._override.mobile` while the canvas
|
|
84
|
+
* is in mobile view, and exported as media-query overrides.
|
|
85
|
+
*/
|
|
86
|
+
responsive?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Color property with a dark-mode variant: with the canvas in dark mode it is
|
|
89
|
+
* edited into `values._override.dark` and exported in a
|
|
90
|
+
* `prefers-color-scheme: dark` rule. The element it styles must carry the
|
|
91
|
+
* matching `v-<kebab-key>` hook class.
|
|
92
|
+
*/
|
|
93
|
+
darkMode?: boolean;
|
|
43
94
|
label: string;
|
|
44
95
|
defaultValue: unknown;
|
|
45
96
|
widget: WidgetType | (string & {});
|
package/dist/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAEpD,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,UAAU,GACV,WAAW,GACX,cAAc,GACd,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,aAAa,GACb,cAAc,CAAC;AAEnB,+CAA+C;AAC/C,MAAM,WAAW,cAAc,CAAC,aAAa,GAAG,OAAO;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,WAAW,EAAE,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CA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,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CACvG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emabuild/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "TypeScript type definitions for @emabuild email editor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
"./schema/mail-editor-config.schema.json": "./schema/mail-editor-config.schema.json"
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
17
|
+
"README.md",
|
|
16
18
|
"dist",
|
|
17
|
-
"
|
|
19
|
+
"schema"
|
|
18
20
|
],
|
|
19
21
|
"publishConfig": {
|
|
20
22
|
"access": "public"
|
|
@@ -28,8 +30,11 @@
|
|
|
28
30
|
],
|
|
29
31
|
"license": "MIT",
|
|
30
32
|
"sideEffects": false,
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"ts-json-schema-generator": "^2"
|
|
35
|
+
},
|
|
31
36
|
"scripts": {
|
|
32
|
-
"build": "tsc",
|
|
37
|
+
"build": "tsc && node scripts/build-schema.mjs",
|
|
33
38
|
"clean": "rm -rf dist"
|
|
34
39
|
}
|
|
35
40
|
}
|