@topol.io/editor 1.0.0-alpha.10 → 1.0.0-alpha.12

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 (67) hide show
  1. package/README.md +17 -14
  2. package/dist/topol-plugin.es.js +109 -95
  3. package/dist/topol-plugin.umd.cjs +1 -1
  4. package/dist/types/src/email-editor/index.d.ts +3 -3
  5. package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
  6. package/dist/types/src/landing-page-editor/index.d.ts +10 -5
  7. package/dist/types/src/landing-page-editor/schemas/api/apiSchema.d.ts +5 -11
  8. package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +33 -17
  9. package/dist/types/src/landing-page-editor/schemas/language/languageSchema.d.ts +1 -1
  10. package/dist/types/src/landing-page-editor/schemas/mjmlStore/mjmlStoreSchema.d.ts +8 -6
  11. package/dist/types/src/landing-page-editor/schemas/notification/notificationSchema.d.ts +0 -1
  12. package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +65 -21
  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 +685 -3
  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 +9 -1
  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 +29 -13
  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 +9 -1
  21. package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +16 -8
  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 +4675 -1996
  31. package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5445 -2356
  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 +8365 -3100
  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 +34901 -48500
  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 +23 -42
  42. package/dist/types/types/API/API.d.ts +1 -3
  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 +2 -1
  46. package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +11 -4
  47. package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +23 -15
  48. package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
  49. package/dist/types/types/Countdown/ICountdownOptions.d.ts +2 -2
  50. package/dist/types/types/IEmailConfig.d.ts +33 -24
  51. package/dist/types/types/IEmailEditorInstance.d.ts +14 -4
  52. package/dist/types/types/{ITopolOptions.d.ts → IEmailOptions.d.ts} +1 -1
  53. package/dist/types/types/MergeTag/IMergeTag.d.ts +18 -0
  54. package/dist/types/types/Notification/INotification.d.ts +2 -1
  55. package/dist/types/types/Sections/ISections.d.ts +12 -1
  56. package/dist/types/types/Shortcuts/EditorShortcut.d.ts +4 -0
  57. package/dist/types/types/Theme/ITheme.d.ts +12 -2
  58. package/dist/types/types/landing-page/ILandingPageEditorInstance.d.ts +65 -5
  59. package/dist/types/types/landing-page/ILandingPageOptions.d.ts +15 -12
  60. package/package.json +1 -1
  61. package/dist/types/src/landing-page-editor/schemas/helpdesk/helpdeskSchema.d.ts +0 -8
  62. package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +0 -59750
  63. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +0 -44831
  64. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +0 -59725
  65. package/dist/types/src/landing-page-editor/schemas/template/blocks/index.d.ts +0 -12
  66. package/dist/types/types/ITopolPlugin.d.ts +0 -2
  67. package/dist/types/types/SavedBlock/ISavedBlock.d.ts +0 -2
package/README.md CHANGED
@@ -8,7 +8,7 @@ import { EmailEditor } from "@topol.io/editor";
8
8
 
