@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.
Files changed (45) hide show
  1. package/dist/api-core.js +29 -22
  2. package/dist/api-core.js.map +1 -1
  3. package/dist/api-custom-tools.js +35 -42
  4. package/dist/api-custom-tools.js.map +1 -1
  5. package/dist/editor-core-source.d.ts +3 -3
  6. package/dist/editor-core-source.d.ts.map +1 -1
  7. package/dist/editor-core-source.js +4 -4
  8. package/dist/editor-core-source.js.map +1 -1
  9. package/dist/editor-core.js +2 -2
  10. package/dist/editor-core.js.map +1 -1
  11. package/dist/editor.js +73 -34
  12. package/dist/editor.js.map +1 -1
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/loadScript.d.ts.map +1 -1
  16. package/dist/loadScript.js +7 -6
  17. package/dist/loadScript.js.map +1 -1
  18. package/dist/shared/const.js +2 -1
  19. package/dist/shared/const.js.map +1 -1
  20. package/dist/shared/edit-icon.js +1 -0
  21. package/dist/shared/edit-icon.js.map +1 -1
  22. package/dist/shared/fonts.js +24 -17
  23. package/dist/shared/fonts.js.map +1 -1
  24. package/dist/shared/schema.d.ts.map +1 -1
  25. package/dist/shared/schema.js +91 -49
  26. package/dist/shared/schema.js.map +1 -1
  27. package/dist/shared/tools.d.ts.map +1 -1
  28. package/dist/shared/tools.js +13 -6
  29. package/dist/shared/tools.js.map +1 -1
  30. package/dist/store.d.ts +5 -5
  31. package/dist/store.d.ts.map +1 -1
  32. package/dist/store.js +235 -315
  33. package/dist/store.js.map +1 -1
  34. package/dist/tools.d.ts.map +1 -1
  35. package/dist/tools.js +120 -112
  36. package/dist/tools.js.map +1 -1
  37. package/dist/unlayer-interface.js +2 -1
  38. package/dist/unlayer-interface.js.map +1 -1
  39. package/dist/unlayer.d.ts +1 -0
  40. package/dist/unlayer.d.ts.map +1 -1
  41. package/dist/unlayer.js +115 -70
  42. package/dist/unlayer.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/editor-core-source.ts +3 -3
  45. package/src/unlayer.tsx +11 -1
package/dist/store.js CHANGED
@@ -1,16 +1,20 @@
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
- };
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, } from './unlayer';
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
- Object.defineProperty(this, "props", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: props
37
- });
38
- Object.defineProperty(this, "unlayerRef", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "editor", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- Object.defineProperty(this, "isInit", {
51
- enumerable: true,
52
- configurable: true,
53
- writable: true,
54
- value: false
55
- });
56
- Object.defineProperty(this, "iframe", {
57
- enumerable: true,
58
- configurable: true,
59
- writable: true,
60
- value: void 0
61
- });
62
- Object.defineProperty(this, "hasDesign", {
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
- Object.defineProperty(this, "addTwin", {
132
- enumerable: true,
133
- configurable: true,
134
- writable: true,
135
- value: (twin) => {
136
- var _a;
137
- (_a = this.props.toolTwins) === null || _a === void 0 ? void 0 : _a.push(twin);
138
- this.sendMessage('--add-twin', JSON.parse(JSON.stringify(twin)));
139
- }
140
- });
141
- Object.defineProperty(this, "setDesign", {
142
- enumerable: true,
143
- configurable: true,
144
- writable: true,
145
- value: (design) => {
146
- if (!this.editor) {
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
- Object.defineProperty(this, "setOnChange", {
156
- enumerable: true,
157
- configurable: true,
158
- writable: true,
159
- value: (onChange) => {
160
- this.onChangeCB = onChange;
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
- Object.defineProperty(this, "setOnSnapshotSave", {
164
- enumerable: true,
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
- Object.defineProperty(this, "setOnReady", {
172
- enumerable: true,
173
- configurable: true,
174
- writable: true,
175
- value: (onReady) => {
176
- this.onReadyCB = onReady;
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
- Object.defineProperty(this, "setOnImage", {
180
- enumerable: true,
181
- configurable: true,
182
- writable: true,
183
- value: (onImage) => {
184
- this.onImageCB = onImage;
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
- Object.defineProperty(this, "setOnMessage", {
188
- enumerable: true,
189
- configurable: true,
190
- writable: true,
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
- Object.defineProperty(this, "onDesignLoaded", {
196
- enumerable: true,
197
- configurable: true,
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
- Object.defineProperty(this, "onDesignUpdated", {
211
- enumerable: true,
212
- configurable: true,
213
- writable: true,
214
- value: (event) => {
215
- var _a, _b;
216
- const isToolAdded = !eventsNotAddingTools.includes(event.type);
217
- const isToolsListChanged = !eventsNotChangingToolsList.includes(event.type);
218
- if (isToolAdded) {
219
- (_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
220
- var _a;
221
- let hasChanges = false;
222
- unlayerToolsIterate(data.design, tool => {
223
- var _a;
224
- const realTool = tool.slug
225
- ? unlayerToolsParseTwinKey((_a = tool.slug) !== null && _a !== void 0 ? _a : '')
226
- : undefined;
227
- if (realTool) {
228
- hasChanges = true;
229
- if (tool.slug) {
230
- delete data.design.counters[`u_content_custom_${tool.slug}`];
231
- delete tool.values._meta.htmlID;
232
- }
233
- tool.type = realTool.type;
234
- tool.slug = realTool.slug;
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
- if (hasChanges) {
238
- this.setDesign(data.design);
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
- Object.defineProperty(this, "onPostMessage", {
249
- enumerable: true,
250
- configurable: true,
251
- writable: true,
252
- value: (e) => {
253
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
254
- if (!((_a = e.data) === null || _a === void 0 ? void 0 : _a['-dte-message-from'])) {
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
- (_j = this.onMessageCB) === null || _j === void 0 ? void 0 : _j.call(this, type, data);
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
- Object.defineProperty(this, "sendMessage", {
307
- enumerable: true,
308
- configurable: true,
309
- writable: true,
310
- value: (type, data) => {
311
- var _a, _b;
312
- (_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage({
313
- '-dte-message-to': {
314
- type,
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
- Object.defineProperty(this, "uploadImage", {
321
- enumerable: true,
322
- configurable: true,
323
- writable: true,
324
- value: (data, done) => {
325
- var _a;
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 _a;
342
- (_a = this.editor) === null || _a === void 0 ? void 0 : _a.loadDesign(design);
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 _a;
346
- (_a = this.editor) === null || _a === void 0 ? void 0 : _a.saveDesign(cb);
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 _a;
350
- (_a = this.editor) === null || _a === void 0 ? void 0 : _a.exportHtml(data => {
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