@topol.io/editor-vue 1.0.0-alpha.9 → 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.
package/README.md CHANGED
@@ -1,107 +1,95 @@
1
+ <p align="center">
1
2
  <a href="https://topol.io" target="_blank">
2
- <svg width="391" height="100" viewBox="0 0 391 100" fill="none" xmlns="http://www.w3.org/2000/svg"><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="black"/></svg>
3
+ <img src="https://cdn.jsdelivr.net/npm/@topol.io/editor@1/logo.svg" alt="Topol" width="235" height="60">
3
4
  </a>
5
+ </p>
4
6
 
5
- ---
7
+ # @topol.io/editor-vue
6
8
 
7
- Easy and quick! Drag and drop HTML editor and builder for beautiful responsive email templates.
9
+ Vue 3 wrapper for Email Editor v4, from `1.0.0` onward.
8
10
 
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',
11
+ ```vue
12
+ <script setup lang="ts">
13
+ import { EmailEditor, type IEmailCallbacks, type IVueEmailOptions } from "@topol.io/editor-vue";
14
+ const options: IVueEmailOptions = {
15
+ authorize: { apiKey: "pk_your-key", entityId: "user-123" },
16
+ };
17
+ const callbacks: IEmailCallbacks = {
18
+ async getNonce() {
19
+ const response = await fetch("/api/topol/nonce", { method: "POST" });
20
+ if (!response.ok) throw new Error("Could not mint a Topol nonce");
21
+ return (await response.json()).nonce;
36
22
  },
37
23
  };
24
+ </script>
25
+ <template>
26
+ <EmailEditor
27
+ :options="options"
28
+ :callbacks="callbacks"
29
+ @on-save="({ json, html }) => console.log(json, html)"
30
+ @on-editor-error="({ source, message }) => console.error(source, message)"
31
+ />
32
+ </template>
38
33
  ```
39
34
 
