@topol.io/editor-vue 1.0.0-alpha.1 → 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,107 +1,82 @@
1
- <a href="https://topol.io" target="_blank">
2
- <img src="https://storage.googleapis.com/topolio17326/plugin-assets/6320/17326/topol-with-bg.png" alt="Tailwind CSS" width="400" height="120">
3
- </a>
1
+ # @topol.io/editor-vue — 1.x alpha
4
2
 
5
- ---
3
+ Vue 3 wrapper for Email Editor v4, from the 1.x alpha line onward.
6
4
 
7
- Easy and quick! Drag and drop HTML editor and builder for beautiful responsive email templates.
8
-
9
- # Documentation
10
-
11
- ## Installation
12
-
13
- Install Editor from NPM using:
14
-
15
- ```sh
16
- npm install @topol.io/editor-vue
17
-
18
- //or
19
-
20
- yarn add @topol.io/editor-vue
21
- ```
22
-
23
- ## Use in Component
24
-
25
- In your Vue component import and add the simplest options.
26
-
27
- For more options see the docs for [TopolOptions configuration](https://docs.topol.io/reference/topol-options.html)
28
-
29
- ```js
30
- import { TopolEditor } from '@topol.io/editor-vue';
31
-
32
- const customOptions = {
33
- authorize: {
34
- apiKey: 'YOUR_API_TOKEN',
35
- userId: 'some-user-id',
5
+ ```vue
6
+ <script setup lang="ts">
7
+ import { EmailEditor, type IEmailCallbacks, type IVueEmailOptions } from "@topol.io/editor-vue";
8
+ const options: IVueEmailOptions = {
9
+ authorize: { apiKey: "pk_your-key", userId: "user-123" },
10
+ cloud: { enabled: true },
11
+ };
12
+ const callbacks: IEmailCallbacks = {
13
+ async getNonce() {
14
+ const response = await fetch("/api/topol/nonce", { method: "POST" });
15
+ if (!response.ok) throw new Error("Cloud authorization failed");
16
+ return (await response.json()).nonce;
36
17
  },
37
18
  };
19
+ </script>
20
+ <template>
21
+ <EmailEditor
22
+ :options="options"
23
+ :callbacks="callbacks"
24
+ @on-cloud-save="({ templateId }) => console.log(templateId)"
25
+ @on-editor-error="({ source, message }) => console.error(source, message)"
26
+ />
27
+ </template>
38
28
  ```
39
29
 
40
- ```html
41
- <TopolEditor :options="customOptions"></TopolEditor>
42
- ```
43
-
44
- ## Call Topol Plugin actions
30
+ Use the **`callbacks` prop for `getNonce` and asynchronous persistence**:
31
+ `callbacks.onSave = async ({ json, html }) => { await persist(json, html); }`.
32
+ Vue event handlers do not return promises to the editor. Events remain available
33
+ for notifications, with the exact core object payloads. If both a callback and an
34
+ event listener are provided, the callback runs first and its result is returned.
45
35
 
46
- To call actions to the editor import:
36
+ `@ready="editor => ..."` receives the instance. A component template ref exposes
37
+ `getEditor()`. `@on-save-and-close` is registered only when explicitly supplied;
38
+ without it or `callbacks.onSaveAndClose`, the runtime's default save-and-close works.
39
+ `getNonce` is a function callback only, never an event.
47
40
 
48
- ```js
49
- import { TopolPlugin } from '@topol.io/editor-vue';
41
+ `LandingPageEditor` and `CoreLandingPageEditor` retain their existing APIs.
42
+ `CoreEmailEditor` exposes the core v4 factory.
50
43
 
51
- TopolPlugin.save();
52
- ```
44
+ `options` contains the v4 configuration (`IEmailConfig`). A `getNonce` callback that
45
+ fetches a fresh `nc_` token from your application's authenticated backend enables
46
+ nonce authentication on its own; Cloud additionally requires it. Never put an `sk_`
47
+ secret in browser code. See the core package README for nonce authentication, Cloud
48
+ feature options, the Countdown block (`enableCountdown`, `countdown`; see the
49
+ [option reference](https://docs.topol.io/email-editor/reference/topol-options#countdown))
50
+ and all v4 renames.
53
51
 
54
- For more TopolPlugin functions refer to the [TopolPlugin actions](https://www.npmjs.com/package/@topol.io/editor#call-topol-plugin-actions)
52
+ Configuration and the presence of callback handlers are captured on mount. Remount
53
+ with a new key to change them; existing callback functions read their latest values.
54
+ `ready` means the iframe has rendered; `onInit` reports editor authentication.
55
+ Set the container's height. Each component owns its own instance and destroys it
56
+ on unmount, including when initialization is still pending.
55
57
 
56
- <br>
58
+ Use `loaderUrl` for an explicit v4 local/preview loader. A numeric `stage` selects
59
+ a PR preview. `TopolEditor` is a deprecated naming alias using the new v4 contract.
57
60
 
58
- ## Editor Events
61
+ ## Running the example against deployed Cloud
59
62
 
60
- The callbacks from editor are received as component events.
63
+ Merge `.env.example` into `example/.env.local` (Vite's development root). Set
64
+ `VITE_TOPOL_CLOUD_PUBLIC_KEY` and `VITE_TOPOL_CLOUD_SECRET_KEY` to a matching `pk_` / `sk_`
65
+ credential pair registered in the deployed backend, then start or restart Vite:
61
66
 
62
- ```html
63
- <TopolEditor
64
- :options="customOptions"
65
- @onSave="handleOnSave"
66
- ></TopolEditor>
67
+ ```sh
68
+ pnpm --filter @topol.io/editor-vue dev
67
69
  ```
68
70
 
69
- ### List of all editor events
70
-
71
- | Event | Description |
72
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
73
- | `@onSave` | Returns object which contains html and json of the template [more info](https://docs.topol.io/guide/callbacks.html#on-save) |
74
- | `@onSaveAndClose` | Returns object which contains html and json of the template [more info](https://docs.topol.io/guide/callbacks.html#on-save-and-close) |
75
- | `@onTestSend` | Returns object which contains email, html and json of the template [more info](https://docs.topol.io/guide/callbacks.html#on-test-email-send) |
76
- | `@onOpenFileManager` | When user clicks file manager open [more info](https://docs.topol.io/guide/custom-filemanager.html#onopenfilemanager) |
77
- | `@onLoaded` | After editor template is loaded using `TopolPlugin.load()` [more info](https://docs.topol.io/guide/callbacks.html#on-loaded) |
78
- | `@onInit` | When editor inits [more info](https://docs.topol.io/guide/callbacks.html#on-init) |
79
- | `@onBlockSave` | When user saves block in editor, returns object of type ISavedBlock [more info](https://docs.topol.io/guide/callbacks.html#on-block-save) |
80
- | `@onBlockRemove` | When user removes saved block, returns id of saved block to be removed [more info](https://docs.topol.io/guide/callbacks.html#on-block-remove) |
81
- | `@onBlockEdit` | When user edits saved block, returns id of saved block to be updated [more info](https://docs.topol.io/guide/callbacks.html#on-block-edit) |
82
- | `@onUndoChange` | When user clicks undo button, retunrs number of steps user undone [more info](https://docs.topol.io/guide/callbacks.html#on-undo-change) |
83
- | `@onRedoChange` | When user clicks redo button, retunrs number of steps user redone [more info](https://docs.topol.io/guide/callbacks.html#on-redo-change) |
84
- | `@onPreview` | When user switches to preview [more info](https://docs.topol.io/guide/callbacks.html#on-preview) |
85
- | `@onAlert` | When alert appears in editor [more info](https://docs.topol.io/guide/callbacks.html#on-alert) |
86
- | `@onClose` | When close is click inside WindowBar [more info](https://docs.topol.io/guide/top-bar.html#window-bar) |
87
- | `@onEdittedWithoutSaveChanged` | When user is about to leave an editor with unsaved changes [more info](https://docs.topol.io/guide/disable-before-leaving-modal.html#before-exit-modal-when-user-has-unsaved-changes) |
88
- | `@onOpenCustomBlockDialog` | When user clicks on the open dialog in custom block [more info](https://docs.topol.io/guide/custom-block.html#inserting-custom-html-in-custom-dialog-component) |
89
- | `@onTemplateRename` | When user clicks on the pencil icon next to the template name [more info](https://docs.topol.io/guide/rename-template.html#rename-template) |
90
- | `@updateTestingEmailAddresses` | When user edits the email list in preview [more info](https://docs.topol.io/guide/sending-a-test-email.html#managing-saving-emails-yourself) |
91
- | `@onError` | When an error that cannot be handled happened in the editor [more info](https://docs.topol.io/guide/callbacks.html#onerror) |
92
-
93
- <br>
94
-
95
- ## TypeScript
96
-
97
- Topol Editor provides full TypeScript integration and exports all necessary types.
98
-
99
- ```vue
100
- <script setup lang="ts">
101
- import {
102
- ITopolOptions,
103
- INotification,
104
- ISavedBlock,
105
- } from '@topol.io/editor-vue';
106
- </script>
107
- ```
71
+ The example uses the production v4 loader at
72
+ `https://v4.email-assets.topol.io/loader/build.js` and defaults to user `42`
73
+ (override with `VITE_TOPOL_CLOUD_USER_ID`). Its `callbacks.getNonce` calls
74
+ `POST https://9wh997i15a.execute-api.eu-central-1.amazonaws.com/auth/nonce`
75
+ directly from the browser. This testing-only example exposes the secret in the
76
+ frontend; use test credentials and do not deploy it. No local nonce endpoint or
77
+ Cloud backend is needed; a made-up nonce or the
78
+ local seed credentials cannot substitute for credentials registered in that backend.
79
+
80
+ The editor loader must use the same backend as `VITE_TOPOL_CLOUD_API_URL`.
81
+ `VITE_TOPOL_API_KEY` remains the landing-page example's key. Deployed
82
+ integrations need an authenticated backend that derives the user from the session.
@@ -1,226 +1,300 @@
1
- import { EmailEditor as v, LandingPageEditor as B } from "@topol.io/editor";
2
- import { EmailEditor as I, LandingPageEditor as D, default as M } from "@topol.io/editor";
3
- import { defineComponent as s, onMounted as g, onBeforeUnmount as u, createElementBlock as k, openBlock as p, ref as S, createBlock as O } from "vue";
4
- const C = "topol-email-editor-id", R = /* @__PURE__ */ s({
1
+ import { EmailEditor as A, LandingPageEditor as P } from "@topol.io/editor";
2
+ import { EmailEditor as O, LandingPageEditor as _, default as M } from "@topol.io/editor";
3
+ import { defineComponent as p, getCurrentInstance as h, ref as k, onMounted as b, onBeforeUnmount as f, createElementBlock as L, openBlock as T } from "vue";
4
+ const B = /* @__PURE__ */ p({
5
5
  __name: "EmailEditor",
6
6
  props: {
7
7
  options: {},
8
- stage: { default: "production" }
8
+ callbacks: {},
9
+ stage: { default: "production" },
10
+ loaderUrl: {}
9
11
  },
10
- emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses", "onError"],
11
- setup(l, { emit: r }) {
12
- const d = l, e = r, i = () => ({
13
- onSave(o, n) {
14
- e("onSave", { json: o, html: n });
15
- },
16
- onSaveAndClose(o, n) {
17
- e("onSaveAndClose", { json: o, html: n });
18
- },
19
- onTestSend(o, n, m) {
20
- e("onTestSend", { email: o, json: n, html: m });
21
- },
22
- onOpenFileManager() {
23
- e("onOpenFileManager");
24
- },
25
- onLoaded() {
26
- e("onLoaded");
27
- },
28
- onBlockSave(o) {
29
- e("onBlockSave", o);
30
- },
31
- onBlockRemove(o) {
32
- e("onBlockRemove", o);
33
- },
34
- onBlockEdit(o) {
35
- e("onBlockEdit", o);
36
- },
37
- onInit() {
38
- e("onInit");
39
- },
40
- onUndoChange(o) {
41
- e("onUndoChange", o);
42
- },
43
- onRedoChange(o) {
44
- e("onRedoChange", o);
45
- },
46
- onPreview(o) {
47
- e("onPreview", o);
48
- },
49
- onAlert(o) {
50
- e("onAlert", o);
51
- },
52
- onClose() {
53
- e("onClose");
54
- },
55
- onBannerClick(o, n) {
56
- e("onBannerClick", { json: o, html: n });
57
- },
58
- onEdittedWithoutSaveChanged(o) {
59
- e("onEdittedWithoutSaveChanged", o);
60
- },
61
- onOpenCustomBlockDialog(o) {
62
- e("onOpenCustomBlockDialog", o);
63
- },
64
- onTemplateRename(o) {
65
- e("onTemplateRename", o);
66
- },
67
- updateTestingEmailAddresses(o) {
68
- e("updateTestingEmailAddresses", o);
69
- },
70
- onError(o, n) {
71
- e("onError", { type: o, message: n });
72
- }
73
- });
74
- return g(async () => {
12
+ emits: ["ready", "onSave", "onSaveAndClose", "onTestSend", "onBannerClick", "onOpenFileManager", "onLoaded", "onSavedSectionSave", "onSavedSectionRemove", "onSavedSectionEdit", "onImageDelete", "onInit", "onUndoChange", "onRedoChange", "onPreview", "onPreviewClose", "onAlert", "onEditorClose", "onEdittedWithoutSaveChanged", "onBlocksAndStructuresVisibilityChange", "onOpenCustomBlockDialog", "onTemplateRename", "onTemplateUpdated", "updateTestingEmailAddresses", "onEditorError", "onLanguageCreated", "onLanguageDeleted", "onLanguageSelected", "onPrimaryLanguageChanged", "onGetMutations", "onCloudSave", "onCloudTemplateChange"],
13
+ setup(C, { expose: m, emit: S }) {
14
+ const a = C, r = S, v = h(), c = k();
15
+ let d, u = !1;
16
+ m({ getEditor: () => d ?? null });
17
+ const i = (s) => {
18
+ var n, o, e;
19
+ const l = `on${s[0].toUpperCase()}${s.slice(1)}`;
20
+ return !!((n = a.callbacks) != null && n[s]) || !!((o = v.vnode.props) != null && o[l]) || !!((e = v.vnode.props) != null && e[`${l}Once`]);
21
+ }, g = (s) => {
22
+ var n, o;
23
+ if (u) return;
24
+ const l = { source: "integration", message: s instanceof Error ? s.message : String(s), detail: s };
25
+ i("onEditorError") || console.error("[@topol.io/editor-vue] EmailEditor failed:", s), (o = (n = a.callbacks) == null ? void 0 : n.onEditorError) == null || o.call(n, l), r("onEditorError", l);
26
+ };
27
+ return b(async () => {
28
+ var l;
29
+ const s = {
30
+ onSave: i("onSave") ? (n) => {
31
+ var e, t;
32
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onSave) == null ? void 0 : t.call(e, n);
33
+ return r("onSave", n), o;
34
+ } : void 0,
35
+ onSaveAndClose: i("onSaveAndClose") ? (n) => {
36
+ var e, t;
37
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onSaveAndClose) == null ? void 0 : t.call(e, n);
38
+ return r("onSaveAndClose", n), o;
39
+ } : void 0,
40
+ onTestSend: i("onTestSend") ? (n) => {
41
+ var e, t;
42
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onTestSend) == null ? void 0 : t.call(e, n);
43
+ return r("onTestSend", n), o;
44
+ } : void 0,
45
+ onBannerClick: i("onBannerClick") ? (n) => {
46
+ var e, t;
47
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onBannerClick) == null ? void 0 : t.call(e, n);
48
+ return r("onBannerClick", n), o;
49
+ } : void 0,
50
+ onOpenFileManager: i("onOpenFileManager") ? () => {
51
+ var o, e;
52
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onOpenFileManager) == null ? void 0 : e.call(o);
53
+ return r("onOpenFileManager"), n;
54
+ } : void 0,
55
+ onLoaded: i("onLoaded") ? () => {
56
+ var o, e;
57
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onLoaded) == null ? void 0 : e.call(o);
58
+ return r("onLoaded"), n;
59
+ } : void 0,
60
+ onSavedSectionSave: i("onSavedSectionSave") ? (n) => {
61
+ var e, t;
62
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onSavedSectionSave) == null ? void 0 : t.call(e, n);
63
+ return r("onSavedSectionSave", n), o;
64
+ } : void 0,
65
+ onSavedSectionRemove: i("onSavedSectionRemove") ? (n) => {
66
+ var e, t;
67
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onSavedSectionRemove) == null ? void 0 : t.call(e, n);
68
+ return r("onSavedSectionRemove", n), o;
69
+ } : void 0,
70
+ onSavedSectionEdit: i("onSavedSectionEdit") ? (n) => {
71
+ var e, t;
72
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onSavedSectionEdit) == null ? void 0 : t.call(e, n);
73
+ return r("onSavedSectionEdit", n), o;
74
+ } : void 0,
75
+ onImageDelete: i("onImageDelete") ? (n) => {
76
+ var e, t;
77
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onImageDelete) == null ? void 0 : t.call(e, n);
78
+ return r("onImageDelete", n), o;
79
+ } : void 0,
80
+ onInit: i("onInit") ? () => {
81
+ var o, e;
82
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onInit) == null ? void 0 : e.call(o);
83
+ return r("onInit"), n;
84
+ } : void 0,
85
+ onUndoChange: i("onUndoChange") ? (n) => {
86
+ var e, t;
87
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onUndoChange) == null ? void 0 : t.call(e, n);
88
+ return r("onUndoChange", n), o;
89
+ } : void 0,
90
+ onRedoChange: i("onRedoChange") ? (n) => {
91
+ var e, t;
92
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onRedoChange) == null ? void 0 : t.call(e, n);
93
+ return r("onRedoChange", n), o;
94
+ } : void 0,
95
+ onPreview: i("onPreview") ? (n) => {
96
+ var e, t;
97
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onPreview) == null ? void 0 : t.call(e, n);
98
+ return r("onPreview", n), o;
99
+ } : void 0,
100
+ onPreviewClose: i("onPreviewClose") ? () => {
101
+ var o, e;
102
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onPreviewClose) == null ? void 0 : e.call(o);
103
+ return r("onPreviewClose"), n;
104
+ } : void 0,
105
+ onAlert: i("onAlert") ? (n) => {
106
+ var e, t;
107
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onAlert) == null ? void 0 : t.call(e, n);
108
+ return r("onAlert", n), o;
109
+ } : void 0,
110
+ onEditorClose: i("onEditorClose") ? () => {
111
+ var o, e;
112
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onEditorClose) == null ? void 0 : e.call(o);
113
+ return r("onEditorClose"), n;
114
+ } : void 0,
115
+ onEdittedWithoutSaveChanged: i("onEdittedWithoutSaveChanged") ? (n) => {
116
+ var e, t;
117
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onEdittedWithoutSaveChanged) == null ? void 0 : t.call(e, n);
118
+ return r("onEdittedWithoutSaveChanged", n), o;
119
+ } : void 0,
120
+ onBlocksAndStructuresVisibilityChange: i("onBlocksAndStructuresVisibilityChange") ? (n) => {
121
+ var e, t;
122
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onBlocksAndStructuresVisibilityChange) == null ? void 0 : t.call(e, n);
123
+ return r("onBlocksAndStructuresVisibilityChange", n), o;
124
+ } : void 0,
125
+ onOpenCustomBlockDialog: i("onOpenCustomBlockDialog") ? (n) => {
126
+ var e, t;
127
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onOpenCustomBlockDialog) == null ? void 0 : t.call(e, n);
128
+ return r("onOpenCustomBlockDialog", n), o;
129
+ } : void 0,
130
+ onTemplateRename: i("onTemplateRename") ? (n) => {
131
+ var e, t;
132
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onTemplateRename) == null ? void 0 : t.call(e, n);
133
+ return r("onTemplateRename", n), o;
134
+ } : void 0,
135
+ onTemplateUpdated: i("onTemplateUpdated") ? () => {
136
+ var o, e;
137
+ const n = (e = (o = a.callbacks) == null ? void 0 : o.onTemplateUpdated) == null ? void 0 : e.call(o);
138
+ return r("onTemplateUpdated"), n;
139
+ } : void 0,
140
+ updateTestingEmailAddresses: i("updateTestingEmailAddresses") ? (n) => {
141
+ var e, t;
142
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.updateTestingEmailAddresses) == null ? void 0 : t.call(e, n);
143
+ return r("updateTestingEmailAddresses", n), o;
144
+ } : void 0,
145
+ onEditorError: i("onEditorError") ? (n) => {
146
+ var e, t;
147
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onEditorError) == null ? void 0 : t.call(e, n);
148
+ return r("onEditorError", n), o;
149
+ } : void 0,
150
+ onLanguageCreated: i("onLanguageCreated") ? (n) => {
151
+ var e, t;
152
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onLanguageCreated) == null ? void 0 : t.call(e, n);
153
+ return r("onLanguageCreated", n), o;
154
+ } : void 0,
155
+ onLanguageDeleted: i("onLanguageDeleted") ? (n) => {
156
+ var e, t;
157
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onLanguageDeleted) == null ? void 0 : t.call(e, n);
158
+ return r("onLanguageDeleted", n), o;
159
+ } : void 0,
160
+ onLanguageSelected: i("onLanguageSelected") ? (n) => {
161
+ var e, t;
162
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onLanguageSelected) == null ? void 0 : t.call(e, n);
163
+ return r("onLanguageSelected", n), o;
164
+ } : void 0,
165
+ onPrimaryLanguageChanged: i("onPrimaryLanguageChanged") ? (n) => {
166
+ var e, t;
167
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onPrimaryLanguageChanged) == null ? void 0 : t.call(e, n);
168
+ return r("onPrimaryLanguageChanged", n), o;
169
+ } : void 0,
170
+ onGetMutations: i("onGetMutations") ? (n) => {
171
+ var e, t;
172
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onGetMutations) == null ? void 0 : t.call(e, n);
173
+ return r("onGetMutations", n), o;
174
+ } : void 0,
175
+ getNonce: (l = a.callbacks) != null && l.getNonce ? () => a.callbacks.getNonce() : void 0,
176
+ onCloudSave: i("onCloudSave") ? (n) => {
177
+ var e, t;
178
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onCloudSave) == null ? void 0 : t.call(e, n);
179
+ return r("onCloudSave", n), o;
180
+ } : void 0,
181
+ onCloudTemplateChange: i("onCloudTemplateChange") ? (n) => {
182
+ var e, t;
183
+ const o = (t = (e = a.callbacks) == null ? void 0 : e.onCloudTemplateChange) == null ? void 0 : t.call(e, n);
184
+ return r("onCloudTemplateChange", n), o;
185
+ } : void 0
186
+ };
75
187
  try {
76
- const o = {
77
- id: "#" + C,
78
- ...d.options,
79
- callbacks: i()
80
- };
81
- await v.init(o, { stage: d.stage });
82
- } catch (o) {
83
- const n = o instanceof Error ? o.message : "Failed to initialize editor";
84
- e("onError", { type: "init", message: n }), console.error("[@topol.io/editor-vue] EmailEditor initialization failed:", o);
188
+ const n = await A.init({ config: a.options, ...s }, { stage: a.stage, loaderUrl: a.loaderUrl });
189
+ if (u) {
190
+ await n.destroy();
191
+ return;
192
+ }
193
+ d = n;
194
+ try {
195
+ await n.render(c.value);
196
+ } catch (o) {
197
+ throw await n.destroy(), d = void 0, o;
198
+ }
199
+ u || r("ready", n);
200
+ } catch (n) {
201
+ g(n);
85
202
  }
86
- }), u(() => {
87
- v.destroy();
88
- }), (o, n) => (p(), k("div", {
89
- id: C,
90
- style: { position: "absolute", width: "100%", height: "100vh" }
91
- }));
203
+ }), f(() => {
204
+ u = !0;
205
+ const s = d;
206
+ d = void 0, s == null || s.destroy().catch((l) => console.warn("[@topol.io/editor-vue] EmailEditor cleanup failed:", l));
207
+ }), (s, l) => (T(), L("div", {
208
+ ref_key: "container",
209
+ ref: c,
210
+ style: { width: "100%", height: "100vh" }
211
+ }, null, 512));
92
212
  }
