@topol.io/editor 1.0.0-alpha.8 → 1.0.0

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 (72) hide show
  1. package/README.md +160 -97
  2. package/dist/index.js +171 -0
  3. package/dist/types/src/email-editor/index.d.ts +16 -102
  4. package/dist/types/src/landing-page-editor/constants.d.ts +1 -1
  5. package/dist/types/src/landing-page-editor/index.d.ts +11 -6
  6. package/dist/types/src/landing-page-editor/schemas/api/apiSchema.d.ts +5 -11
  7. package/dist/types/src/landing-page-editor/schemas/contentBlock/contentBlockScheme.d.ts +34 -18
  8. package/dist/types/src/landing-page-editor/schemas/language/languageSchema.d.ts +1 -1
  9. package/dist/types/src/landing-page-editor/schemas/mjmlStore/mjmlStoreSchema.d.ts +8 -6
  10. package/dist/types/src/landing-page-editor/schemas/notification/notificationSchema.d.ts +0 -1
  11. package/dist/types/src/landing-page-editor/schemas/openAI/openAISchema.d.ts +1 -2
  12. package/dist/types/src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema.d.ts +150 -17
  13. package/dist/types/src/landing-page-editor/schemas/premadeSection/premadeSectionSchema.d.ts +30 -0
  14. package/dist/types/src/landing-page-editor/schemas/template/blocks/buttonBlockSchema.d.ts +687 -5
  15. package/dist/types/src/landing-page-editor/schemas/template/blocks/carouselBlockSchema.d.ts +9 -2
  16. package/dist/types/src/landing-page-editor/schemas/template/blocks/dividerBlockSchema.d.ts +11 -3
  17. package/dist/types/src/landing-page-editor/schemas/template/blocks/formBlockSchema.d.ts +1069 -0
  18. package/dist/types/src/landing-page-editor/schemas/template/blocks/imageAnGifBlockSchema.d.ts +35 -19
  19. package/dist/types/src/landing-page-editor/schemas/template/blocks/rawBlockSchema.d.ts +9 -1
  20. package/dist/types/src/landing-page-editor/schemas/template/blocks/socialBlockSchema.d.ts +11 -3
  21. package/dist/types/src/landing-page-editor/schemas/template/blocks/spacerBlockSchema.d.ts +18 -10
  22. package/dist/types/src/landing-page-editor/schemas/template/blocks/textBlockSchema.d.ts +9 -1
  23. package/dist/types/src/landing-page-editor/schemas/template/blocks/videoBlockSchema.d.ts +9 -1
  24. package/dist/types/src/landing-page-editor/schemas/template/commonSchema.d.ts +28 -8
  25. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarCTASchema.d.ts +335 -0
  26. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarHamburgerSchema.d.ts +1109 -0
  27. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarLogoSchema.d.ts +252 -0
  28. package/dist/types/src/landing-page-editor/schemas/template/navbarBlocks/navbarMenuSchema.d.ts +1209 -0
  29. package/dist/types/src/landing-page-editor/schemas/template/settingsSchema.d.ts +4058 -546
  30. package/dist/types/src/landing-page-editor/schemas/template/structure/blockSchema.d.ts +5007 -2328
  31. package/dist/types/src/landing-page-editor/schemas/template/structure/columnSchema.d.ts +5501 -2412
  32. package/dist/types/src/landing-page-editor/schemas/template/structure/navbarSchema.d.ts +4394 -0
  33. package/dist/types/src/landing-page-editor/schemas/template/structure/rowSchema.d.ts +11094 -0
  34. package/dist/types/src/landing-page-editor/schemas/template/structure/sectionSchema.d.ts +8602 -3337
  35. package/dist/types/src/landing-page-editor/schemas/template/styleSchema.d.ts +55 -44
  36. package/dist/types/src/landing-page-editor/schemas/templateSchema.d.ts +34865 -48464
  37. package/dist/types/src/landing-page-editor/schemas/templateSettings/templateSettingsSchema.d.ts +4304 -794
  38. package/dist/types/src/landing-page-editor/schemas/theme/themeSchema.d.ts +6 -1
  39. package/dist/types/src/landing-page-editor/schemas/utils/cssValue.d.ts +21 -0
  40. package/dist/types/src/landing-page-editor/schemas/utils/transformBorder.d.ts +10 -5
  41. package/dist/types/src/main.d.ts +28 -108
  42. package/dist/types/types/API/API.d.ts +8 -9
  43. package/dist/types/types/APIBlocks/APIBlocks.d.ts +9 -0
  44. package/dist/types/types/Auth/IAuthorize.d.ts +6 -0
  45. package/dist/types/types/Auth/INonceAuthCallbacks.d.ts +10 -0
  46. package/dist/types/types/Callbacks/ICallbackPayloads.d.ts +27 -23
  47. package/dist/types/types/Callbacks/IEmailCallbacks.d.ts +73 -155
  48. package/dist/types/types/Cloud/ICloudOptions.d.ts +32 -0
  49. package/dist/types/types/ContentBlock/IContentBlockOptions.d.ts +1 -1
  50. package/dist/types/types/Countdown/ICountdownOptions.d.ts +48 -0
  51. package/dist/types/types/{ITopolOptions.d.ts → IEmailConfig.d.ts} +80 -28
  52. package/dist/types/types/IEmailEditorInstance.d.ts +64 -0
  53. package/dist/types/types/IEmailOptions.d.ts +7 -0
  54. package/dist/types/types/Language/Language.d.ts +1 -1
  55. package/dist/types/types/MergeTag/IMergeTag.d.ts +18 -0
  56. package/dist/types/types/Notification/INotification.d.ts +2 -1
  57. package/dist/types/types/Sections/ISections.d.ts +41 -0
  58. package/dist/types/types/Shortcuts/EditorShortcut.d.ts +4 -0
  59. package/dist/types/types/Theme/ITheme.d.ts +12 -2
  60. package/dist/types/types/landing-page/ILandingPageEditorInstance.d.ts +65 -5
  61. package/dist/types/types/landing-page/ILandingPageOptions.d.ts +105 -69
  62. package/logo.svg +1 -0
  63. package/package.json +11 -13
  64. package/dist/topol-plugin.es.js +0 -284
  65. package/dist/topol-plugin.umd.js +0 -1
  66. package/dist/types/src/landing-page-editor/schemas/helpdesk/helpdeskSchema.d.ts +0 -8
  67. package/dist/types/src/landing-page-editor/schemas/premadeBlock/premadeBlockSchema.d.ts +0 -59750
  68. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockApiSchema.d.ts +0 -44831
  69. package/dist/types/src/landing-page-editor/schemas/savedBlock/savedBlockSchema.d.ts +0 -59725
  70. package/dist/types/src/landing-page-editor/schemas/template/blocks/index.d.ts +0 -12
  71. package/dist/types/types/ITopolPlugin.d.ts +0 -44
  72. package/dist/types/types/SavedBlock/ISavedBlock.d.ts +0 -6
