@topol.io/editor 1.0.0-alpha.8 → 1.0.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.
Files changed (72) hide show
  1. package/README.md +160 -97
  2. package/dist/index.js +171 -0
  3. package/dist/types/src/email-editor/index.d.ts +16 -102
  4. package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
  5. package/dist/types/src/landing-page-editor/index.d.ts +11 -6
  6. package/dist/types/src/landing-page-editor/schemas/api/apiSchema.d.ts +5 -11
  7. package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +34 -18
  8. package/dist/types/src/landing-page-editor/schemas/language/languageSchema.d.ts +1 -1
  9. package/dist/types/src/landing-page-editor/schemas/mjmlStore/mjmlStoreSchema.d.ts +8 -6
  10. package/dist/types/src/landing-page-editor/schemas/notification/notificationSchema.d.ts +0 -1
  11. package/dist/types/src/landing-page-editor/schemas/openAI/openAISchema.d.ts +1 -2
  12. package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +150 -17
  13. package/dist/types/src/landing-page-editor/schemas/premadeSection/premadeSectionSchema.d.ts +30 -0
  14. package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +687 -5
  15. package/dist/types/src/landing-page-editor/schemas/template/blocks/carouselBlockSchema.d.ts +9 -2
  16. package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +11 -3
  17. package/dist/types/src/landing-page-editor/schemas/template/blocks/formBlockSchema.d.ts +1069 -0
  18. package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +35 -19
  19. package/dist/types/src/landing-page-editor/schemas/template/blocks/rawBlockSchema.d.ts +9 -1
  20. package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +11 -3
  21. package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +18 -10
  22. package/dist/types/src/landing-page-editor/schemas/template/blocks/textBlockSchema.d.ts +9 -1
  23. package/dist/types/src/landing-page-editor/schemas/template/blocks/videoBlockSchema.d.ts +9 -1
  24. package/dist/types/src/landing-page-editor/schemas/template/commonSchema.d.ts +28 -8
  25. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarCTASchema.d.ts +335 -0
  26. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarHamburgerSchema.d.ts +1109 -0
  27. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarLogoSchema.d.ts +252 -0
  28. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarMenuSchema.d.ts +1209 -0
  29. package/dist/types/src/landing-page-editor/schemas/template/settingsSchema.d.ts +4058 -546
  30. package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +5007 -2328
  31. package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5501 -2412
  32. package/dist/types/src/landing-page-editor/schemas/template/structure/navbarSchema.d.ts +4394 -0
  33. package/dist/types/src/landing-page-editor/schemas/template/structure/rowSchema.d.ts +11094 -0
  34. package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +8602 -3337
  35. package/dist/types/src/landing-page-editor/schemas/template/styleSchema.d.ts +55 -44
  36. package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +34865 -48464
  37. package/dist/types/src/landing-page-editor/schemas/templateSettings/templateSettingsSchema.d.ts +4304 -794
  38. package/dist/types/src/landing-page-editor/schemas/theme/themeSchema.d.ts +6 -1
  39. package/dist/types/src/landing-page-editor/schemas/utils/cssValue.d.ts +21 -0
  40. package/dist/types/src/landing-page-editor/schemas/utils/transformBorder.d.ts +10 -5
  41. package/dist/types/src/main.d.ts +28 -108
  42. package/dist/types/types/API/API.d.ts +8 -9
  43. package/dist/types/types/APIBlocks/APIBlocks.d.ts +9 -0
  44. package/dist/types/types/Auth/IAuthorize.d.ts +6 -0
  45. package/dist/types/types/Auth/INonceAuthCallbacks.d.ts +10 -0
  46. package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +27 -23
  47. package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +73 -155
  48. package/dist/types/types/Cloud/ICloudOptions.d.ts +32 -0
  49. package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
  50. package/dist/types/types/Countdown/ICountdownOptions.d.ts +48 -0
  51. package/dist/types/types/{ITopolOptions.d.ts → IEmailConfig.d.ts} +80 -28
  52. package/dist/types/types/IEmailEditorInstance.d.ts +64 -0
  53. package/dist/types/types/IEmailOptions.d.ts +7 -0
  54. package/dist/types/types/Language/Language.d.ts +1 -1
  55. package/dist/types/types/MergeTag/IMergeTag.d.ts +18 -0
  56. package/dist/types/types/Notification/INotification.d.ts +2 -1
  57. package/dist/types/types/Sections/ISections.d.ts +41 -0
  58. package/dist/types/types/Shortcuts/EditorShortcut.d.ts +4 -0
  59. package/dist/types/types/Theme/ITheme.d.ts +12 -2
  60. package/dist/types/types/landing-page/ILandingPageEditorInstance.d.ts +65 -5
  61. package/dist/types/types/landing-page/ILandingPageOptions.d.ts +105 -69
  62. package/logo.svg +1 -0
  63. package/package.json +11 -13
  64. package/dist/topol-plugin.es.js +0 -284
  65. package/dist/topol-plugin.umd.js +0 -1
  66. package/dist/types/src/landing-page-editor/schemas/helpdesk/helpdeskSchema.d.ts +0 -8
  67. package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +0 -59750
  68. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +0 -44831
  69. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +0 -59725
  70. package/dist/types/src/landing-page-editor/schemas/template/blocks/index.d.ts +0 -12
  71. package/dist/types/types/ITopolPlugin.d.ts +0 -44
  72. package/dist/types/types/SavedBlock/ISavedBlock.d.ts +0 -6
