@servicetitan/dte-unlayer 0.0.1-test1
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/api-core.d.ts +19 -0
- package/dist/api-core.d.ts.map +1 -0
- package/dist/api-core.js +121 -0
- package/dist/api-core.js.map +1 -0
- package/dist/api-custom-tools.d.ts +18 -0
- package/dist/api-custom-tools.d.ts.map +1 -0
- package/dist/api-custom-tools.js +96 -0
- package/dist/api-custom-tools.js.map +1 -0
- package/dist/editor.d.ts +19 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +47 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/loadScript.d.ts +2 -0
- package/dist/loadScript.d.ts.map +1 -0
- package/dist/loadScript.js +24 -0
- package/dist/loadScript.js.map +1 -0
- package/dist/shared/const.d.ts +27 -0
- package/dist/shared/const.d.ts.map +1 -0
- package/dist/shared/const.js +6 -0
- package/dist/shared/const.js.map +1 -0
- package/dist/shared/fonts.d.ts +10 -0
- package/dist/shared/fonts.d.ts.map +1 -0
- package/dist/shared/fonts.js +127 -0
- package/dist/shared/fonts.js.map +1 -0
- package/dist/shared/schema.d.ts +51 -0
- package/dist/shared/schema.d.ts.map +1 -0
- package/dist/shared/schema.js +104 -0
- package/dist/shared/schema.js.map +1 -0
- package/dist/shared/tools.d.ts +14 -0
- package/dist/shared/tools.d.ts.map +1 -0
- package/dist/shared/tools.js +8 -0
- package/dist/shared/tools.js.map +1 -0
- package/dist/store.d.ts +31 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +274 -0
- package/dist/store.js.map +1 -0
- package/dist/tools.d.ts +26 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +164 -0
- package/dist/tools.js.map +1 -0
- package/dist/unlayer-interface.d.ts +64 -0
- package/dist/unlayer-interface.d.ts.map +1 -0
- package/dist/unlayer-interface.js +2 -0
- package/dist/unlayer-interface.js.map +1 -0
- package/dist/unlayer.d.ts +57 -0
- package/dist/unlayer.d.ts.map +1 -0
- package/dist/unlayer.js +117 -0
- package/dist/unlayer.js.map +1 -0
- package/package.json +20 -0
- package/src/__tests__/schema.test.ts +96 -0
- package/src/api-core.ts +94 -0
- package/src/api-custom-tools.ts +79 -0
- package/src/editor.tsx +87 -0
- package/src/index.ts +11 -0
- package/src/loadScript.ts +27 -0
- package/src/shared/const.ts +30 -0
- package/src/shared/fonts.ts +126 -0
- package/src/shared/schema.ts +190 -0
- package/src/shared/tools.ts +18 -0
- package/src/store.ts +197 -0
- package/src/tools.ts +213 -0
- package/src/unlayer-interface.tsx +71 -0
- package/src/unlayer.tsx +176 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type SchemaNodeAvailableTypes = 'object' | 'array' | 'string';
|
|
2
|
+
export declare const schemaNodeAvailableTypes: string[];
|
|
3
|
+
export type SchemaNodeStringSubTypes = 'string' | 'text' | 'html';
|
|
4
|
+
export declare const schemaNodeStringSubTypes: string[];
|
|
5
|
+
export declare const schemaIsAvailableType: (type: string) => type is SchemaNodeAvailableTypes;
|
|
6
|
+
export interface SchemaFieldBaseOptions {
|
|
7
|
+
placeholder?: any;
|
|
8
|
+
}
|
|
9
|
+
interface SchemaNodeProps {
|
|
10
|
+
title?: string;
|
|
11
|
+
options?: SchemaFieldBaseOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface SchemaObject extends SchemaNodeProps {
|
|
14
|
+
type: 'object';
|
|
15
|
+
properties: Record<string, SchemaNode>;
|
|
16
|
+
}
|
|
17
|
+
export interface SchemaArray extends SchemaNodeProps {
|
|
18
|
+
type: 'array';
|
|
19
|
+
items: SchemaNode;
|
|
20
|
+
}
|
|
21
|
+
export interface SchemaSimpleString extends SchemaNodeProps {
|
|
22
|
+
type: 'string';
|
|
23
|
+
subType?: SchemaNodeStringSubTypes;
|
|
24
|
+
}
|
|
25
|
+
export type SchemaSimple = SchemaSimpleString;
|
|
26
|
+
export declare const schemaArrayRootKey = "[]";
|
|
27
|
+
export type SchemaNode = SchemaObject | SchemaArray | SchemaSimple;
|
|
28
|
+
export declare const schemaIsObject: (node?: SchemaNode) => node is SchemaObject;
|
|
29
|
+
export declare const schemaIsArray: (node?: SchemaNode) => node is SchemaArray;
|
|
30
|
+
export declare const schemaIsString: (node?: SchemaNode) => node is SchemaSimpleString;
|
|
31
|
+
export declare const schemaIsStringHtml: (node?: SchemaNode) => node is SchemaSimpleString;
|
|
32
|
+
export declare const schemaFindNode: (schema: SchemaNode, key: string) => SchemaNode | undefined;
|
|
33
|
+
export declare const schemaFindParentNode: (schema: SchemaNode, key: string) => SchemaNode | undefined;
|
|
34
|
+
export declare const schemaGetFieldKey: (fullKey: string) => string;
|
|
35
|
+
export declare const schemaBuildNode: (type: SchemaNodeAvailableTypes, arrayItemType?: SchemaNodeAvailableTypes) => SchemaNode;
|
|
36
|
+
export interface SchemaMetaField {
|
|
37
|
+
fieldKey: string;
|
|
38
|
+
fullKey: string;
|
|
39
|
+
node: SchemaNode;
|
|
40
|
+
title: string;
|
|
41
|
+
fullTitle: string;
|
|
42
|
+
isArrayed: boolean;
|
|
43
|
+
isValue: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type SchemaMap = Record<string, SchemaMetaField>;
|
|
46
|
+
export declare const schemaBuildMap: (schema: SchemaObject) => {
|
|
47
|
+
map: SchemaMap;
|
|
48
|
+
dummyData: any;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/shared/schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AACrE,eAAO,MAAM,wBAAwB,UAAgC,CAAC;AAEtE,MAAM,MAAM,wB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F,eAAO,MAAM,eAAe,SAClB,wBAAwB,kBACd,wBAAwB,KACzC,UASF,CAAC;AAEF,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,cAAc,WAAY,YAAY;SAAU,SAAS;eAAa,GAAG;CA8ErF,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export const schemaNodeAvailableTypes = ['object', 'array', 'string'];
|
|
2
|
+
export const schemaNodeStringSubTypes = ['string', 'text', 'html'];
|
|
3
|
+
export const schemaIsAvailableType = (type) => schemaNodeAvailableTypes.includes(type);
|
|
4
|
+
export const schemaArrayRootKey = '[]';
|
|
5
|
+
export const schemaIsObject = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'object';
|
|
6
|
+
export const schemaIsArray = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'array';
|
|
7
|
+
export const schemaIsString = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'string';
|
|
8
|
+
export const schemaIsStringHtml = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'string' && (node === null || node === void 0 ? void 0 : node.subType) === 'html';
|
|
9
|
+
export const schemaFindNode = (schema, key) => {
|
|
10
|
+
const nodeFinder = (node, keys) => {
|
|
11
|
+
if (!node) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
if (!keys.length) {
|
|
15
|
+
return node;
|
|
16
|
+
}
|
|
17
|
+
const key = keys.shift();
|
|
18
|
+
if (!key) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (key === schemaArrayRootKey) {
|
|
22
|
+
return schemaIsArray(node) ? nodeFinder(node.items, keys) : undefined;
|
|
23
|
+
}
|
|
24
|
+
return schemaIsObject(node) ? nodeFinder(node.properties[key], keys) : undefined;
|
|
25
|
+
};
|
|
26
|
+
return nodeFinder(schema, key.split('.'));
|
|
27
|
+
};
|
|
28
|
+
export const schemaFindParentNode = (schema, key) => {
|
|
29
|
+
const keys = key.split('.');
|
|
30
|
+
keys.pop();
|
|
31
|
+
return keys.length
|
|
32
|
+
? schemaFindNode(schema, keys.join('.'))
|
|
33
|
+
: schemaIsObject(schema) && schema.properties[key]
|
|
34
|
+
? schema
|
|
35
|
+
: undefined;
|
|
36
|
+
};
|
|
37
|
+
export const schemaGetFieldKey = (fullKey) => { var _a; return (_a = fullKey.split('.').pop()) !== null && _a !== void 0 ? _a : ''; };
|
|
38
|
+
export const schemaBuildNode = (type, arrayItemType) => {
|
|
39
|
+
if (type === 'object') {
|
|
40
|
+
return { type: 'object', properties: {}, options: {} };
|
|
41
|
+
}
|
|
42
|
+
if (type === 'array') {
|
|
43
|
+
return { type: 'array', items: schemaBuildNode(arrayItemType !== null && arrayItemType !== void 0 ? arrayItemType : 'object'), options: {} };
|
|
44
|
+
}
|
|
45
|
+
return { type, options: {} };
|
|
46
|
+
};
|
|
47
|
+
export const schemaBuildMap = (schema) => {
|
|
48
|
+
const fieldsMap = {};
|
|
49
|
+
const dummyData = {};
|
|
50
|
+
const processNode = (node, nodeKey, parentNodes, isArrayed, dummyDataNode) => {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
52
|
+
const nodeLabel = (_a = node.title) !== null && _a !== void 0 ? _a : nodeKey;
|
|
53
|
+
const isArrayRoot = nodeKey === schemaArrayRootKey;
|
|
54
|
+
if (nodeKey) {
|
|
55
|
+
const fullKey = [...parentNodes.map(n => n.key), nodeKey].join('.');
|
|
56
|
+
const fullTitle = [...parentNodes.map(n => n.title), nodeLabel].join(' - ');
|
|
57
|
+
fieldsMap[fullKey] = {
|
|
58
|
+
fieldKey: nodeKey,
|
|
59
|
+
fullKey,
|
|
60
|
+
fullTitle,
|
|
61
|
+
title: (_b = node.title) !== null && _b !== void 0 ? _b : fullTitle,
|
|
62
|
+
node,
|
|
63
|
+
isArrayed,
|
|
64
|
+
isValue: !schemaIsObject(node) && !schemaIsArray(node),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (schemaIsObject(node)) {
|
|
68
|
+
const properties = (_c = node.properties) !== null && _c !== void 0 ? _c : {};
|
|
69
|
+
const keys = Object.keys(properties !== null && properties !== void 0 ? properties : {}).sort();
|
|
70
|
+
let dummyDataObject = {};
|
|
71
|
+
if (isArrayRoot) {
|
|
72
|
+
(_d = dummyDataNode.push) === null || _d === void 0 ? void 0 : _d.call(dummyDataNode, dummyDataObject);
|
|
73
|
+
}
|
|
74
|
+
else if (nodeKey) {
|
|
75
|
+
dummyDataNode[nodeKey] = dummyDataObject;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
dummyDataObject = dummyDataNode;
|
|
79
|
+
}
|
|
80
|
+
for (const key of keys) {
|
|
81
|
+
processNode(properties[key], key, nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [], isArrayed, dummyDataObject);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (schemaIsArray(node)) {
|
|
85
|
+
const items = (_e = node.items) !== null && _e !== void 0 ? _e : {};
|
|
86
|
+
dummyDataNode[nodeKey] = [];
|
|
87
|
+
processNode(items, schemaArrayRootKey, nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [], true, dummyDataNode[nodeKey]);
|
|
88
|
+
}
|
|
89
|
+
else if (nodeKey) {
|
|
90
|
+
const placeholder = (_f = node === null || node === void 0 ? void 0 : node.options) === null || _f === void 0 ? void 0 : _f.placeholder;
|
|
91
|
+
if (placeholder !== undefined) {
|
|
92
|
+
if (isArrayRoot) {
|
|
93
|
+
(_g = dummyDataNode.push) === null || _g === void 0 ? void 0 : _g.call(dummyDataNode, placeholder);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
dummyDataNode[nodeKey] = placeholder;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
processNode(schema, '', [], false, dummyData);
|
|
102
|
+
return { map: fieldsMap, dummyData };
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/shared/schema.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAGtE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAoC,EAAE,CACpF,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AA4B5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAGvC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAiB,EAAwB,EAAE,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,QAAQ,CAAC;AACnG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAiB,EAAuB,EAAE,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,OAAO,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAiB,EAA8B,EAAE,CAC5E,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAiB,EAA8B,EAAE,CAChF,CAAA,IAAI,aAAJ,IA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E,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EACnE,SAAS,EACT,eAAe,CAClB,CAAC;aACL;SACJ;aAAM,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;YAC5B,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC;YAE/B,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAC5B,WAAW,CACP,KAAK,EACL,kBAAkB,EAClB,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EACnE,IAAI,EACJ,aAAa,CAAC,OAAO,CAAC,CACzB,CAAC;SACL;aAAM,IAAI,OAAO,EAAE;YAChB,MAAM,WAAW,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,0CAAE,WAAW,CAAC;YAE/C,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC3B,IAAI,WAAW,EAAE;oBACb,MAAA,aAAa,CAAC,IAAI,8DAAG,WAAW,CAAC,CAAC;iBACrC;qBAAM;oBACH,aAAa,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC;iBACxC;aACJ;SACJ;IACL,CAAC,CAAC;IAEF,WAAW,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAE9C,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const unlayerUnitsGenerateToolKey: (unitId: string, unitGeneric: string) => string;
|
|
2
|
+
export declare const unlayerUnitsParseToolKey: (toolKey: string) => {
|
|
3
|
+
id: string;
|
|
4
|
+
generic: string;
|
|
5
|
+
} | undefined;
|
|
6
|
+
export interface UnlayerStore {
|
|
7
|
+
renderHtml(html: string, data: any): string;
|
|
8
|
+
sendData(type: string, data?: any): void;
|
|
9
|
+
getTool(key: string): {
|
|
10
|
+
getModel(): object;
|
|
11
|
+
dataSources(values?: any): string[];
|
|
12
|
+
} | undefined;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/shared/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,WAAY,MAAM,eAAe,MAAM,WAC5C,CAAC;AAEpC,eAAO,MAAM,wBAAwB,YACxB,MAAM;QACV,MAAM;aAAW,MAAM;aAM/B,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,QAAQ,IAAI,MAAM,CAAC;QAAC,WAAW,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;CACjG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const unlayerUnitsGenerateToolKey = (unitId, unitGeneric) => `${unitGeneric}:unit:${unitId}`;
|
|
2
|
+
export const unlayerUnitsParseToolKey = (toolKey) => {
|
|
3
|
+
const [generic, type, id] = (toolKey !== null && toolKey !== void 0 ? toolKey : '').split(':');
|
|
4
|
+
if (type === 'unit' && generic && id) {
|
|
5
|
+
return { id, generic };
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/shared/tools.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE,CAC/E,GAAG,WAAW,SAAS,MAAM,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACpC,OAAe,EAC4B,EAAE;IAC7C,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvD,IAAI,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,EAAE,EAAE;QAClC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;KAC1B;AACL,CAAC,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CreateUnlayerEditorProps, UnlayerDesignFormat, UnlayerRef } from './unlayer-interface';
|
|
2
|
+
export interface UnlayerDesignChangeInfo {
|
|
3
|
+
isToolsListChanged: boolean;
|
|
4
|
+
event: any;
|
|
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 hasDesign;
|
|
13
|
+
private onMessageCB?;
|
|
14
|
+
private onChangeCB?;
|
|
15
|
+
private onReadyCB?;
|
|
16
|
+
private onImageCB?;
|
|
17
|
+
constructor(props: CreateUnlayerEditorProps);
|
|
18
|
+
init: (container: HTMLDivElement) => Promise<void>;
|
|
19
|
+
destroy: () => void;
|
|
20
|
+
setDesign: (design?: UnlayerDesignFormat) => void;
|
|
21
|
+
setOnChange: (onChange?: UnlayerStore['onChangeCB']) => void;
|
|
22
|
+
setOnReady: (onReady?: UnlayerStore['onReadyCB']) => 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 uploadImage;
|
|
30
|
+
}
|
|
31
|
+
//# 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,uBAAuB;IACpC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,EAAE,GAAG,CAAC;CACd;AAWD,qBAAa,YAAY;IAaT,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAZpD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAC,CAAoB;IACnC,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,WAAW,CAAC,CAAoC;IACxD,OAAO,CAAC,UAAU,CAAC,CAA0C;IAC7D,OAAO,CAAC,SAAS,CAAC,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAC,CAA2C;gBAExC,KAAK,EAAE,wBAAwB;IAgBpD,IAAI,cAAqB,cAAc,mBAiBrC;IAEF,OAAO,aAUL;IAEF,SAAS,YAAa,mBAAmB,UAUvC;IAEF,WAAW,cAAe,YAAY,CAAC,YAAY,CAAC,UAElD;IAEF,UAAU,aAAc,YAAY,CAAC,WAAW,CAAC,UAE/C;IAEF,UAAU,aAAc,YAAY,CAAC,WAAW,CAAC,UAE/C;IAEF,YAAY,eAAgB,YAAY,CAAC,aAAa,CAAC,UAErD;IAEF,OAAO,CAAC,cAAc,CAQpB;IAEF,OAAO,CAAC,eAAe,CAKrB;IAEF,OAAO,CAAC,aAAa,CAuCnB;IAEF,OAAO,CAAC,WAAW,CAUjB;IAEF,OAAO,CAAC,WAAW,CAWjB;CACL"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
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 { createUnlayerEditor, DesignUpdatedEventType, } from './unlayer';
|
|
12
|
+
const defaultScriptUrl = 'https://editor.unlayer.com/embed.js?2';
|
|
13
|
+
const eventsNotChangingToolsList = [
|
|
14
|
+
DesignUpdatedEventType.ContentMoved,
|
|
15
|
+
DesignUpdatedEventType.ContentModified,
|
|
16
|
+
DesignUpdatedEventType.ColumnModified,
|
|
17
|
+
DesignUpdatedEventType.RowMoved,
|
|
18
|
+
DesignUpdatedEventType.RowModified,
|
|
19
|
+
DesignUpdatedEventType.BodyModified,
|
|
20
|
+
];
|
|
21
|
+
export class UnlayerStore {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
Object.defineProperty(this, "props", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: props
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "unlayerRef", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "editor", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "isInit", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: false
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(this, "iframe", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(this, "hasDesign", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: false
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "onMessageCB", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: void 0
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(this, "onChangeCB", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "onReadyCB", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(this, "onImageCB", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(this, "init", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true,
|
|
87
|
+
value: (container) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
var _a;
|
|
89
|
+
if (this.isInit) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.isInit = true;
|
|
93
|
+
window.addEventListener('message', this.onPostMessage);
|
|
94
|
+
yield loadScript(defaultScriptUrl);
|
|
95
|
+
this.editor = createUnlayerEditor(container, this.props);
|
|
96
|
+
this.editor.addEventListener('design:loaded', this.onDesignLoaded);
|
|
97
|
+
this.editor.addEventListener('design:updated', this.onDesignUpdated);
|
|
98
|
+
this.editor.registerCallback('image', this.uploadImage);
|
|
99
|
+
this.iframe = (_a = container.querySelector(`iframe`)) !== null && _a !== void 0 ? _a : undefined;
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(this, "destroy", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: () => {
|
|
107
|
+
window.removeEventListener('message', this.onPostMessage);
|
|
108
|
+
if (this.editor) {
|
|
109
|
+
this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
|
|
110
|
+
this.editor.removeEventListener('design:updated', this.onDesignUpdated);
|
|
111
|
+
this.editor.unregisterCallback('image', this.uploadImage);
|
|
112
|
+
this.editor = undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "setDesign", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: (design) => {
|
|
121
|
+
if (!this.editor) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.hasDesign = !!design;
|
|
125
|
+
if (design) {
|
|
126
|
+
this.editor.loadDesign(design);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(this, "setOnChange", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: (onChange) => {
|
|
135
|
+
this.onChangeCB = onChange;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(this, "setOnReady", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
configurable: true,
|
|
141
|
+
writable: true,
|
|
142
|
+
value: (onReady) => {
|
|
143
|
+
this.onReadyCB = onReady;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(this, "setOnImage", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
configurable: true,
|
|
149
|
+
writable: true,
|
|
150
|
+
value: (onImage) => {
|
|
151
|
+
this.onImageCB = onImage;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(this, "setOnMessage", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: (onMessage) => {
|
|
159
|
+
this.onMessageCB = onMessage;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(this, "onDesignLoaded", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
configurable: true,
|
|
165
|
+
writable: true,
|
|
166
|
+
value: () => {
|
|
167
|
+
var _a;
|
|
168
|
+
if (!this.hasDesign) {
|
|
169
|
+
this.hasDesign = true;
|
|
170
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.setBodyValues({
|
|
171
|
+
backgroundColor: 'rgba(0,0,0,0)',
|
|
172
|
+
contentWidth: '100%',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(this, "onDesignUpdated", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
configurable: true,
|
|
180
|
+
writable: true,
|
|
181
|
+
value: (event) => {
|
|
182
|
+
var _a;
|
|
183
|
+
(_a = this.onChangeCB) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
184
|
+
isToolsListChanged: !eventsNotChangingToolsList.includes(event.type),
|
|
185
|
+
event,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(this, "onPostMessage", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
configurable: true,
|
|
192
|
+
writable: true,
|
|
193
|
+
value: (e) => {
|
|
194
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
195
|
+
if (!((_a = e.data) === null || _a === void 0 ? void 0 : _a['-dte-message-from'])) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const type = (_c = (_b = e.data) === null || _b === void 0 ? void 0 : _b['-dte-message-from']) === null || _c === void 0 ? void 0 : _c.type;
|
|
199
|
+
const data = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d['-dte-message-from']) === null || _e === void 0 ? void 0 : _e.data;
|
|
200
|
+
if (!type) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (type === '--ready' || type === '--registered') {
|
|
204
|
+
(_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this);
|
|
205
|
+
}
|
|
206
|
+
else if (type === '--core-loaded') {
|
|
207
|
+
const data = {
|
|
208
|
+
dummyData: this.props.dummyData,
|
|
209
|
+
schema: this.props.schema,
|
|
210
|
+
generics: this.props.generics,
|
|
211
|
+
genericConfigMode: this.props.genericConfigMode,
|
|
212
|
+
};
|
|
213
|
+
this.sendMessage('--config', JSON.parse(JSON.stringify(data)));
|
|
214
|
+
}
|
|
215
|
+
else if (type === '--data-loaded') {
|
|
216
|
+
const data = {
|
|
217
|
+
customTools: this.props.tools.map(tool => ({ key: tool.key })),
|
|
218
|
+
units: (_g = this.props.units) === null || _g === void 0 ? void 0 : _g.map(unit => (Object.assign(Object.assign({}, unit), { values: Object.assign(Object.assign({}, unit.values), { adminConfig: undefined }) }))),
|
|
219
|
+
};
|
|
220
|
+
this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
|
|
221
|
+
}
|
|
222
|
+
(_h = this.onMessageCB) === null || _h === void 0 ? void 0 : _h.call(this, type, data);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
Object.defineProperty(this, "sendMessage", {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
configurable: true,
|
|
228
|
+
writable: true,
|
|
229
|
+
value: (type, data) => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
(_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({
|
|
232
|
+
'-dte-message-to': {
|
|
233
|
+
type,
|
|
234
|
+
data,
|
|
235
|
+
},
|
|
236
|
+
}, '*');
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(this, "uploadImage", {
|
|
240
|
+
enumerable: true,
|
|
241
|
+
configurable: true,
|
|
242
|
+
writable: true,
|
|
243
|
+
value: (data, done) => {
|
|
244
|
+
var _a;
|
|
245
|
+
if (!this.onImageCB) {
|
|
246
|
+
done({ progress: 100 });
|
|
247
|
+
throw new Error('image upload is not implemented');
|
|
248
|
+
}
|
|
249
|
+
if ((_a = data.attachments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
250
|
+
this.onImageCB(data.attachments[0])
|
|
251
|
+
.then(({ url }) => done({ progress: 100, url }))
|
|
252
|
+
.catch(() => done({ progress: 100 }));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
this.unlayerRef = {
|
|
257
|
+
loadDesign: design => {
|
|
258
|
+
var _a;
|
|
259
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.loadDesign(design);
|
|
260
|
+
},
|
|
261
|
+
saveDesign: cb => {
|
|
262
|
+
var _a;
|
|
263
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.saveDesign(cb);
|
|
264
|
+
},
|
|
265
|
+
exportHtml: cb => {
|
|
266
|
+
var _a;
|
|
267
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
|
|
268
|
+
cb(data);
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
};
|
|
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CAAC,IAAS,EAAE,IAA2B,EAAE,EAAE;;gBAC7D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;oBACjB,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;oBACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;iBACtD;gBAED,IAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,MAAM,EAAE;oBAC1B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;yBAC9B,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;yBAC/C,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;iBAC7C;YACL,CAAC;WAAC;QA3JE,IAAI,CAAC,UAAU,GAAG;YACd,UAAU,EAAE,MAAM,CAAC,EAAE;;gBACjB,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;YACD,UAAU,EAAE,EAAE,CAAC,EAAE;;gBACb,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;YACD,UAAU,EAAE,EAAE,CAAC,EAAE;;gBACb,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,CAAC,IAAI,CAAC,EAAE;oBAC3B,EAAE,CAAC,IAAI,CAAC,CAAC;gBACb,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;CA+IJ"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UnlayerDesignFormat, UnlayerDesignTool } from './unlayer-interface';
|
|
2
|
+
export declare const unlayerGetDefaultDesign: () => UnlayerDesignFormat;
|
|
3
|
+
export declare const unlayerToolsIterate: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | undefined | void) => void;
|
|
4
|
+
export declare const unlayerToolsIterateCustom: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | undefined | void) => void;
|
|
5
|
+
export declare const unlayerToolsListCustomKeys: (design: UnlayerDesignFormat) => string[];
|
|
6
|
+
export declare const unlayerToolsFind: (design: UnlayerDesignFormat, cb: (tool: UnlayerDesignTool) => boolean | void) => UnlayerDesignTool | undefined;
|
|
7
|
+
export interface UnlayerCustomToolsStat {
|
|
8
|
+
counters: Record<string, number>;
|
|
9
|
+
missing: string[];
|
|
10
|
+
notSupported: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const unlayerToolsCustomStat: (design: UnlayerDesignFormat, tools?: {
|
|
13
|
+
key: string;
|
|
14
|
+
isRequired?: boolean;
|
|
15
|
+
}[], units?: {
|
|
16
|
+
id: string;
|
|
17
|
+
generic: string;
|
|
18
|
+
isRequired?: boolean;
|
|
19
|
+
}[]) => UnlayerCustomToolsStat;
|
|
20
|
+
export declare const unlayerToolsListCustom: (design: UnlayerDesignFormat) => UnlayerDesignTool[];
|
|
21
|
+
export declare const unlayerToolsBuildDesign: (tools: UnlayerDesignTool[]) => UnlayerDesignFormat;
|
|
22
|
+
export declare const unlayerUnitsGetIdFromValues: (values?: any) => string | undefined;
|
|
23
|
+
export declare const unlayerUnitsGetTitleFromValues: (values?: any) => string | undefined;
|
|
24
|
+
export declare const unlayerUnitsGetId: (tool: UnlayerDesignTool) => string | undefined;
|
|
25
|
+
export declare const unlayerUnitsGetTitle: (tool: UnlayerDesignTool) => string | undefined;
|
|
26
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;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