@topol.io/editor 0.0.0-alfa.1 → 0.0.0-alfa.2
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/dist/topol-plugin.d.ts +231 -0
- package/dist/topol-plugin.es.js +120 -0
- package/dist/topol-plugin.umd.js +1 -0
- package/package.json +13 -2
- package/.eslintrc.js +0 -18
- package/.prettierrc.json +0 -1
- package/.vscode/settings.json +0 -3
- package/example/index.html +0 -18
- package/example/index.ts +0 -20
- package/src/main.ts +0 -101
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -19
- package/types/API/API.ts +0 -22
- package/types/AuthHeaderConfig/IAuthHeaderConfig.ts +0 -3
- package/types/ContentBlock/IContentBlockOptions.ts +0 -6
- package/types/Font/IFont.ts +0 -5
- package/types/ITopolOptions.ts +0 -58
- package/types/ITopolPlugin.ts +0 -20
- package/types/MergeTag/IMergeTag.ts +0 -5
- package/types/MergeTag/IMergeTagGroup.ts +0 -6
- package/types/Notification/INotification.ts +0 -7
- package/types/SavedBlock/ISavedBlock.ts +0 -5
- package/types/Theme/ITheme.ts +0 -34
- package/vite.config.ts +0 -21
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
declare module 'topol-plugin/src/main' {
|
|
2
|
+
import ITopolOptions from "topol-plugin/types/ITopolOptions";
|
|
3
|
+
import ITopolPlugin from "topol-plugin/types/ITopolPlugin";
|
|
4
|
+
import INotification from "topol-plugin/types/Notification/INotification";
|
|
5
|
+
import ISavedBlock from "topol-plugin/types/SavedBlock/ISavedBlock";
|
|
6
|
+
global {
|
|
7
|
+
interface Window {
|
|
8
|
+
TopolPlugin: ITopolPlugin;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const createTopolPlugin: (options: ITopolOptions) => {
|
|
12
|
+
init: () => Promise<boolean | string>;
|
|
13
|
+
save: () => void;
|
|
14
|
+
load: (json: unknown) => void;
|
|
15
|
+
togglePreview: () => void;
|
|
16
|
+
togglePreviewSize: () => void;
|
|
17
|
+
chooseFile: (url: string) => void;
|
|
18
|
+
undo: () => void;
|
|
19
|
+
redo: () => void;
|
|
20
|
+
setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
|
|
21
|
+
createNotification: (notification: INotification) => void;
|
|
22
|
+
changeEmailToMobile: () => void;
|
|
23
|
+
changeEmailToDesktop: () => void;
|
|
24
|
+
toggleBlocksAndStructuresVisibility: () => void;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
};
|
|
27
|
+
export default createTopolPlugin;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
declare module 'topol-plugin/types/API/API' {
|
|
31
|
+
export interface IAPI {
|
|
32
|
+
GET_AUTOSAVE: string;
|
|
33
|
+
AUTOSAVES: string;
|
|
34
|
+
LOAD: string;
|
|
35
|
+
SAVE: string | null;
|
|
36
|
+
AUTOSAVE: string;
|
|
37
|
+
PREVIEW: string;
|
|
38
|
+
FEEDS: string;
|
|
39
|
+
PRODUCTS: string;
|
|
40
|
+
IMAGE_UPLOAD: string;
|
|
41
|
+
FOLDERS: string;
|
|
42
|
+
IMAGE_EDITOR_UPLOAD: string | null;
|
|
43
|
+
TEST_EMAIL: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ILockedAPI {
|
|
46
|
+
GIPHY_API_KEY: string;
|
|
47
|
+
GIPHY_SEARCH: string;
|
|
48
|
+
AUTHORIZE: string;
|
|
49
|
+
GCS_SIGNED_URL: string;
|
|
50
|
+
SAVE_SERVER: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
declare module 'topol-plugin/types/AuthHeaderConfig/IAuthHeaderConfig' {
|
|
55
|
+
export default interface AuthHeaderConfig {
|
|
56
|
+
[key: string]: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
declare module 'topol-plugin/types/ContentBlock/IContentBlockOptions' {
|
|
61
|
+
export default interface IContentBlockOptions {
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
disabledText?: string;
|
|
64
|
+
hidden?: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
declare module 'topol-plugin/types/Font/IFont' {
|
|
69
|
+
export default interface IFont {
|
|
70
|
+
label: string;
|
|
71
|
+
style: string;
|
|
72
|
+
url?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
declare module 'topol-plugin/types/ITopolOptions' {
|
|
77
|
+
import { IAPI } from "topol-plugin/types/API/API";
|
|
78
|
+
import ISavedBlock from "topol-plugin/types/SavedBlock/ISavedBlock";
|
|
79
|
+
import INotification from "topol-plugin/types/Notification/INotification";
|
|
80
|
+
import IMergeTagGroup from "topol-plugin/types/MergeTag/IMergeTagGroup";
|
|
81
|
+
import IContentBlockOptions from "topol-plugin/types/ContentBlock/IContentBlockOptions";
|
|
82
|
+
import ITheme from "topol-plugin/types/Theme/ITheme";
|
|
83
|
+
import IAuthHeaderConfig from "topol-plugin/types/AuthHeaderConfig/IAuthHeaderConfig";
|
|
84
|
+
import IFont from "topol-plugin/types/Font/IFont";
|
|
85
|
+
export default interface ITopolOptions {
|
|
86
|
+
id: string;
|
|
87
|
+
authorize: {
|
|
88
|
+
apiKey: string;
|
|
89
|
+
userId: string | number;
|
|
90
|
+
};
|
|
91
|
+
templateId?: number;
|
|
92
|
+
title?: string;
|
|
93
|
+
removeTopBar?: boolean;
|
|
94
|
+
topBarOptions?: Array<string>;
|
|
95
|
+
mainMenuAlign?: "left" | "right";
|
|
96
|
+
disableAlerts?: boolean;
|
|
97
|
+
customFileManager?: boolean;
|
|
98
|
+
language?: string;
|
|
99
|
+
light?: boolean;
|
|
100
|
+
theme?: ITheme;
|
|
101
|
+
hideSettingsTab?: boolean;
|
|
102
|
+
imageEditor?: boolean;
|
|
103
|
+
premadeBlocks?: unknown | boolean;
|
|
104
|
+
savedBlocks?: Array<ISavedBlock> | boolean;
|
|
105
|
+
mergeTags?: Array<IMergeTagGroup>;
|
|
106
|
+
enableAutosaves?: boolean;
|
|
107
|
+
htmlMinified?: boolean;
|
|
108
|
+
apiAuthorizationHeader?: IAuthHeaderConfig | string;
|
|
109
|
+
contentBlocks?: IContentBlockOptions[];
|
|
110
|
+
callbacks: {
|
|
111
|
+
onSave?(json: unknown, html: unknown): void;
|
|
112
|
+
onSaveAndClose?(json: unknown, html: unknown): void;
|
|
113
|
+
onTestSend?(email: string, json: unknown, html: unknown): void;
|
|
114
|
+
onOpenFileManager?(): void;
|
|
115
|
+
onLoaded?(): void;
|
|
116
|
+
onBlockSave?(block: ISavedBlock): void;
|
|
117
|
+
onBlockRemove?(blockId: number): void;
|
|
118
|
+
onBlockEdit?(blockId: number): void;
|
|
119
|
+
onInit?(): void;
|
|
120
|
+
onUndoChange?(count: number): void;
|
|
121
|
+
onRedoChange?(count: number): void;
|
|
122
|
+
onPreview?(html: unknown): void;
|
|
123
|
+
onAlert?(notification: INotification): void;
|
|
124
|
+
};
|
|
125
|
+
api?: IAPI;
|
|
126
|
+
mobileFirstEnabled?: boolean;
|
|
127
|
+
fonts?: Array<IFont>;
|
|
128
|
+
tinyConfig?: unknown;
|
|
129
|
+
fontSizes?: Array<number>;
|
|
130
|
+
colors?: Array<string>;
|
|
131
|
+
googleApiKey?: string;
|
|
132
|
+
role?: "manager" | "editor" | "reader";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
declare module 'topol-plugin/types/ITopolPlugin' {
|
|
137
|
+
import INotification from "topol-plugin/types/Notification/INotification";
|
|
138
|
+
import ISavedBlock from "topol-plugin/types/SavedBlock/ISavedBlock";
|
|
139
|
+
import ITopolOptions from "topol-plugin/types/ITopolOptions";
|
|
140
|
+
export default interface ITopolPlugin {
|
|
141
|
+
init: (topolOptions: ITopolOptions) => void;
|
|
142
|
+
save: () => void;
|
|
143
|
+
load: (json: unknown) => void;
|
|
144
|
+
togglePreview: () => void;
|
|
145
|
+
togglePreviewSize: () => void;
|
|
146
|
+
chooseFile: (url: string) => void;
|
|
147
|
+
undo: () => void;
|
|
148
|
+
redo: () => void;
|
|
149
|
+
setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
|
|
150
|
+
createNotification: (notification: INotification) => void;
|
|
151
|
+
changeEmailToMobile: () => void;
|
|
152
|
+
changeEmailToDesktop: () => void;
|
|
153
|
+
toggleBlocksAndStructuresVisibility: () => void;
|
|
154
|
+
destroy: () => void;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
declare module 'topol-plugin/types/MergeTag/IMergeTag' {
|
|
159
|
+
export default interface IMergeTag {
|
|
160
|
+
value: string;
|
|
161
|
+
text: string;
|
|
162
|
+
label: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
declare module 'topol-plugin/types/MergeTag/IMergeTagGroup' {
|
|
167
|
+
import IMergeTag from "topol-plugin/types/MergeTag/IMergeTag";
|
|
168
|
+
export default interface IMergeTagGroup {
|
|
169
|
+
name: string;
|
|
170
|
+
items: Array<IMergeTag | IMergeTagGroup>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
declare module 'topol-plugin/types/Notification/INotification' {
|
|
175
|
+
export default interface INotification {
|
|
176
|
+
title: string;
|
|
177
|
+
text: string;
|
|
178
|
+
expectSideEffect?: boolean;
|
|
179
|
+
persistent?: boolean;
|
|
180
|
+
type: "info" | "error" | "success";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
declare module 'topol-plugin/types/SavedBlock/ISavedBlock' {
|
|
185
|
+
export default interface ISavedBlock {
|
|
186
|
+
id: number;
|
|
187
|
+
name: string;
|
|
188
|
+
definition: Array<Object>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
declare module 'topol-plugin/types/Theme/ITheme' {
|
|
193
|
+
export default interface ITheme {
|
|
194
|
+
preset: "light" | "dark";
|
|
195
|
+
borderRadius?: {
|
|
196
|
+
small?: string;
|
|
197
|
+
large?: string;
|
|
198
|
+
};
|
|
199
|
+
colors: {
|
|
200
|
+
"900"?: string;
|
|
201
|
+
"800"?: string;
|
|
202
|
+
"700"?: string;
|
|
203
|
+
"600"?: string;
|
|
204
|
+
"500"?: string;
|
|
205
|
+
"450"?: string;
|
|
206
|
+
"400"?: string;
|
|
207
|
+
"350"?: string;
|
|
208
|
+
"300"?: string;
|
|
209
|
+
"200"?: string;
|
|
210
|
+
"150"?: string;
|
|
211
|
+
"100"?: string;
|
|
212
|
+
white?: string;
|
|
213
|
+
primary?: string;
|
|
214
|
+
"primary-light"?: string;
|
|
215
|
+
"primary-dark"?: string;
|
|
216
|
+
secondary?: string;
|
|
217
|
+
"secondary-light"?: string;
|
|
218
|
+
error?: string;
|
|
219
|
+
"error-light"?: string;
|
|
220
|
+
success?: string;
|
|
221
|
+
"success-light"?: string;
|
|
222
|
+
active?: string;
|
|
223
|
+
"active-light"?: string;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
declare module 'topol-plugin' {
|
|
229
|
+
import main = require('topol-plugin/src/main');
|
|
230
|
+
export = main;
|
|
231
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var loadScript = function load(src, opts, cb) {
|
|
2
|
+
var head = document.head || document.getElementsByTagName("head")[0];
|
|
3
|
+
var script = document.createElement("script");
|
|
4
|
+
if (typeof opts === "function") {
|
|
5
|
+
cb = opts;
|
|
6
|
+
opts = {};
|
|
7
|
+
}
|
|
8
|
+
opts = opts || {};
|
|
9
|
+
cb = cb || function() {
|
|
10
|
+
};
|
|
11
|
+
script.type = opts.type || "text/javascript";
|
|
12
|
+
script.charset = opts.charset || "utf8";
|
|
13
|
+
script.async = "async" in opts ? !!opts.async : true;
|
|
14
|
+
script.src = src;
|
|
15
|
+
if (opts.attrs) {
|
|
16
|
+
setAttributes(script, opts.attrs);
|
|
17
|
+
}
|
|
18
|
+
if (opts.text) {
|
|
19
|
+
script.text = "" + opts.text;
|
|
20
|
+
}
|
|
21
|
+
var onend = "onload" in script ? stdOnEnd : ieOnEnd;
|
|
22
|
+
onend(script, cb);
|
|
23
|
+
if (!script.onload) {
|
|
24
|
+
stdOnEnd(script, cb);
|
|
25
|
+
}
|
|
26
|
+
head.appendChild(script);
|
|
27
|
+
};
|
|
28
|
+
function setAttributes(script, attrs) {
|
|
29
|
+
for (var attr in attrs) {
|
|
30
|
+
script.setAttribute(attr, attrs[attr]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function stdOnEnd(script, cb) {
|
|
34
|
+
script.onload = function() {
|
|
35
|
+
this.onerror = this.onload = null;
|
|
36
|
+
cb(null, script);
|
|
37
|
+
};
|
|
38
|
+
script.onerror = function() {
|
|
39
|
+
this.onerror = this.onload = null;
|
|
40
|
+
cb(new Error("Failed to load " + this.src), script);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function ieOnEnd(script, cb) {
|
|
44
|
+
script.onreadystatechange = function() {
|
|
45
|
+
if (this.readyState != "complete" && this.readyState != "loaded")
|
|
46
|
+
return;
|
|
47
|
+
this.onreadystatechange = null;
|
|
48
|
+
cb(null, script);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const TOPOL_URL = "https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js";
|
|
52
|
+
const createTopolPlugin = (options) => {
|
|
53
|
+
const init = () => {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
loadScript(TOPOL_URL, (err) => {
|
|
56
|
+
if (err !== null) {
|
|
57
|
+
reject(err);
|
|
58
|
+
}
|
|
59
|
+
window.TopolPlugin.init(options);
|
|
60
|
+
resolve(true);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const save = () => {
|
|
65
|
+
window.TopolPlugin.save();
|
|
66
|
+
};
|
|
67
|
+
const load2 = (json) => {
|
|
68
|
+
window.TopolPlugin.load(json);
|
|
69
|
+
};
|
|
70
|
+
const togglePreview = () => {
|
|
71
|
+
window.TopolPlugin.togglePreview();
|
|
72
|
+
};
|
|
73
|
+
const togglePreviewSize = () => {
|
|
74
|
+
window.TopolPlugin.togglePreviewSize();
|
|
75
|
+
};
|
|
76
|
+
const chooseFile = (url) => {
|
|
77
|
+
window.TopolPlugin.chooseFile(url);
|
|
78
|
+
};
|
|
79
|
+
const undo = () => {
|
|
80
|
+
window.TopolPlugin.undo();
|
|
81
|
+
};
|
|
82
|
+
const redo = () => {
|
|
83
|
+
window.TopolPlugin.redo();
|
|
84
|
+
};
|
|
85
|
+
const setSavedBlocks = (savedBlocks) => {
|
|
86
|
+
window.TopolPlugin.setSavedBlocks(savedBlocks);
|
|
87
|
+
};
|
|
88
|
+
const createNotification = (notification) => {
|
|
89
|
+
window.TopolPlugin.createNotification(notification);
|
|
90
|
+
};
|
|
91
|
+
const changeEmailToMobile = () => {
|
|
92
|
+
window.TopolPlugin.changeEmailToMobile();
|
|
93
|
+
};
|
|
94
|
+
const changeEmailToDesktop = () => {
|
|
95
|
+
window.TopolPlugin.changeEmailToDesktop();
|
|
96
|
+
};
|
|
97
|
+
const toggleBlocksAndStructuresVisibility = () => {
|
|
98
|
+
window.TopolPlugin.toggleBlocksAndStructuresVisibility();
|
|
99
|
+
};
|
|
100
|
+
const destroy = () => {
|
|
101
|
+
window.TopolPlugin.destroy();
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
init,
|
|
105
|
+
save,
|
|
106
|
+
load: load2,
|
|
107
|
+
togglePreview,
|
|
108
|
+
togglePreviewSize,
|
|
109
|
+
chooseFile,
|
|
110
|
+
undo,
|
|
111
|
+
redo,
|
|
112
|
+
setSavedBlocks,
|
|
113
|
+
createNotification,
|
|
114
|
+
changeEmailToMobile,
|
|
115
|
+
changeEmailToDesktop,
|
|
116
|
+
toggleBlocksAndStructuresVisibility,
|
|
117
|
+
destroy
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export { createTopolPlugin as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(d,a){typeof exports=="object"&&typeof module!="undefined"?module.exports=a():typeof define=="function"&&define.amd?define(a):(d=typeof globalThis!="undefined"?globalThis:d||self,d["topol-plugin"]=a())})(this,function(){"use strict";var d=function(i,o,l){var r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("script");typeof o=="function"&&(l=o,o={}),o=o||{},l=l||function(){},n.type=o.type||"text/javascript",n.charset=o.charset||"utf8",n.async="async"in o?!!o.async:!0,n.src=i,o.attrs&&a(n,o.attrs),o.text&&(n.text=""+o.text);var s="onload"in n?c:g;s(n,l),n.onload||c(n,l),r.appendChild(n)};function a(e,i){for(var o in i)e.setAttribute(o,i[o])}function c(e,i){e.onload=function(){this.onerror=this.onload=null,i(null,e)},e.onerror=function(){this.onerror=this.onload=null,i(new Error("Failed to load "+this.src),e)}}function g(e,i){e.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,i(null,e))}}const w="https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js";return e=>({init:()=>new Promise((t,f)=>{d(w,u=>{u!==null&&f(u),window.TopolPlugin.init(e),t(!0)})}),save:()=>{window.TopolPlugin.save()},load:t=>{window.TopolPlugin.load(t)},togglePreview:()=>{window.TopolPlugin.togglePreview()},togglePreviewSize:()=>{window.TopolPlugin.togglePreviewSize()},chooseFile:t=>{window.TopolPlugin.chooseFile(t)},undo:()=>{window.TopolPlugin.undo()},redo:()=>{window.TopolPlugin.redo()},setSavedBlocks:t=>{window.TopolPlugin.setSavedBlocks(t)},createNotification:t=>{window.TopolPlugin.createNotification(t)},changeEmailToMobile:()=>{window.TopolPlugin.changeEmailToMobile()},changeEmailToDesktop:()=>{window.TopolPlugin.changeEmailToDesktop()},toggleBlocksAndStructuresVisibility:()=>{window.TopolPlugin.toggleBlocksAndStructuresVisibility()},destroy:()=>{window.TopolPlugin.destroy()}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topol.io/editor",
|
|
3
|
-
"version": "0.0.0-alfa.
|
|
3
|
+
"version": "0.0.0-alfa.2",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist"
|
|
6
|
+
],
|
|
7
|
+
"module": "./dist/topol-plugin.es.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/topol-plugin.es.js",
|
|
11
|
+
"require": "./dist/topol-plugin.umd.js",
|
|
12
|
+
"types": "./dist/topol-plugin.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
4
15
|
"scripts": {
|
|
5
16
|
"dev": "vite",
|
|
6
17
|
"build": "tsc && vite build && yarn run build:types",
|
|
@@ -25,4 +36,4 @@
|
|
|
25
36
|
"publishConfig": {
|
|
26
37
|
"access": "public"
|
|
27
38
|
}
|
|
28
|
-
}
|
|
39
|
+
}
|
package/.eslintrc.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-undef
|
|
2
|
-
module.exports = {
|
|
3
|
-
env: {
|
|
4
|
-
browser: true,
|
|
5
|
-
es2021: true,
|
|
6
|
-
},
|
|
7
|
-
extends: [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:@typescript-eslint/recommended",
|
|
10
|
-
"prettier",
|
|
11
|
-
],
|
|
12
|
-
parser: "@typescript-eslint/parser",
|
|
13
|
-
parserOptions: {
|
|
14
|
-
ecmaVersion: "latest",
|
|
15
|
-
sourceType: "module",
|
|
16
|
-
},
|
|
17
|
-
plugins: ["@typescript-eslint"],
|
|
18
|
-
};
|
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/.vscode/settings.json
DELETED
package/example/index.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Topol Plugin Example</title>
|
|
7
|
-
|
|
8
|
-
<style>
|
|
9
|
-
body {
|
|
10
|
-
margin: 0;
|
|
11
|
-
}
|
|
12
|
-
</style>
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div id="app" style="position: absolute; width: 100%; height: 100%"></div>
|
|
16
|
-
<script type="module" src="./index.ts"></script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
package/example/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import createTopolPlugin from "../src/main";
|
|
2
|
-
import TopolOptions from "../types/ITopolOptions";
|
|
3
|
-
|
|
4
|
-
const TOPOL_OPTIONS: TopolOptions = {
|
|
5
|
-
id: "#app",
|
|
6
|
-
authorize: {
|
|
7
|
-
apiKey: "5vse7PL21Ec17RcFEJACDHodtclmaTDZrh3DpvHgxtuNzuJOL7ALV3UCksA6",
|
|
8
|
-
userId: "someId",
|
|
9
|
-
},
|
|
10
|
-
callbacks: {
|
|
11
|
-
onSave(json, html) {
|
|
12
|
-
console.log(html);
|
|
13
|
-
console.log(json);
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const topolPlugin = createTopolPlugin(TOPOL_OPTIONS);
|
|
19
|
-
|
|
20
|
-
topolPlugin.init();
|
package/src/main.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import loadScript from "load-script";
|
|
2
|
-
import ITopolOptions from "../types/ITopolOptions";
|
|
3
|
-
import ITopolPlugin from "../types/ITopolPlugin";
|
|
4
|
-
import INotification from "../types/Notification/INotification";
|
|
5
|
-
import ISavedBlock from "../types/SavedBlock/ISavedBlock";
|
|
6
|
-
|
|
7
|
-
const TOPOL_URL =
|
|
8
|
-
"https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js";
|
|
9
|
-
|
|
10
|
-
declare global {
|
|
11
|
-
interface Window {
|
|
12
|
-
TopolPlugin: ITopolPlugin;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const createTopolPlugin = (options: ITopolOptions) => {
|
|
17
|
-
const init = (): Promise<boolean | string> => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
loadScript(TOPOL_URL, (err) => {
|
|
20
|
-
if (err !== null) {
|
|
21
|
-
reject(err);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
window.TopolPlugin.init(options);
|
|
25
|
-
|
|
26
|
-
resolve(true);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const save = () => {
|
|
32
|
-
window.TopolPlugin.save();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const load = (json: unknown) => {
|
|
36
|
-
window.TopolPlugin.load(json);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const togglePreview = () => {
|
|
40
|
-
window.TopolPlugin.togglePreview();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const togglePreviewSize = () => {
|
|
44
|
-
window.TopolPlugin.togglePreviewSize();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const chooseFile = (url: string) => {
|
|
48
|
-
window.TopolPlugin.chooseFile(url);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const undo = () => {
|
|
52
|
-
window.TopolPlugin.undo();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const redo = () => {
|
|
56
|
-
window.TopolPlugin.redo();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const setSavedBlocks = (savedBlocks: ISavedBlock[]) => {
|
|
60
|
-
window.TopolPlugin.setSavedBlocks(savedBlocks);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const createNotification = (notification: INotification) => {
|
|
64
|
-
window.TopolPlugin.createNotification(notification);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const changeEmailToMobile = () => {
|
|
68
|
-
window.TopolPlugin.changeEmailToMobile();
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const changeEmailToDesktop = () => {
|
|
72
|
-
window.TopolPlugin.changeEmailToDesktop();
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const toggleBlocksAndStructuresVisibility = () => {
|
|
76
|
-
window.TopolPlugin.toggleBlocksAndStructuresVisibility();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const destroy = () => {
|
|
80
|
-
window.TopolPlugin.destroy();
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
init,
|
|
85
|
-
save,
|
|
86
|
-
load,
|
|
87
|
-
togglePreview,
|
|
88
|
-
togglePreviewSize,
|
|
89
|
-
chooseFile,
|
|
90
|
-
undo,
|
|
91
|
-
redo,
|
|
92
|
-
setSavedBlocks,
|
|
93
|
-
createNotification,
|
|
94
|
-
changeEmailToMobile,
|
|
95
|
-
changeEmailToDesktop,
|
|
96
|
-
toggleBlocksAndStructuresVisibility,
|
|
97
|
-
destroy,
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default createTopolPlugin;
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
"declaration": false,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"jsx": "preserve",
|
|
10
|
-
"sourceMap": false,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"declarationMap": false,
|
|
13
|
-
"esModuleInterop": false,
|
|
14
|
-
"inlineSourceMap": false,
|
|
15
|
-
"lib": ["esnext", "dom"],
|
|
16
|
-
"types": ["node"]
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx"]
|
|
19
|
-
}
|
package/types/API/API.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface IAPI {
|
|
2
|
-
GET_AUTOSAVE: string;
|
|
3
|
-
AUTOSAVES: string;
|
|
4
|
-
LOAD: string;
|
|
5
|
-
SAVE: string | null;
|
|
6
|
-
AUTOSAVE: string;
|
|
7
|
-
PREVIEW: string;
|
|
8
|
-
FEEDS: string;
|
|
9
|
-
PRODUCTS: string;
|
|
10
|
-
IMAGE_UPLOAD: string;
|
|
11
|
-
FOLDERS: string;
|
|
12
|
-
IMAGE_EDITOR_UPLOAD: string | null;
|
|
13
|
-
TEST_EMAIL: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ILockedAPI {
|
|
17
|
-
GIPHY_API_KEY: string;
|
|
18
|
-
GIPHY_SEARCH: string;
|
|
19
|
-
AUTHORIZE: string;
|
|
20
|
-
GCS_SIGNED_URL: string;
|
|
21
|
-
SAVE_SERVER: string;
|
|
22
|
-
}
|
package/types/Font/IFont.ts
DELETED
package/types/ITopolOptions.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { IAPI } from "./API/API";
|
|
2
|
-
import ISavedBlock from "./SavedBlock/ISavedBlock";
|
|
3
|
-
import INotification from "./Notification/INotification";
|
|
4
|
-
import IMergeTagGroup from "./MergeTag/IMergeTagGroup";
|
|
5
|
-
import IContentBlockOptions from "./ContentBlock/IContentBlockOptions";
|
|
6
|
-
import ITheme from "./Theme/ITheme";
|
|
7
|
-
import IAuthHeaderConfig from "./AuthHeaderConfig/IAuthHeaderConfig";
|
|
8
|
-
import IFont from "./Font/IFont";
|
|
9
|
-
|
|
10
|
-
export default interface ITopolOptions {
|
|
11
|
-
id: string;
|
|
12
|
-
authorize: {
|
|
13
|
-
apiKey: string;
|
|
14
|
-
userId: string | number;
|
|
15
|
-
};
|
|
16
|
-
templateId?: number;
|
|
17
|
-
title?: string;
|
|
18
|
-
removeTopBar?: boolean;
|
|
19
|
-
topBarOptions?: Array<string>;
|
|
20
|
-
mainMenuAlign?: "left" | "right";
|
|
21
|
-
disableAlerts?: boolean;
|
|
22
|
-
customFileManager?: boolean;
|
|
23
|
-
language?: string;
|
|
24
|
-
light?: boolean;
|
|
25
|
-
theme?: ITheme;
|
|
26
|
-
hideSettingsTab?: boolean;
|
|
27
|
-
imageEditor?: boolean;
|
|
28
|
-
premadeBlocks?: unknown | boolean;
|
|
29
|
-
savedBlocks?: Array<ISavedBlock> | boolean;
|
|
30
|
-
mergeTags?: Array<IMergeTagGroup>;
|
|
31
|
-
enableAutosaves?: boolean;
|
|
32
|
-
htmlMinified?: boolean;
|
|
33
|
-
apiAuthorizationHeader?: IAuthHeaderConfig | string;
|
|
34
|
-
contentBlocks?: IContentBlockOptions[];
|
|
35
|
-
callbacks: {
|
|
36
|
-
onSave?(json: unknown, html: unknown): void;
|
|
37
|
-
onSaveAndClose?(json: unknown, html: unknown): void;
|
|
38
|
-
onTestSend?(email: string, json: unknown, html: unknown): void;
|
|
39
|
-
onOpenFileManager?(): void;
|
|
40
|
-
onLoaded?(): void;
|
|
41
|
-
onBlockSave?(block: ISavedBlock): void;
|
|
42
|
-
onBlockRemove?(blockId: number): void;
|
|
43
|
-
onBlockEdit?(blockId: number): void;
|
|
44
|
-
onInit?(): void;
|
|
45
|
-
onUndoChange?(count: number): void;
|
|
46
|
-
onRedoChange?(count: number): void;
|
|
47
|
-
onPreview?(html: unknown): void;
|
|
48
|
-
onAlert?(notification: INotification): void;
|
|
49
|
-
};
|
|
50
|
-
api?: IAPI;
|
|
51
|
-
mobileFirstEnabled?: boolean;
|
|
52
|
-
fonts?: Array<IFont>;
|
|
53
|
-
tinyConfig?: unknown;
|
|
54
|
-
fontSizes?: Array<number>;
|
|
55
|
-
colors?: Array<string>;
|
|
56
|
-
googleApiKey?: string;
|
|
57
|
-
role?: "manager" | "editor" | "reader";
|
|
58
|
-
}
|
package/types/ITopolPlugin.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import INotification from "./Notification/INotification";
|
|
2
|
-
import ISavedBlock from "./SavedBlock/ISavedBlock";
|
|
3
|
-
import ITopolOptions from "./ITopolOptions";
|
|
4
|
-
|
|
5
|
-
export default interface ITopolPlugin {
|
|
6
|
-
init: (topolOptions: ITopolOptions) => void;
|
|
7
|
-
save: () => void;
|
|
8
|
-
load: (json: unknown) => void;
|
|
9
|
-
togglePreview: () => void;
|
|
10
|
-
togglePreviewSize: () => void;
|
|
11
|
-
chooseFile: (url: string) => void;
|
|
12
|
-
undo: () => void;
|
|
13
|
-
redo: () => void;
|
|
14
|
-
setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
|
|
15
|
-
createNotification: (notification: INotification) => void;
|
|
16
|
-
changeEmailToMobile: () => void;
|
|
17
|
-
changeEmailToDesktop: () => void;
|
|
18
|
-
toggleBlocksAndStructuresVisibility: () => void;
|
|
19
|
-
destroy: () => void;
|
|
20
|
-
}
|
package/types/Theme/ITheme.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export default interface ITheme {
|
|
2
|
-
preset: "light" | "dark";
|
|
3
|
-
borderRadius?: {
|
|
4
|
-
small?: string;
|
|
5
|
-
large?: string;
|
|
6
|
-
};
|
|
7
|
-
colors: {
|
|
8
|
-
"900"?: string;
|
|
9
|
-
"800"?: string;
|
|
10
|
-
"700"?: string;
|
|
11
|
-
"600"?: string;
|
|
12
|
-
"500"?: string;
|
|
13
|
-
"450"?: string;
|
|
14
|
-
"400"?: string;
|
|
15
|
-
"350"?: string;
|
|
16
|
-
"300"?: string;
|
|
17
|
-
"200"?: string;
|
|
18
|
-
"150"?: string; // light only
|
|
19
|
-
"100"?: string; // light only
|
|
20
|
-
|
|
21
|
-
white?: string;
|
|
22
|
-
primary?: string;
|
|
23
|
-
"primary-light"?: string;
|
|
24
|
-
"primary-dark"?: string;
|
|
25
|
-
secondary?: string;
|
|
26
|
-
"secondary-light"?: string;
|
|
27
|
-
error?: string;
|
|
28
|
-
"error-light"?: string;
|
|
29
|
-
success?: string;
|
|
30
|
-
"success-light"?: string;
|
|
31
|
-
active?: string;
|
|
32
|
-
"active-light"?: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
|
|
4
|
-
// https://vitejs.dev/config/
|
|
5
|
-
export default defineConfig(({ mode }) => {
|
|
6
|
-
if (mode === "development") {
|
|
7
|
-
return {
|
|
8
|
-
root: resolve(__dirname, "example"),
|
|
9
|
-
};
|
|
10
|
-
} else {
|
|
11
|
-
return {
|
|
12
|
-
build: {
|
|
13
|
-
lib: {
|
|
14
|
-
entry: resolve(__dirname, "src/main.ts"),
|
|
15
|
-
name: "topol-plugin",
|
|
16
|
-
fileName: (format) => `topol-plugin.${format}.js`,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
});
|