@servicetitan/dte-unlayer 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ import { CSSProperties } from 'react';
2
+ import { UnlayerToolsInfo } from './store';
3
+ import { UnlayerRef, CreateUnlayerEditorProps } from './unlayer-interface';
4
+ interface UnlayerEditorProps {
5
+ id?: string;
6
+ design: any;
7
+ opts: CreateUnlayerEditorProps;
8
+ minHeight?: number;
9
+ style?: CSSProperties;
10
+ onReady?(): void;
11
+ onChange?(info: UnlayerToolsInfo): void;
12
+ onImage?(file: any): Promise<{
13
+ url: string;
14
+ }>;
15
+ onMessage?(type: string, data: any): void;
16
+ }
17
+ export declare const useUnlayerRef: () => import("react").MutableRefObject<UnlayerRef | null>;
18
+ export declare const UnlayerEditor: import("react").ForwardRefExoticComponent<UnlayerEditorProps & import("react").RefAttributes<UnlayerRef>>;
19
+ export {};
20
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAOhB,MAAM,OAAO,CAAC;AACf,OAAO,EAAgB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,UAAU,kBAAkB;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,wBAAwB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,QAAQ,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACxC,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,aAAa,2DAAwC,CAAC;AAEnE,eAAO,MAAM,aAAa,2GA4DxB,CAAC"}
package/dist/editor.js ADDED
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
3
+ import { UnlayerStore } from './store';
4
+ export const useUnlayerRef = () => useRef(null);
5
+ export const UnlayerEditor = forwardRef((props, ref) => {
6
+ var _a;
7
+ const [status, setStatus] = useState(0);
8
+ const containerRef = useRef(null);
9
+ const store = useMemo(() => new UnlayerStore(props.opts),
10
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11
+ []);
12
+ const isReady = status === 2;
13
+ useEffect(() => {
14
+ if (containerRef.current) {
15
+ store
16
+ .init(containerRef.current)
17
+ .then(() => setStatus(2))
18
+ .catch(() => setStatus(1));
19
+ }
20
+ return () => store.destroy();
21
+ }, [store]);
22
+ useImperativeHandle(ref, () => store.unlayerRef, [store]);
23
+ useEffect(() => {
24
+ if (isReady && props.design) {
25
+ store.setDesign(props.design);
26
+ }
27
+ }, [isReady, props.design, store]);
28
+ useEffect(() => {
29
+ store.setOnChange(props.onChange);
30
+ return () => store.setOnChange();
31
+ }, [props.onChange, store]);
32
+ useEffect(() => {
33
+ store.setOnReady(props.onReady);
34
+ return () => store.setOnReady();
35
+ }, [props.onReady, store]);
36
+ useEffect(() => {
37
+ store.setOnImage(props.onImage);
38
+ return () => store.setOnImage();
39
+ }, [props.onImage, store]);
40
+ useEffect(() => {
41
+ store.setOnMessage(props.onMessage);
42
+ return () => store.setOnMessage();
43
+ }, [props.onMessage, store]);
44
+ const { minHeight = 800, style = {} } = props;
45
+ return (_jsxs("div", Object.assign({ style: { minHeight, display: 'flex' } }, { children: [status === 1 && _jsx("p", Object.assign({ className: "c-red-500" }, { children: "error loading editor" })), _jsx("div", { id: (_a = props.id) !== null && _a !== void 0 ? _a : 'editor', style: style, ref: containerRef })] })));
46
+ });
47
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEH,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,QAAQ,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAoB,MAAM,SAAS,CAAC;AAezD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,MAAM,CAAoB,IAAI,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAiC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;;IACnF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CACjB,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;IAClC,uDAAuD;IACvD,EAAE,CACL,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,YAAY,CAAC,OAAO,EAAE;YACtB,KAAK;iBACA,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;iBAC1B,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;iBACxB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;QAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACjC,CA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SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7B,MAAM,EAAE,SAAS,GAAG,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IAE9C,OAAO,CACH,6BAAK,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,iBACrC,MAAM,KAAK,CAAC,IAAI,0BAAG,SAAS,EAAC,WAAW,0CAAyB,EAClE,cAAK,EAAE,EAAE,MAAA,KAAK,CAAC,EAAE,mCAAI,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,GAAI,KAChE,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './editor';
2
+ export * from './tools';
3
+ export * from './unlayer-interface';
4
+ export * from './loadScript';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './editor';
2
+ export * from './tools';
3
+ export * from './unlayer-interface';
4
+ export * from './loadScript';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const loadScript: (scriptUrl: string) => Promise<void>;
2
+ //# sourceMappingURL=loadScript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadScript.d.ts","sourceRoot":"","sources":["../src/loadScript.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,UAAU,cAAe,MAAM,KAAG,QAAQ,IAAI,CAa1D,CAAC"}
@@ -0,0 +1,24 @@
1
+ const isScriptInjected = (scriptUrl) => {
2
+ const scripts = document.querySelectorAll('script');
3
+ let injected = false;
4
+ scripts.forEach(script => {
5
+ if (script.src.includes(scriptUrl)) {
6
+ injected = true;
7
+ }
8
+ });
9
+ return injected;
10
+ };
11
+ export const loadScript = (scriptUrl) => {
12
+ return new Promise(resolve => {
13
+ if (isScriptInjected(scriptUrl)) {
14
+ resolve();
15
+ }
16
+ const embedScript = document.createElement('script');
17
+ embedScript.setAttribute('src', scriptUrl);
18
+ embedScript.onload = () => {
19
+ resolve();
20
+ };
21
+ document.head.appendChild(embedScript);
22
+ });
23
+ };
24
+ //# sourceMappingURL=loadScript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadScript.js","sourceRoot":"","sources":["../src/loadScript.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpD,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACrB,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAChC,QAAQ,GAAG,IAAI,CAAC;SACnB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAiB,EAAiB,EAAE;IAC3D,OAAO,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;QAC/B,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,EAAE,CAAC;SACb;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACrD,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,WAAW,CAAC,MAAM,GAAG,GAAG,EAAE;YACtB,OAAO,EAAE,CAAC;QACd,CAAC,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { CreateUnlayerEditorProps, UnlayerDesignFormat, UnlayerRef } from './unlayer-interface';
2
+ export interface UnlayerToolsInfo {
3
+ notSupported: string[];
4
+ required: string[];
5
+ }
6
+ export declare class UnlayerStore {
7
+ readonly props: CreateUnlayerEditorProps;
8
+ readonly unlayerRef: UnlayerRef;
9
+ private editor;
10
+ private isInit;
11
+ private iframe?;
12
+ private onMessageCB?;
13
+ private onChangeCB?;
14
+ private onReadyCB?;
15
+ private onImageCB?;
16
+ private currentComponents;
17
+ constructor(props: CreateUnlayerEditorProps);
18
+ init: (container: HTMLDivElement) => Promise<void>;
19
+ destroy: () => void;
20
+ setDesign: (design: UnlayerDesignFormat) => void;
21
+ setOnChange: (onChange?: ((info: UnlayerToolsInfo) => void) | undefined) => void;
22
+ setOnReady: (onReady?: ((info: UnlayerToolsInfo) => void) | undefined) => void;
23
+ setOnImage: (onImage?: UnlayerStore['onImageCB']) => void;
24
+ setOnMessage: (onMessage?: UnlayerStore['onMessageCB']) => void;
25
+ private onDesignLoaded;
26
+ private onDesignUpdated;
27
+ private onPostMessage;
28
+ private sendMessage;
29
+ private getToolsInfo;
30
+ private uploadImage;
31
+ }
32
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIhG,MAAM,WAAW,gBAAgB;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,qBAAa,YAAY;IAcT,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAbpD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAC,CAAoB;IAEnC,OAAO,CAAC,WAAW,CAAC,CAAoC;IACxD,OAAO,CAAC,UAAU,CAAC,CAAmC;IACtD,OAAO,CAAC,SAAS,CAAC,CAAmC;IACrD,OAAO,CAAC,SAAS,CAAC,CAA0C;IAE5D,OAAO,CAAC,iBAAiB,CAA8B;gBAElC,KAAK,EAAE,wBAAwB;IA+BpD,IAAI,cAAqB,cAAc,mBAiBrC;IAEF,OAAO,aAUL;IAEF,SAAS,WAAY,mBAAmB,UAetC;IAEF,WAAW,sBAAsB,gBAAgB,KAAK,IAAI,uBAExD;IAEF,UAAU,qBAAqB,gBAAgB,KAAK,IAAI,uBAEtD;IAEF,UAAU,aAAc,YAAY,CAAC,WAAW,CAAC,UAE/C;IAEF,YAAY,eAAgB,YAAY,CAAC,aAAa,CAAC,UAErD;IAEF,OAAO,CAAC,cAAc,CAKpB;IAEF,OAAO,CAAC,eAAe,CAwBrB;IAEF,OAAO,CAAC,aAAa,CAyBnB;IAEF,OAAO,CAAC,WAAW,CAUjB;IAEF,OAAO,CAAC,YAAY,CASlB;IAEF,OAAO,CAAC,WAAW,CAMjB;CACL"}
package/dist/store.js ADDED
@@ -0,0 +1,291 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { loadScript } from './loadScript';
11
+ import { unlayerIterateCustomTools } from './tools';
12
+ import { createUnlayerEditor, DesignUpdatedEventType, } from './unlayer';
13
+ const defaultScriptUrl = 'https://editor.unlayer.com/embed.js?2';
14
+ export class UnlayerStore {
15
+ constructor(props) {
16
+ Object.defineProperty(this, "props", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: props
21
+ });
22
+ Object.defineProperty(this, "unlayerRef", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ Object.defineProperty(this, "editor", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "isInit", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: false
39
+ });
40
+ Object.defineProperty(this, "iframe", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: void 0
45
+ });
46
+ Object.defineProperty(this, "onMessageCB", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "onChangeCB", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ Object.defineProperty(this, "onReadyCB", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "onImageCB", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: void 0
69
+ });
70
+ Object.defineProperty(this, "currentComponents", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: {}
75
+ });
76
+ Object.defineProperty(this, "init", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: (container) => __awaiter(this, void 0, void 0, function* () {
81
+ var _a;
82
+ if (this.isInit) {
83
+ return;
84
+ }
85
+ this.isInit = true;
86
+ window.addEventListener('message', this.onPostMessage);
87
+ yield loadScript(defaultScriptUrl);
88
+ this.editor = createUnlayerEditor(container, this.props);
89
+ this.editor.addEventListener('design:loaded', this.onDesignLoaded);
90
+ this.editor.addEventListener('design:updated', this.onDesignUpdated);
91
+ this.editor.registerCallback('image', this.uploadImage);
92
+ this.iframe = (_a = container.querySelector(`iframe`)) !== null && _a !== void 0 ? _a : undefined;
93
+ })
94
+ });
95
+ Object.defineProperty(this, "destroy", {
96
+ enumerable: true,
97
+ configurable: true,
98
+ writable: true,
99
+ value: () => {
100
+ window.removeEventListener('message', this.onPostMessage);
101
+ if (this.editor) {
102
+ this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
103
+ this.editor.removeEventListener('design:updated', this.onDesignUpdated);
104
+ this.editor.unregisterCallback('image', this.uploadImage);
105
+ this.editor = undefined;
106
+ }
107
+ }
108
+ });
109
+ Object.defineProperty(this, "setDesign", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: (design) => {
114
+ if (!this.editor) {
115
+ return;
116
+ }
117
+ this.currentComponents = {};
118
+ unlayerIterateCustomTools(design, tool => {
119
+ if (!this.currentComponents[tool.slug]) {
120
+ this.currentComponents[tool.slug] = 0;
121
+ }
122
+ this.currentComponents[tool.slug]++;
123
+ });
124
+ this.editor.loadDesign(design);
125
+ }
126
+ });
127
+ Object.defineProperty(this, "setOnChange", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: (onChange) => {
132
+ this.onChangeCB = onChange;
133
+ }
134
+ });
135
+ Object.defineProperty(this, "setOnReady", {
136
+ enumerable: true,
137
+ configurable: true,
138
+ writable: true,
139
+ value: (onReady) => {
140
+ this.onReadyCB = onReady;
141
+ }
142
+ });
143
+ Object.defineProperty(this, "setOnImage", {
144
+ enumerable: true,
145
+ configurable: true,
146
+ writable: true,
147
+ value: (onImage) => {
148
+ this.onImageCB = onImage;
149
+ }
150
+ });
151
+ Object.defineProperty(this, "setOnMessage", {
152
+ enumerable: true,
153
+ configurable: true,
154
+ writable: true,
155
+ value: (onMessage) => {
156
+ this.onMessageCB = onMessage;
157
+ }
158
+ });
159
+ Object.defineProperty(this, "onDesignLoaded", {
160
+ enumerable: true,
161
+ configurable: true,
162
+ writable: true,
163
+ value: () => {
164
+ var _a;
165
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.setBodyValues({
166
+ backgroundColor: 'rgba(0,0,0,0)',
167
+ contentWidth: '100%',
168
+ });
169
+ }
170
+ });
171
+ Object.defineProperty(this, "onDesignUpdated", {
172
+ enumerable: true,
173
+ configurable: true,
174
+ writable: true,
175
+ value: (data) => {
176
+ var _a;
177
+ if (data.type === DesignUpdatedEventType.ContentRemoved) {
178
+ const tool = data.item.type === 'custom' ? data.item.slug : undefined;
179
+ if (tool && this.currentComponents[tool]) {
180
+ this.currentComponents[tool]--;
181
+ if (!this.currentComponents[tool]) {
182
+ delete this.currentComponents[tool];
183
+ }
184
+ }
185
+ }
186
+ else if (data.type === DesignUpdatedEventType.ContentAdded) {
187
+ const tool = data.item.type === 'custom' ? data.item.slug : undefined;
188
+ if (tool && this.currentComponents[tool]) {
189
+ if (!this.currentComponents[tool]) {
190
+ this.currentComponents[tool] = 0;
191
+ }
192
+ this.currentComponents[tool]++;
193
+ }
194
+ }
195
+ (_a = this.onChangeCB) === null || _a === void 0 ? void 0 : _a.call(this, this.getToolsInfo());
196
+ }
197
+ });
198
+ Object.defineProperty(this, "onPostMessage", {
199
+ enumerable: true,
200
+ configurable: true,
201
+ writable: true,
202
+ value: (e) => {
203
+ var _a, _b, _c, _d, _e, _f, _g, _h;
204
+ if (!((_a = e.data) === null || _a === void 0 ? void 0 : _a['-dte-message-from'])) {
205
+ return;
206
+ }
207
+ const type = (_c = (_b = e.data) === null || _b === void 0 ? void 0 : _b['-dte-message-from']) === null || _c === void 0 ? void 0 : _c.type;
208
+ const data = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d['-dte-message-from']) === null || _e === void 0 ? void 0 : _e.data;
209
+ if (!type) {
210
+ return;
211
+ }
212
+ if (type === 'ready') {
213
+ (_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this, this.getToolsInfo());
214
+ this.sendMessage('--config', JSON.parse(JSON.stringify({
215
+ altTools: (_g = this.props.altTools) !== null && _g !== void 0 ? _g : [],
216
+ })));
217
+ }
218
+ (_h = this.onMessageCB) === null || _h === void 0 ? void 0 : _h.call(this, type, data);
219
+ }
220
+ });
221
+ Object.defineProperty(this, "sendMessage", {
222
+ enumerable: true,
223
+ configurable: true,
224
+ writable: true,
225
+ value: (type, data) => {
226
+ var _a, _b;
227
+ (_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({
228
+ '-dte-message-to': {
229
+ type,
230
+ data,
231
+ },
232
+ }, '*');
233
+ }
234
+ });
235
+ Object.defineProperty(this, "getToolsInfo", {
236
+ enumerable: true,
237
+ configurable: true,
238
+ writable: true,
239
+ value: () => {
240
+ return {
241
+ notSupported: Object.keys(this.currentComponents).filter(key => !this.props.tools.some(tool => tool.key === key)),
242
+ required: this.props.tools
243
+ .filter(tool => tool.isRequired && !this.currentComponents[tool.key])
244
+ .map(tool => tool.key),
245
+ };
246
+ }
247
+ });
248
+ Object.defineProperty(this, "uploadImage", {
249
+ enumerable: true,
250
+ configurable: true,
251
+ writable: true,
252
+ value: (file, done) => {
253
+ if (!this.onImageCB) {
254
+ throw new Error('image upload is not implemented');
255
+ }
256
+ this.onImageCB(file).then(({ url }) => done({ progress: 100, url }));
257
+ }
258
+ });
259
+ this.unlayerRef = {
260
+ loadDesign: design => {
261
+ var _a;
262
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.loadDesign(design);
263
+ },
264
+ saveDesign: cb => {
265
+ var _a;
266
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.saveDesign(cb);
267
+ },
268
+ exportHtml: cb => {
269
+ var _a;
270
+ (_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
271
+ var _a, _b;
272
+ if ((_a = this.props.altTools) === null || _a === void 0 ? void 0 : _a.length) {
273
+ unlayerIterateCustomTools(data.design, tool => {
274
+ if (tool.slug.includes(':')) {
275
+ tool.slug = tool.slug.split(':')[0];
276
+ }
277
+ });
278
+ for (const key of Object.keys((_b = data.design.counters) !== null && _b !== void 0 ? _b : {})) {
279
+ if (key.startsWith('u_content_custom_') && key.includes(':')) {
280
+ data.design.counters[key.split(':')[0]] = data.design.counters[key];
281
+ delete data.design.counters[key];
282
+ }
283
+ }
284
+ }
285
+ cb(data);
286
+ });
287
+ },
288
+ };
289
+ }
290
+ }
291
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACH,mBAAmB,EACnB,sBAAsB,GAGzB,MAAM,WAAW,CAAC;AAGnB,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AAOjE,MAAM,OAAO,YAAY;IAcrB,YAAqB,KAA+B;;;;;mBAA/B;;QAbrB;;;;;WAAgC;QAEhC;;;;;WAAoC;QACpC;;;;mBAAiB,KAAK;WAAC;QACvB;;;;;WAAmC;QAEnC;;;;;WAAwD;QACxD;;;;;WAAsD;QACtD;;;;;WAAqD;QACrD;;;;;WAA4D;QAE5D;;;;mBAAoD,EAAE;WAAC;QAiCvD;;;;mBAAO,CAAO,SAAyB,EAAE,EAAE;;gBACvC,IAAI,IAAI,CAAC,MAAM,EAAE;oBACb,OAAO;iBACV;gBAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBAEnB,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,C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AAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gCACpE,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;6BACpC;yBACJ;qBACJ;oBAED,EAAE,CAAC,IAAI,CAAC,CAAC;gBACb,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;CA4JJ"}
@@ -0,0 +1,6 @@
1
+ import { UnlayerDesignFormat, UnlayerDesignTool } from './unlayer-interface';
2
+ export declare const unlayerIterateTools: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | undefined | void) => void;
3
+ export declare const unlayerIterateCustomTools: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | undefined | void) => void;
4
+ export declare const unlayerGetAllCustomTools: (design: UnlayerDesignFormat) => string[];
5
+ export declare const unlayerFindTool: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | void) => UnlayerDesignTool | undefined;
6
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,eAAO,MAAM,mBAAmB,WACpB,mBAAmB,aAChB,iBAAiB,KAAK,OAAO,GAAG,SAAS,GAAG,IAAI,SAW9D,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAC1B,mBAAmB,aAChB,iBAAiB,KAAK,OAAO,GAAG,SAAS,GAAG,IAAI,SAO9D,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAAY,mBAAmB,KAAG,MAAM,EAQ5E,CAAC;AAEF,eAAO,MAAM,eAAe,WAChB,mBAAmB,aAChB,iBAAiB,KAAK,OAAO,GAAG,IAAI,KAChD,iBAAiB,GAAG,SAWtB,CAAC"}
package/dist/tools.js ADDED
@@ -0,0 +1,37 @@
1
+ export const unlayerIterateTools = (design, cb) => {
2
+ var _a, _b;
3
+ for (const row of (_b = (_a = design === null || design === void 0 ? void 0 : design.body) === null || _a === void 0 ? void 0 : _a.rows) !== null && _b !== void 0 ? _b : []) {
4
+ for (const column of row.columns) {
5
+ for (const content of column.contents) {
6
+ if (cb(content) === false) {
7
+ return;
8
+ }
9
+ }
10
+ }
11
+ }
12
+ };
13
+ export const unlayerIterateCustomTools = (design, cb) => {
14
+ unlayerIterateTools(design, tool => {
15
+ if (tool.type === 'custom') {
16
+ return cb(tool);
17
+ }
18
+ });
19
+ };
20
+ export const unlayerGetAllCustomTools = (design) => {
21
+ const allTools = new Set();
22
+ unlayerIterateCustomTools(design, tool => {
23
+ allTools.add(tool.slug);
24
+ });
25
+ return Array.from(allTools);
26
+ };
27
+ export const unlayerFindTool = (design, cb) => {
28
+ let out;
29
+ unlayerIterateTools(design, tool => {
30
+ if (cb(tool)) {
31
+ out = tool;
32
+ return false;
33
+ }
34
+ });
35
+ return out;
36
+ };
37
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAC/B,MAA2B,EAC3B,EAA2D,EAC7D,EAAE;;IACA,KAAK,MAAM,GAAG,IAAI,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,IAAI,mCAAI,EAAE,EAAE;QACxC,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE;YAC9B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE;gBACnC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,EAAE;oBACvB,OAAO;iBACV;aACJ;SACJ;KACJ;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACrC,MAA2B,EAC3B,EAA2D,EAC7D,EAAE;IACA,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;YACxB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;SACnB;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAA2B,EAAY,EAAE;IAC9E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QACrC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,MAA2B,EAC3B,EAA+C,EAClB,EAAE;IAC/B,IAAI,GAAkC,CAAC;IAEvC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC/B,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE;YACV,GAAG,GAAG,IAAI,CAAC;YACX,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ export interface UnlayerDesignTool {
2
+ type: string;
3
+ slug: string;
4
+ values: any;
5
+ }
6
+ export interface UnlayerEditorToolInfo {
7
+ key: string;
8
+ path: string;
9
+ isRequired?: boolean;
10
+ }
11
+ export interface UnlayerDesignFormat {
12
+ body: {
13
+ rows: {
14
+ cells: number[];
15
+ columns: {
16
+ contents: UnlayerDesignTool[];
17
+ }[];
18
+ }[];
19
+ };
20
+ counters: Record<string, number>;
21
+ schemaVersion: number;
22
+ }
23
+ export interface UnlayerExport {
24
+ html: string;
25
+ chunks: any;
26
+ design: UnlayerDesignFormat;
27
+ }
28
+ export interface UnlayerRef {
29
+ loadDesign(design: any): void;
30
+ saveDesign(cb: (design: any) => void): void;
31
+ exportHtml(cb: (data: UnlayerExport) => void): void;
32
+ }
33
+ export interface UnlayerAltTool {
34
+ id: string;
35
+ tool: string;
36
+ label: string;
37
+ values: any;
38
+ }
39
+ export interface UnlayerEditorMergeTagInfo {
40
+ id: string;
41
+ name: string;
42
+ propertyPath: string;
43
+ }
44
+ export interface CreateUnlayerEditorProps {
45
+ packageUrl: string;
46
+ tools: UnlayerEditorToolInfo[];
47
+ altTools?: UnlayerAltTool[];
48
+ customCSS?: string;
49
+ customJS?: string | string[] | undefined;
50
+ mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;
51
+ noCoreTools?: boolean;
52
+ latest?: boolean;
53
+ blocks?: boolean;
54
+ }
55
+ //# sourceMappingURL=unlayer-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlayer-interface.d.ts","sourceRoot":"","sources":["../src/unlayer-interface.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE;QACF,IAAI,EAAE;YACF,KAAK,EAAE,MAAM,EAAE,CAAC;YAChB,OAAO,EAAE;gBACL,QAAQ,EAAE,iBAAiB,EAAE,CAAC;aACjC,EAAE,CAAC;SACP,EAAE,CAAC;KACP,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACvB,UAAU,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5C,UAAU,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,yBAAyB,EAAE,GAAG,SAAS,CAAC;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unlayer-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlayer-interface.js","sourceRoot":"","sources":["../src/unlayer-interface.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ import { CreateUnlayerEditorProps } from './unlayer-interface';
2
+ export interface UnlayerExport {
3
+ html: string;
4
+ chunks: any;
5
+ design: any;
6
+ }
7
+ export interface Unlayer {
8
+ addEventListener(event: string, cb: (arg: any) => void): void;
9
+ removeEventListener(event: string, cb: (arg: any) => void): void;
10
+ registerCallback(type: string, cb: (...args: any[]) => void): void;
11
+ unregisterCallback(type: string, cb: (...args: any[]) => void): void;
12
+ registerProvider(type: string, cb: (...args: any[]) => void): void;
13
+ unregisterProvider(type: string, cb: (...args: any[]) => void): void;
14
+ loadDesign(design: any): void;
15
+ saveDesign(callback: (design: any) => void): void;
16
+ exportHtml(callback: (data: UnlayerExport) => void): void;
17
+ setMergeTags(tags: any): void;
18
+ createViewer(opts: {
19
+ render: (values: any) => string;
20
+ }): any;
21
+ registerTool(tool: any): void;
22
+ setBodyValues(values: any): void;
23
+ }
24
+ export declare enum DesignUpdatedEventType {
25
+ ContentRemoved = "content:removed",
26
+ ContentAdded = "content:added"
27
+ }
28
+ export interface EventDesignUpdated {
29
+ type: DesignUpdatedEventType;
30
+ item: {
31
+ type: string;
32
+ slug?: string;
33
+ };
34
+ }
35
+ export interface UnlayerEditorMergeTagInfo {
36
+ id: string;
37
+ name: string;
38
+ propertyPath: string;
39
+ }
40
+ export declare const createUnlayerEditor: (container: HTMLDivElement, { customCSS, customJS, latest, mergeTags, noCoreTools, packageUrl, tools, }: CreateUnlayerEditorProps) => Unlayer;
41
+ //# sourceMappingURL=unlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unlayer.d.ts","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACpB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CA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