@servicetitan/dte-unlayer 0.89.0 → 0.90.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/api-core.js +29 -22
- package/dist/api-core.js.map +1 -1
- package/dist/api-custom-tools.js +35 -42
- package/dist/api-custom-tools.js.map +1 -1
- package/dist/editor-core-source.d.ts +3 -3
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +4 -4
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor-core.js +2 -2
- package/dist/editor-core.js.map +1 -1
- package/dist/editor.js +73 -34
- package/dist/editor.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/loadScript.d.ts.map +1 -1
- package/dist/loadScript.js +7 -6
- package/dist/loadScript.js.map +1 -1
- package/dist/shared/const.js +2 -1
- package/dist/shared/const.js.map +1 -1
- package/dist/shared/edit-icon.js +1 -0
- package/dist/shared/edit-icon.js.map +1 -1
- package/dist/shared/fonts.js +24 -17
- package/dist/shared/fonts.js.map +1 -1
- package/dist/shared/schema.d.ts.map +1 -1
- package/dist/shared/schema.js +91 -49
- package/dist/shared/schema.js.map +1 -1
- package/dist/shared/tools.d.ts.map +1 -1
- package/dist/shared/tools.js +13 -6
- package/dist/shared/tools.js.map +1 -1
- package/dist/store.d.ts +5 -5
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +235 -315
- package/dist/store.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +120 -112
- package/dist/tools.js.map +1 -1
- package/dist/unlayer-interface.js +2 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.d.ts +1 -0
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +115 -70
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/editor-core-source.ts +3 -3
- package/src/unlayer.tsx +11 -1
package/dist/store.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
10
14
|
import { loadScript } from './loadScript';
|
|
11
15
|
import { unlayerToolsParseTwinKey } from './shared/tools';
|
|
12
16
|
import { unlayerToolsIterate } from './tools';
|
|
13
|
-
import { createUnlayerEditor, DesignUpdatedEventType
|
|
17
|
+
import { createUnlayerEditor, DesignUpdatedEventType } from './unlayer';
|
|
14
18
|
const defaultScriptUrl = 'https://editor.unlayer.com/embed.js?2';
|
|
15
19
|
// We are using exclusive lists here, because we can't be sure that we know all unlayer event types
|
|
16
20
|
const eventsNotChangingToolsList = [
|
|
@@ -19,339 +23,255 @@ const eventsNotChangingToolsList = [
|
|
|
19
23
|
DesignUpdatedEventType.ColumnModified,
|
|
20
24
|
DesignUpdatedEventType.RowMoved,
|
|
21
25
|
DesignUpdatedEventType.RowModified,
|
|
22
|
-
DesignUpdatedEventType.BodyModified
|
|
26
|
+
DesignUpdatedEventType.BodyModified
|
|
23
27
|
];
|
|
24
28
|
const eventsNotAddingTools = [
|
|
25
29
|
...eventsNotChangingToolsList,
|
|
26
30
|
DesignUpdatedEventType.ContentRemoved,
|
|
27
31
|
DesignUpdatedEventType.ColumnRemoved,
|
|
28
|
-
DesignUpdatedEventType.RowRemoved
|
|
32
|
+
DesignUpdatedEventType.RowRemoved
|
|
29
33
|
];
|
|
30
34
|
export class UnlayerStore {
|
|
31
|
-
constructor(props)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: false
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(this, "onMessageCB", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
writable: true,
|
|
72
|
-
value: void 0
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(this, "onChangeCB", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: void 0
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(this, "onSnapshotSaveCB", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
configurable: true,
|
|
83
|
-
writable: true,
|
|
84
|
-
value: void 0
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(this, "onReadyCB", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
configurable: true,
|
|
89
|
-
writable: true,
|
|
90
|
-
value: void 0
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(this, "onImageCB", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
configurable: true,
|
|
95
|
-
writable: true,
|
|
96
|
-
value: void 0
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(this, "init", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: (container) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
var _a;
|
|
104
|
-
if (this.isInit) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.isInit = true;
|
|
108
|
-
setTimeout(() => window.addEventListener('message', this.onPostMessage));
|
|
109
|
-
yield loadScript(defaultScriptUrl);
|
|
110
|
-
this.editor = createUnlayerEditor(container, this.props);
|
|
111
|
-
this.editor.addEventListener('design:loaded', this.onDesignLoaded);
|
|
112
|
-
this.editor.addEventListener('design:updated', this.onDesignUpdated);
|
|
113
|
-
this.editor.registerCallback('image', this.uploadImage);
|
|
114
|
-
this.iframe = (_a = container.querySelector(`iframe`)) !== null && _a !== void 0 ? _a : undefined;
|
|
115
|
-
})
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(this, "destroy", {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
configurable: true,
|
|
120
|
-
writable: true,
|
|
121
|
-
value: () => {
|
|
122
|
-
window.removeEventListener('message', this.onPostMessage);
|
|
123
|
-
if (this.editor) {
|
|
124
|
-
this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
|
|
125
|
-
this.editor.removeEventListener('design:updated', this.onDesignUpdated);
|
|
126
|
-
this.editor.unregisterCallback('image', this.uploadImage);
|
|
127
|
-
this.editor = undefined;
|
|
128
|
-
}
|
|
35
|
+
constructor(props){
|
|
36
|
+
_define_property(this, "props", void 0);
|
|
37
|
+
_define_property(this, "unlayerRef", void 0);
|
|
38
|
+
_define_property(this, "editor", void 0);
|
|
39
|
+
_define_property(this, "isInit", void 0);
|
|
40
|
+
_define_property(this, "iframe", void 0);
|
|
41
|
+
_define_property(this, "hasDesign", void 0);
|
|
42
|
+
_define_property(this, "onMessageCB", void 0);
|
|
43
|
+
_define_property(this, "onChangeCB", void 0);
|
|
44
|
+
_define_property(this, "onSnapshotSaveCB", void 0);
|
|
45
|
+
_define_property(this, "onReadyCB", void 0);
|
|
46
|
+
_define_property(this, "onImageCB", void 0);
|
|
47
|
+
_define_property(this, "init", void 0);
|
|
48
|
+
_define_property(this, "destroy", void 0);
|
|
49
|
+
_define_property(this, "addTwin", void 0);
|
|
50
|
+
_define_property(this, "setDesign", void 0);
|
|
51
|
+
_define_property(this, "setOnChange", void 0);
|
|
52
|
+
_define_property(this, "setOnSnapshotSave", void 0);
|
|
53
|
+
_define_property(this, "setOnReady", void 0);
|
|
54
|
+
_define_property(this, "setOnImage", void 0);
|
|
55
|
+
_define_property(this, "setOnMessage", void 0);
|
|
56
|
+
_define_property(this, "onDesignLoaded", void 0);
|
|
57
|
+
_define_property(this, "onDesignUpdated", void 0);
|
|
58
|
+
_define_property(this, "onPostMessage", void 0);
|
|
59
|
+
_define_property(this, "sendMessage", void 0);
|
|
60
|
+
_define_property(this, "uploadImage", void 0);
|
|
61
|
+
this.props = props;
|
|
62
|
+
this.isInit = false;
|
|
63
|
+
this.hasDesign = false;
|
|
64
|
+
this.init = async (container)=>{
|
|
65
|
+
if (this.isInit) {
|
|
66
|
+
return;
|
|
129
67
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this.hasDesign = !!design;
|
|
150
|
-
if (design) {
|
|
151
|
-
this.editor.loadDesign(design);
|
|
152
|
-
}
|
|
68
|
+
this.isInit = true;
|
|
69
|
+
setTimeout(()=>window.addEventListener('message', this.onPostMessage));
|
|
70
|
+
await loadScript(defaultScriptUrl);
|
|
71
|
+
this.editor = createUnlayerEditor(container, this.props);
|
|
72
|
+
this.editor.addEventListener('design:loaded', this.onDesignLoaded);
|
|
73
|
+
this.editor.addEventListener('design:updated', this.onDesignUpdated);
|
|
74
|
+
this.editor.registerCallback('image', this.uploadImage);
|
|
75
|
+
var _container_querySelector;
|
|
76
|
+
this.iframe = (_container_querySelector = container.querySelector(`iframe`)) !== null && _container_querySelector !== void 0 ? _container_querySelector : undefined;
|
|
77
|
+
};
|
|
78
|
+
this.destroy = ()=>{
|
|
79
|
+
window.removeEventListener('message', this.onPostMessage);
|
|
80
|
+
if (this.editor) {
|
|
81
|
+
this.editor.removeEventListener('design:loaded', this.onDesignLoaded);
|
|
82
|
+
this.editor.removeEventListener('design:updated', this.onDesignUpdated);
|
|
83
|
+
this.editor.unregisterCallback('image', this.uploadImage);
|
|
84
|
+
this.editor = undefined;
|
|
153
85
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
86
|
+
};
|
|
87
|
+
this.addTwin = (twin)=>{
|
|
88
|
+
var _this_props_toolTwins;
|
|
89
|
+
(_this_props_toolTwins = this.props.toolTwins) === null || _this_props_toolTwins === void 0 ? void 0 : _this_props_toolTwins.push(twin);
|
|
90
|
+
this.sendMessage('--add-twin', JSON.parse(JSON.stringify(twin)));
|
|
91
|
+
};
|
|
92
|
+
this.setDesign = (design)=>{
|
|
93
|
+
if (!this.editor) {
|
|
94
|
+
return;
|
|
161
95
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
configurable: true,
|
|
166
|
-
writable: true,
|
|
167
|
-
value: (onSnapshotSave) => {
|
|
168
|
-
this.onSnapshotSaveCB = onSnapshotSave;
|
|
96
|
+
this.hasDesign = !!design;
|
|
97
|
+
if (design) {
|
|
98
|
+
this.editor.loadDesign(design);
|
|
169
99
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
100
|
+
};
|
|
101
|
+
this.setOnChange = (onChange)=>{
|
|
102
|
+
this.onChangeCB = onChange;
|
|
103
|
+
};
|
|
104
|
+
this.setOnSnapshotSave = (onSnapshotSave)=>{
|
|
105
|
+
this.onSnapshotSaveCB = onSnapshotSave;
|
|
106
|
+
};
|
|
107
|
+
this.setOnReady = (onReady)=>{
|
|
108
|
+
this.onReadyCB = onReady;
|
|
109
|
+
};
|
|
110
|
+
this.setOnImage = (onImage)=>{
|
|
111
|
+
this.onImageCB = onImage;
|
|
112
|
+
};
|
|
113
|
+
this.setOnMessage = (onMessage)=>{
|
|
114
|
+
this.onMessageCB = onMessage;
|
|
115
|
+
};
|
|
116
|
+
this.onDesignLoaded = ()=>{
|
|
117
|
+
if (!this.hasDesign) {
|
|
118
|
+
var _this_editor;
|
|
119
|
+
this.hasDesign = true;
|
|
120
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.setBodyValues({
|
|
121
|
+
backgroundColor: 'rgba(0,0,0,0)',
|
|
122
|
+
contentWidth: '100%'
|
|
123
|
+
});
|
|
177
124
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.
|
|
125
|
+
};
|
|
126
|
+
this.onDesignUpdated = (event)=>{
|
|
127
|
+
const isToolAdded = !eventsNotAddingTools.includes(event.type);
|
|
128
|
+
const isToolsListChanged = !eventsNotChangingToolsList.includes(event.type);
|
|
129
|
+
if (isToolAdded) {
|
|
130
|
+
var _this_editor;
|
|
131
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((data)=>{
|
|
132
|
+
var _this_onChangeCB, _this;
|
|
133
|
+
let hasChanges = false;
|
|
134
|
+
unlayerToolsIterate(data.design, (tool)=>{
|
|
135
|
+
var _tool_slug;
|
|
136
|
+
const realTool = tool.slug ? unlayerToolsParseTwinKey((_tool_slug = tool.slug) !== null && _tool_slug !== void 0 ? _tool_slug : '') : undefined;
|
|
137
|
+
if (realTool) {
|
|
138
|
+
hasChanges = true;
|
|
139
|
+
if (tool.slug) {
|
|
140
|
+
delete data.design.counters[`u_content_custom_${tool.slug}`];
|
|
141
|
+
delete tool.values._meta.htmlID;
|
|
142
|
+
}
|
|
143
|
+
tool.type = realTool.type;
|
|
144
|
+
tool.slug = realTool.slug;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (hasChanges) {
|
|
148
|
+
this.setDesign(data.design);
|
|
149
|
+
}
|
|
150
|
+
(_this_onChangeCB = (_this = this).onChangeCB) === null || _this_onChangeCB === void 0 ? void 0 : _this_onChangeCB.call(_this, {
|
|
151
|
+
isToolsListChanged
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
var _this_onChangeCB, _this;
|
|
156
|
+
(_this_onChangeCB = (_this = this).onChangeCB) === null || _this_onChangeCB === void 0 ? void 0 : _this_onChangeCB.call(_this, {
|
|
157
|
+
isToolsListChanged
|
|
158
|
+
});
|
|
185
159
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
value: (onMessage) => {
|
|
192
|
-
this.onMessageCB = onMessage;
|
|
160
|
+
};
|
|
161
|
+
this.onPostMessage = (e)=>{
|
|
162
|
+
var _e_data, _e_data_dtemessagefrom, _e_data1, _e_data_dtemessagefrom1, _e_data2, _this_onMessageCB, _this;
|
|
163
|
+
if (!((_e_data = e.data) === null || _e_data === void 0 ? void 0 : _e_data['-dte-message-from'])) {
|
|
164
|
+
return;
|
|
193
165
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
writable: true,
|
|
199
|
-
value: () => {
|
|
200
|
-
var _a;
|
|
201
|
-
if (!this.hasDesign) {
|
|
202
|
-
this.hasDesign = true;
|
|
203
|
-
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.setBodyValues({
|
|
204
|
-
backgroundColor: 'rgba(0,0,0,0)',
|
|
205
|
-
contentWidth: '100%',
|
|
206
|
-
});
|
|
207
|
-
}
|
|
166
|
+
const type = (_e_data1 = e.data) === null || _e_data1 === void 0 ? void 0 : (_e_data_dtemessagefrom = _e_data1['-dte-message-from']) === null || _e_data_dtemessagefrom === void 0 ? void 0 : _e_data_dtemessagefrom.type;
|
|
167
|
+
const data = (_e_data2 = e.data) === null || _e_data2 === void 0 ? void 0 : (_e_data_dtemessagefrom1 = _e_data2['-dte-message-from']) === null || _e_data_dtemessagefrom1 === void 0 ? void 0 : _e_data_dtemessagefrom1.data;
|
|
168
|
+
if (!type) {
|
|
169
|
+
return;
|
|
208
170
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
171
|
+
if (type === '--ready' || type === '--registered') {
|
|
172
|
+
var _this_onReadyCB, _this1;
|
|
173
|
+
(_this_onReadyCB = (_this1 = this).onReadyCB) === null || _this_onReadyCB === void 0 ? void 0 : _this_onReadyCB.call(_this1);
|
|
174
|
+
} else if (type === '--core-loaded') {
|
|
175
|
+
const data = {
|
|
176
|
+
dummyData: this.props.dummyData,
|
|
177
|
+
schema: this.props.schema,
|
|
178
|
+
generics: this.props.generics,
|
|
179
|
+
genericConfigMode: this.props.genericConfigMode,
|
|
180
|
+
isSnapshotMode: this.props.isSnapshotMode
|
|
181
|
+
};
|
|
182
|
+
this.sendMessage('--config', JSON.parse(JSON.stringify(data)));
|
|
183
|
+
} else if (type === '--data-loaded') {
|
|
184
|
+
var _this_props_units;
|
|
185
|
+
const data = {
|
|
186
|
+
customTools: this.props.tools.map((tool)=>({
|
|
187
|
+
key: tool.key
|
|
188
|
+
})),
|
|
189
|
+
toolTwins: this.props.toolTwins,
|
|
190
|
+
eSignRecipients: this.props.eSignRecipients,
|
|
191
|
+
eSignFieldTypes: this.props.eSignFieldTypes,
|
|
192
|
+
units: (_this_props_units = this.props.units) === null || _this_props_units === void 0 ? void 0 : _this_props_units.map((unit)=>({
|
|
193
|
+
...unit,
|
|
194
|
+
values: {
|
|
195
|
+
...unit.values,
|
|
196
|
+
adminConfig: undefined
|
|
197
|
+
}
|
|
198
|
+
}))
|
|
199
|
+
};
|
|
200
|
+
this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
|
|
201
|
+
} else if (type === '--save-snapshot') {
|
|
202
|
+
var _this_editor;
|
|
203
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((template)=>{
|
|
204
|
+
unlayerToolsIterate(template.design, (tool)=>{
|
|
205
|
+
var _tool_values_twin, _tool_values;
|
|
206
|
+
if (((_tool_values = tool.values) === null || _tool_values === void 0 ? void 0 : (_tool_values_twin = _tool_values.twin) === null || _tool_values_twin === void 0 ? void 0 : _tool_values_twin.id) === data.id) {
|
|
207
|
+
var _this_onSnapshotSaveCB, _this;
|
|
208
|
+
if (!tool.slug) {
|
|
209
|
+
return;
|
|
235
210
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
211
|
+
(_this_onSnapshotSaveCB = (_this = this).onSnapshotSaveCB) === null || _this_onSnapshotSaveCB === void 0 ? void 0 : _this_onSnapshotSaveCB.call(_this, {
|
|
212
|
+
title: '',
|
|
213
|
+
tool: tool.slug,
|
|
214
|
+
values: tool.values
|
|
215
|
+
});
|
|
216
|
+
return false;
|
|
239
217
|
}
|
|
240
|
-
(_a = this.onChangeCB) === null || _a === void 0 ? void 0 : _a.call(this, { isToolsListChanged });
|
|
241
218
|
});
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
(_b = this.onChangeCB) === null || _b === void 0 ? void 0 : _b.call(this, { isToolsListChanged });
|
|
245
|
-
}
|
|
219
|
+
});
|
|
246
220
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
const type = (_c = (_b = e.data) === null || _b === void 0 ? void 0 : _b['-dte-message-from']) === null || _c === void 0 ? void 0 : _c.type;
|
|
258
|
-
const data = (_e = (_d = e.data) === null || _d === void 0 ? void 0 : _d['-dte-message-from']) === null || _e === void 0 ? void 0 : _e.data;
|
|
259
|
-
if (!type) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
if (type === '--ready' || type === '--registered') {
|
|
263
|
-
(_f = this.onReadyCB) === null || _f === void 0 ? void 0 : _f.call(this);
|
|
264
|
-
}
|
|
265
|
-
else if (type === '--core-loaded') {
|
|
266
|
-
const data = {
|
|
267
|
-
dummyData: this.props.dummyData,
|
|
268
|
-
schema: this.props.schema,
|
|
269
|
-
generics: this.props.generics,
|
|
270
|
-
genericConfigMode: this.props.genericConfigMode,
|
|
271
|
-
isSnapshotMode: this.props.isSnapshotMode,
|
|
272
|
-
};
|
|
273
|
-
this.sendMessage('--config', JSON.parse(JSON.stringify(data)));
|
|
274
|
-
}
|
|
275
|
-
else if (type === '--data-loaded') {
|
|
276
|
-
const data = {
|
|
277
|
-
customTools: this.props.tools.map(tool => ({ key: tool.key })),
|
|
278
|
-
toolTwins: this.props.toolTwins,
|
|
279
|
-
eSignRecipients: this.props.eSignRecipients,
|
|
280
|
-
eSignFieldTypes: this.props.eSignFieldTypes,
|
|
281
|
-
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 }) }))),
|
|
282
|
-
};
|
|
283
|
-
this.sendMessage('--register', JSON.parse(JSON.stringify(data)));
|
|
284
|
-
}
|
|
285
|
-
else if (type === '--save-snapshot') {
|
|
286
|
-
(_h = this.editor) === null || _h === void 0 ? void 0 : _h.exportHtml(template => {
|
|
287
|
-
unlayerToolsIterate(template.design, tool => {
|
|
288
|
-
var _a, _b, _c;
|
|
289
|
-
if (((_b = (_a = tool.values) === null || _a === void 0 ? void 0 : _a.twin) === null || _b === void 0 ? void 0 : _b.id) === data.id) {
|
|
290
|
-
if (!tool.slug) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
(_c = this.onSnapshotSaveCB) === null || _c === void 0 ? void 0 : _c.call(this, {
|
|
294
|
-
title: '',
|
|
295
|
-
tool: tool.slug,
|
|
296
|
-
values: tool.values,
|
|
297
|
-
});
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
221
|
+
(_this_onMessageCB = (_this = this).onMessageCB) === null || _this_onMessageCB === void 0 ? void 0 : _this_onMessageCB.call(_this, type, data);
|
|
222
|
+
};
|
|
223
|
+
this.sendMessage = (type, data)=>{
|
|
224
|
+
var _this_iframe_contentWindow, _this_iframe;
|
|
225
|
+
(_this_iframe = this.iframe) === null || _this_iframe === void 0 ? void 0 : (_this_iframe_contentWindow = _this_iframe.contentWindow) === null || _this_iframe_contentWindow === void 0 ? void 0 : _this_iframe_contentWindow.postMessage({
|
|
226
|
+
'-dte-message-to': {
|
|
227
|
+
type,
|
|
228
|
+
data
|
|
302
229
|
}
|
|
303
|
-
|
|
230
|
+
}, '*');
|
|
231
|
+
};
|
|
232
|
+
this.uploadImage = (data, done)=>{
|
|
233
|
+
var _data_attachments;
|
|
234
|
+
if (!this.onImageCB) {
|
|
235
|
+
done({
|
|
236
|
+
progress: 100
|
|
237
|
+
});
|
|
238
|
+
throw new Error('image upload is not implemented');
|
|
304
239
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
data,
|
|
316
|
-
},
|
|
317
|
-
}, '*');
|
|
240
|
+
done({
|
|
241
|
+
progress: 0
|
|
242
|
+
});
|
|
243
|
+
if ((_data_attachments = data.attachments) === null || _data_attachments === void 0 ? void 0 : _data_attachments.length) {
|
|
244
|
+
this.onImageCB(data.attachments[0]).catch(()=>({
|
|
245
|
+
url: ''
|
|
246
|
+
})).then(({ url })=>done({
|
|
247
|
+
progress: 100,
|
|
248
|
+
url
|
|
249
|
+
}));
|
|
318
250
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (!this.onImageCB) {
|
|
327
|
-
done({ progress: 100 });
|
|
328
|
-
throw new Error('image upload is not implemented');
|
|
329
|
-
}
|
|
330
|
-
done({ progress: 0 });
|
|
331
|
-
if ((_a = data.attachments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
332
|
-
this.onImageCB(data.attachments[0])
|
|
333
|
-
.catch(() => ({ url: '' }))
|
|
334
|
-
.then(({ url }) => done({ progress: 100, url }));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
this.props.eSignFieldTypes = ['Signature', 'Initials', 'Date Signed', 'Full Name'];
|
|
251
|
+
};
|
|
252
|
+
this.props.eSignFieldTypes = [
|
|
253
|
+
'Signature',
|
|
254
|
+
'Initials',
|
|
255
|
+
'Date Signed',
|
|
256
|
+
'Full Name'
|
|
257
|
+
];
|
|
339
258
|
this.unlayerRef = {
|
|
340
|
-
loadDesign: design
|
|
341
|
-
var
|
|
342
|
-
(
|
|
259
|
+
loadDesign: (design)=>{
|
|
260
|
+
var _this_editor;
|
|
261
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.loadDesign(design);
|
|
343
262
|
},
|
|
344
|
-
saveDesign: cb
|
|
345
|
-
var
|
|
346
|
-
(
|
|
263
|
+
saveDesign: (cb)=>{
|
|
264
|
+
var _this_editor;
|
|
265
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.saveDesign(cb);
|
|
347
266
|
},
|
|
348
|
-
exportHtml: cb
|
|
349
|
-
var
|
|
350
|
-
(
|
|
267
|
+
exportHtml: (cb)=>{
|
|
268
|
+
var _this_editor;
|
|
269
|
+
(_this_editor = this.editor) === null || _this_editor === void 0 ? void 0 : _this_editor.exportHtml((data)=>{
|
|
351
270
|
cb(data);
|
|
352
271
|
});
|
|
353
|
-
}
|
|
272
|
+
}
|
|
354
273
|
};
|
|
355
274
|
}
|
|
356
275
|
}
|
|
276
|
+
|
|
357
277
|
//# sourceMappingURL=store.js.map
|