@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.
Files changed (74) hide show
  1. package/README.md +153 -101
  2. package/dist/topol-plugin.es.js +146 -191
  3. package/dist/topol-plugin.umd.cjs +1 -0
  4. package/dist/types/src/core/script-loader.d.ts +15 -0
  5. package/dist/types/src/email-editor/constants.d.ts +3 -3
  6. package/dist/types/src/email-editor/index.d.ts +16 -91
  7. package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
  8. package/dist/types/src/landing-page-editor/index.d.ts +27 -10
  9. package/dist/types/src/landing-page-editor/schemas/api/apiSchema.d.ts +5 -10
  10. package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +34 -18
  11. package/dist/types/src/landing-page-editor/schemas/language/languageSchema.d.ts +1 -1
  12. package/dist/types/src/landing-page-editor/schemas/mjmlStore/mjmlStoreSchema.d.ts +8 -6
  13. package/dist/types/src/landing-page-editor/schemas/notification/notificationSchema.d.ts +0 -1
  14. package/dist/types/src/landing-page-editor/schemas/openAI/openAISchema.d.ts +1 -2
  15. package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +153 -17
  16. package/dist/types/src/landing-page-editor/schemas/premadeSection/premadeSectionSchema.d.ts +30 -0
  17. package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +687 -5
  18. package/dist/types/src/landing-page-editor/schemas/template/blocks/carouselBlockSchema.d.ts +9 -2
  19. package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +11 -3
  20. package/dist/types/src/landing-page-editor/schemas/template/blocks/formBlockSchema.d.ts +1069 -0
  21. package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +35 -19
  22. package/dist/types/src/landing-page-editor/schemas/template/blocks/rawBlockSchema.d.ts +9 -1
  23. package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +11 -3
  24. package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +18 -10
  25. package/dist/types/src/landing-page-editor/schemas/template/blocks/textBlockSchema.d.ts +9 -1
  26. package/dist/types/src/landing-page-editor/schemas/template/blocks/videoBlockSchema.d.ts +9 -1
  27. package/dist/types/src/landing-page-editor/schemas/template/commonSchema.d.ts +28 -8
  28. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarCTASchema.d.ts +335 -0
  29. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarHamburgerSchema.d.ts +1109 -0
  30. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarLogoSchema.d.ts +252 -0
  31. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarMenuSchema.d.ts +1209 -0
  32. package/dist/types/src/landing-page-editor/schemas/template/settingsSchema.d.ts +4058 -546
  33. package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +5007 -2328
  34. package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5501 -2412
  35. package/dist/types/src/landing-page-editor/schemas/template/structure/navbarSchema.d.ts +4394 -0
  36. package/dist/types/src/landing-page-editor/schemas/template/structure/rowSchema.d.ts +11094 -0
  37. package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +8602 -3337
  38. package/dist/types/src/landing-page-editor/schemas/template/styleSchema.d.ts +55 -44
  39. package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +34865 -48464
  40. package/dist/types/src/landing-page-editor/schemas/templateSettings/templateSettingsSchema.d.ts +4305 -794
  41. package/dist/types/src/landing-page-editor/schemas/theme/themeSchema.d.ts +6 -1
  42. package/dist/types/src/landing-page-editor/schemas/utils/cssValue.d.ts +21 -0
  43. package/dist/types/src/landing-page-editor/schemas/utils/transformBorder.d.ts +10 -5
  44. package/dist/types/src/main.d.ts +28 -101
  45. package/dist/types/types/API/API.d.ts +10 -9
  46. package/dist/types/types/APIBlocks/APIBlocks.d.ts +11 -0
  47. package/dist/types/types/Auth/IAuthorize.d.ts +18 -0
  48. package/dist/types/types/Auth/INonceAuthCallbacks.d.ts +10 -0
  49. package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +28 -18
  50. package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +85 -104
  51. package/dist/types/types/Cloud/ICloudOptions.d.ts +32 -0
  52. package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
  53. package/dist/types/types/Countdown/ICountdownOptions.d.ts +48 -0
  54. package/dist/types/types/IEmailConfig.d.ts +225 -0
  55. package/dist/types/types/IEmailEditorInstance.d.ts +68 -0
  56. package/dist/types/types/IEmailOptions.d.ts +7 -0
  57. package/dist/types/types/Language/Language.d.ts +6 -1
  58. package/dist/types/types/MergeTag/IMergeTag.d.ts +18 -0
  59. package/dist/types/types/Notification/INotification.d.ts +2 -1
  60. package/dist/types/types/Sections/ISections.d.ts +41 -0
  61. package/dist/types/types/Shortcuts/EditorShortcut.d.ts +4 -0
  62. package/dist/types/types/Theme/ITheme.d.ts +12 -2
  63. package/dist/types/types/landing-page/ILandingPageEditorInstance.d.ts +73 -9
  64. package/dist/types/types/landing-page/ILandingPageOptions.d.ts +110 -62
  65. package/package.json +10 -13
  66. package/dist/topol-plugin.umd.js +0 -1
  67. package/dist/types/src/landing-page-editor/schemas/helpdesk/helpdeskSchema.d.ts +0 -8
  68. package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +0 -59750
  69. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +0 -44831
  70. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +0 -59725
  71. package/dist/types/src/landing-page-editor/schemas/template/blocks/index.d.ts +0 -12
  72. package/dist/types/types/ITopolOptions.d.ts +0 -123
  73. package/dist/types/types/ITopolPlugin.d.ts +0 -37
  74. package/dist/types/types/SavedBlock/ISavedBlock.d.ts +0 -6
