@topol.io/editor 2.0.0-alpha.1 → 2.0.0-alpha.3

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 CHANGED
@@ -30,6 +30,31 @@ Every `init` creates an independent instance. Host methods return promises, incl
30
30
  `setSavedSections`, `refreshSyncedSections`, `setMergeTags`, `translateLanguage(code,
31
31
  sourceCode?)`, `translateAllLanguages`, and other editor actions.
32
32
 
33
+ ## Nonce authentication
34
+
35
+ Passing a `getNonce` callback switches authentication from the public key alone to
36
+ short-lived `nc_` nonces minted on your backend from the `sk_` secret. Nothing else
37
+ changes: templates, autosaves, images, comments and sections keep using your own
38
+ `api.*` endpoints and callbacks. There is no separate option; the presence of the
39
+ callback enables it. Topol Cloud is built on top of it and requires the callback.
40
+
41
+ ```ts
42
+ const editor = await EmailEditor.init({
43
+ config: { authorize: { apiKey: "pk_your-public-key", userId: "user-123" } },
44
+ async getNonce() {
45
+ // Your backend calls Topol's POST /auth/nonce with the sk_ secret and this userId.
46
+ const response = await fetch("/api/topol/nonce", { method: "POST" });
47
+ if (!response.ok) throw new Error("Could not mint a Topol nonce");
48
+ return (await response.json()).nonce; // A fresh nc_ token.
49
+ },
50
+ });
51
+ ```
52
+
53
+ The editor refreshes the nonce before it expires and retries once on a rejected
54
+ nonce. A first nonce that cannot be obtained, or `cloud.enabled` without `getNonce`,
55
+ reports `onEditorError` with `source: "authorize"`; a later refresh failure reports
56
+ `source: "nonceAuth"` while the editor keeps working on the last valid nonce.
57
+
33
58
  ## Topol Cloud
34
59
 
