@topol.io/editor 1.0.0-alpha.8 → 2.0.0-alpha.1

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 (37) hide show
  1. package/README.md +89 -110
  2. package/dist/topol-plugin.es.js +122 -249
  3. package/dist/topol-plugin.umd.cjs +1 -0
  4. package/dist/types/src/email-editor/constants.d.ts +3 -3
  5. package/dist/types/src/email-editor/index.d.ts +15 -101
  6. package/dist/types/src/landing-page-editor/index.d.ts +1 -1
  7. package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +1 -1
  8. package/dist/types/src/landing-page-editor/schemas/openAI/openAISchema.d.ts +1 -2
  9. package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +89 -0
  10. package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +816 -816
  11. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +612 -612
  12. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +816 -816
  13. package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +2 -2
  14. package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +2 -2
  15. package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +6 -6
  16. package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +2 -2
  17. package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +2 -2
  18. package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +92 -92
  19. package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +94 -94
  20. package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +204 -204
  21. package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +804 -804
  22. package/dist/types/src/main.d.ts +11 -74
  23. package/dist/types/types/API/API.d.ts +8 -7
  24. package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +19 -22
  25. package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +64 -155
  26. package/dist/types/types/Cloud/ICloudOptions.d.ts +33 -0
  27. package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
  28. package/dist/types/types/IEmailConfig.d.ts +190 -0
  29. package/dist/types/types/IEmailEditorInstance.d.ts +54 -0
  30. package/dist/types/types/ITopolOptions.d.ts +4 -153
  31. package/dist/types/types/ITopolPlugin.d.ts +2 -44
  32. package/dist/types/types/Language/Language.d.ts +1 -1
  33. package/dist/types/types/SavedBlock/ISavedBlock.d.ts +2 -6
  34. package/dist/types/types/Sections/ISections.d.ts +30 -0
  35. package/dist/types/types/landing-page/ILandingPageOptions.d.ts +96 -63
  36. package/package.json +7 -10
  37. package/dist/topol-plugin.umd.js +0 -1