93
- }), E = "topol-landing-page-editor-id", f = /* @__PURE__ */ s({
213
+ }), E = "topol-landing-page-editor-id", R = /* @__PURE__ */ p({
94
214
  __name: "LandingPageEditor",
95
215
  props: {
96
216
  options: {},
97
217
  stage: { default: "production" }
98
218
  },
99
- emits: ["onSave", "onSaveAndClose", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "onError"],
100
- setup(l, { expose: r, emit: d }) {
101
- const e = l, i = d, o = S(null), n = () => ({
102
- onSave(t, a) {
103
- i("onSave", { json: t, html: a });
104
- },
105
- onSaveAndClose(t, a) {
106
- i("onSaveAndClose", { json: t, html: a });
107
- },
108
- onOpenFileManager() {
109
- i("onOpenFileManager");
110
- },
111
- onLoaded() {
112
- i("onLoaded");
113
- },
114
- onBlockSave(t) {
115
- i("onBlockSave", t);
116
- },
117
- onBlockRemove(t) {
118
- i("onBlockRemove", t);
119
- },
120
- onBlockEdit(t) {
121
- i("onBlockEdit", t);
122
- },
123
- onInit() {
124
- i("onInit");
125
- },
126
- onClose() {
127
- i("onClose");
128
- },
129
- onUndoChange(t) {
130
- i("onUndoChange", t);
131
- },
132
- onRedoChange(t) {
133
- i("onRedoChange", t);
134
- },
135
- onPreview(t) {
136
- i("onPreview", t);
137
- },
138
- onAlert(t) {
139
- i("onAlert", t);
140
- },
141
- onBannerClick(t, a) {
142
- i("onBannerClick", { json: t, html: a });
143
- },
144
- onEdittedWithoutSaveChanged(t) {
145
- i("onEdittedWithoutSaveChanged", t);
146
- },
147
- onOpenCustomBlockDialog(t) {
148
- i("onOpenCustomBlockDialog", t);
149
- },
150
- onTemplateRename(t) {
151
- i("onTemplateRename", t);
152
- },
153
- onError(t, a) {
154
- i("onError", { type: t, message: a });
155
- }
156
- });
157
- return g(async () => {
219
+ emits: ["onSave", "onSaveAndClose", "onOpenFileManager", "onImageDelete", "onLoaded", "onInit", "onUndoChange", "onRedoChange", "onPreview", "onPreviewClose", "onAlert", "onEditorClose", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "onEditorError"],
220
+ setup(C, { expose: m, emit: S }) {
221
+ const a = C, r = S, v = [
222
+ "onSave",
223
+ "onSaveAndClose",
224
+ "onOpenFileManager",
225
+ "onImageDelete",
226
+ "onLoaded",
227
+ "onInit",
228
+ "onUndoChange",
229
+ "onRedoChange",
230
+ "onPreview",
231
+ "onPreviewClose",
232
+ "onAlert",
233
+ "onEditorClose",
234
+ "onEdittedWithoutSaveChanged",
235
+ "onOpenCustomBlockDialog",
236
+ "onTemplateRename",
237
+ "onEditorError"
238
+ ], c = k(null), d = h(), u = (o) => {
239
+ const e = d == null ? void 0 : d.vnode.props;
240
+ if (!e) return !1;
241
+ const t = "on" + o.charAt(0).toUpperCase() + o.slice(1);
242
+ return typeof e[t] == "function" || Array.isArray(e[t]);
243
+ }, i = () => {
244
+ const o = {};
245
+ for (const e of v)
246
+ u(e) && (o[e] = (t) => {
247
+ t === void 0 ? r(e) : r(e, t);
248
+ });
249
+ return o;
250
+ };
251
+ let g = !1;
252
+ async function s(o) {
253
+ var e;
254
+ if (o)
255
+ try {
256
+ await ((e = o.destroy) == null ? void 0 : e.call(o));
257
+ } catch (t) {
258
+ console.warn("[@topol.io/editor-vue] LandingPageEditor destroy failed:", t);
259
+ }
260
+ }
261
+ return b(async () => {
158
262
  try {
159
- const t = await B.init({ config: e.options, ...n() }, { stage: e.stage });
160
- o.value = t, t.render("#" + E);
161
- } catch (t) {
162
- const a = t instanceof Error ? t.message : "Failed to initialize editor";
163
- i("onError", { type: "init", message: a }), console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:", t);
263
+ const o = await P.init({ config: a.options, ...i() }, { stage: a.stage });
264
+ if (g) {
265
+ await s(o);
266
+ return;
267
+ }
268
+ c.value = o, await o.render("#" + E);
269
+ } catch (o) {
270
+ if (g) return;
271
+ const e = o instanceof Error ? o.message : "Failed to initialize editor";
272
+ r("onEditorError", { source: "init", message: e, detail: o }), console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:", o);
164
273
  }
165
- }), u(() => {
166
- var t;
167
- (t = o.value) == null || t.destroy();
168
- }), r({
169
- load: (t) => {
170
- var a;
171
- (a = o.value) == null || a.load(t);
274
+ }), f(() => {
275
+ g = !0;
276
+ const o = c.value;
277
+ c.value = null, s(o);
278
+ }), m({
279
+ load: (o) => {
280
+ var e;
281
+ (e = c.value) == null || e.load(o);
172
282
  },
173
283
  save: () => {
174
- var t;
175
- (t = o.value) == null || t.save();
284
+ var o;
285
+ (o = c.value) == null || o.save();
176
286
  }
177
- }), (t, a) => (p(), k("div", {
287
+ }), (o, e) => (T(), L("div", {
178
288
  id: E,
179
289
  style: { position: "absolute", width: "100%", height: "100vh" }
180
290
  }));
181
291
  }
182
- }), L = /* @__PURE__ */ s({
183
- __name: "TopolEditor",
184
- props: {
185
- options: {},
186
- stage: { default: "production" }
187
- },
188
- emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses", "onError"],
189
- setup(l, { emit: r }) {
190
- const d = l, e = r;
191
- return g(() => {
192
- console.warn("[@topol.io/editor-vue] TopolEditor is deprecated and will be removed in a future version. Please use EmailEditor instead.");
193
- }), (i, o) => (p(), O(R, {
194
- options: d.options,
195
- stage: d.stage,
196
- onOnSave: o[0] || (o[0] = (n) => e("onSave", n)),
197
- onOnSaveAndClose: o[1] || (o[1] = (n) => e("onSaveAndClose", n)),
198
- onOnTestSend: o[2] || (o[2] = (n) => e("onTestSend", n)),
199
- onOnOpenFileManager: o[3] || (o[3] = () => e("onOpenFileManager")),
200
- onOnLoaded: o[4] || (o[4] = () => e("onLoaded")),
201
- onOnBlockSave: o[5] || (o[5] = (n) => e("onBlockSave", n)),
202
- onOnBlockRemove: o[6] || (o[6] = (n) => e("onBlockRemove", n)),
203
- onOnBlockEdit: o[7] || (o[7] = (n) => e("onBlockEdit", n)),
204
- onOnInit: o[8] || (o[8] = () => e("onInit")),
205
- onOnClose: o[9] || (o[9] = () => e("onClose")),
206
- onOnUndoChange: o[10] || (o[10] = (n) => e("onUndoChange", n)),
207
- onOnRedoChange: o[11] || (o[11] = (n) => e("onRedoChange", n)),
208
- onOnPreview: o[12] || (o[12] = (n) => e("onPreview", n)),
209
- onOnAlert: o[13] || (o[13] = (n) => e("onAlert", n)),
210
- onOnBannerClick: o[14] || (o[14] = (n) => e("onBannerClick", n)),
211
- onOnEdittedWithoutSaveChanged: o[15] || (o[15] = (n) => e("onEdittedWithoutSaveChanged", n)),
212
- onOnOpenCustomBlockDialog: o[16] || (o[16] = (n) => e("onOpenCustomBlockDialog", n)),
213
- onOnTemplateRename: o[17] || (o[17] = (n) => e("onTemplateRename", n)),
214
- onUpdateTestingEmailAddresses: o[18] || (o[18] = (n) => e("updateTestingEmailAddresses", n)),
215
- onOnError: o[19] || (o[19] = (n) => e("onError", n))
216
- }, null, 8, ["options", "stage"]));
217
- }
218
292
  });
219
293
  export {
220
- I as CoreEmailEditor,
221
- D as CoreLandingPageEditor,
222
- R as EmailEditor,
223
- f as LandingPageEditor,
224
- L as TopolEditor,
294
+ O as CoreEmailEditor,
295
+ _ as CoreLandingPageEditor,
296
+ B as EmailEditor,
297
+ R as LandingPageEditor,
298
+ B as TopolEditor,
225
299
  M as TopolPlugin
226
300
  };
@@ -0,0 +1 @@
1
+ (function(d,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@topol.io/editor"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@topol.io/editor","vue"],u):(d=typeof globalThis<"u"?globalThis:d||self,u(d["topol-editor-vue"]={},d.TopolPlugin,d.Vue))})(this,function(d,u,s){"use strict";const k=s.defineComponent({__name:"EmailEditor",props:{options:{},callbacks:{},stage:{default:"production"},loaderUrl:{}},emits:["ready","onSave","onSaveAndClose","onTestSend","onBannerClick","onOpenFileManager","onLoaded","onSavedSectionSave","onSavedSectionRemove","onSavedSectionEdit","onImageDelete","onInit","onUndoChange","onRedoChange","onPreview","onPreviewClose","onAlert","onEditorClose","onEdittedWithoutSaveChanged","onBlocksAndStructuresVisibilityChange","onOpenCustomBlockDialog","onTemplateRename","onTemplateUpdated","updateTestingEmailAddresses","onEditorError","onLanguageCreated","onLanguageDeleted","onLanguageSelected","onPrimaryLanguageChanged","onGetMutations","onCloudSave","onCloudTemplateChange"],setup(E,{expose:p,emit:h}){const a=E,r=h,S=s.getCurrentInstance(),v=s.ref();let g,C=!1;p({getEditor:()=>g??null});const i=l=>{var o,n,e;const c=`on${l[0].toUpperCase()}${l.slice(1)}`;return!!((o=a.callbacks)!=null&&o[l])||!!((n=S.vnode.props)!=null&&n[c])||!!((e=S.vnode.props)!=null&&e[`${c}Once`])},m=l=>{var o,n;if(C)return;const c={source:"integration",message:l instanceof Error?l.message:String(l),detail:l};i("onEditorError")||console.error("[@topol.io/editor-vue] EmailEditor failed:",l),(n=(o=a.callbacks)==null?void 0:o.onEditorError)==null||n.call(o,c),r("onEditorError",c)};return s.onMounted(async()=>{var c;const l={onSave:i("onSave")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onSave)==null?void 0:t.call(e,o);return r("onSave",o),n}:void 0,onSaveAndClose:i("onSaveAndClose")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onSaveAndClose)==null?void 0:t.call(e,o);return r("onSaveAndClose",o),n}:void 0,onTestSend:i("onTestSend")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onTestSend)==null?void 0:t.call(e,o);return r("onTestSend",o),n}:void 0,onBannerClick:i("onBannerClick")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onBannerClick)==null?void 0:t.call(e,o);return r("onBannerClick",o),n}:void 0,onOpenFileManager:i("onOpenFileManager")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onOpenFileManager)==null?void 0:e.call(n);return r("onOpenFileManager"),o}:void 0,onLoaded:i("onLoaded")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onLoaded)==null?void 0:e.call(n);return r("onLoaded"),o}:void 0,onSavedSectionSave:i("onSavedSectionSave")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onSavedSectionSave)==null?void 0:t.call(e,o);return r("onSavedSectionSave",o),n}:void 0,onSavedSectionRemove:i("onSavedSectionRemove")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onSavedSectionRemove)==null?void 0:t.call(e,o);return r("onSavedSectionRemove",o),n}:void 0,onSavedSectionEdit:i("onSavedSectionEdit")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onSavedSectionEdit)==null?void 0:t.call(e,o);return r("onSavedSectionEdit",o),n}:void 0,onImageDelete:i("onImageDelete")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onImageDelete)==null?void 0:t.call(e,o);return r("onImageDelete",o),n}:void 0,onInit:i("onInit")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onInit)==null?void 0:e.call(n);return r("onInit"),o}:void 0,onUndoChange:i("onUndoChange")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onUndoChange)==null?void 0:t.call(e,o);return r("onUndoChange",o),n}:void 0,onRedoChange:i("onRedoChange")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onRedoChange)==null?void 0:t.call(e,o);return r("onRedoChange",o),n}:void 0,onPreview:i("onPreview")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onPreview)==null?void 0:t.call(e,o);return r("onPreview",o),n}:void 0,onPreviewClose:i("onPreviewClose")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onPreviewClose)==null?void 0:e.call(n);return r("onPreviewClose"),o}:void 0,onAlert:i("onAlert")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onAlert)==null?void 0:t.call(e,o);return r("onAlert",o),n}:void 0,onEditorClose:i("onEditorClose")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onEditorClose)==null?void 0:e.call(n);return r("onEditorClose"),o}:void 0,onEdittedWithoutSaveChanged:i("onEdittedWithoutSaveChanged")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onEdittedWithoutSaveChanged)==null?void 0:t.call(e,o);return r("onEdittedWithoutSaveChanged",o),n}:void 0,onBlocksAndStructuresVisibilityChange:i("onBlocksAndStructuresVisibilityChange")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onBlocksAndStructuresVisibilityChange)==null?void 0:t.call(e,o);return r("onBlocksAndStructuresVisibilityChange",o),n}:void 0,onOpenCustomBlockDialog:i("onOpenCustomBlockDialog")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onOpenCustomBlockDialog)==null?void 0:t.call(e,o);return r("onOpenCustomBlockDialog",o),n}:void 0,onTemplateRename:i("onTemplateRename")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onTemplateRename)==null?void 0:t.call(e,o);return r("onTemplateRename",o),n}:void 0,onTemplateUpdated:i("onTemplateUpdated")?()=>{var n,e;const o=(e=(n=a.callbacks)==null?void 0:n.onTemplateUpdated)==null?void 0:e.call(n);return r("onTemplateUpdated"),o}:void 0,updateTestingEmailAddresses:i("updateTestingEmailAddresses")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.updateTestingEmailAddresses)==null?void 0:t.call(e,o);return r("updateTestingEmailAddresses",o),n}:void 0,onEditorError:i("onEditorError")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onEditorError)==null?void 0:t.call(e,o);return r("onEditorError",o),n}:void 0,onLanguageCreated:i("onLanguageCreated")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onLanguageCreated)==null?void 0:t.call(e,o);return r("onLanguageCreated",o),n}:void 0,onLanguageDeleted:i("onLanguageDeleted")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onLanguageDeleted)==null?void 0:t.call(e,o);return r("onLanguageDeleted",o),n}:void 0,onLanguageSelected:i("onLanguageSelected")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onLanguageSelected)==null?void 0:t.call(e,o);return r("onLanguageSelected",o),n}:void 0,onPrimaryLanguageChanged:i("onPrimaryLanguageChanged")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onPrimaryLanguageChanged)==null?void 0:t.call(e,o);return r("onPrimaryLanguageChanged",o),n}:void 0,onGetMutations:i("onGetMutations")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onGetMutations)==null?void 0:t.call(e,o);return r("onGetMutations",o),n}:void 0,getNonce:(c=a.callbacks)!=null&&c.getNonce?()=>a.callbacks.getNonce():void 0,onCloudSave:i("onCloudSave")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onCloudSave)==null?void 0:t.call(e,o);return r("onCloudSave",o),n}:void 0,onCloudTemplateChange:i("onCloudTemplateChange")?o=>{var e,t;const n=(t=(e=a.callbacks)==null?void 0:e.onCloudTemplateChange)==null?void 0:t.call(e,o);return r("onCloudTemplateChange",o),n}:void 0};try{const o=await u.EmailEditor.init({config:a.options,...l},{stage:a.stage,loaderUrl:a.loaderUrl});if(C){await o.destroy();return}g=o;try{await o.render(v.value)}catch(n){throw await o.destroy(),g=void 0,n}C||r("ready",o)}catch(o){m(o)}}),s.onBeforeUnmount(()=>{C=!0;const l=g;g=void 0,l==null||l.destroy().catch(c=>console.warn("[@topol.io/editor-vue] EmailEditor cleanup failed:",c))}),(l,c)=>(s.openBlock(),s.createElementBlock("div",{ref_key:"container",ref:v,style:{width:"100%",height:"100vh"}},null,512))}}),f="topol-landing-page-editor-id",b=s.defineComponent({__name:"LandingPageEditor",props:{options:{},stage:{default:"production"}},emits:["onSave","onSaveAndClose","onOpenFileManager","onImageDelete","onLoaded","onInit","onUndoChange","onRedoChange","onPreview","onPreviewClose","onAlert","onEditorClose","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","onEditorError"],setup(E,{expose:p,emit:h}){const a=E,r=h,S=["onSave","onSaveAndClose","onOpenFileManager","onImageDelete","onLoaded","onInit","onUndoChange","onRedoChange","onPreview","onPreviewClose","onAlert","onEditorClose","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","onEditorError"],v=s.ref(null),g=s.getCurrentInstance(),C=n=>{const e=g==null?void 0:g.vnode.props;if(!e)return!1;const t="on"+n.charAt(0).toUpperCase()+n.slice(1);return typeof e[t]=="function"||Array.isArray(e[t])},i=()=>{const n={};for(const e of S)C(e)&&(n[e]=t=>{t===void 0?r(e):r(e,t)});return n};let m=!1;async function l(n){var e;if(n)try{await((e=n.destroy)==null?void 0:e.call(n))}catch(t){console.warn("[@topol.io/editor-vue] LandingPageEditor destroy failed:",t)}}return s.onMounted(async()=>{try{const n=await u.LandingPageEditor.init({config:a.options,...i()},{stage:a.stage});if(m){await l(n);return}v.value=n,await n.render("#"+f)}catch(n){if(m)return;const e=n instanceof Error?n.message:"Failed to initialize editor";r("onEditorError",{source:"init",message:e,detail:n}),console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:",n)}}),s.onBeforeUnmount(()=>{m=!0;const n=v.value;v.value=null,l(n)}),p({load:n=>{var e;(e=v.value)==null||e.load(n)},save:()=>{var n;(n=v.value)==null||n.save()}}),(n,e)=>(s.openBlock(),s.createElementBlock("div",{id:f,style:{position:"absolute",width:"100%",height:"100vh"}}))}});Object.defineProperty(d,"CoreEmailEditor",{enumerable:!0,get:()=>u.EmailEditor}),Object.defineProperty(d,"CoreLandingPageEditor",{enumerable:!0,get:()=>u.LandingPageEditor}),d.TopolPlugin=u,d.EmailEditor=k,d.LandingPageEditor=b,d.TopolEditor=k,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
@@ -1,15 +1,145 @@
1
- import { type IStage } from '@topol.io/editor';
2
- import type { IVueEmailOptions } from './types';
1
+ import type { IEmailCallbacks, IEmailEditorInstance, IStage, IErrorData } from "@topol.io/editor";
2
+ import type { IVueEmailOptions } from "./types";
3
3
  type __VLS_Props = {
4
4
  options: IVueEmailOptions;
5
+ callbacks?: IEmailCallbacks;
5
6
  stage?: IStage;
7
+ loaderUrl?: string;
6
8
  };
7
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
- [x: string]: any;
9
- } & {
10
- [x: string]: any;
9
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {
10
+ getEditor: () => IEmailEditorInstance | null;
11
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ onSave: (payload: import("@topol.io/editor").ISaveData) => any;
13
+ onSaveAndClose: (payload: import("@topol.io/editor").ISaveData) => any;
14
+ onTestSend: (payload: import("@topol.io/editor").ISendTestData) => any;
15
+ onBannerClick: (payload: {
16
+ json: unknown;
17
+ html: unknown;
18
+ }) => any;
19
+ onOpenFileManager: () => any;
20
+ onLoaded: () => any;
21
+ onSavedSectionSave: (payload: {
22
+ section: import("@topol.io/editor").ISavedBlock;
23
+ }) => any;
24
+ onSavedSectionRemove: (payload: {
25
+ id: number | string;
26
+ }) => any;
27
+ onSavedSectionEdit: (payload: {
28
+ id: number | string;
29
+ }) => any;
30
+ onImageDelete: (payload: {
31
+ items: import("@topol.io/editor").IEmailDeletedItem[];
32
+ }) => any;
33
+ onInit: () => any;
34
+ onUndoChange: (payload: {
35
+ count: number;
36
+ }) => any;
37
+ onRedoChange: (payload: {
38
+ count: number;
39
+ }) => any;
40
+ onPreview: (payload: {
41
+ html: unknown;
42
+ }) => any;
43
+ onPreviewClose: () => any;
44
+ onAlert: (payload: {
45
+ notification: import("@topol.io/editor").INotification;
46
+ }) => any;
47
+ onEditorClose: () => any;
48
+ onEdittedWithoutSaveChanged: (payload: {
49
+ value: boolean;
50
+ }) => any;
51
+ onBlocksAndStructuresVisibilityChange: (payload: {
52
+ value: boolean;
53
+ }) => any;
54
+ onOpenCustomBlockDialog: (payload: {
55
+ block: unknown;
56
+ }) => any;
57
+ onTemplateRename: (payload: {
58
+ name: string;
59
+ }) => any;
60
+ onTemplateUpdated: () => any;
61
+ updateTestingEmailAddresses: (payload: {
62
+ emails: string[];
63
+ }) => any;
64
+ onEditorError: (payload: IErrorData) => any;
65
+ onLanguageCreated: (payload: import("@topol.io/editor").ILanguageChangePayload) => any;
66
+ onLanguageDeleted: (payload: import("@topol.io/editor").ILanguageChangePayload) => any;
67
+ onLanguageSelected: (payload: {
68
+ code: string;
69
+ }) => any;
70
+ onPrimaryLanguageChanged: (payload: import("@topol.io/editor").ILanguageChangePayload) => any;
71
+ onGetMutations: (payload: {
72
+ mutations: import("@topol.io/editor").ILanguageMutation[];
73
+ }) => any;
74
+ onCloudSave: (payload: import("@topol.io/editor").ICloudSavePayload) => any;
75
+ onCloudTemplateChange: (payload: import("@topol.io/editor").ICloudTemplateChangePayload) => any;
76
+ ready: (editor: IEmailEditorInstance) => any;
11
77
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
- [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
78
+ onOnSave?: ((payload: import("@topol.io/editor").ISaveData) => any) | undefined;
79
+ onOnSaveAndClose?: ((payload: import("@topol.io/editor").ISaveData) => any) | undefined;
80
+ onOnTestSend?: ((payload: import("@topol.io/editor").ISendTestData) => any) | undefined;
81
+ onOnBannerClick?: ((payload: {
82
+ json: unknown;
83
+ html: unknown;
84
+ }) => any) | undefined;
85
+ onOnOpenFileManager?: (() => any) | undefined;
86
+ onOnLoaded?: (() => any) | undefined;
87
+ onOnSavedSectionSave?: ((payload: {
88
+ section: import("@topol.io/editor").ISavedBlock;
89
+ }) => any) | undefined;
90
+ onOnSavedSectionRemove?: ((payload: {
91
+ id: number | string;
92
+ }) => any) | undefined;
93
+ onOnSavedSectionEdit?: ((payload: {
94
+ id: number | string;
95
+ }) => any) | undefined;
96
+ onOnImageDelete?: ((payload: {
97
+ items: import("@topol.io/editor").IEmailDeletedItem[];
98
+ }) => any) | undefined;
99
+ onOnInit?: (() => any) | undefined;
100
+ onOnUndoChange?: ((payload: {
101
+ count: number;
102
+ }) => any) | undefined;
103
+ onOnRedoChange?: ((payload: {
104
+ count: number;
105
+ }) => any) | undefined;
106
+ onOnPreview?: ((payload: {
107
+ html: unknown;
108
+ }) => any) | undefined;
109
+ onOnPreviewClose?: (() => any) | undefined;
110
+ onOnAlert?: ((payload: {
111
+ notification: import("@topol.io/editor").INotification;
112
+ }) => any) | undefined;
113
+ onOnEditorClose?: (() => any) | undefined;
114
+ onOnEdittedWithoutSaveChanged?: ((payload: {
115
+ value: boolean;
116
+ }) => any) | undefined;
117
+ onOnBlocksAndStructuresVisibilityChange?: ((payload: {
118
+ value: boolean;
119
+ }) => any) | undefined;
120
+ onOnOpenCustomBlockDialog?: ((payload: {
121
+ block: unknown;
122
+ }) => any) | undefined;
123
+ onOnTemplateRename?: ((payload: {
124
+ name: string;
125
+ }) => any) | undefined;
126
+ onOnTemplateUpdated?: (() => any) | undefined;
127
+ onUpdateTestingEmailAddresses?: ((payload: {
128
+ emails: string[];
129
+ }) => any) | undefined;
130
+ onOnEditorError?: ((payload: IErrorData) => any) | undefined;
131
+ onOnLanguageCreated?: ((payload: import("@topol.io/editor").ILanguageChangePayload) => any) | undefined;
132
+ onOnLanguageDeleted?: ((payload: import("@topol.io/editor").ILanguageChangePayload) => any) | undefined;
133
+ onOnLanguageSelected?: ((payload: {
134
+ code: string;
135
+ }) => any) | undefined;
136
+ onOnPrimaryLanguageChanged?: ((payload: import("@topol.io/editor").ILanguageChangePayload) => any) | undefined;
137
+ onOnGetMutations?: ((payload: {
138
+ mutations: import("@topol.io/editor").ILanguageMutation[];
139
+ }) => any) | undefined;
140
+ onOnCloudSave?: ((payload: import("@topol.io/editor").ICloudSavePayload) => any) | undefined;
141
+ onOnCloudTemplateChange?: ((payload: import("@topol.io/editor").ICloudTemplateChangePayload) => any) | undefined;
142
+ onReady?: ((editor: IEmailEditorInstance) => any) | undefined;
13
143
  }>, {
14
144
  stage: IStage;
15
145
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,5 +1,5 @@
1
- import { type IStage } from '@topol.io/editor';
2
- import type { IVueLandingPageOptions } from './types';
1
+ import { type IStage } from "@topol.io/editor";
2
+ import type { IVueLandingPageOptions } from "./types";
3
3
  type __VLS_Props = {
4
4
  options: IVueLandingPageOptions;
5
5
  stage?: IStage;
@@ -1,16 +1,3 @@
1
- import { type IStage } from '@topol.io/editor';
2
- import type { IVueEmailOptions } from './types';
3
- type __VLS_Props = {
4
- options: IVueEmailOptions;
5
- stage?: IStage;
6
- };
7
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
- [x: string]: any;
9
- } & {
10
- [x: string]: any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
- [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
13
- }>, {
14
- stage: IStage;
15
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
- export default _default;
1
+ /** @deprecated Naming alias only; uses the v4 EmailEditor contract. */
2
+ import EmailEditor from "./EmailEditor.vue";
3
+ export default EmailEditor;
@@ -31,12 +31,13 @@
31
31
  * </template>
32
32
  * ```
33
33
  */
34
- export { default as TopolPlugin, EmailEditor as CoreEmailEditor, LandingPageEditor as CoreLandingPageEditor } from '@topol.io/editor';
35
- export { default as EmailEditor } from './EmailEditor.vue';
36
- export { default as LandingPageEditor } from './LandingPageEditor.vue';
34
+ export { default as TopolPlugin, EmailEditor as CoreEmailEditor, LandingPageEditor as CoreLandingPageEditor } from "@topol.io/editor";
35
+ export { default as EmailEditor } from "./EmailEditor.vue";
36
+ export { default as LandingPageEditor } from "./LandingPageEditor.vue";
37
37
  /**
38
38
  * @deprecated Use EmailEditor instead. TopolEditor is an alias for backwards compatibility.
39
39
  */
40
- export { default as TopolEditor } from './TopolEditor.vue';
41
- export type { ITopolOptions, ILandingPageOptions, ILandingPageEditorInstance, IEmailCallbacks, ILandingPageCallbacks, ISaveData, IErrorData, ISendTestData, INotification, ISavedBlock, IStage, TopolSection, } from '@topol.io/editor';
42
- export type { IVueEmailOptions, IVueLandingPageOptions, IVueOptions } from './types';
40
+ export { default as TopolEditor } from "./TopolEditor.vue";
41
+ export type { ITopolOptions, ILandingPageOptions, ILandingPageEditorInstance, IEmailCallbacks, ILandingPageCallbacks, ISaveData, IErrorData, ISendTestData, INotification, ISavedBlock, IStage, TopolSection, } from "@topol.io/editor";
42
+ export type { IVueEmailOptions, IVueLandingPageOptions, IVueOptions } from "./types";
43
+ export type { IEmailConfig, IEmailEditorInstance, IEmailEditorPluginOptions, ICloudOptions, ICloudFeatures, INonceAuthCallbacks, ICountdownOptions, ICountdownDefaultColors, ICountdownDateMergeTag, ICloudCallbacks, ICloudSavePayload, ICloudTemplateChangePayload, ISavedSection, IPremadeSection, IPremadeSections, IPremadeSectionsOptions, ILanguageMutation, ILanguageChangePayload, IEmailDeletedItem, IUpdateTemplateOptions, } from "@topol.io/editor";
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Type re-exports from core package and Vue-specific types.
3
3
  */
4
- export type { ITopolOptions, ILandingPageOptions, ILandingPageEditorInstance, IEmailCallbacks, ILandingPageCallbacks, ISaveData, IErrorData, ISendTestData, INotification, ISavedBlock, IStage, TopolSection, } from '@topol.io/editor';
5
- import type { ITopolOptions, ILandingPageOptions } from '@topol.io/editor';
4
+ export type { ITopolOptions, ILandingPageOptions, ILandingPageEditorInstance, IEmailCallbacks, ILandingPageCallbacks, ISaveData, IErrorData, ISendTestData, INotification, ISavedBlock, IStage, TopolSection, } from "@topol.io/editor";
5
+ import type { IEmailConfig, ILandingPageOptions } from "@topol.io/editor";
6
6
  /**
7
7
  * Vue-specific options for EmailEditor component.
8
- * Omits 'id' and 'callbacks' as they are handled internally by the Vue wrapper.
8
+ * Contains the v4 config; callbacks are provided separately.
9
9
  */
10
- export type IVueEmailOptions = Omit<ITopolOptions, 'id' | 'callbacks'>;
10
+ export type IVueEmailOptions = IEmailConfig;
11
11
  /**
12
12
  * Vue-specific options for LandingPageEditor component.
13
13
  * Contains only the config options, as callbacks are handled as Vue emits.
14
14
  */
15
- export type IVueLandingPageOptions = ILandingPageOptions['config'];
15
+ export type IVueLandingPageOptions = ILandingPageOptions["config"];
16
16
  /**
17
17
  * @deprecated Use IVueEmailOptions instead.
18
18
  */
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "author": "Topol.io",
15
15
  "homepage": "https://topol.io",
16
16
  "license": "Apache-2.0",
17
- "version": "1.0.0-alpha.1",
17
+ "version": "1.0.0-alpha.10",
18
18
  "type": "module",
19
19
  "files": [
20
20
  "dist"
@@ -25,11 +25,11 @@
25
25
  ".": {
26
26
  "types": "./dist/types/entry.d.ts",
27
27
  "import": "./dist/topol-editor-vue.es.js",
28
- "require": "./dist/topol-editor-vue.umd.js"
28
+ "require": "./dist/topol-editor-vue.umd.cjs"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@topol.io/editor": "1.0.0-alpha.1"
32
+ "@topol.io/editor": "1.0.0-alpha.10"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "vue": "^3.2.25"
@@ -55,6 +55,10 @@
55
55
  "preview": "vite preview",
56
56
  "build:types": "vue-tsc -p tsconfig.prod.json",
57
57
  "test": "vitest run",
58
- "test:watch": "vitest"
58
+ "test:watch": "vitest",
59
+ "lint": "oxlint --deny-warnings .",
60
+ "lint:fix": "oxlint --fix --deny-warnings .",
61
+ "format": "oxfmt --write .",
62
+ "format:check": "oxfmt --check ."
59
63
  }
60
64
  }
@@ -1 +0,0 @@
1
- (function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@topol.io/editor"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@topol.io/editor","vue"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d["topol-editor-vue"]={},d.editor,d.Vue))})(this,function(d,r,a){"use strict";const m="topol-email-editor-id",C=a.defineComponent({__name:"EmailEditor",props:{options:{},stage:{default:"production"}},emits:["onSave","onSaveAndClose","onTestSend","onOpenFileManager","onLoaded","onBlockSave","onBlockRemove","onBlockEdit","onInit","onClose","onUndoChange","onRedoChange","onPreview","onAlert","onBannerClick","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","updateTestingEmailAddresses","onError"],setup(p,{emit:g}){const s=p,e=g,i=()=>({onSave(o,n){e("onSave",{json:o,html:n})},onSaveAndClose(o,n){e("onSaveAndClose",{json:o,html:n})},onTestSend(o,n,u){e("onTestSend",{email:o,json:n,html:u})},onOpenFileManager(){e("onOpenFileManager")},onLoaded(){e("onLoaded")},onBlockSave(o){e("onBlockSave",o)},onBlockRemove(o){e("onBlockRemove",o)},onBlockEdit(o){e("onBlockEdit",o)},onInit(){e("onInit")},onUndoChange(o){e("onUndoChange",o)},onRedoChange(o){e("onRedoChange",o)},onPreview(o){e("onPreview",o)},onAlert(o){e("onAlert",o)},onClose(){e("onClose")},onBannerClick(o,n){e("onBannerClick",{json:o,html:n})},onEdittedWithoutSaveChanged(o){e("onEdittedWithoutSaveChanged",o)},onOpenCustomBlockDialog(o){e("onOpenCustomBlockDialog",o)},onTemplateRename(o){e("onTemplateRename",o)},updateTestingEmailAddresses(o){e("updateTestingEmailAddresses",o)},onError(o,n){e("onError",{type:o,message:n})}});return a.onMounted(async()=>{try{const o={id:"#"+m,...s.options,callbacks:i()};await r.EmailEditor.init(o,{stage:s.stage})}catch(o){const n=o instanceof Error?o.message:"Failed to initialize editor";e("onError",{type:"init",message:n}),console.error("[@topol.io/editor-vue] EmailEditor initialization failed:",o)}}),a.onBeforeUnmount(()=>{r.EmailEditor.destroy()}),(o,n)=>(a.openBlock(),a.createElementBlock("div",{id:m,style:{position:"absolute",width:"100%",height:"100vh"}}))}}),E="topol-landing-page-editor-id",v=a.defineComponent({__name:"LandingPageEditor",props:{options:{},stage:{default:"production"}},emits:["onSave","onSaveAndClose","onOpenFileManager","onLoaded","onBlockSave","onBlockRemove","onBlockEdit","onInit","onClose","onUndoChange","onRedoChange","onPreview","onAlert","onBannerClick","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","onError"],setup(p,{expose:g,emit:s}){const e=p,i=s,o=a.ref(null),n=()=>({onSave(t,l){i("onSave",{json:t,html:l})},onSaveAndClose(t,l){i("onSaveAndClose",{json:t,html:l})},onOpenFileManager(){i("onOpenFileManager")},onLoaded(){i("onLoaded")},onBlockSave(t){i("onBlockSave",t)},onBlockRemove(t){i("onBlockRemove",t)},onBlockEdit(t){i("onBlockEdit",t)},onInit(){i("onInit")},onClose(){i("onClose")},onUndoChange(t){i("onUndoChange",t)},onRedoChange(t){i("onRedoChange",t)},onPreview(t){i("onPreview",t)},onAlert(t){i("onAlert",t)},onBannerClick(t,l){i("onBannerClick",{json:t,html:l})},onEdittedWithoutSaveChanged(t){i("onEdittedWithoutSaveChanged",t)},onOpenCustomBlockDialog(t){i("onOpenCustomBlockDialog",t)},onTemplateRename(t){i("onTemplateRename",t)},onError(t,l){i("onError",{type:t,message:l})}});return a.onMounted(async()=>{try{const t=await r.LandingPageEditor.init({config:e.options,...n()},{stage:e.stage});o.value=t,t.render("#"+E)}catch(t){const l=t instanceof Error?t.message:"Failed to initialize editor";i("onError",{type:"init",message:l}),console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:",t)}}),a.onBeforeUnmount(()=>{var t;(t=o.value)==null||t.destroy()}),g({load:t=>{var l;(l=o.value)==null||l.load(t)},save:()=>{var t;(t=o.value)==null||t.save()}}),(t,l)=>(a.openBlock(),a.createElementBlock("div",{id:E,style:{position:"absolute",width:"100%",height:"100vh"}}))}}),k=a.defineComponent({__name:"TopolEditor",props:{options:{},stage:{default:"production"}},emits:["onSave","onSaveAndClose","onTestSend","onOpenFileManager","onLoaded","onBlockSave","onBlockRemove","onBlockEdit","onInit","onClose","onUndoChange","onRedoChange","onPreview","onAlert","onBannerClick","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","updateTestingEmailAddresses","onError"],setup(p,{emit:g}){const s=p,e=g;return a.onMounted(()=>{console.warn("[@topol.io/editor-vue] TopolEditor is deprecated and will be removed in a future version. Please use EmailEditor instead.")}),(i,o)=>(a.openBlock(),a.createBlock(C,{options:s.options,stage:s.stage,onOnSave:o[0]||(o[0]=n=>e("onSave",n)),onOnSaveAndClose:o[1]||(o[1]=n=>e("onSaveAndClose",n)),onOnTestSend:o[2]||(o[2]=n=>e("onTestSend",n)),onOnOpenFileManager:o[3]||(o[3]=()=>e("onOpenFileManager")),onOnLoaded:o[4]||(o[4]=()=>e("onLoaded")),onOnBlockSave:o[5]||(o[5]=n=>e("onBlockSave",n)),onOnBlockRemove:o[6]||(o[6]=n=>e("onBlockRemove",n)),onOnBlockEdit:o[7]||(o[7]=n=>e("onBlockEdit",n)),onOnInit:o[8]||(o[8]=()=>e("onInit")),onOnClose:o[9]||(o[9]=()=>e("onClose")),onOnUndoChange:o[10]||(o[10]=n=>e("onUndoChange",n)),onOnRedoChange:o[11]||(o[11]=n=>e("onRedoChange",n)),onOnPreview:o[12]||(o[12]=n=>e("onPreview",n)),onOnAlert:o[13]||(o[13]=n=>e("onAlert",n)),onOnBannerClick:o[14]||(o[14]=n=>e("onBannerClick",n)),onOnEdittedWithoutSaveChanged:o[15]||(o[15]=n=>e("onEdittedWithoutSaveChanged",n)),onOnOpenCustomBlockDialog:o[16]||(o[16]=n=>e("onOpenCustomBlockDialog",n)),onOnTemplateRename:o[17]||(o[17]=n=>e("onTemplateRename",n)),onUpdateTestingEmailAddresses:o[18]||(o[18]=n=>e("updateTestingEmailAddresses",n)),onOnError:o[19]||(o[19]=n=>e("onError",n))},null,8,["options","stage"]))}});Object.defineProperty(d,"CoreEmailEditor",{enumerable:!0,get:()=>r.EmailEditor}),Object.defineProperty(d,"CoreLandingPageEditor",{enumerable:!0,get:()=>r.LandingPageEditor}),d.TopolPlugin=r,d.EmailEditor=C,d.LandingPageEditor=v,d.TopolEditor=k,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});