@topol.io/editor 1.0.0-alpha.2 → 1.0.0-alpha.4

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.
@@ -192,6 +192,8 @@ const f = {
192
192
  selectLanguage: (e) => {
193
193
  window.TopolPlugin.selectLanguage(e);
194
194
  },
195
+ /** Get the list of mutations */
196
+ getMutations: () => window.TopolPlugin.getMutations(),
195
197
  /** Toggle the control panel visibility */
196
198
  toggleControlPanel: () => {
197
199
  window.TopolPlugin.toggleControlPanel();
@@ -1 +1 @@
1
- (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l["topol-plugin"]={}))})(this,function(l){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T=function(n,o,i){var a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("script");typeof o=="function"&&(i=o,o={}),o=o||{},i=i||function(){},t.type=o.type||"text/javascript",t.charset=o.charset||"utf8",t.async="async"in o?!!o.async:!0,t.src=n,o.attrs&&P(t,o.attrs),o.text&&(t.text=""+o.text);var s="onload"in t?w:f;s(t,i),t.onload||w(t,i),a.appendChild(t)};function P(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 f(e,n){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,e))}}const r=u(T);var g={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const d={production:g.VITE_TOPOL_URL,dev:g.VITE_TOPOL_DEV_URL,staging:g.VITE_TOPOL_STAGING_URL},m="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";function h(e="production"){switch(e){case"dev":return d.dev;case"staging":return d.staging;case"production":return d.production;default:return m.replace("{stage}",String(e))}}async function E(e){return new Promise((n,o)=>{r(d.production,i=>{if(i!==null){o(i);return}window.TopolPlugin.init(e),n(!0)})})}const c={init:(e,n)=>new Promise((o,i)=>{const a=h(n==null?void 0:n.stage);r(a,async t=>{if(t!==null){if(a!==d.production)try{return await E(e),o(!0)}catch(s){i(s)}i(t);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)},toggleControlPanel:()=>{window.TopolPlugin.toggleControlPanel()},updateTemplate:(e,n)=>{window.TopolPlugin.updateTemplate(e,n)},toggleDarkMode:()=>{window.TopolPlugin.toggleDarkMode()}},v="https://v1.page-assets.topol.io/topol-lpe.js",y={init:(e,n)=>new Promise((o,i)=>{r(v,a=>{if(a!==null){i(a);return}const t=window.LandingPageEditor(e);o(t)})})},p=c;l.EmailEditor=c,l.LandingPageEditor=y,l.TopolPlugin=p,l.default=p,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l["topol-plugin"]={}))})(this,function(l){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T=function(n,o,i){var a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("script");typeof o=="function"&&(i=o,o={}),o=o||{},i=i||function(){},t.type=o.type||"text/javascript",t.charset=o.charset||"utf8",t.async="async"in o?!!o.async:!0,t.src=n,o.attrs&&P(t,o.attrs),o.text&&(t.text=""+o.text);var s="onload"in t?w:f;s(t,i),t.onload||w(t,i),a.appendChild(t)};function P(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 f(e,n){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,e))}}const r=u(T);var g={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const d={production:g.VITE_TOPOL_URL,dev:g.VITE_TOPOL_DEV_URL,staging:g.VITE_TOPOL_STAGING_URL},m="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";function h(e="production"){switch(e){case"dev":return d.dev;case"staging":return d.staging;case"production":return d.production;default:return m.replace("{stage}",String(e))}}async function E(e){return new Promise((n,o)=>{r(d.production,i=>{if(i!==null){o(i);return}window.TopolPlugin.init(e),n(!0)})})}const c={init:(e,n)=>new Promise((o,i)=>{const a=h(n==null?void 0:n.stage);r(a,async t=>{if(t!==null){if(a!==d.production)try{return await E(e),o(!0)}catch(s){i(s)}i(t);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()}},v="https://v1.page-assets.topol.io/topol-lpe.js",y={init:(e,n)=>new Promise((o,i)=>{r(v,a=>{if(a!==null){i(a);return}const t=window.LandingPageEditor(e);o(t)})})},p=c;l.EmailEditor=c,l.LandingPageEditor=y,l.TopolPlugin=p,l.default=p,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -95,6 +95,8 @@ export declare const EmailEditor: {
95
95
  deleteLanguage: (lang: string) => void;
96
96
  /** Select/switch to a language */
97
97
  selectLanguage: (lang: string) => void;
98
+ /** Get the list of mutations */
99
+ getMutations: () => void;
98
100
  /** Toggle the control panel visibility */
99
101
  toggleControlPanel: () => void;
100
102
  /** Update the editor template with new JSON data */
@@ -70,6 +70,7 @@ declare const TopolPlugin: {
70
70
  setPrimaryLanguage: (lang: string) => void;
71
71
  deleteLanguage: (lang: string) => void;
72
72
  selectLanguage: (lang: string) => void;
73
+ getMutations: () => void;
73
74
  toggleControlPanel: () => void;
74
75
  updateTemplate: (json: unknown, options?: {
75
76
  skipSnapshot?: boolean | undefined;
@@ -17,11 +17,12 @@ export interface ISaveData {
17
17
  }
18
18
  /**
19
19
  * Payload for onError callback.
20
- * Used when transforming (type, message) arguments into a single object.
20
+ * Used when transforming (type, message, responseBody) arguments into a single object.
21
21
  */
22
22
  export interface IErrorData {
23
23
  type: string;
24
24
  message: string;
25
+ responseBody?: unknown;
25
26
  }
26
27
  /**
27
28
  * Payload for onTestSend callback (Email Editor only).
@@ -114,6 +114,47 @@ export default interface IEmailCallbacks {
114
114
  * Called when an error occurs.
115
115
  * @param type - The error type
116
116
  * @param message - The error message
117
+ * @param responseBody - The response body (optional)
117
118
  */
118
- onError?(type: string, message: string): void;
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;
119
160
  }
@@ -35,6 +35,7 @@ export default interface ITopolPlugin {
35
35
  setPrimaryLanguage: (lang: string) => void;
36
36
  deleteLanguage: (lang: string) => void;
37
37
  selectLanguage: (lang: string) => void;
38
+ getMutations: () => void;
38
39
  toggleControlPanel: () => void;
39
40
  updateTemplate: (json: unknown, options?: {
40
41
  skipSnapshot?: boolean;
@@ -97,8 +97,9 @@ export interface ILandingPageCallbacks {
97
97
  * Called when an error occurs.
98
98
  * @param type - The error type
99
99
  * @param message - The error message
100
+ * @param responseBody - The response body (optional)
100
101
  */
101
- onError?(type: string, message: string): void;
102
+ onError?(type: string, message: string, responseBody?: unknown): void;
102
103
  }
103
104
  /**
104
105
  * 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.2",
15
+ "version": "1.0.0-alpha.4",
16
16
  "files": [
17
17
  "dist"
18
18
  ],