@@ -0,0 +1,54 @@
1
+ import type IEmailConfig from "./IEmailConfig";
2
+ import type INotification from "./Notification/INotification";
3
+ import type { ISavedSection } from "./Sections/ISections";
4
+ import type IMergeTag from "./MergeTag/IMergeTag";
5
+ import type IMergeTagGroup from "./MergeTag/IMergeTagGroup";
6
+ import type { ILanguageMutation } from "./Callbacks/ICallbackPayloads";
7
+ export interface IUpdateTemplateOptions {
8
+ skipSnapshot?: boolean;
9
+ }
10
+ /** Per-instance methods cross the iframe boundary asynchronously. Use onInit to observe successful authentication. */
11
+ export default interface IEmailEditorInstance {
12
+ render(container: string | HTMLElement): Promise<void>;
13
+ destroy(): Promise<void>;
14
+ /** Resolves once the template is actually applied. */
15
+ load: (json: unknown) => Promise<void>;
16
+ /** Resolves once the save (render/persist + host onSave) has settled. */
17
+ save: (payload?: {
18
+ langCode?: string;
19
+ }) => Promise<void>;
20
+ togglePreview: () => Promise<void>;
21
+ togglePreviewSize: () => Promise<void>;
22
+ toggleDarkMode: () => Promise<void>;
23
+ chooseFile: (url: string) => Promise<void>;
24
+ undo: () => Promise<void>;
25
+ redo: () => Promise<void>;
26
+ setSavedSections: (savedSections: ISavedSection[]) => Promise<void>;
27
+ setPreviewHTML: (html: unknown) => Promise<void>;
28
+ createNotification: (notification: INotification) => Promise<void>;
29
+ setActiveMembers: (activeMembers: string[]) => Promise<void>;
30
+ changeEmailToMobile: () => Promise<void>;
31
+ changeEmailToDesktop: () => Promise<void>;
32
+ toggleBlocksAndStructuresVisibility: () => Promise<void>;
33
+ updateCustomBlockContent: (content: string) => Promise<void>;
34
+ refreshComments: (key: string) => Promise<void>;
35
+ refreshSyncedSections: () => Promise<void>;
36
+ openPremadeTemplatesSelection: () => Promise<void>;
37
+ updateApiAuthorizationHeader: (newHeader: string | Record<string, string>) => Promise<void>;
38
+ setTemplateName: (name: string) => Promise<void>;
39
+ updateOptions: (topolOptions: Partial<Omit<IEmailConfig, "authorize">>) => Promise<void>;
40
+ setMergeTags: (mergeTags: Array<IMergeTag | IMergeTagGroup>) => Promise<void>;
41
+ toggleChatAI: () => Promise<void>;
42
+ toggleAutosaves: () => Promise<void>;
43
+ toggleComments: () => Promise<void>;
44
+ createLanguage: (code: string) => Promise<void>;
45
+ setPrimaryLanguage: (code: string) => Promise<void>;
46
+ deleteLanguage: (code: string) => Promise<void>;
47
+ selectLanguage: (code: string) => Promise<void>;
48
+ translateLanguage: (code: string, sourceCode?: string) => Promise<void>;
49
+ translateAllLanguages: () => Promise<void>;
50
+ /** Returns the template's language mutations (also fires onGetMutations). */
51
+ getMutations: () => Promise<ILanguageMutation[]>;
52
+ toggleControlPanel: () => Promise<void>;
53
+ updateTemplate: (json: unknown, options?: IUpdateTemplateOptions) => Promise<void>;
54
+ }
@@ -1,156 +1,7 @@
1
- import type IAPI from "./API/API";
2
- import type IAPIBlockProperties from "./APIBlocks/APIBlocks";
3
- import type ISavedBlock from "./SavedBlock/ISavedBlock";
4
- import type IMergeTagGroup from "./MergeTag/IMergeTagGroup";
5
- import type { IContentBlockOptions } from "./ContentBlock/IContentBlockOptions";
6
- import type ITheme from "./Theme/ITheme";
7
- import type IAuthHeaderConfig from "./AuthHeaderConfig/IAuthHeaderConfig";
8
- import type IFont from "./Font/IFont";
9
- import type ICustomBlockData from "./CustomBlocks/CustomBlocks";
10
- import type { Language, IMultilingualLanguage } from "./Language/Language";
11
- import type IMergeTag from "./MergeTag/IMergeTag";
12
- import type SmartMergeTagPattern from "./MergeTag/SmartMergeTagPattern";
13
- import type IUser from "./User/User";
14
- import type IHelpdesk from "./Helpdesk/Helpdesk";
1
+ import type IEmailConfig from "./IEmailConfig";
15
2
  import type IEmailCallbacks from "./Callbacks/IEmailCallbacks";