@@ -1,109 +1,145 @@
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
22
- */
23
- onSaveAndClose?(json: unknown, html: unknown): void;
24
- /**
25
- * Called after a template has been loaded into the editor via `load()`.
26
- *
27
- * Note: this is NOT an "editor ready" signal. The runtime does not currently emit a
28
- * separate ready event; `render()` resolving is the closest equivalent, and `load()`
29
- * can be called as soon as `render()` resolves.
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.
30
54
  */
31
- onLoaded?(): void;
55
+ onSave?(payload: ILandingPageSavePayload): void | Promise<void>;
32
56
  /**
33
- * Called when the editor is initialized.
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.
34
60
  */
35
- onInit?(): void;
61
+ onSaveAndClose?(payload: ILandingPageSavePayload): void | Promise<void>;
36
62
  /**
37
- * Called when the user closes the editor.
63
+ * Called when the custom file manager should be opened.
38
64
  */
39
- onClose?(): void;
65
+ onOpenFileManager?(): void;
40
66
  /**
41
- * Called when the user clicks the banner.
42
- * @param json - The landing page JSON structure
43
- * @param html - The generated HTML output
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.
44
69
  */
45
- onBannerClick?(json: unknown, html: unknown): void;
70
+ onImageDelete?(payload: {
71
+ items: ILandingPageDeletedItem[];
72
+ }): void;
46
73
  /**
47
- * Called when the custom file manager should be opened.
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.
48
77
  */
49
- onOpenFileManager?(): void;
78
+ onLoaded?(): void;
50
79
  /**
51
- * Called when a block is saved.
52
- * @param block - The saved block section
80
+ * Called once the editor is fully initialized and ready.
53
81
  */
