@topol.io/editor 0.0.0-alfa.9 → 0.0.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.
@@ -1,71 +1,52 @@
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 TopolPlugin = {
53
- init: (options) => {
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
- },
44
+ }),
64
45
  save: () => {
65
46
  window.TopolPlugin.save();
66
47
  },
67
- load: (json) => {
68
- window.TopolPlugin.load(json);
48
+ load: (o) => {
49
+ window.TopolPlugin.load(o);
69
50
  },
70
51
  togglePreview: () => {
71
52
  window.TopolPlugin.togglePreview();
@@ -73,8 +54,8 @@ const TopolPlugin = {
73
54
  togglePreviewSize: () => {
74
55
  window.TopolPlugin.togglePreviewSize();
75
56
  },
76
- chooseFile: (url) => {
77
- window.TopolPlugin.chooseFile(url);
57
+ chooseFile: (o) => {
58
+ window.TopolPlugin.chooseFile(o);
78
59
  },
79
60
  undo: () => {
80
61
  window.TopolPlugin.undo();
@@ -82,11 +63,11 @@ const TopolPlugin = {
82
63
  redo: () => {
83
64
  window.TopolPlugin.redo();
84
65
  },
85
- setSavedBlocks: (savedBlocks) => {
86
- window.TopolPlugin.setSavedBlocks(savedBlocks);
66
+ setSavedBlocks: (o) => {
67
+ window.TopolPlugin.setSavedBlocks(o);
87
68
  },
88
- createNotification: (notification) => {
89
- window.TopolPlugin.createNotification(notification);
69
+ createNotification: (o) => {
70
+ window.TopolPlugin.createNotification(o);
90
71
  },
91
72
  changeEmailToMobile: () => {
92
73
  window.TopolPlugin.changeEmailToMobile();
@@ -101,4 +82,6 @@ const TopolPlugin = {
101
82
  window.TopolPlugin.destroy();
102
83
  }
103
84
  };
104
- export { TopolPlugin as default };
85
+ export {
86
+ P as default
87
+ };
@@ -1 +1 @@
1
- (function(l,d){typeof exports=="object"&&typeof module!="undefined"?module.exports=d():typeof define=="function"&&define.amd?define(d):(l=typeof globalThis!="undefined"?globalThis:l||self,l["topol-plugin"]=d())})(this,function(){"use strict";var l=function(n,e,t){var c=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");typeof e=="function"&&(t=e,e={}),e=e||{},t=t||function(){},i.type=e.type||"text/javascript",i.charset=e.charset||"utf8",i.async="async"in e?!!e.async:!0,i.src=n,e.attrs&&d(i,e.attrs),e.text&&(i.text=""+e.text);var s="onload"in i?u:a;s(i,t),i.onload||u(i,t),c.appendChild(i)};function d(o,n){for(var e in n)o.setAttribute(e,n[e])}function u(o,n){o.onload=function(){this.onerror=this.onload=null,n(null,o)},o.onerror=function(){this.onerror=this.onload=null,n(new Error("Failed to load "+this.src),o)}}function a(o,n){o.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,n(null,o))}}const r="https://d5aoblv5p04cg.cloudfront.net/editor-3/loader/build.js";return{init:o=>new Promise((n,e)=>{l(r,t=>{t!==null&&e(t),window.TopolPlugin.init(o),n(!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()}}});
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()}}});
@@ -2,13 +2,25 @@ import ITopolOptions from "../types/ITopolOptions";
2
2
  import ITopolPlugin from "../types/ITopolPlugin";
3
3
  import INotification from "../types/Notification/INotification";
4
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
+ import { Stage } from "../types/Stage";
5
14
  declare global {
6
15
  interface Window {
7
16
  TopolPlugin: ITopolPlugin;
8
17
  }
9
18
  }
19
+ interface PluginOptions {
20
+ stage?: Stage;
21
+ }
10
22
  declare const TopolPlugin: {
11
- init: (options: ITopolOptions) => Promise<boolean | string>;
23
+ init: (topolOptions: ITopolOptions, options?: PluginOptions) => Promise<boolean | string>;
12
24
  save: () => void;
13
25
  load: (json: unknown) => void;
14
26
  togglePreview: () => void;
@@ -24,6 +36,4 @@ declare const TopolPlugin: {
24
36
  destroy: () => void;
25
37
  };
26
38
  export default TopolPlugin;
27
- export type { ITopolOptions };
28
- export type { INotification };
29
- export type { ISavedBlock };
39
+ export type { ITopolOptions, INotification, ISavedBlock, IMergeTagGroup, IMergeTag, IContentBlockOptions, ITheme, IAuthHeaderConfig, IFont, IAPI, ICustomBlockData, Stage as IStage };
@@ -1,21 +1,14 @@
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
- export interface ILockedAPI {
16
- GIPHY_API_KEY: string;
17
- GIPHY_SEARCH: string;
18
- AUTHORIZE: string;
19
- GCS_SIGNED_URL: string;
20
- SAVE_SERVER: string;
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;
21
14
  }
@@ -1,5 +1,10 @@
1
- export default interface IContentBlockOptions {
1
+ type BlockType = "text" | "image" | "gif" | "button" | "divider" | "spacer" | "social" | "video" | "html" | "product";
2
+ export type IContentBlockOption = {
2
3
  disabled?: boolean;
3
4
  disabledText?: string;
4
5
  hidden?: boolean;
5
- }
6
+ };
7
+ export type IContentBlockOptions = {
8
+ [TKey in BlockType]?: IContentBlockOption;
9
+ };
10
+ export {};
@@ -0,0 +1,20 @@
1
+ import { IContentBlockOption } 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]: IContentBlockOption;
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;
@@ -1,36 +1,39 @@
1
- import { IAPI } from "./API/API";
1
+ import IAPI from "./API/API";
2
2
  import ISavedBlock from "./SavedBlock/ISavedBlock";
3
3
  import INotification from "./Notification/INotification";
4
4
  import IMergeTagGroup from "./MergeTag/IMergeTagGroup";
5
- import IContentBlockOptions from "./ContentBlock/IContentBlockOptions";
5
+ import { IContentBlockOptions } from "./ContentBlock/IContentBlockOptions";
6
6
  import ITheme from "./Theme/ITheme";
7
7
  import IAuthHeaderConfig from "./AuthHeaderConfig/IAuthHeaderConfig";
8
8
  import IFont from "./Font/IFont";
9
+ import ICustomBlockData from "./CustomBlocks/CustomBlocks";
10
+ import { Language } from "./Language/Language";
11
+ import IMergeTag from "./MergeTag/IMergeTag";
12
+ import SmartMergeTagPattern from "./MergeTag/SmartMergeTagPattern";
9
13
  export default interface ITopolOptions {
10
14
  id: string;
11
15
  authorize: {
12
16
  apiKey: string;
13
17
  userId: string | number;
14
18
  };
15
- templateId?: number;
16
19
  title?: string;
17
20
  removeTopBar?: boolean;
18
21
  topBarOptions?: Array<string>;
19
22
  mainMenuAlign?: "left" | "right";
20
23
  disableAlerts?: boolean;
21
24
  customFileManager?: boolean;
22
- language?: string;
25
+ language?: Language;
23
26
  light?: boolean;
24
27
  theme?: ITheme;
25
28
  hideSettingsTab?: boolean;
26
29
  imageEditor?: boolean;
27
- premadeBlocks?: unknown | boolean;
30
+ premadeBlocks?: Record<any, any> | boolean;
28
31
  savedBlocks?: Array<ISavedBlock> | boolean;
29
- mergeTags?: Array<IMergeTagGroup>;
32
+ mergeTags?: Array<IMergeTagGroup | IMergeTag>;
30
33
  enableAutosaves?: boolean;
31
34
  htmlMinified?: boolean;
32
35
  apiAuthorizationHeader?: IAuthHeaderConfig | string;
33
- contentBlocks?: IContentBlockOptions[];
36
+ contentBlocks?: IContentBlockOptions;
34
37
  callbacks: {
35
38
  onSave?(json: unknown, html: unknown): void;
36
39
  onSaveAndClose?(json: unknown, html: unknown): void;
@@ -45,13 +48,45 @@ export default interface ITopolOptions {
45
48
  onRedoChange?(count: number): void;
46
49
  onPreview?(html: unknown): void;
47
50
  onAlert?(notification: INotification): void;
51
+ onClose?(): void;
52
+ onEdittedWithoutSaveChanged?(hasUnsavedChanges: boolean): void;
48
53
  };
49
54
  api?: IAPI;
50
55
  mobileFirstEnabled?: boolean;
51
- fonts?: Array<IFont>;
56
+ smartMergeTags?: {
57
+ enabled: boolean;
58
+ patterns?: Record<string, SmartMergeTagPattern>;
59
+ syntax?: {
60
+ start: string;
61
+ end: string;
62
+ };
63
+ };
64
+ customFonts?: {
65
+ override?: boolean;
66
+ fonts: Array<IFont>;
67
+ };
52
68
  tinyConfig?: unknown;
53
69
  fontSizes?: Array<number>;
54
70
  colors?: Array<string>;
55
71
  googleApiKey?: string;
56
72
  role?: "manager" | "editor" | "reader";
73
+ windowBar?: Array<string>;
74
+ imageMaxSize?: number;
75
+ autosaveInterval?: number;
76
+ betaFeatures?: {
77
+ carousel?: boolean;
78
+ };
79
+ customBlocks?: ICustomBlockData[];
80
+ imageCompressionOptions?: {
81
+ qualityJpeg?: number;
82
+ qualityPng?: number;
83
+ enableAutoResize?: boolean;
84
+ enableCompression?: boolean;
85
+ };
86
+ premadeTemplates?: boolean;
87
+ disableAiAssistant?: boolean;
88
+ chatAI?: boolean;
89
+ enableImageToTextRatio?: boolean;
90
+ enableTemplateSizeInfo?: boolean;
91
+ showUnsavedDialogBeforeExit?: boolean;
57
92
  }
@@ -16,4 +16,7 @@ export default interface ITopolPlugin {
16
16
  changeEmailToDesktop: () => void;
17
17
  toggleBlocksAndStructuresVisibility: () => void;
18
18
  destroy: () => void;
19
+ setPreviewHTML: (html: unknown) => void;
20
+ setActiveMembers: (activeMemers: string[]) => void;
21
+ updateCustomBlockContent: (content: string) => void;
19
22
  }
@@ -0,0 +1 @@
1
+ export type Language = "en" | "fr" | "pt" | "es" | "ja" | "zh" | "ru" | "tr" | "de" | "sv" | "nl" | "it" | "fi" | "ro" | "cs" | "pl" | "ko" | "vi" | "he";
@@ -0,0 +1,4 @@
1
+ export default interface SmartMergeTagPattern {
2
+ regex: string;
3
+ label: string;
4
+ }
@@ -1,5 +1,5 @@
1
1
  export default interface ISavedBlock {
2
2
  id: number;
3
3
  name: string;
4
- definition: Array<Object>;
4
+ definition: unknown;
5
5
  }
@@ -0,0 +1 @@
1
+ export type Stage = "dev" | "staging" | "production";
@@ -10,24 +10,26 @@ export default interface ITheme {
10
10
  "700"?: string;
11
11
  "600"?: string;
12
12
  "500"?: string;
13
- "450"?: string;
14
13
  "400"?: string;
15
- "350"?: string;
16
14
  "300"?: string;
17
15
  "200"?: string;
18
- "150"?: string;
19
16
  "100"?: string;
17
+ "50"?: string;
18
+ "10"?: string;
20
19
  white?: string;
21
20
  primary?: string;
22
21
  "primary-light"?: string;
22
+ "primary-light-2"?: string;
23
23
  "primary-dark"?: string;
24
24
  secondary?: string;
25
25
  "secondary-light"?: string;
26
+ "secondary-light-2"?: string;
26
27
  error?: string;
27
28
  "error-light"?: string;
28
29
  success?: string;
29
30
  "success-light"?: string;
30
31
  active?: string;
31
- "active-light"?: string;
32
+ "active-2"?: string;
33
+ "active-3"?: string;
32
34
  };
33
35
  }
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "author": "Topol.io",
13
13
  "homepage": "https://topol.io",
14
14
  "license": "Apache-2.0",
15
- "version": "0.0.0-alfa.9",
15
+ "version": "0.0.0",
16
16
  "files": [
17
17
  "dist"
18
18
  ],
@@ -25,28 +25,27 @@
25
25
  "types": "./dist/types/src/main.d.ts"
26
26
  }
27
27
  },
28
- "scripts": {
29
- "dev": "vite",
30
- "build": "vite build && tsc",
31
- "lint": "eslint --config '.eslintrc.js' ./**/*.ts --fix",
32
- "format": "prettier --write .",
33
- "build:types": "tsc"
34
- },
35
28
  "devDependencies": {
36
- "@types/node": "^17.0.12",
37
- "@typescript-eslint/eslint-plugin": "^5.10.1",
38
- "@typescript-eslint/parser": "^5.10.1",
39
- "eslint": "^8.7.0",
40
- "eslint-config-prettier": "^8.3.0",
41
- "npm-dts": "^1.3.10",
42
- "prettier": "2.5.1",
43
- "typescript": "^4.4.4",
44
- "vite": "^2.7.2"
29
+ "@types/node": "^20.6.5",
30
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
31
+ "@typescript-eslint/parser": "^6.7.2",
32
+ "eslint": "^8.50.0",
33
+ "eslint-config-prettier": "^9.0.0",
34
+ "prettier": "3.0.3",
35
+ "typescript": "^5.2.2",
36
+ "vite": "^4.4.9"
45
37
  },
46
38
  "dependencies": {
47
39
  "load-script": "^2.0.0"
48
40
  },
49
41
  "publishConfig": {
50
42
  "access": "public"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite build --watch",
46
+ "build": "vite build && yarn run build:types",
47
+ "lint": "eslint --config '.eslintrc.js' ./**/*.ts --fix",
48
+ "format": "prettier --write .",
49
+ "build:types": "tsc -p tsconfig.prod.json"
51
50
  }
52
- }
51
+ }