@topol.io/editor 1.0.0-alpha.1 → 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 +153 -101
- package/dist/topol-plugin.es.js +146 -191
- package/dist/topol-plugin.umd.cjs +1 -0
- package/dist/types/src/core/script-loader.d.ts +15 -0
- package/dist/types/src/email-editor/constants.d.ts +3 -3
- package/dist/types/src/email-editor/index.d.ts +16 -91
- package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
- package/dist/types/src/landing-page-editor/index.d.ts +27 -10
- 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 +34 -18
- 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/openAI/openAISchema.d.ts +1 -2
- package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +153 -17
- 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 +687 -5
- 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 +11 -3
- 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 +35 -19
- 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 +11 -3
- package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +18 -10
- 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 +5007 -2328
- package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5501 -2412
- 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 +8602 -3337
- 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 +34865 -48464
- 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 +28 -101
- package/dist/types/types/API/API.d.ts +10 -9
- 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 +10 -0
- package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +28 -18
- package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +85 -104
- package/dist/types/types/Cloud/ICloudOptions.d.ts +32 -0
- package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
- package/dist/types/types/Countdown/ICountdownOptions.d.ts +48 -0
- package/dist/types/types/IEmailConfig.d.ts +225 -0
- package/dist/types/types/IEmailEditorInstance.d.ts +68 -0
- package/dist/types/types/IEmailOptions.d.ts +7 -0
- package/dist/types/types/Language/Language.d.ts +6 -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 +41 -0
- 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 +73 -9
- package/dist/types/types/landing-page/ILandingPageOptions.d.ts +110 -62
- package/package.json +10 -13
- package/dist/topol-plugin.umd.js +0 -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/ITopolOptions.d.ts +0 -123
- package/dist/types/types/ITopolPlugin.d.ts +0 -37
- package/dist/types/types/SavedBlock/ISavedBlock.d.ts +0 -6
|
@@ -0,0 +1 @@
|
|
|
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"})});
|
|
@@ -5,3 +5,18 @@
|
|
|
5
5
|
* @returns Promise that resolves when script is loaded
|
|
6
6
|
*/
|
|
7
7
|
export declare function loadScriptWithFallback(url: string, fallbackUrl?: string): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Loads a script at most once per page.
|
|
10
|
+
*
|
|
11
|
+
* - If `isReady()` already reports the global the script defines, resolves immediately
|
|
12
|
+
* without touching the DOM (the script was loaded by a previous init() call or by the host page).
|
|
13
|
+
* - If a load for the same URL is already in flight, returns the same promise so concurrent
|
|
14
|
+
* init() calls (e.g. React StrictMode double-invoking effects) share one `<script>` tag.
|
|
15
|
+
* - If the host page already has a `<script src="url">` tag that hasn't finished loading,
|
|
16
|
+
* waits for it instead of injecting a duplicate.
|
|
17
|
+
* - A failed load is not cached, so the next call retries.
|
|
18
|
+
*
|
|
19
|
+
* @param url - Script URL
|
|
20
|
+
* @param isReady - Returns true once the global the script defines is available
|
|
21
|
+
*/
|
|
22
|
+
export declare function loadScriptOnce(url: string, isReady: () => boolean): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const EMAIL_EDITOR_URLS: {
|
|
2
|
-
readonly production:
|
|
3
|
-
readonly dev:
|
|
4
|
-
readonly staging:
|
|
2
|
+
readonly production: any;
|
|
3
|
+
readonly dev: any;
|
|
4
|
+
readonly staging: any;
|
|
5
5
|
};
|
|
6
6
|
export declare const EMAIL_EDITOR_PREVIEW_URL_PATTERN = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
|
|
7
7
|
export declare const EMAIL_EDITOR_HTML_ID = "topol-editor";
|
|
@@ -1,97 +1,22 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type IEmailOptions from "../../types/IEmailOptions";
|
|
2
|
+
import type IEmailEditorInstance from "../../types/IEmailEditorInstance";
|
|
3
|
+
import type { Stage } from "../../types/Stage";
|
|
4
|
+
export interface IEmailEditorPluginOptions {
|
|
5
|
+
stage?: Stage;
|
|
6
|
+
/** Explicit v4 loader URL, e.g. a deployed preview or local build. One URL per page; never falls back on failure. */
|
|
7
|
+
loaderUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
type IRawEmailEditorInstance = Omit<IEmailEditorInstance, "destroy"> & {
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
type IEmailEditorFactory = (options: IEmailOptions) => IRawEmailEditorInstance;
|
|
6
13
|
declare global {
|
|
7
14
|
interface Window {
|
|
8
|
-
|
|
15
|
+
TopolEmailEditor: IEmailEditorFactory;
|
|
9
16
|
}
|
|
10
17
|
}
|
|
11
|
-
|
|
12
|
-
stage?: Stage;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Email Editor - Create rich email templates with drag-and-drop editing.
|
|
16
|
-
*
|
|
17
|
-
* This is the main Email Editor integration that loads the Topol Email Editor
|
|
18
|
-
* into your application.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { EmailEditor } from '@topol.io/editor';
|
|
23
|
-
*
|
|
24
|
-
* await EmailEditor.init({
|
|
25
|
-
* id: '#editor',
|
|
26
|
-
* authorize: { apiKey: 'your-key', userId: 'user-123' },
|
|
27
|
-
* callbacks: {
|
|
28
|
-
* onSave(json, html) { console.log('Saved:', json); }
|
|
29
|
-
* }
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
18
|
+
/** Editor v4. init creates an instance; render mounts it; onInit reports successful editor authentication. */
|
|
33
19
|
export declare const EmailEditor: {
|
|
34
|
-
|
|
35
|
-
* Initialize the Email Editor.
|
|
36
|
-
* @param topolOptions - Configuration options for the editor
|
|
37
|
-
* @param options - Plugin options including stage selection
|
|
38
|
-
* @returns Promise that resolves to true when the editor is ready
|
|
39
|
-
*/
|
|
40
|
-
init: (topolOptions: ITopolOptions, options?: EmailEditorPluginOptions) => Promise<boolean | string>;
|
|
41
|
-
/** Trigger the save callback with current editor content */
|
|
42
|
-
save: () => void;
|
|
43
|
-
/** Load a template JSON into the editor */
|
|
44
|
-
load: (json: unknown) => void;
|
|
45
|
-
/** Toggle the preview mode */
|
|
46
|
-
togglePreview: () => void;
|
|
47
|
-
/** Toggle between desktop and mobile preview sizes */
|
|
48
|
-
togglePreviewSize: () => void;
|
|
49
|
-
/** Select a file from the custom file manager */
|
|
50
|
-
chooseFile: (url: string) => void;
|
|
51
|
-
/** Undo the last action */
|
|
52
|
-
undo: () => void;
|
|
53
|
-
/** Redo the last undone action */
|
|
54
|
-
redo: () => void;
|
|
55
|
-
/** Destroy the editor instance and clean up resources */
|
|
56
|
-
destroy: () => void;
|
|
57
|
-
/** Update the list of saved/reusable blocks */
|
|
58
|
-
setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
|
|
59
|
-
/** Set custom HTML for the preview */
|
|
60
|
-
setPreviewHTML: (html: unknown) => void;
|
|
61
|
-
/** Display a notification in the editor */
|
|
62
|
-
createNotification: (notification: INotification) => void;
|
|
63
|
-
/** Set the list of active collaboration members */
|
|
64
|
-
setActiveMembers: (activeMembers: string[]) => void;
|
|
65
|
-
/** Switch to mobile view */
|
|
66
|
-
changeEmailToMobile: () => void;
|
|
67
|
-
/** Switch to desktop view */
|
|
68
|
-
changeEmailToDesktop: () => void;
|
|
69
|
-
/** Toggle visibility of hidden blocks and structures */
|
|
70
|
-
toggleBlocksAndStructuresVisibility: () => void;
|
|
71
|
-
/** Update the content of a custom block */
|
|
72
|
-
updateCustomBlockContent: (content: string) => void;
|
|
73
|
-
/** Refresh comments/conversations */
|
|
74
|
-
refreshComments: (key: string) => void;
|
|
75
|
-
/** Refresh synced rows */
|
|
76
|
-
refreshSyncedRows: () => void;
|
|
77
|
-
/** Open the premade templates selection modal */
|
|
78
|
-
openPremadeTemplatesSelection: () => void;
|
|
79
|
-
/** Update the API authorization header */
|
|
80
|
-
updateApiAuthorizationHeader: (newHeader: string | Record<string, string>) => void;
|
|
81
|
-
/** Set the template name/title */
|
|
82
|
-
setTemplateName: (name: string) => void;
|
|
83
|
-
/** Toggle the AI chat feature */
|
|
84
|
-
toggleChatAI: () => void;
|
|
85
|
-
/** Toggle the autosaves feature */
|
|
86
|
-
toggleAutosaves: () => void;
|
|
87
|
-
/** Toggle the comments panel */
|
|
88
|
-
toggleComments: () => void;
|
|
89
|
-
/** Create a new language variant */
|
|
90
|
-
createLanguage: (lang: string) => void;
|
|
91
|
-
/** Set the primary language */
|
|
92
|
-
setPrimaryLanguage: (lang: string) => void;
|
|
93
|
-
/** Delete a language variant */
|
|
94
|
-
deleteLanguage: (lang: string) => void;
|
|
95
|
-
/** Select/switch to a language */
|
|
96
|
-
selectLanguage: (lang: string) => void;
|
|
20
|
+
init(options: IEmailOptions, pluginOptions?: IEmailEditorPluginOptions): Promise<IEmailEditorInstance>;
|
|
97
21
|
};
|
|
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";
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import type ILandingPageOptions from "../../types/landing-page/ILandingPageOptions";
|
|
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 loader (loader/build.js).
|
|
6
|
+
* It exposes close() rather than destroy(); init() aliases the latter.
|
|
7
|
+
*/
|
|
8
|
+
type RawLandingPageEditorInstance = Omit<ILandingPageEditorInstance, "destroy"> & {
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
destroy?(): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
type LandingPageEditorFactory = (options: ILandingPageOptions) => RawLandingPageEditorInstance;
|
|
5
13
|
declare global {
|
|
6
14
|
interface Window {
|
|
7
15
|
LandingPageEditor: LandingPageEditorFactory;
|
|
8
16
|
}
|
|
9
17
|
}
|
|
10
|
-
export interface
|
|
18
|
+
export interface ILandingPageEditorPluginOptions {
|
|
11
19
|
/**
|
|
12
20
|
* Stage/environment to use. Currently only 'production' is supported for LPE.
|
|
13
21
|
* This is reserved for future staging/dev URL support.
|
|
14
22
|
*/
|
|
15
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;
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
31
|
* Landing Page Editor - Create landing pages with drag-and-drop editing.
|
|
@@ -20,26 +33,30 @@ export interface LandingPageEditorPluginOptions {
|
|
|
20
33
|
* This integration loads the Topol Landing Page Editor into your application.
|
|
21
34
|
* Unlike the Email Editor, this creates an instance that you can interact with.
|
|
22
35
|
*
|
|
36
|
+
* The runtime script is injected at most once per page; subsequent init() calls
|
|
37
|
+
* reuse the already-loaded runtime, so opening the editor repeatedly (or React StrictMode
|
|
38
|
+
* double-mounting) does not inject duplicate script tags.
|
|
39
|
+
*
|
|
23
40
|
* @example
|
|
24
41
|
* ```typescript
|
|
25
42
|
* import { LandingPageEditor } from '@topol.io/editor';
|
|
26
43
|
*
|
|
27
44
|
* const editor = await LandingPageEditor.init({
|
|
28
45
|
* config: {
|
|
29
|
-
* authorize: { apiKey: 'your-key',
|
|
46
|
+
* authorize: { apiKey: 'your-key', entityId: 'user-123' },
|
|
30
47
|
* },
|
|
31
|
-
* onSave(json, html) { console.log('Saved:', json, html); },
|
|
32
|
-
* onLoaded() { console.log('
|
|
48
|
+
* onSave({ json, html }) { console.log('Saved:', json, html); },
|
|
49
|
+
* onLoaded() { console.log('Template loaded'); }
|
|
33
50
|
* });
|
|
34
51
|
*
|
|
35
|
-
* // Render the editor into a container
|
|
36
|
-
* editor.render('#landing-page-editor');
|
|
52
|
+
* // Render the editor into a container (resolves once the iframe is rendered)
|
|
53
|
+
* await editor.render('#landing-page-editor');
|
|
37
54
|
*
|
|
38
55
|
* // Optionally load a template
|
|
39
56
|
* editor.load(templateJson);
|
|
40
57
|
*
|
|
41
58
|
* // Clean up when done
|
|
42
|
-
* editor.destroy();
|
|
59
|
+
* await editor.destroy();
|
|
43
60
|
* ```
|
|
44
61
|
*/
|
|
45
62
|
export declare const LandingPageEditor: {
|
|
@@ -47,9 +64,9 @@ export declare const LandingPageEditor: {
|
|
|
47
64
|
* Inits Landing Page Editor.
|
|
48
65
|
*
|
|
49
66
|
* @param options - Configuration options for the editor
|
|
50
|
-
* @param pluginOptions - Plugin options
|
|
67
|
+
* @param pluginOptions - Plugin options: an explicit `loaderUrl`
|
|
51
68
|
* @returns Promise that resolves with the editor instance
|
|
52
69
|
*/
|
|
53
|
-
init: (options: ILandingPageOptions, pluginOptions?:
|
|
70
|
+
init: (options: ILandingPageOptions, pluginOptions?: ILandingPageEditorPluginOptions) => Promise<ILandingPageEditorInstance>;
|
|
54
71
|
};
|
|
55
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>;
|
|
@@ -6,10 +6,10 @@ export declare const TopolBlockOptionsSchema: z.ZodObject<{
|
|
|
6
6
|
disabledBadge: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
8
|
export declare const TopolBlockTypeSchema: z.ZodEnum<{
|
|
9
|
-
text: "text";
|
|
10
9
|
image: "image";
|
|
11
|
-
gif: "gif";
|
|
12
10
|
button: "button";
|
|
11
|
+
text: "text";
|
|
12
|
+
gif: "gif";
|
|
13
13
|
divider: "divider";
|
|
14
14
|
spacer: "spacer";
|
|
15
15
|
social: "social";
|
|
@@ -17,19 +17,33 @@ export declare const TopolBlockTypeSchema: z.ZodEnum<{
|
|
|
17
17
|
html: "html";
|
|
18
18
|
raw: "raw";
|
|
19
19
|
"custom-raw": "custom-raw";
|
|
20
|
+
form: "form";
|
|
20
21
|
}>;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
/** Block types `contentBlocks` can configure. The HTML block's palette entry is keyed `html`; custom blocks use `customBlocks[].disabled`. */
|
|
23
|
+
export declare const TopolContentBlockOptionKeySchema: z.ZodEnum<{
|
|
23
24
|
image: "image";
|
|
25
|
+
button: "button";
|
|
26
|
+
text: "text";
|
|
24
27
|
gif: "gif";
|
|
28
|
+
divider: "divider";
|
|
29
|
+
spacer: "spacer";
|
|
30
|
+
social: "social";
|
|
31
|
+
video: "video";
|
|
32
|
+
html: "html";
|
|
33
|
+
form: "form";
|
|
34
|
+
}>;
|
|
35
|
+
export type TopolContentBlockOptionKey = z.infer<typeof TopolContentBlockOptionKeySchema>;
|
|
36
|
+
export declare const TopolContentBlockOptionsSchema: z.ZodRecord<z.ZodUnion<[z.ZodEnum<{
|
|
37
|
+
image: "image";
|
|
25
38
|
button: "button";
|
|
39
|
+
text: "text";
|
|
40
|
+
gif: "gif";
|
|
26
41
|
divider: "divider";
|
|
27
42
|
spacer: "spacer";
|
|
28
43
|
social: "social";
|
|
29
44
|
video: "video";
|
|
30
45
|
html: "html";
|
|
31
|
-
|
|
32
|
-
"custom-raw": "custom-raw";
|
|
46
|
+
form: "form";
|
|
33
47
|
}>, z.ZodNever]> & z.core.$partial, z.ZodObject<{
|
|
34
48
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
35
49
|
disabledText: z.ZodOptional<z.ZodString>;
|
|
@@ -172,6 +186,7 @@ export declare const ButtonAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodEnum<{
|
|
|
172
186
|
align: "align";
|
|
173
187
|
"inner-padding": "inner-padding";
|
|
174
188
|
border: "border";
|
|
189
|
+
gradient: "gradient";
|
|
175
190
|
}>, z.ZodNever]> & z.core.$partial, z.ZodUnion<[z.ZodObject<{
|
|
176
191
|
value: z.ZodAny;
|
|
177
192
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -228,9 +243,9 @@ export declare const ButtonStyleAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodE
|
|
|
228
243
|
validatorErrorMessage: z.ZodOptional<z.ZodString>;
|
|
229
244
|
}, z.core.$strip>, z.ZodAny]>>;
|
|
230
245
|
export declare const ImageAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodEnum<{
|
|
246
|
+
title: "title";
|
|
231
247
|
src: "src";
|
|
232
248
|
transform: "transform";
|
|
233
|
-
title: "title";
|
|
234
249
|
filter: "filter";
|
|
235
250
|
display: "display";
|
|
236
251
|
width: "width";
|
|
@@ -301,9 +316,9 @@ export declare const ImageStyleAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodEn
|
|
|
301
316
|
}, z.core.$strip>, z.ZodAny]>>;
|
|
302
317
|
export declare const TopolCustomBlockMixContentSchema: z.ZodObject<{
|
|
303
318
|
type: z.ZodEnum<{
|
|
304
|
-
text: "text";
|
|
305
319
|
image: "image";
|
|
306
320
|
button: "button";
|
|
321
|
+
text: "text";
|
|
307
322
|
video: "video";
|
|
308
323
|
}>;
|
|
309
324
|
attributes: z.ZodAny;
|
|
@@ -323,9 +338,9 @@ export declare const TopolCustomBlockDataSchema: z.ZodObject<{
|
|
|
323
338
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
324
339
|
disabledBadge: z.ZodOptional<z.ZodString>;
|
|
325
340
|
type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
|
|
326
|
-
text: "text";
|
|
327
341
|
image: "image";
|
|
328
342
|
button: "button";
|
|
343
|
+
text: "text";
|
|
329
344
|
video: "video";
|
|
330
345
|
}>, z.ZodLiteral<"mix">]>>;
|
|
331
346
|
attributes: z.ZodOptional<z.ZodAny>;
|
|
@@ -334,9 +349,9 @@ export declare const TopolCustomBlockDataSchema: z.ZodObject<{
|
|
|
334
349
|
xsAttributes: z.ZodOptional<z.ZodAny>;
|
|
335
350
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
336
351
|
type: z.ZodEnum<{
|
|
337
|
-
text: "text";
|
|
338
352
|
image: "image";
|
|
339
353
|
button: "button";
|
|
354
|
+
text: "text";
|
|
340
355
|
video: "video";
|
|
341
356
|
}>;
|
|
342
357
|
attributes: z.ZodAny;
|
|
@@ -357,9 +372,9 @@ export declare const TopolCustomBlocksDataSchema: z.ZodArray<z.ZodObject<{
|
|
|
357
372
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
358
373
|
disabledBadge: z.ZodOptional<z.ZodString>;
|
|
359
374
|
type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
|
|
360
|
-
text: "text";
|
|
361
375
|
image: "image";
|
|
362
376
|
button: "button";
|
|
377
|
+
text: "text";
|
|
363
378
|
video: "video";
|
|
364
379
|
}>, z.ZodLiteral<"mix">]>>;
|
|
365
380
|
attributes: z.ZodOptional<z.ZodAny>;
|
|
@@ -368,9 +383,9 @@ export declare const TopolCustomBlocksDataSchema: z.ZodArray<z.ZodObject<{
|
|
|
368
383
|
xsAttributes: z.ZodOptional<z.ZodAny>;
|
|
369
384
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
370
385
|
type: z.ZodEnum<{
|
|
371
|
-
text: "text";
|
|
372
386
|
image: "image";
|
|
373
387
|
button: "button";
|
|
388
|
+
text: "text";
|
|
374
389
|
video: "video";
|
|
375
390
|
}>;
|
|
376
391
|
attributes: z.ZodAny;
|
|
@@ -390,9 +405,9 @@ export declare const TopolCustomBlockMixContentWithKeySchema: z.ZodObject<{
|
|
|
390
405
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
391
406
|
disabledBadge: z.ZodOptional<z.ZodString>;
|
|
392
407
|
type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
|
|
393
|
-
text: "text";
|
|
394
408
|
image: "image";
|
|
395
409
|
button: "button";
|
|
410
|
+
text: "text";
|
|
396
411
|
video: "video";
|
|
397
412
|
}>, z.ZodLiteral<"mix">]>>;
|
|
398
413
|
attributes: z.ZodOptional<z.ZodAny>;
|
|
@@ -401,9 +416,9 @@ export declare const TopolCustomBlockMixContentWithKeySchema: z.ZodObject<{
|
|
|
401
416
|
xsAttributes: z.ZodOptional<z.ZodAny>;
|
|
402
417
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
403
418
|
type: z.ZodEnum<{
|
|
404
|
-
text: "text";
|
|
405
419
|
image: "image";
|
|
406
420
|
button: "button";
|
|
421
|
+
text: "text";
|
|
407
422
|
video: "video";
|
|
408
423
|
}>;
|
|
409
424
|
attributes: z.ZodAny;
|
|
@@ -416,10 +431,10 @@ export declare const TopolCustomBlockMixContentWithKeySchema: z.ZodObject<{
|
|
|
416
431
|
}, z.core.$strip>;
|
|
417
432
|
export declare const TopolBlockClickedEventSchema: z.ZodObject<{
|
|
418
433
|
type: z.ZodEnum<{
|
|
419
|
-
text: "text";
|
|
420
434
|
image: "image";
|
|
421
|
-
gif: "gif";
|
|
422
435
|
button: "button";
|
|
436
|
+
text: "text";
|
|
437
|
+
gif: "gif";
|
|
423
438
|
divider: "divider";
|
|
424
439
|
spacer: "spacer";
|
|
425
440
|
social: "social";
|
|
@@ -427,6 +442,7 @@ export declare const TopolBlockClickedEventSchema: z.ZodObject<{
|
|
|
427
442
|
html: "html";
|
|
428
443
|
raw: "raw";
|
|
429
444
|
"custom-raw": "custom-raw";
|
|
445
|
+
form: "form";
|
|
430
446
|
}>;
|
|
431
447
|
customBlockData: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
432
448
|
key: z.ZodString;
|
|
@@ -439,9 +455,9 @@ export declare const TopolBlockClickedEventSchema: z.ZodObject<{
|
|
|
439
455
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
440
456
|
disabledBadge: z.ZodOptional<z.ZodString>;
|
|
441
457
|
type: z.ZodOptional<z.ZodUnion<[z.ZodEnum<{
|
|
442
|
-
text: "text";
|
|
443
458
|
image: "image";
|
|
444
459
|
button: "button";
|
|
460
|
+
text: "text";
|
|
445
461
|
video: "video";
|
|
446
462
|
}>, z.ZodLiteral<"mix">]>>;
|
|
447
463
|
attributes: z.ZodOptional<z.ZodAny>;
|
|
@@ -450,9 +466,9 @@ export declare const TopolBlockClickedEventSchema: z.ZodObject<{
|
|
|
450
466
|
xsAttributes: z.ZodOptional<z.ZodAny>;
|
|
451
467
|
blocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
452
468
|
type: z.ZodEnum<{
|
|
453
|
-
text: "text";
|
|
454
469
|
image: "image";
|
|
455
470
|
button: "button";
|
|
471
|
+
text: "text";
|
|
456
472
|
video: "video";
|
|
457
473
|
}>;
|
|
458
474
|
attributes: z.ZodAny;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export declare const LanguageSchema: z.ZodUnion<readonly [z.ZodLiteral<"en">, z.ZodLiteral<"fr">, z.ZodLiteral<"pt">, z.ZodLiteral<"es">, z.ZodLiteral<"ja">, z.ZodLiteral<"zh">, z.ZodLiteral<"ru">, z.ZodLiteral<"tr">, z.ZodLiteral<"de">, z.ZodLiteral<"sv">, z.ZodLiteral<"nl">, z.ZodLiteral<"it">, z.ZodLiteral<"fi">, z.ZodLiteral<"ro">, z.ZodLiteral<"cs">, z.ZodLiteral<"pl">, z.ZodLiteral<"ko">, z.ZodLiteral<"vi">, z.ZodLiteral<"he">, z.ZodLiteral<"ar">]>;
|
|
2
|
+
export declare const LanguageSchema: z.ZodUnion<readonly [z.ZodLiteral<"en">, z.ZodLiteral<"fr">, z.ZodLiteral<"pt">, z.ZodLiteral<"es">, z.ZodLiteral<"ja">, z.ZodLiteral<"zh">, z.ZodLiteral<"ru">, z.ZodLiteral<"tr">, z.ZodLiteral<"de">, z.ZodLiteral<"sv">, z.ZodLiteral<"sk">, z.ZodLiteral<"nl">, z.ZodLiteral<"it">, z.ZodLiteral<"fi">, z.ZodLiteral<"ro">, z.ZodLiteral<"cs">, z.ZodLiteral<"pl">, z.ZodLiteral<"ko">, z.ZodLiteral<"vi">, z.ZodLiteral<"he">, z.ZodLiteral<"ar">]>;
|
|
3
3
|
export type ILanguage = z.infer<typeof LanguageSchema>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { topolTemplateSchema } from "../templateSchema";
|
|
3
|
-
import type { TopolSection } from "../template/structure/sectionSchema";
|
|
4
|
-
import type { TopolColumn } from "../template/structure/columnSchema";
|
|
5
|
-
import type { TopolBlock } from "../template/structure/blockSchema";
|
|
2
|
+
import { topolTemplateSchema, TopolSection, TopolColumn, TopolBlock, TopolNavbar, TopolNavbarChild, TopolNavbarMenuItem, TopolNavbarHamburger, TopolRow } from "../templateSchema";
|
|
6
3
|
export declare const MjmlStateSchema: z.ZodObject<{
|
|
7
4
|
mjml: typeof topolTemplateSchema;
|
|
8
5
|
selectedPath: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
|
|
@@ -12,7 +9,7 @@ export declare const MjmlStateSchema: z.ZodObject<{
|
|
|
12
9
|
productTab: z.ZodDefault<z.ZodString>;
|
|
13
10
|
defaultTemplate: typeof topolTemplateSchema;
|
|
14
11
|
}>;
|
|
15
|
-
export type Element = TopolSection | TopolColumn | TopolBlock | TopolSection["container"] | undefined;
|
|
12
|
+
export type Element = TopolSection | TopolNavbar | TopolNavbarChild | TopolNavbarMenuItem | TopolColumn | TopolBlock | TopolSection["container"] | TopolRow | TopolNavbarHamburger["container"] | undefined;
|
|
16
13
|
export type baseAttributesKeys = keyof z.infer<typeof topolTemplateSchema>["attributes"];
|
|
17
14
|
export type TopolStyleKeys = keyof z.infer<typeof topolTemplateSchema>["style"];
|
|
18
15
|
export type MjmlState = z.infer<typeof MjmlStateSchema>;
|
|
@@ -20,12 +17,17 @@ export type MjmlStateGetters = {
|
|
|
20
17
|
getBase: any;
|
|
21
18
|
getElementByPath: (path: Array<string | number>) => Element;
|
|
22
19
|
getActiveElement: Element | null;
|
|
23
|
-
getSettingsElementAttribute: (elementName: string, prop: string,
|
|
20
|
+
getSettingsElementAttribute: (elementName: string, prop: string, elState?: "hover" | "open") => any;
|
|
24
21
|
getSettingsElementHoverAttribute: (elementName: string, prop: string) => any;
|
|
25
22
|
getActiveElementHoverAttribute: (prop: string) => any;
|
|
23
|
+
getActiveElementOpenAttribute: (prop: string) => any;
|
|
24
|
+
getActiveElementSubTagHoverAttribute: (prop: string, subPath: Array<string | number>) => any;
|
|
26
25
|
getActiveElementAttribute: (prop: string) => any;
|
|
26
|
+
getActiveElementSubTagAttribute: (prop: string, subPath: Array<string | number>, elState?: "hover" | "open") => any;
|
|
27
27
|
getSettingsContainerAttribute: (prop: string) => any;
|
|
28
28
|
getBlockAttribute: (block: Element | null, prop: string) => any;
|
|
29
|
+
getBlockSubTagAttribute: (block: Element | null, prop: string, subPath: Array<string | number>, elState?: "hover" | "open") => any;
|
|
29
30
|
getSettingsContainerWasChanged: () => boolean;
|
|
31
|
+
getSettingsHoverStyle: (elementName: string) => any;
|
|
30
32
|
};
|
|
31
33
|
export type MjmlStateWithGetters = MjmlState & MjmlStateGetters;
|
|
@@ -9,7 +9,6 @@ export declare const NotificationSchema: z.ZodObject<{
|
|
|
9
9
|
error: "error";
|
|
10
10
|
success: "success";
|
|
11
11
|
}>;
|
|
12
|
-
extarnalUse: z.ZodOptional<z.ZodBoolean>;
|
|
13
12
|
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
14
13
|
}, z.core.$strip>;
|
|
15
14
|
export type Notification = z.infer<typeof NotificationSchema>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const OpenAIMessageSchema: z.ZodObject<{
|
|
2
|
+
export declare const OpenAIMessageSchema: z.ZodObject<{
|
|
3
3
|
role: z.ZodString;
|
|
4
4
|
content: z.ZodString;
|
|
5
5
|
}, z.core.$strip>;
|
|
6
6
|
export type IOpenAIMessage = z.infer<typeof OpenAIMessageSchema>;
|
|
7
|
-
export {};
|