35
60
  ```ts
@@ -57,9 +82,54 @@ await editor.render("#editor");
57
82
 
58
83
  Enabling Cloud activates templates, autosaves, images, comments, sections,
59
84
  multilanguage, and test-send. Set a feature to `false` to use external behavior.
60
- Omit `cloud.templateId` to start in the Cloud template browser. The editor handles
61
- nonce refresh, persistence, and its Cloud recovery UI; this package supplies the
62
- host bridge. Your application must implement the nonce endpoint above.
85
+ Omit `cloud.templateId` to start in the Cloud template browser. Cloud requires the
86
+ `getNonce` callback from nonce authentication above; `init` rejects without it. The
87
+ editor handles nonce refresh, persistence, and its Cloud recovery UI; this package
88
+ supplies the host bridge.
89
+
90
+ ## Countdown block
91
+
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:
96
+
97
+ ```ts
98
+ const editor = await EmailEditor.init({
99
+ config: {
100
+ authorize: { apiKey: "pk_your-public-key", userId: "user-123" },
101
+ templateId: 123,
102
+ enableCountdown: true,
103
+ countdown: {
104
+ defaultColors: { background: "#ffffff", digits: "#000000", accent: "#2b66b3" },
105
+ styleThumbnailBase: "https://cdn.example.com/countdown-styles",
106
+ mergeTag: "*|CONTACT_ID|*",
107
+ dateMergeTags: [{ label: "From send", value: "*|SEND_DATE+{seconds}|*" }],
108
+ },
109
+ },
110
+ async getNonce() {
111
+ /* ... */
112
+ },
113
+ });
114
+ ```
115
+
116
+ - `defaultColors` — palette of newly created countdowns; any subset of `background`,
117
+ `digits`, `labels`, `accent` as hex colors (`#RGB`, `#RRGGBB`, `#RRGGBBAA`). Unset
118
+ colors keep the editor defaults.
119
+ - `styleThumbnailBase` — base URL of your own style thumbnails; the editor loads
120
+ `{base}/{style}.gif` for each of the ten styles.
121
+ - `mergeTag` — merge tag identifying the recipient of an evergreen countdown, stored
122
+ in the template as part of the countdown image URL (`?key={tag}`). Prefer a stable
123
+ contact ID over the email address. At most 100 characters, no quotes. Unset = the
124
+ recipient's email address in the syntax of `emailServiceProvider`.
125
+ - `dateMergeTags` — merge tags that can supply the end date of a dynamic countdown
126
+ (for automations); without them the editor does not offer the dynamic type.
127
+ `{seconds}` in a `value` is replaced with the countdown length the user sets. The
128
+ value goes into the URL verbatim: at most 200 characters, no quotes, `<`, `>` or `&`.
129
+
130
+ The types are exported as `ICountdownOptions`, `ICountdownDefaultColors` and
131
+ `ICountdownDateMergeTag`. Details and the ESP requirements are in the
132
+ [option reference](https://docs.topol.io/email-editor/reference/topol-options#countdown).
63
133
 
64
134
  ## Loader selection
65
135
 
@@ -1,14 +1,14 @@
1
1
  function P(e) {
2
2
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
3
  }
4
- var I = function(o, t, r) {
4
+ var b = function(o, t, r) {
5
5
  var n = document.head || document.getElementsByTagName("head")[0], i = document.createElement("script");
6
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 ? g : b;
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 && I(i, t.attrs), t.text && (i.text = "" + t.text);
8
+ var a = "onload" in i ? g : T;
9
9
  a(i, r), i.onload || g(i, r), n.appendChild(i);
10
10
  };
11
- function T(e, o) {
11
+ function I(e, o) {
12
12
  for (var t in o)
13
13
  e.setAttribute(t, o[t]);
14
14
  }
@@ -19,12 +19,12 @@ function g(e, o) {
19
19
  this.onerror = this.onload = null, o(new Error("Failed to load " + this.src), e);
20
20
  };
21
21
  }
22
- function b(e, o) {
22
+ function T(e, o) {
23
23
  e.onreadystatechange = function() {
24
24
  this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, o(null, e));
25
25
  };
26
26
  }
27
- const _ = /* @__PURE__ */ P(I), f = /* @__PURE__ */ new Map();
27
+ const _ = /* @__PURE__ */ P(b), f = /* @__PURE__ */ new Map();
28
28
  function U(e, o) {
29
29
  if (o())
30
30
  return Promise.resolve();
@@ -111,25 +111,25 @@ async function v(e) {
111
111
  const r = window.TopolEmailEditor;
112
112
  return s = { urls: /* @__PURE__ */ new Set([o]), factory: r }, r;
113
113
  }
114
- const C = {
114
+ const N = {
115
115
  async init(e, o) {
116
- var m, E;
116
+ var E, m;
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 (!((m = e == null ? void 0 : e.config) != null && m.authorize))
119
+ if (!((E = e == null ? void 0 : e.config) != null && E.authorize))
120
120
  throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See the v2 migration guide.");
121
121
  const t = e.config.authorize.userId;
122
122
  if (typeof t == "string" ? !/^[A-Za-z0-9_-]+$/.test(t) : !Number.isInteger(t) || t < 0)
123
123
  throw new Error("[@topol.io/editor] authorize.userId must be a URL-safe string or a non-negative integer.");
124
- if ((E = e.config.cloud) != null && E.enabled && typeof e.getNonce != "function")
125
- throw new Error("[@topol.io/editor] Cloud mode requires a top-level getNonce callback returning Promise<string>.");
124
+ if ((m = e.config.cloud) != null && m.enabled && typeof e.getNonce != "function")
125
+ throw new Error("[@topol.io/editor] cloud.enabled requires nonce authentication: pass a top-level getNonce callback returning Promise<string>.");
126
126
  const r = S(o), n = (o == null ? void 0 : o.loaderUrl) === void 0 && r !== u.production ? u.production : void 0, i = await O(r, n), { onClose: a, onError: l, ...d } = e, c = i(d);
127
127
  let L;
128
128
  return Object.assign(c, {
129
129
  destroy: () => L ?? (L = Promise.resolve().then(() => c.close()))
130
130
  });
131
131
  }
132
- }, N = "https://v1.page-assets.topol.io/topol-lpe.js";
132
+ }, C = "https://v1.page-assets.topol.io/topol-lpe.js";
133
133
  function R() {
134
134
  return typeof window < "u" && typeof window.LandingPageEditor == "function";
135
135
  }
@@ -143,14 +143,14 @@ const j = {
143
143
  */
144
144
  init: async (e, o) => {
145
145
  var a;
146
- if (await U(N, R), !R())
146
+ if (await U(C, R), !R())
147
147
  throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");
148
148
  const { onClose: t, ...r } = e, n = window.LandingPageEditor(r), i = ((a = n.destroy) == null ? void 0 : a.bind(n)) ?? (() => n.close());
149
149
  return n.destroy = () => i(), n;
150
150
  }
151
- }, D = C;
151
+ }, D = N;
152
152
  export {
153
- C as EmailEditor,
153
+ N as EmailEditor,
154
154
  j as LandingPageEditor,
155
155
  D as TopolPlugin,
156
156
  D as default
@@ -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 _=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(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 I(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(_),m=new Map;function p(e,o){if(o())return Promise.resolve();const t=m.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(()=>{m.delete(e)});return m.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 h="https://v4.email-assets.topol.io/loader/build.js",w={production:h,dev:h,staging:h},O="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";class E extends Error{}let s,v=Promise.resolve();function j(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 C(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 T,b;if(typeof window>"u"||typeof document>"u")throw new Error("[@topol.io/editor] EmailEditor.init requires a browser. Call it after mounting.");if(!((T=e==null?void 0:e.config)!=null&&T.authorize))throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See the v2 migration guide.");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 mode requires a top-level getNonce callback returning Promise<string>.");const n=j(o),r=(o==null?void 0:o.loaderUrl)===void 0&&n!==w.production?w.production:void 0,i=await C(n,r),{onClose:d,onError:c,...l}=e,f=i(l);let z;return Object.assign(f,{destroy:()=>z??(z=Promise.resolve().then(()=>f.close()))})}},N="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(N,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}},P=U;a.EmailEditor=U,a.LandingPageEditor=D,a.TopolPlugin=P,a.default=P,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a.TopolPlugin={}))})(this,function(a){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _=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(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 I(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(_),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 j(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 N(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 T,b;if(typeof window>"u"||typeof document>"u")throw new Error("[@topol.io/editor] EmailEditor.init requires a browser. Call it after mounting.");if(!((T=e==null?void 0:e.config)!=null&&T.authorize))throw new Error("[@topol.io/editor] Editor v4 requires { config: { authorize, ... }, onSave, ... }. See the v2 migration guide.");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=j(o),r=(o==null?void 0:o.loaderUrl)===void 0&&n!==w.production?w.production:void 0,i=await N(n,r),{onClose:d,onError:c,...l}=e,f=i(l);let z;return Object.assign(f,{destroy:()=>z??(z=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}},P=U;a.EmailEditor=U,a.LandingPageEditor=D,a.TopolPlugin=P,a.default=P,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -16,6 +16,7 @@ import type ISavedBlock from "../types/SavedBlock/ISavedBlock";
16
16
  import type IMergeTagGroup from "../types/MergeTag/IMergeTagGroup";
17
17
  import type IMergeTag from "../types/MergeTag/IMergeTag";
18
18
  import type { IContentBlockOptions } from "../types/ContentBlock/IContentBlockOptions";
19
+ import type { ICountdownOptions, ICountdownDefaultColors, ICountdownDateMergeTag } from "../types/Countdown/ICountdownOptions";
19
20
  import type ITheme from "../types/Theme/ITheme";
20
21
  import type IAuthHeaderConfig from "../types/AuthHeaderConfig/IAuthHeaderConfig";
21
22
  import type IFont from "../types/Font/IFont";
@@ -34,12 +35,13 @@ export default TopolPlugin;
34
35
  export { TopolPlugin };
35
36
  export { EmailEditor };
36
37
  export { LandingPageEditor };
37
- export type { ITopolOptions, IEmailCallbacks, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData, Stage as IStage };
38
+ export type { ITopolOptions, IEmailCallbacks, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ICountdownOptions, ICountdownDefaultColors, ICountdownDateMergeTag, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData, Stage as IStage, };
38
39
  export type { ISaveData, IErrorData, ISendTestData };
39
40
  export type { ILandingPageOptions, ILandingPageCallbacks, ILandingPageEditorInstance, TopolSection, ILandingPageSavePayload, ILandingPageDeletedItem, ILandingPageErrorPayload };
40
41
  export type { default as IEmailConfig } from "../types/IEmailConfig";
41
42
  export type { default as IEmailEditorInstance, IUpdateTemplateOptions } from "../types/IEmailEditorInstance";
42
43
  export type { IEmailEditorPluginOptions } from "./email-editor";
44
+ export type { INonceAuthCallbacks } from "../types/Auth/INonceAuthCallbacks";
43
45
  export type { ICloudFeatures, ICloudOptions, ICloudCallbacks, ICloudSavePayload, ICloudTemplateChangePayload } from "../types/Cloud/ICloudOptions";
44
46
  export type { ISavedSection, IPremadeSection, IPremadeSections, ILegacyPremadeSections, IPremadeSectionsOptions } from "../types/Sections/ISections";
45
47
  export type { ILanguageMutation, ILanguageChangePayload, IEmailDeletedItem } from "../types/Callbacks/ICallbackPayloads";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Nonce authentication. Passing `getNonce` switches the editor from the legacy
3
+ * public-key authorize call to short-lived `nc_` nonces minted on your backend.
4
+ * Works on its own (every feature stays external) and is required by Topol Cloud.
5
+ */
6
+ export interface INonceAuthCallbacks {
7
+ /** Fetch a fresh nc_ nonce from your authenticated backend. Never expose an sk_ secret in the browser. */
8
+ getNonce?(): Promise<string>;
9
+ }
@@ -1,9 +1,10 @@
1
1
  import type INotification from "../Notification/INotification";
2
2
  import type { ISavedSection } from "../Sections/ISections";
3
3
  import type { ICloudCallbacks } from "../Cloud/ICloudOptions";
4
+ import type { INonceAuthCallbacks } from "../Auth/INonceAuthCallbacks";
4
5
  import type { ISaveData, ISendTestData, IErrorData, ILanguageChangePayload, ILanguageMutation, IEmailDeletedItem } from "./ICallbackPayloads";
5
6
  /** v4 host callbacks. Return save promises so the editor can await persistence. */
6
- export default interface IEmailCallbacks extends ICloudCallbacks {
7
+ export default interface IEmailCallbacks extends INonceAuthCallbacks, ICloudCallbacks {
7
8
  onSave?(payload: ISaveData): void | Promise<void>;
8
9
  onSaveAndClose?(payload: ISaveData): void | Promise<void>;
9
10
  onTestSend?(payload: ISendTestData): void;
@@ -25,9 +25,8 @@ export interface ICloudTemplateChangePayload {
25
25
  name?: string;
26
26
  folderId?: number | null;
27
27
  }
28
+ /** Cloud-scoped callbacks. Cloud also requires `getNonce` from INonceAuthCallbacks. */
28
29
  export interface ICloudCallbacks {
29
- /** Fetch a fresh nc_ nonce from your authenticated backend. Never expose an sk_ secret in the browser. */
30
- getNonce?(): Promise<string>;
31
30
  onCloudSave?(payload: ICloudSavePayload): void;
32
31
  onCloudTemplateChange?(payload: ICloudTemplateChangePayload): void;
33
32
  }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Palette of newly created countdowns. Any subset of `background`, `digits`, `labels`
3
+ * and `accent` as hex colors (`#RGB`, `#RRGGBB` or `#RRGGBBAA`); unset colors keep the
4
+ * editor defaults (white background, black text, purple accent).
5
+ */
6
+ export interface ICountdownDefaultColors {
7
+ background?: string;
8
+ digits?: string;
9
+ labels?: string;
10
+ accent?: string;
11
+ }
12
+ /**
13
+ * A merge tag of your ESP that can supply the end date of a dynamic countdown.
14
+ * The `value` goes into the countdown image URL verbatim (`?end_date_time={tag}`)
15
+ * and must produce an RFC 3339 date once the ESP substitutes it.
16
+ */
17
+ export interface ICountdownDateMergeTag {
18
+ /** Name shown to the user when picking the tag. */
19
+ label: string;
20
+ /**
21
+ * The tag itself. `{seconds}` in it is replaced with the countdown length the user
22
+ * sets (e.g. `*|SEND_DATE+{seconds}|*`); without it the tag is inserted as is
23
+ * (e.g. `*|RESERVATION_UNTIL|*`). At most 200 characters, no quotes, `<`, `>` or `&`.
24
+ */
25
+ value: string;
26
+ }
27
+ /**
28
+ * Countdown block settings of the host. The block itself is switched on with
29
+ * `enableCountdown`. See https://docs.topol.io/email-editor/reference/topol-options#countdown
30
+ */
31
+ export interface ICountdownOptions {
32
+ /** Palette of newly created countdowns (any subset); unset colors keep the package defaults. */
33
+ defaultColors?: ICountdownDefaultColors;
34
+ /** Base URL of a custom style thumbnail set: the editor loads `{base}/{style}.gif` for every countdown style. */
35
+ styleThumbnailBase?: string;
36
+ /**
37
+ * Merge tag the evergreen countdowns' recipient key is rendered with (verbatim, no quotes).
38
+ * Use a value that is stable and unique per recipient, ideally a contact ID
39
+ * (e.g. `*|CONTACT_ID|*`). Unset = the recipient's email address in the syntax of
40
+ * `emailServiceProvider`. At most 100 characters.
41
+ */
42
+ mergeTag?: string;
43
+ /**
44
+ * Merge tags a dynamic countdown's deadline (`end_date_time`) can come from;
45
+ * `{seconds}` in a value = the countdown length the user sets. Unset = no dynamic mode.
46
+ */
47
+ dateMergeTags?: ICountdownDateMergeTag[];
48
+ }
@@ -4,6 +4,7 @@ import type { ISavedSection, IPremadeSectionsOptions } from "./Sections/ISection
4
4
  import type { ICloudOptions } from "./Cloud/ICloudOptions";
5
5
  import type IMergeTagGroup from "./MergeTag/IMergeTagGroup";
6
6
  import type { IContentBlockOptions } from "./ContentBlock/IContentBlockOptions";
7
+ import type { ICountdownOptions } from "./Countdown/ICountdownOptions";
7
8
  import type ITheme from "./Theme/ITheme";
8
9
  import type IAuthHeaderConfig from "./AuthHeaderConfig/IAuthHeaderConfig";
9
10
  import type IFont from "./Font/IFont";
@@ -42,6 +43,8 @@ export default interface IEmailConfig {
42
43
  cloud?: ICloudOptions;
43
44
  colors?: Array<string>;
44
45
  contentBlocks?: IContentBlockOptions;
46
+ /** Countdown block settings of the host (the block itself is gated by `enableCountdown`). */
47
+ countdown?: ICountdownOptions;
45
48
  currentUser?: IUser;
46
49
  customBlocks?: ICustomBlockData[];
47
50
  customFileManager?: boolean;
@@ -92,6 +95,12 @@ export default interface IEmailConfig {
92
95
  emailServiceProvider?: "mailchimp" | "sparkpost";
93
96
  enableAutosaves?: boolean;
94
97
  enableComments?: boolean;
98
+ /**
99
+ * Opt-in for the Countdown block, a paid add-on rolled out per user: the block only appears
100
+ * when the add-on flag your backend put into the editor nonce is set **and** this option is
101
+ * `true`, and it also needs `templateId`.
102
+ */
103
+ enableCountdown?: boolean;
95
104
  enableDarkMode?: boolean;
96
105
  enableFileManagerInGif?: boolean;
97
106
  enableSubjectLine?: boolean;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "author": "Topol.io",
13
13
  "homepage": "https://topol.io",
14
14
  "license": "Apache-2.0",
15
- "version": "2.0.0-alpha.1",
15
+ "version": "2.0.0-alpha.3",
16
16
  "files": [
17
17
  "dist"
18
18
  ],