@@ -2,10 +2,16 @@ import z from "zod";
2
2
  export declare const ThemeSchema: z.ZodObject<{
3
3
  preset: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"light">, z.ZodLiteral<"dark">]>>;
4
4
  borderRadius: z.ZodOptional<z.ZodObject<{
5
+ extraSmall: z.ZodOptional<z.ZodString>;
5
6
  small: z.ZodOptional<z.ZodString>;
6
7
  large: z.ZodOptional<z.ZodString>;
8
+ extraLarge: z.ZodOptional<z.ZodString>;
7
9
  }, z.core.$strip>>;
8
10
  canvasColor: z.ZodOptional<z.ZodString>;
11
+ font: z.ZodOptional<z.ZodObject<{
12
+ family: z.ZodOptional<z.ZodString>;
13
+ url: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>>;
9
15
  colors: z.ZodOptional<z.ZodObject<{
10
16
  "900": z.ZodOptional<z.ZodString>;
11
17
  "800": z.ZodOptional<z.ZodString>;
@@ -22,7 +28,6 @@ export declare const ThemeSchema: z.ZodObject<{
22
28
  primary: z.ZodOptional<z.ZodString>;
23
29
  "primary-light": z.ZodOptional<z.ZodString>;
24
30
  "primary-light-2": z.ZodOptional<z.ZodString>;
25
- "primary-dark": z.ZodOptional<z.ZodString>;
26
31
  secondary: z.ZodOptional<z.ZodString>;
27
32
  "secondary-light": z.ZodOptional<z.ZodString>;
28
33
  "secondary-light-2": z.ZodOptional<z.ZodString>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rules for turning template attribute values into CSS declarations. Any code
3
+ * that writes styles from template attributes should use them, so the canvas
4
+ * and the published page agree on units and on which values are emitted.
5
+ */
6
+ /**
7
+ * Whether an attribute value should produce a CSS declaration. Zero is a real
8
+ * value (`opacity: 0`, `padding: 0`), so only missing and empty values are
9
+ * skipped.
10
+ */
11
+ export declare function hasCssValue(value: unknown): boolean;
12
+ /**
13
+ * A length as CSS: a number or a bare numeric string gets `px`, anything that
14
+ * already carries a unit (or is a keyword such as `auto`) is kept as it is.
15
+ */
16
+ export declare function toCssLength(value: string | number | null | undefined): string | undefined;
17
+ /**
18
+ * The CSS value for `property`: numbers become px lengths, except for
19
+ * properties that are unitless.
20
+ */
21
+ export declare function toCssValue<T>(property: string, value: T): T | string;
@@ -1,9 +1,14 @@
1
- /**
2
- * Transform border shorthand properties to individual border-width, border-style, border-color
3
- * Handles border, border-top, border-bottom, border-left, border-right
4
- */
5
- export default function transformBorder(border?: string | null, borderTop?: string | null, borderBottom?: string | null, borderLeft?: string | null, borderRight?: string | null): {
1
+ type BorderParts = {
6
2
  width?: string;
7
3
  style?: string;
8
4
  color?: string;
9
5
  };
6
+ /**
7
+ * Parses a `border` shorthand by classifying each token rather than by
8
+ * position: legacy templates store both `width style color` (standard CSS)
9
+ * and `width color style`. Splits on spaces outside parentheses so colors
10
+ * like `rgb(0, 0, 0)` stay one token.
11
+ */
12
+ export declare function parseBorderShorthand(value?: string | null): BorderParts;
13
+ declare const _default: (common?: string | null, top?: string | null, bottom?: string | null, left?: string | null, right?: string | null) => BorderParts;
14
+ export default _default;
@@ -1,108 +1,28 @@
1
- /**
2
- * @topol.io/editor - Official Topol Editor Integration Package
3
- *
4
- * This package provides integrations for Topol's email and landing page editors.
5
- *
6
- * @example Email Editor (default export - backwards compatible)
7
- * ```typescript
8
- * import TopolPlugin from '@topol.io/editor';
9
- *
10
- * await TopolPlugin.init({
11
- * id: '#editor',
12
- * authorize: { apiKey: 'your-key', userId: 'user-123' },
13
- * callbacks: { onSave(json, html) { console.log('Saved'); } }
14
- * });
15
- * ```
16
- *
17
- * @example Email Editor (explicit named export)
18
- * ```typescript
19
- * import { EmailEditor } from '@topol.io/editor';
20
- *
21
- * await EmailEditor.init({ ... });
22
- * ```
23
- *
24
- * @example Landing Page Editor
25
- * ```typescript
26
- * import { LandingPageEditor } from '@topol.io/editor';
27
- *
28
- * const editor = await LandingPageEditor.init({
29
- * authorize: { apiKey: 'your-key', userId: 'user-123' },
30
- * callbacks: { onSave(data) { console.log('Saved'); } }
31
- * });
32
- * editor.render('#landing-page-editor');
33
- * ```
34
- */
35
- import { EmailEditor } from "./email-editor";
36
- /**
37
- * @deprecated Use `EmailEditor` instead. `TopolPlugin` is an alias for backwards compatibility.
38
- *
39
- * TopolPlugin is the original name for the Email Editor integration.
40
- * New code should use `EmailEditor` for clarity.
41
- */
42
- declare const TopolPlugin: {
43
- init: (topolOptions: ITopolOptions, options?: import("./email-editor").EmailEditorPluginOptions | undefined) => Promise<string | boolean>;
44
- save: (lang?: string | undefined) => void;
45
- load: (json: unknown) => void;
46
- togglePreview: () => void;
47
- togglePreviewSize: () => void;
48
- chooseFile: (url: string) => void;
49
- undo: () => void;
50
- redo: () => void;
51
- destroy: () => void;
52
- setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
53
- setPreviewHTML: (html: unknown) => void;
54
- createNotification: (notification: INotification) => void;
55
- setActiveMembers: (activeMembers: string[]) => void;
56
- changeEmailToMobile: () => void;
57
- changeEmailToDesktop: () => void;
58
- toggleBlocksAndStructuresVisibility: () => void;
59
- updateCustomBlockContent: (content: string) => void;
60
- refreshComments: (key: string) => void;
61
- refreshSyncedRows: () => void;
62
- openPremadeTemplatesSelection: () => void;
63
- updateApiAuthorizationHeader: (newHeader: string | Record<string, string>) => void;
64
- setTemplateName: (name: string) => void;
65
- updateOptions: (options: Partial<ITopolOptions>) => void;
66
- toggleChatAI: () => void;
67
- toggleAutosaves: () => void;
68
- toggleComments: () => void;
69
- createLanguage: (lang: string) => void;
70
- setPrimaryLanguage: (lang: string) => void;
71
- deleteLanguage: (lang: string) => void;
72
- selectLanguage: (lang: string) => void;
73
- getMutations: () => void;
74
- toggleControlPanel: () => void;
75
- updateTemplate: (json: unknown, options?: {
76
- skipSnapshot?: boolean | undefined;
77
- } | undefined) => void;
78
- toggleDarkMode: () => void;
79
- };
80
- import { LandingPageEditor } from "./landing-page-editor";
81
- import type ITopolOptions from "../types/ITopolOptions";
82
- import type IEmailCallbacks from "../types/Callbacks/IEmailCallbacks";
83
- import type INotification from "../types/Notification/INotification";
84
- import type ISavedBlock from "../types/SavedBlock/ISavedBlock";
85
- import type IMergeTagGroup from "../types/MergeTag/IMergeTagGroup";
86
- import type IMergeTag from "../types/MergeTag/IMergeTag";
87
- import type { IContentBlockOptions } from "../types/ContentBlock/IContentBlockOptions";
88
- import type ITheme from "../types/Theme/ITheme";
89
- import type IAuthHeaderConfig from "../types/AuthHeaderConfig/IAuthHeaderConfig";
90
- import type IFont from "../types/Font/IFont";
91
- import type IAPI from "../types/API/API";
92
- import type ICustomBlockData from "../types/CustomBlocks/CustomBlocks";
93
- import { Stage } from "../types/Stage";
94
- import type { ISaveData, IErrorData, ISendTestData } from "../types/Callbacks/ICallbackPayloads";
95
- import type ILandingPageOptions from "../types/landing-page/ILandingPageOptions";
96
- import type { ILandingPageCallbacks } from "../types/landing-page/ILandingPageOptions";
97
- import type ILandingPageEditorInstance from "../types/landing-page/ILandingPageEditorInstance";
98
- import type { TopolSection } from "./landing-page-editor/schemas/template/structure/sectionSchema";
99
- export default TopolPlugin;
100
- /**
101
- * @deprecated Use `EmailEditor` instead. `TopolPlugin` is an alias for backwards compatibility.
102
- */
103
- export { TopolPlugin };
104
- export { EmailEditor };
105
- export { LandingPageEditor };
106
- export type { ITopolOptions, IEmailCallbacks, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData, Stage as IStage };
107
- export type { ISaveData, IErrorData, ISendTestData };
108
- export type { ILandingPageOptions, ILandingPageCallbacks, ILandingPageEditorInstance, TopolSection };
1
+ export { EmailEditor } from "./email-editor";
2
+ export { LandingPageEditor } from "./landing-page-editor";
3
+ export type { default as IEmailOptions } from "../types/IEmailOptions";
4
+ export type { default as IEmailConfig } from "../types/IEmailConfig";
5
+ export type { default as IEmailCallbacks } from "../types/Callbacks/IEmailCallbacks";
6
+ export type { default as IEmailEditorInstance, IUpdateTemplateOptions } from "../types/IEmailEditorInstance";
7
+ export type { IEmailEditorPluginOptions } from "./email-editor";
8
+ export type { IEmailSavePayload, IEmailErrorPayload, IEmailTestSendPayload, IEmailDeletedItem, ILanguageMutation, ILanguageChangePayload } from "../types/Callbacks/ICallbackPayloads";
9
+ export type { default as ILandingPageOptions, ILandingPageConfig, ILandingPageCallbacks, ILandingPageSavePayload, ILandingPageErrorPayload, ILandingPageDeletedItem } from "../types/landing-page/ILandingPageOptions";
10
+ export type { default as ILandingPageEditorInstance } from "../types/landing-page/ILandingPageEditorInstance";
11
+ export type { ILandingPageEditorPluginOptions } from "./landing-page-editor";
12
+ export type { Stage as IStage } from "../types/Stage";
13
+ export type { EditorErrorSource } from "../types/Callbacks/ICallbackPayloads";
14
+ export type { INonceAuthCallbacks } from "../types/Auth/INonceAuthCallbacks";
15
+ export type { IAuthorize } from "../types/Auth/IAuthorize";
16
+ export type { EmailEditorShortcut, LandingPageEditorShortcut } from "../types/Shortcuts/EditorShortcut";
17
+ export type { default as INotification } from "../types/Notification/INotification";
18
+ export type { default as IMergeTagGroup } from "../types/MergeTag/IMergeTagGroup";
19
+ export type { default as IMergeTag, IMergeTagChildProperty, IMergeTagSuggestionSet } from "../types/MergeTag/IMergeTag";
20
+ export type { IContentBlockOptions } from "../types/ContentBlock/IContentBlockOptions";
21
+ export type { ICountdownOptions, ICountdownDefaultColors, ICountdownDateMergeTag } from "../types/Countdown/ICountdownOptions";
22
+ export type { default as ITheme } from "../types/Theme/ITheme";
23
+ export type { default as IAuthHeaderConfig } from "../types/AuthHeaderConfig/IAuthHeaderConfig";
24
+ export type { default as IFont } from "../types/Font/IFont";
25
+ export type { default as IAPI } from "../types/API/API";
26
+ export type { default as ICustomBlockData } from "../types/CustomBlocks/CustomBlocks";
27
+ export type { ICloudFeatures, ICloudOptions, ICloudCallbacks, ICloudSavePayload, ICloudTemplateChangePayload } from "../types/Cloud/ICloudOptions";
28
+ export type { ISavedSection, ISavedSectionDraft, IPremadeSection, IPremadeSections, ILegacyPremadeSections, IPremadeSectionsOptions, IPremadePreset, IPremadePresetId } from "../types/Sections/ISections";
@@ -1,18 +1,17 @@
1
1
  export default interface IAPI {
2
- AUTOSAVE?: string;
3
2
  AUTOSAVES?: string;
4
- GET_AUTOSAVE?: string;
5
3
  CONVERSATIONS?: string;
6
4
  COMMENTS?: string;
7
5
  IMAGE_UPLOAD?: string;
8
- IMAGE_EDITOR_UPLOAD?: string;
9
6
  FOLDERS?: string;
10
- LOAD?: string;
11
- PREVIEW?: string;
7
+ GENERATE_TEXT?: string;
8
+ GENERATE_PREHEADER?: string;
9
+ GENERATE_TRANSLATION?: string;
12
10
  PRODUCTS?: string;
13
11
  FEEDS?: string;
14
- SAVE?: string;
15
- SYNCED_ROWS?: string;
16
- SAVED_BLOCKS?: string;
17
- TEST_EMAIL?: string;
12
+ PRODUCT_CATEGORIES?: string;
13
+ SAVED_SECTIONS?: string;
14
+ PREMADE_TEMPLATES?: string;
15
+ PREMADE_TEMPLATE_CATEGORIES?: string;
16
+ PREMADE_TEMPLATE_KEYWORDS?: string;
18
17
  }
@@ -1,12 +1,21 @@
1
+ interface IAPIBlockMergeTag {
2
+ label: string;
3
+ value: string;
4
+ }
1
5
  export default interface IAPIBlockProperties {
6
+ name: string;
2
7
  pluralName: string;
3
8
  icon: string;
4
9
  blockStructure: any;
5
10
  apiStructure?: any;
6
11
  itemsURL?: string;
7
12
  feedsURL?: string;
13
+ categoriesURL?: string;
8
14
  apiWithoutSearch?: boolean;
9
15
  nextKey?: boolean;
10
16
  beta?: boolean;
11
17
  disabled?: boolean;
18
+ /** Merge tags offered for the items of this block. */
19
+ dynamicMergeTags?: IAPIBlockMergeTag[];
12
20
  }
21
+ export {};
@@ -0,0 +1,6 @@
1
+ /** `entityId` names the account the editor works for. */
2
+ export type IAuthorize = {
3
+ apiKey: string;
4
+ /** URL-safe [A-Za-z0-9_-]+ string or a non-negative integer. */
5
+ entityId: string | number;
6
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Nonce authentication. Passing `getNonce` switches the editor from the legacy
3
+ * public-key authorize call to short-lived `nc_` nonces minted on your backend.
4
+ * Shared by the Email and Landing Page Editors. Works on its own (every feature stays
5
+ * external); the Email Editor's Topol Cloud requires it.
6
+ */
7
+ export interface INonceAuthCallbacks {
8
+ /** Fetch a fresh nc_ nonce from your authenticated backend. Never expose an sk_ secret in the browser. */
9
+ getNonce?(): Promise<string>;
10
+ }
@@ -1,35 +1,39 @@
1
- /**
2
- * Shared callback payload types for framework wrappers (Vue, React, Svelte).
3
- * These types represent the transformed callback arguments used by wrapper components.
4
- */
5
- /**
6
- * Payload for onSave and onSaveAndClose callbacks.
7
- * Used when transforming (json, html) arguments into a single object.
8
- */
9
- export interface ISaveData {
1
+ /** Language identifiers use code in editor v4. */
2
+ export interface ILanguageMutation {
3
+ code: string;
4
+ primary: boolean;
5
+ }
6
+ export interface IEmailSavePayload {
10
7
  json: unknown;
11
8
  html: unknown;
12
- mutations?: {
13
- key: string;
14
- primary: boolean;
15
- }[];
9
+ mutations?: ILanguageMutation[];
16
10
  syncedSections?: number[];
17
11
  }
18
12
  /**
19
- * Payload for onError callback.
20
- * Used when transforming (type, message, responseBody) arguments into a single object.
13
+ * Where an `onEditorError` came from, shared by the Email and Landing Page Editors.
14
+ * `integration`: the wrapper or loader could not start the editor (the iframe never booted).
15
+ * `init`: the editor itself crashed while starting up.
16
+ * Renaming or removing a value is a breaking change.
21
17
  */
22
- export interface IErrorData {
23
- type: string;
18
+ export type EditorErrorSource = "integration" | "init" | "authorize" | "nonceAuth" | "network" | "load" | "updateTemplate" | "save" | "testSend" | "cloudTemplates" | "cloudSync";
19
+ export interface IEmailErrorPayload {
20
+ source: EditorErrorSource;
24
21
  message: string;
25
- responseBody?: unknown;
22
+ detail?: unknown;
26
23
  }
27
- /**
28
- * Payload for onTestSend callback (Email Editor only).
29
- * Used when transforming (email, json, html) arguments into a single object.
30
- */
31
- export interface ISendTestData {
24
+ export interface IEmailTestSendPayload {
32
25
  email: string | string[];
33
26
  json: unknown;
34
27
  html: unknown;
35
28
  }
29
+ export interface ILanguageChangePayload {
30
+ code: string;
31
+ mutations: ILanguageMutation[];
32
+ }
33
+ export interface IEmailDeletedItem {
34
+ name: string;
35
+ type: "file" | "folder";
36
+ path: string;
37
+ url?: string;
38
+ key: string | null;
39
+ }
@@ -1,160 +1,78 @@
1
- import type ISavedBlock from "../SavedBlock/ISavedBlock";
2
1
  import type INotification from "../Notification/INotification";
3
- /**
4
- * Callback functions for Email Editor events.
5
- */
6
- export default interface IEmailCallbacks {
7
- /**
8
- * Called when the user saves the email template.
9
- * @param json - The email template JSON structure
10
- * @param html - The generated HTML output
11
- * @param mutations - The mutations applied to the email template
12
- * @param syncedSections - The synced sections id that were in the email template at the time of saving
13
- */
14
- onSave?(json: unknown, html: unknown, mutations: {
15
- key: string;
16
- primary: boolean;
17
- }[], syncedSections: number[]): void;
18
- /**
19
- * Called when the user clicks "Save and Close".
20
- * @param json - The email template JSON structure
21
- * @param html - The generated HTML output
22
- * @param mutations - The mutations applied to the email template
23
- * @param syncedSections - The synced sections id that were in the email template at the time of saving
24
- */
25
- onSaveAndClose?(json: unknown, html: unknown, mutations: {
26
- key: string;
27
- primary: boolean;
28
- }[], syncedSections: number[]): void;
29
- /**
30
- * Called when the user sends a test email.
31
- * @param email - The email address(es) to send to
32
- * @param json - The email template JSON structure
33
- * @param html - The generated HTML output
34
- */
35
- onTestSend?(email: string | string[], json: unknown, html: unknown): void;
36
- /**
37
- * Called when the user clicks the banner (free version only).
38
- * @param json - The email template JSON structure
39
- * @param html - The generated HTML output
40
- */
41
- onBannerClick?(json: unknown, html: unknown): void;
42
- /**
43
- * Called when the custom file manager should be opened.
44
- */
2
+ import type { ISavedSectionDraft } from "../Sections/ISections";
3
+ import type { ICloudCallbacks } from "../Cloud/ICloudOptions";
4
+ import type { INonceAuthCallbacks } from "../Auth/INonceAuthCallbacks";
5
+ import type { IEmailSavePayload, IEmailTestSendPayload, IEmailErrorPayload, ILanguageChangePayload, ILanguageMutation, IEmailDeletedItem } from "./ICallbackPayloads";
6
+ /** v4 host callbacks. Return save promises so the editor can await persistence. */
7
+ export default interface IEmailCallbacks extends INonceAuthCallbacks, ICloudCallbacks {
8
+ onSave?(payload: IEmailSavePayload): void | Promise<void>;
9
+ onSaveAndClose?(payload: IEmailSavePayload): void | Promise<void>;
10
+ onTestSend?(payload: IEmailTestSendPayload): void;
11
+ onBannerClick?(payload: {
12
+ json: unknown;
13
+ html: unknown;
14
+ }): void;
45
15
  onOpenFileManager?(): void;
46
- /**
47
- * Called when the editor has finished loading.
48
- */
49
16
  onLoaded?(): void;
50
- /**
51
- * Called when a block is saved.
52
- * @param block - The saved block data
53
- */
54
- onBlockSave?(block: ISavedBlock): void;
55
- /**
56
- * Called when a block is removed.
57
- * @param blockId - The ID of the removed block
58
- */
59
- onBlockRemove?(blockId: number): void;
60
- /**
61
- * Called when a block is being edited.
62
- * @param blockId - The ID of the block being edited
63
- */
64
- onBlockEdit?(blockId: number): void;
65
- /**
66
- * Called when the editor is initialized.
67
- */
17
+ onSavedSectionSave?(payload: {
18
+ section: ISavedSectionDraft;
19
+ }): void;
20
+ onSavedSectionRemove?(payload: {
21
+ id: number;
22
+ }): void;
23
+ onSavedSectionEdit?(payload: {
24
+ id: number;
25
+ }): void;
26
+ onImageDelete?(payload: {
27
+ items: IEmailDeletedItem[];
28
+ }): void;
68
29
  onInit?(): void;
69
- /**
70
- * Called when the undo stack changes.
71
- * @param count - Number of undo steps available
72
- */
73
- onUndoChange?(count: number): void;
74
- /**
75
- * Called when the redo stack changes.
76
- * @param count - Number of redo steps available
77
- */
78
- onRedoChange?(count: number): void;
79
- /**
80
- * Called when the user requests a preview.
81
- * @param html - The preview HTML
82
- */
83
- onPreview?(html: unknown): void;
84
- /**
85
- * Called when an alert/notification is triggered.
86
- * @param notification - The notification object
87
- */
88
- onAlert?(notification: INotification): void;
89
- /**
90
- * Called when the user closes the editor.
91
- */
92
- onClose?(): void;
93
- /**
94
- * Called when the edited-without-save state changes.
95
- * @param hasUnsavedChanges - Whether there are unsaved changes
96
- */
97
- onEdittedWithoutSaveChanged?(hasUnsavedChanges: boolean): void;
98
- /**
99
- * Called when a custom block dialog should be opened.
100
- * @param customBlock - The custom block data
101
- */
102
- onOpenCustomBlockDialog?(customBlock: unknown): void;
103
- /**
104
- * Called when the template is renamed.
105
- * @param title - The new template title
106
- */
107
- onTemplateRename?(title: string): void;
108
- /**
109
- * Called when testing email addresses are updated.
110
- * @param emails - The updated email addresses
111
- */
112
- updateTestingEmailAddresses?(emails: string[]): void;
113
- /**
114
- * Called when an error occurs.
115
- * @param type - The error type
116
- * @param message - The error message
117
- * @param responseBody - The response body (optional)
118
- */
119
- onError?(type: string, message: string, responseBody?: unknown): void;
120
- /**
121
- * Called when a new language variant is created.
122
- * @param lang - The language code that was created
123
- * @param mutations - The mutations applied to the email template at the time of language creation
124
- */
125
- onLanguageCreated?(lang: string, mutations: {
126
- key: string;
127
- primary: boolean;
128
- }[]): void;
129
- /**
130
- * Called when a language variant is deleted.
131
- * @param lang - The language code that was deleted
132
- * @param mutations - The mutations applied to the email template at the time of language deletion
133
- */
134
- onLanguageDeleted?(lang: string, mutations: {
135
- key: string;
136
- primary: boolean;
137
- }[]): void;
138
- /**
139
- * Called when a language variant is selected/switched to.
140
- * @param lang - The language code that was selected
141
- */
142
- onLanguageSelected?(lang: string): void;
143
- /**
144
- * Called when the primary language is changed.
145
- * @param lang - The language code that was set as primary
146
- * @param mutations - The mutations applied to the email template at the time of primary language change
147
- */
148
- onPrimaryLanguageChanged?(lang: string, mutations: {
149
- key: string;
150
- primary: boolean;
151
- }[]): void;
152
- /**
153
- * Called when mutations are requested via `getMutations`.
154
- * @param mutations - The mutations currently applied to the email template
155
- */
156
- onGetMutations?(mutations: {
157
- key: string;
158
- primary: boolean;
159
- }[]): void;
30
+ onUndoChange?(payload: {
31
+ count: number;
32
+ }): void;
33
+ onRedoChange?(payload: {
34
+ count: number;
35
+ }): void;
36
+ onPreview?(payload: {
37
+ html: unknown;
38
+ }): void;
39
+ onPreviewClose?(): void;
40
+ onAlert?(payload: {
41
+ notification: INotification;
42
+ }): void;
43
+ /**
44
+ * Called when the user closes the editor from the window bar. Closing the editor UI is your
45
+ * job in this handler. May return a Promise: the editor waits for it, and closes itself if
46
+ * it rejects.
47
+ */
48
+ onEditorClose?(): void | Promise<void>;
49
+ /** Called when the unsaved-changes state flips; `hasUnsavedChanges` is `true` while there are unsaved edits. */
50
+ onUnsavedChangesChange?(payload: {
51
+ hasUnsavedChanges: boolean;
52
+ }): void;
53
+ /** Called when hidden elements are shown or hidden: by the top-bar switch, `toggleHiddenElementsVisibility()` or the reveal on device switch. */
54
+ onHiddenElementsVisibilityChange?(payload: {
55
+ visible: boolean;
56
+ }): void;
57
+ onOpenCustomBlockDialog?(payload: {
58
+ block: unknown;
59
+ }): void;
60
+ onTemplateRename?(payload: {
61
+ name: string;
62
+ }): void;
63
+ onTemplateUpdated?(): void;
64
+ /** Called when the user edits the list of test email addresses. */
65
+ onTestingEmailsChange?(payload: {
66
+ emails: string[];
67
+ }): void;
68
+ onEditorError?(payload: IEmailErrorPayload): void;
69
+ onLanguageCreated?(payload: ILanguageChangePayload): void;
70
+ onLanguageDeleted?(payload: ILanguageChangePayload): void;
71
+ onLanguageSelected?(payload: {
72
+ code: string;
73
+ }): void;
74
+ onPrimaryLanguageChanged?(payload: ILanguageChangePayload): void;
75
+ onGetMutations?(payload: {
76
+ mutations: ILanguageMutation[];
77
+ }): void;
160
78
  }
@@ -0,0 +1,32 @@
1
+ /** Enabling Cloud opts in to all features; set individual features to false to use your own backend. */
2
+ export interface ICloudFeatures {
3
+ templates?: boolean;
4
+ autosaves?: boolean;
5
+ images?: boolean;
6
+ comments?: boolean;
7
+ sections?: boolean;
8
+ multilanguage?: boolean;
9
+ testSend?: boolean;
10
+ }
11
+ export interface ICloudOptions {
12
+ enabled: boolean;
13
+ /** Cloud template to open. Top-level config.templateId is ignored in Cloud mode. */
14
+ templateId?: number | string;
15
+ features?: ICloudFeatures;
16
+ }
17
+ export interface ICloudSavePayload {
18
+ templateId: number | string;
19
+ name?: string;
20
+ langCode?: string;
21
+ }
22
+ export interface ICloudTemplateChangePayload {
23
+ type: "rename" | "delete" | "duplicate" | "move";
24
+ templateId: number | string;
25
+ name?: string;
26
+ folderId?: number | null;
27
+ }
28
+ /** Cloud-scoped callbacks. Cloud also requires `getNonce` from INonceAuthCallbacks. */
29
+ export interface ICloudCallbacks {
30
+ onCloudSave?(payload: ICloudSavePayload): void;
31
+ onCloudTemplateChange?(payload: ICloudTemplateChangePayload): void;
32
+ }
@@ -1,4 +1,4 @@
1
- type BlockType = "text" | "image" | "gif" | "button" | "divider" | "spacer" | "social" | "video" | "html" | "product" | "dynamic" | "article" | "carousel" | "raw" | "custom-raw" | "apiBlock";
1
+ type BlockType = "text" | "image" | "gif" | "button" | "divider" | "spacer" | "social" | "video" | "html" | "product" | "dynamic" | "article" | "carousel" | "countdown" | "loop" | "rating";
2
2
  export type IContentBlockOption = {
3
3
  disabled?: boolean;
4
4
  disabledText?: string;