@topol.io/editor 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -1,35 +1,35 @@
1
1
  function f(o) {
2
2
  return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
3
3
  }
4
- var P = function(t, e, i) {
5
- var r = document.head || document.getElementsByTagName("head")[0], n = document.createElement("script");
4
+ var P = function(n, e, i) {
5
+ var l = document.head || document.getElementsByTagName("head")[0], t = document.createElement("script");
6
6
  typeof e == "function" && (i = e, e = {}), e = e || {}, i = i || function() {
7
- }, n.type = e.type || "text/javascript", n.charset = e.charset || "utf8", n.async = "async" in e ? !!e.async : !0, n.src = t, e.attrs && m(n, e.attrs), e.text && (n.text = "" + e.text);
8
- var l = "onload" in n ? w : E;
9
- l(n, i), n.onload || w(n, i), r.appendChild(n);
7
+ }, t.type = e.type || "text/javascript", t.charset = e.charset || "utf8", t.async = "async" in e ? !!e.async : !0, t.src = n, e.attrs && m(t, e.attrs), e.text && (t.text = "" + e.text);
8
+ var r = "onload" in t ? w : E;
9
+ r(t, i), t.onload || w(t, i), l.appendChild(t);
10
10
  };
11
- function m(o, t) {
12
- for (var e in t)
13
- o.setAttribute(e, t[e]);
11
+ function m(o, n) {
12
+ for (var e in n)
13
+ o.setAttribute(e, n[e]);
14
14
  }
15
- function w(o, t) {
15
+ function w(o, n) {
16
16
  o.onload = function() {
17
- this.onerror = this.onload = null, t(null, o);
17
+ this.onerror = this.onload = null, n(null, o);
18
18
  }, o.onerror = function() {
19
- this.onerror = this.onload = null, t(new Error("Failed to load " + this.src), o);
19
+ this.onerror = this.onload = null, n(new Error("Failed to load " + this.src), o);
20
20
  };
21
21
  }
22
- function E(o, t) {
22
+ function E(o, n) {
23
23
  o.onreadystatechange = function() {
24
- this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, t(null, o));
24
+ this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, n(null, o));
25
25
  };
26
26
  }
27
27
  const g = /* @__PURE__ */ f(P);
28
- var u = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
29
- const h = "https://v3.email-assets.topol.io/loader/build.js", L = "https://v3.develop.email-assets.topol.io/loader/build.js", v = "https://v3.develop.email-assets.topol.io/loader/build.js", a = {
30
- production: u.VITE_TOPOL_URL || h,
31
- dev: u.VITE_TOPOL_DEV_URL || L,
32
- staging: u.VITE_TOPOL_STAGING_URL || v
28
+ var s = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
29
+ const h = "https://v3.email-assets.topol.io/loader/build.js", v = "https://v3.develop.email-assets.topol.io/loader/build.js", L = "https://v3.develop.email-assets.topol.io/loader/build.js", a = {
30
+ production: s.VITE_TOPOL_URL || h,
31
+ dev: s.VITE_TOPOL_DEV_URL || v,
32
+ staging: s.VITE_TOPOL_STAGING_URL || L
33
33
  }, y = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
34
34
  function _(o) {
35
35
  switch (o) {
@@ -44,22 +44,22 @@ function _(o) {
44
44
  }
45
45
  }
46
46
  function S(o = "production") {
47
- const t = _(o);
48
- if (!t) {
47
+ const n = _(o);
48
+ if (!n) {
49
49
  if (a.production)
50
50
  return console.error(`[@topol.io/editor] No loader URL resolved for stage "${o}"; falling back to the production loader.`), a.production;
51
51
  throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${o}". The editor cannot be loaded.`);
52
52
  }
53
- return t;
53
+ return n;
54
54
  }
55
55
  async function A(o) {
56
- return new Promise((t, e) => {
56
+ return new Promise((n, e) => {
57
57
  g(a.production, (i) => {
58
58
  if (i !== null) {
59
59
  e(i);
60
60
  return;
61
61
  }
62
- window.TopolPlugin.init(o), t(!0);
62
+ window.TopolPlugin.init(o), n(!0);
63
63
  });
64
64
  });
65
65
  }
@@ -70,17 +70,17 @@ const R = {
70
70
  * @param options - Plugin options including stage selection
71
71
  * @returns Promise that resolves to true when the editor is ready
72
72
  */
73
- init: (o, t) => new Promise((e, i) => {
74
- const r = S(t == null ? void 0 : t.stage);
75
- g(r, async (n) => {
76
- if (n !== null) {
77
- if (r !== a.production)
73
+ init: (o, n) => new Promise((e, i) => {
74
+ const l = S(n == null ? void 0 : n.stage);
75
+ g(l, async (t) => {
76
+ if (t !== null) {
77
+ if (l !== a.production)
78
78
  try {
79
79
  return await A(o), e(!0);
80
- } catch (l) {
81
- i(l);
80
+ } catch (r) {
81
+ i(r);
82
82
  }
83
- i(n);
83
+ i(t);
84
84
  return;
85
85
  }
86
86
  window.TopolPlugin.init(o), e(!0);
@@ -208,46 +208,46 @@ const R = {
208
208
  window.TopolPlugin.toggleControlPanel();
209
209
  },
210
210
  /** Update the editor template with new JSON data */
211
- updateTemplate: (o, t) => {
212
- window.TopolPlugin.updateTemplate(o, t);
211
+ updateTemplate: (o, n) => {
212
+ window.TopolPlugin.updateTemplate(o, n);
213
213
  },
214
214
  /** Toggle dark mode for the editor */
215
215
  toggleDarkMode: () => {
216
216
  window.TopolPlugin.toggleDarkMode();
217
217
  }
218
- }, O = "https://v1.page-assets.topol.io/topol-lpe.js", s = /* @__PURE__ */ new Map();
219
- function D(o, t) {
220
- if (t())
218
+ }, O = "https://v1.page-assets.topol.io/topol-lpe.js", u = /* @__PURE__ */ new Map();
219
+ function D(o, n) {
220
+ if (n())
221
221
  return Promise.resolve();
222
- const e = s.get(o);
222
+ const e = u.get(o);
223
223
  if (e)
224
224
  return e;
225
- const i = new Promise((r, n) => {
226
- const l = typeof document < "u" ? U(o) : null;
227
- if (l) {
225
+ const i = new Promise((l, t) => {
226
+ const r = typeof document < "u" ? U(o) : null;
227
+ if (r) {
228
228
  const d = () => {
229
- p(), r();
229
+ p(), l();
230
230
  }, c = () => {
231
- p(), n(new Error(`Failed to load script: ${o}`));
231
+ p(), t(new Error(`Failed to load script: ${o}`));
232
232
  }, p = () => {
233
- l.removeEventListener("load", d), l.removeEventListener("error", c);
233
+ r.removeEventListener("load", d), r.removeEventListener("error", c);
234
234
  };
235
- l.addEventListener("load", d), l.addEventListener("error", c);
235
+ r.addEventListener("load", d), r.addEventListener("error", c);
236
236
  return;
237
237
  }
238
238
  g(o, (d) => {
239
- d !== null ? n(d) : r();
239
+ d !== null ? t(d) : l();
240
240
  });
241
241
  }).finally(() => {
242
- s.delete(o);
242
+ u.delete(o);
243
243
  });
244
- return s.set(o, i), i;
244
+ return u.set(o, i), i;
245
245
  }
246
246
  function U(o) {
247
- const t = document.getElementsByTagName("script");
248
- for (let e = 0; e < t.length; e++)
249
- if (t[e].src === o)
250
- return t[e];
247
+ const n = document.getElementsByTagName("script");
248
+ for (let e = 0; e < n.length; e++)
249
+ if (n[e].src === o)
250
+ return n[e];
251
251
  return null;
252
252
  }
253
253
  function T() {
@@ -261,11 +261,12 @@ const C = {
261
261
  * @param pluginOptions - Plugin options (reserved for future staging/dev URL support)
262
262
  * @returns Promise that resolves with the editor instance
263
263
  */
264
- init: async (o, t) => {
264
+ init: async (o, n) => {
265
+ var r;
265
266
  if (await D(O, T), !T())
266
267
  throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");
267
- const e = window.LandingPageEditor(o);
268
- return e.destroy ?? (e.destroy = () => e.close()), e;
268
+ const { onClose: e, ...i } = o, l = window.LandingPageEditor(i), t = ((r = l.destroy) == null ? void 0 : r.bind(l)) ?? (() => l.close());
269
+ return l.destroy = () => t(), l;
269
270
  }
270
271
  }, I = R;
271
272
  export {
@@ -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 L=function(n,o,i){var d=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&&h(t,o.attrs),o.text&&(t.text=""+o.text);var r="onload"in t?w:v;r(t,i),t.onload||w(t,i),d.appendChild(t)};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 a={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 a.dev;case"staging":return a.staging;case"production":return a.production;default:return _.replace("{stage}",String(e))}}function A(e="production"){const n=y(e);if(!n){if(a.production)return console.error(`[@topol.io/editor] No loader URL resolved for stage "${e}"; falling back to the production loader.`),a.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(a.production,i=>{if(i!==null){o(i);return}window.TopolPlugin.init(e),n(!0)})})}const f={init:(e,n)=>new Promise((o,i)=>{const d=A(n==null?void 0:n.stage);g(d,async t=>{if(t!==null){if(d!==a.production)try{return await S(e),o(!0)}catch(r){i(r)}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()}},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 i=new Promise((d,t)=>{const r=typeof document<"u"?D(e):null;if(r){const s=()=>{E(),d()},m=()=>{E(),t(new Error(`Failed to load script: ${e}`))},E=()=>{r.removeEventListener("load",s),r.removeEventListener("error",m)};r.addEventListener("load",s),r.addEventListener("error",m);return}g(e,s=>{s!==null?t(s):d()})}).finally(()=>{p.delete(e)});return p.set(e,i),i}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)=>{if(await U(R,T),!T())throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");const o=window.LandingPageEditor(e);return o.destroy??(o.destroy=()=>o.close()),o}},P=f;l.EmailEditor=f,l.LandingPageEditor=O,l.TopolPlugin=P,l.default=P,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a["topol-plugin"]={}))})(this,function(a){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=function(n,o,i){var l=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&&L(t,o.attrs),o.text&&(t.text=""+o.text);var r="onload"in t?w:v;r(t,i),t.onload||w(t,i),l.appendChild(t)};function L(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(h);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,i=>{if(i!==null){o(i);return}window.TopolPlugin.init(e),n(!0)})})}const f={init:(e,n)=>new Promise((o,i)=>{const l=A(n==null?void 0:n.stage);g(l,async t=>{if(t!==null){if(l!==d.production)try{return await S(e),o(!0)}catch(r){i(r)}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()}},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 i=new Promise((l,t)=>{const r=typeof document<"u"?O(e):null;if(r){const s=()=>{E(),l()},m=()=>{E(),t(new Error(`Failed to load script: ${e}`))},E=()=>{r.removeEventListener("load",s),r.removeEventListener("error",m)};r.addEventListener("load",s),r.addEventListener("error",m);return}g(e,s=>{s!==null?t(s):l()})}).finally(()=>{p.delete(e)});return p.set(e,i),i}function O(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 D={init:async(e,n)=>{var r;if(await U(R,T),!T())throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");const{onClose:o,...i}=e,l=window.LandingPageEditor(i),t=((r=l.destroy)==null?void 0:r.bind(l))??(()=>l.close());return l.destroy=()=>t(),l}},P=f;a.EmailEditor=f,a.LandingPageEditor=D,a.TopolPlugin=P,a.default=P,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -40,7 +40,7 @@ export interface LandingPageEditorPluginOptions {
40
40
  * config: {
41
41
  * authorize: { apiKey: 'your-key', userId: 'user-123' },
42
42
  * },
43
- * onSave(json, html) { console.log('Saved:', json, html); },
43
+ * onSave({ json, html }) { console.log('Saved:', json, html); },
44
44
  * onLoaded() { console.log('Template loaded'); }
45
45
  * });
46
46
  *
@@ -77,5 +77,94 @@ export interface IPluginOptions {
77
77
  windowBar?: string[];
78
78
  }
79
79
  export type IPluginOptionsPartial = Omit<IPluginOptions, "authorize" | "callbacks">;
80
+ /** A file or folder deleted in the built-in file manager (`onImageDelete`). */
81
+ export declare const DeletedItemSchema: z.ZodObject<{
82
+ name: z.ZodString;
83
+ type: z.ZodUnion<readonly [z.ZodLiteral<"file">, z.ZodLiteral<"folder">]>;
84
+ path: z.ZodString;
85
+ url: z.ZodOptional<z.ZodString>;
86
+ key: z.ZodNullable<z.ZodString>;
87
+ }, z.core.$strip>;
88
+ /** Payload of `onSave` and `onSaveAndClose`. */
89
+ export declare const SavePayloadSchema: z.ZodObject<{
90
+ json: z.ZodJSONSchema;
91
+ html: z.ZodString;
92
+ }, z.core.$strip>;
93
+ /**
94
+ * Host callbacks — top-level zoid props of `LandingPageEditor({ config, onSave, ... })`.
95
+ *
96
+ * Convention: every callback receives at most one argument — a payload object with named
97
+ * properties, so payloads can grow without breaking host integrations. Zero-payload
98
+ * callbacks receive nothing.
99
+ *
100
+ * `onEditorClose` / `onEditorError` are named so because zoid reserves `onClose` / `onError`
101
+ * for its own lifecycle (those never reach the child).
102
+ */
103
+ export declare const HostCallbacksSchema: z.ZodObject<{
104
+ onSave: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
105
+ json: z.ZodJSONSchema;
106
+ html: z.ZodString;
107
+ }, z.core.$strip>], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
108
+ onSaveAndClose: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
109
+ json: z.ZodJSONSchema;
110
+ html: z.ZodString;
111
+ }, z.core.$strip>], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
112
+ onOpenFileManager: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodVoid>>;
113
+ onImageDelete: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
114
+ items: z.ZodArray<z.ZodObject<{
115
+ name: z.ZodString;
116
+ type: z.ZodUnion<readonly [z.ZodLiteral<"file">, z.ZodLiteral<"folder">]>;
117
+ path: z.ZodString;
118
+ url: z.ZodOptional<z.ZodString>;
119
+ key: z.ZodNullable<z.ZodString>;
120
+ }, z.core.$strip>>;
121
+ }, z.core.$strip>], null>, z.ZodVoid>>;
122
+ onLoaded: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodVoid>>;
123
+ onInit: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodVoid>>;
124
+ onUndoChange: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
125
+ count: z.ZodNumber;
126
+ }, z.core.$strip>], null>, z.ZodVoid>>;
127
+ onRedoChange: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
128
+ count: z.ZodNumber;
129
+ }, z.core.$strip>], null>, z.ZodVoid>>;
130
+ onPreview: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
131
+ html: z.ZodString;
132
+ }, z.core.$strip>], null>, z.ZodVoid>>;
133
+ onPreviewClose: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodVoid>>;
134
+ onAlert: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
135
+ notification: z.ZodObject<{
136
+ title: z.ZodOptional<z.ZodString>;
137
+ text: z.ZodString;
138
+ expectSideEffect: z.ZodOptional<z.ZodBoolean>;
139
+ persistent: z.ZodOptional<z.ZodBoolean>;
140
+ type: z.ZodEnum<{
141
+ info: "info";
142
+ error: "error";
143
+ success: "success";
144
+ }>;
145
+ extarnalUse: z.ZodOptional<z.ZodBoolean>;
146
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
147
+ }, z.core.$strip>;
148
+ }, z.core.$strip>], null>, z.ZodVoid>>;
149
+ onEditorClose: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodUnion<readonly [z.ZodVoid, z.ZodPromise<z.ZodVoid>]>>>;
150
+ onEdittedWithoutSaveChanged: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
151
+ value: z.ZodBoolean;
152
+ }, z.core.$strip>], null>, z.ZodVoid>>;
153
+ onOpenCustomBlockDialog: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
154
+ block: z.ZodUnknown;
155
+ }, z.core.$strip>], null>, z.ZodVoid>>;
156
+ onTemplateRename: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
157
+ name: z.ZodString;
158
+ }, z.core.$strip>], null>, z.ZodVoid>>;
159
+ onEditorError: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
160
+ source: z.ZodString;
161
+ message: z.ZodString;
162
+ detail: z.ZodOptional<z.ZodUnknown>;
163
+ }, z.core.$strip>], null>, z.ZodVoid>>;
164
+ }, z.core.$strip>;
165
+ export type IHostCallbacks = z.infer<typeof HostCallbacksSchema>;
166
+ export type ISavePayload = z.infer<typeof SavePayloadSchema>;
167
+ export type IDeletedItem = z.infer<typeof DeletedItemSchema>;
168
+ /** Everything zoid sets on `window.xprops`: `config`, the host callbacks and zoid's child helpers. */
80
169
  export declare const XpropsSchema: z.ZodTypeAny;