16
- type TopolTagAttribute = "font-family" | "font-size" | "font-weight" | "font-style" | "letter-spacing" | "text-transform" | "text-decoration" | "background-color" | "color" | "border-collapse";
17
- type DefaultTemplateLangsSchema = {
18
- key: string;
19
- primary: boolean;
20
- }[];
21
- /**
22
- * Configuration options for the Email Editor (TopolPlugin).
23
- */
24
- export default interface ITopolOptions {
25
- id: string;
26
- authorize: {
27
- apiKey: string;
28
- userId: string | number;
29
- };
30
- api?: IAPI;
31
- apiAuthorizationHeader?: IAuthHeaderConfig | string;
32
- apiBlocks?: Record<string, IAPIBlockProperties>;
33
- autosaveInterval?: number;
34
- betaFeatures?: {
35
- carousel?: boolean;
36
- loop?: boolean;
37
- };
38
- chatAI?: boolean;
39
- colors?: Array<string>;
40
- contentBlocks?: IContentBlockOptions;
41
- currentUser?: IUser;
42
- customBlocks?: ICustomBlockData[];
43
- customFileManager?: boolean;
44
- customFonts?: {
45
- override?: boolean;
46
- fonts: Array<IFont>;
47
- };
48
- customLanguagePreset?: {
49
- langs: IMultilingualLanguage;
50
- override?: boolean;
51
- };
52
- defaultTemplateSettings?: {
53
- emailWidth?: number;
54
- emailBackgroundColor?: string;
55
- blockBackgroundColor?: string;
56
- buttonsBackgroundColor?: string;
57
- hyperlinkColor?: string;
58
- h1?: {
59
- [key in TopolTagAttribute]?: string;
60
- };
61
- h2?: {
62
- [key in TopolTagAttribute]?: string;
63
- };
64
- h3?: {
65
- [key in TopolTagAttribute]?: string;
66
- };
67
- p?: {
68
- [key in TopolTagAttribute]?: string;
69
- };
70
- button?: {
71
- [key in TopolTagAttribute]?: string;
72
- };
73
- "line-height"?: number;
74
- "structure-margin"?: string;
75
- "stack-columns"?: boolean;
76
- langs?: DefaultTemplateLangsSchema;
77
- };
78
- disableAiAssistant?: boolean;
79
- disableAlerts?: boolean;
80
- disableExtendedComparators?: boolean;
81
- emailServiceProvider?: "mailchimp" | "sparkpost";
82
- enableAutosaves?: boolean;
83
- enableComments?: boolean;
84
- enableDarkMode?: boolean;
85
- enableImageToTextRatio?: boolean;
86
- enableMergeTagPreview?: boolean;
87
- enableSectionVariants?: boolean;
88
- enableTemplateSizeInfo?: boolean;
89
- fileManagerPreferences?: {
90
- defaultTilesView?: boolean;
91
- hidePexelsIntegration?: boolean;
92
- };
93
- fontSizes?: Array<number>;
94
- googleApiKey?: string;
95
- helpdesk?: IHelpdesk;
96
- hideSettingsTab?: boolean;
97
- hideControlPanel?: boolean;
98
- htmlDesktopFirst?: boolean;
99
- htmlMinified?: boolean;
100
- imageCompressionOptions?: {
101
- qualityJpeg?: number;
102
- qualityPng?: number;
103
- enableAutoResize?: boolean;
104
- enableCompression?: boolean;
105
- };
106
- imageEditor?: boolean;
107
- imageEditorOptions?: {
108
- hideControls?: Array<string>;
109
- };
110
- imageMaxSize?: number;
111
- language?: Language;
112
- light?: boolean;
113
- logicalOperatorsInsideVariant?: boolean;
114
- mainMenuAlign?: "left" | "right";
115
- mergeTags?: Array<IMergeTagGroup | IMergeTag>;
116
- mobileFirstEnabled?: boolean;
117
- multilingual?: boolean;
118
- premadeBlocks?: Record<any, any> | boolean;
119
- premadeBlocksNoOverwrite?: boolean;
120
- premadeTemplates?: boolean;
121
- premadeTemplatesOptions?: {
122
- hideSearch?: boolean;
123
- showDelete?: boolean;
124
- };
125
- removeTopBar?: boolean;
126
- renameTemplate?: boolean;
127
- role?: "manager" | "editor" | "reader";
128
- savedBlocks?: Array<ISavedBlock> | boolean;
129
- showControlPanelExpand?: boolean;
130
- showUnsavedDialogBeforeExit?: boolean;
131
- smartMergeTags?: {
132
- enabled: boolean;
133
- patterns?: Record<string, SmartMergeTagPattern>;
134
- syntax?: {
135
- start: string;
136
- end: string;
137
- };
138
- };
139
- syncedRowsEnable?: boolean;
140
- teamUsers?: IUser[];
141
- templateId?: number | string;
142
- testingEmails?: boolean | string[];
143
- textEditor?: "tinymce" | "tiptap";
144
- textEditorToolbarBottomPosition?: "left" | "center" | "right";
145
- textOverride?: Record<string, string>;
146
- theme?: ITheme;
147
- tinyConfig?: unknown;
148
- tiptapConfig?: {
149
- light?: boolean;
150
- };
151
- title?: string;
152
- topBarOptions?: Array<string>;
153
- windowBar?: Array<string>;
154
- callbacks: IEmailCallbacks;
3
+ /** Email Editor v4 factory props. Callbacks live alongside config. */
4
+ export default interface ITopolOptions extends IEmailCallbacks {
5
+ config: IEmailConfig;
155
6
  }
156
7
  export type { IEmailCallbacks };
@@ -1,44 +1,2 @@
1
- import INotification from "./Notification/INotification";
2
- import ISavedBlock from "./SavedBlock/ISavedBlock";
3
- import ITopolOptions from "./ITopolOptions";
4
- import IMergeTagGroup from "./MergeTag/IMergeTagGroup";
5
- import IMergeTag from "./MergeTag/IMergeTag";
6
- export default interface ITopolPlugin {
7
- init: (topolOptions: ITopolOptions) => void;
8
- save: (lang?: string) => void;
9
- load: (json: unknown) => void;
10
- togglePreview: () => void;
11
- togglePreviewSize: () => void;
12
- chooseFile: (url: string) => void;
13
- undo: () => void;
14
- redo: () => void;
15
- destroy: () => void;
16
- setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
17
- setPreviewHTML: (html: unknown) => void;
18
- createNotification: (notification: INotification) => void;
19
- setActiveMembers: (activeMemers: string[]) => void;
20
- changeEmailToMobile: () => void;
21
- changeEmailToDesktop: () => void;
22
- toggleBlocksAndStructuresVisibility: () => void;
23
- updateCustomBlockContent: (content: string) => void;
24
- refreshComments: (key: string) => void;
25
- refreshSyncedRows: () => void;
26
- openPremadeTemplatesSelection: () => void;
27
- updateApiAuthorizationHeader: (newHeader: string | Record<string, string>) => void;
28
- setTemplateName: (name: string) => void;
29
- updateOptions: (options: Partial<ITopolOptions>) => void;
30
- setMergeTags: (mergeTags: Array<IMergeTagGroup | IMergeTag>) => void;
31
- toggleChatAI: () => void;
32
- toggleAutosaves: () => void;
33
- toggleComments: () => void;
34
- createLanguage: (lang: string) => void;
35
- setPrimaryLanguage: (lang: string) => void;
36
- deleteLanguage: (lang: string) => void;
37
- selectLanguage: (lang: string) => void;
38
- getMutations: () => void;
39
- toggleControlPanel: () => void;
40
- updateTemplate: (json: unknown, options?: {
41
- skipSnapshot?: boolean;
42
- }) => void;
43
- toggleDarkMode: () => void;
44
- }
1
+ /** @deprecated Use IEmailEditorInstance. */
2
+ export type { default } from "./IEmailEditorInstance";
@@ -1,4 +1,4 @@
1
- export type Language = "en" | "fr" | "pt" | "es" | "ja" | "zh" | "ru" | "tr" | "de" | "sv" | "nl" | "it" | "fi" | "ro" | "cs" | "pl" | "ko" | "vi" | "he";
1
+ export type Language = "en" | "fr" | "pt" | "es" | "ja" | "zh" | "ru" | "tr" | "de" | "sv" | "nl" | "it" | "fi" | "ro" | "cs" | "pl" | "ko" | "vi" | "he" | "ar" | "sk";
2
2
  export type IMultilingualLanguage = {
3
3
  name: string;
4
4
  code: string;
@@ -1,6 +1,2 @@
1
- export default interface ISavedBlock {
2
- id: number;
3
- name: string;
4
- definition: unknown;
5
- img?: string;
6
- }
1
+ /** @deprecated Use ISavedSection. Editor v4 uses sections. */
2
+ export type { ISavedSection as default } from "../Sections/ISections";
@@ -0,0 +1,30 @@
1
+ /** Reusable section. Template definitions and translations are opaque JSON. */
2
+ export interface ISavedSection {
3
+ id: number;
4
+ name: string;
5
+ img?: string | null;
6
+ definition: unknown;
7
+ translation?: unknown;
8
+ children?: ISavedSection[];
9
+ }
10
+ export interface IPremadeSection {
11
+ name?: string;
12
+ img?: string;
13
+ definition: unknown;
14
+ translation?: unknown;
15
+ }
16
+ export type IPremadeSections = {
17
+ id?: number;
18
+ name: string;
19
+ blocks: IPremadeSection[];
20
+ }[];
21
+ export interface ILegacyPremadeSections {
22
+ content?: IPremadeSection[];
23
+ ecomm?: IPremadeSection[];
24
+ footers?: IPremadeSection[];
25
+ headers?: IPremadeSection[];
26
+ }
27
+ export type IPremadeSectionsOptions = false | IPremadeSections | ILegacyPremadeSections | {
28
+ blocks: IPremadeSections | ILegacyPremadeSections;
29
+ override: boolean;
30
+ };
@@ -3,107 +3,140 @@
3
3
  * Re-exports the IPluginOptions from the schema with additional callbacks.
4
4
  */
5
5
  import type { IPluginOptions } from "../../src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema";
6
- import type { TopolSection } from "../../src/landing-page-editor/schemas/template/structure/sectionSchema";
7
6
  import type { INotification } from "../../src/landing-page-editor/schemas/notification/notificationSchema";
7
+ /**
8
+ * Payload of `onSave` and `onSaveAndClose`.
9
+ */
10
+ export interface ILandingPageSavePayload {
11
+ /** The landing page JSON structure (template definition). */
12
+ json: unknown;
13
+ /** The rendered page HTML. */
14
+ html: string;
15
+ }
16
+ /**
17
+ * A file or folder deleted in the built-in file manager (`onImageDelete`).
18
+ */
19
+ export interface ILandingPageDeletedItem {
20
+ name: string;
21
+ type: "file" | "folder";
22
+ path: string;
23
+ url?: string;
24
+ key: string | null;
25
+ }
26
+ /**
27
+ * Payload of `onEditorError`.
28
+ */
29
+ export interface ILandingPageErrorPayload {
30
+ /** Where the error originated. `"init"` is emitted by the framework wrappers when `init()` rejects. */
31
+ source: "authorize" | "network" | "templateLoad" | "init" | (string & {});
32
+ /** Human-readable description. */
33
+ message: string;
34
+ /** Raw error data when available (for `network` errors, the response body). */
35
+ detail?: unknown;
36
+ }
8
37
  /**
9
38
  * Callback functions for Landing Page Editor events.
39
+ *
40
+ * Every callback receives at most one argument: a payload object with named
41
+ * properties. New fields can be added to a payload without breaking handlers,
42
+ * so destructure what you need and ignore the rest. Callbacks that carry no
43
+ * data are called with no arguments.
10
44
  */
11
45
  export interface ILandingPageCallbacks {
12
46
  /**
13
47
  * Called when the user saves the landing page.
14
- * @param json - The landing page JSON structure
15
- * @param html - The generated HTML output
48
+ * May return a Promise: the editor keeps its saving state until it settles and a
49
+ * rejection is shown as a save error. A Promise that never settles is released after
50
+ * a timeout with a console warning.
16
51
  */
17
- onSave?(json: unknown, html: unknown): void;
52
+ onSave?(payload: ILandingPageSavePayload): void | Promise<void>;
18
53
  /**
19
- * Called when the user clicks "Save and Close".
20
- * @param json - The landing page JSON structure
21
- * @param html - The generated HTML output
54
+ * Called when the user clicks "Save and Close". Same payload and Promise handling as
55
+ * `onSave`; a rejection keeps the editor open. Closing the editor UI is your job here.
56
+ * When not defined, the payload goes to `onSave` and the editor iframe is removed afterwards.
22
57
  */
23
- onSaveAndClose?(json: unknown, html: unknown): void;
58
+ onSaveAndClose?(payload: ILandingPageSavePayload): void | Promise<void>;
24
59
  /**
25
- * Called after a template has been loaded into the editor via `load()`.
26
- *
27
- * Note: this is NOT an "editor ready" signal. The runtime does not currently emit a
28
- * separate ready event; `render()` resolving is the closest equivalent, and `load()`
29
- * can be called as soon as `render()` resolves.
30
- */
31
- onLoaded?(): void;
32
- /**
33
- * Called when the editor is initialized.
34
- */
35
- onInit?(): void;
36
- /**
37
- * Called when the user closes the editor.
60
+ * Called when the custom file manager should be opened.
38
61
  */
39
- onClose?(): void;
62
+ onOpenFileManager?(): void;
40
63
  /**
41
- * Called when the user clicks the banner.
42
- * @param json - The landing page JSON structure
43
- * @param html - The generated HTML output
64
+ * Called when files or folders are deleted in the built-in file manager, so the
65
+ * deletion can be mirrored in your own storage.
44
66
  */
45
- onBannerClick?(json: unknown, html: unknown): void;
67
+ onImageDelete?(payload: {
68
+ items: ILandingPageDeletedItem[];
69
+ }): void;
46
70
  /**
47
- * Called when the custom file manager should be opened.
71
+ * Called after a template has been loaded into the editor via `load()`.
72
+ *
73
+ * Note: this is NOT an "editor ready" signal; use `onInit` for that.
48
74
  */
49
- onOpenFileManager?(): void;
75
+ onLoaded?(): void;
50
76
  /**
51
- * Called when a block is saved.
52
- * @param block - The saved block section
77
+ * Called once the editor is fully initialized and ready.
53
78
  */
54
- onBlockSave?(block: TopolSection): void;
79
+ onInit?(): void;
55
80
  /**
56
- * Called when a block is removed.
57
- * @param blockId - The ID of the removed block
81
+ * Called when the undo stack changes. `count` is the number of undo steps available.
58
82
  */
59
- onBlockRemove?(blockId: number | string): void;
83
+ onUndoChange?(payload: {
84
+ count: number;
85
+ }): void;
60
86
  /**
61
- * Called when a block is being edited.
62
- * @param blockId - The ID of the block being edited
87
+ * Called when the redo stack changes. `count` is the number of redo steps available.
63
88
  */
64
- onBlockEdit?(blockId: number | string): void;
89
+ onRedoChange?(payload: {
90
+ count: number;
91
+ }): void;
65
92
  /**
66
- * Called when the undo stack changes.
67
- * @param count - Number of undo steps available
93
+ * Called when the user requests a preview. `html` is the rendered page.
68
94
  */
69
- onUndoChange?(count: number): void;
95
+ onPreview?(payload: {
96
+ html: string;
97
+ }): void;
70
98
  /**
71
- * Called when the redo stack changes.
72
- * @param count - Number of redo steps available
99
+ * Called when the preview is closed.
73
100
  */
74
- onRedoChange?(count: number): void;
101
+ onPreviewClose?(): void;
75
102
  /**
76
- * Called when the user requests a preview.
77
- * @param html - The preview HTML
103
+ * Called when an alert/notification is triggered.
78
104
  */
79
- onPreview?(html: unknown): void;
105
+ onAlert?(payload: {
106
+ notification: INotification;
107
+ }): void;
80
108
  /**
81
- * Called when an alert/notification is triggered.
82
- * @param notification - The notification object
109
+ * Called when the user closes the editor from the window bar. Closing the editor UI is
110
+ * your job in this handler. May return a Promise; the editor waits for it before teardown.
111
+ *
112
+ * Named `onEditorClose` because the underlying loader reserves `onClose` for its own
113
+ * lifecycle. It is NOT invoked when the host tears the editor down via `destroy()`.
83
114
  */
84
- onAlert?(notification: INotification): void;
115
+ onEditorClose?(): void | Promise<void>;
85
116
  /**
86
- * Called when the edited-without-save state changes.
87
- * @param hasChanges - Whether there are unsaved changes
117
+ * Called when the unsaved-changes state flips. `value` is `true` while there are unsaved edits.
88
118
  */
89
- onEdittedWithoutSaveChanged?(hasChanges: boolean): void;
119
+ onEdittedWithoutSaveChanged?(payload: {
120
+ value: boolean;
121
+ }): void;
90
122
  /**
91
- * Called when a custom block dialog should be opened.
92
- * @param blockData - The custom block data
123
+ * Called when a custom block dialog should be opened. `block` is the custom block data.
93
124
  */
94
- onOpenCustomBlockDialog?(blockData: unknown): void;
125
+ onOpenCustomBlockDialog?(payload: {
126
+ block: unknown;
127
+ }): void;
95
128
  /**
96
- * Called when the template is renamed.
97
- * @param newName - The new template name
129
+ * Called when the user clicks the rename button. `name` is the current template name.
98
130
  */
99
- onTemplateRename?(newName: string): void;
131
+ onTemplateRename?(payload: {
132
+ name: string;
133
+ }): void;
100
134
  /**
101
- * Called when an error occurs.
102
- * @param type - The error type
103
- * @param message - The error message
104
- * @param responseBody - The response body (optional)
135
+ * Called when an error occurs in the editor.
136
+ *
137
+ * Named `onEditorError` because the underlying loader reserves `onError` for its own lifecycle.
105
138
  */
106
- onError?(type: string, message: string, responseBody?: unknown): void;
139
+ onEditorError?(payload: ILandingPageErrorPayload): void;
107
140
  }
108
141
  /**
109
142
  * Configuration options for the Landing Page Editor.
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "author": "Topol.io",
13
13
  "homepage": "https://topol.io",
14
14
  "license": "Apache-2.0",
15
- "version": "1.0.0-alpha.8",
15
+ "version": "2.0.0-alpha.1",
16
16
  "files": [
17
17
  "dist"
18
18
  ],
@@ -23,17 +23,12 @@
23
23
  ".": {
24
24
  "types": "./dist/types/src/main.d.ts",
25
25
  "import": "./dist/topol-plugin.es.js",
26
- "require": "./dist/topol-plugin.umd.js"
26
+ "require": "./dist/topol-plugin.umd.cjs"
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^20.6.5",
31
- "@typescript-eslint/eslint-plugin": "^6.7.2",
32
- "@typescript-eslint/parser": "^6.7.2",
33
- "eslint": "^8.50.0",
34
- "eslint-config-prettier": "^9.0.0",
35
31
  "happy-dom": "^20.0.11",
36
- "prettier": "3.1.1",
37
32
  "typescript": "^5.2.2",
38
33
  "vite": "^5.0.11",
39
34
  "vitest": "^4.0.16"
@@ -49,10 +44,12 @@
49
44
  "dev": "vite",
50
45
  "build-watch": "vite build --watch",
51
46
  "build-with-types": "vite build && pnpm run build:types",
52
- "lint": "eslint --no-eslintrc --config '.eslintrc.cjs' 'src/**/*.ts' --fix",
53
- "format": "prettier --write .",
47
+ "lint": "oxlint --deny-warnings .",
48
+ "format": "oxfmt --write .",
54
49
  "build:types": "tsc -p tsconfig.prod.json",
55
50
  "test": "vitest run",
56
- "test:watch": "vitest"
51
+ "test:watch": "vitest",
52
+ "lint:fix": "oxlint --fix --deny-warnings .",
53
+ "format:check": "oxfmt --check ."
57
54
  }
58
55
  }