54
- onBlockSave?(block: TopolSection): void;
82
+ onInit?(): void;
55
83
  /**
56
- * Called when a block is removed.
57
- * @param blockId - The ID of the removed block
84
+ * Called when the undo stack changes. `count` is the number of undo steps available.
58
85
  */
59
- onBlockRemove?(blockId: number | string): void;
86
+ onUndoChange?(payload: {
87
+ count: number;
88
+ }): void;
60
89
  /**
61
- * Called when a block is being edited.
62
- * @param blockId - The ID of the block being edited
90
+ * Called when the redo stack changes. `count` is the number of redo steps available.
63
91
  */
64
- onBlockEdit?(blockId: number | string): void;
92
+ onRedoChange?(payload: {
93
+ count: number;
94
+ }): void;
65
95
  /**
66
- * Called when the undo stack changes.
67
- * @param count - Number of undo steps available
96
+ * Called when the user requests a preview. `html` is the rendered page.
68
97
  */
69
- onUndoChange?(count: number): void;
98
+ onPreview?(payload: {
99
+ html: string;
100
+ }): void;
70
101
  /**
71
- * Called when the redo stack changes.
72
- * @param count - Number of redo steps available
102
+ * Called when the preview is closed.
73
103
  */
74
- onRedoChange?(count: number): void;
104
+ onPreviewClose?(): void;
75
105
  /**
76
- * Called when the user requests a preview.
77
- * @param html - The preview HTML
106
+ * Called when an alert/notification is triggered.
78
107
  */
79
- onPreview?(html: unknown): void;
108
+ onAlert?(payload: {
109
+ notification: INotification;
110
+ }): void;
80
111
  /**
81
- * Called when an alert/notification is triggered.
82
- * @param notification - The notification object
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()`.
83
117
  */
84
- onAlert?(notification: INotification): void;
118
+ onEditorClose?(): void | Promise<void>;
85
119
  /**
86
- * Called when the edited-without-save state changes.
87
- * @param hasChanges - Whether there are unsaved changes
120
+ * Called when the unsaved-changes state flips. `hasUnsavedChanges` is `true` while there are unsaved edits.
88
121
  */
89
- onEdittedWithoutSaveChanged?(hasChanges: boolean): void;
122
+ onUnsavedChangesChange?(payload: {
123
+ hasUnsavedChanges: boolean;
124
+ }): void;
90
125
  /**
91
- * Called when a custom block dialog should be opened.
92
- * @param blockData - The custom block data
126
+ * Called when a custom block dialog should be opened. `block` is the custom block data.
93
127
  */
94
- onOpenCustomBlockDialog?(blockData: unknown): void;
128
+ onOpenCustomBlockDialog?(payload: {
129
+ block: unknown;
130
+ }): void;
95
131
  /**
96
- * Called when the template is renamed.
97
- * @param newName - The new template name
132
+ * Called when the user clicks the rename button. `name` is the current template name.
98
133
  */
99
- onTemplateRename?(newName: string): void;
134
+ onTemplateRename?(payload: {
135
+ name: string;
136
+ }): void;
100
137
  /**
101
- * Called when an error occurs.
102
- * @param type - The error type
103
- * @param message - The error message
104
- * @param responseBody - The response body (optional)
138
+ * Called when an error occurs in the editor.
139
+ *
140
+ * Named `onEditorError` because the underlying loader reserves `onError` for its own lifecycle.
105
141
  */
106
- onError?(type: string, message: string, responseBody?: unknown): void;
142
+ onEditorError?(payload: ILandingPageErrorPayload): void;
107
143
  }
108
144
  /**
109
145
  * Configuration options for the Landing Page Editor.
@@ -113,7 +149,7 @@ export default interface ILandingPageOptions extends ILandingPageCallbacks {
113
149
  /**
114
150
  * Editor configuration options.
115
151
  */
116
- config: IPluginOptions;
152
+ config: ILandingPageConfig;
117
153
  }
118
- export type { IPluginOptions };
154
+ export type { ILandingPageConfig };
119
155
  export type { LambdaStage, UserRole } from "../../src/landing-page-editor/schemas/pluginOptions/pluginOptionsSchema";
