@topol.io/editor 1.0.0-alpha.9 → 2.0.0-alpha.2
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 +111 -106
- package/dist/topol-plugin.es.js +126 -246
- package/dist/topol-plugin.umd.cjs +1 -0
- package/dist/types/src/email-editor/constants.d.ts +3 -3
- package/dist/types/src/email-editor/index.d.ts +15 -101
- package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +1 -1
- package/dist/types/src/landing-page-editor/schemas/openAI/openAISchema.d.ts +1 -2
- package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +816 -816
- package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +612 -612
- package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +816 -816
- package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +2 -2
- package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +2 -2
- package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +6 -6
- package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +2 -2
- package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +2 -2
- package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +92 -92
- package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +94 -94
- package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +204 -204
- package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +804 -804
- package/dist/types/src/main.d.ts +10 -72
- package/dist/types/types/API/API.d.ts +8 -7
- package/dist/types/types/Auth/INonceAuthCallbacks.d.ts +9 -0
- package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +19 -22
- package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +65 -155
- package/dist/types/types/Cloud/ICloudOptions.d.ts +32 -0
- package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
- package/dist/types/types/IEmailConfig.d.ts +190 -0
- package/dist/types/types/IEmailEditorInstance.d.ts +54 -0
- package/dist/types/types/ITopolOptions.d.ts +4 -153
- package/dist/types/types/ITopolPlugin.d.ts +2 -44
- package/dist/types/types/Language/Language.d.ts +1 -1
- package/dist/types/types/SavedBlock/ISavedBlock.d.ts +2 -6
- package/dist/types/types/Sections/ISections.d.ts +30 -0
- package/package.json +7 -10
- package/dist/topol-plugin.umd.js +0 -1
|
@@ -0,0 +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(_),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"}})});
|
|
@@ -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,108 +1,22 @@
|
|
|
1
1
|
import type ITopolOptions from "../../types/ITopolOptions";
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
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: ITopolOptions) => 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: (lang?: string) => 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
|
-
updateOptions: (options: Partial<ITopolOptions>) => void;
|
|
84
|
-
/** Toggle the AI chat feature */
|
|
85
|
-
toggleChatAI: () => void;
|
|
86
|
-
/** Toggle the autosaves feature */
|
|
87
|
-
toggleAutosaves: () => void;
|
|
88
|
-
/** Toggle the comments panel */
|
|
89
|
-
toggleComments: () => void;
|
|
90
|
-
/** Create a new language variant */
|
|
91
|
-
createLanguage: (lang: string) => void;
|
|
92
|
-
/** Set the primary language */
|
|
93
|
-
setPrimaryLanguage: (lang: string) => void;
|
|
94
|
-
/** Delete a language variant */
|
|
95
|
-
deleteLanguage: (lang: string) => void;
|
|
96
|
-
/** Select/switch to a language */
|
|
97
|
-
selectLanguage: (lang: string) => void;
|
|
98
|
-
/** Get the list of mutations */
|
|
99
|
-
getMutations: () => void;
|
|
100
|
-
/** Toggle the control panel visibility */
|
|
101
|
-
toggleControlPanel: () => void;
|
|
102
|
-
/** Update the editor template with new JSON data */
|
|
103
|
-
updateTemplate: (json: unknown, options?: {
|
|
104
|
-
skipSnapshot?: boolean;
|
|
105
|
-
}) => void;
|
|
106
|
-
/** Toggle dark mode for the editor */
|
|
107
|
-
toggleDarkMode: () => void;
|
|
20
|
+
init(options: ITopolOptions, pluginOptions?: IEmailEditorPluginOptions): Promise<IEmailEditorInstance>;
|
|
108
21
|
};
|
|
22
|
+
export {};
|
|
@@ -228,9 +228,9 @@ export declare const ButtonStyleAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodE
|
|
|
228
228
|
validatorErrorMessage: z.ZodOptional<z.ZodString>;
|
|
229
229
|
}, z.core.$strip>, z.ZodAny]>>;
|
|
230
230
|
export declare const ImageAttributesSchema: z.ZodRecord<z.ZodUnion<[z.ZodEnum<{
|
|
231
|
+
title: "title";
|
|
231
232
|
src: "src";
|
|
232
233
|
transform: "transform";
|
|
233
|
-
title: "title";
|
|
234
234
|
filter: "filter";
|
|
235
235
|
display: "display";
|
|
236
236
|
width: "width";
|
|
@@ -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 {};
|