@topol.io/editor 1.0.0-alpha.10 → 1.0.0-alpha.11
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/README.md +17 -14
- package/dist/topol-plugin.es.js +109 -95
- package/dist/topol-plugin.umd.cjs +1 -1
- package/dist/types/src/email-editor/index.d.ts +3 -3
- package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
- package/dist/types/src/landing-page-editor/index.d.ts +10 -5
- package/dist/types/src/landing-page-editor/schemas/api/apiSchema.d.ts +5 -10
- package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +33 -17
- package/dist/types/src/landing-page-editor/schemas/language/languageSchema.d.ts +1 -1
- package/dist/types/src/landing-page-editor/schemas/mjmlStore/mjmlStoreSchema.d.ts +8 -6
- package/dist/types/src/landing-page-editor/schemas/notification/notificationSchema.d.ts +0 -1
- package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +66 -19
- package/dist/types/src/landing-page-editor/schemas/premadeSection/premadeSectionSchema.d.ts +30 -0
- package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +685 -3
- package/dist/types/src/landing-page-editor/schemas/template/blocks/carouselBlockSchema.d.ts +9 -2
- package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +9 -1
- package/dist/types/src/landing-page-editor/schemas/template/blocks/formBlockSchema.d.ts +1069 -0
- package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +29 -13
- package/dist/types/src/landing-page-editor/schemas/template/blocks/rawBlockSchema.d.ts +9 -1
- package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +9 -1
- package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +16 -8
- package/dist/types/src/landing-page-editor/schemas/template/blocks/textBlockSchema.d.ts +9 -1
- package/dist/types/src/landing-page-editor/schemas/template/blocks/videoBlockSchema.d.ts +9 -1
- package/dist/types/src/landing-page-editor/schemas/template/commonSchema.d.ts +28 -8
- package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarCTASchema.d.ts +335 -0
- package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarHamburgerSchema.d.ts +1109 -0
- package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarLogoSchema.d.ts +252 -0
- package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarMenuSchema.d.ts +1209 -0
- package/dist/types/src/landing-page-editor/schemas/template/settingsSchema.d.ts +4058 -546
- package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +4675 -1996
- package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5445 -2356
- package/dist/types/src/landing-page-editor/schemas/template/structure/navbarSchema.d.ts +4394 -0
- package/dist/types/src/landing-page-editor/schemas/template/structure/rowSchema.d.ts +11094 -0
- package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +8365 -3100
- package/dist/types/src/landing-page-editor/schemas/template/styleSchema.d.ts +55 -44
- package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +34901 -48500
- package/dist/types/src/landing-page-editor/schemas/templateSettings/templateSettingsSchema.d.ts +4305 -794
- package/dist/types/src/landing-page-editor/schemas/theme/themeSchema.d.ts +6 -1
- package/dist/types/src/landing-page-editor/schemas/utils/cssValue.d.ts +21 -0
- package/dist/types/src/landing-page-editor/schemas/utils/transformBorder.d.ts +10 -5
- package/dist/types/src/main.d.ts +23 -42
- package/dist/types/types/API/API.d.ts +2 -2
- package/dist/types/types/APIBlocks/APIBlocks.d.ts +11 -0
- package/dist/types/types/Auth/IAuthorize.d.ts +18 -0
- package/dist/types/types/Auth/INonceAuthCallbacks.d.ts +2 -1
- package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +11 -4
- package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +30 -10
- package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
- package/dist/types/types/Countdown/ICountdownOptions.d.ts +2 -2
- package/dist/types/types/IEmailConfig.d.ts +44 -18
- package/dist/types/types/IEmailEditorInstance.d.ts +16 -2
- package/dist/types/types/{ITopolOptions.d.ts → IEmailOptions.d.ts} +1 -1
- package/dist/types/types/MergeTag/IMergeTag.d.ts +18 -0
- package/dist/types/types/Notification/INotification.d.ts +2 -1
- package/dist/types/types/Sections/ISections.d.ts +12 -1
- package/dist/types/types/Shortcuts/EditorShortcut.d.ts +4 -0
- package/dist/types/types/Theme/ITheme.d.ts +12 -2
- package/dist/types/types/landing-page/ILandingPageEditorInstance.d.ts +65 -5
- package/dist/types/types/landing-page/ILandingPageOptions.d.ts +20 -10
- package/package.json +1 -1
- package/dist/types/src/landing-page-editor/schemas/helpdesk/helpdeskSchema.d.ts +0 -8
- package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +0 -59750
- package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +0 -44831
- package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +0 -59725
- package/dist/types/src/landing-page-editor/schemas/template/blocks/index.d.ts +0 -12
- package/dist/types/types/ITopolPlugin.d.ts +0 -2
- 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",
|
|
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",
|
|
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
|
|
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",
|
|
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
|
|
94
|
-
|
|
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",
|
|
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
|
-
|
|
169
|
-
`
|
|
170
|
-
|
|
164
|
+
- `authorize.userId` → `authorize.entityId`, which must be a non-negative integer or match `[A-Za-z0-9_-]+`. `userId` still works as a deprecated alias.
|
|
165
|
+
- `hideControlPanel` / `showControlPanelExpand` / `toggleControlPanel()` → `hideSelectionPanel` / `hideSelectionPanelExpand` (inverted) / `toggleSelectionPanel()`. The old names still work as deprecated aliases.
|
|
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.
|
package/dist/topol-plugin.es.js
CHANGED
|
@@ -1,157 +1,171 @@
|
|
|
1
|
-
function
|
|
1
|
+
function T(e) {
|
|
2
2
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
3
3
|
}
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
typeof
|
|
7
|
-
},
|
|
8
|
-
var
|
|
9
|
-
|
|
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
|
|
12
|
-
for (var
|
|
13
|
-
e.setAttribute(
|
|
11
|
+
function A(e, t) {
|
|
12
|
+
for (var o in t)
|
|
13
|
+
e.setAttribute(o, t[o]);
|
|
14
14
|
}
|
|
15
|
-
function p(e,
|
|
15
|
+
function p(e, t) {
|
|
16
16
|
e.onload = function() {
|
|
17
|
-
this.onerror = this.onload = null,
|
|
17
|
+
this.onerror = this.onload = null, t(null, e);
|
|
18
18
|
}, e.onerror = function() {
|
|
19
|
-
this.onerror = this.onload = null,
|
|
19
|
+
this.onerror = this.onload = null, t(new Error("Failed to load " + this.src), e);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function S(e, t) {
|
|
23
23
|
e.onreadystatechange = function() {
|
|
24
|
-
this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null,
|
|
24
|
+
this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, t(null, e));
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
function
|
|
29
|
-
if (
|
|
27
|
+
const N = /* @__PURE__ */ T(_), f = /* @__PURE__ */ new Map();
|
|
28
|
+
function I(e, t) {
|
|
29
|
+
if (t())
|
|
30
30
|
return Promise.resolve();
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
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
|
-
|
|
44
|
+
d.addEventListener("load", a), d.addEventListener("error", s);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
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,
|
|
54
|
+
return f.set(e, n), n;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
for (let
|
|
59
|
-
if (o
|
|
60
|
-
return o
|
|
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
|
-
},
|
|
67
|
+
}, C = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
|
|
68
68
|
class h extends Error {
|
|
69
69
|
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
70
|
+
let c, R = Promise.resolve();
|
|
71
|
+
function z(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
|
|
78
|
-
if (!
|
|
79
|
-
throw new Error(`[@topol.io/editor] Unsupported stage "${
|
|
80
|
-
return
|
|
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
|
|
83
|
-
const
|
|
82
|
+
function D(e, t) {
|
|
83
|
+
const o = R.then(async () => {
|
|
84
84
|
try {
|
|
85
|
-
return await
|
|
86
|
-
} catch (
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
89
|
-
const
|
|
90
|
-
return
|
|
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
|
|
94
|
-
}),
|
|
93
|
+
return R = o.catch(() => {
|
|
94
|
+
}), o;
|
|
95
95
|
}
|
|
96
|
-
async function
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
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
|
|
104
|
-
if (!
|
|
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
|
|
107
|
-
for (const
|
|
108
|
-
|
|
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
|
|
112
|
-
return
|
|
111
|
+
const n = window.TopolEmailEditor;
|
|
112
|
+
return c = { urls: /* @__PURE__ */ new Set([t]), factory: n }, n;
|
|
113
113
|
}
|
|
114
|
-
const
|
|
115
|
-
async init(e,
|
|
116
|
-
var
|
|
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 (!((
|
|
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
|
|
122
|
-
if (typeof
|
|
123
|
-
throw new Error("[@topol.io/editor] authorize.
|
|
124
|
-
if ((
|
|
121
|
+
const o = e.config.authorize.entityId ?? e.config.authorize.userId;
|
|
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
|
|
127
|
-
let
|
|
128
|
-
return Object.assign(
|
|
129
|
-
destroy: () =>
|
|
126
|
+
const n = z(t), i = (t == null ? void 0 : t.loaderUrl) === void 0 && n !== u.production ? u.production : void 0, r = await D(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
|
-
},
|
|
133
|
-
function
|
|
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
|
-
|
|
136
|
+
let E;
|
|
137
|
+
function y(e) {
|
|
138
|
+
return typeof document < "u" ? new URL(e, document.baseURI).href : e;
|
|
139
|
+
}
|
|
140
|
+
function j(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
|
|
155
|
+
* @param pluginOptions - Plugin options: an explicit `loaderUrl`
|
|
142
156
|
* @returns Promise that resolves with the editor instance
|
|
143
157
|
*/
|
|
144
|
-
init: async (e,
|
|
158
|
+
init: async (e, t) => {
|
|
145
159
|
var a;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
160
|
+
const o = j(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
|
-
}
|
|
167
|
+
};
|
|
152
168
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
D as TopolPlugin,
|
|
156
|
-
D as default
|
|
169
|
+
O as EmailEditor,
|
|
170
|
+
x as LandingPageEditor
|
|
157
171
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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(_),h=new Map;function U(e,t){if(t())return Promise.resolve();const o=h.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(()=>{h.delete(e)});return h.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 m="https://v4.email-assets.topol.io/loader/build.js",w={production:m,dev:m,staging:m},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 z(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 D={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??e.config.authorize.userId;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 z(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 g(){return typeof window<"u"&&typeof window.LandingPageEditor=="function"}let y;function p(e){return typeof document<"u"?new URL(e,document.baseURI).href:e}function O(e){if(e!==void 0&&!e.trim())throw new Error("[@topol.io/editor] loaderUrl must not be empty.");const t=e??T;if(!g())return y=void 0,t;if((y??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=O(t==null?void 0:t.loaderUrl);if(await U(o,g),!g())throw new Error("[@topol.io/editor] The Landing Page Editor loader loaded but window.LandingPageEditor is not defined.");y=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=D,s.LandingPageEditor=M,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
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:
|
|
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:
|
|
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/
|
|
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
|
|
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
|
|
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',
|
|
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
|
|
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?:
|
|
70
|
+
init: (options: ILandingPageOptions, pluginOptions?: ILandingPageEditorPluginOptions) => Promise<ILandingPageEditorInstance>;
|
|
66
71
|
};
|
|
67
72
|
export {};
|
|
@@ -1,22 +1,16 @@
|
|
|
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
|
-
|
|
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>;
|
|
13
|
+
PREMADE_TEMPLATE_KEYWORDS: z.ZodOptional<z.ZodString>;
|
|
20
14
|
PREMADE_TEMPLATES_KEYWORDS: z.ZodOptional<z.ZodString>;
|
|
21
15
|
}, z.core.$strip>;
|
|
22
16
|
export declare const LockedApiSchema: z.ZodObject<{
|
|
@@ -24,10 +18,11 @@ export declare const LockedApiSchema: z.ZodObject<{
|
|
|
24
18
|
GCS_SIGNED_URL: z.ZodString;
|
|
25
19
|
GENERATE_CHAT: z.ZodString;
|
|
26
20
|
GENERATE_IMAGE: z.ZodString;
|
|
21
|
+
GENERATE_META: z.ZodString;
|
|
27
22
|
GENERATE_TEXT: z.ZodString;
|
|
28
23
|
GIPHY_API_KEY: z.ZodString;
|
|
29
24
|
GIPHY_SEARCH: z.ZodString;
|
|
30
|
-
|
|
25
|
+
PREVIEW_SAVE: z.ZodString;
|
|
31
26
|
}, z.core.$strip>;
|
|
32
27
|
export type IAPI = z.infer<typeof ApiSchema>;
|
|
33
28
|
export type ILockedAPI = z.infer<typeof LockedApiSchema>;
|