@@ -1 +0,0 @@
1
- (function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r["topol-plugin"]={}))})(this,function(r){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var L=function(n,o,t){var a=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");typeof o=="function"&&(t=o,o={}),o=o||{},t=t||function(){},i.type=o.type||"text/javascript",i.charset=o.charset||"utf8",i.async="async"in o?!!o.async:!0,i.src=n,o.attrs&&h(i,o.attrs),o.text&&(i.text=""+o.text);var l="onload"in i?w:v;l(i,t),i.onload||w(i,t),a.appendChild(i)};function h(e,n){for(var o in n)e.setAttribute(o,n[o])}function w(e,n){e.onload=function(){this.onerror=this.onload=null,n(null,e)},e.onerror=function(){this.onerror=this.onload=null,n(new Error("Failed to load "+this.src),e)}}function v(e,n){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,e))}}const g=u(L);var c={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const d={production:c.VITE_TOPOL_URL||"https://v3.email-assets.topol.io/loader/build.js",dev:c.VITE_TOPOL_DEV_URL||"https://v3.develop.email-assets.topol.io/loader/build.js",staging:c.VITE_TOPOL_STAGING_URL||"https://v3.develop.email-assets.topol.io/loader/build.js"},_="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";function y(e){switch(e){case"dev":return d.dev;case"staging":return d.staging;case"production":return d.production;default:return _.replace("{stage}",String(e))}}function A(e="production"){const n=y(e);if(!n){if(d.production)return console.error(`[@topol.io/editor] No loader URL resolved for stage "${e}"; falling back to the production loader.`),d.production;throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${e}". The editor cannot be loaded.`)}return n}async function S(e){return new Promise((n,o)=>{g(d.production,t=>{if(t!==null){o(t);return}window.TopolPlugin.init(e),n(!0)})})}const f={init:(e,n)=>new Promise((o,t)=>{const a=A(n==null?void 0:n.stage);g(a,async i=>{if(i!==null){if(a!==d.production)try{return await S(e),o(!0)}catch(l){t(l)}t(i);return}window.TopolPlugin.init(e),o(!0)})}),save:e=>{window.TopolPlugin.save(e)},load:e=>{window.TopolPlugin.load(e)},togglePreview:()=>{window.TopolPlugin.togglePreview()},togglePreviewSize:()=>{window.TopolPlugin.togglePreviewSize()},chooseFile:e=>{window.TopolPlugin.chooseFile(e)},undo:()=>{window.TopolPlugin.undo()},redo:()=>{window.TopolPlugin.redo()},destroy:()=>{window.TopolPlugin.destroy()},setSavedBlocks:e=>{window.TopolPlugin.setSavedBlocks(e)},setPreviewHTML:e=>{window.TopolPlugin.setPreviewHTML(e)},createNotification:e=>{window.TopolPlugin.createNotification(e)},setActiveMembers:e=>{window.TopolPlugin.setActiveMembers(e)},changeEmailToMobile:()=>{window.TopolPlugin.changeEmailToMobile()},changeEmailToDesktop:()=>{window.TopolPlugin.changeEmailToDesktop()},toggleBlocksAndStructuresVisibility:()=>{window.TopolPlugin.toggleBlocksAndStructuresVisibility()},updateCustomBlockContent:e=>{window.TopolPlugin.updateCustomBlockContent(e)},refreshComments:e=>{window.TopolPlugin.refreshComments(e)},refreshSyncedRows:()=>{window.TopolPlugin.refreshSyncedRows()},openPremadeTemplatesSelection:()=>{window.TopolPlugin.openPremadeTemplatesSelection()},updateApiAuthorizationHeader:e=>{window.TopolPlugin.updateApiAuthorizationHeader(e)},setTemplateName:e=>{window.TopolPlugin.setTemplateName(e)},updateOptions:e=>{window.TopolPlugin.updateOptions(e)},toggleChatAI:()=>{window.TopolPlugin.toggleChatAI()},toggleAutosaves:()=>{window.TopolPlugin.toggleAutosaves()},toggleComments:()=>{window.TopolPlugin.toggleComments()},createLanguage:e=>{window.TopolPlugin.createLanguage(e)},setPrimaryLanguage:e=>{window.TopolPlugin.setPrimaryLanguage(e)},deleteLanguage:e=>{window.TopolPlugin.deleteLanguage(e)},selectLanguage:e=>{window.TopolPlugin.selectLanguage(e)},getMutations:()=>window.TopolPlugin.getMutations(),toggleControlPanel:()=>{window.TopolPlugin.toggleControlPanel()},updateTemplate:(e,n)=>{window.TopolPlugin.updateTemplate(e,n)},toggleDarkMode:()=>{window.TopolPlugin.toggleDarkMode()}},R="https://v1.page-assets.topol.io/topol-lpe.js",p=new Map;function U(e,n){if(n())return Promise.resolve();const o=p.get(e);if(o)return o;const t=new Promise((a,i)=>{const l=typeof document<"u"?D(e):null;if(l){const s=()=>{E(),a()},m=()=>{E(),i(new Error(`Failed to load script: ${e}`))},E=()=>{l.removeEventListener("load",s),l.removeEventListener("error",m)};l.addEventListener("load",s),l.addEventListener("error",m);return}g(e,s=>{s!==null?i(s):a()})}).finally(()=>{p.delete(e)});return p.set(e,t),t}function D(e){const n=document.getElementsByTagName("script");for(let o=0;o<n.length;o++)if(n[o].src===e)return n[o];return null}function T(){return typeof window<"u"&&typeof window.LandingPageEditor=="function"}const O={init:async(e,n)=>{var i;if(await U(R,T),!T())throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");let o=!1;const t=window.LandingPageEditor({...e,onClose(){var l;o||(l=e.onClose)==null||l.call(e)}}),a=((i=t.destroy)==null?void 0:i.bind(t))??(()=>t.close());return t.destroy=()=>(o=!0,a()),t}},P=f;r.EmailEditor=f,r.LandingPageEditor=O,r.TopolPlugin=P,r.default=P,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});