@topol.io/editor 0.0.0-alfa.2 → 0.0.0-alfa.20

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2022 Ecomail s.r.o.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ <a href="https://topol.io" target="_blank">
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>
4
+
5
+ ---
6
+
7
+ Easy and quick! Drag and drop HTML editor and builder for beautiful responsive email templates.
8
+
9
+ # Documentation
10
+
11
+ ## Installation
12
+
13
+ Install Editor from NPM using:
14
+
15
+ ```sh
16
+ npm install @topol.io/editor
17
+
18
+ //or
19
+
20
+ yarn add @topol.io/editor
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Add HTML element Editor will load to
26
+
27
+ ```html
28
+ <div id="app" style="position: absolute; width: 100%; height: 100%"></div>
29
+ ```
30
+
31
+ In your JS or TS file import TopolPlugin, initialize the editor, as an ID provide the id you defined the HTML, in this example its `app`
32
+
33
+ For more options see the docs for [TopolOptions configuration](https://topol.io/docs#plugin-configuration)
34
+
35
+ ```js
36
+ import TopolPlugin from "@topol.io/editor";
37
+
38
+ const TOPOL_OPTIONS = {
39
+ id: "#app",
40
+ authorize: {
41
+ apiKey: "YOUR_API_TOKEN",
42
+ userId: "some-user-id",
43
+ },
44
+ callbacks: {
45
+ onSave(json, html) {},
46
+ },
47
+ };
48
+
49
+ TopolPlugin.init(TOPOL_OPTIONS);
50
+ ```
51
+
52
+ ## Call Topol Plugin actions
53
+
54
+ To call actions to the editor import:
55
+
56
+ ```js
57
+ import { TopolPlugin } from "@topol.io/editor";
58
+
59
+ TopolPlugin.save();
60
+ ```
61
+
62
+ ### List of all available TopolPlugin actions:
63
+
64
+ | Action | Description |
65
+ | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
66
+ | `TopolPlugin.save()` | Saves the content of the editor [more info](https://topol.io/docs#plugin-configuration) |
67
+ | `TopolPlugin.load(template`) | Loads the provided template [more info](https://topol.io/docs#save-and-load-options) |
68
+ | `TopolPlugin.togglePreview()` | Toggles editor preview [more info](https://topol.io/docs#preview-mode-on-desktop-and-mobile) |
69
+ | `TopolPlugin.togglePreviewSize()` | Toggles editor preview size |
70
+ | `TopolPlugin.undo()` | Undo change in editor [more info](https://topol.io/docs#redo-and-undo) |
71
+ | `TopolPlugin.redo()` | Redo change in editor [more info](https://topol.io/docs#redo-and-undo) |
72
+ | `TopolPlugin.setSavedBlocks(savedblock: ISavedBlock[])` | Sets the saved blocks [more info](https://topol.io/docs#saved-blocks) |
73
+ | `TopolPlugin.createNotification(notification: INotification)` | Creates editor's notification [more info](https://topol.io/docs#show-custom-notification-in-editor) |
74
+ | `TopolPlugin.changeEmailToMobile()` | Change email to mobile view [more info](https://topol.io/docs#mobile-first-email-template) |
75
+ | `TopolPlugin.changeEmailToDesktop()` | Change email to desktop view [more info](https://topol.io/docs#mobile-first-email-template) |
76
+ | `TopolPlugin.toggleBlocksAndStructuresVisibility()` | Toggle hidden structures visibility for blocks and structures [more info](https://topol.io/docs#mobile-first-email-template) |
77
+ | `TopolPlugin.destroy()` | Destroys the editor initialization [more info](https://topol.io/docs#working-with-js-frameworks) |
78
+
79
+ <br>
80
+ <br>
81
+
82
+ ## TypeScript
83
+
84
+ Topol Editor provides full TypeScript integration and exports all necessary types.
85
+
86
+ ```ts
87
+ import { ITopolOptions, INotification, ISavedBlock } from "@topol.io/editor";
88
+ ```
@@ -1,120 +1,87 @@
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);
1
+ function r(o) {
2
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
3
+ }
4
+ var u = function(t, e, l) {
5
+ var i = document.head || document.getElementsByTagName("head")[0], n = document.createElement("script");
6
+ typeof e == "function" && (l = e, e = {}), e = e || {}, l = l || function() {
7
+ }, n.type = e.type || "text/javascript", n.charset = e.charset || "utf8", n.async = "async" in e ? !!e.async : !0, n.src = t, e.attrs && c(n, e.attrs), e.text && (n.text = "" + e.text);
8
+ var d = "onload" in n ? a : s;
9
+ d(n, l), n.onload || a(n, l), i.appendChild(n);
27
10
  };
28
- function setAttributes(script, attrs) {
29
- for (var attr in attrs) {
30
- script.setAttribute(attr, attrs[attr]);
31
- }
11
+ function c(o, t) {
12
+ for (var e in t)
13
+ o.setAttribute(e, t[e]);
32
14
  }
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);
15
+ function a(o, t) {
16
+ o.onload = function() {
17
+ this.onerror = this.onload = null, t(null, o);
18
+ }, o.onerror = function() {
19
+ this.onerror = this.onload = null, t(new Error("Failed to load " + this.src), o);
41
20
  };
42
21
  }
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);
22
+ function s(o, t) {
23
+ o.onreadystatechange = function() {
24
+ this.readyState != "complete" && this.readyState != "loaded" || (this.onreadystatechange = null, t(null, o));
49
25
  };
50
26
  }
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
- });
27
+ const g = /* @__PURE__ */ r(u), w = "https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js", f = "https://d5aoblv5p04cg.cloudfront.net/develop/loader/build.js", h = "https://d5aoblv5p04cg.cloudfront.net/staging/loader/build.js";
28
+ function T(o = "production") {
29
+ switch (o) {
30
+ case "dev":
31
+ return f;
32
+ case "staging":
33
+ return h;
34
+ default:
35
+ return w;
36
+ }
37
+ }
38
+ const P = {
39
+ init: (o, t) => new Promise((e, l) => {
40
+ const i = T(t == null ? void 0 : t.stage);
41
+ g(i, (n) => {
42
+ n !== null && l(n), window.TopolPlugin.init(o), e(!0);
62
43
  });
63
- };
64
- const save = () => {
44
+ }),
45
+ save: () => {
65
46
  window.TopolPlugin.save();
66
- };
67
- const load2 = (json) => {
68
- window.TopolPlugin.load(json);
69
- };
70
- const togglePreview = () => {
47
+ },
48
+ load: (o) => {
49
+ window.TopolPlugin.load(o);
50
+ },
51
+ togglePreview: () => {
71
52
  window.TopolPlugin.togglePreview();
72
- };
73
- const togglePreviewSize = () => {
53
+ },
54
+ togglePreviewSize: () => {
74
55
  window.TopolPlugin.togglePreviewSize();
75
- };
76
- const chooseFile = (url) => {
77
- window.TopolPlugin.chooseFile(url);
78
- };
79
- const undo = () => {
56
+ },
57
+ chooseFile: (o) => {
58
+ window.TopolPlugin.chooseFile(o);
59
+ },
60
+ undo: () => {
80
61
  window.TopolPlugin.undo();
81
- };
82
- const redo = () => {
62
+ },
63
+ redo: () => {
83
64
  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 = () => {
65
+ },
66
+ setSavedBlocks: (o) => {
67
+ window.TopolPlugin.setSavedBlocks(o);
68
+ },
69
+ createNotification: (o) => {
70
+ window.TopolPlugin.createNotification(o);
71
+ },
72
+ changeEmailToMobile: () => {
92
73
  window.TopolPlugin.changeEmailToMobile();
93
- };
94
- const changeEmailToDesktop = () => {
74
+ },
75
+ changeEmailToDesktop: () => {
95
76
  window.TopolPlugin.changeEmailToDesktop();
96
- };
97
- const toggleBlocksAndStructuresVisibility = () => {
77
+ },
78
+ toggleBlocksAndStructuresVisibility: () => {
98
79
  window.TopolPlugin.toggleBlocksAndStructuresVisibility();
99
- };
100
- const destroy = () => {
80
+ },
81
+ destroy: () => {
101
82
  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
- };
83
+ }
84
+ };
85
+ export {
86
+ P as default
119
87
  };
120
- export { createTopolPlugin as default };
@@ -1 +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()}})});
1
+ (function(l,d){typeof exports=="object"&&typeof module<"u"?module.exports=d():typeof define=="function"&&define.amd?define(d):(l=typeof globalThis<"u"?globalThis:l||self,l["topol-plugin"]=d())})(this,function(){"use strict";function l(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var d=function(t,e,i){var r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("script");typeof e=="function"&&(i=e,e={}),e=e||{},i=i||function(){},n.type=e.type||"text/javascript",n.charset=e.charset||"utf8",n.async="async"in e?!!e.async:!0,n.src=t,e.attrs&&u(n,e.attrs),e.text&&(n.text=""+e.text);var h="onload"in n?a:c;h(n,i),n.onload||a(n,i),r.appendChild(n)};function u(o,t){for(var e in t)o.setAttribute(e,t[e])}function a(o,t){o.onload=function(){this.onerror=this.onload=null,t(null,o)},o.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),o)}}function c(o,t){o.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,t(null,o))}}const s=l(d),g="https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js",f="https://d5aoblv5p04cg.cloudfront.net/develop/loader/build.js",w="https://d5aoblv5p04cg.cloudfront.net/staging/loader/build.js";function p(o="production"){switch(o){case"dev":return f;case"staging":return w;default:return g}}return{init:(o,t)=>new Promise((e,i)=>{const r=p(t==null?void 0:t.stage);s(r,n=>{n!==null&&i(n),window.TopolPlugin.init(o),e(!0)})}),save:()=>{window.TopolPlugin.save()},load:o=>{window.TopolPlugin.load(o)},togglePreview:()=>{window.TopolPlugin.togglePreview()},togglePreviewSize:()=>{window.TopolPlugin.togglePreviewSize()},chooseFile:o=>{window.TopolPlugin.chooseFile(o)},undo:()=>{window.TopolPlugin.undo()},redo:()=>{window.TopolPlugin.redo()},setSavedBlocks:o=>{window.TopolPlugin.setSavedBlocks(o)},createNotification:o=>{window.TopolPlugin.createNotification(o)},changeEmailToMobile:()=>{window.TopolPlugin.changeEmailToMobile()},changeEmailToDesktop:()=>{window.TopolPlugin.changeEmailToDesktop()},toggleBlocksAndStructuresVisibility:()=>{window.TopolPlugin.toggleBlocksAndStructuresVisibility()},destroy:()=>{window.TopolPlugin.destroy()}}});
@@ -0,0 +1,39 @@
1
+ import ITopolOptions from "../types/ITopolOptions";
2
+ import ITopolPlugin from "../types/ITopolPlugin";
3
+ import INotification from "../types/Notification/INotification";
4
+ import ISavedBlock from "../types/SavedBlock/ISavedBlock";
5
+ import IMergeTagGroup from "../types/MergeTag/IMergeTagGroup";
6
+ import IMergeTag from "../types/MergeTag/IMergeTag";
7
+ import IContentBlockOptions from "../types/ContentBlock/IContentBlockOptions";
8
+ import ITheme from "../types/Theme/ITheme";
9
+ import IAuthHeaderConfig from "../types/AuthHeaderConfig/IAuthHeaderConfig";
10
+ import IFont from "../types/Font/IFont";
11
+ import IAPI from "../types/API/API";
12
+ import ICustomBlockData from "../types/CustomBlocks/CustomBlocks";
13
+ declare global {
14
+ interface Window {
15
+ TopolPlugin: ITopolPlugin;
16
+ }
17
+ }
18
+ type Stage = 'dev' | 'staging' | 'production';
19
+ interface PluginOptions {
20
+ stage?: Stage;
21
+ }
22
+ declare const TopolPlugin: {
23
+ init: (topolOptions: ITopolOptions, options?: PluginOptions) => Promise<boolean | string>;
24
+ save: () => void;
25
+ load: (json: unknown) => void;
26
+ togglePreview: () => void;
27
+ togglePreviewSize: () => void;
28
+ chooseFile: (url: string) => void;
29
+ undo: () => void;
30
+ redo: () => void;
31
+ setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
32
+ createNotification: (notification: INotification) => void;
33
+ changeEmailToMobile: () => void;
34
+ changeEmailToDesktop: () => void;
35
+ toggleBlocksAndStructuresVisibility: () => void;
36
+ destroy: () => void;
37
+ };
38
+ export default TopolPlugin;
39
+ export type { ITopolOptions, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData };
@@ -0,0 +1,14 @@
1
+ export default interface IAPI {
2
+ GET_AUTOSAVE?: string;
3
+ AUTOSAVES?: string;
4
+ LOAD?: string;
5
+ SAVE?: string;
6
+ AUTOSAVE?: string;
7
+ PREVIEW?: string;
8
+ FEEDS?: string;
9
+ PRODUCTS?: string;
10
+ IMAGE_UPLOAD?: string;
11
+ FOLDERS?: string;
12
+ IMAGE_EDITOR_UPLOAD?: string;
13
+ TEST_EMAIL?: string;
14
+ }
@@ -0,0 +1,3 @@
1
+ export default interface AuthHeaderConfig {
2
+ [key: string]: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ export default interface IContentBlockOptions {
2
+ disabled?: boolean;
3
+ disabledText?: string;
4
+ hidden?: boolean;
5
+ }
@@ -0,0 +1,20 @@
1
+ import IContentBlockOptions from "../ContentBlock/IContentBlockOptions";
2
+ export type BlockType = "text" | "image" | "gif" | "button" | "divider" | "spacer" | "social" | "video" | "html" | "product" | "dynamic" | "article" | "carousel" | "raw" | "custom-raw";
3
+ export type IContentBlockOptionsType = {
4
+ [key in BlockType]: IContentBlockOptions;
5
+ };
6
+ export type ICustomBlockData = {
7
+ key: string;
8
+ name: string;
9
+ dialog: true;
10
+ icon?: "box" | "rss" | string;
11
+ content?: string;
12
+ dialogButtonText?: string;
13
+ beta?: boolean;
14
+ disabled?: boolean;
15
+ };
16
+ export type BlockClickedEvent = {
17
+ type: BlockType;
18
+ customBlockData?: ICustomBlockData;
19
+ };
20
+ export default ICustomBlockData;
@@ -0,0 +1,5 @@
1
+ export default interface IFont {
2
+ label: string;
3
+ style: string;
4
+ url?: string;
5
+ }
@@ -0,0 +1,69 @@
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
+ import ICustomBlockData from "./CustomBlocks/CustomBlocks";
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
+ onClose?(): void;
50
+ };
51
+ api?: IAPI;
52
+ mobileFirstEnabled?: boolean;
53
+ customFonts?: {
54
+ override?: boolean;
55
+ fonts: Array<IFont>;
56
+ };
57
+ tinyConfig?: unknown;
58
+ fontSizes?: Array<number>;
59
+ colors?: Array<string>;
60
+ googleApiKey?: string;
61
+ role?: "manager" | "editor" | "reader";
62
+ windowBar?: Array<string>;
63
+ imageMaxSize?: number;
64
+ autosaveInterval?: number;
65
+ betaFeatures?: {
66
+ carousel?: boolean;
67
+ };
68
+ customBlocks?: ICustomBlockData[];
69
+ }
@@ -0,0 +1,19 @@
1
+ import INotification from "./Notification/INotification";
2
+ import ISavedBlock from "./SavedBlock/ISavedBlock";
3
+ import ITopolOptions from "./ITopolOptions";
4
+ export default interface ITopolPlugin {
5
+ init: (topolOptions: ITopolOptions) => void;
6
+ save: () => void;
7
+ load: (json: unknown) => void;
8
+ togglePreview: () => void;
9
+ togglePreviewSize: () => void;
10
+ chooseFile: (url: string) => void;
11
+ undo: () => void;
12
+ redo: () => void;
13
+ setSavedBlocks: (savedBlocks: ISavedBlock[]) => void;
14
+ createNotification: (notification: INotification) => void;
15
+ changeEmailToMobile: () => void;
16
+ changeEmailToDesktop: () => void;
17
+ toggleBlocksAndStructuresVisibility: () => void;
18
+ destroy: () => void;
19
+ }
@@ -0,0 +1,5 @@
1
+ export default interface IMergeTag {
2
+ value: string;
3
+ text: string;
4
+ label: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import IMergeTag from "./IMergeTag";
2
+ export default interface IMergeTagGroup {
3
+ name: string;
4
+ items: Array<IMergeTag | IMergeTagGroup>;
5
+ }
@@ -0,0 +1,7 @@
1
+ export default interface INotification {
2
+ title: string;
3
+ text: string;
4
+ expectSideEffect?: boolean;
5
+ persistent?: boolean;
6
+ type: "info" | "error" | "success";
7
+ }
@@ -0,0 +1,5 @@
1
+ export default interface ISavedBlock {
2
+ id: number;
3
+ name: string;
4
+ definition: unknown;
5
+ }
@@ -0,0 +1,33 @@
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;
19
+ "100"?: string;
20
+ white?: string;
21
+ primary?: string;
22
+ "primary-light"?: string;
23
+ "primary-dark"?: string;
24
+ secondary?: string;
25
+ "secondary-light"?: string;
26
+ error?: string;
27
+ "error-light"?: string;
28
+ success?: string;
29
+ "success-light"?: string;
30
+ active?: string;
31
+ "active-light"?: string;
32
+ };
33
+ }
package/package.json CHANGED
@@ -1,34 +1,46 @@
1
1
  {
2
2
  "name": "@topol.io/editor",
3
- "version": "0.0.0-alfa.2",
3
+ "description": "Official package for Topol Editor.",
4
+ "keywords": [
5
+ "plugin",
6
+ "editor",
7
+ "email",
8
+ "topol",
9
+ "topol.io",
10
+ "email templates"
11
+ ],
12
+ "author": "Topol.io",
13
+ "homepage": "https://topol.io",
14
+ "license": "Apache-2.0",
15
+ "version": "0.0.0-alfa.20",
4
16
  "files": [
5
17
  "dist"
6
18
  ],
7
19
  "module": "./dist/topol-plugin.es.js",
20
+ "types": "./dist/types/src/main.d.ts",
8
21
  "exports": {
9
22
  ".": {
10
23
  "import": "./dist/topol-plugin.es.js",
11
24
  "require": "./dist/topol-plugin.umd.js",
12
- "types": "./dist/topol-plugin.d.ts"
25
+ "types": "./dist/types/src/main.d.ts"
13
26
  }
14
27
  },
15
28
  "scripts": {
16
29
  "dev": "vite",
17
- "build": "tsc && vite build && yarn run build:types",
30
+ "build": "vite build && yarn run build:types",
18
31
  "lint": "eslint --config '.eslintrc.js' ./**/*.ts --fix",
19
32
  "format": "prettier --write .",
20
- "build:types": "npm-dts generate --entry ./src/main --output ./dist/topol-plugin.d.ts"
33
+ "build:types": "tsc -p tsconfig.prod.json"
21
34
  },
22
35
  "devDependencies": {
23
- "@types/node": "^17.0.12",
24
- "@typescript-eslint/eslint-plugin": "^5.10.1",
25
- "@typescript-eslint/parser": "^5.10.1",
26
- "eslint": "^8.7.0",
27
- "eslint-config-prettier": "^8.3.0",
28
- "npm-dts": "^1.3.10",
29
- "prettier": "2.5.1",
30
- "typescript": "^4.4.4",
31
- "vite": "^2.7.2"
36
+ "@types/node": "^20.6.5",
37
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
38
+ "@typescript-eslint/parser": "^6.7.2",
39
+ "eslint": "^8.50.0",
40
+ "eslint-config-prettier": "^9.0.0",
41
+ "prettier": "3.0.3",
42
+ "typescript": "^5.2.2",
43
+ "vite": "^4.4.9"
32
44
  },
33
45
  "dependencies": {
34
46
  "load-script": "^2.0.0"
package/README DELETED
@@ -1 +0,0 @@
1
- # Topol Plugin NPM package
@@ -1,231 +0,0 @@
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
- }