@topol.io/editor-vue 0.0.4 → 0.1.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
|
@@ -2,48 +2,48 @@
|
|
|
2
2
|
<img src="https://storage.googleapis.com/topolio17326/plugin-assets/6320/17326/topol-with-bg.png" alt="Tailwind CSS" width="400" height="120">
|
|
3
3
|
</a>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
7
|
Easy and quick! Drag and drop HTML editor and builder for beautiful responsive email templates.
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Documentation
|
|
11
10
|
|
|
12
11
|
## Installation
|
|
12
|
+
|
|
13
13
|
Install Editor from NPM using:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
npm install @topol.io/editor-vue
|
|
17
17
|
|
|
18
|
-
//or
|
|
18
|
+
//or
|
|
19
19
|
|
|
20
20
|
yarn add @topol.io/editor-vue
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## Use in Component
|
|
24
|
+
|
|
24
25
|
In your Vue component import and add the simplest options.
|
|
25
26
|
|
|
26
|
-
For more options see the docs for [TopolOptions configuration](https://topol.io/
|
|
27
|
+
For more options see the docs for [TopolOptions configuration](https://docs.topol.io/reference/topol-options.html)
|
|
27
28
|
|
|
28
|
-
```js
|
|
29
|
+
```js
|
|
29
30
|
import { TopolEditor } from '@topol.io/editor-vue';
|
|
30
31
|
|
|
31
32
|
const customOptions = {
|
|
32
33
|
authorize: {
|
|
33
|
-
apiKey:
|
|
34
|
-
userId:
|
|
35
|
-
},
|
|
34
|
+
apiKey: 'YOUR_API_TOKEN',
|
|
35
|
+
userId: 'some-user-id',
|
|
36
|
+
},
|
|
36
37
|
};
|
|
37
|
-
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
```html
|
|
41
41
|
<TopolEditor :options="customOptions"></TopolEditor>
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
45
44
|
## Call Topol Plugin actions
|
|
46
|
-
|
|
45
|
+
|
|
46
|
+
To call actions to the editor import:
|
|
47
47
|
|
|
48
48
|
```js
|
|
49
49
|
import { TopolPlugin } from '@topol.io/editor-vue';
|
|
@@ -53,20 +53,27 @@ TopolPlugin.save();
|
|
|
53
53
|
|
|
54
54
|
### List of all available TopolPlugin actions:
|
|
55
55
|
|
|
56
|
-
| Action
|
|
57
|
-
|
|
|
58
|
-
| `TopolPlugin.save()`
|
|
59
|
-
| `TopolPlugin.load(template)`
|
|
60
|
-
| `TopolPlugin.togglePreview()`
|
|
61
|
-
| `TopolPlugin.togglePreviewSize()`
|
|
62
|
-
| `TopolPlugin.undo()`
|
|
63
|
-
| `TopolPlugin.redo()`
|
|
64
|
-
| `TopolPlugin.setSavedBlocks(savedblock: ISavedBlock[])`
|
|
65
|
-
| `TopolPlugin.createNotification(notification: INotification)`
|
|
66
|
-
| `TopolPlugin.changeEmailToMobile()`
|
|
67
|
-
| `TopolPlugin.changeEmailToDesktop()`
|
|
68
|
-
| `TopolPlugin.toggleBlocksAndStructuresVisibility()`
|
|
69
|
-
| `TopolPlugin.destroy()`
|
|
56
|
+
| Action | Description |
|
|
57
|
+
| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `TopolPlugin.save()` | Saves the content of the editor [more info](https://docs.topol.io/guide/how-to-use-custom-topbar.html#save-and-saveandclose) |
|
|
59
|
+
| `TopolPlugin.load(template)` | Loads the provided template [more info](https://docs.topol.io/guide/how-to-load-and-save-template.html#loading-template) |
|
|
60
|
+
| `TopolPlugin.togglePreview()` | Toggles editor preview [more info](https://docs.topol.io/guide/how-to-use-custom-topbar.html#changing-preview-mode) |
|
|
61
|
+
| `TopolPlugin.togglePreviewSize()` | Toggles editor preview size [more info](https://docs.topol.io/guide/how-to-use-custom-topbar.html#changing-preview-mode) |
|
|
62
|
+
| `TopolPlugin.undo()` | Undo change in editor [more info](https://docs.topol.io/guide/how-to-use-custom-topbar.html#undo-and-redo) |
|
|
63
|
+
| `TopolPlugin.redo()` | Redo change in editor [more info](https://docs.topol.io/guide/how-to-use-custom-topbar.html#undo-and-redo) |
|
|
64
|
+
| `TopolPlugin.setSavedBlocks(savedblock: ISavedBlock[])` | Sets the saved blocks [more info](https://docs.topol.io/guide/saved-blocks.html) |
|
|
65
|
+
| `TopolPlugin.createNotification(notification: INotification)` | Creates editor's notification [more info](https://docs.topol.io/guide/custom-notifications.html) |
|
|
66
|
+
| `TopolPlugin.changeEmailToMobile()` | Change email to mobile view [more info](https://docs.topol.io/guide/mobile-first.html#mobile-first-email-template) |
|
|
67
|
+
| `TopolPlugin.changeEmailToDesktop()` | Change email to desktop view [more info](https://docs.topol.io/guide/mobile-first.html#mobile-first-email-template) |
|
|
68
|
+
| `TopolPlugin.toggleBlocksAndStructuresVisibility()` | Toggle hidden structures visibility for blocks and structures [more info](https://docs.topol.io/guide/mobile-first.html#mobile-first-email-template) |
|
|
69
|
+
| `TopolPlugin.destroy()` | Destroys the editor initialization |
|
|
70
|
+
| `TopolPlugin.chooseFile()` | Chooses the file if image block is active [more info](https://docs.topol.io/guide/custom-filemanager.html#choosefile) |
|
|
71
|
+
| `TopolPlugin.openPremadeTemplatesSelection()` | Opens the premade templates modal pick [more info](https://docs.topol.io/guide/premade-templates-in-editor.html) |
|
|
72
|
+
| `TopolPlugin.refreshComments(key: string)` | Refreshes the conversation [more info](https://docs.topol.io/guide/comments.html#refreshcomments) |
|
|
73
|
+
| `TopolPlugin.setActiveMembers(activeMemers: string[])` | Sets the active members |
|
|
74
|
+
| `TopolPlugin.setTemplateName(name: string)` | Sets the name of template [more info](https://docs.topol.io/guide/rename-template.html) |
|
|
75
|
+
| `TopolPlugin.updateApiAuthorizationHeader(newHeader: string \| Record<string, string>)` | Refreshes the authorization tokens [more info](https://docs.topol.io/guide/security.html#refresh-token) |
|
|
76
|
+
| `TopolPlugin.updateCustomBlockContent(content: string)` | Refreshes the authorization tokens [more info](https://docs.topol.io/guide/custom-block.html#inserting-custom-html-in-custom-dialog-component) |
|
|
70
77
|
|
|
71
78
|
<br>
|
|
72
79
|
|
|
@@ -75,28 +82,35 @@ TopolPlugin.save();
|
|
|
75
82
|
The callbacks from editor are received as component events.
|
|
76
83
|
|
|
77
84
|
```html
|
|
78
|
-
<TopolEditor
|
|
85
|
+
<TopolEditor
|
|
86
|
+
:options="customOptions"
|
|
87
|
+
@onSave="handleOnSave"
|
|
88
|
+
></TopolEditor>
|
|
79
89
|
```
|
|
80
90
|
|
|
81
91
|
### List of all editor events
|
|
82
92
|
|
|
83
|
-
| Event
|
|
84
|
-
|
|
|
85
|
-
| `@onSave`
|
|
86
|
-
| `@onSaveAndClose`
|
|
87
|
-
| `@onTestSend`
|
|
88
|
-
| `@onOpenFileManager`
|
|
89
|
-
| `@onLoaded`
|
|
90
|
-
| `@onInit`
|
|
91
|
-
| `@onBlockSave`
|
|
92
|
-
| `@onBlockRemove`
|
|
93
|
-
| `@onBlockEdit`
|
|
94
|
-
| `@onUndoChange`
|
|
95
|
-
| `@
|
|
96
|
-
| `@onPreview`
|
|
97
|
-
| `@onAlert`
|
|
98
|
-
| `@onClose`
|
|
99
|
-
|
|
93
|
+
| Event | Description |
|
|
94
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `@onSave` | Returns object which contains html and json of the template [more info](https://docs.topol.io/guide/callbacks.html#on-save) |
|
|
96
|
+
| `@onSaveAndClose` | Returns object which contains html and json of the template [more info](https://docs.topol.io/guide/callbacks.html#on-save-and-close) |
|
|
97
|
+
| `@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) |
|
|
98
|
+
| `@onOpenFileManager` | When user clicks file manager open [more info](https://docs.topol.io/guide/custom-filemanager.html#onopenfilemanager) |
|
|
99
|
+
| `@onLoaded` | After editor template is loaded using `TopolPlugin.load()` [more info](https://docs.topol.io/guide/callbacks.html#on-loaded) |
|
|
100
|
+
| `@onInit` | When editor inits [more info](https://docs.topol.io/guide/callbacks.html#on-init) |
|
|
101
|
+
| `@onBlockSave` | When user saves block in editor, returns object of type ISavedBlock [more info](https://docs.topol.io/guide/callbacks.html#on-block-save) |
|
|
102
|
+
| `@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) |
|
|
103
|
+
| `@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) |
|
|
104
|
+
| `@onUndoChange` | When user clicks undo button, retunrs number of steps user undone [more info](https://docs.topol.io/guide/callbacks.html#on-undo-change) |
|
|
105
|
+
| `@onRedoChange` | When user clicks redo button, retunrs number of steps user redone [more info](https://docs.topol.io/guide/callbacks.html#on-redo-change) |
|
|
106
|
+
| `@onPreview` | When user switches to preview [more info](https://docs.topol.io/guide/callbacks.html#on-preview) |
|
|
107
|
+
| `@onAlert` | When alert appears in editor [more info](https://docs.topol.io/guide/callbacks.html#on-alert) |
|
|
108
|
+
| `@onClose` | When close is click inside WindowBar [more info](https://docs.topol.io/guide/top-bar.html#window-bar) |
|
|
109
|
+
| `@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) |
|
|
110
|
+
| `@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) |
|
|
111
|
+
| `@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) |
|
|
112
|
+
| `@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) |
|
|
113
|
+
| `@onError` | When an error that cannot be handled happened in the editor [more info](https://docs.topol.io/guide/callbacks.html#onerror) |
|
|
100
114
|
|
|
101
115
|
<br>
|
|
102
116
|
|
|
@@ -106,8 +120,10 @@ Topol Editor provides full TypeScript integration and exports all necessary type
|
|
|
106
120
|
|
|
107
121
|
```vue
|
|
108
122
|
<script setup lang="ts">
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
import {
|
|
124
|
+
ITopolOptions,
|
|
125
|
+
INotification,
|
|
126
|
+
ISavedBlock,
|
|
127
|
+
} from '@topol.io/editor-vue';
|
|
112
128
|
</script>
|
|
113
|
-
```
|
|
129
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i from "@topol.io/editor";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as T } from "@topol.io/editor";
|
|
3
3
|
import { defineComponent as p, onMounted as m, onBeforeUnmount as g, openBlock as C, createElementBlock as u } from "vue";
|
|
4
4
|
const l = "topol-editor-id", B = /* @__PURE__ */ p({
|
|
5
5
|
__name: "TopolEditor",
|
|
@@ -7,7 +7,7 @@ const l = "topol-editor-id", B = /* @__PURE__ */ p({
|
|
|
7
7
|
options: {},
|
|
8
8
|
stage: { default: "production" }
|
|
9
9
|
},
|
|
10
|
-
emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses"],
|
|
10
|
+
emits: ["onSave", "onSaveAndClose", "onTestSend", "onOpenFileManager", "onLoaded", "onBlockSave", "onBlockRemove", "onBlockEdit", "onInit", "onClose", "onUndoChange", "onRedoChange", "onPreview", "onAlert", "onBannerClick", "onEdittedWithoutSaveChanged", "onOpenCustomBlockDialog", "onTemplateRename", "updateTestingEmailAddresses", "onError"],
|
|
11
11
|
setup(d, { emit: s }) {
|
|
12
12
|
const a = d, e = s, r = () => {
|
|
13
13
|
const t = {
|
|
@@ -53,7 +53,7 @@ const l = "topol-editor-id", B = /* @__PURE__ */ p({
|
|
|
53
53
|
onClose() {
|
|
54
54
|
e("onClose");
|
|
55
55
|
},
|
|
56
|
-
//
|
|
56
|
+
// only in free version
|
|
57
57
|
onBannerClick(o, n) {
|
|
58
58
|
e("onBannerClick", { json: o, html: n });
|
|
59
59
|
},
|
|
@@ -68,6 +68,9 @@ const l = "topol-editor-id", B = /* @__PURE__ */ p({
|
|
|
68
68
|
},
|
|
69
69
|
updateTestingEmailAddresses(o) {
|
|
70
70
|
e("updateTestingEmailAddresses", o);
|
|
71
|
+
},
|
|
72
|
+
onError(o, n) {
|
|
73
|
+
e("onError", { type: o, message: n });
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
76
|
return { id: "#" + l, ...a.options, callbacks: { ...t } };
|
|
@@ -85,5 +88,5 @@ const l = "topol-editor-id", B = /* @__PURE__ */ p({
|
|
|
85
88
|
});
|
|
86
89
|
export {
|
|
87
90
|
B as TopolEditor,
|
|
88
|
-
|
|
91
|
+
T as TopolPlugin
|
|
89
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@topol.io/editor"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@topol.io/editor","vue"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n["topol-editor-vue"]={},n.TopolPlugin,n.Vue))})(this,function(n,i,d){"use strict";const s="topol-editor-id",r=d.defineComponent({__name:"TopolEditor",props:{options:{},stage:{default:"production"}},emits:["onSave","onSaveAndClose","onTestSend","onOpenFileManager","onLoaded","onBlockSave","onBlockRemove","onBlockEdit","onInit","onClose","onUndoChange","onRedoChange","onPreview","onAlert","onBannerClick","onEdittedWithoutSaveChanged","onOpenCustomBlockDialog","onTemplateRename","updateTestingEmailAddresses","onError"],setup(c,{emit:p}){const l=c,e=p,u=()=>{const a={onSave(o,t){e("onSave",{json:o,html:t})},onSaveAndClose(o,t){e("onSaveAndClose",{json:o,html:t})},onTestSend(o,t,m){e("onTestSend",{email:o,json:t,html:m})},onOpenFileManager(){e("onOpenFileManager")},onLoaded(){e("onLoaded")},onBlockSave(o){e("onBlockSave",o)},onBlockRemove(o){e("onBlockRemove",o)},onBlockEdit(o){e("onBlockEdit",o)},onInit(){e("onInit")},onUndoChange(o){e("onUndoChange",o)},onRedoChange(o){e("onRedoChange",o)},onPreview(o){e("onPreview",o)},onAlert(o){e("onAlert",o)},onClose(){e("onClose")},onBannerClick(o,t){e("onBannerClick",{json:o,html:t})},onEdittedWithoutSaveChanged(o){e("onEdittedWithoutSaveChanged",o)},onOpenCustomBlockDialog(o){e("onOpenCustomBlockDialog",o)},onTemplateRename(o){e("onTemplateRename",o)},updateTestingEmailAddresses(o){e("updateTestingEmailAddresses",o)},onError(o,t){e("onError",{type:o,message:t})}};return{id:"#"+s,...l.options,callbacks:{...a}}};return d.onMounted(async()=>{const a=u();await i.init(a,{stage:l.stage})}),d.onBeforeUnmount(()=>{i.destroy()}),(a,o)=>(d.openBlock(),d.createElementBlock("div",{id:s,style:{position:"absolute",width:"100%",height:"100vh"}}))}});n.TopolPlugin=i,n.TopolEditor=r,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -9,6 +9,10 @@ export type ISendTestData = {
|
|
|
9
9
|
json: unknown;
|
|
10
10
|
html: unknown;
|
|
11
11
|
};
|
|
12
|
+
export type IErrorData = {
|
|
13
|
+
type: string;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
12
16
|
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
13
17
|
options: IVueOptions;
|
|
14
18
|
stage?: IStage | undefined;
|
|
@@ -34,12 +38,14 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
34
38
|
onOpenCustomBlockDialog: (blockContent: unknown) => void;
|
|
35
39
|
onTemplateRename: (title: string) => void;
|
|
36
40
|
updateTestingEmailAddresses: (emails: string[]) => void;
|
|
41
|
+
onError: (error: IErrorData) => void;
|
|
37
42
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
38
43
|
options: IVueOptions;
|
|
39
44
|
stage?: IStage | undefined;
|
|
40
45
|
}>, {
|
|
41
46
|
stage: string;
|
|
42
47
|
}>>> & {
|
|
48
|
+
onOnError?: ((error: IErrorData) => any) | undefined;
|
|
43
49
|
onOnSave?: ((data: ISaveData) => any) | undefined;
|
|
44
50
|
onOnSaveAndClose?: ((data: ISaveData) => any) | undefined;
|
|
45
51
|
onOnTestSend?: ((data: ISendTestData) => any) | undefined;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"author": "Topol.io",
|
|
15
15
|
"homepage": "https://topol.io",
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
|
-
"version": "0.0
|
|
17
|
+
"version": "0.1.0",
|
|
18
18
|
"type": "module",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@topol.io/editor": "0.0
|
|
32
|
+
"@topol.io/editor": "0.1.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"vue": "^3.2.25"
|