40
- ```html
41
- <TopolEditor :options="customOptions"></TopolEditor>
42
- ```
43
-
44
- ## Call Topol Plugin actions
45
-
46
- To call actions to the editor import:
35
+ Use the **`callbacks` prop for `getNonce` and asynchronous persistence**:
36
+ `callbacks.onSave = async ({ json, html }) => { await persist(json, html); }`.
37
+ Vue event handlers do not return promises to the editor. Events remain available
38
+ for notifications, with the exact core object payloads. If both a callback and an
39
+ event listener are provided, the callback runs first and its result is returned.
40
+
41
+ `@ready="editor => ..."` receives the instance. A component template ref exposes
42
+ `getEditor()`. `@on-save-and-close` is registered only when explicitly supplied;
43
+ without it or `callbacks.onSaveAndClose`, the runtime's default save-and-close works.
44
+ `getNonce` is a function callback only, never an event.
45
+
46
+ The exposed `load()` and `save()` of `LandingPageEditor` return Promises: `save()`
47
+ settles once the save has finished and rejects with `err.code === "SAVE_IN_PROGRESS"`
48
+ while another save runs. The exposed `getEditor()` returns the instance for its other
49
+ methods. `LandingPageEditor` takes the same `callbacks` prop (`ILandingPageCallbacks`):
50
+ pass `getNonce` there to turn nonce authentication on, and async `onSave` /
51
+ `onSaveAndClose` / `onEditorClose` handlers the editor should wait for.
52
+ It also has `@ready`, `loader-url` and a container without a fixed `id`, so several
53
+ editors can share a page; `class` and `style` fall through to the container.
54
+ `CoreEmailEditor` exposes the core v4 factory.
55
+
56
+ `options` contains the v4 configuration (`IEmailConfig`). A `getNonce` callback that
57
+ fetches a fresh `nc_` token from your application's authenticated backend enables
58
+ nonce authentication. Never put an `sk_` secret in browser code. See the core package
59
+ README for nonce authentication, loader selection and the migration list.
60
+
61
+ Configuration and the presence of callback handlers are captured on mount. Remount
62
+ with a new key to change them; existing callback functions read their latest values.
63
+ `ready` means the iframe has rendered; `onInit` reports editor authentication.
64
+ Set the container's height. Each component owns its own instance and destroys it
65
+ on unmount, including when initialization is still pending.
66
+
67
+ Use `loaderUrl` for an explicit v4 local/preview loader. A numeric `stage` selects
68
+ a PR preview. The `TopolEditor` alias is removed; import `EmailEditor`.
69
+
70
+ <!-- Hidden until Topol Cloud is public.
71
+
72
+ ## Running the example against deployed Cloud
73
+
74
+ Merge `.env.example` into `example/.env.local` (Vite's development root). Set
75
+ `VITE_TOPOL_CLOUD_PUBLIC_KEY` and `VITE_TOPOL_CLOUD_SECRET_KEY` to a matching `pk_` / `sk_`
76
+ credential pair registered in the deployed backend, then start or restart Vite:
47
77
 
48
- ```js
49
- import { TopolPlugin } from '@topol.io/editor-vue';
50
-
51
- TopolPlugin.save();
78
+ ```sh
79
+ pnpm --filter @topol.io/editor-vue dev
52
80
  ```
53
81
 
54
- For more TopolPlugin functions refer to the [TopolPlugin actions](https://www.npmjs.com/package/@topol.io/editor#call-topol-plugin-actions)
55
-
56
- <br>
57
-
58
- ## Editor Events
82
+ The example uses the production v4 loader at
83
+ `https://v4.email-assets.topol.io/loader/build.js` and defaults to user `42`
84
+ (override with `VITE_TOPOL_CLOUD_USER_ID`). Its `callbacks.getNonce` calls
85
+ `POST https://api.topol.io/auth/nonce`
86
+ directly from the browser. This testing-only example exposes the secret in the
87
+ frontend; use test credentials and do not deploy it. No local nonce endpoint or
88
+ Cloud backend is needed; a made-up nonce or the
89
+ local seed credentials cannot substitute for credentials registered in that backend.
59
90
 
60
- The callbacks from editor are received as component events.
91
+ The editor loader must use the same backend as `VITE_TOPOL_CLOUD_API_URL`.
92
+ `VITE_TOPOL_API_KEY` remains the landing-page example's key. Deployed
93
+ integrations need an authenticated backend that derives the user from the session.
61
94
 
62
- ```html
63
- <TopolEditor
64
- :options="customOptions"
65
- @onSave="handleOnSave"
66
- ></TopolEditor>
67
- ```
68
-
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
- ```
95
+ -->
package/dist/index.js ADDED
@@ -0,0 +1,314 @@
1
+ import { EmailEditor as R, LandingPageEditor as y } from "@topol.io/editor";
2
+ import { EmailEditor as N, LandingPageEditor as x } from "@topol.io/editor";
3
+ import { defineComponent as L, getCurrentInstance as w, ref as U, onMounted as P, onBeforeUnmount as T, createElementBlock as A, openBlock as D, shallowRef as B } from "vue";
4
+ const _ = /* @__PURE__ */ L({
5
+ __name: "EmailEditor",
6
+ props: {
7
+ options: {},
8
+ callbacks: {},
9
+ stage: { default: "production" },
10
+ loaderUrl: {}
11
+ },
12
+ emits: ["ready", "onSave", "onSaveAndClose", "onTestSend", "onBannerClick", "onOpenFileManager", "onLoaded", "onSavedSectionSave", "onSavedSectionRemove", "onSavedSectionEdit", "onImageDelete", "onInit", "onUndoChange", "onRedoChange", "onPreview", "onPreviewClose", "onAlert", "onEditorClose", "onUnsavedChangesChange", "onHiddenElementsVisibilityChange", "onOpenCustomBlockDialog", "onTemplateRename", "onTemplateUpdated", "onTestingEmailsChange", "onEditorError", "onLanguageCreated", "onLanguageDeleted", "onLanguageSelected", "onPrimaryLanguageChanged", "onGetMutations", "onCloudSave", "onCloudTemplateChange"],
13
+ setup(S, { expose: k, emit: p }) {
14
+ const a = S, r = p, E = w(), m = U();
15
+ let u, v = !1;
16
+ k({ getEditor: () => u ?? null });
17
+ const l = (i) => {
18
+ var n, t, e;
19
+ const d = `on${i[0].toUpperCase()}${i.slice(1)}`;
20
+ return !!((n = a.callbacks) != null && n[i]) || !!((t = E.vnode.props) != null && t[d]) || !!((e = E.vnode.props) != null && e[`${d}Once`]);
21
+ }, b = (i) => {
22
+ var n, t;
23
+ if (v) return;
24
+ const d = { source: "integration", message: i instanceof Error ? i.message : String(i), detail: i };
25
+ l("onEditorError") || console.error("[@topol.io/editor-vue] EmailEditor failed:", i), (t = (n = a.callbacks) == null ? void 0 : n.onEditorError) == null || t.call(n, d), r("onEditorError", d);
26
+ };
27
+ return P(async () => {
28
+ var d;
29
+ const i = {
30
+ onSave: l("onSave") ? (n) => {
31
+ var e, o;
32
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onSave) == null ? void 0 : o.call(e, n);
33
+ return r("onSave", n), t;
34
+ } : void 0,
35
+ onSaveAndClose: l("onSaveAndClose") ? (n) => {
36
+ var e, o;
37
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onSaveAndClose) == null ? void 0 : o.call(e, n);
38
+ return r("onSaveAndClose", n), t;
39
+ } : void 0,
40
+ onTestSend: l("onTestSend") ? (n) => {
41
+ var e, o;
42
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onTestSend) == null ? void 0 : o.call(e, n);
43
+ return r("onTestSend", n), t;
44
+ } : void 0,
45
+ onBannerClick: l("onBannerClick") ? (n) => {
46
+ var e, o;
47
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onBannerClick) == null ? void 0 : o.call(e, n);
48
+ return r("onBannerClick", n), t;
49
+ } : void 0,
50
+ onOpenFileManager: l("onOpenFileManager") ? () => {
51
+ var t, e;
52
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onOpenFileManager) == null ? void 0 : e.call(t);
53
+ return r("onOpenFileManager"), n;
54
+ } : void 0,
55
+ onLoaded: l("onLoaded") ? () => {
56
+ var t, e;
57
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onLoaded) == null ? void 0 : e.call(t);
58
+ return r("onLoaded"), n;
59
+ } : void 0,
60
+ onSavedSectionSave: l("onSavedSectionSave") ? (n) => {
61
+ var e, o;
62
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onSavedSectionSave) == null ? void 0 : o.call(e, n);
63
+ return r("onSavedSectionSave", n), t;
64
+ } : void 0,
65
+ onSavedSectionRemove: l("onSavedSectionRemove") ? (n) => {
66
+ var e, o;
67
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onSavedSectionRemove) == null ? void 0 : o.call(e, n);
68
+ return r("onSavedSectionRemove", n), t;
69
+ } : void 0,
70
+ onSavedSectionEdit: l("onSavedSectionEdit") ? (n) => {
71
+ var e, o;
72
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onSavedSectionEdit) == null ? void 0 : o.call(e, n);
73
+ return r("onSavedSectionEdit", n), t;
74
+ } : void 0,
75
+ onImageDelete: l("onImageDelete") ? (n) => {
76
+ var e, o;
77
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onImageDelete) == null ? void 0 : o.call(e, n);
78
+ return r("onImageDelete", n), t;
79
+ } : void 0,
80
+ onInit: l("onInit") ? () => {
81
+ var t, e;
82
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onInit) == null ? void 0 : e.call(t);
83
+ return r("onInit"), n;
84
+ } : void 0,
85
+ onUndoChange: l("onUndoChange") ? (n) => {
86
+ var e, o;
87
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onUndoChange) == null ? void 0 : o.call(e, n);
88
+ return r("onUndoChange", n), t;
89
+ } : void 0,
90
+ onRedoChange: l("onRedoChange") ? (n) => {
91
+ var e, o;
92
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onRedoChange) == null ? void 0 : o.call(e, n);
93
+ return r("onRedoChange", n), t;
94
+ } : void 0,
95
+ onPreview: l("onPreview") ? (n) => {
96
+ var e, o;
97
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onPreview) == null ? void 0 : o.call(e, n);
98
+ return r("onPreview", n), t;
99
+ } : void 0,
100
+ onPreviewClose: l("onPreviewClose") ? () => {
101
+ var t, e;
102
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onPreviewClose) == null ? void 0 : e.call(t);
103
+ return r("onPreviewClose"), n;
104
+ } : void 0,
105
+ onAlert: l("onAlert") ? (n) => {
106
+ var e, o;
107
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onAlert) == null ? void 0 : o.call(e, n);
108
+ return r("onAlert", n), t;
109
+ } : void 0,
110
+ onEditorClose: l("onEditorClose") ? () => {
111
+ var t, e;
112
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onEditorClose) == null ? void 0 : e.call(t);
113
+ return r("onEditorClose"), n;
114
+ } : void 0,
115
+ onUnsavedChangesChange: l("onUnsavedChangesChange") ? (n) => {
116
+ var e, o;
117
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onUnsavedChangesChange) == null ? void 0 : o.call(e, n);
118
+ return r("onUnsavedChangesChange", n), t;
119
+ } : void 0,
120
+ onHiddenElementsVisibilityChange: l("onHiddenElementsVisibilityChange") ? (n) => {
121
+ var e, o;
122
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onHiddenElementsVisibilityChange) == null ? void 0 : o.call(e, n);
123
+ return r("onHiddenElementsVisibilityChange", n), t;
124
+ } : void 0,
125
+ onOpenCustomBlockDialog: l("onOpenCustomBlockDialog") ? (n) => {
126
+ var e, o;
127
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onOpenCustomBlockDialog) == null ? void 0 : o.call(e, n);
128
+ return r("onOpenCustomBlockDialog", n), t;
129
+ } : void 0,
130
+ onTemplateRename: l("onTemplateRename") ? (n) => {
131
+ var e, o;
132
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onTemplateRename) == null ? void 0 : o.call(e, n);
133
+ return r("onTemplateRename", n), t;
134
+ } : void 0,
135
+ onTemplateUpdated: l("onTemplateUpdated") ? () => {
136
+ var t, e;
137
+ const n = (e = (t = a.callbacks) == null ? void 0 : t.onTemplateUpdated) == null ? void 0 : e.call(t);
138
+ return r("onTemplateUpdated"), n;
139
+ } : void 0,
140
+ onTestingEmailsChange: l("onTestingEmailsChange") ? (n) => {
141
+ var e, o;
142
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onTestingEmailsChange) == null ? void 0 : o.call(e, n);
143
+ return r("onTestingEmailsChange", n), t;
144
+ } : void 0,
145
+ onEditorError: l("onEditorError") ? (n) => {
146
+ var e, o;
147
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onEditorError) == null ? void 0 : o.call(e, n);
148
+ return r("onEditorError", n), t;
149
+ } : void 0,
150
+ onLanguageCreated: l("onLanguageCreated") ? (n) => {
151
+ var e, o;
152
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onLanguageCreated) == null ? void 0 : o.call(e, n);
153
+ return r("onLanguageCreated", n), t;
154
+ } : void 0,
155
+ onLanguageDeleted: l("onLanguageDeleted") ? (n) => {
156
+ var e, o;
157
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onLanguageDeleted) == null ? void 0 : o.call(e, n);
158
+ return r("onLanguageDeleted", n), t;
159
+ } : void 0,
160
+ onLanguageSelected: l("onLanguageSelected") ? (n) => {
161
+ var e, o;
162
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onLanguageSelected) == null ? void 0 : o.call(e, n);
163
+ return r("onLanguageSelected", n), t;
164
+ } : void 0,
165
+ onPrimaryLanguageChanged: l("onPrimaryLanguageChanged") ? (n) => {
166
+ var e, o;
167
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onPrimaryLanguageChanged) == null ? void 0 : o.call(e, n);
168
+ return r("onPrimaryLanguageChanged", n), t;
169
+ } : void 0,
170
+ onGetMutations: l("onGetMutations") ? (n) => {
171
+ var e, o;
172
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onGetMutations) == null ? void 0 : o.call(e, n);
173
+ return r("onGetMutations", n), t;
174
+ } : void 0,
175
+ getNonce: (d = a.callbacks) != null && d.getNonce ? () => a.callbacks.getNonce() : void 0,
176
+ onCloudSave: l("onCloudSave") ? (n) => {
177
+ var e, o;
178
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onCloudSave) == null ? void 0 : o.call(e, n);
179
+ return r("onCloudSave", n), t;
180
+ } : void 0,
181
+ onCloudTemplateChange: l("onCloudTemplateChange") ? (n) => {
182
+ var e, o;
183
+ const t = (o = (e = a.callbacks) == null ? void 0 : e.onCloudTemplateChange) == null ? void 0 : o.call(e, n);
184
+ return r("onCloudTemplateChange", n), t;
185
+ } : void 0
186
+ };
187
+ try {
188
+ const n = await R.init({ config: a.options, ...i }, { stage: a.stage, loaderUrl: a.loaderUrl });
189
+ if (v) {
190
+ await n.destroy();
191
+ return;
192
+ }
193
+ u = n;
194
+ try {
195
+ await n.render(m.value);
196
+ } catch (t) {
197
+ throw await n.destroy(), u = void 0, t;
198
+ }
199
+ v || r("ready", n);
200
+ } catch (n) {
201
+ b(n);
202
+ }
203
+ }), T(() => {
204
+ v = !0;
205
+ const i = u;
206
+ u = void 0, i == null || i.destroy().catch((d) => console.warn("[@topol.io/editor-vue] EmailEditor cleanup failed:", d));
207
+ }), (i, d) => (D(), A("div", {
208
+ ref_key: "container",
209
+ ref: m,
210
+ style: { width: "100%", height: "100vh" }
211
+ }, null, 512));
212
+ }
213
+ }), M = /* @__PURE__ */ L({
214
+ __name: "LandingPageEditor",
215
+ props: {
216
+ options: {},
217
+ callbacks: {},
218
+ stage: { default: "production" },
219
+ loaderUrl: {}
220
+ },
221
+ emits: ["ready", "onSave", "onSaveAndClose", "onOpenFileManager", "onImageDelete", "onLoaded", "onInit", "onUndoChange", "onRedoChange", "onPreview", "onPreviewClose", "onAlert", "onEditorClose", "onUnsavedChangesChange", "onOpenCustomBlockDialog", "onTemplateRename", "onEditorError"],
222
+ setup(S, { expose: k, emit: p }) {
223
+ const a = S, r = p, E = [
224
+ "onSave",
225
+ "onSaveAndClose",
226
+ "onOpenFileManager",
227
+ "onImageDelete",
228
+ "onLoaded",
229
+ "onInit",
230
+ "onUndoChange",
231
+ "onRedoChange",
232
+ "onPreview",
233
+ "onPreviewClose",
234
+ "onAlert",
235
+ "onEditorClose",
236
+ "onUnsavedChangesChange",
237
+ "onOpenCustomBlockDialog",
238
+ "onTemplateRename",
239
+ "onEditorError"
240
+ ], m = U(), u = B(null), v = w(), l = (o) => {
241
+ var g;
242
+ if (typeof ((g = a.callbacks) == null ? void 0 : g[o]) == "function") return !0;
243
+ const c = v == null ? void 0 : v.vnode.props;
244
+ if (!c) return !1;
245
+ const s = "on" + o.charAt(0).toUpperCase() + o.slice(1);
246
+ return [s, s + "Once"].some((C) => typeof c[C] == "function" || Array.isArray(c[C]));
247
+ }, b = () => {
248
+ var c;
249
+ const o = {};
250
+ for (const s of E)
251
+ l(s) && (o[s] = (g) => {
252
+ var h, f;
253
+ const C = (f = (h = a.callbacks) == null ? void 0 : h[s]) == null ? void 0 : f.call(h, g);
254
+ return g === void 0 ? r(s) : r(s, g), C;
255
+ });
256
+ return typeof ((c = a.callbacks) == null ? void 0 : c.getNonce) == "function" && (o.getNonce = () => a.callbacks.getNonce()), o;
257
+ };
258
+ let i = !1;
259
+ async function d(o) {
260
+ var c;
261
+ if (o)
262
+ try {
263
+ await ((c = o.destroy) == null ? void 0 : c.call(o));
264
+ } catch (s) {
265
+ console.warn("[@topol.io/editor-vue] LandingPageEditor destroy failed:", s);
266
+ }
267
+ }
268
+ return P(async () => {
269
+ var o, c;
270
+ try {
271
+ const s = await y.init({ config: a.options, ...b() }, { stage: a.stage, loaderUrl: a.loaderUrl });
272
+ if (i) {
273
+ await d(s);
274
+ return;
275
+ }
276
+ u.value = s;
277
+ try {
278
+ await s.render(m.value);
279
+ } catch (g) {
280
+ throw u.value === s && (u.value = null), await d(s), g;
281
+ }
282
+ i || r("ready", s);
283
+ } catch (s) {
284
+ if (i) return;
285
+ const C = { source: "integration", message: s instanceof Error ? s.message : "Failed to initialize editor", detail: s };
286
+ (c = (o = a.callbacks) == null ? void 0 : o.onEditorError) == null || c.call(o, C), r("onEditorError", C), console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:", s);
287
+ }
288
+ }), T(() => {
289
+ i = !0;
290
+ const o = u.value;
291
+ u.value = null, d(o);
292
+ }), k({
293
+ load: async (o) => {
294
+ var c;
295
+ await ((c = u.value) == null ? void 0 : c.load(o));
296
+ },
297
+ save: async () => {
298
+ var o;
299
+ await ((o = u.value) == null ? void 0 : o.save());
300
+ },
301
+ getEditor: () => u.value ?? null
302
+ }), (o, c) => (D(), A("div", {
303
+ ref_key: "container",
304
+ ref: m,
305
+ style: { width: "100%", height: "100vh" }
306
+ }, null, 512));
307
+ }
308
+ });
309
+ export {
310
+ N as CoreEmailEditor,
311
+ x as CoreLandingPageEditor,
312
+ _ as EmailEditor,
313
+ M as LandingPageEditor
314
+ };
@@ -1,15 +1,145 @@
1
- import { type IStage } from '@topol.io/editor';
2
- import type { IVueEmailOptions } from './types';
1
+ import type { IEmailCallbacks, IEmailEditorInstance, IStage, IEmailErrorPayload } 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").IEmailSavePayload) => any;
13
+ onSaveAndClose: (payload: import("@topol.io/editor").IEmailSavePayload) => any;
14
+ onTestSend: (payload: import("@topol.io/editor").IEmailTestSendPayload) => 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").ISavedSectionDraft;
23
+ }) => any;
24
+ onSavedSectionRemove: (payload: {
25
+ id: number;
26
+ }) => any;
27
+ onSavedSectionEdit: (payload: {
28
+ id: number;
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
+ onUnsavedChangesChange: (payload: {
49
+ hasUnsavedChanges: boolean;
50
+ }) => any;
51
+ onHiddenElementsVisibilityChange: (payload: {
52
+ visible: boolean;
53
+ }) => any;
54
+ onOpenCustomBlockDialog: (payload: {
55
+ block: unknown;
56
+ }) => any;
57
+ onTemplateRename: (payload: {
58
+ name: string;
59
+ }) => any;
60
+ onTemplateUpdated: () => any;
61
+ onTestingEmailsChange: (payload: {
62
+ emails: string[];
63
+ }) => any;
64
+ onEditorError: (payload: IEmailErrorPayload) => 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").IEmailSavePayload) => any) | undefined;
79
+ onOnSaveAndClose?: ((payload: import("@topol.io/editor").IEmailSavePayload) => any) | undefined;
80
+ onOnTestSend?: ((payload: import("@topol.io/editor").IEmailTestSendPayload) => 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").ISavedSectionDraft;
89
+ }) => any) | undefined;
90
+ onOnSavedSectionRemove?: ((payload: {
91
+ id: number;
92
+ }) => any) | undefined;
93
+ onOnSavedSectionEdit?: ((payload: {
94
+ id: number;
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
+ onOnUnsavedChangesChange?: ((payload: {
115
+ hasUnsavedChanges: boolean;
116
+ }) => any) | undefined;
117
+ onOnHiddenElementsVisibilityChange?: ((payload: {
118
+ visible: 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
+ onOnTestingEmailsChange?: ((payload: {
128
+ emails: string[];
129
+ }) => any) | undefined;
130
+ onOnEditorError?: ((payload: IEmailErrorPayload) => 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,12 +1,21 @@
1
- import { type IStage } from '@topol.io/editor';
2
- import type { IVueLandingPageOptions } from './types';
1
+ import { type ILandingPageCallbacks, type ILandingPageEditorInstance, type IStage } from "@topol.io/editor";
2
+ import type { IVueLandingPageOptions } from "./types";
3
3
  type __VLS_Props = {
4
4
  options: IVueLandingPageOptions;
5
+ /**
6
+ * Callbacks as functions, for the ones whose result the editor uses: `getNonce` (the only
7
+ * way to pass it), and an async `onSave` / `onSaveAndClose` / `onEditorClose` the editor
8
+ * should wait for. A callback given here and its event (`@on-save`) both fire.
9
+ */
10
+ callbacks?: ILandingPageCallbacks;
5
11
  stage?: IStage;
12
+ /** Explicit loader URL, e.g. a deployed preview or a local build. One loader URL per page. */
13
+ loaderUrl?: string;
6
14
  };
7
15
  declare const _default: import("vue").DefineComponent<__VLS_Props, {
8
- load: (template: unknown) => void;
9
- save: () => void;
16
+ load: (template: unknown) => Promise<void>;
17
+ save: () => Promise<void>;
18
+ getEditor: () => ILandingPageEditorInstance | null;
10
19
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
20
  [x: string]: any;
12
21
  } & {
@@ -7,7 +7,7 @@
7
7
  * import { EmailEditor, type IVueEmailOptions } from '@topol.io/editor-vue';
8
8
  *
9
9
  * const options: IVueEmailOptions = {
10
- * authorize: { apiKey: 'your-key', userId: 'user-123' },
10
+ * authorize: { apiKey: 'your-key', entityId: 'user-123' },
11
11
  * };
12
12
  * </script>
13
13
  *
@@ -22,7 +22,7 @@
22
22
  * import { LandingPageEditor, type IVueLandingPageOptions } from '@topol.io/editor-vue';
23
23
  *
24
24
  * const options: IVueLandingPageOptions = {
25
- * authorize: { apiKey: 'your-key', userId: 'user-123' },
25
+ * authorize: { apiKey: 'your-key', entityId: 'user-123' },
26
26
  * };
27
27
  * </script>
28
28
  *
@@ -31,12 +31,8 @@
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';
37
- /**
38
- * @deprecated Use EmailEditor instead. TopolEditor is an alias for backwards compatibility.
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';
34
+ export { 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
+ export type { IVueEmailOptions, IVueLandingPageOptions } from "./types";
38
+ export type { IEmailOptions, IEmailConfig, IEmailCallbacks, IEmailEditorInstance, IEmailEditorPluginOptions, IEmailSavePayload, IEmailErrorPayload, IEmailTestSendPayload, IEmailDeletedItem, IUpdateTemplateOptions, ILanguageMutation, ILanguageChangePayload, ILandingPageOptions, ILandingPageConfig, ILandingPageCallbacks, ILandingPageEditorInstance, ILandingPageEditorPluginOptions, ILandingPageSavePayload, ILandingPageErrorPayload, ILandingPageDeletedItem, IStage, EditorErrorSource, INonceAuthCallbacks, IAuthorize, EmailEditorShortcut, LandingPageEditorShortcut, INotification, ICloudOptions, ICloudFeatures, ICloudCallbacks, ICloudSavePayload, ICloudTemplateChangePayload, ICountdownOptions, ICountdownDefaultColors, ICountdownDateMergeTag, ISavedSection, ISavedSectionDraft, IPremadeSection, IPremadeSections, IPremadeSectionsOptions, } from "@topol.io/editor";
@@ -1,19 +1,11 @@
1
+ import type { IEmailConfig, ILandingPageConfig } from "@topol.io/editor";
1
2
  /**
2
- * Type re-exports from core package and Vue-specific types.
3
+ * The `options` prop of the EmailEditor component: the editor config.
4
+ * Callbacks are passed through the `callbacks` prop or as events.
3
5
  */
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';
6
+ export type IVueEmailOptions = IEmailConfig;
6
7
  /**
7
- * Vue-specific options for EmailEditor component.
8
- * Omits 'id' and 'callbacks' as they are handled internally by the Vue wrapper.
8
+ * The `options` prop of the LandingPageEditor component: the editor config.
9
+ * Callbacks are passed through the `callbacks` prop or as events.
9
10
  */
10
- export type IVueEmailOptions = Omit<ITopolOptions, 'id' | 'callbacks'>;
11
- /**
12
- * Vue-specific options for LandingPageEditor component.
13
- * Contains only the config options, as callbacks are handled as Vue emits.
14
- */
15
- export type IVueLandingPageOptions = ILandingPageOptions['config'];
16
- /**
17
- * @deprecated Use IVueEmailOptions instead.
18
- */
19
- export type IVueOptions = IVueEmailOptions;
11
+ export type IVueLandingPageOptions = ILandingPageConfig;
package/package.json CHANGED
@@ -14,22 +14,22 @@
14
14
  "author": "Topol.io",
15
15
  "homepage": "https://topol.io",
16
16
  "license": "Apache-2.0",
17
- "version": "1.0.0-alpha.9",
17
+ "version": "1.0.0",
18
18
  "type": "module",
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "module": "./dist/topol-editor-vue.es.js",
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.js",
23
24
  "types": "./dist/types/entry.d.ts",
24
25
  "exports": {
25
26
  ".": {
26
27
  "types": "./dist/types/entry.d.ts",
27
- "import": "./dist/topol-editor-vue.es.js",
28
- "require": "./dist/topol-editor-vue.umd.js"
28
+ "default": "./dist/index.js"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@topol.io/editor": "1.0.0-alpha.9"
32
+ "@topol.io/editor": "1.0.0"
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,236 +0,0 @@
1
- import { EmailEditor as L, LandingPageEditor as A } from "@topol.io/editor";
2
- import { EmailEditor as b, LandingPageEditor as x, default as G } from "@topol.io/editor";
3
- import { defineComponent as m, onMounted as C, onBeforeUnmount as k, createElementBlock as B, openBlock as v, ref as T, getCurrentInstance as P, createBlock as R } from "vue";
4
- const O = "topol-email-editor-id", y = /* @__PURE__ */ m({
5
- __name: "EmailEditor",
6
- props: {
7
- options: {},
8
- stage: { default: "production" }
9
- },
10
- emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses", "onError", "onLanguageCreated", "onLanguageDeleted", "onLanguageSelected", "onPrimaryLanguageChanged", "onGetMutations"],
11
- setup(l, { emit: g }) {
12
- const r = l, e = g, s = () => ({
13
- onSave(o, n, i, u) {
14
- e("onSave", { json: o, html: n, mutations: i, syncedSections: u });
15
- },
16
- onSaveAndClose(o, n, i, u) {
17
- e("onSaveAndClose", { json: o, html: n, mutations: i, syncedSections: u });
18
- },
19
- onTestSend(o, n, i) {
20
- e("onTestSend", { email: o, json: n, html: i });
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, i) {
71
- e("onError", { type: o, message: n, responseBody: i });
72
- },
73
- onLanguageCreated(o, n) {
74
- e("onLanguageCreated", { lang: o, mutations: n });
75
- },
76
- onLanguageDeleted(o, n) {
77
- e("onLanguageDeleted", { lang: o, mutations: n });
78
- },
79
- onLanguageSelected(o) {
80
- e("onLanguageSelected", { lang: o });
81
- },
82
- onPrimaryLanguageChanged(o, n) {
83
- e("onPrimaryLanguageChanged", { lang: o, mutations: n });
84
- },
85
- onGetMutations(o) {
86
- e("onGetMutations", { mutations: o });
87
- }
88
- });
89
- return C(async () => {
90
- try {
91
- const o = {
92
- id: "#" + O,
93
- ...r.options,
94
- callbacks: s()
95
- };
96
- await L.init(o, { stage: r.stage });
97
- } catch (o) {
98
- const n = o instanceof Error ? o.message : "Failed to initialize editor";
99
- e("onError", { type: "init", message: n }), console.error("[@topol.io/editor-vue] EmailEditor initialization failed:", o);
100
- }
101
- }), k(() => {
102
- L.destroy();
103
- }), (o, n) => (v(), B("div", {
104
- id: O,
105
- style: { position: "absolute", width: "100%", height: "100vh" }
106
- }));
107
- }
108
- }), S = "topol-landing-page-editor-id", I = /* @__PURE__ */ m({
109
- __name: "LandingPageEditor",
110
- props: {
111
- options: {},
112
- stage: { default: "production" }
113
- },
114
- emits: ["onSave", "onSaveAndClose", "onOpenFileManager", "onImageDelete", "onLoaded", "onInit", "onUndoChange", "onRedoChange", "onPreview", "onPreviewClose", "onAlert", "onEditorClose", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "onEditorError"],
115
- setup(l, { expose: g, emit: r }) {
116
- const e = l, s = r, o = [
117
- "onSave",
118
- "onSaveAndClose",
119
- "onOpenFileManager",
120
- "onImageDelete",
121
- "onLoaded",
122
- "onInit",
123
- "onUndoChange",
124
- "onRedoChange",
125
- "onPreview",
126
- "onPreviewClose",
127
- "onAlert",
128
- "onEditorClose",
129
- "onEdittedWithoutSaveChanged",
130
- "onOpenCustomBlockDialog",
131
- "onTemplateRename",
132
- "onEditorError"
133
- ], n = T(null), i = P(), u = (t) => {
134
- const a = i == null ? void 0 : i.vnode.props;
135
- if (!a) return !1;
136
- const d = "on" + t.charAt(0).toUpperCase() + t.slice(1);
137
- return typeof a[d] == "function" || Array.isArray(a[d]);
138
- }, f = () => {
139
- const t = {};
140
- for (const a of o)
141
- u(a) && (t[a] = (d) => {
142
- d === void 0 ? s(a) : s(a, d);
143
- });
144
- return t;
145
- };
146
- let p = !1;
147
- async function E(t) {
148
- var a;
149
- if (t)
150
- try {
151
- await ((a = t.destroy) == null ? void 0 : a.call(t));
152
- } catch (d) {
153
- console.warn("[@topol.io/editor-vue] LandingPageEditor destroy failed:", d);
154
- }
155
- }
156
- return C(async () => {
157
- try {
158
- const t = await A.init({ config: e.options, ...f() }, { stage: e.stage });
159
- if (p) {
160
- await E(t);
161
- return;
162
- }
163
- n.value = t, await t.render("#" + S);
164
- } catch (t) {
165
- if (p) return;
166
- const a = t instanceof Error ? t.message : "Failed to initialize editor";
167
- s("onEditorError", { source: "init", message: a, detail: t }), console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:", t);
168
- }
169
- }), k(() => {
170
- p = !0;
171
- const t = n.value;
172
- n.value = null, E(t);
173
- }), g({
174
- load: (t) => {
175
- var a;
176
- (a = n.value) == null || a.load(t);
177
- },
178
- save: () => {
179
- var t;
180
- (t = n.value) == null || t.save();
181
- }
182
- }), (t, a) => (v(), B("div", {
183
- id: S,
184
- style: { position: "absolute", width: "100%", height: "100vh" }
185
- }));
186
- }
187
- }), U = /* @__PURE__ */ m({
188
- __name: "TopolEditor",
189
- props: {
190
- options: {},
191
- stage: { default: "production" }
192
- },
193
- emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses", "onError", "onLanguageCreated", "onLanguageDeleted", "onLanguageSelected", "onPrimaryLanguageChanged", "onGetMutations"],
194
- setup(l, { emit: g }) {
195
- const r = l, e = g;
196
- return C(() => {
197
- console.warn("[@topol.io/editor-vue] TopolEditor is deprecated and will be removed in a future version. Please use EmailEditor instead.");
198
- }), (s, o) => (v(), R(y, {
199
- options: r.options,
200
- stage: r.stage,
201
- onOnSave: o[0] || (o[0] = (n) => e("onSave", n)),
202
- onOnSaveAndClose: o[1] || (o[1] = (n) => e("onSaveAndClose", n)),
203
- onOnTestSend: o[2] || (o[2] = (n) => e("onTestSend", n)),
204
- onOnOpenFileManager: o[3] || (o[3] = () => e("onOpenFileManager")),
205
- onOnLoaded: o[4] || (o[4] = () => e("onLoaded")),
206
- onOnBlockSave: o[5] || (o[5] = (n) => e("onBlockSave", n)),
207
- onOnBlockRemove: o[6] || (o[6] = (n) => e("onBlockRemove", n)),
208
- onOnBlockEdit: o[7] || (o[7] = (n) => e("onBlockEdit", n)),
209
- onOnInit: o[8] || (o[8] = () => e("onInit")),
210
- onOnClose: o[9] || (o[9] = () => e("onClose")),
211
- onOnUndoChange: o[10] || (o[10] = (n) => e("onUndoChange", n)),
212
- onOnRedoChange: o[11] || (o[11] = (n) => e("onRedoChange", n)),
213
- onOnPreview: o[12] || (o[12] = (n) => e("onPreview", n)),
214
- onOnAlert: o[13] || (o[13] = (n) => e("onAlert", n)),
215
- onOnBannerClick: o[14] || (o[14] = (n) => e("onBannerClick", n)),
216
- onOnEdittedWithoutSaveChanged: o[15] || (o[15] = (n) => e("onEdittedWithoutSaveChanged", n)),
217
- onOnOpenCustomBlockDialog: o[16] || (o[16] = (n) => e("onOpenCustomBlockDialog", n)),
218
- onOnTemplateRename: o[17] || (o[17] = (n) => e("onTemplateRename", n)),
219
- onUpdateTestingEmailAddresses: o[18] || (o[18] = (n) => e("updateTestingEmailAddresses", n)),
220
- onOnError: o[19] || (o[19] = (n) => e("onError", n)),
221
- onOnLanguageCreated: o[20] || (o[20] = (n) => e("onLanguageCreated", n)),
222
- onOnLanguageDeleted: o[21] || (o[21] = (n) => e("onLanguageDeleted", n)),
223
- onOnLanguageSelected: o[22] || (o[22] = (n) => e("onLanguageSelected", n)),
224
- onOnPrimaryLanguageChanged: o[23] || (o[23] = (n) => e("onPrimaryLanguageChanged", n)),
225
- onOnGetMutations: o[24] || (o[24] = (n) => e("onGetMutations", n))
226
- }, null, 8, ["options", "stage"]));
227
- }
228
- });
229
- export {
230
- b as CoreEmailEditor,
231
- x as CoreLandingPageEditor,
232
- y as EmailEditor,
233
- I as LandingPageEditor,
234
- U as TopolEditor,
235
- G as TopolPlugin
236
- };
@@ -1 +0,0 @@
1
- (function(r,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@topol.io/editor"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@topol.io/editor","vue"],l):(r=typeof globalThis<"u"?globalThis:r||self,l(r["topol-editor-vue"]={},r.editor,r.Vue))})(this,function(r,l,i){"use strict";const v="topol-email-editor-id",f=i.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","onLanguageCreated","onLanguageDeleted","onLanguageSelected","onPrimaryLanguageChanged","onGetMutations"],setup(p,{emit:m}){const s=p,e=m,u=()=>({onSave(n,o,d,C){e("onSave",{json:n,html:o,mutations:d,syncedSections:C})},onSaveAndClose(n,o,d,C){e("onSaveAndClose",{json:n,html:o,mutations:d,syncedSections:C})},onTestSend(n,o,d){e("onTestSend",{email:n,json:o,html:d})},onOpenFileManager(){e("onOpenFileManager")},onLoaded(){e("onLoaded")},onBlockSave(n){e("onBlockSave",n)},onBlockRemove(n){e("onBlockRemove",n)},onBlockEdit(n){e("onBlockEdit",n)},onInit(){e("onInit")},onUndoChange(n){e("onUndoChange",n)},onRedoChange(n){e("onRedoChange",n)},onPreview(n){e("onPreview",n)},onAlert(n){e("onAlert",n)},onClose(){e("onClose")},onBannerClick(n,o){e("onBannerClick",{json:n,html:o})},onEdittedWithoutSaveChanged(n){e("onEdittedWithoutSaveChanged",n)},onOpenCustomBlockDialog(n){e("onOpenCustomBlockDialog",n)},onTemplateRename(n){e("onTemplateRename",n)},updateTestingEmailAddresses(n){e("updateTestingEmailAddresses",n)},onError(n,o,d){e("onError",{type:n,message:o,responseBody:d})},onLanguageCreated(n,o){e("onLanguageCreated",{lang:n,mutations:o})},onLanguageDeleted(n,o){e("onLanguageDeleted",{lang:n,mutations:o})},onLanguageSelected(n){e("onLanguageSelected",{lang:n})},onPrimaryLanguageChanged(n,o){e("onPrimaryLanguageChanged",{lang:n,mutations:o})},onGetMutations(n){e("onGetMutations",{mutations:n})}});return i.onMounted(async()=>{try{const n={id:"#"+v,...s.options,callbacks:u()};await l.EmailEditor.init(n,{stage:s.stage})}catch(n){const o=n instanceof Error?n.message:"Failed to initialize editor";e("onError",{type:"init",message:o}),console.error("[@topol.io/editor-vue] EmailEditor initialization failed:",n)}}),i.onBeforeUnmount(()=>{l.EmailEditor.destroy()}),(n,o)=>(i.openBlock(),i.createElementBlock("div",{id:v,style:{position:"absolute",width:"100%",height:"100vh"}}))}}),O="topol-landing-page-editor-id",L=i.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(p,{expose:m,emit:s}){const e=p,u=s,n=["onSave","onSaveAndClose","onOpenFileManager","onImageDelete","onLoaded","onInit","onUndoChange","onRedoChange","onPreview","onPreviewClose","onAlert","onEditorClose","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","onEditorError"],o=i.ref(null),d=i.getCurrentInstance(),C=t=>{const a=d==null?void 0:d.vnode.props;if(!a)return!1;const g="on"+t.charAt(0).toUpperCase()+t.slice(1);return typeof a[g]=="function"||Array.isArray(a[g])},B=()=>{const t={};for(const a of n)C(a)&&(t[a]=g=>{g===void 0?u(a):u(a,g)});return t};let E=!1;async function S(t){var a;if(t)try{await((a=t.destroy)==null?void 0:a.call(t))}catch(g){console.warn("[@topol.io/editor-vue] LandingPageEditor destroy failed:",g)}}return i.onMounted(async()=>{try{const t=await l.LandingPageEditor.init({config:e.options,...B()},{stage:e.stage});if(E){await S(t);return}o.value=t,await t.render("#"+O)}catch(t){if(E)return;const a=t instanceof Error?t.message:"Failed to initialize editor";u("onEditorError",{source:"init",message:a,detail:t}),console.error("[@topol.io/editor-vue] LandingPageEditor initialization failed:",t)}}),i.onBeforeUnmount(()=>{E=!0;const t=o.value;o.value=null,S(t)}),m({load:t=>{var a;(a=o.value)==null||a.load(t)},save:()=>{var t;(t=o.value)==null||t.save()}}),(t,a)=>(i.openBlock(),i.createElementBlock("div",{id:O,style:{position:"absolute",width:"100%",height:"100vh"}}))}}),k=i.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","onLanguageCreated","onLanguageDeleted","onLanguageSelected","onPrimaryLanguageChanged","onGetMutations"],setup(p,{emit:m}){const s=p,e=m;return i.onMounted(()=>{console.warn("[@topol.io/editor-vue] TopolEditor is deprecated and will be removed in a future version. Please use EmailEditor instead.")}),(u,n)=>(i.openBlock(),i.createBlock(f,{options:s.options,stage:s.stage,onOnSave:n[0]||(n[0]=o=>e("onSave",o)),onOnSaveAndClose:n[1]||(n[1]=o=>e("onSaveAndClose",o)),onOnTestSend:n[2]||(n[2]=o=>e("onTestSend",o)),onOnOpenFileManager:n[3]||(n[3]=()=>e("onOpenFileManager")),onOnLoaded:n[4]||(n[4]=()=>e("onLoaded")),onOnBlockSave:n[5]||(n[5]=o=>e("onBlockSave",o)),onOnBlockRemove:n[6]||(n[6]=o=>e("onBlockRemove",o)),onOnBlockEdit:n[7]||(n[7]=o=>e("onBlockEdit",o)),onOnInit:n[8]||(n[8]=()=>e("onInit")),onOnClose:n[9]||(n[9]=()=>e("onClose")),onOnUndoChange:n[10]||(n[10]=o=>e("onUndoChange",o)),onOnRedoChange:n[11]||(n[11]=o=>e("onRedoChange",o)),onOnPreview:n[12]||(n[12]=o=>e("onPreview",o)),onOnAlert:n[13]||(n[13]=o=>e("onAlert",o)),onOnBannerClick:n[14]||(n[14]=o=>e("onBannerClick",o)),onOnEdittedWithoutSaveChanged:n[15]||(n[15]=o=>e("onEdittedWithoutSaveChanged",o)),onOnOpenCustomBlockDialog:n[16]||(n[16]=o=>e("onOpenCustomBlockDialog",o)),onOnTemplateRename:n[17]||(n[17]=o=>e("onTemplateRename",o)),onUpdateTestingEmailAddresses:n[18]||(n[18]=o=>e("updateTestingEmailAddresses",o)),onOnError:n[19]||(n[19]=o=>e("onError",o)),onOnLanguageCreated:n[20]||(n[20]=o=>e("onLanguageCreated",o)),onOnLanguageDeleted:n[21]||(n[21]=o=>e("onLanguageDeleted",o)),onOnLanguageSelected:n[22]||(n[22]=o=>e("onLanguageSelected",o)),onOnPrimaryLanguageChanged:n[23]||(n[23]=o=>e("onPrimaryLanguageChanged",o)),onOnGetMutations:n[24]||(n[24]=o=>e("onGetMutations",o))},null,8,["options","stage"]))}});Object.defineProperty(r,"CoreEmailEditor",{enumerable:!0,get:()=>l.EmailEditor}),Object.defineProperty(r,"CoreLandingPageEditor",{enumerable:!0,get:()=>l.LandingPageEditor}),r.TopolPlugin=l,r.EmailEditor=f,r.LandingPageEditor=L,r.TopolEditor=k,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
@@ -1,16 +0,0 @@
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;