81
170
  export type IXprops = z.infer<typeof XpropsSchema>;
@@ -10,7 +10,7 @@
10
10
  * await TopolPlugin.init({
11
11
  * id: '#editor',
12
12
  * authorize: { apiKey: 'your-key', userId: 'user-123' },
13
- * callbacks: { onSave(json, html) { console.log('Saved'); } }
13
+ * callbacks: { onSave({ json, html }) { console.log('Saved'); } }
14
14
  * });
15
15
  * ```
16
16
  *
@@ -93,7 +93,7 @@ import type ICustomBlockData from "../types/CustomBlocks/CustomBlocks";
93
93
  import { Stage } from "../types/Stage";
94
94
  import type { ISaveData, IErrorData, ISendTestData } from "../types/Callbacks/ICallbackPayloads";
95
95
  import type ILandingPageOptions from "../types/landing-page/ILandingPageOptions";
96
- import type { ILandingPageCallbacks } from "../types/landing-page/ILandingPageOptions";
96
+ import type { ILandingPageCallbacks, ILandingPageSavePayload, ILandingPageDeletedItem, ILandingPageErrorPayload } from "../types/landing-page/ILandingPageOptions";
97
97
  import type ILandingPageEditorInstance from "../types/landing-page/ILandingPageEditorInstance";
98
98
  import type { TopolSection } from "./landing-page-editor/schemas/template/structure/sectionSchema";
99
99
  export default TopolPlugin;
@@ -105,4 +105,4 @@ export { EmailEditor };
105
105
  export { LandingPageEditor };
106
106
  export type { ITopolOptions, IEmailCallbacks, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData, Stage as IStage };
107
107
  export type { ISaveData, IErrorData, ISendTestData };
108
- export type { ILandingPageOptions, ILandingPageCallbacks, ILandingPageEditorInstance, TopolSection };
108
+ export type { ILandingPageOptions, ILandingPageCallbacks, ILandingPageEditorInstance, TopolSection, ILandingPageSavePayload, ILandingPageDeletedItem, ILandingPageErrorPayload };
@@ -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.7",
15
+ "version": "1.0.0-alpha.9",
16
16
  "files": [
17
17
  "dist"
18
18
  ],