9
9
  const editor = await EmailEditor.init({
10
10
  config: {
11
- authorize: { apiKey: "your-api-key", userId: "user-123" },
11
+ authorize: { apiKey: "your-api-key", entityId: "user-123" },
12
12
  },
13
13
  async onSave({ json, html, mutations, syncedSections }) {
14
14
  // Await your own backend's persistence here. A rejection shows a save error.
@@ -40,9 +40,9 @@ callback enables it. Topol Cloud is built on top of it and requires the callback
40
40
 
41
41
  ```ts
42
42
  const editor = await EmailEditor.init({
43
- config: { authorize: { apiKey: "pk_your-public-key", userId: "user-123" } },
43
+ config: { authorize: { apiKey: "pk_your-public-key", entityId: "user-123" } },
44
44
  async getNonce() {
45
- // Your backend calls Topol's POST /auth/nonce with the sk_ secret and this userId.
45
+ // Your backend calls Topol's POST /auth/nonce with the sk_ secret and this entityId.
46
46
  const response = await fetch("/api/topol/nonce", { method: "POST" });
47
47
  if (!response.ok) throw new Error("Could not mint a Topol nonce");
48
48
  return (await response.json()).nonce; // A fresh nc_ token.
@@ -60,7 +60,7 @@ reports `onEditorError` with `source: "authorize"`; a later refresh failure repo
60
60
  ```ts
61
61
  const editor = await EmailEditor.init({
62
62
  config: {
63
- authorize: { apiKey: "pk_your-public-key", userId: "user-123" },
63
+ authorize: { apiKey: "pk_your-public-key", entityId: "user-123" },
64
64
  cloud: { enabled: true, templateId: 123, features: { images: false } },
65
65
  },
66
66
  async getNonce() {
@@ -90,16 +90,14 @@ supplies the host bridge.
90
90
  ## Countdown block
91
91
 
92
92
  The Countdown block is a paid add-on rolled out per user. It appears only when the
93
- add-on flag your backend put into the editor nonce is set **and** `enableCountdown`
94
- is `true`, and it needs `templateId`. The optional `countdown` object adapts the block
95
- to your email service provider:
93
+ add-on flag your backend put into the editor nonce is set, and it needs `templateId`.
94
+ The optional `countdown` object adapts the block to your email service provider:
96
95
 
97
96
  ```ts
98
97
  const editor = await EmailEditor.init({
99
98
  config: {
100
- authorize: { apiKey: "pk_your-public-key", userId: "user-123" },
99
+ authorize: { apiKey: "pk_your-public-key", entityId: "user-123" },
101
100
  templateId: 123,
102
- enableCountdown: true,
103
101
  countdown: {
104
102
  defaultColors: { background: "#ffffff", digits: "#000000", accent: "#2b66b3" },
105
103
  styleThumbnailBase: "https://cdn.example.com/countdown-styles",
@@ -163,8 +161,13 @@ the editor at that origin, or build a loader with an explicit iframe URL.
163
161
  - `api.SAVED_BLOCKS` → `api.SAVED_SECTIONS`; `api.SYNCED_ROWS` is removed. Legacy SAVE/LOAD/PREVIEW and singular autosave endpoints are removed.
164
162
  - Language mutations and `defaultTemplateSettings.langs` use `code`, not `key`.
165
163
  - `topBarOptions` → `hideTopbarControls` (a list of controls to hide).
166
- - `authorize.userId` must be a non-negative integer or match `[A-Za-z0-9_-]+`.
167
-
168
- `TopolPlugin` remains a naming alias for the new EmailEditor API, not a v3 adapter.
169
- `LandingPageEditor` retains its existing API and loader. Its Cloud integration is
170
- not enabled by these email-specific changes.
164
+ - `authorize.userId` → `authorize.entityId`, which must be a non-negative integer or match `[A-Za-z0-9_-]+`. `userId` is no longer read.
165
+ - `hideControlPanel` / `showControlPanelExpand` / `toggleControlPanel()` → `hideSelectionPanel` / `hideSelectionPanelExpand` (inverted) / `toggleSelectionPanel()`. The old names are removed.
166
+
167
+ The `TopolPlugin` alias and the default export are removed; import the named `EmailEditor`.
168
+ `LandingPageEditor` retains its loader. Every instance method returns a Promise;
169
+ `save()` settles once the save has finished, including your `onSave` Promise, and
170
+ rejects with `err.code === "SAVE_IN_PROGRESS"` while another save runs. Pass `getNonce`
171
+ next to the other callbacks to turn nonce authentication on, and `{ loaderUrl }` as the
172
+ second argument of `init()` to load a preview or local build (one loader URL per page). Its Cloud
173
+ integration is not enabled by these email-specific changes.
@@ -1,157 +1,171 @@
1
- function I(e) {
1
+ function T(e) {
2
2
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
3
  }
4
- var P = function(o, t, r) {
5
- var n = document.head || document.getElementsByTagName("head")[0], i = document.createElement("script");
6
- typeof t == "function" && (r = t, t = {}), t = t || {}, r = r || function() {
7
- }, i.type = t.type || "text/javascript", i.charset = t.charset || "utf8", i.async = "async" in t ? !!t.async : !0, i.src = o, t.attrs && T(i, t.attrs), t.text && (i.text = "" + t.text);
8
- var a = "onload" in i ? p : b;
9
- a(i, r), i.onload || p(i, r), n.appendChild(i);
4
+ var _ = function(t, o, n) {
5
+ var i = document.head || document.getElementsByTagName("head")[0], r = document.createElement("script");
6
+ typeof o == "function" && (n = o, o = {}), o = o || {}, n = n || function() {
7
+ }, r.type = o.type || "text/javascript", r.charset = o.charset || "utf8", r.async = "async" in o ? !!o.async : !0, r.src = t, o.attrs && A(r, o.attrs), o.text && (r.text = "" + o.text);
8
+ var d = "onload" in r ? p : S;
9
+ d(r, n), r.onload || p(r, n), i.appendChild(r);
10
10
  };
11
- function T(e, o) {
12
- for (var t in o)
13
- e.setAttribute(t, o[t]);
11
+ function A(e, t) {
12
+ for (var o in t)
13
+ e.setAttribute(o, t[o]);
14
14
  }
15
- function p(e, o) {
15
+ function p(e, t) {
16
16
  e.onload = function() {
17
- this.onerror = this.onload = null, o(null, e);
17
+ this.onerror = this.onload = null, t(null, e);
18
18
  }, e.onerror = function() {
19
- this.onerror = this.onload = null, o(new Error("Failed to load " + this.src), e);
19
+ this.onerror = this.onload = null, t(new Error("Failed to load " + this.src), e);
20
20
  };
21
21
  }
22
- function b(e, o) {
22
+ function S(e, t) {
23
23
  e.onreadystatechange = function() {
24
- this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, o(null, e));
24
+ this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, t(null, e));
25
25
  };
26
26
  }
27
- const _ = /* @__PURE__ */ I(P), f = /* @__PURE__ */ new Map();
28
- function U(e, o) {
29
- if (o())
27
+ const N = /* @__PURE__ */ T(_), f = /* @__PURE__ */ new Map();
28
+ function I(e, t) {
29
+ if (t())
30
30
  return Promise.resolve();
31
- const t = f.get(e);
32
- if (t)
33
- return t;
34
- const r = new Promise((n, i) => {
35
- const a = typeof document < "u" ? g(e) : null;
36
- if (a) {
37
- const l = () => {
38
- c(), n();
39
- }, d = () => {
40
- c(), a.remove(), i(new Error(`Failed to load script: ${e}`));
41
- }, c = () => {
42
- a.removeEventListener("load", l), a.removeEventListener("error", d);
31
+ const o = f.get(e);
32
+ if (o)
33
+ return o;
34
+ const n = new Promise((i, r) => {
35
+ const d = typeof document < "u" ? U(e) : null;
36
+ if (d) {
37
+ const a = () => {
38
+ l(), i();
39
+ }, s = () => {
40
+ l(), d.remove(), r(new Error(`Failed to load script: ${e}`));
41
+ }, l = () => {
42
+ d.removeEventListener("load", a), d.removeEventListener("error", s);
43
43
  };
44
- a.addEventListener("load", l), a.addEventListener("error", d);
44
+ d.addEventListener("load", a), d.addEventListener("error", s);
45
45
  return;
46
46
  }
47
- _(e, (l) => {
48
- var d;
49
- l !== null ? ((d = g(e)) == null || d.remove(), i(l)) : n();
47
+ N(e, (a) => {
48
+ var s;
49
+ a !== null ? ((s = U(e)) == null || s.remove(), r(a)) : i();
50
50
  });
51
51
  }).finally(() => {
52
52
  f.delete(e);
53
53
  });
54
- return f.set(e, r), r;
54
+ return f.set(e, n), n;
55
55
  }
56
- function g(e) {
57
- const o = document.getElementsByTagName("script");
58
- for (let t = 0; t < o.length; t++)
59
- if (o[t].src === new URL(e, document.baseURI).href)
60
- return o[t];
56
+ function U(e) {
57
+ const t = document.getElementsByTagName("script");
58
+ for (let o = 0; o < t.length; o++)
59
+ if (t[o].src === new URL(e, document.baseURI).href)
60
+ return t[o];
61
61
  return null;
62
62
  }
63
63
  const w = "https://v4.email-assets.topol.io/loader/build.js", u = {
64
64
  production: w,
65
65
  dev: w,
66
66
  staging: w
67
- }, A = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
67
+ }, C = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
68
68
  class h extends Error {
69
69
  }
70
- let s, y = Promise.resolve();
71
- function O(e) {
70
+ let c, R = Promise.resolve();
71
+ function D(e) {
72
72
  if ((e == null ? void 0 : e.loaderUrl) !== void 0) {
73
73
  if (!e.loaderUrl.trim())
74
74
  throw new Error("[@topol.io/editor] loaderUrl must not be empty.");
75
75
  return e.loaderUrl;
76
76
  }
77
- const o = (e == null ? void 0 : e.stage) ?? "production", r = typeof o == "number" || /^\d+$/.test(o) ? A.replace("{stage}", String(o)) : u[o];
78
- if (!r)
79
- throw new Error(`[@topol.io/editor] Unsupported stage "${o}". Use a supported stage or loaderUrl.`);
80
- return r;
77
+ const t = (e == null ? void 0 : e.stage) ?? "production", n = typeof t == "number" || /^\d+$/.test(t) ? C.replace("{stage}", String(t)) : u[t];
78
+ if (!n)
79
+ throw new Error(`[@topol.io/editor] Unsupported stage "${t}". Use a supported stage or loaderUrl.`);
80
+ return n;
81
81
  }
82
- function S(e, o) {
83
- const t = y.then(async () => {
82
+ function j(e, t) {
83
+ const o = R.then(async () => {
84
84
  try {
85
- return await v(e);
86
- } catch (r) {
87
- if (r instanceof h || o === void 0)
88
- throw r;
89
- const n = await v(o);
90
- return s == null || s.urls.add(new URL(e, document.baseURI).href), n;
85
+ return await L(e);
86
+ } catch (n) {
87
+ if (n instanceof h || t === void 0)
88
+ throw n;
89
+ const i = await L(t);
90
+ return c == null || c.urls.add(new URL(e, document.baseURI).href), i;
91
91
  }
92
92
  });
93
- return y = t.catch(() => {
94
- }), t;
93
+ return R = o.catch(() => {
94
+ }), o;
95
95
  }
96
- async function v(e) {
97
- const o = new URL(e, document.baseURI).href;
98
- if (s) {
99
- if (s.urls.has(o))
100
- return s.factory;
96
+ async function L(e) {
97
+ const t = new URL(e, document.baseURI).href;
98
+ if (c) {
99
+ if (c.urls.has(t))
100
+ return c.factory;
101
101
  throw new h("[@topol.io/editor] Editor v4 supports one loader URL per page. Reload the page to switch environments.");
102
102
  }
103
- const t = o === new URL(u.production, document.baseURI).href && typeof window.TopolEmailEditor == "function";
104
- if (!t && (typeof window.TopolEmailEditor == "function" || Array.from(document.scripts).some((n) => n.src === o)))
103
+ const o = t === new URL(u.production, document.baseURI).href && typeof window.TopolEmailEditor == "function";
104
+ if (!o && (typeof window.TopolEmailEditor == "function" || Array.from(document.scripts).some((i) => i.src === t)))
105
105
  throw new h("[@topol.io/editor] Cannot initialize from a host-provided loader with unknown lifecycle. Remove the script, reload the page, and let EmailEditor.init load the requested URL.");
106
- if (await U(e, () => t), typeof window.TopolEmailEditor != "function") {
107
- for (const n of Array.from(document.scripts))
108
- n.src === o && n.remove();
106
+ if (await I(e, () => o), typeof window.TopolEmailEditor != "function") {
107
+ for (const i of Array.from(document.scripts))
108
+ i.src === t && i.remove();
109
109
  throw new Error("[@topol.io/editor] The loader did not define window.TopolEmailEditor. Use an editor v4 loader.");
110
110
  }
111
- const r = window.TopolEmailEditor;
112
- return s = { urls: /* @__PURE__ */ new Set([o]), factory: r }, r;
111
+ const n = window.TopolEmailEditor;
112
+ return c = { urls: /* @__PURE__ */ new Set([t]), factory: n }, n;
113
113
  }
114
- const N = {
115
- async init(e, o) {
116
- var E, m;
114
+ const O = {
115
+ async init(e, t) {
116
+ var g, v;
117
117
  if (typeof window > "u" || typeof document > "u")
118
118
  throw new Error("[@topol.io/editor] EmailEditor.init requires a browser. Call it after mounting.");
119
- if (!((E = e == null ? void 0 : e.config) != null && E.authorize))
119
+ if (!((g = e == null ? void 0 : e.config) != null && g.authorize))
120
120
  throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See docs/MIGRATION-editor-v4.md.");
121
- const t = e.config.authorize.userId;
122
- if (typeof t == "string" ? !/^[A-Za-z0-9_-]+$/.test(t) : !Number.isInteger(t) || t < 0)
123
- throw new Error("[@topol.io/editor] authorize.userId must be a URL-safe string or a non-negative integer.");
124
- if ((m = e.config.cloud) != null && m.enabled && typeof e.getNonce != "function")
121
+ const o = e.config.authorize.entityId;
122
+ if (typeof o == "string" ? !/^[A-Za-z0-9_-]+$/.test(o) : typeof o != "number" || !Number.isInteger(o) || o < 0)
123
+ throw new Error("[@topol.io/editor] authorize.entityId must be a URL-safe string or a non-negative integer.");
124
+ if ((v = e.config.cloud) != null && v.enabled && typeof e.getNonce != "function")
125
125
  throw new Error("[@topol.io/editor] cloud.enabled requires nonce authentication: pass a top-level getNonce callback returning Promise<string>.");
126
- const r = O(o), n = (o == null ? void 0 : o.loaderUrl) === void 0 && r !== u.production ? u.production : void 0, i = await S(r, n), { onClose: a, onError: l, ...d } = e, c = i(d);
127
- let L;
128
- return Object.assign(c, {
129
- destroy: () => L ?? (L = Promise.resolve().then(() => c.close()))
126
+ const n = D(t), i = (t == null ? void 0 : t.loaderUrl) === void 0 && n !== u.production ? u.production : void 0, r = await j(n, i), { onClose: d, onError: a, ...s } = e, l = r(s);
127
+ let P;
128
+ return Object.assign(l, {
129
+ destroy: () => P ?? (P = Promise.resolve().then(() => l.close()))
130
130
  });
131
131
  }
132
- }, C = "https://v1.page-assets.topol.io/topol-lpe.js";
133
- function R() {
132
+ }, b = "https://v1.page-assets.topol.io/loader/build.js";
133
+ function m() {
134
134
  return typeof window < "u" && typeof window.LandingPageEditor == "function";
135
135
  }
136
- const j = {
136
+ let E;
137
+ function y(e) {
138
+ return typeof document < "u" ? new URL(e, document.baseURI).href : e;
139
+ }
140
+ function z(e) {
141
+ if (e !== void 0 && !e.trim())
142
+ throw new Error("[@topol.io/editor] loaderUrl must not be empty.");
143
+ const t = e ?? b;
144
+ if (!m())
145
+ return E = void 0, t;
146
+ if ((E ?? y(b)) !== y(t))
147
+ throw new Error("[@topol.io/editor] The Landing Page Editor supports one loader URL per page. Reload the page to switch environments.");
148
+ return t;
149
+ }
150
+ const x = {
137
151
  /**
138
152
  * Inits Landing Page Editor.
139
153
  *
140
154
  * @param options - Configuration options for the editor
141
- * @param pluginOptions - Plugin options (reserved for future staging/dev URL support)
155
+ * @param pluginOptions - Plugin options: an explicit `loaderUrl`
142
156
  * @returns Promise that resolves with the editor instance
143
157
  */
144
- init: async (e, o) => {
158
+ init: async (e, t) => {
145
159
  var a;
146
- if (await U(C, R), !R())
147
- throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");
148
- const { onClose: t, ...r } = e, n = window.LandingPageEditor(r), i = ((a = n.destroy) == null ? void 0 : a.bind(n)) ?? (() => n.close());
149
- return n.destroy = () => i(), n;
160
+ const o = z(t == null ? void 0 : t.loaderUrl);
161
+ if (await I(o, m), !m())
162
+ throw new Error("[@topol.io/editor] The Landing Page Editor loader loaded but window.LandingPageEditor is not defined.");
163
+ E = y(o);
164
+ const { onClose: n, ...i } = e, r = window.LandingPageEditor(i), d = ((a = r.destroy) == null ? void 0 : a.bind(r)) ?? (() => r.close());
165
+ return r.destroy = () => d(), r;
150
166
  }
151
- }, D = N;
167
+ };
152
168
  export {
153
- N as EmailEditor,
154
- j as LandingPageEditor,
155
- D as TopolPlugin,
156
- D as default
169
+ O as EmailEditor,
170
+ x as LandingPageEditor
157
171
  };
@@ -1 +1 @@
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.TopolPlugin={}))})(this,function(a){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I=function(o,t,n){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");typeof t=="function"&&(n=t,t={}),t=t||{},n=n||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async="async"in t?!!t.async:!0,i.src=o,t.attrs&&_(i,t.attrs),t.text&&(i.text=""+t.text);var d="onload"in i?g:S;d(i,n),i.onload||g(i,n),r.appendChild(i)};function _(e,o){for(var t in o)e.setAttribute(t,o[t])}function g(e,o){e.onload=function(){this.onerror=this.onload=null,o(null,e)},e.onerror=function(){this.onerror=this.onload=null,o(new Error("Failed to load "+this.src),e)}}function S(e,o){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,o(null,e))}}const A=u(I),h=new Map;function p(e,o){if(o())return Promise.resolve();const t=h.get(e);if(t)return t;const n=new Promise((r,i)=>{const d=typeof document<"u"?y(e):null;if(d){const c=()=>{f(),r()},l=()=>{f(),d.remove(),i(new Error(`Failed to load script: ${e}`))},f=()=>{d.removeEventListener("load",c),d.removeEventListener("error",l)};d.addEventListener("load",c),d.addEventListener("error",l);return}A(e,c=>{var l;c!==null?((l=y(e))==null||l.remove(),i(c)):r()})}).finally(()=>{h.delete(e)});return h.set(e,n),n}function y(e){const o=document.getElementsByTagName("script");for(let t=0;t<o.length;t++)if(o[t].src===new URL(e,document.baseURI).href)return o[t];return null}const m="https://v4.email-assets.topol.io/loader/build.js",w={production:m,dev:m,staging:m},O="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";class E extends Error{}let s,v=Promise.resolve();function N(e){if((e==null?void 0:e.loaderUrl)!==void 0){if(!e.loaderUrl.trim())throw new Error("[@topol.io/editor] loaderUrl must not be empty.");return e.loaderUrl}const o=(e==null?void 0:e.stage)??"production",n=typeof o=="number"||/^\d+$/.test(o)?O.replace("{stage}",String(o)):w[o];if(!n)throw new Error(`[@topol.io/editor] Unsupported stage "${o}". Use a supported stage or loaderUrl.`);return n}function j(e,o){const t=v.then(async()=>{try{return await R(e)}catch(n){if(n instanceof E||o===void 0)throw n;const r=await R(o);return s==null||s.urls.add(new URL(e,document.baseURI).href),r}});return v=t.catch(()=>{}),t}async function R(e){const o=new URL(e,document.baseURI).href;if(s){if(s.urls.has(o))return s.factory;throw new E("[@topol.io/editor] Editor v4 supports one loader URL per page. Reload the page to switch environments.")}const t=o===new URL(w.production,document.baseURI).href&&typeof window.TopolEmailEditor=="function";if(!t&&(typeof window.TopolEmailEditor=="function"||Array.from(document.scripts).some(r=>r.src===o)))throw new E("[@topol.io/editor] Cannot initialize from a host-provided loader with unknown lifecycle. Remove the script, reload the page, and let EmailEditor.init load the requested URL.");if(await p(e,()=>t),typeof window.TopolEmailEditor!="function"){for(const r of Array.from(document.scripts))r.src===o&&r.remove();throw new Error("[@topol.io/editor] The loader did not define window.TopolEmailEditor. Use an editor v4 loader.")}const n=window.TopolEmailEditor;return s={urls:new Set([o]),factory:n},n}const U={async init(e,o){var P,b;if(typeof window>"u"||typeof document>"u")throw new Error("[@topol.io/editor] EmailEditor.init requires a browser. Call it after mounting.");if(!((P=e==null?void 0:e.config)!=null&&P.authorize))throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See docs/MIGRATION-editor-v4.md.");const t=e.config.authorize.userId;if(typeof t=="string"?!/^[A-Za-z0-9_-]+$/.test(t):!Number.isInteger(t)||t<0)throw new Error("[@topol.io/editor] authorize.userId must be a URL-safe string or a non-negative integer.");if((b=e.config.cloud)!=null&&b.enabled&&typeof e.getNonce!="function")throw new Error("[@topol.io/editor] cloud.enabled requires nonce authentication: pass a top-level getNonce callback returning Promise<string>.");const n=N(o),r=(o==null?void 0:o.loaderUrl)===void 0&&n!==w.production?w.production:void 0,i=await j(n,r),{onClose:d,onError:c,...l}=e,f=i(l);let M;return Object.assign(f,{destroy:()=>M??(M=Promise.resolve().then(()=>f.close()))})}},C="https://v1.page-assets.topol.io/topol-lpe.js";function L(){return typeof window<"u"&&typeof window.LandingPageEditor=="function"}const D={init:async(e,o)=>{var d;if(await p(C,L),!L())throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");const{onClose:t,...n}=e,r=window.LandingPageEditor(n),i=((d=r.destroy)==null?void 0:d.bind(r))??(()=>r.close());return r.destroy=()=>i(),r}},T=U;a.EmailEditor=U,a.LandingPageEditor=D,a.TopolPlugin=T,a.default=T,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(s,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s.TopolPlugin={}))})(this,function(s){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _=function(t,o,n){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("script");typeof o=="function"&&(n=o,o={}),o=o||{},n=n||function(){},r.type=o.type||"text/javascript",r.charset=o.charset||"utf8",r.async="async"in o?!!o.async:!0,r.src=t,o.attrs&&S(r,o.attrs),o.text&&(r.text=""+o.text);var d="onload"in r?v:A;d(r,n),r.onload||v(r,n),i.appendChild(r)};function S(e,t){for(var o in t)e.setAttribute(o,t[o])}function v(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function A(e,t){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,t(null,e))}}const N=u(_),m=new Map;function U(e,t){if(t())return Promise.resolve();const o=m.get(e);if(o)return o;const n=new Promise((i,r)=>{const d=typeof document<"u"?R(e):null;if(d){const a=()=>{f(),i()},c=()=>{f(),d.remove(),r(new Error(`Failed to load script: ${e}`))},f=()=>{d.removeEventListener("load",a),d.removeEventListener("error",c)};d.addEventListener("load",a),d.addEventListener("error",c);return}N(e,a=>{var c;a!==null?((c=R(e))==null||c.remove(),r(a)):i()})}).finally(()=>{m.delete(e)});return m.set(e,n),n}function R(e){const t=document.getElementsByTagName("script");for(let o=0;o<t.length;o++)if(t[o].src===new URL(e,document.baseURI).href)return t[o];return null}const h="https://v4.email-assets.topol.io/loader/build.js",w={production:h,dev:h,staging:h},j="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";class E extends Error{}let l,L=Promise.resolve();function C(e){if((e==null?void 0:e.loaderUrl)!==void 0){if(!e.loaderUrl.trim())throw new Error("[@topol.io/editor] loaderUrl must not be empty.");return e.loaderUrl}const t=(e==null?void 0:e.stage)??"production",n=typeof t=="number"||/^\d+$/.test(t)?j.replace("{stage}",String(t)):w[t];if(!n)throw new Error(`[@topol.io/editor] Unsupported stage "${t}". Use a supported stage or loaderUrl.`);return n}function D(e,t){const o=L.then(async()=>{try{return await b(e)}catch(n){if(n instanceof E||t===void 0)throw n;const i=await b(t);return l==null||l.urls.add(new URL(e,document.baseURI).href),i}});return L=o.catch(()=>{}),o}async function b(e){const t=new URL(e,document.baseURI).href;if(l){if(l.urls.has(t))return l.factory;throw new E("[@topol.io/editor] Editor v4 supports one loader URL per page. Reload the page to switch environments.")}const o=t===new URL(w.production,document.baseURI).href&&typeof window.TopolEmailEditor=="function";if(!o&&(typeof window.TopolEmailEditor=="function"||Array.from(document.scripts).some(i=>i.src===t)))throw new E("[@topol.io/editor] Cannot initialize from a host-provided loader with unknown lifecycle. Remove the script, reload the page, and let EmailEditor.init load the requested URL.");if(await U(e,()=>o),typeof window.TopolEmailEditor!="function"){for(const i of Array.from(document.scripts))i.src===t&&i.remove();throw new Error("[@topol.io/editor] The loader did not define window.TopolEmailEditor. Use an editor v4 loader.")}const n=window.TopolEmailEditor;return l={urls:new Set([t]),factory:n},n}const O={async init(e,t){var P,I;if(typeof window>"u"||typeof document>"u")throw new Error("[@topol.io/editor] EmailEditor.init requires a browser. Call it after mounting.");if(!((P=e==null?void 0:e.config)!=null&&P.authorize))throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See docs/MIGRATION-editor-v4.md.");const o=e.config.authorize.entityId;if(typeof o=="string"?!/^[A-Za-z0-9_-]+$/.test(o):typeof o!="number"||!Number.isInteger(o)||o<0)throw new Error("[@topol.io/editor] authorize.entityId must be a URL-safe string or a non-negative integer.");if((I=e.config.cloud)!=null&&I.enabled&&typeof e.getNonce!="function")throw new Error("[@topol.io/editor] cloud.enabled requires nonce authentication: pass a top-level getNonce callback returning Promise<string>.");const n=C(t),i=(t==null?void 0:t.loaderUrl)===void 0&&n!==w.production?w.production:void 0,r=await D(n,i),{onClose:d,onError:a,...c}=e,f=r(c);let x;return Object.assign(f,{destroy:()=>x??(x=Promise.resolve().then(()=>f.close()))})}},T="https://v1.page-assets.topol.io/loader/build.js";function y(){return typeof window<"u"&&typeof window.LandingPageEditor=="function"}let g;function p(e){return typeof document<"u"?new URL(e,document.baseURI).href:e}function z(e){if(e!==void 0&&!e.trim())throw new Error("[@topol.io/editor] loaderUrl must not be empty.");const t=e??T;if(!y())return g=void 0,t;if((g??p(T))!==p(t))throw new Error("[@topol.io/editor] The Landing Page Editor supports one loader URL per page. Reload the page to switch environments.");return t}const M={init:async(e,t)=>{var a;const o=z(t==null?void 0:t.loaderUrl);if(await U(o,y),!y())throw new Error("[@topol.io/editor] The Landing Page Editor loader loaded but window.LandingPageEditor is not defined.");g=p(o);const{onClose:n,...i}=e,r=window.LandingPageEditor(i),d=((a=r.destroy)==null?void 0:a.bind(r))??(()=>r.close());return r.destroy=()=>d(),r}};s.EmailEditor=O,s.LandingPageEditor=M,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,4 @@
1
- import type ITopolOptions from "../../types/ITopolOptions";
1
+ import type IEmailOptions from "../../types/IEmailOptions";
2
2
  import type IEmailEditorInstance from "../../types/IEmailEditorInstance";
3
3
  import type { Stage } from "../../types/Stage";
4
4
  export interface IEmailEditorPluginOptions {
@@ -9,7 +9,7 @@ export interface IEmailEditorPluginOptions {
9
9
  type IRawEmailEditorInstance = Omit<IEmailEditorInstance, "destroy"> & {
10
10
  close(): Promise<void>;
11
11
  };
12
- type IEmailEditorFactory = (options: ITopolOptions) => IRawEmailEditorInstance;
12
+ type IEmailEditorFactory = (options: IEmailOptions) => IRawEmailEditorInstance;
13
13
  declare global {
14
14
  interface Window {
15
15
  TopolEmailEditor: IEmailEditorFactory;
@@ -17,6 +17,6 @@ declare global {
17
17
  }
18
18
  /** Editor v4. init creates an instance; render mounts it; onInit reports successful editor authentication. */
19
19
  export declare const EmailEditor: {
20
- init(options: ITopolOptions, pluginOptions?: IEmailEditorPluginOptions): Promise<IEmailEditorInstance>;
20
+ init(options: IEmailOptions, pluginOptions?: IEmailEditorPluginOptions): Promise<IEmailEditorInstance>;
21
21
  };
22
22
  export {};
@@ -1 +1 @@
1
- export declare const LANDING_PAGE_EDITOR_URL = "https://v1.page-assets.topol.io/topol-lpe.js";
1
+ export declare const LANDING_PAGE_EDITOR_URL = "https://v1.page-assets.topol.io/loader/build.js";
@@ -2,7 +2,7 @@ import type ILandingPageOptions from "../../types/landing-page/ILandingPageOptio
2
2
  import type ILandingPageEditorInstance from "../../types/landing-page/ILandingPageEditorInstance";
3
3
  import { Stage } from "../../types/Stage";
4
4
  /**
5
- * Raw zoid component instance created by the CDN runtime (topol-lpe.js).
5
+ * Raw zoid component instance created by the CDN loader (loader/build.js).
6
6
  * It exposes close() rather than destroy(); init() aliases the latter.
7
7
  */
8
8
  type RawLandingPageEditorInstance = Omit<ILandingPageEditorInstance, "destroy"> & {
@@ -15,12 +15,17 @@ declare global {
15
15
  LandingPageEditor: LandingPageEditorFactory;
16
16
  }
17
17
  }
18
- export interface LandingPageEditorPluginOptions {
18
+ export interface ILandingPageEditorPluginOptions {
19
19
  /**
20
20
  * Stage/environment to use. Currently only 'production' is supported for LPE.
21
21
  * This is reserved for future staging/dev URL support.
22
22
  */
23
23
  stage?: Stage;
24
+ /**
25
+ * Explicit loader URL, e.g. a deployed preview or a local build. One loader URL per page:
26
+ * a second `init()` with a different URL rejects until the page is reloaded.
27
+ */
28
+ loaderUrl?: string;
24
29
  }
25
30
  /**
26
31
  * Landing Page Editor - Create landing pages with drag-and-drop editing.
@@ -38,7 +43,7 @@ export interface LandingPageEditorPluginOptions {
38
43
  *
39
44
  * const editor = await LandingPageEditor.init({
40
45
  * config: {
41
- * authorize: { apiKey: 'your-key', userId: 'user-123' },
46
+ * authorize: { apiKey: 'your-key', entityId: 'user-123' },
42
47
  * },
43
48
  * onSave({ json, html }) { console.log('Saved:', json, html); },
44
49
  * onLoaded() { console.log('Template loaded'); }
@@ -59,9 +64,9 @@ export declare const LandingPageEditor: {
59
64
  * Inits Landing Page Editor.
60
65
  *
61
66
  * @param options - Configuration options for the editor
62
- * @param pluginOptions - Plugin options (reserved for future staging/dev URL support)
67
+ * @param pluginOptions - Plugin options: an explicit `loaderUrl`
63
68
  * @returns Promise that resolves with the editor instance
64
69
  */
65
- init: (options: ILandingPageOptions, pluginOptions?: LandingPageEditorPluginOptions) => Promise<ILandingPageEditorInstance>;
70
+ init: (options: ILandingPageOptions, pluginOptions?: ILandingPageEditorPluginOptions) => Promise<ILandingPageEditorInstance>;
66
71
  };
67
72
  export {};
@@ -1,33 +1,27 @@
1
1
  import z from "zod";
2
2
  export declare const ApiSchema: z.ZodObject<{
3
- AUTOSAVE: z.ZodOptional<z.ZodString>;
4
3
  AUTOSAVES: z.ZodOptional<z.ZodString>;
5
- GET_AUTOSAVE: z.ZodOptional<z.ZodString>;
6
4
  CONVERSATIONS: z.ZodOptional<z.ZodString>;
7
5
  COMMENTS: z.ZodOptional<z.ZodString>;
6
+ GENERATE_META: z.ZodOptional<z.ZodString>;
8
7
  IMAGE_UPLOAD: z.ZodOptional<z.ZodString>;
9
8
  IMAGE_EDITOR_UPLOAD: z.ZodOptional<z.ZodString>;
10
9
  FOLDERS: z.ZodOptional<z.ZodString>;
11
- LOAD: z.ZodOptional<z.ZodString>;
12
- PREVIEW: z.ZodOptional<z.ZodString>;
13
- PRODUCTS: z.ZodOptional<z.ZodString>;
14
- SAVE: z.ZodOptional<z.ZodString>;
15
- SYNCED_SECTIONS: z.ZodOptional<z.ZodString>;
16
- SAVED_BLOCKS: z.ZodOptional<z.ZodString>;
17
- TEST_EMAIL: z.ZodOptional<z.ZodString>;
10
+ SAVED_SECTIONS: z.ZodOptional<z.ZodString>;
18
11
  PREMADE_TEMPLATES: z.ZodOptional<z.ZodString>;
19
12
  PREMADE_TEMPLATE_CATEGORIES: z.ZodOptional<z.ZodString>;
20
- PREMADE_TEMPLATES_KEYWORDS: z.ZodOptional<z.ZodString>;
13
+ PREMADE_TEMPLATE_KEYWORDS: z.ZodOptional<z.ZodString>;
21
14
  }, z.core.$strip>;
22
15
  export declare const LockedApiSchema: z.ZodObject<{
23
16
  AUTHORIZE: z.ZodString;
24
17
  GCS_SIGNED_URL: z.ZodString;
25
18
  GENERATE_CHAT: z.ZodString;
26
19
  GENERATE_IMAGE: z.ZodString;
20
+ GENERATE_META: z.ZodString;
27
21
  GENERATE_TEXT: z.ZodString;
28
22
  GIPHY_API_KEY: z.ZodString;
29
23
  GIPHY_SEARCH: z.ZodString;
30
- SAVE_SERVER: z.ZodString;
24
+ PREVIEW_SAVE: z.ZodString;
31
25
  }, z.core.$strip>;
32
26
  export type IAPI = z.infer<typeof ApiSchema>;
33
27
  export type ILockedAPI = z.infer<typeof LockedApiSchema>;