package/logo.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="391" height="100" viewBox="0 0 391 100" fill="none" role="img" aria-label="Topol"><title>Topol</title><path d="M198.658 24.5069C194.15 21.9659 188.894 20.6954 182.903 20.6954C176.911 20.6954 171.655 21.9659 167.103 24.5069C162.561 27.0478 159.024 30.5918 156.525 35.161C154.003 39.7192 152.765 45.024 152.765 51.0755C152.765 57.1269 154.014 62.376 156.558 66.9341C159.08 71.5034 162.617 75.0474 167.136 77.5883C171.678 80.1293 176.922 81.3998 182.914 81.3998C188.906 81.3998 194.116 80.1293 198.635 77.5883C203.177 75.0474 206.703 71.5034 209.224 66.9341C211.746 62.376 213.018 57.0824 213.018 51.0755C213.018 45.0685 211.746 39.7192 209.224 35.161C206.703 30.5918 203.177 27.0478 198.658 24.5069ZM198.011 60.604C196.593 63.3233 194.585 65.4296 192.008 66.9119C189.43 68.4052 186.395 69.1519 182.914 69.1519C179.432 69.1519 176.386 68.4052 173.798 66.9119C171.209 65.4296 169.2 63.3233 167.772 60.604C166.344 57.8848 165.641 54.7086 165.641 51.0755C165.641 47.4423 166.344 44.2216 167.772 41.5134C169.2 38.8165 171.198 36.699 173.775 35.2056C176.353 33.7011 179.399 32.9433 182.914 32.9433C186.428 32.9433 189.43 33.7011 192.008 35.2056C194.585 36.699 196.593 38.8165 198.011 41.5134C199.439 44.2216 200.153 47.3978 200.153 51.0755C200.153 54.7532 199.439 57.8959 198.011 60.604ZM332.387 24.5069C327.879 21.9659 322.635 20.6954 316.643 20.6954C310.651 20.6954 305.384 21.9659 300.843 24.5069C296.291 27.0478 292.753 30.5918 290.254 35.161C287.744 39.7192 286.494 45.024 286.494 51.0755C286.494 57.1269 287.755 62.376 290.288 66.9341C292.809 71.5034 296.335 75.0474 300.876 77.5883C305.407 80.1293 310.651 81.3998 316.654 81.3998C322.657 81.3998 327.834 80.1293 332.376 77.5883C336.906 75.0474 340.432 71.5034 342.953 66.9341C345.475 62.376 346.747 57.0824 346.747 51.0755C346.747 45.0685 345.475 39.7192 342.953 35.161C340.432 30.5918 336.906 27.0478 332.387 24.5069ZM331.751 60.604C330.323 63.3233 328.325 65.4296 325.748 66.9119C323.159 68.4052 320.124 69.1519 316.654 69.1519C313.184 69.1519 310.126 68.4052 307.527 66.9119C304.938 65.4296 302.93 63.3233 301.501 60.604C300.084 57.8848 299.37 54.7086 299.37 51.0755C299.37 47.4423 300.084 44.2216 301.501 41.5134C302.93 38.8165 304.927 36.699 307.504 35.2056C310.082 33.7011 313.139 32.9433 316.654 32.9433C320.169 32.9433 323.159 33.7011 325.748 35.2056C328.325 36.699 330.323 38.8165 331.751 41.5134C333.168 44.2216 333.882 47.3978 333.882 51.0755C333.882 54.7532 333.168 57.8959 331.751 60.604ZM267.971 24.44C263.798 21.9436 258.889 20.6954 253.276 20.6954C248.043 20.6954 243.591 21.8656 239.942 24.1837C236.963 26.0782 234.575 28.7195 232.768 32.0517V21.8767H219.3V100H232.768V69.464C234.575 72.7962 236.952 75.4263 239.942 77.3208C243.591 79.6612 248.043 80.8091 253.276 80.8091C258.889 80.8091 263.798 79.5609 267.971 77.0311C272.156 74.5236 275.414 71.0019 277.757 66.4772C280.1 61.9637 281.283 56.7034 281.283 50.7188C281.283 44.7342 280.1 39.474 277.757 34.9604C275.414 30.4358 272.145 26.9252 267.971 24.44ZM266.186 60.1137C264.736 62.7995 262.694 64.8724 260.072 66.3435C257.449 67.8257 254.359 68.5612 250.81 68.5612C247.262 68.5612 244.171 67.8257 241.549 66.3435C238.916 64.8724 236.874 62.7995 235.435 60.1137C233.984 57.439 233.248 54.3185 233.248 50.7411C233.248 47.1637 233.973 43.9987 235.435 41.3351C236.874 38.6827 238.916 36.6098 241.549 35.1499C244.171 33.6788 247.262 32.9544 250.81 32.9544C254.359 32.9544 257.483 33.69 260.094 35.1499C262.705 36.6098 264.724 38.6827 266.186 41.3574C267.626 44.0321 268.362 47.1526 268.362 50.7411C268.362 54.3297 267.637 57.4501 266.186 60.1137ZM391 66.7781V80.2407H366.408V66.7781H391ZM366.397 0V66.7781H352.918V0H366.397ZM127.38 21.7096H149.607V35.1722H127.38V66.7893H113.79V0H127.38V21.7096ZM127.38 66.7781H147.152V80.2407H127.38V66.7781ZM80.3379 66.8004V80.263H60.2534V66.8004H80.3379ZM0 66.8004H20.0845V80.263H0V66.8004ZM0.0223161 50.1727V30.1126H20.0845V50.1727H0.0223161ZM60.2534 50.1727V30.1126H20.0845V13.4849H60.2534V30.1126H80.3044V50.1727H60.2534ZM20.0845 50.1727H60.2534V66.8004H20.0845V50.1727ZM0 13.4738V0.0222891H20.0845V13.4849L0 13.4738ZM80.3379 13.4738H60.2534V0.0222891H80.3379V13.4738Z" fill="#000000"/></svg>
package/package.json CHANGED
@@ -12,28 +12,24 @@
12
12
  "author": "Topol.io",
