@servicetitan/dte-unlayer 0.6.0 → 0.8.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/const.d.ts +6 -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/schema.d.ts +42 -0
- package/dist/shared/schema.d.ts.map +1 -0
- package/dist/shared/schema.js +77 -0
- package/dist/shared/schema.js.map +1 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -18
- package/dist/store.js.map +1 -1
- package/dist/unlayer-interface.d.ts +12 -8
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer.d.ts +1 -1
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +32 -4
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/schema.test.ts +72 -0
- package/src/index.ts +1 -0
- package/src/shared/const.ts +5 -0
- package/src/shared/schema.ts +156 -0
- package/src/store.ts +10 -24
- package/src/unlayer-interface.tsx +14 -9
- package/src/unlayer.tsx +32 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './editor';
|
|
|
2
2
|
export * from './tools';
|
|
3
3
|
export * from './unlayer-interface';
|
|
4
4
|
export * from './loadScript';
|
|
5
|
+
export * from './shared/schema';
|
|
5
6
|
export { UnlayerToolsInfo } from './store';
|
|
6
7
|
export { versions } from './unlayer';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
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;AAC7B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAC7B,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../src/shared/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/shared/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,gBAAgB,EAAE,OAAO;IACzB,mBAAmB,EAAE,aAAa;IAClC,kBAAkB,EAAE,QAAQ;CAC/B,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type SchemaNodeAvailableTypes = 'object' | 'array' | 'string';
|
|
2
|
+
export declare const schemaNodeAvailableTypes: string[];
|
|
3
|
+
export declare const schemaIsAvailableType: (type: string) => type is SchemaNodeAvailableTypes;
|
|
4
|
+
export interface SchemaFieldBaseOptions {
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
interface SchemaNodeProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
options?: SchemaFieldBaseOptions;
|
|
10
|
+
}
|
|
11
|
+
export interface SchemaObject extends SchemaNodeProps {
|
|
12
|
+
type: 'object';
|
|
13
|
+
properties: Record<string, SchemaNode>;
|
|
14
|
+
}
|
|
15
|
+
export interface SchemaArray extends SchemaNodeProps {
|
|
16
|
+
type: 'array';
|
|
17
|
+
items: SchemaNode;
|
|
18
|
+
}
|
|
19
|
+
export interface SchemaSimple extends SchemaNodeProps {
|
|
20
|
+
type: 'string';
|
|
21
|
+
}
|
|
22
|
+
export declare const schemaArrayRootKey = "[]";
|
|
23
|
+
export type SchemaNode = SchemaObject | SchemaArray | SchemaSimple;
|
|
24
|
+
export declare const schemaIsObject: (node?: SchemaNode) => node is SchemaObject;
|
|
25
|
+
export declare const schemaIsArray: (node?: SchemaNode) => node is SchemaArray;
|
|
26
|
+
export declare const schemaFindNode: (schema: SchemaNode, key: string) => SchemaNode | undefined;
|
|
27
|
+
export declare const schemaFindParentNode: (schema: SchemaNode, key: string) => SchemaNode | undefined;
|
|
28
|
+
export declare const schemaGetFieldKey: (fullKey: string) => string;
|
|
29
|
+
export declare const schemaBuildNode: (type: SchemaNodeAvailableTypes, arrayItemType?: SchemaNodeAvailableTypes) => SchemaNode;
|
|
30
|
+
export interface SchemaMetaField {
|
|
31
|
+
fieldKey: string;
|
|
32
|
+
fullKey: string;
|
|
33
|
+
node: SchemaNode;
|
|
34
|
+
title: string;
|
|
35
|
+
fullTitle: string;
|
|
36
|
+
isArrayed: boolean;
|
|
37
|
+
isValue: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type SchemaMap = Record<string, SchemaMetaField>;
|
|
40
|
+
export declare const schemaBuildMap: (schema: SchemaObject) => SchemaMap;
|
|
41
|
+
export {};
|
|
42
|
+
//# 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,eAAO,MAAM,qBAAqB,SAAU,MAAM,qCACP,CAAC;AAE5C,MAAM,WAAW,sBAAsB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,eAAe;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,sBAAsB,CAAC;CACpC;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,WAAY,SAAQ,eAAe;IAChD,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACjD,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,CAAC;AAEnE,eAAO,MAAM,cAAc,UAAW,UAAU,yBAAkD,CAAC;AACnG,eAAO,MAAM,aAAa,UAAW,UAAU,wBAAgD,CAAC;AAEhG,eAAO,MAAM,cAAc,WAAY,UAAU,OAAO,MAAM,KAAG,UAAU,GAAG,SAwB7E,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAY,UAAU,OAAO,MAAM,KAAG,UAAU,GAAG,SAUnF,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,MAAwC,CAAC;AAE7F,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,KAAG,SAsDrD,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const schemaNodeAvailableTypes = ['object', 'array', 'string'];
|
|
2
|
+
export const schemaIsAvailableType = (type) => schemaNodeAvailableTypes.includes(type);
|
|
3
|
+
export const schemaArrayRootKey = '[]';
|
|
4
|
+
export const schemaIsObject = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'object';
|
|
5
|
+
export const schemaIsArray = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'array';
|
|
6
|
+
export const schemaFindNode = (schema, key) => {
|
|
7
|
+
const nodeFinder = (node, keys) => {
|
|
8
|
+
if (!node) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!keys.length) {
|
|
12
|
+
return node;
|
|
13
|
+
}
|
|
14
|
+
const key = keys.shift();
|
|
15
|
+
if (!key) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (key === schemaArrayRootKey) {
|
|
19
|
+
return schemaIsArray(node) ? nodeFinder(node.items, keys) : undefined;
|
|
20
|
+
}
|
|
21
|
+
return schemaIsObject(node) ? nodeFinder(node.properties[key], keys) : undefined;
|
|
22
|
+
};
|
|
23
|
+
return nodeFinder(schema, key.split('.'));
|
|
24
|
+
};
|
|
25
|
+
export const schemaFindParentNode = (schema, key) => {
|
|
26
|
+
const keys = key.split('.');
|
|
27
|
+
keys.pop();
|
|
28
|
+
return keys.length
|
|
29
|
+
? schemaFindNode(schema, keys.join('.'))
|
|
30
|
+
: schemaIsObject(schema) && schema.properties[key]
|
|
31
|
+
? schema
|
|
32
|
+
: undefined;
|
|
33
|
+
};
|
|
34
|
+
export const schemaGetFieldKey = (fullKey) => { var _a; return (_a = fullKey.split('.').pop()) !== null && _a !== void 0 ? _a : ''; };
|
|
35
|
+
export const schemaBuildNode = (type, arrayItemType) => {
|
|
36
|
+
if (type === 'object') {
|
|
37
|
+
return { type: 'object', properties: {}, options: {} };
|
|
38
|
+
}
|
|
39
|
+
if (type === 'array') {
|
|
40
|
+
return { type: 'array', items: schemaBuildNode(arrayItemType !== null && arrayItemType !== void 0 ? arrayItemType : 'object'), options: {} };
|
|
41
|
+
}
|
|
42
|
+
return { type, options: {} };
|
|
43
|
+
};
|
|
44
|
+
export const schemaBuildMap = (schema) => {
|
|
45
|
+
const fieldsMap = {};
|
|
46
|
+
const processNode = (node, nodeKey, parentNodes, isArrayed) => {
|
|
47
|
+
var _a, _b, _c, _d;
|
|
48
|
+
const nodeLabel = (_a = node.title) !== null && _a !== void 0 ? _a : nodeKey;
|
|
49
|
+
if (nodeKey) {
|
|
50
|
+
const fullKey = [...parentNodes.map(n => n.key), nodeKey].join('.');
|
|
51
|
+
const fullTitle = [...parentNodes.map(n => n.title), nodeLabel].join(' - ');
|
|
52
|
+
fieldsMap[fullKey] = {
|
|
53
|
+
fieldKey: nodeKey,
|
|
54
|
+
fullKey,
|
|
55
|
+
fullTitle,
|
|
56
|
+
title: (_b = node.title) !== null && _b !== void 0 ? _b : fullTitle,
|
|
57
|
+
node,
|
|
58
|
+
isArrayed,
|
|
59
|
+
isValue: !schemaIsObject(node) && !schemaIsArray(node),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (schemaIsObject(node)) {
|
|
63
|
+
const properties = (_c = node.properties) !== null && _c !== void 0 ? _c : {};
|
|
64
|
+
const keys = Object.keys(properties !== null && properties !== void 0 ? properties : {}).sort();
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
processNode(properties[key], key, nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [], isArrayed);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (schemaIsArray(node)) {
|
|
70
|
+
const items = (_d = node.items) !== null && _d !== void 0 ? _d : {};
|
|
71
|
+
processNode(items, schemaArrayRootKey, nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [], true);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
processNode(schema, '', [], false);
|
|
75
|
+
return fieldsMap;
|
|
76
|
+
};
|
|
77
|
+
//# 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;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAoC,EAAE,CACpF,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAyB5C,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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CAAC,CAAC;IAEF,WAAW,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAEnC,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC"}
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +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;IAeT,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAdpD,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,CAAmC;IACtD,OAAO,CAAC,SAAS,CAAC,CAAmC;IACrD,OAAO,CAAC,SAAS,CAAC,CAA2C;IAE7D,OAAO,CAAC,iBAAiB,CAA8B;gBAElC,KAAK,EAAE,wBAAwB;
|
|
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;IAeT,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAdpD,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,CAAmC;IACtD,OAAO,CAAC,SAAS,CAAC,CAAmC;IACrD,OAAO,CAAC,SAAS,CAAC,CAA2C;IAE7D,OAAO,CAAC,iBAAiB,CAA8B;gBAElC,KAAK,EAAE,wBAAwB;IAgBpD,IAAI,cAAqB,cAAc,mBAiBrC;IAEF,OAAO,aAUL;IAEF,SAAS,YAAa,mBAAmB,UAmBvC;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,CAwBrB;IAEF,OAAO,CAAC,aAAa,CAoCnB;IAEF,OAAO,CAAC,WAAW,CAUjB;IAEF,OAAO,CAAC,YAAY,CASlB;IAEF,OAAO,CAAC,WAAW,CAWjB;CACL"}
|
package/dist/store.js
CHANGED
|
@@ -223,14 +223,14 @@ export class UnlayerStore {
|
|
|
223
223
|
}
|
|
224
224
|
if (type === 'ready') {
|
|
225
225
|
(_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this, this.getToolsInfo());
|
|
226
|
-
this.sendMessage('--config', JSON.parse(JSON.stringify({
|
|
227
|
-
altTools: (_g = this.props.altTools) !== null && _g !== void 0 ? _g : [],
|
|
228
|
-
model: this.props.model,
|
|
229
|
-
})));
|
|
230
226
|
}
|
|
231
227
|
else if (type === '--core-loaded') {
|
|
232
228
|
this.sendMessage('--config', JSON.parse(JSON.stringify({
|
|
233
229
|
model: this.props.model,
|
|
230
|
+
schema: this.props.schema,
|
|
231
|
+
generics: this.props.generics,
|
|
232
|
+
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 }) }))),
|
|
233
|
+
genericConfigMode: this.props.genericConfigMode,
|
|
234
234
|
})));
|
|
235
235
|
}
|
|
236
236
|
(_h = this.onMessageCB) === null || _h === void 0 ? void 0 : _h.call(this, type, data);
|
|
@@ -292,20 +292,6 @@ export class UnlayerStore {
|
|
|
292
292
|
exportHtml: cb => {
|
|
293
293
|
var _a;
|
|
294
294
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
|
|
295
|
-
var _a, _b;
|
|
296
|
-
if ((_a = this.props.altTools) === null || _a === void 0 ? void 0 : _a.length) {
|
|
297
|
-
unlayerIterateCustomTools(data.design, tool => {
|
|
298
|
-
if (tool.slug.includes(':')) {
|
|
299
|
-
tool.slug = tool.slug.split(':')[0];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
for (const key of Object.keys((_b = data.design.counters) !== null && _b !== void 0 ? _b : {})) {
|
|
303
|
-
if (key.startsWith('u_content_custom_') && key.includes(':')) {
|
|
304
|
-
data.design.counters[key.split(':')[0]] = data.design.counters[key];
|
|
305
|
-
delete data.design.counters[key];
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
295
|
cb(data);
|
|
310
296
|
});
|
|
311
297
|
},
|
package/dist/store.js.map
CHANGED
|
@@ -1 +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,WA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UAAU,CAAC,IAAI,CAAC,EAAE;oBAC3B,EAAE,CAAC,IAAI,CAAC,CAAC;gBACb,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;CAmLJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SchemaObject } from './shared/schema';
|
|
1
2
|
export interface UnlayerDesignTool {
|
|
2
3
|
type: string;
|
|
3
4
|
slug: string;
|
|
@@ -30,25 +31,28 @@ export interface UnlayerRef {
|
|
|
30
31
|
saveDesign(cb: (design: any) => void): void;
|
|
31
32
|
exportHtml(cb: (data: UnlayerExport) => void): void;
|
|
32
33
|
}
|
|
33
|
-
export interface UnlayerAltTool {
|
|
34
|
-
id: string;
|
|
35
|
-
tool: string;
|
|
36
|
-
label: string;
|
|
37
|
-
values: any;
|
|
38
|
-
}
|
|
39
34
|
export interface UnlayerEditorMergeTagInfo {
|
|
40
35
|
id: string;
|
|
41
36
|
name: string;
|
|
42
37
|
propertyPath: string;
|
|
43
38
|
}
|
|
39
|
+
export interface UnlayerEditorUnit {
|
|
40
|
+
id: string;
|
|
41
|
+
generic: string;
|
|
42
|
+
title: string;
|
|
43
|
+
values: any;
|
|
44
|
+
}
|
|
44
45
|
export interface CreateUnlayerEditorProps {
|
|
45
46
|
packageUrl: string;
|
|
46
47
|
tools: UnlayerEditorToolInfo[];
|
|
47
|
-
altTools?: UnlayerAltTool[];
|
|
48
48
|
model?: any;
|
|
49
|
-
|
|
49
|
+
schema?: SchemaObject;
|
|
50
|
+
customCSS?: string | string[] | undefined;
|
|
50
51
|
customJS?: string | string[] | undefined;
|
|
51
52
|
mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;
|
|
53
|
+
genericConfigMode?: boolean;
|
|
54
|
+
generics?: string[];
|
|
55
|
+
units?: UnlayerEditorUnit[];
|
|
52
56
|
noCoreTools?: boolean;
|
|
53
57
|
latest?: boolean;
|
|
54
58
|
blocks?: boolean;
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"unlayer-interface.d.ts","sourceRoot":"","sources":["../src/unlayer-interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,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AAC;IACZ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,yBAAyB,EAAE,GAAG,SAAS,CAAC;IACpD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
package/dist/unlayer.d.ts
CHANGED
|
@@ -47,5 +47,5 @@ export declare const versions: {
|
|
|
47
47
|
unlayer: string;
|
|
48
48
|
schema: number;
|
|
49
49
|
};
|
|
50
|
-
export declare const createUnlayerEditor: (container: HTMLDivElement, { customCSS, customJS, latest, mergeTags, noCoreTools, packageUrl, tools, }: CreateUnlayerEditorProps) => Unlayer;
|
|
50
|
+
export declare const createUnlayerEditor: (container: HTMLDivElement, { customCSS, customJS, latest, mergeTags, noCoreTools, packageUrl, tools, units, }: CreateUnlayerEditorProps) => Unlayer;
|
|
51
51
|
//# sourceMappingURL=unlayer.d.ts.map
|
package/dist/unlayer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlayer.d.ts","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unlayer.d.ts","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"AACA,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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EAAE,GAAG,GAAG,IAAI,CAAC;CACpC;AAED,oBAAY,sBAAsB;IAC9B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;CACjC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,IAAI,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL;AAED,MAAM,WAAW,yBAAyB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;CAGpB,CAAC;AAEF,eAAO,MAAM,mBAAmB,cACjB,cAAc,sFAUtB,wBAAwB,KAC5B,OA8GF,CAAC"}
|
package/dist/unlayer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { constGenericsEditor } from './shared/const';
|
|
1
2
|
export var DesignUpdatedEventType;
|
|
2
3
|
(function (DesignUpdatedEventType) {
|
|
3
4
|
DesignUpdatedEventType["ContentRemoved"] = "content:removed";
|
|
@@ -13,9 +14,10 @@ export const versions = {
|
|
|
13
14
|
unlayer: '1.2.9',
|
|
14
15
|
schema: 5,
|
|
15
16
|
};
|
|
16
|
-
export const createUnlayerEditor = (container, { customCSS, customJS, latest, mergeTags, noCoreTools, packageUrl, tools, }) => {
|
|
17
|
+
export const createUnlayerEditor = (container, { customCSS, customJS, latest, mergeTags, noCoreTools, packageUrl, tools, units, }) => {
|
|
17
18
|
const customScripts = [
|
|
18
19
|
'/core.bundle.js',
|
|
20
|
+
'/tools.bundle.js',
|
|
19
21
|
'window.dteStore.sendData("--core-loaded")',
|
|
20
22
|
...tools.map(tool => `/${tool.path}`),
|
|
21
23
|
tools.map(tool => `window.dteStore.registerTool(unlayer, '${tool.key}');`).join('\n'),
|
|
@@ -25,6 +27,11 @@ export const createUnlayerEditor = (container, { customCSS, customJS, latest, me
|
|
|
25
27
|
]
|
|
26
28
|
.map(url => (url.startsWith('/') ? `${packageUrl}${url}` : url))
|
|
27
29
|
.filter(js => !!(js === null || js === void 0 ? void 0 : js.trim()));
|
|
30
|
+
const customStyles = [
|
|
31
|
+
...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),
|
|
32
|
+
]
|
|
33
|
+
.map(url => (url.startsWith('/') && !url.startsWith('/*') ? `${packageUrl}${url}` : url))
|
|
34
|
+
.filter(css => !!(css === null || css === void 0 ? void 0 : css.trim()));
|
|
28
35
|
/**
|
|
29
36
|
* Unlayer supports only passing id of container, but when we use shadowDOM (MFE),
|
|
30
37
|
* getElementById can't find element in it
|
|
@@ -38,6 +45,27 @@ export const createUnlayerEditor = (container, { customCSS, customJS, latest, me
|
|
|
38
45
|
}
|
|
39
46
|
return currentFind.call(document, id);
|
|
40
47
|
};
|
|
48
|
+
const acv = constGenericsEditor.adminConfigProperty;
|
|
49
|
+
const unitsConfig = (units !== null && units !== void 0 ? units : []).reduce((out, unit) => {
|
|
50
|
+
out[`custom#${unit.generic}:unit:${unit.id}`] = {
|
|
51
|
+
data: {
|
|
52
|
+
[acv]: unit.values[acv],
|
|
53
|
+
},
|
|
54
|
+
properties: {
|
|
55
|
+
[constGenericsEditor.userConfigProperty]: {
|
|
56
|
+
editor: {
|
|
57
|
+
data: { [acv]: unit.values[acv] },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
[constGenericsEditor.infoDataProperty]: {
|
|
61
|
+
editor: {
|
|
62
|
+
data: { title: unit.title },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
return out;
|
|
68
|
+
}, {});
|
|
41
69
|
const result = window.unlayer.createEditor({
|
|
42
70
|
displayMode: 'web',
|
|
43
71
|
devices: ['desktop'],
|
|
@@ -52,19 +80,19 @@ export const createUnlayerEditor = (container, { customCSS, customJS, latest, me
|
|
|
52
80
|
}, {}),
|
|
53
81
|
projectId: 5713,
|
|
54
82
|
version: latest ? undefined : versions.unlayer,
|
|
55
|
-
tools: Object.assign({ button: { enabled: false }, html: { enabled: false }, menu: { enabled: false }, form: { enabled: false }, image: { enabled: false } }, (noCoreTools
|
|
83
|
+
tools: Object.assign(Object.assign({ button: { enabled: false }, html: { enabled: false }, menu: { enabled: false }, form: { enabled: false }, image: { enabled: false } }, (noCoreTools
|
|
56
84
|
? {
|
|
57
85
|
columns: { enabled: false },
|
|
58
86
|
text: { enabled: false },
|
|
59
87
|
heading: { enabled: false },
|
|
60
88
|
divider: { enabled: false },
|
|
61
89
|
}
|
|
62
|
-
: {})),
|
|
90
|
+
: {})), unitsConfig),
|
|
63
91
|
editor: {
|
|
64
92
|
autoSelectOnDrop: true,
|
|
65
93
|
},
|
|
66
94
|
customJS: customScripts,
|
|
67
|
-
customCSS:
|
|
95
|
+
customCSS: customStyles,
|
|
68
96
|
id,
|
|
69
97
|
fonts: {
|
|
70
98
|
showDefaultFonts: true,
|
package/dist/unlayer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlayer.js","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unlayer.js","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAyBrD,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,4DAAkC,CAAA;IAClC,wDAA8B,CAAA;AAClC,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAgBD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAC/B,SAAyB,EACzB,EACI,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,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I;SACzB;QACD,QAAQ,EAAE,aAAa;QACvB,SAAS,EAAE,YAAY;QACvB,EAAE;QACF,KAAK,EAAE;YACH,gBAAgB,EAAE,IAAI;YACtB,WAAW,EAAE;gBACT,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;gBAC1C,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;gBAC9C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;aAC/C;SACJ;QACD,IAAI,EAAE;YACF,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;SAC7B;KACJ,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,GAAG,WAAW,CAAC;IACtC,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { schemaFindNode, schemaFindParentNode, SchemaObject } from '../shared/schema';
|
|
2
|
+
|
|
3
|
+
const schemaSource = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
title: '',
|
|
6
|
+
properties: {
|
|
7
|
+
Name: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
title: 'First Name',
|
|
10
|
+
},
|
|
11
|
+
LastName: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
title: 'Last Name',
|
|
14
|
+
},
|
|
15
|
+
Job: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
title: 'Job Info',
|
|
18
|
+
properties: {
|
|
19
|
+
Id: { type: 'string' },
|
|
20
|
+
Name: { type: 'string' },
|
|
21
|
+
SubJob: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
Id: { type: 'string' },
|
|
25
|
+
Name: { type: 'string' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
Xfactor: { type: 'string' },
|
|
29
|
+
Technicians: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
ID: { type: 'string' },
|
|
35
|
+
Name: { type: 'string' },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
IDList: {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: 'string' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const schema = schemaSource as SchemaObject;
|
|
48
|
+
|
|
49
|
+
describe('schemaFindNode', () => {
|
|
50
|
+
test('return undefined for unknown key', () => {
|
|
51
|
+
expect(schemaFindNode(schema, 'XXX')).toEqual(undefined);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('return node for root key', () => {
|
|
55
|
+
expect(schemaFindNode(schema, 'Name')).toEqual(schemaSource.properties.Name);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('schemaFindNode', () => {
|
|
60
|
+
test('return undefined for unknown key', () => {
|
|
61
|
+
expect(schemaFindParentNode(schema, 'XXX')).toEqual(undefined);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('return root schema for root key', () => {
|
|
65
|
+
expect(schemaFindParentNode(schema, 'Name')).toEqual(schema);
|
|
66
|
+
});
|
|
67
|
+
test('return parent', () => {
|
|
68
|
+
expect(schemaFindParentNode(schema, 'Job.SubJob.Id')).toEqual(
|
|
69
|
+
schemaSource.properties.Job.properties.SubJob
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export type SchemaNodeAvailableTypes = 'object' | 'array' | 'string';
|
|
2
|
+
export const schemaNodeAvailableTypes = ['object', 'array', 'string'];
|
|
3
|
+
|
|
4
|
+
export const schemaIsAvailableType = (type: string): type is SchemaNodeAvailableTypes =>
|
|
5
|
+
schemaNodeAvailableTypes.includes(type);
|
|
6
|
+
|
|
7
|
+
export interface SchemaFieldBaseOptions {
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface SchemaNodeProps {
|
|
12
|
+
title?: string;
|
|
13
|
+
options?: SchemaFieldBaseOptions;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SchemaObject extends SchemaNodeProps {
|
|
17
|
+
type: 'object';
|
|
18
|
+
properties: Record<string, SchemaNode>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SchemaArray extends SchemaNodeProps {
|
|
22
|
+
type: 'array';
|
|
23
|
+
items: SchemaNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SchemaSimple extends SchemaNodeProps {
|
|
27
|
+
type: 'string';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const schemaArrayRootKey = '[]';
|
|
31
|
+
export type SchemaNode = SchemaObject | SchemaArray | SchemaSimple;
|
|
32
|
+
|
|
33
|
+
export const schemaIsObject = (node?: SchemaNode): node is SchemaObject => node?.type === 'object';
|
|
34
|
+
export const schemaIsArray = (node?: SchemaNode): node is SchemaArray => node?.type === 'array';
|
|
35
|
+
|
|
36
|
+
export const schemaFindNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {
|
|
37
|
+
const nodeFinder = (node: SchemaNode, keys: string[]): SchemaNode | undefined => {
|
|
38
|
+
if (!node) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!keys.length) {
|
|
43
|
+
return node;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const key = keys.shift();
|
|
47
|
+
|
|
48
|
+
if (!key) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (key === schemaArrayRootKey) {
|
|
53
|
+
return schemaIsArray(node) ? nodeFinder(node.items, keys) : undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return schemaIsObject(node) ? nodeFinder(node.properties[key], keys) : undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return nodeFinder(schema, key.split('.'));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const schemaFindParentNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {
|
|
63
|
+
const keys = key.split('.');
|
|
64
|
+
|
|
65
|
+
keys.pop();
|
|
66
|
+
|
|
67
|
+
return keys.length
|
|
68
|
+
? schemaFindNode(schema, keys.join('.'))
|
|
69
|
+
: schemaIsObject(schema) && schema.properties[key]
|
|
70
|
+
? schema
|
|
71
|
+
: undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const schemaGetFieldKey = (fullKey: string): string => fullKey.split('.').pop() ?? '';
|
|
75
|
+
|
|
76
|
+
export const schemaBuildNode = (
|
|
77
|
+
type: SchemaNodeAvailableTypes,
|
|
78
|
+
arrayItemType?: SchemaNodeAvailableTypes
|
|
79
|
+
): SchemaNode => {
|
|
80
|
+
if (type === 'object') {
|
|
81
|
+
return { type: 'object', properties: {}, options: {} };
|
|
82
|
+
}
|
|
83
|
+
if (type === 'array') {
|
|
84
|
+
return { type: 'array', items: schemaBuildNode(arrayItemType ?? 'object'), options: {} };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return { type, options: {} };
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface SchemaMetaField {
|
|
91
|
+
fieldKey: string;
|
|
92
|
+
fullKey: string;
|
|
93
|
+
node: SchemaNode;
|
|
94
|
+
title: string; // node.title or fullTitle
|
|
95
|
+
fullTitle: string; // joined title of all parents and field
|
|
96
|
+
isArrayed: boolean;
|
|
97
|
+
isValue: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type SchemaMap = Record<string, SchemaMetaField>;
|
|
101
|
+
|
|
102
|
+
export const schemaBuildMap = (schema: SchemaObject): SchemaMap => {
|
|
103
|
+
const fieldsMap: Record<string, SchemaMetaField> = {};
|
|
104
|
+
|
|
105
|
+
const processNode = (
|
|
106
|
+
node: SchemaNode,
|
|
107
|
+
nodeKey: string,
|
|
108
|
+
parentNodes: { key: string; title: string }[],
|
|
109
|
+
isArrayed: boolean
|
|
110
|
+
) => {
|
|
111
|
+
const nodeLabel = node.title ?? nodeKey;
|
|
112
|
+
if (nodeKey) {
|
|
113
|
+
const fullKey = [...parentNodes.map(n => n.key), nodeKey].join('.');
|
|
114
|
+
const fullTitle = [...parentNodes.map(n => n.title), nodeLabel].join(' - ');
|
|
115
|
+
|
|
116
|
+
fieldsMap[fullKey] = {
|
|
117
|
+
fieldKey: nodeKey,
|
|
118
|
+
fullKey,
|
|
119
|
+
fullTitle,
|
|
120
|
+
title: node.title ?? fullTitle,
|
|
121
|
+
node,
|
|
122
|
+
isArrayed,
|
|
123
|
+
isValue: !schemaIsObject(node) && !schemaIsArray(node),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (schemaIsObject(node)) {
|
|
128
|
+
const properties = node.properties ?? {};
|
|
129
|
+
const keys = Object.keys(properties ?? {}).sort();
|
|
130
|
+
|
|
131
|
+
for (const key of keys) {
|
|
132
|
+
processNode(
|
|
133
|
+
properties[key],
|
|
134
|
+
key,
|
|
135
|
+
nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],
|
|
136
|
+
isArrayed
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (schemaIsArray(node)) {
|
|
142
|
+
const items = node.items ?? {};
|
|
143
|
+
|
|
144
|
+
processNode(
|
|
145
|
+
items,
|
|
146
|
+
schemaArrayRootKey,
|
|
147
|
+
nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],
|
|
148
|
+
true
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
processNode(schema, '', [], false);
|
|
154
|
+
|
|
155
|
+
return fieldsMap;
|
|
156
|
+
};
|
package/src/store.ts
CHANGED
|
@@ -40,21 +40,6 @@ export class UnlayerStore {
|
|
|
40
40
|
},
|
|
41
41
|
exportHtml: cb => {
|
|
42
42
|
this.editor?.exportHtml(data => {
|
|
43
|
-
if (this.props.altTools?.length) {
|
|
44
|
-
unlayerIterateCustomTools(data.design, tool => {
|
|
45
|
-
if (tool.slug.includes(':')) {
|
|
46
|
-
tool.slug = tool.slug.split(':')[0];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
for (const key of Object.keys(data.design.counters ?? {})) {
|
|
51
|
-
if (key.startsWith('u_content_custom_') && key.includes(':')) {
|
|
52
|
-
data.design.counters[key.split(':')[0]] = data.design.counters[key];
|
|
53
|
-
delete data.design.counters[key];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
43
|
cb(data);
|
|
59
44
|
});
|
|
60
45
|
},
|
|
@@ -179,21 +164,22 @@ export class UnlayerStore {
|
|
|
179
164
|
|
|
180
165
|
if (type === 'ready') {
|
|
181
166
|
this.onReadyCB?.(this.getToolsInfo());
|
|
182
|
-
this.sendMessage(
|
|
183
|
-
'--config',
|
|
184
|
-
JSON.parse(
|
|
185
|
-
JSON.stringify({
|
|
186
|
-
altTools: this.props.altTools ?? [],
|
|
187
|
-
model: this.props.model,
|
|
188
|
-
})
|
|
189
|
-
)
|
|
190
|
-
);
|
|
191
167
|
} else if (type === '--core-loaded') {
|
|
192
168
|
this.sendMessage(
|
|
193
169
|
'--config',
|
|
194
170
|
JSON.parse(
|
|
195
171
|
JSON.stringify({
|
|
196
172
|
model: this.props.model,
|
|
173
|
+
schema: this.props.schema,
|
|
174
|
+
generics: this.props.generics,
|
|
175
|
+
units: this.props.units?.map(unit => ({
|
|
176
|
+
...unit,
|
|
177
|
+
values: {
|
|
178
|
+
...unit.values,
|
|
179
|
+
adminConfig: undefined,
|
|
180
|
+
},
|
|
181
|
+
})),
|
|
182
|
+
genericConfigMode: this.props.genericConfigMode,
|
|
197
183
|
})
|
|
198
184
|
)
|
|
199
185
|
);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SchemaObject } from './shared/schema';
|
|
2
|
+
|
|
1
3
|
export interface UnlayerDesignTool {
|
|
2
4
|
type: string;
|
|
3
5
|
slug: string;
|
|
@@ -35,27 +37,30 @@ export interface UnlayerRef {
|
|
|
35
37
|
exportHtml(cb: (data: UnlayerExport) => void): void;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export interface UnlayerAltTool {
|
|
39
|
-
id: string;
|
|
40
|
-
tool: string;
|
|
41
|
-
label: string;
|
|
42
|
-
values: any;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
40
|
export interface UnlayerEditorMergeTagInfo {
|
|
46
41
|
id: string;
|
|
47
42
|
name: string;
|
|
48
43
|
propertyPath: string;
|
|
49
44
|
}
|
|
50
45
|
|
|
46
|
+
export interface UnlayerEditorUnit {
|
|
47
|
+
id: string;
|
|
48
|
+
generic: string;
|
|
49
|
+
title: string;
|
|
50
|
+
values: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
51
53
|
export interface CreateUnlayerEditorProps {
|
|
52
54
|
packageUrl: string;
|
|
53
55
|
tools: UnlayerEditorToolInfo[];
|
|
54
|
-
altTools?: UnlayerAltTool[];
|
|
55
56
|
model?: any;
|
|
56
|
-
|
|
57
|
+
schema?: SchemaObject;
|
|
58
|
+
customCSS?: string | string[] | undefined;
|
|
57
59
|
customJS?: string | string[] | undefined;
|
|
58
60
|
mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;
|
|
61
|
+
genericConfigMode?: boolean;
|
|
62
|
+
generics?: string[];
|
|
63
|
+
units?: UnlayerEditorUnit[];
|
|
59
64
|
noCoreTools?: boolean;
|
|
60
65
|
latest?: boolean;
|
|
61
66
|
blocks?: boolean;
|
package/src/unlayer.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { constGenericsEditor } from './shared/const';
|
|
1
2
|
import { CreateUnlayerEditorProps } from './unlayer-interface';
|
|
2
3
|
|
|
3
4
|
export interface UnlayerExport {
|
|
@@ -62,10 +63,12 @@ export const createUnlayerEditor = (
|
|
|
62
63
|
noCoreTools,
|
|
63
64
|
packageUrl,
|
|
64
65
|
tools,
|
|
66
|
+
units,
|
|
65
67
|
}: CreateUnlayerEditorProps
|
|
66
68
|
): Unlayer => {
|
|
67
69
|
const customScripts = [
|
|
68
70
|
'/core.bundle.js',
|
|
71
|
+
'/tools.bundle.js',
|
|
69
72
|
'window.dteStore.sendData("--core-loaded")',
|
|
70
73
|
...tools.map(tool => `/${tool.path}`),
|
|
71
74
|
tools.map(tool => `window.dteStore.registerTool(unlayer, '${tool.key}');`).join('\n'),
|
|
@@ -75,6 +78,11 @@ export const createUnlayerEditor = (
|
|
|
75
78
|
]
|
|
76
79
|
.map(url => (url.startsWith('/') ? `${packageUrl}${url}` : url))
|
|
77
80
|
.filter(js => !!js?.trim());
|
|
81
|
+
const customStyles = [
|
|
82
|
+
...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),
|
|
83
|
+
]
|
|
84
|
+
.map(url => (url.startsWith('/') && !url.startsWith('/*') ? `${packageUrl}${url}` : url))
|
|
85
|
+
.filter(css => !!css?.trim());
|
|
78
86
|
|
|
79
87
|
/**
|
|
80
88
|
* Unlayer supports only passing id of container, but when we use shadowDOM (MFE),
|
|
@@ -91,6 +99,28 @@ export const createUnlayerEditor = (
|
|
|
91
99
|
return currentFind.call(document, id);
|
|
92
100
|
};
|
|
93
101
|
|
|
102
|
+
const acv = constGenericsEditor.adminConfigProperty;
|
|
103
|
+
const unitsConfig = (units ?? []).reduce((out, unit) => {
|
|
104
|
+
out[`custom#${unit.generic}:unit:${unit.id}`] = {
|
|
105
|
+
data: {
|
|
106
|
+
[acv]: unit.values[acv],
|
|
107
|
+
},
|
|
108
|
+
properties: {
|
|
109
|
+
[constGenericsEditor.userConfigProperty]: {
|
|
110
|
+
editor: {
|
|
111
|
+
data: { [acv]: unit.values[acv] },
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
[constGenericsEditor.infoDataProperty]: {
|
|
115
|
+
editor: {
|
|
116
|
+
data: { title: unit.title },
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
return out;
|
|
122
|
+
}, {} as Record<string, any>);
|
|
123
|
+
|
|
94
124
|
const result = (window as any).unlayer.createEditor({
|
|
95
125
|
displayMode: 'web',
|
|
96
126
|
devices: ['desktop'],
|
|
@@ -120,12 +150,13 @@ export const createUnlayerEditor = (
|
|
|
120
150
|
divider: { enabled: false },
|
|
121
151
|
}
|
|
122
152
|
: {}),
|
|
153
|
+
...unitsConfig,
|
|
123
154
|
},
|
|
124
155
|
editor: {
|
|
125
156
|
autoSelectOnDrop: true,
|
|
126
157
|
},
|
|
127
158
|
customJS: customScripts,
|
|
128
|
-
customCSS:
|
|
159
|
+
customCSS: customStyles,
|
|
129
160
|
id,
|
|
130
161
|
fonts: {
|
|
131
162
|
showDefaultFonts: true,
|