@@ -1,104 +1,152 @@
1
1
  /**
2
- * Configuration options for the Landing Page Editor.
3
- * Re-exports the IPluginOptions from the schema with additional callbacks.
2
+ * Options of `LandingPageEditor.init()`: the editor `config` plus the host callbacks.
4
3
  */
5
- import type { IPluginOptions } from "../../src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema";
6
- import type { TopolSection } from "../../src/landing-page-editor/schemas/template/structure/sectionSchema";
4
+ import type { ILandingPageConfig } from "../../src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema";
7
5
  import type { INotification } from "../../src/landing-page-editor/schemas/notification/notificationSchema";
6
+ import type { EditorErrorSource } from "../Callbacks/ICallbackPayloads";
7
+ import type { INonceAuthCallbacks } from "../Auth/INonceAuthCallbacks";
8
+ /**
9
+ * Payload of `onSave` and `onSaveAndClose`.
10
+ */
11
+ export interface ILandingPageSavePayload {
12
+ /** The landing page JSON structure (template definition). */
13
+ json: unknown;
14
+ /** The rendered page HTML. */
15
+ html: string;
16
+ /** Ids of the synced sections placed in the saved template. */
17
+ syncedSections?: number[];
18
+ }
19
+ /**
20
+ * A file or folder deleted in the built-in file manager (`onImageDelete`).
21
+ */
22
+ export interface ILandingPageDeletedItem {
23
+ name: string;
24
+ type: "file" | "folder";
25
+ path: string;
26
+ url?: string;
27
+ key: string | null;
28
+ }
29
+ /**
30
+ * Payload of `onEditorError`.
31
+ */
32
+ export interface ILandingPageErrorPayload {
33
+ /** Where the error originated. The wrappers report `"integration"` when `init()` or `render()` rejects. */
34
+ source: EditorErrorSource;
35
+ /** Human-readable description. */
36
+ message: string;
37
+ /** Raw error data when available (for `network` errors, the response body). */
38
+ detail?: unknown;
39
+ }
8
40
  /**
9
41
  * Callback functions for Landing Page Editor events.
42
+ *
43
+ * Every callback receives at most one argument: a payload object with named
44
+ * properties. New fields can be added to a payload without breaking handlers,
45
+ * so destructure what you need and ignore the rest. Callbacks that carry no
46
+ * data are called with no arguments. The one exception is `getNonce`, which returns a value.
10
47
  */