13
13
  "homepage": "https://topol.io",
14
14
  "license": "Apache-2.0",
15
- "version": "1.0.0-alpha.8",
15
+ "version": "1.0.0",
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "logo.svg"
18
19
  ],
19
20
  "type": "module",
20
- "module": "./dist/topol-plugin.es.js",
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.js",
21
23
  "types": "./dist/types/src/main.d.ts",
22
24
  "exports": {
23
25
  ".": {
24
26
  "types": "./dist/types/src/main.d.ts",
25
- "import": "./dist/topol-plugin.es.js",
26
- "require": "./dist/topol-plugin.umd.js"
27
+ "default": "./dist/index.js"
27
28
  }
28
29
  },
29
30
  "devDependencies": {
30
31
  "@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
32
  "happy-dom": "^20.0.11",
36
- "prettier": "3.1.1",
37
33
  "typescript": "^5.2.2",
38
34
  "vite": "^5.0.11",
39
35
  "vitest": "^4.0.16"
@@ -49,10 +45,12 @@
49
45
  "dev": "vite",
50
46
  "build-watch": "vite build --watch",
51
47
  "build-with-types": "vite build && pnpm run build:types",
52
- "lint": "eslint --no-eslintrc --config '.eslintrc.cjs' 'src/**/*.ts' --fix",
53
- "format": "prettier --write .",
48
+ "lint": "oxlint --deny-warnings .",
49
+ "format": "oxfmt --write .",
54
50
  "build:types": "tsc -p tsconfig.prod.json",
55
51
  "test": "vitest run",
56
- "test:watch": "vitest"
52
+ "test:watch": "vitest",
53
+ "lint:fix": "oxlint --fix --deny-warnings .",
54
+ "format:check": "oxfmt --check ."
57
55
  }
58
56
  }
