@topol.io/editor-svelte 1.0.0-alpha.1 → 1.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -100
- package/dist/EmailEditor.svelte +124 -0
- package/dist/EmailEditor.svelte.d.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/package.json +19 -10
- package/dist/TopolEditor.svelte +0 -87
- package/dist/TopolEditor.svelte.d.ts +0 -49
package/README.md
CHANGED
|
@@ -1,109 +1,61 @@
|
|
|
1
|
-
|
|
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-svelte — 1.x alpha
|
|
4
2
|
|
|
5
|
-
|
|
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.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
yarn add @topol.io/editor-svelte
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Use in Component
|
|
24
|
-
|
|
25
|
-
In your Svelte 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-svelte';
|
|
31
|
-
|
|
32
|
-
const customOptions = {
|
|
33
|
-
authorize: {
|
|
34
|
-
apiKey: 'YOUR_API_TOKEN',
|
|
35
|
-
userId: 'some-user-id',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```html
|
|
41
|
-
<TopolEditor options="{customOptions}"></TopolEditor>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Call Topol Plugin actions
|
|
45
|
-
|
|
46
|
-
To call actions to the editor import:
|
|
47
|
-
|
|
48
|
-
```js
|
|
49
|
-
import { TopolPlugin } from '@topol.io/editor-svelte';
|
|
6
|
+
```svelte
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { EmailEditor, type ISvelteEmailOptions } from "@topol.io/editor-svelte";
|
|
9
|
+
const options: ISvelteEmailOptions = {
|
|
10
|
+
authorize: { apiKey: "pk_your-key", entityId: "user-123" },
|
|
11
|
+
cloud: { enabled: true },
|
|
12
|
+
};
|
|
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
|
+
}
|
|
18
|
+
</script>
|
|
50
19
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
20
|
+
<EmailEditor
|
|
21
|
+
{options}
|
|
22
|
+
{getNonce}
|
|
23
|
+
onCloudSave={({ templateId }) => console.log(templateId)}
|
|
24
|
+
onEditorError={({ message }) => console.error(message)}
|
|
25
|
+
/>
|
|
54
26
|
```
|
|
55
27
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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.
|
|
59
32
|
|
|
60
|
-
|
|
33
|
+
The `on:` events and the `callbacks` prop of earlier 1.x alphas are removed:
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<TopolEditor
|
|
66
|
-
options="{customOptions}"
|
|
67
|
-
on:onSave="{onSave}"
|
|
68
|
-
></TopolEditor>
|
|
35
|
+
```diff
|
|
36
|
+
- <EmailEditor {options} callbacks={{ getNonce, onSave }} on:onEditorError={(e) => report(e.detail)} />
|
|
37
|
+
+ <EmailEditor {options} {getNonce} {onSave} onEditorError={(payload) => report(payload)} />
|
|
69
38
|
```
|
|
70
39
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
| `@onError` | When an error that cannot be handled happened in the editor [more info](https://docs.topol.io/guide/callbacks.html#onerror) |
|
|
94
|
-
|
|
95
|
-
<br>
|
|
96
|
-
|
|
97
|
-
## TypeScript
|
|
98
|
-
|
|
99
|
-
Topol Editor provides full TypeScript integration and exports all necessary types.
|
|
100
|
-
|
|
101
|
-
```svelte
|
|
102
|
-
<script lang="ts">
|
|
103
|
-
import {
|
|
104
|
-
ITopolOptions,
|
|
105
|
-
INotification,
|
|
106
|
-
ISavedBlock,
|
|
107
|
-
} from '@topol.io/editor-svelte';
|
|
108
|
-
</script>
|
|
109
|
-
```
|
|
40
|
+
Use `bind:this={component}` and `component.getEditor()` for async instance methods,
|
|
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.
|
|
44
|
+
|
|
45
|
+
`options` contains the v4 configuration (`IEmailConfig`). A `getNonce` callback that
|
|
46
|
+
fetches a fresh `nc_` token from your application's authenticated backend enables
|
|
47
|
+
nonce authentication on its own; Cloud additionally requires it. Never put an `sk_`
|
|
48
|
+
secret in browser code. See the core package README for nonce authentication, Cloud
|
|
49
|
+
feature options, the Countdown block (`countdown`; see the
|
|
50
|
+
[option reference](https://docs.topol.io/email-editor/reference/topol-options#countdown))
|
|
51
|
+
and all v4 renames.
|
|
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.
|
|
59
|
+
|
|
60
|
+
Use `loaderUrl` for an explicit v4 local/preview loader. A numeric `stage` selects
|
|
61
|
+
a PR preview. The `TopolEditor` alias is removed; import `EmailEditor`.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script
|
|
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
|
+
}
|
|
22
|
+
|
|
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);
|
|
85
|
+
};
|
|
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);
|
|
93
|
+
}
|
|
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
|
+
});
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<div
|
|
121
|
+
bind:this={container}
|
|
122
|
+
class={props.class}
|
|
123
|
+
style="width: 100%; height: 100vh; {props.style ?? ''}"
|
|
124
|
+
></div>
|
|
@@ -0,0 +1,23 @@
|
|
|
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;
|
|
18
|
+
}
|
|
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
|
|
3
|
-
export {
|
|
4
|
-
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
|
+
export type * from "@topol.io/editor";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { default as
|
|
1
|
+
export { EmailEditor as CoreEmailEditor } from "@topol.io/editor";
|
|
2
|
+
export { default as EmailEditor } from "./EmailEditor.svelte";
|
package/package.json
CHANGED
|
@@ -17,37 +17,46 @@
|
|
|
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
|
".": {
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"svelte": "./dist/index.js"
|
|
25
|
+
"svelte": "./dist/index.js",
|
|
26
|
+
"default": "./dist/index.js"
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
"types": "./dist/index.d.ts",
|
|
29
30
|
"svelte": "./dist/index.js",
|
|
30
31
|
"peerDependencies": {
|
|
31
|
-
"svelte": "^
|
|
32
|
+
"svelte": "^5.0.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@sveltejs/package": "^2.
|
|
35
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
35
|
+
"@sveltejs/package": "^2.5.0",
|
|
36
|
+
"@sveltejs/vite-plugin-svelte": "^5.1.1",
|
|
36
37
|
"@tsconfig/svelte": "^5.0.2",
|
|
37
|
-
"svelte": "^
|
|
38
|
-
"svelte-check": "^
|
|
38
|
+
"svelte": "^5.57.0",
|
|
39
|
+
"svelte-check": "^4.0.0",
|
|
39
40
|
"tslib": "^2.6.2",
|
|
40
41
|
"typescript": "^5.2.2",
|
|
41
|
-
"vite": "^
|
|
42
|
+
"vite": "^6.2.0",
|
|
43
|
+
"vitest": "^4.0.16",
|
|
44
|
+
"happy-dom": "^20.0.11"
|
|
42
45
|
},
|
|
43
46
|
"dependencies": {
|
|
44
|
-
"@topol.io/editor": "1.0.0-alpha.
|
|
47
|
+
"@topol.io/editor": "1.0.0-alpha.11"
|
|
45
48
|
},
|
|
46
49
|
"publishConfig": {
|
|
47
50
|
"access": "public"
|
|
48
51
|
},
|
|
49
52
|
"scripts": {
|
|
50
53
|
"dev": "vite",
|
|
51
|
-
"build": "svelte-package"
|
|
54
|
+
"build": "svelte-package",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
57
|
+
"lint": "oxlint --deny-warnings .",
|
|
58
|
+
"lint:fix": "oxlint --fix --deny-warnings .",
|
|
59
|
+
"format": "oxfmt --write .",
|
|
60
|
+
"format:check": "oxfmt --check ."
|
|
52
61
|
}
|
|
53
62
|
}
|
package/dist/TopolEditor.svelte
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<script context="module"></script>
|
|
2
|
-
|
|
3
|
-
<script>import { createEventDispatcher, onMount, onDestroy } from "svelte";
|
|
4
|
-
import TopolPlugin from "@topol.io/editor";
|
|
5
|
-
const EDITOR_HTML_ID = "topol-editor-id";
|
|
6
|
-
export let options;
|
|
7
|
-
export let stage = "production";
|
|
8
|
-
const dispatch = createEventDispatcher();
|
|
9
|
-
const mergeOptions = () => {
|
|
10
|
-
const callbacks = {
|
|
11
|
-
onSave(json, html) {
|
|
12
|
-
dispatch("onSave", { json, html });
|
|
13
|
-
},
|
|
14
|
-
onSaveAndClose(json, html) {
|
|
15
|
-
dispatch("onSaveAndClose", { json, html });
|
|
16
|
-
},
|
|
17
|
-
onTestSend(email, json, html) {
|
|
18
|
-
dispatch("onTestSend", { email, json, html });
|
|
19
|
-
},
|
|
20
|
-
onOpenFileManager() {
|
|
21
|
-
dispatch("onOpenFileManager");
|
|
22
|
-
},
|
|
23
|
-
onLoaded() {
|
|
24
|
-
dispatch("onLoaded");
|
|
25
|
-
},
|
|
26
|
-
onBlockSave(block) {
|
|
27
|
-
dispatch("onBlockSave", block);
|
|
28
|
-
},
|
|
29
|
-
onBlockRemove(blockId) {
|
|
30
|
-
dispatch("onBlockRemove", blockId);
|
|
31
|
-
},
|
|
32
|
-
onBlockEdit(blockId) {
|
|
33
|
-
dispatch("onBlockEdit", blockId);
|
|
34
|
-
},
|
|
35
|
-
onInit() {
|
|
36
|
-
dispatch("onInit");
|
|
37
|
-
},
|
|
38
|
-
onUndoChange(count) {
|
|
39
|
-
dispatch("onUndoChange", count);
|
|
40
|
-
},
|
|
41
|
-
onRedoChange(count) {
|
|
42
|
-
dispatch("onRedoChange", count);
|
|
43
|
-
},
|
|
44
|
-
onPreview(html) {
|
|
45
|
-
dispatch("onPreview", html);
|
|
46
|
-
},
|
|
47
|
-
onAlert(notification) {
|
|
48
|
-
dispatch("onAlert", notification);
|
|
49
|
-
},
|
|
50
|
-
onClose() {
|
|
51
|
-
dispatch("onClose");
|
|
52
|
-
},
|
|
53
|
-
// only in free version
|
|
54
|
-
onBannerClick(json, html) {
|
|
55
|
-
dispatch("onBannerClick", { json, html });
|
|
56
|
-
},
|
|
57
|
-
onEdittedWithoutSaveChanged(hasUnsavedChanges) {
|
|
58
|
-
dispatch("onEdittedWithoutSaveChanged", hasUnsavedChanges);
|
|
59
|
-
},
|
|
60
|
-
onOpenCustomBlockDialog(blockContent) {
|
|
61
|
-
dispatch("onOpenCustomBlockDialog", blockContent);
|
|
62
|
-
},
|
|
63
|
-
onTemplateRename(title) {
|
|
64
|
-
dispatch("onTemplateRename", title);
|
|
65
|
-
},
|
|
66
|
-
updateTestingEmailAddresses(emails) {
|
|
67
|
-
dispatch("updateTestingEmailAddresses", emails);
|
|
68
|
-
},
|
|
69
|
-
onError(type, message) {
|
|
70
|
-
dispatch("onError", { type, message });
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return { id: "#" + EDITOR_HTML_ID, ...options, callbacks: { ...callbacks } };
|
|
74
|
-
};
|
|
75
|
-
onMount(async () => {
|
|
76
|
-
const mergedTopolOptinos = mergeOptions();
|
|
77
|
-
await TopolPlugin.init(mergedTopolOptinos, { stage });
|
|
78
|
-
});
|
|
79
|
-
onDestroy(() => {
|
|
80
|
-
TopolPlugin.destroy();
|
|
81
|
-
});
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<div
|
|
85
|
-
id="{EDITOR_HTML_ID}"
|
|
86
|
-
style="position: absolute; width: 100%; height: 100vh"
|
|
87
|
-
></div>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
export type ISvelteOptions = Omit<ITopolOptions, 'id' | 'callbacks'>;
|
|
3
|
-
export type ISaveData = {
|
|
4
|
-
json: unknown;
|
|
5
|
-
html: unknown;
|
|
6
|
-
};
|
|
7
|
-
export type ISendTestData = {
|
|
8
|
-
email: string;
|
|
9
|
-
json: unknown;
|
|
10
|
-
html: unknown;
|
|
11
|
-
};
|
|
12
|
-
import type { ITopolOptions, IStage } from '@topol.io/editor';
|
|
13
|
-
declare const __propDef: {
|
|
14
|
-
props: {
|
|
15
|
-
options: ISvelteOptions;
|
|
16
|
-
stage?: IStage | undefined;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
onSave: CustomEvent<any>;
|
|
20
|
-
onSaveAndClose: CustomEvent<any>;
|
|
21
|
-
onTestSend: CustomEvent<any>;
|
|
22
|
-
onOpenFileManager: CustomEvent<any>;
|
|
23
|
-
onLoaded: CustomEvent<any>;
|
|
24
|
-
onBlockSave: CustomEvent<any>;
|
|
25
|
-
onBlockRemove: CustomEvent<any>;
|
|
26
|
-
onBlockEdit: CustomEvent<any>;
|
|
27
|
-
onInit: CustomEvent<any>;
|
|
28
|
-
onUndoChange: CustomEvent<any>;
|
|
29
|
-
onRedoChange: CustomEvent<any>;
|
|
30
|
-
onPreview: CustomEvent<any>;
|
|
31
|
-
onAlert: CustomEvent<any>;
|
|
32
|
-
onClose: CustomEvent<any>;
|
|
33
|
-
onBannerClick: CustomEvent<any>;
|
|
34
|
-
onEdittedWithoutSaveChanged: CustomEvent<any>;
|
|
35
|
-
onOpenCustomBlockDialog: CustomEvent<any>;
|
|
36
|
-
onTemplateRename: CustomEvent<any>;
|
|
37
|
-
updateTestingEmailAddresses: CustomEvent<any>;
|
|
38
|
-
onError: CustomEvent<any>;
|
|
39
|
-
} & {
|
|
40
|
-
[evt: string]: CustomEvent<any>;
|
|
41
|
-
};
|
|
42
|
-
slots: {};
|
|
43
|
-
};
|
|
44
|
-
export type TopolEditorProps = typeof __propDef.props;
|
|
45
|
-
export type TopolEditorEvents = typeof __propDef.events;
|
|
46
|
-
export type TopolEditorSlots = typeof __propDef.slots;
|
|
47
|
-
export default class TopolEditor extends SvelteComponent<TopolEditorProps, TopolEditorEvents, TopolEditorSlots> {
|
|
48
|
-
}
|
|
49
|
-
export {};
|