11
- export interface ILandingPageCallbacks {
48
+ export interface ILandingPageCallbacks extends INonceAuthCallbacks {
12
49
  /**
13
50
  * Called when the user saves the landing page.
14
- * @param json - The landing page JSON structure
15
- * @param html - The generated HTML output
16
- */
17
- onSave?(json: unknown, html: unknown): void;
18
- /**
19
- * Called when the user clicks "Save and Close".
20
- * @param json - The landing page JSON structure
21
- * @param html - The generated HTML output
51
+ * May return a Promise: the editor keeps its saving state until it settles and a
52
+ * rejection is shown as a save error. A Promise that never settles is released after
53
+ * a timeout with a console warning.
22
54
  */
23
- onSaveAndClose?(json: unknown, html: unknown): void;
55
+ onSave?(payload: ILandingPageSavePayload): void | Promise<void>;
24
56
  /**
25
- * Called when the editor has finished loading.
57
+ * Called when the user clicks "Save and Close". Same payload and Promise handling as
58
+ * `onSave`; a rejection keeps the editor open. Closing the editor UI is your job here.
59
+ * When not defined, the payload goes to `onSave` and the editor iframe is removed afterwards.
26
60
  */
27
- onLoaded?(): void;
61
+ onSaveAndClose?(payload: ILandingPageSavePayload): void | Promise<void>;
28
62
  /**
29
- * Called when the editor is initialized.
63
+ * Called when the custom file manager should be opened.
30
64
  */
31
- onInit?(): void;
65
+ onOpenFileManager?(): void;
32
66
  /**
33
- * Called when the user closes the editor.
67
+ * Called when files or folders are deleted in the built-in file manager, so the
68
+ * deletion can be mirrored in your own storage.
34
69
  */
35
- onClose?(): void;
70
+ onImageDelete?(payload: {
71
+ items: ILandingPageDeletedItem[];
72
+ }): void;
36
73
  /**
37
- * Called when the user clicks the banner.
38
- * @param json - The landing page JSON structure
39
- * @param html - The generated HTML output
74
+ * Called after a template has been loaded into the editor via `load()`.
75
+ *
76
+ * Note: this is NOT an "editor ready" signal; use `onInit` for that.
40
77
  */
41
- onBannerClick?(json: unknown, html: unknown): void;
78
+ onLoaded?(): void;
42
79
  /**
43
- * Called when the custom file manager should be opened.
80
+ * Called once the editor is fully initialized and ready.
44
81
  */
45
- onOpenFileManager?(): void;
82
+ onInit?(): void;
46
83
  /**
47
- * Called when a block is saved.
48
- * @param block - The saved block section
84
+ * Called when the undo stack changes. `count` is the number of undo steps available.
49
85
  */
50
- onBlockSave?(block: TopolSection): void;
86
+ onUndoChange?(payload: {
87
+ count: number;
88
+ }): void;
51
89
  /**
52
- * Called when a block is removed.
53
- * @param blockId - The ID of the removed block
90
+ * Called when the redo stack changes. `count` is the number of redo steps available.
54
91
  */
55
- onBlockRemove?(blockId: number | string): void;
92
+ onRedoChange?(payload: {
93
+ count: number;
94
+ }): void;
56
95
  /**
57
- * Called when a block is being edited.
58
- * @param blockId - The ID of the block being edited
96
+ * Called when the user requests a preview. `html` is the rendered page.
59
97
  */
60
- onBlockEdit?(blockId: number | string): void;
98
+ onPreview?(payload: {
99
+ html: string;
100
+ }): void;
61
101
  /**
62
- * Called when the undo stack changes.
63
- * @param count - Number of undo steps available
102
+ * Called when the preview is closed.
64
103
  */
65
- onUndoChange?(count: number): void;
104
+ onPreviewClose?(): void;
66
105
  /**
67
- * Called when the redo stack changes.
68
- * @param count - Number of redo steps available
106
+ * Called when an alert/notification is triggered.
69
107
  */
70
- onRedoChange?(count: number): void;
108
+ onAlert?(payload: {
109
+ notification: INotification;
110
+ }): void;
71
111
  /**
72
- * Called when the user requests a preview.
73
- * @param html - The preview HTML
112
+ * Called when the user closes the editor from the window bar. Closing the editor UI is
113
+ * your job in this handler. May return a Promise; the editor waits for it before teardown.
114
+ *
115
+ * Named `onEditorClose` because the underlying loader reserves `onClose` for its own
116
+ * lifecycle. It is NOT invoked when the host tears the editor down via `destroy()`.
74
117
  */
75
- onPreview?(html: unknown): void;
118
+ onEditorClose?(): void | Promise<void>;
76
119
  /**
77
- * Called when an alert/notification is triggered.
78
- * @param notification - The notification object
120
+ * Called when the unsaved-changes state flips. `hasUnsavedChanges` is `true` while there are unsaved edits.
79
121
  */
80
- onAlert?(notification: INotification): void;
122
+ onUnsavedChangesChange?(payload: {
123
+ hasUnsavedChanges: boolean;
124
+ }): void;
81
125
  /**
82
- * Called when the edited-without-save state changes.
83
- * @param hasChanges - Whether there are unsaved changes
126
+ * @deprecated Use `onUnsavedChangesChange`. Fires alongside it with `{ value }`; the editor logs a
127
+ * deprecation warning when it is passed.
84
128
  */
85
- onEdittedWithoutSaveChanged?(hasChanges: boolean): void;
129
+ onEdittedWithoutSaveChanged?(payload: {
130
+ value: boolean;
131
+ }): void;
86
132
  /**
87
- * Called when a custom block dialog should be opened.
88
- * @param blockData - The custom block data
133
+ * Called when a custom block dialog should be opened. `block` is the custom block data.
89
134
  */
90
- onOpenCustomBlockDialog?(blockData: unknown): void;
135
+ onOpenCustomBlockDialog?(payload: {
136
+ block: unknown;
137
+ }): void;
91
138
  /**
92
- * Called when the template is renamed.
93
- * @param newName - The new template name
139
+ * Called when the user clicks the rename button. `name` is the current template name.
94
140
  */
95
- onTemplateRename?(newName: string): void;
141
+ onTemplateRename?(payload: {
142
+ name: string;
143
+ }): void;
96
144
  /**
97
- * Called when an error occurs.
98
- * @param type - The error type
99
- * @param message - The error message
145
+ * Called when an error occurs in the editor.
146
+ *
147
+ * Named `onEditorError` because the underlying loader reserves `onError` for its own lifecycle.
100
148
  */
101
- onError?(type: string, message: string): void;
149
+ onEditorError?(payload: ILandingPageErrorPayload): void;
102
150
  }
103
151
  /**
104
152
  * Configuration options for the Landing Page Editor.
@@ -108,7 +156,7 @@ export default interface ILandingPageOptions extends ILandingPageCallbacks {
108
156
  /**
109
157
  * Editor configuration options.
110
158
  */
111
- config: IPluginOptions;
159
+ config: ILandingPageConfig;
112
160
  }