@@ -1,284 +0,0 @@
1
- function T(e) {
2
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
- }
4
- var P = function(n, o, t) {
5
- var r = document.head || document.getElementsByTagName("head")[0], i = document.createElement("script");
6
- typeof o == "function" && (t = o, o = {}), o = o || {}, t = t || function() {
7
- }, i.type = o.type || "text/javascript", i.charset = o.charset || "utf8", i.async = "async" in o ? !!o.async : !0, i.src = n, o.attrs && m(i, o.attrs), o.text && (i.text = "" + o.text);
8
- var l = "onload" in i ? p : E;
9
- l(i, t), i.onload || p(i, t), r.appendChild(i);
10
- };
11
- function m(e, n) {
12
- for (var o in n)
13
- e.setAttribute(o, n[o]);
14
- }
15
- function p(e, n) {
16
- e.onload = function() {
17
- this.onerror = this.onload = null, n(null, e);
18
- }, e.onerror = function() {
19
- this.onerror = this.onload = null, n(new Error("Failed to load " + this.src), e);
20
- };
21
- }
22
- function E(e, n) {
23
- e.onreadystatechange = function() {
24
- this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, n(null, e));
25
- };
26
- }
27
- const g = /* @__PURE__ */ T(P);
28
- var u = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
29
- const h = "https://v3.email-assets.topol.io/loader/build.js", L = "https://v3.develop.email-assets.topol.io/loader/build.js", v = "https://v3.develop.email-assets.topol.io/loader/build.js", a = {
30
- production: u.VITE_TOPOL_URL || h,
31
- dev: u.VITE_TOPOL_DEV_URL || L,
32
- staging: u.VITE_TOPOL_STAGING_URL || v
33
- }, y = "https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";
34
- function _(e) {
35
- switch (e) {
36
- case "dev":
37
- return a.dev;
38
- case "staging":
39
- return a.staging;
40
- case "production":
41
- return a.production;
42
- default:
43
- return y.replace("{stage}", String(e));
44
- }
45
- }
46
- function S(e = "production") {
47
- const n = _(e);
48
- if (!n) {
49
- if (a.production)
50
- return console.error(`[@topol.io/editor] No loader URL resolved for stage "${e}"; falling back to the production loader.`), a.production;
51
- throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${e}". The editor cannot be loaded.`);
52
- }
53
- return n;
54
- }
55
- async function A(e) {
56
- return new Promise((n, o) => {
57
- g(a.production, (t) => {
58
- if (t !== null) {
59
- o(t);
60
- return;
61
- }
62
- window.TopolPlugin.init(e), n(!0);
63
- });
64
- });
65
- }
66
- const R = {
67
- /**
68
- * Initialize the Email Editor.
69
- * @param topolOptions - Configuration options for the editor
70
- * @param options - Plugin options including stage selection
71
- * @returns Promise that resolves to true when the editor is ready
72
- */
73
- init: (e, n) => new Promise((o, t) => {
74
- const r = S(n == null ? void 0 : n.stage);
75
- g(r, async (i) => {
76
- if (i !== null) {
77
- if (r !== a.production)
78
- try {
79
- return await A(e), o(!0);
80
- } catch (l) {
81
- t(l);
82
- }
83
- t(i);
84
- return;
85
- }
86
- window.TopolPlugin.init(e), o(!0);
87
- });
88
- }),
89
- /** Trigger the save callback with current editor content */
90
- save: (e) => {
91
- window.TopolPlugin.save(e);
92
- },
93
- /** Load a template JSON into the editor */
94
- load: (e) => {
95
- window.TopolPlugin.load(e);
96
- },
97
- /** Toggle the preview mode */
98
- togglePreview: () => {
99
- window.TopolPlugin.togglePreview();
100
- },
101
- /** Toggle between desktop and mobile preview sizes */
102
- togglePreviewSize: () => {
103
- window.TopolPlugin.togglePreviewSize();
104
- },
105
- /** Select a file from the custom file manager */
106
- chooseFile: (e) => {
107
- window.TopolPlugin.chooseFile(e);
108
- },
109
- /** Undo the last action */
110
- undo: () => {
111
- window.TopolPlugin.undo();
112
- },
113
- /** Redo the last undone action */
114
- redo: () => {
115
- window.TopolPlugin.redo();
116
- },
117
- /** Destroy the editor instance and clean up resources */
118
- destroy: () => {
119
- window.TopolPlugin.destroy();
120
- },
121
- /** Update the list of saved/reusable blocks */
122
- setSavedBlocks: (e) => {
123
- window.TopolPlugin.setSavedBlocks(e);
124
- },
125
- /** Set custom HTML for the preview */
126
- setPreviewHTML: (e) => {
127
- window.TopolPlugin.setPreviewHTML(e);
128
- },
129
- /** Display a notification in the editor */
130
- createNotification: (e) => {
131
- window.TopolPlugin.createNotification(e);
132
- },
133
- /** Set the list of active collaboration members */
134
- setActiveMembers: (e) => {
135
- window.TopolPlugin.setActiveMembers(e);
136
- },
137
- /** Switch to mobile view */
138
- changeEmailToMobile: () => {
139
- window.TopolPlugin.changeEmailToMobile();
140
- },
141
- /** Switch to desktop view */
142
- changeEmailToDesktop: () => {
143
- window.TopolPlugin.changeEmailToDesktop();
144
- },
145
- /** Toggle visibility of hidden blocks and structures */
146
- toggleBlocksAndStructuresVisibility: () => {
147
- window.TopolPlugin.toggleBlocksAndStructuresVisibility();
148
- },
149
- /** Update the content of a custom block */
150
- updateCustomBlockContent: (e) => {
151
- window.TopolPlugin.updateCustomBlockContent(e);
152
- },
153
- /** Refresh comments/conversations */
154
- refreshComments: (e) => {
155
- window.TopolPlugin.refreshComments(e);
156
- },
157
- /** Refresh synced rows */
158
- refreshSyncedRows: () => {
159
- window.TopolPlugin.refreshSyncedRows();
160
- },
161
- /** Open the premade templates selection modal */
162
- openPremadeTemplatesSelection: () => {
163
- window.TopolPlugin.openPremadeTemplatesSelection();
164
- },
165
- /** Update the API authorization header */
166
- updateApiAuthorizationHeader: (e) => {
167
- window.TopolPlugin.updateApiAuthorizationHeader(e);
168
- },
169
- /** Set the template name/title */
170
- setTemplateName: (e) => {
171
- window.TopolPlugin.setTemplateName(e);
172
- },
173
- updateOptions: (e) => {
174
- window.TopolPlugin.updateOptions(e);
175
- },
176
- /** Toggle the AI chat feature */
177
- toggleChatAI: () => {
178
- window.TopolPlugin.toggleChatAI();
179
- },
180
- /** Toggle the autosaves feature */
181
- toggleAutosaves: () => {
182
- window.TopolPlugin.toggleAutosaves();
183
- },
184
- /** Toggle the comments panel */
185
- toggleComments: () => {
186
- window.TopolPlugin.toggleComments();
187
- },
188
- /** Create a new language variant */
189
- createLanguage: (e) => {
190
- window.TopolPlugin.createLanguage(e);
191
- },
192
- /** Set the primary language */
193
- setPrimaryLanguage: (e) => {
194
- window.TopolPlugin.setPrimaryLanguage(e);
195
- },
196
- /** Delete a language variant */
197
- deleteLanguage: (e) => {
198
- window.TopolPlugin.deleteLanguage(e);
199
- },
200
- /** Select/switch to a language */
201
- selectLanguage: (e) => {
202
- window.TopolPlugin.selectLanguage(e);
203
- },
204
- /** Get the list of mutations */
205
- getMutations: () => window.TopolPlugin.getMutations(),
206
- /** Toggle the control panel visibility */
207
- toggleControlPanel: () => {
208
- window.TopolPlugin.toggleControlPanel();
209
- },
210
- /** Update the editor template with new JSON data */
211
- updateTemplate: (e, n) => {
212
- window.TopolPlugin.updateTemplate(e, n);
213
- },
214
- /** Toggle dark mode for the editor */
215
- toggleDarkMode: () => {
216
- window.TopolPlugin.toggleDarkMode();
217
- }
218
- }, O = "https://v1.page-assets.topol.io/topol-lpe.js", s = /* @__PURE__ */ new Map();
219
- function D(e, n) {
220
- if (n())
221
- return Promise.resolve();
222
- const o = s.get(e);
223
- if (o)
224
- return o;
225
- const t = new Promise((r, i) => {
226
- const l = typeof document < "u" ? U(e) : null;
227
- if (l) {
228
- const d = () => {
229
- w(), r();
230
- }, c = () => {
231
- w(), i(new Error(`Failed to load script: ${e}`));
232
- }, w = () => {
233
- l.removeEventListener("load", d), l.removeEventListener("error", c);
234
- };
235
- l.addEventListener("load", d), l.addEventListener("error", c);
236
- return;
237
- }
238
- g(e, (d) => {
239
- d !== null ? i(d) : r();
240
- });
241
- }).finally(() => {
242
- s.delete(e);
243
- });
244
- return s.set(e, t), t;
245
- }
246
- function U(e) {
247
- const n = document.getElementsByTagName("script");
248
- for (let o = 0; o < n.length; o++)
249
- if (n[o].src === e)
250
- return n[o];
251
- return null;
252
- }
253
- function f() {
254
- return typeof window < "u" && typeof window.LandingPageEditor == "function";
255
- }
256
- const C = {
257
- /**
258
- * Inits Landing Page Editor.
259
- *
260
- * @param options - Configuration options for the editor
261
- * @param pluginOptions - Plugin options (reserved for future staging/dev URL support)
262
- * @returns Promise that resolves with the editor instance
263
- */
264
- init: async (e, n) => {
265
- var i;
266
- if (await D(O, f), !f())
267
- throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");
268
- let o = !1;
269
- const t = window.LandingPageEditor({
270
- ...e,
271
- onClose() {
272
- var l;
273
- o || (l = e.onClose) == null || l.call(e);
274
- }
275
- }), r = ((i = t.destroy) == null ? void 0 : i.bind(t)) ?? (() => t.close());
276
- return t.destroy = () => (o = !0, r()), t;
277
- }
278
- }, I = R;
279
- export {
280
- R as EmailEditor,
281
- C as LandingPageEditor,
282
- I as TopolPlugin,
283
- I as default
284
- };
@@ -1 +0,0 @@
1
- (function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r["topol-plugin"]={}))})(this,function(r){"use strict";function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var L=function(n,o,t){var a=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");typeof o=="function"&&(t=o,o={}),o=o||{},t=t||function(){},i.type=o.type||"text/javascript",i.charset=o.charset||"utf8",i.async="async"in o?!!o.async:!0,i.src=n,o.attrs&&h(i,o.attrs),o.text&&(i.text=""+o.text);var l="onload"in i?w:v;l(i,t),i.onload||w(i,t),a.appendChild(i)};function h(e,n){for(var o in n)e.setAttribute(o,n[o])}function w(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 v(e,n){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,e))}}const g=u(L);var c={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const d={production:c.VITE_TOPOL_URL||"https://v3.email-assets.topol.io/loader/build.js",dev:c.VITE_TOPOL_DEV_URL||"https://v3.develop.email-assets.topol.io/loader/build.js",staging:c.VITE_TOPOL_STAGING_URL||"https://v3.develop.email-assets.topol.io/loader/build.js"},_="https://d10h8ga60f7b91.cloudfront.net/preview-app-{stage}/loader/build.js";function y(e){switch(e){case"dev":return d.dev;case"staging":return d.staging;case"production":return d.production;default:return _.replace("{stage}",String(e))}}function A(e="production"){const n=y(e);if(!n){if(d.production)return console.error(`[@topol.io/editor] No loader URL resolved for stage "${e}"; falling back to the production loader.`),d.production;throw new Error(`[@topol.io/editor] Could not resolve a loader URL for stage "${e}". The editor cannot be loaded.`)}return n}async function S(e){return new Promise((n,o)=>{g(d.production,t=>{if(t!==null){o(t);return}window.TopolPlugin.init(e),n(!0)})})}const f={init:(e,n)=>new Promise((o,t)=>{const a=A(n==null?void 0:n.stage);g(a,async i=>{if(i!==null){if(a!==d.production)try{return await S(e),o(!0)}catch(l){t(l)}t(i);return}window.TopolPlugin.init(e),o(!0)})}),save:e=>{window.TopolPlugin.save(e)},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)},updateOptions:e=>{window.TopolPlugin.updateOptions(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)},getMutations:()=>window.TopolPlugin.getMutations(),toggleControlPanel:()=>{window.TopolPlugin.toggleControlPanel()},updateTemplate:(e,n)=>{window.TopolPlugin.updateTemplate(e,n)},toggleDarkMode:()=>{window.TopolPlugin.toggleDarkMode()}},R="https://v1.page-assets.topol.io/topol-lpe.js",p=new Map;function U(e,n){if(n())return Promise.resolve();const o=p.get(e);if(o)return o;const t=new Promise((a,i)=>{const l=typeof document<"u"?D(e):null;if(l){const s=()=>{E(),a()},m=()=>{E(),i(new Error(`Failed to load script: ${e}`))},E=()=>{l.removeEventListener("load",s),l.removeEventListener("error",m)};l.addEventListener("load",s),l.addEventListener("error",m);return}g(e,s=>{s!==null?i(s):a()})}).finally(()=>{p.delete(e)});return p.set(e,t),t}function D(e){const n=document.getElementsByTagName("script");for(let o=0;o<n.length;o++)if(n[o].src===e)return n[o];return null}function T(){return typeof window<"u"&&typeof window.LandingPageEditor=="function"}const O={init:async(e,n)=>{var i;if(await U(R,T),!T())throw new Error("[@topol.io/editor] topol-lpe.js loaded but window.LandingPageEditor is not defined.");let o=!1;const t=window.LandingPageEditor({...e,onClose(){var l;o||(l=e.onClose)==null||l.call(e)}}),a=((i=t.destroy)==null?void 0:i.bind(t))??(()=>t.close());return t.destroy=()=>(o=!0,a()),t}},P=f;r.EmailEditor=f,r.LandingPageEditor=O,r.TopolPlugin=P,r.default=P,Object.defineProperties(r,{__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>;