@topol.io/editor-svelte 1.0.0-alpha.10 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -29
- package/dist/EmailEditor.svelte +115 -212
- package/dist/EmailEditor.svelte.d.ts +22 -123
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/package.json +8 -8
- package/dist/svelte-internal.d.ts +0 -7
package/README.md
CHANGED
|
@@ -1,55 +1,61 @@
|
|
|
1
1
|
# @topol.io/editor-svelte — 1.x alpha
|
|
2
2
|
|
|
3
|
-
Svelte
|
|
3
|
+
Svelte 5 wrapper for Email Editor v4, from the 1.x alpha line onward. Svelte 4 is not
|
|
4
|
+
supported; stay on `@topol.io/editor-svelte@0.3` until you upgrade Svelte.
|
|
4
5
|
|
|
5
6
|
```svelte
|
|
6
7
|
<script lang="ts">
|
|
7
|
-
import { EmailEditor, type
|
|
8
|
-
const options:
|
|
9
|
-
authorize: { apiKey: "pk_your-key",
|
|
8
|
+
import { EmailEditor, type ISvelteEmailOptions } from "@topol.io/editor-svelte";
|
|
9
|
+
const options: ISvelteEmailOptions = {
|
|
10
|
+
authorize: { apiKey: "pk_your-key", entityId: "user-123" },
|
|
10
11
|
cloud: { enabled: true },
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
};
|
|
13
|
+
async function 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;
|
|
17
|
+
}
|
|
19
18
|
</script>
|
|
20
19
|
|
|
21
20
|
<EmailEditor
|
|
22
21
|
{options}
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
{getNonce}
|
|
23
|
+
onCloudSave={({ templateId }) => console.log(templateId)}
|
|
24
|
+
onEditorError={({ message }) => console.error(message)}
|
|
26
25
|
/>
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
Every editor callback is a **prop** that receives the exact v4 payload object, for
|
|
29
|
+
example `onSave({ json, html })` or `onLanguageCreated({ code })`. A callback may return
|
|
30
|
+
a promise (`onSave`, `onSaveAndClose`, `onEditorClose`, `getNonce`) and the editor waits
|
|
31
|
+
for it. `IEmailEditorProps` is the type of all props.
|
|
32
|
+
|
|
33
|
+
The `on:` events and the `callbacks` prop of earlier 1.x alphas are removed:
|
|
34
|
+
|
|
35
|
+
```diff
|
|
36
|
+
- <EmailEditor {options} callbacks={{ getNonce, onSave }} on:onEditorError={(e) => report(e.detail)} />
|
|
37
|
+
+ <EmailEditor {options} {getNonce} {onSave} onEditorError={(payload) => report(payload)} />
|
|
38
|
+
```
|
|
34
39
|
|
|
35
40
|
Use `bind:this={component}` and `component.getEditor()` for async instance methods,
|
|
36
|
-
or
|
|
37
|
-
|
|
38
|
-
`
|
|
41
|
+
or pass `onReady` to receive the instance. `CoreEmailEditor` exposes the core v4
|
|
42
|
+
factory. `ISvelteEmailOptions` (formerly `ISvelteOptions`) is the type of `options`;
|
|
43
|
+
`IEmailOptions` is the core `{ config, ...callbacks }` type.
|
|
39
44
|
|
|
40
45
|
`options` contains the v4 configuration (`IEmailConfig`). A `getNonce` callback that
|
|
41
46
|
fetches a fresh `nc_` token from your application's authenticated backend enables
|
|
42
47
|
nonce authentication on its own; Cloud additionally requires it. Never put an `sk_`
|
|
43
48
|
secret in browser code. See the core package README for nonce authentication, Cloud
|
|
44
|
-
feature options, the Countdown block (`
|
|
49
|
+
feature options, the Countdown block (`countdown`; see the
|
|
45
50
|
[option reference](https://docs.topol.io/email-editor/reference/topol-options#countdown))
|
|
46
51
|
and all v4 renames.
|
|
47
52
|
|
|
48
|
-
Configuration and the presence of callback
|
|
49
|
-
with a
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
Configuration and the presence of callback props are captured on mount. Remount
|
|
54
|
+
with a `{#key}` block to change them; a callback that was present on mount always
|
|
55
|
+
calls its latest value. `onReady` means the iframe has rendered; `onInit` reports
|
|
56
|
+
editor authentication. The container is `width: 100%; height: 100vh` by default;
|
|
57
|
+
pass `class` or `style` to change it. Each component owns its own instance and
|
|
58
|
+
destroys it on unmount, including when initialization is still pending.
|
|
53
59
|
|
|
54
60
|
Use `loaderUrl` for an explicit v4 local/preview loader. A numeric `stage` selects
|
|
55
|
-
a PR preview. `TopolEditor`
|
|
61
|
+
a PR preview. The `TopolEditor` alias is removed; import `EmailEditor`.
|
package/dist/EmailEditor.svelte
CHANGED
|
@@ -1,221 +1,124 @@
|
|
|
1
1
|
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
module
|
|
3
|
+
lang="ts"
|
|
4
|
+
>
|
|
5
|
+
import type { IEmailConfig, IEmailCallbacks, IEmailEditorInstance, IEmailEditorPluginOptions } from "@topol.io/editor";
|
|
6
|
+
export type ISvelteEmailOptions = IEmailConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Props of the EmailEditor component: the editor `config` as `options`, plus every editor
|
|
9
|
+
* callback as a prop. Each callback receives a single payload object (e.g.
|
|
10
|
+
* `onSave({ json, html })`); see `IEmailCallbacks`. Passing `getNonce` turns nonce
|
|
11
|
+
* authentication on.
|
|
12
|
+
*/
|
|
13
|
+
export interface IEmailEditorProps extends IEmailCallbacks, IEmailEditorPluginOptions {
|
|
14
|
+
options: ISvelteEmailOptions;
|
|
15
|
+
/** Called once the editor iframe has rendered, with the running instance. */
|
|
16
|
+
onReady?(editor: IEmailEditorInstance): void;
|
|
17
|
+
/** Class of the container element. */
|
|
18
|
+
class?: string;
|
|
19
|
+
/** Inline styles of the container element, applied after the default `width: 100%; height: 100vh`. */
|
|
20
|
+
style?: string;
|
|
21
|
+
}
|
|
5
22
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return result;
|
|
69
|
-
} : void 0,
|
|
70
|
-
onSavedSectionRemove: hasHandler("onSavedSectionRemove") ? (payload) => {
|
|
71
|
-
const result = callbacks.onSavedSectionRemove?.(payload);
|
|
72
|
-
dispatch("onSavedSectionRemove", payload);
|
|
73
|
-
return result;
|
|
74
|
-
} : void 0,
|
|
75
|
-
onSavedSectionEdit: hasHandler("onSavedSectionEdit") ? (payload) => {
|
|
76
|
-
const result = callbacks.onSavedSectionEdit?.(payload);
|
|
77
|
-
dispatch("onSavedSectionEdit", payload);
|
|
78
|
-
return result;
|
|
79
|
-
} : void 0,
|
|
80
|
-
onImageDelete: hasHandler("onImageDelete") ? (payload) => {
|
|
81
|
-
const result = callbacks.onImageDelete?.(payload);
|
|
82
|
-
dispatch("onImageDelete", payload);
|
|
83
|
-
return result;
|
|
84
|
-
} : void 0,
|
|
85
|
-
onInit: hasHandler("onInit") ? () => {
|
|
86
|
-
const result = callbacks.onInit?.();
|
|
87
|
-
dispatch("onInit");
|
|
88
|
-
return result;
|
|
89
|
-
} : void 0,
|
|
90
|
-
onUndoChange: hasHandler("onUndoChange") ? (payload) => {
|
|
91
|
-
const result = callbacks.onUndoChange?.(payload);
|
|
92
|
-
dispatch("onUndoChange", payload);
|
|
93
|
-
return result;
|
|
94
|
-
} : void 0,
|
|
95
|
-
onRedoChange: hasHandler("onRedoChange") ? (payload) => {
|
|
96
|
-
const result = callbacks.onRedoChange?.(payload);
|
|
97
|
-
dispatch("onRedoChange", payload);
|
|
98
|
-
return result;
|
|
99
|
-
} : void 0,
|
|
100
|
-
onPreview: hasHandler("onPreview") ? (payload) => {
|
|
101
|
-
const result = callbacks.onPreview?.(payload);
|
|
102
|
-
dispatch("onPreview", payload);
|
|
103
|
-
return result;
|
|
104
|
-
} : void 0,
|
|
105
|
-
onPreviewClose: hasHandler("onPreviewClose") ? () => {
|
|
106
|
-
const result = callbacks.onPreviewClose?.();
|
|
107
|
-
dispatch("onPreviewClose");
|
|
108
|
-
return result;
|
|
109
|
-
} : void 0,
|
|
110
|
-
onAlert: hasHandler("onAlert") ? (payload) => {
|
|
111
|
-
const result = callbacks.onAlert?.(payload);
|
|
112
|
-
dispatch("onAlert", payload);
|
|
113
|
-
return result;
|
|
114
|
-
} : void 0,
|
|
115
|
-
onEditorClose: hasHandler("onEditorClose") ? () => {
|
|
116
|
-
const result = callbacks.onEditorClose?.();
|
|
117
|
-
dispatch("onEditorClose");
|
|
118
|
-
return result;
|
|
119
|
-
} : void 0,
|
|
120
|
-
onEdittedWithoutSaveChanged: hasHandler("onEdittedWithoutSaveChanged") ? (payload) => {
|
|
121
|
-
const result = callbacks.onEdittedWithoutSaveChanged?.(payload);
|
|
122
|
-
dispatch("onEdittedWithoutSaveChanged", payload);
|
|
123
|
-
return result;
|
|
124
|
-
} : void 0,
|
|
125
|
-
onBlocksAndStructuresVisibilityChange: hasHandler("onBlocksAndStructuresVisibilityChange") ? (payload) => {
|
|
126
|
-
const result = callbacks.onBlocksAndStructuresVisibilityChange?.(payload);
|
|
127
|
-
dispatch("onBlocksAndStructuresVisibilityChange", payload);
|
|
128
|
-
return result;
|
|
129
|
-
} : void 0,
|
|
130
|
-
onOpenCustomBlockDialog: hasHandler("onOpenCustomBlockDialog") ? (payload) => {
|
|
131
|
-
const result = callbacks.onOpenCustomBlockDialog?.(payload);
|
|
132
|
-
dispatch("onOpenCustomBlockDialog", payload);
|
|
133
|
-
return result;
|
|
134
|
-
} : void 0,
|
|
135
|
-
onTemplateRename: hasHandler("onTemplateRename") ? (payload) => {
|
|
136
|
-
const result = callbacks.onTemplateRename?.(payload);
|
|
137
|
-
dispatch("onTemplateRename", payload);
|
|
138
|
-
return result;
|
|
139
|
-
} : void 0,
|
|
140
|
-
onTemplateUpdated: hasHandler("onTemplateUpdated") ? () => {
|
|
141
|
-
const result = callbacks.onTemplateUpdated?.();
|
|
142
|
-
dispatch("onTemplateUpdated");
|
|
143
|
-
return result;
|
|
144
|
-
} : void 0,
|
|
145
|
-
updateTestingEmailAddresses: hasHandler("updateTestingEmailAddresses") ? (payload) => {
|
|
146
|
-
const result = callbacks.updateTestingEmailAddresses?.(payload);
|
|
147
|
-
dispatch("updateTestingEmailAddresses", payload);
|
|
148
|
-
return result;
|
|
149
|
-
} : void 0,
|
|
150
|
-
onEditorError: hasHandler("onEditorError") ? (payload) => {
|
|
151
|
-
const result = callbacks.onEditorError?.(payload);
|
|
152
|
-
dispatch("onEditorError", payload);
|
|
153
|
-
return result;
|
|
154
|
-
} : void 0,
|
|
155
|
-
onLanguageCreated: hasHandler("onLanguageCreated") ? (payload) => {
|
|
156
|
-
const result = callbacks.onLanguageCreated?.(payload);
|
|
157
|
-
dispatch("onLanguageCreated", payload);
|
|
158
|
-
return result;
|
|
159
|
-
} : void 0,
|
|
160
|
-
onLanguageDeleted: hasHandler("onLanguageDeleted") ? (payload) => {
|
|
161
|
-
const result = callbacks.onLanguageDeleted?.(payload);
|
|
162
|
-
dispatch("onLanguageDeleted", payload);
|
|
163
|
-
return result;
|
|
164
|
-
} : void 0,
|
|
165
|
-
onLanguageSelected: hasHandler("onLanguageSelected") ? (payload) => {
|
|
166
|
-
const result = callbacks.onLanguageSelected?.(payload);
|
|
167
|
-
dispatch("onLanguageSelected", payload);
|
|
168
|
-
return result;
|
|
169
|
-
} : void 0,
|
|
170
|
-
onPrimaryLanguageChanged: hasHandler("onPrimaryLanguageChanged") ? (payload) => {
|
|
171
|
-
const result = callbacks.onPrimaryLanguageChanged?.(payload);
|
|
172
|
-
dispatch("onPrimaryLanguageChanged", payload);
|
|
173
|
-
return result;
|
|
174
|
-
} : void 0,
|
|
175
|
-
onGetMutations: hasHandler("onGetMutations") ? (payload) => {
|
|
176
|
-
const result = callbacks.onGetMutations?.(payload);
|
|
177
|
-
dispatch("onGetMutations", payload);
|
|
178
|
-
return result;
|
|
179
|
-
} : void 0,
|
|
180
|
-
getNonce: callbacks.getNonce ? () => callbacks.getNonce() : void 0,
|
|
181
|
-
onCloudSave: hasHandler("onCloudSave") ? (payload) => {
|
|
182
|
-
const result = callbacks.onCloudSave?.(payload);
|
|
183
|
-
dispatch("onCloudSave", payload);
|
|
184
|
-
return result;
|
|
185
|
-
} : void 0,
|
|
186
|
-
onCloudTemplateChange: hasHandler("onCloudTemplateChange") ? (payload) => {
|
|
187
|
-
const result = callbacks.onCloudTemplateChange?.(payload);
|
|
188
|
-
dispatch("onCloudTemplateChange", payload);
|
|
189
|
-
return result;
|
|
190
|
-
} : void 0
|
|
23
|
+
/** Every editor callback. The `satisfies` clause fails the build when `IEmailCallbacks` gains one. */
|
|
24
|
+
const CALLBACK_NAMES = Object.keys({
|
|
25
|
+
onSave: true,
|
|
26
|
+
onSaveAndClose: true,
|
|
27
|
+
onTestSend: true,
|
|
28
|
+
onBannerClick: true,
|
|
29
|
+
onOpenFileManager: true,
|
|
30
|
+
onLoaded: true,
|
|
31
|
+
onSavedSectionSave: true,
|
|
32
|
+
onSavedSectionRemove: true,
|
|
33
|
+
onSavedSectionEdit: true,
|
|
34
|
+
onImageDelete: true,
|
|
35
|
+
onInit: true,
|
|
36
|
+
onUndoChange: true,
|
|
37
|
+
onRedoChange: true,
|
|
38
|
+
onPreview: true,
|
|
39
|
+
onPreviewClose: true,
|
|
40
|
+
onAlert: true,
|
|
41
|
+
onEditorClose: true,
|
|
42
|
+
onUnsavedChangesChange: true,
|
|
43
|
+
onEdittedWithoutSaveChanged: true,
|
|
44
|
+
onHiddenElementsVisibilityChange: true,
|
|
45
|
+
onBlocksAndStructuresVisibilityChange: true,
|
|
46
|
+
onOpenCustomBlockDialog: true,
|
|
47
|
+
onTemplateRename: true,
|
|
48
|
+
onTemplateUpdated: true,
|
|
49
|
+
onTestingEmailsChange: true,
|
|
50
|
+
updateTestingEmailAddresses: true,
|
|
51
|
+
onEditorError: true,
|
|
52
|
+
onLanguageCreated: true,
|
|
53
|
+
onLanguageDeleted: true,
|
|
54
|
+
onLanguageSelected: true,
|
|
55
|
+
onPrimaryLanguageChanged: true,
|
|
56
|
+
onGetMutations: true,
|
|
57
|
+
getNonce: true,
|
|
58
|
+
onCloudSave: true,
|
|
59
|
+
onCloudTemplateChange: true,
|
|
60
|
+
} satisfies Record<keyof IEmailCallbacks, true>) as Array<keyof IEmailCallbacks>;
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<script lang="ts">
|
|
64
|
+
import { onMount } from "svelte";
|
|
65
|
+
import { EmailEditor as CoreEmailEditor } from "@topol.io/editor";
|
|
66
|
+
import type { IEmailErrorPayload } from "@topol.io/editor";
|
|
67
|
+
|
|
68
|
+
const props: IEmailEditorProps = $props();
|
|
69
|
+
let container: HTMLDivElement;
|
|
70
|
+
let editor: IEmailEditorInstance | null = null;
|
|
71
|
+
|
|
72
|
+
/** The running editor instance, for its methods; `null` before it has started. */
|
|
73
|
+
export function getEditor(): IEmailEditorInstance | null {
|
|
74
|
+
return editor;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onMount(() => {
|
|
78
|
+
let disposed = false;
|
|
79
|
+
let owned: IEmailEditorInstance | undefined;
|
|
80
|
+
const reportError = (error: unknown) => {
|
|
81
|
+
if (disposed) return;
|
|
82
|
+
const payload: IEmailErrorPayload = { source: "integration", message: error instanceof Error ? error.message : String(error), detail: error };
|
|
83
|
+
if (props.onEditorError) props.onEditorError(payload);
|
|
84
|
+
else console.error("[@topol.io/editor-svelte] EmailEditor failed:", error);
|
|
191
85
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
await created.render(container);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
await created.destroy();
|
|
202
|
-
editor = void 0;
|
|
203
|
-
throw error;
|
|
86
|
+
// Only callbacks provided at mount are registered: the editor changes behaviour based on
|
|
87
|
+
// whether e.g. `onSaveAndClose` exists at all. Each proxy reads the prop on every call, so
|
|
88
|
+
// the latest handler is used, and returns its result so the editor can await it.
|
|
89
|
+
const callbacks: Record<string, (payload?: unknown) => unknown> = {};
|
|
90
|
+
for (const name of CALLBACK_NAMES) {
|
|
91
|
+
if (typeof props[name] !== "function") continue;
|
|
92
|
+
callbacks[name] = (payload?: unknown) => (props[name] as ((p?: unknown) => unknown) | undefined)?.(payload);
|
|
204
93
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
})
|
|
94
|
+
const initialize = async () => {
|
|
95
|
+
const created = await CoreEmailEditor.init({ config: props.options, ...(callbacks as IEmailCallbacks) }, { stage: props.stage, loaderUrl: props.loaderUrl });
|
|
96
|
+
owned = created;
|
|
97
|
+
if (disposed) {
|
|
98
|
+
await created.destroy();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
editor = created;
|
|
102
|
+
try {
|
|
103
|
+
await created.render(container);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
await created.destroy();
|
|
106
|
+
if (editor === created) editor = null;
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
if (!disposed) props.onReady?.(created);
|
|
110
|
+
};
|
|
111
|
+
void initialize().catch(reportError);
|
|
112
|
+
return () => {
|
|
113
|
+
disposed = true;
|
|
114
|
+
if (editor === owned) editor = null;
|
|
115
|
+
void owned?.destroy().catch((error) => console.warn("[@topol.io/editor-svelte] EmailEditor cleanup failed:", error));
|
|
116
|
+
};
|
|
117
|
+
});
|
|
216
118
|
</script>
|
|
217
119
|
|
|
218
120
|
<div
|
|
219
121
|
bind:this={container}
|
|
220
|
-
|
|
122
|
+
class={props.class}
|
|
123
|
+
style="width: 100%; height: 100vh; {props.style ?? ''}"
|
|
221
124
|
></div>
|
|
@@ -1,124 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import type { IEmailConfig, IEmailCallbacks } from "@topol.io/editor";
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onPreview: Parameters<NonNullable<IEmailCallbacks["onPreview"]>>[0];
|
|
19
|
-
onPreviewClose: void;
|
|
20
|
-
onAlert: Parameters<NonNullable<IEmailCallbacks["onAlert"]>>[0];
|
|
21
|
-
onEditorClose: void;
|
|
22
|
-
onEdittedWithoutSaveChanged: Parameters<NonNullable<IEmailCallbacks["onEdittedWithoutSaveChanged"]>>[0];
|
|
23
|
-
onBlocksAndStructuresVisibilityChange: Parameters<NonNullable<IEmailCallbacks["onBlocksAndStructuresVisibilityChange"]>>[0];
|
|
24
|
-
onOpenCustomBlockDialog: Parameters<NonNullable<IEmailCallbacks["onOpenCustomBlockDialog"]>>[0];
|
|
25
|
-
onTemplateRename: Parameters<NonNullable<IEmailCallbacks["onTemplateRename"]>>[0];
|
|
26
|
-
onTemplateUpdated: void;
|
|
27
|
-
updateTestingEmailAddresses: Parameters<NonNullable<IEmailCallbacks["updateTestingEmailAddresses"]>>[0];
|
|
28
|
-
onEditorError: Parameters<NonNullable<IEmailCallbacks["onEditorError"]>>[0];
|
|
29
|
-
onLanguageCreated: Parameters<NonNullable<IEmailCallbacks["onLanguageCreated"]>>[0];
|
|
30
|
-
onLanguageDeleted: Parameters<NonNullable<IEmailCallbacks["onLanguageDeleted"]>>[0];
|
|
31
|
-
onLanguageSelected: Parameters<NonNullable<IEmailCallbacks["onLanguageSelected"]>>[0];
|
|
32
|
-
onPrimaryLanguageChanged: Parameters<NonNullable<IEmailCallbacks["onPrimaryLanguageChanged"]>>[0];
|
|
33
|
-
onGetMutations: Parameters<NonNullable<IEmailCallbacks["onGetMutations"]>>[0];
|
|
34
|
-
onCloudSave: Parameters<NonNullable<IEmailCallbacks["onCloudSave"]>>[0];
|
|
35
|
-
onCloudTemplateChange: Parameters<NonNullable<IEmailCallbacks["onCloudTemplateChange"]>>[0];
|
|
36
|
-
ready: IEmailEditorInstance;
|
|
37
|
-
};
|
|
38
|
-
import type { IEmailEditorInstance, IStage, IErrorData } from "@topol.io/editor";
|
|
39
|
-
declare const __propDef: {
|
|
40
|
-
props: {
|
|
41
|
-
options: ISvelteOptions;
|
|
42
|
-
callbacks?: IEmailCallbacks | undefined;
|
|
43
|
-
stage?: IStage | undefined;
|
|
44
|
-
loaderUrl?: string | undefined;
|
|
45
|
-
getEditor?: (() => IEmailEditorInstance | null) | undefined;
|
|
46
|
-
};
|
|
47
|
-
events: {
|
|
48
|
-
onSave: CustomEvent<import("@topol.io/editor").ISaveData>;
|
|
49
|
-
onSaveAndClose: CustomEvent<import("@topol.io/editor").ISaveData>;
|
|
50
|
-
onTestSend: CustomEvent<import("@topol.io/editor").ISendTestData>;
|
|
51
|
-
onBannerClick: CustomEvent<{
|
|
52
|
-
json: unknown;
|
|
53
|
-
html: unknown;
|
|
54
|
-
}>;
|
|
55
|
-
onOpenFileManager: CustomEvent<void>;
|
|
56
|
-
onLoaded: CustomEvent<void>;
|
|
57
|
-
onSavedSectionSave: CustomEvent<{
|
|
58
|
-
section: import("@topol.io/editor").ISavedBlock;
|
|
59
|
-
}>;
|
|
60
|
-
onSavedSectionRemove: CustomEvent<{
|
|
61
|
-
id: string | number;
|
|
62
|
-
}>;
|
|
63
|
-
onSavedSectionEdit: CustomEvent<{
|
|
64
|
-
id: string | number;
|
|
65
|
-
}>;
|
|
66
|
-
onImageDelete: CustomEvent<{
|
|
67
|
-
items: import("@topol.io/editor").IEmailDeletedItem[];
|
|
68
|
-
}>;
|
|
69
|
-
onInit: CustomEvent<void>;
|
|
70
|
-
onUndoChange: CustomEvent<{
|
|
71
|
-
count: number;
|
|
72
|
-
}>;
|
|
73
|
-
onRedoChange: CustomEvent<{
|
|
74
|
-
count: number;
|
|
75
|
-
}>;
|
|
76
|
-
onPreview: CustomEvent<{
|
|
77
|
-
html: unknown;
|
|
78
|
-
}>;
|
|
79
|
-
onPreviewClose: CustomEvent<void>;
|
|
80
|
-
onAlert: CustomEvent<{
|
|
81
|
-
notification: import("@topol.io/editor").INotification;
|
|
82
|
-
}>;
|
|
83
|
-
onEditorClose: CustomEvent<void>;
|
|
84
|
-
onEdittedWithoutSaveChanged: CustomEvent<{
|
|
85
|
-
value: boolean;
|
|
86
|
-
}>;
|
|
87
|
-
onBlocksAndStructuresVisibilityChange: CustomEvent<{
|
|
88
|
-
value: boolean;
|
|
89
|
-
}>;
|
|
90
|
-
onOpenCustomBlockDialog: CustomEvent<{
|
|
91
|
-
block: unknown;
|
|
92
|
-
}>;
|
|
93
|
-
onTemplateRename: CustomEvent<{
|
|
94
|
-
name: string;
|
|
95
|
-
}>;
|
|
96
|
-
onTemplateUpdated: CustomEvent<void>;
|
|
97
|
-
updateTestingEmailAddresses: CustomEvent<{
|
|
98
|
-
emails: string[];
|
|
99
|
-
}>;
|
|
100
|
-
onEditorError: CustomEvent<IErrorData>;
|
|
101
|
-
onLanguageCreated: CustomEvent<import("@topol.io/editor").ILanguageChangePayload>;
|
|
102
|
-
onLanguageDeleted: CustomEvent<import("@topol.io/editor").ILanguageChangePayload>;
|
|
103
|
-
onLanguageSelected: CustomEvent<{
|
|
104
|
-
code: string;
|
|
105
|
-
}>;
|
|
106
|
-
onPrimaryLanguageChanged: CustomEvent<import("@topol.io/editor").ILanguageChangePayload>;
|
|
107
|
-
onGetMutations: CustomEvent<{
|
|
108
|
-
mutations: import("@topol.io/editor").ILanguageMutation[];
|
|
109
|
-
}>;
|
|
110
|
-
onCloudSave: CustomEvent<import("@topol.io/editor").ICloudSavePayload>;
|
|
111
|
-
onCloudTemplateChange: CustomEvent<import("@topol.io/editor").ICloudTemplateChangePayload>;
|
|
112
|
-
ready: CustomEvent<IEmailEditorInstance>;
|
|
113
|
-
} & {
|
|
114
|
-
[evt: string]: CustomEvent<any>;
|
|
115
|
-
};
|
|
116
|
-
slots: {};
|
|
117
|
-
};
|
|
118
|
-
export type EmailEditorProps = typeof __propDef.props;
|
|
119
|
-
export type EmailEditorEvents = typeof __propDef.events;
|
|
120
|
-
export type EmailEditorSlots = typeof __propDef.slots;
|
|
121
|
-
export default class EmailEditor extends SvelteComponent<EmailEditorProps, EmailEditorEvents, EmailEditorSlots> {
|
|
122
|
-
get getEditor(): () => IEmailEditorInstance | null;
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { IEmailConfig, IEmailCallbacks, IEmailEditorInstance, IEmailEditorPluginOptions } from "@topol.io/editor";
|
|
3
|
+
export type ISvelteEmailOptions = IEmailConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Props of the EmailEditor component: the editor `config` as `options`, plus every editor
|
|
6
|
+
* callback as a prop. Each callback receives a single payload object (e.g.
|
|
7
|
+
* `onSave({ json, html })`); see `IEmailCallbacks`. Passing `getNonce` turns nonce
|
|
8
|
+
* authentication on.
|
|
9
|
+
*/
|
|
10
|
+
export interface IEmailEditorProps extends IEmailCallbacks, IEmailEditorPluginOptions {
|
|
11
|
+
options: ISvelteEmailOptions;
|
|
12
|
+
/** Called once the editor iframe has rendered, with the running instance. */
|
|
13
|
+
onReady?(editor: IEmailEditorInstance): void;
|
|
14
|
+
/** Class of the container element. */
|
|
15
|
+
class?: string;
|
|
16
|
+
/** Inline styles of the container element, applied after the default `width: 100%; height: 100vh`. */
|
|
17
|
+
style?: string;
|
|
123
18
|
}
|
|
124
|
-
|
|
19
|
+
declare const EmailEditor: import("svelte").Component<IEmailEditorProps, {
|
|
20
|
+
getEditor: () => IEmailEditorInstance | null;
|
|
21
|
+
}, "">;
|
|
22
|
+
type EmailEditor = ReturnType<typeof EmailEditor>;
|
|
23
|
+
export default EmailEditor;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { default as EmailEditor
|
|
3
|
-
export type {
|
|
1
|
+
export { EmailEditor as CoreEmailEditor } from "@topol.io/editor";
|
|
2
|
+
export { default as EmailEditor } from "./EmailEditor.svelte";
|
|
3
|
+
export type { ISvelteEmailOptions, IEmailEditorProps } from "./EmailEditor.svelte";
|
|
4
4
|
export type * from "@topol.io/editor";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { default as EmailEditor
|
|
1
|
+
export { EmailEditor as CoreEmailEditor } from "@topol.io/editor";
|
|
2
|
+
export { default as EmailEditor } from "./EmailEditor.svelte";
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
-
"version": "1.0.0-alpha.
|
|
20
|
+
"version": "1.0.0-alpha.11",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"svelte": "./dist/index.js",
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"svelte": "^
|
|
32
|
+
"svelte": "^5.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@sveltejs/package": "^2.
|
|
36
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
35
|
+
"@sveltejs/package": "^2.5.0",
|
|
36
|
+
"@sveltejs/vite-plugin-svelte": "^5.1.1",
|
|
37
37
|
"@tsconfig/svelte": "^5.0.2",
|
|
38
|
-
"svelte": "^
|
|
39
|
-
"svelte-check": "^
|
|
38
|
+
"svelte": "^5.57.0",
|
|
39
|
+
"svelte-check": "^4.0.0",
|
|
40
40
|
"tslib": "^2.6.2",
|
|
41
41
|
"typescript": "^5.2.2",
|
|
42
|
-
"vite": "^
|
|
42
|
+
"vite": "^6.2.0",
|
|
43
43
|
"vitest": "^4.0.16",
|
|
44
44
|
"happy-dom": "^20.0.11"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@topol.io/editor": "1.0.0-alpha.
|
|
47
|
+
"@topol.io/editor": "1.0.0-alpha.11"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Svelte 4 exposes no public listener-presence API. Only inspect callback presence;
|
|
2
|
-
// installing an absent onSaveAndClose handler changes the editor's close behavior.
|
|
3
|
-
declare module "svelte/internal" {
|
|
4
|
-
export function get_current_component(): {
|
|
5
|
-
$$: { callbacks: Record<string, unknown[] | undefined> };
|
|
6
|
-
};
|
|
7
|
-
}
|