113
- export type { IPluginOptions };
161
+ export type { ILandingPageConfig };
114
162
  export type { LambdaStage, UserRole } from "../../src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema";
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": "1.0.0-alpha.1",
15
+ "version": "1.0.0-alpha.11",
16
16
  "files": [
17
17
  "dist"
18
18
  ],
@@ -23,24 +23,19 @@
23
23
  ".": {
24
24
  "types": "./dist/types/src/main.d.ts",
25
25
  "import": "./dist/topol-plugin.es.js",
26
- "require": "./dist/topol-plugin.umd.js"
26
+ "require": "./dist/topol-plugin.umd.cjs"
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^20.6.5",
31
- "@typescript-eslint/eslint-plugin": "^6.7.2",
32
- "@typescript-eslint/parser": "^6.7.2",
33
- "eslint": "^8.50.0",
34
- "eslint-config-prettier": "^9.0.0",
35
31
  "happy-dom": "^20.0.11",
36
- "prettier": "3.1.1",
37
32
  "typescript": "^5.2.2",
38
33
  "vite": "^5.0.11",
39
- "vitest": "^4.0.16",
40
- "zod": "^4.3.5"
34
+ "vitest": "^4.0.16"
41
35
  },
42
36
  "dependencies": {
43
- "load-script": "^2.0.0"
37
+ "load-script": "^2.0.0",
38
+ "zod": "^4.3.5"
44
39
  },
45
40
  "publishConfig": {
46
41
  "access": "public"
@@ -49,10 +44,12 @@
49
44
  "dev": "vite",
50
45
  "build-watch": "vite build --watch",
51
46
  "build-with-types": "vite build && pnpm run build:types",
52
- "lint": "eslint --no-eslintrc --config '.eslintrc.cjs' 'src/**/*.ts' --fix",
53
- "format": "prettier --write .",
47
+ "lint": "oxlint --deny-warnings .",
48
+ "format": "oxfmt --write .",
54
49
  "build:types": "tsc -p tsconfig.prod.json",
55
50
  "test": "vitest run",
56
- "test:watch": "vitest"
51
+ "test:watch": "vitest",
52
+ "lint:fix": "oxlint --fix --deny-warnings .",
53
+ "format:check": "oxfmt --check ."
57
54
  }
58
55
  }
