@topol.io/editor 1.0.0-alpha.8 → 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.
- package/dist/topol-plugin.es.js +109 -116
- package/dist/topol-plugin.umd.js +1 -1
- package/dist/types/src/landing-page-editor/index.d.ts +1 -1
- package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +89 -0
- package/dist/types/src/main.d.ts +3 -3
- package/dist/types/types/landing-page/ILandingPageOptions.d.ts +96 -63
- package/package.json +1 -1
package/dist/topol-plugin.es.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function f(o) {
|
|
2
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
3
3
|
}
|
|
4
|
-
var P = function(n,
|
|
5
|
-
var
|
|
6
|
-
typeof
|
|
7
|
-
},
|
|
8
|
-
var
|
|
9
|
-
|
|
4
|
+
var P = function(n, e, i) {
|
|
5
|
+
var l = document.head || document.getElementsByTagName("head")[0], t = document.createElement("script");
|
|
6
|
+
typeof e == "function" && (i = e, e = {}), e = e || {}, i = i || function() {
|
|
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(
|
|
12
|
-
for (var
|
|
13
|
-
|
|
11
|
+
function m(o, n) {
|
|
12
|
+
for (var e in n)
|
|
13
|
+
o.setAttribute(e, n[e]);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
this.onerror = this.onload = null, n(null,
|
|
18
|
-
},
|
|
19
|
-
this.onerror = this.onload = null, n(new Error("Failed to load " + this.src),
|
|
15
|
+
function w(o, n) {
|
|
16
|
+
o.onload = function() {
|
|
17
|
+
this.onerror = this.onload = null, n(null, o);
|
|
18
|
+
}, o.onerror = function() {
|
|
19
|
+
this.onerror = this.onload = null, n(new Error("Failed to load " + this.src), o);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function E(
|
|
23
|
-
|
|
24
|
-
this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, n(null,
|
|
22
|
+
function E(o, n) {
|
|
23
|
+
o.onreadystatechange = function() {
|
|
24
|
+
this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, n(null, o));
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const g = /* @__PURE__ */
|
|
28
|
-
var
|
|
29
|
-
const h = "https://v3.email-assets.topol.io/loader/build.js",
|
|
30
|
-
production:
|
|
31
|
-
dev:
|
|
32
|
-
staging:
|
|
27
|
+
const g = /* @__PURE__ */ f(P);
|
|
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
|
-
function _(
|
|
35
|
-
switch (
|
|
34
|
+
function _(o) {
|
|
35
|
+
switch (o) {
|
|
36
36
|
case "dev":
|
|
37
37
|
return a.dev;
|
|
38
38
|
case "staging":
|
|
@@ -40,26 +40,26 @@ function _(e) {
|
|
|
40
40
|
case "production":
|
|
41
41
|
return a.production;
|
|
42
42
|
default:
|
|
43
|
-
return y.replace("{stage}", String(
|
|
43
|
+
return y.replace("{stage}", String(o));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function S(
|
|
47
|
-
const n = _(
|
|
46
|
+
function S(o = "production") {
|
|
47
|
+
const n = _(o);
|
|
48
48
|
if (!n) {
|
|
49
49
|
if (a.production)
|
|
50
|
-
return console.error(`[@topol.io/editor] No loader URL resolved for stage "${
|
|
51
|
-
throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${
|
|
50
|
+
return console.error(`[@topol.io/editor] No loader URL resolved for stage "${o}"; falling back to the production loader.`), a.production;
|
|
51
|
+
throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${o}". The editor cannot be loaded.`);
|
|
52
52
|
}
|
|
53
53
|
return n;
|
|
54
54
|
}
|
|
55
|
-
async function A(
|
|
56
|
-
return new Promise((n,
|
|
57
|
-
g(a.production, (
|
|
58
|
-
if (
|
|
59
|
-
|
|
55
|
+
async function A(o) {
|
|
56
|
+
return new Promise((n, e) => {
|
|
57
|
+
g(a.production, (i) => {
|
|
58
|
+
if (i !== null) {
|
|
59
|
+
e(i);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
window.TopolPlugin.init(
|
|
62
|
+
window.TopolPlugin.init(o), n(!0);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -70,29 +70,29 @@ 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: (
|
|
74
|
-
const
|
|
75
|
-
g(
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
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
|
-
return await A(
|
|
80
|
-
} catch (
|
|
81
|
-
|
|
79
|
+
return await A(o), e(!0);
|
|
80
|
+
} catch (r) {
|
|
81
|
+
i(r);
|
|
82
82
|
}
|
|
83
|
-
t
|
|
83
|
+
i(t);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
window.TopolPlugin.init(
|
|
86
|
+
window.TopolPlugin.init(o), e(!0);
|
|
87
87
|
});
|
|
88
88
|
}),
|
|
89
89
|
/** Trigger the save callback with current editor content */
|
|
90
|
-
save: (
|
|
91
|
-
window.TopolPlugin.save(
|
|
90
|
+
save: (o) => {
|
|
91
|
+
window.TopolPlugin.save(o);
|
|
92
92
|
},
|
|
93
93
|
/** Load a template JSON into the editor */
|
|
94
|
-
load: (
|
|
95
|
-
window.TopolPlugin.load(
|
|
94
|
+
load: (o) => {
|
|
95
|
+
window.TopolPlugin.load(o);
|
|
96
96
|
},
|
|
97
97
|
/** Toggle the preview mode */
|
|
98
98
|
togglePreview: () => {
|
|
@@ -103,8 +103,8 @@ const R = {
|
|
|
103
103
|
window.TopolPlugin.togglePreviewSize();
|
|
104
104
|
},
|
|
105
105
|
/** Select a file from the custom file manager */
|
|
106
|
-
chooseFile: (
|
|
107
|
-
window.TopolPlugin.chooseFile(
|
|
106
|
+
chooseFile: (o) => {
|
|
107
|
+
window.TopolPlugin.chooseFile(o);
|
|
108
108
|
},
|
|
109
109
|
/** Undo the last action */
|
|
110
110
|
undo: () => {
|
|
@@ -119,20 +119,20 @@ const R = {
|
|
|
119
119
|
window.TopolPlugin.destroy();
|
|
120
120
|
},
|
|
121
121
|
/** Update the list of saved/reusable blocks */
|
|
122
|
-
setSavedBlocks: (
|
|
123
|
-
window.TopolPlugin.setSavedBlocks(
|
|
122
|
+
setSavedBlocks: (o) => {
|
|
123
|
+
window.TopolPlugin.setSavedBlocks(o);
|
|
124
124
|
},
|
|
125
125
|
/** Set custom HTML for the preview */
|
|
126
|
-
setPreviewHTML: (
|
|
127
|
-
window.TopolPlugin.setPreviewHTML(
|
|
126
|
+
setPreviewHTML: (o) => {
|
|
127
|
+
window.TopolPlugin.setPreviewHTML(o);
|
|
128
128
|
},
|
|
129
129
|
/** Display a notification in the editor */
|
|
130
|
-
createNotification: (
|
|
131
|
-
window.TopolPlugin.createNotification(
|
|
130
|
+
createNotification: (o) => {
|
|
131
|
+
window.TopolPlugin.createNotification(o);
|
|
132
132
|
},
|
|
133
133
|
/** Set the list of active collaboration members */
|
|
134
|
-
setActiveMembers: (
|
|
135
|
-
window.TopolPlugin.setActiveMembers(
|
|
134
|
+
setActiveMembers: (o) => {
|
|
135
|
+
window.TopolPlugin.setActiveMembers(o);
|
|
136
136
|
},
|
|
137
137
|
/** Switch to mobile view */
|
|
138
138
|
changeEmailToMobile: () => {
|
|
@@ -147,12 +147,12 @@ const R = {
|
|
|
147
147
|
window.TopolPlugin.toggleBlocksAndStructuresVisibility();
|
|
148
148
|
},
|
|
149
149
|
/** Update the content of a custom block */
|
|
150
|
-
updateCustomBlockContent: (
|
|
151
|
-
window.TopolPlugin.updateCustomBlockContent(
|
|
150
|
+
updateCustomBlockContent: (o) => {
|
|
151
|
+
window.TopolPlugin.updateCustomBlockContent(o);
|
|
152
152
|
},
|
|
153
153
|
/** Refresh comments/conversations */
|
|
154
|
-
refreshComments: (
|
|
155
|
-
window.TopolPlugin.refreshComments(
|
|
154
|
+
refreshComments: (o) => {
|
|
155
|
+
window.TopolPlugin.refreshComments(o);
|
|
156
156
|
},
|
|
157
157
|
/** Refresh synced rows */
|
|
158
158
|
refreshSyncedRows: () => {
|
|
@@ -163,15 +163,15 @@ const R = {
|
|
|
163
163
|
window.TopolPlugin.openPremadeTemplatesSelection();
|
|
164
164
|
},
|
|
165
165
|
/** Update the API authorization header */
|
|
166
|
-
updateApiAuthorizationHeader: (
|
|
167
|
-
window.TopolPlugin.updateApiAuthorizationHeader(
|
|
166
|
+
updateApiAuthorizationHeader: (o) => {
|
|
167
|
+
window.TopolPlugin.updateApiAuthorizationHeader(o);
|
|
168
168
|
},
|
|
169
169
|
/** Set the template name/title */
|
|
170
|
-
setTemplateName: (
|
|
171
|
-
window.TopolPlugin.setTemplateName(
|
|
170
|
+
setTemplateName: (o) => {
|
|
171
|
+
window.TopolPlugin.setTemplateName(o);
|
|
172
172
|
},
|
|
173
|
-
updateOptions: (
|
|
174
|
-
window.TopolPlugin.updateOptions(
|
|
173
|
+
updateOptions: (o) => {
|
|
174
|
+
window.TopolPlugin.updateOptions(o);
|
|
175
175
|
},
|
|
176
176
|
/** Toggle the AI chat feature */
|
|
177
177
|
toggleChatAI: () => {
|
|
@@ -186,20 +186,20 @@ const R = {
|
|
|
186
186
|
window.TopolPlugin.toggleComments();
|
|
187
187
|
},
|
|
188
188
|
/** Create a new language variant */
|
|
189
|
-
createLanguage: (
|
|
190
|
-
window.TopolPlugin.createLanguage(
|
|
189
|
+
createLanguage: (o) => {
|
|
190
|
+
window.TopolPlugin.createLanguage(o);
|
|
191
191
|
},
|
|
192
192
|
/** Set the primary language */
|
|
193
|
-
setPrimaryLanguage: (
|
|
194
|
-
window.TopolPlugin.setPrimaryLanguage(
|
|
193
|
+
setPrimaryLanguage: (o) => {
|
|
194
|
+
window.TopolPlugin.setPrimaryLanguage(o);
|
|
195
195
|
},
|
|
196
196
|
/** Delete a language variant */
|
|
197
|
-
deleteLanguage: (
|
|
198
|
-
window.TopolPlugin.deleteLanguage(
|
|
197
|
+
deleteLanguage: (o) => {
|
|
198
|
+
window.TopolPlugin.deleteLanguage(o);
|
|
199
199
|
},
|
|
200
200
|
/** Select/switch to a language */
|
|
201
|
-
selectLanguage: (
|
|
202
|
-
window.TopolPlugin.selectLanguage(
|
|
201
|
+
selectLanguage: (o) => {
|
|
202
|
+
window.TopolPlugin.selectLanguage(o);
|
|
203
203
|
},
|
|
204
204
|
/** Get the list of mutations */
|
|
205
205
|
getMutations: () => window.TopolPlugin.getMutations(),
|
|
@@ -208,49 +208,49 @@ const R = {
|
|
|
208
208
|
window.TopolPlugin.toggleControlPanel();
|
|
209
209
|
},
|
|
210
210
|
/** Update the editor template with new JSON data */
|
|
211
|
-
updateTemplate: (
|
|
212
|
-
window.TopolPlugin.updateTemplate(
|
|
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",
|
|
219
|
-
function D(
|
|
218
|
+
}, O = "https://v1.page-assets.topol.io/topol-lpe.js", u = /* @__PURE__ */ new Map();
|
|
219
|
+
function D(o, n) {
|
|
220
220
|
if (n())
|
|
221
221
|
return Promise.resolve();
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
return
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
222
|
+
const e = u.get(o);
|
|
223
|
+
if (e)
|
|
224
|
+
return e;
|
|
225
|
+
const i = new Promise((l, t) => {
|
|
226
|
+
const r = typeof document < "u" ? U(o) : null;
|
|
227
|
+
if (r) {
|
|
228
228
|
const d = () => {
|
|
229
|
-
|
|
229
|
+
p(), l();
|
|
230
230
|
}, c = () => {
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
|
|
231
|
+
p(), t(new Error(`Failed to load script: ${o}`));
|
|
232
|
+
}, p = () => {
|
|
233
|
+
r.removeEventListener("load", d), r.removeEventListener("error", c);
|
|
234
234
|
};
|
|
235
|
-
|
|
235
|
+
r.addEventListener("load", d), r.addEventListener("error", c);
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
g(
|
|
239
|
-
d !== null ?
|
|
238
|
+
g(o, (d) => {
|
|
239
|
+
d !== null ? t(d) : l();
|
|
240
240
|
});
|
|
241
241
|
}).finally(() => {
|
|
242
|
-
|
|
242
|
+
u.delete(o);
|
|
243
243
|
});
|
|
244
|
-
return
|
|
244
|
+
return u.set(o, i), i;
|
|
245
245
|
}
|
|
246
|
-
function U(
|
|
246
|
+
function U(o) {
|
|
247
247
|
const n = document.getElementsByTagName("script");
|
|
248
|
-
for (let
|
|
249
|
-
if (n[
|
|
250
|
-
return n[
|
|
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
|
-
function
|
|
253
|
+
function T() {
|
|
254
254
|
return typeof window < "u" && typeof window.LandingPageEditor == "function";
|
|
255
255
|
}
|
|
256
256
|
const C = {
|
|
@@ -261,19 +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 (
|
|
265
|
-
var
|
|
266
|
-
if (await D(O,
|
|
264
|
+
init: async (o, n) => {
|
|
265
|
+
var r;
|
|
266
|
+
if (await D(O, T), !T())
|
|
267
267
|
throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
...e,
|
|
271
|
-
onClose() {
|
|
272
|
-
var l;
|
|
273
|
-
o || (l = e.onClose) == null || l.call(e);
|
|
274
|
-
}
|
|
275
|
-
}), r = ((i = t.destroy) == null ? void 0 : i.bind(t)) ?? (() => t.close());
|
|
276
|
-
return t.destroy = () => (o = !0, r()), t;
|
|
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;
|
|
277
270
|
}
|
|
278
271
|
}, I = R;
|
|
279
272
|
export {
|
package/dist/topol-plugin.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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>;
|
package/dist/types/src/main.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
15
|
-
*
|
|
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?(
|
|
52
|
+
onSave?(payload: ILandingPageSavePayload): void | Promise<void>;
|
|
18
53
|
/**
|
|
19
|
-
* Called when the user clicks "Save and Close".
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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?(
|
|
58
|
+
onSaveAndClose?(payload: ILandingPageSavePayload): void | Promise<void>;
|
|
24
59
|
/**
|
|
25
|
-
* Called
|
|
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
|
-
|
|
62
|
+
onOpenFileManager?(): void;
|
|
40
63
|
/**
|
|
41
|
-
* Called when the
|
|
42
|
-
*
|
|
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
|
-
|
|
67
|
+
onImageDelete?(payload: {
|
|
68
|
+
items: ILandingPageDeletedItem[];
|
|
69
|
+
}): void;
|
|
46
70
|
/**
|
|
47
|
-
* Called
|
|
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
|
-
|
|
75
|
+
onLoaded?(): void;
|
|
50
76
|
/**
|
|
51
|
-
* Called
|
|
52
|
-
* @param block - The saved block section
|
|
77
|
+
* Called once the editor is fully initialized and ready.
|
|
53
78
|
*/
|
|
54
|
-
|
|
79
|
+
onInit?(): void;
|
|
55
80
|
/**
|
|
56
|
-
* Called when
|
|
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
|
-
|
|
83
|
+
onUndoChange?(payload: {
|
|
84
|
+
count: number;
|
|
85
|
+
}): void;
|
|
60
86
|
/**
|
|
61
|
-
* Called when
|
|
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
|
-
|
|
89
|
+
onRedoChange?(payload: {
|
|
90
|
+
count: number;
|
|
91
|
+
}): void;
|
|
65
92
|
/**
|
|
66
|
-
* Called when the
|
|
67
|
-
* @param count - Number of undo steps available
|
|
93
|
+
* Called when the user requests a preview. `html` is the rendered page.
|
|
68
94
|
*/
|
|
69
|
-
|
|
95
|
+
onPreview?(payload: {
|
|
96
|
+
html: string;
|
|
97
|
+
}): void;
|
|
70
98
|
/**
|
|
71
|
-
* Called when the
|
|
72
|
-
* @param count - Number of redo steps available
|
|
99
|
+
* Called when the preview is closed.
|
|
73
100
|
*/
|
|
74
|
-
|
|
101
|
+
onPreviewClose?(): void;
|
|
75
102
|
/**
|
|
76
|
-
* Called when
|
|
77
|
-
* @param html - The preview HTML
|
|
103
|
+
* Called when an alert/notification is triggered.
|
|
78
104
|
*/
|
|
79
|
-
|
|
105
|
+
onAlert?(payload: {
|
|
106
|
+
notification: INotification;
|
|
107
|
+
}): void;
|
|
80
108
|
/**
|
|
81
|
-
* Called when
|
|
82
|
-
*
|
|
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
|
-
|
|
115
|
+
onEditorClose?(): void | Promise<void>;
|
|
85
116
|
/**
|
|
86
|
-
* Called when the
|
|
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?(
|
|
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?(
|
|
125
|
+
onOpenCustomBlockDialog?(payload: {
|
|
126
|
+
block: unknown;
|
|
127
|
+
}): void;
|
|
95
128
|
/**
|
|
96
|
-
* Called when the
|
|
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?(
|
|
131
|
+
onTemplateRename?(payload: {
|
|
132
|
+
name: string;
|
|
133
|
+
}): void;
|
|
100
134
|
/**
|
|
101
|
-
* Called when an error occurs.
|
|
102
|
-
*
|
|
103
|
-
*
|
|
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
|
-
|
|
139
|
+
onEditorError?(payload: ILandingPageErrorPayload): void;
|
|
107
140
|
}
|
|
108
141
|
/**
|
|
109
142
|
* Configuration options for the Landing Page Editor.
|