@agilemotion/oui-react-js 1.8.57 → 1.8.59

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.
@@ -4,503 +4,52 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _ej2ReactDocumenteditor = require("@syncfusion/ej2-react-documenteditor");
8
- var _ej2Base = require("@syncfusion/ej2-base");
9
- var _react = _interopRequireWildcard(require("react"));
10
- var React = _react;
7
+ var React = _interopRequireWildcard(require("react"));
11
8
  require("./DocumentTemplateDesignerComponent.css");
12
- var _ApplicationManager = _interopRequireDefault(require("../ApplicationManager"));
9
+ var _DocumentViewer = _interopRequireDefault(require("./DocumentViewer"));
13
10
  var _Form = _interopRequireDefault(require("./form/Form"));
14
- var _EventType = _interopRequireDefault(require("../event/EventType"));
15
- var _Observable = _interopRequireDefault(require("../event/Observable"));
16
- var _Utils = _interopRequireDefault(require("../Utils"));
17
- var _reactPromiseTracker = require("react-promise-tracker");
18
- var _WordDocumentViewer = require("./WordDocumentViewer");
19
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
12
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
21
- (0, _ej2Base.registerLicense)(_WordDocumentViewer.KEY);
22
- _ej2ReactDocumenteditor.DocumentEditorContainerComponent.Inject(_ej2ReactDocumenteditor.Toolbar);
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
18
  const DocumentTemplateDesignerComponent = props => {
24
- const {
25
- contractTemplate,
26
- uploadTrigger,
27
- valueChangeHandler,
28
- addDocumentMetaDataHandler,
29
- value
30
- } = props;
31
- const [container, setContainer] = React.useState(null);
32
- const model = React.useRef({});
19
+ const propertiesComponentHandle = React.useState({});
20
+ const templateDesignerComponentHandle = React.useState({});
33
21
  const [doc, setDoc] = React.useState(null);
34
- const [file, setFile] = React.useState(null);
35
- const [documentData, setDocumentData] = React.useState(null);
36
- const [contentState] = React.useState({
37
- changed: false
38
- });
39
- const btnRef = (0, _react.useRef)(null);
40
- const currentVal = (0, _react.useRef)(null);
41
- const propertiesFormHandle = React.useRef({});
42
- const onToolbarClick = args => {
43
- switch (args.item.id) {
44
- case "Custom":
45
- break;
46
- default:
47
- break;
48
- }
49
- };
50
- const onWrapText = text => {
51
- let content = '';
52
- const index = text.lastIndexOf(' ');
53
- if (index !== -1) {
54
- content = text.slice(0, index) + "<div class='e-de-text-wrap'>" + text.slice(index + 1) + "</div>";
55
- } else {
56
- content = text;
57
- }
58
- return content;
59
- };
60
- const findNext = () => {
61
- container.documentEditor.search.searchResults.index = container.documentEditor.search.searchResults.index + 1;
62
- };
63
- const findPrev = () => {
64
- container.documentEditor.search.searchResults.index = container.documentEditor.search.searchResults.index - 1;
65
- };
66
- let next = {
67
- prefixIcon: "e-chevron-down",
68
- click: findNext.bind(void 0),
69
- tooltipText: 'Next placeholder',
70
- text: '',
71
- id: "NextPlaceHolder"
72
- };
73
- let previous = {
74
- prefixIcon: "e-chevron-up",
75
- click: findPrev.bind(void 0),
76
- tooltipText: 'Previous placeholder',
77
- text: '',
78
- id: "PrevPlaceHolder"
79
- };
80
- let apply = {
81
- prefixIcon: "e-icons e-save",
82
- click: applyChanges.bind(void 0),
83
- tooltipText: 'Previous placeholder',
84
- text: 'Apply',
85
- id: "PrevPlaceHolder"
86
- };
87
- let items = ["Open", apply, "Undo", "Redo", "Separator", {
88
- tooltipText: 'Bold',
89
- prefixIcon: 'e-icons e-bold',
90
- command: 'Bold'
91
- }, {
92
- tooltipText: 'Italic',
93
- prefixIcon: 'e-icons e-italic',
94
- command: 'Italic'
95
- }, "Separator", "Image", "Table", "Separator", "Header", "Footer", "PageSetup", "PageNumber", "InsertFootnote", "Separator", "Find"];
96
- let searchHighlightColor = {
97
- searchHighlightColor: 'Red'
98
- };
99
- const saveDoc = () => {
100
- return new Promise((accept, reject) => {
101
- if (container && container.documentEditor) {
102
- container.documentEditor.saveAsBlob('Docx').then(blob => {
103
- accept(blob);
104
- }).catch(e => {
105
- console.error("Error saving document");
106
- reject(e);
107
- });
108
- }
109
- });
110
- };
111
- const onContentChange = () => {
112
- contentState.changed = true;
113
- };
114
- (0, _react.useEffect)(() => {
115
- if (uploadTrigger != null && btnRef.current) {
116
- btnRef.current.click();
117
- }
118
- }, [uploadTrigger]);
119
- (0, _react.useEffect)(() => {
120
- if (value) {
121
- let i = 0;
122
- for (const property of value.properties) {
123
- property.id = i++;
124
- }
125
- propertiesFormHandle.current.api.model = {
126
- properties: value.properties
127
- };
128
- if (value.file && value.file.url) {
129
- let tokens = value.file.url.split(';base64,');
130
- let type = tokens[0].replace("data:", "");
131
- let base64 = tokens[1];
132
- const arrayBuffer = _Utils.default.base64ToArrayBuffer(base64);
133
- const file = new Blob([arrayBuffer], {
134
- type
135
- });
136
- const formData = new FormData();
137
- formData.append('files', file, 'document.docx');
138
- (0, _reactPromiseTracker.trackPromise)(fetch("".concat(_WordDocumentViewer.DOCSVC, "Import"), {
139
- method: 'POST',
140
- body: formData
141
- }).then(response => {
142
- (0, _reactPromiseTracker.trackPromise)(response.json().then(json => {
143
- setDocumentData(json);
144
- }));
145
- }));
146
- }
147
- }
148
- }, [value]);
149
- const getFooterText = () => {
150
- container.documentEditor.selection.goToFooter();
151
- container.documentEditor.selection.selectAll();
152
- let footerText = container.documentEditor.selection.getText();
153
- container.documentEditor.selection.closeHeaderFooter();
154
- container.documentEditor.selection.clear();
155
- return footerText;
156
- };
157
- function applyChanges() {
158
- setup();
159
- }
160
- const comparePositions = (a, b) => {
161
- if (a.location.yIn === b.location.yIn && a.location.xIn === b.location.xIn) {
162
- return 0;
163
- }
164
- if (a.location.yIn > b.location.yIn) {
165
- return 1;
166
- }
167
- if (a.location.yIn < b.location.yIn) {
168
- return -1;
169
- }
170
- if (a.location.yIn === b.location.yIn) {
171
- if (a.location.xIn < b.location.xIn) {
172
- return -1;
173
- } else {
174
- return 1;
175
- }
176
- }
177
- return 0;
178
- };
179
- const getSearchStartPosition = (anchorPosition, searchList) => {
180
- if (!anchorPosition) {
181
- return searchList[0].startIn;
182
- }
183
- for (const searchListElement of searchList) {
184
- if (comparePositions(searchListElement.startIn, anchorPosition) >= 0) {
185
- return searchListElement.startIn;
186
- }
187
- }
188
- return anchorPosition;
189
- };
190
- const getSearchEndPosition = (anchorPosition, searchList) => {
191
- if (!anchorPosition) {
192
- return searchList[0].endIn;
193
- }
194
- for (const searchListElement of searchList) {
195
- if (comparePositions(searchListElement.endIn, anchorPosition) >= 0) {
196
- return searchListElement.endIn;
197
- }
198
- }
199
- return anchorPosition;
200
- };
201
- function generateSubstrings(sentence) {
202
- let substrings = [];
203
- for (let i = 0; i < sentence.length; i++) {
204
- substrings.push(sentence.substring(0, i + 1)); // Add substring from index 0 to i
205
- }
206
- return substrings;
207
- }
208
- function detectWordWrap(anchorPosition, startPosition, endPosition, editor, sentence, startY) {
209
- let substrings = generateSubstrings(sentence);
210
- let wordWrapAnchorPosition = anchorPosition;
211
- let wordWrapPositions = [];
212
- if (substrings.length === 1) {
213
- wordWrapPositions.push({
214
- startPosition,
215
- endPosition
216
- });
217
- } else {
218
- let wordWrapTokens = [];
219
- let currentY = startY;
220
- let wordWrapIndex = 0;
221
- let pos = 0;
222
- for (const substring of substrings) {
223
- container.documentEditor.search.find(substring);
224
- let endPosition = getSearchEndPosition(wordWrapAnchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
225
- wordWrapAnchorPosition = endPosition;
226
- if (endPosition.location.yIn > currentY) {
227
- wordWrapTokens.push(sentence.substring(wordWrapIndex, pos));
228
- currentY = endPosition.location.yIn;
229
- wordWrapIndex = pos;
230
- }
231
- pos++;
232
- }
233
-
234
- //Add last substring
235
- wordWrapTokens.push(sentence.substring(wordWrapIndex, sentence.length));
236
- //console.log("\n\n\n\n\nWORD WRAP TOKENS : [" + wordWrapIndex + "]", wordWrapTokens);
237
- for (const wordWrapToken of wordWrapTokens) {
238
- container.documentEditor.search.find(wordWrapToken);
239
- let startPosition = getSearchStartPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
240
- let endPosition = getSearchEndPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
241
- wordWrapPositions.push({
242
- startPosition,
243
- endPosition
244
- });
245
- }
246
- }
247
- return wordWrapPositions;
248
- }
249
- const setPlaceholderPositions = prop => {
250
- console.log("SETTING PLACE HOLDER POSITIONS FOR : " + prop.placeHolder);
251
- container.documentEditor.search.find(prop.originalText);
252
- let searchResults = container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList;
253
- prop.positions = [];
254
- for (const searchResult of searchResults) {
255
- if (searchResult.endIn.location.yIn > searchResult.startIn.location.yIn) {
256
- let positions = detectWordWrap(searchResult.startIn, searchResult.startIn, searchResult.endIn, container.documentEditor, prop.originalText, searchResult.startIn.location.yIn);
257
- for (const position of positions) {
258
- prop.positions.push({
259
- start: {
260
- paragraph: {
261
- x: position.startPosition.currentWidget.paragraph.x,
262
- y: position.startPosition.currentWidget.paragraph.y,
263
- height: position.startPosition.currentWidget.paragraph.height
264
- },
265
- x: position.startPosition.location.xIn,
266
- y: position.startPosition.location.yIn
267
- },
268
- end: {
269
- paragraph: {
270
- x: position.endPosition.currentWidget.paragraph.x,
271
- y: position.endPosition.currentWidget.paragraph.y,
272
- height: position.endPosition.currentWidget.paragraph.height
273
- },
274
- x: position.endPosition.location.xIn,
275
- y: position.endPosition.location.yIn
276
- }
277
- });
278
- }
279
- } else {
280
- prop.positions.push({
281
- start: {
282
- paragraph: {
283
- x: searchResult.startIn.currentWidget.paragraph.x,
284
- y: searchResult.startIn.currentWidget.paragraph.y,
285
- height: searchResult.startIn.currentWidget.paragraph.height
286
- },
287
- x: searchResult.startIn.location.xIn,
288
- y: searchResult.startIn.location.yIn
289
- },
290
- end: {
291
- paragraph: {
292
- x: searchResult.endIn.currentWidget.paragraph.x,
293
- y: searchResult.endIn.currentWidget.paragraph.y,
294
- height: searchResult.endIn.currentWidget.paragraph.height
295
- },
296
- x: searchResult.endIn.location.xIn,
297
- y: searchResult.endIn.location.yIn
298
- }
299
- });
300
- }
301
- }
302
- console.log(prop);
303
- console.log("\n\n");
304
- };
305
- function setup() {
306
- let initialFormValue = {
307
- properties: []
308
- };
309
- if (container) {
310
- container.documentEditor.selection.selectAll();
311
- const text = container.documentEditor.selection.getText();
312
- container.documentEditor.selection.clear();
313
- const bodyMatches = removeNextLineCharsFromPlaceholders(text, '<<', '>>');
314
- const footerText = getFooterText();
315
- let footerMatches = removeNextLineCharsFromPlaceholders(footerText, '<<', '>>');
316
- const matches = bodyMatches.concat(footerMatches);
317
-
318
- //container.documentEditor.editor.enforceProtection('password', 'CommentsOnly');
319
- //container.documentEditor.search.findAll(/<<[\s\S]*?>>/g);
320
-
321
- matches.forEach(match => {
322
- let prop = model.current.properties.find(p => p.placeHolder === match.text);
323
- if (!prop) {
324
- prop = {
325
- placeHolder: match.text
326
- };
327
- }
328
- prop.originalText = match.originalText;
329
- setPlaceholderPositions(prop);
330
- if (!initialFormValue.properties.find(p => p.placeHolder === match.text)) {
331
- initialFormValue.properties.push(prop);
332
- }
333
- });
334
- let i = 0;
335
- for (const property of initialFormValue.properties) {
336
- property.id = i++;
337
- }
338
- propertiesFormHandle.current.api.bindData(initialFormValue);
339
- saveDoc().then(blob => {
340
- const newFile = new File([blob], props.documentName, {
341
- type: blob.type
342
- });
343
- setFile(newFile);
344
- if (contentState.changed) {
345
- if (!initialFormValue) {
346
- valueChangeHandler(null);
347
- } else {
348
- let newVal = validateProps(initialFormValue.properties) ? {
349
- properties: initialFormValue.properties,
350
- file: newFile
351
- } : null;
352
- valueChangeHandler(newVal);
353
- }
354
- }
355
- contentState.changed = false;
356
- });
357
- }
358
- }
359
- (0, _react.useEffect)(() => {
360
- setup();
361
- }, [doc]);
362
- (0, _react.useEffect)(() => {
363
- if (container && documentData) {
364
- container.documentEditor.open(JSON.stringify(documentData));
365
- }
366
- }, [documentData]);
367
- const validateProps = properties => {
368
- let valid = properties && properties.length > 0;
369
- if (valid) {
370
- for (const property of properties) {
371
- if (!property.valueField) {
372
- valid = false;
373
- break;
374
- }
375
- }
376
- }
377
- return valid;
378
- };
379
- const removeNextLineCharsFromPlaceholders = (text, startTag, endTag) => {
380
- const matches = [];
381
- let index = 0;
382
- while (index < text.length) {
383
- const startIndex = text.indexOf(startTag, index);
384
- if (startIndex === -1) break;
385
- const endIndex = text.indexOf(endTag, startIndex + startTag.length);
386
- if (endIndex === -1) break;
387
- let find = text.substring(startIndex, endIndex + endTag.length);
388
- let split = find.split("\r");
389
- if (split.length > 1) {
390
- container.documentEditor.search.find(split[0]);
391
- let startPosition = container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList[0].startIn;
392
- container.documentEditor.search.find(split[split.length - 1]);
393
- let endPosition = container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList[0].endIn;
394
- let selection = container.documentEditor.selection;
395
- selection.selectRange(startPosition, endPosition);
396
- if (selection && selection.start && selection.end) {
397
- let selectedText = selection.getText();
398
- container.documentEditor.editor.delete();
399
- container.documentEditor.editor.insertText(selectedText.replace(/(\r\n|\n|\r)/gm, ""));
400
- } else {
401
- console.error("No valid selection found");
402
- }
403
- }
404
- matches.push({
405
- originalText: find,
406
- start: startIndex,
407
- end: endIndex + endTag.length,
408
- text: find.replace(/(\r\n|\n|\r)/gm, "")
409
- });
410
- index = endIndex + endTag.length;
411
- }
412
- return matches;
413
- };
414
- function setupContainer() {
415
- container.documentEditor.currentUser = _ApplicationManager.default.getUserDetails().name + " " + _ApplicationManager.default.getUserDetails().surname;
416
- }
417
- (0, _react.useEffect)(() => {
418
- if (container) {
419
- setupContainer();
420
- //autoSave();
421
-
422
- const editor = container.documentEditor;
423
- editor.addEventListener("keyDown", event => {
424
- const startPosition = container.documentEditor.selection.start;
425
- let selectedProperty;
426
- for (const property of model.current.properties) {
427
- for (const position of property.positions) {
428
- if (position.start.y === startPosition.location.yIn && position.start.x <= startPosition.location.xIn && position.end.x >= startPosition.location.xIn) {
429
- selectedProperty = property;
430
- break;
431
- }
432
- }
433
- }
434
- if (selectedProperty) {
435
- event.event.preventDefault();
436
- if (event.event.key === "Backspace") {
437
- // For some reason, preventDefault does not work on the backspace key so we throw this exception as a temporary measure to prevent it
438
- throw new Error("Backspace pressed on restricted area");
439
- }
440
- }
441
- });
442
- }
443
- }, [container]);
444
- (0, _react.useEffect)(() => {
22
+ React.useEffect(() => {
445
23
  props.handle.api = api();
446
24
  });
447
- (0, _react.useEffect)(() => {
448
- props.handle.api = api();
449
- let eventHandlingConfig = {};
450
- let defaultAction = {
451
- actionType: 'script',
452
- script: {
453
- lines: ["@#{this}.highlightSelection($event.data)"]
454
- }
455
- };
456
- eventHandlingConfig.subscriptions = [];
457
- let subscription = {
458
- publisher: 'propertiesGrid',
459
- eventType: _EventType.default.SELECTION_CHANGE,
460
- actions: [defaultAction]
461
- };
462
- eventHandlingConfig.subscriptions.push(subscription);
463
- _Observable.default.addSubscriptions(_Utils.default.parseConfig({
464
- id: props.id + "DocTemplateDesigner",
465
- eventHandlingConfig
466
- }, props.viewId).eventHandlingConfig, props.handle, props.viewId);
467
- return () => {
468
- _Observable.default.clearComponentEventListeners(props.handle);
469
- };
470
- }, []);
471
- const doHighlightSelection = selectedPropertyRows => {
472
- if (container && selectedPropertyRows && selectedPropertyRows.length > 0) {
473
- container.documentEditor.selection.clear();
474
- container.documentEditor.search.find(selectedPropertyRows[0].placeHolder);
475
- }
476
- };
477
- const saveAsBase64 = async () => {
478
- if (props.allowUnresolvedChanges === false && container.documentEditor.revisions.length > 0) {
479
- setErrorMessage("Please accept or reject all suggested changes");
480
- return null;
481
- }
482
- if (container) {
483
- var _props$file, _props$file2;
484
- container.documentEditor.editor.stopProtection("password");
485
- let blob = await container.documentEditor.saveAsBlob('Docx');
486
- if (props.commentsOnly) {
487
- container.documentEditor.editor.enforceProtection('password', 'CommentsOnly');
488
- }
489
- return new File([blob], (_props$file = props.file) !== null && _props$file !== void 0 && _props$file.name ? props.file.name : 'document.docx', {
490
- type: (_props$file2 = props.file) !== null && _props$file2 !== void 0 && _props$file2.type ? props.file.type : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
491
- });
25
+ React.useEffect(() => {
26
+ if (props.value) {
27
+ propertiesComponentHandle.api.model = {
28
+ properties: props.value.properties
29
+ };
492
30
  }
493
- };
31
+ }, [props.value]);
494
32
  const api = () => {
495
33
  return {
496
34
  get id() {
497
- return props.id + "DocTemplateDesigner";
35
+ return props.id + "-templateDesignerComponent";
498
36
  },
499
- highlightSelection: selectedPropertyRow => {
500
- doHighlightSelection(selectedPropertyRow);
37
+ getChildren: () => {
38
+ return [propertiesComponentHandle, templateDesignerComponentHandle];
501
39
  },
502
40
  getValue: () => {
503
- return saveAsBase64();
41
+ if (templateDesignerComponentHandle.api) {
42
+ return {
43
+ file: templateDesignerComponentHandle.api.getValue(),
44
+ properties: propertiesComponentHandle.api.value
45
+ };
46
+ }
47
+ },
48
+ getDocumentValue: async () => {
49
+ if (templateDesignerComponentHandle.api) {
50
+ return templateDesignerComponentHandle.api.getDocumentValue();
51
+ }
52
+ return null;
504
53
  }
505
54
  };
506
55
  };
@@ -511,88 +60,39 @@ const DocumentTemplateDesignerComponent = props => {
511
60
  }
512
61
  }, /*#__PURE__*/React.createElement("div", {
513
62
  style: {
514
- width: "40%",
515
- overflow: "auto",
63
+ width: "25%",
64
+ overflow: "hidden",
516
65
  minHeight: "250px",
517
66
  height: "100%",
518
- border: "1px solid #e1e1e1",
519
67
  borderRadius: '4px',
520
- marginRight: "4px"
68
+ padding: "0 16px"
521
69
  }
522
70
  }, /*#__PURE__*/React.createElement("div", {
523
71
  style: {
524
- width: "100%",
525
- fontSize: "12px",
526
- backgroundColor: "#fafafa",
527
- padding: "8px",
528
- height: "77px",
529
- color: "rgba(0, 0, 0, 0.87)",
530
- borderBottom: "#f1f1f1",
531
- display: "flex",
532
- alignItems: "center"
533
- }
534
- }, "Properties"), /*#__PURE__*/React.createElement("div", {
535
- style: {
536
- width: "100%",
72
+ width: "calc(100% - 8px)",
537
73
  marginTop: "4px",
538
- padding: "0 8px"
74
+ padding: "0",
75
+ overflowY: "hidden",
76
+ maxHeight: "100%"
539
77
  }
540
78
  }, /*#__PURE__*/React.createElement(_Form.default, {
541
- config: props.propertiesFormConfig,
542
- handle: propertiesFormHandle.current,
543
- valueChangeHandler: React.useCallback(val => {
544
- model.current = val;
545
- let newVal = validateProps(val.properties) ? val : null;
546
- if (JSON.stringify(currentVal.current) !== JSON.stringify(newVal === null || newVal === void 0 ? void 0 : newVal.properties)) {
547
- if (newVal) {
548
- valueChangeHandler({
549
- properties: val.properties,
550
- file
551
- });
552
- currentVal.current = val.properties;
553
- } else {
554
- if (currentVal.current) {
555
- currentVal.current = null;
556
- valueChangeHandler(null);
557
- }
558
- }
559
- }
560
- }, [file]),
79
+ config: props.propertiesForm,
80
+ handle: propertiesComponentHandle,
561
81
  viewId: props.viewId,
562
82
  className: 'defaultForm'
563
83
  }))), props.visible && /*#__PURE__*/React.createElement("div", {
564
84
  className: 'col no-margin no-padding',
565
85
  style: {
566
- maxWidth: 'calc(60% - 16px)',
86
+ maxWidth: '75%',
567
87
  height: '100%'
568
88
  }
569
- }, /*#__PURE__*/React.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
570
- id: "container",
571
- height: '590px',
572
- ref: scope => {
573
- setContainer(scope);
574
- },
575
- created: () => {
576
- if (container) {
577
- container.resize();
578
- container.documentEditor.resize();
579
- }
580
- },
581
- documentChange: doc => {
582
- if (container) {
583
- setupContainer();
584
- }
585
- setDoc(doc);
586
- }
587
- //documentEditorSettings={searchHighlightColor}
588
- ,
589
- showPropertiesPane: false,
590
- enableTrackChanges: false,
591
- toolbarItems: items,
592
- toolbarClick: onToolbarClick,
593
- contentChange: onContentChange,
594
- serviceUrl: _WordDocumentViewer.DOCSVC,
595
- enableToolbar: true
89
+ }, /*#__PURE__*/React.createElement(_DocumentViewer.default, {
90
+ config: props.templateViewer,
91
+ handle: templateDesignerComponentHandle,
92
+ viewId: props.viewId,
93
+ onValueChange: file => props.valueChangeHandler(_objectSpread(_objectSpread({}, propertiesComponentHandle.api.value), {}, {
94
+ file: file
95
+ }))
596
96
  })));
597
97
  };
598
98
  var _default = exports.default = DocumentTemplateDesignerComponent;
@@ -169,9 +169,12 @@ const DocumentViewer = /*#__PURE__*/_react.default.memo(/*#__PURE__*/_react.defa
169
169
  file: value,
170
170
  onDocumentLoadSuccess: () => {},
171
171
  valueHandler: wordEditorValueHandler,
172
- valueChangeHandler: () => {
172
+ valueChangeHandler: file => {
173
173
  let event = new _Event.default(props.handle, props.viewId, null);
174
174
  _Observable.default.fireEvent(_EventType.default.VALUE_CHANGE, event);
175
+ if (props.onValueChange) {
176
+ props.onValueChange(file);
177
+ }
175
178
  },
176
179
  allowUnresolvedChanges: _Utils.default.evaluateBooleanExpression(parsedConfig.allowUnresolvedChanges, props.config.id),
177
180
  disableRejectChanges: _Utils.default.evaluateBooleanExpression(parsedConfig.disableRejectChanges, props.config.id),