@@ -1 +0,0 @@
1
- (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l["topol-plugin"]={}))})(this,function(l){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T=function(n,o,i){var a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("script");typeof o=="function"&&(i=o,o={}),o=o||{},i=i||function(){},t.type=o.type||"text/javascript",t.charset=o.charset||"utf8",t.async="async"in o?!!o.async:!0,t.src=n,o.attrs&&P(t,o.attrs),o.text&&(t.text=""+o.text);var s="onload"in t?c:f;s(t,i),t.onload||c(t,i),a.appendChild(t)};function P(e,n){for(var o in n)e.setAttribute(o,n[o])}function c(e,n){e.onload=function(){this.onerror=this.onload=null,n(null,e)},e.onerror=function(){this.onerror=this.onload=null,n(new Error("Failed to load "+this.src),e)}}function f(e,n){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,e))}}const d=u(T);var g={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const r={production:g.VITE_TOPOL_URL,dev:g.VITE_TOPOL_DEV_URL,staging:g.VITE_TOPOL_STAGING_URL},m="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";function h(e="production"){switch(e){case"dev":return r.dev;case"staging":return r.staging;case"production":return r.production;default:return m.replace("{stage}",String(e))}}async function E(e){return new Promise((n,o)=>{d(r.production,i=>{if(i!==null){o(i);return}window.TopolPlugin.init(e),n(!0)})})}const w={init:(e,n)=>new Promise((o,i)=>{const a=h(n==null?void 0:n.stage);d(a,async t=>{if(t!==null){if(a!==r.production)try{return await E(e),o(!0)}catch(s){i(s)}i(t);return}window.TopolPlugin.init(e),o(!0)})}),save:()=>{window.TopolPlugin.save()},load:e=>{window.TopolPlugin.load(e)},togglePreview:()=>{window.TopolPlugin.togglePreview()},togglePreviewSize:()=>{window.TopolPlugin.togglePreviewSize()},chooseFile:e=>{window.TopolPlugin.chooseFile(e)},undo:()=>{window.TopolPlugin.undo()},redo:()=>{window.TopolPlugin.redo()},destroy:()=>{window.TopolPlugin.destroy()},setSavedBlocks:e=>{window.TopolPlugin.setSavedBlocks(e)},setPreviewHTML:e=>{window.TopolPlugin.setPreviewHTML(e)},createNotification:e=>{window.TopolPlugin.createNotification(e)},setActiveMembers:e=>{window.TopolPlugin.setActiveMembers(e)},changeEmailToMobile:()=>{window.TopolPlugin.changeEmailToMobile()},changeEmailToDesktop:()=>{window.TopolPlugin.changeEmailToDesktop()},toggleBlocksAndStructuresVisibility:()=>{window.TopolPlugin.toggleBlocksAndStructuresVisibility()},updateCustomBlockContent:e=>{window.TopolPlugin.updateCustomBlockContent(e)},refreshComments:e=>{window.TopolPlugin.refreshComments(e)},refreshSyncedRows:()=>{window.TopolPlugin.refreshSyncedRows()},openPremadeTemplatesSelection:()=>{window.TopolPlugin.openPremadeTemplatesSelection()},updateApiAuthorizationHeader:e=>{window.TopolPlugin.updateApiAuthorizationHeader(e)},setTemplateName:e=>{window.TopolPlugin.setTemplateName(e)},toggleChatAI:()=>{window.TopolPlugin.toggleChatAI()},toggleAutosaves:()=>{window.TopolPlugin.toggleAutosaves()},toggleComments:()=>{window.TopolPlugin.toggleComments()},createLanguage:e=>{window.TopolPlugin.createLanguage(e)},setPrimaryLanguage:e=>{window.TopolPlugin.setPrimaryLanguage(e)},deleteLanguage:e=>{window.TopolPlugin.deleteLanguage(e)},selectLanguage:e=>{window.TopolPlugin.selectLanguage(e)}},v="https://v1.page-assets.topol.io/topol-lpe.js",y={init:(e,n)=>new Promise((o,i)=>{d(v,a=>{if(a!==null){i(a);return}const t=window.LandingPageEditor(e);o(t)})})},p=w;l.EmailEditor=w,l.LandingPageEditor=y,l.TopolPlugin=p,l.default=p,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- export declare const HelpSchema: z.ZodObject<{
3
- text: z.ZodString;
4
- url: z.ZodString;
5
- }, z.core.$strip>;
6
- export declare const HelpdeskSchema: z.ZodObject<{}, z.core.$strip>;
7
- export type IHelp = z.infer<typeof HelpSchema>;
8
- export type IHelpdesk = z.infer<typeof HelpdeskSchema>;