@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.
@@ -10,36 +10,35 @@ var _UseIsVisible = require("../UseIsVisible");
10
10
  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); }
11
11
  /* eslint-disable react-hooks/exhaustive-deps */
12
12
 
13
- const ToolbarButton = props => {
14
- var _props$root;
13
+ const ToolbarButton = _ref => {
14
+ let {
15
+ children,
16
+ root,
17
+ onVisibilityChange,
18
+ id
19
+ } = _ref;
15
20
  const ref = (0, _react.useRef)();
16
- const isVisible = (0, _UseIsVisible.useIsVisible)(ref, (_props$root = props.root) === null || _props$root === void 0 ? void 0 : _props$root.current);
17
- const [visible, setVisible] = (0, _react.useState)(null);
18
- const [contentWidth, setContentWidth] = (0, _react.useState)(null);
19
- const {
20
- children
21
- } = props;
21
+ const isVisible = (0, _UseIsVisible.useIsVisible)(ref, root === null || root === void 0 ? void 0 : root.current);
22
+ const last = (0, _react.useRef)(null);
22
23
  (0, _react.useEffect)(() => {
23
- if (visible === null) {
24
- setVisible(true);
25
- } else {
26
- setVisible(isVisible);
27
- props.onVisibilityChange(isVisible);
28
- if (isVisible) {
29
- setContentWidth(ref.current.getBoundingClientRect().right - ref.current.getBoundingClientRect().left);
30
- }
24
+ if (last.current !== isVisible) {
25
+ last.current = isVisible;
26
+ onVisibilityChange === null || onVisibilityChange === void 0 || onVisibilityChange(isVisible);
31
27
  }
32
28
  }, [isVisible]);
33
29
  return /*#__PURE__*/_react.default.createElement("div", {
34
30
  ref: ref,
35
31
  style: {
36
- width: isVisible ? '100%' : 0,
37
- minWidth: isVisible ? '100%' : 0
32
+ display: 'inline-flex',
33
+ alignItems: 'center',
34
+ visibility: isVisible ? 'visible' : 'hidden',
35
+ pointerEvents: isVisible ? 'auto' : 'none',
36
+ height: '100%',
37
+ maxHeight: '100%',
38
+ width: '100%',
39
+ minWidth: 'unset',
40
+ whiteSpace: 'nowrap'
38
41
  }
39
- }, !isVisible ? /*#__PURE__*/_react.default.createElement("div", {
40
- style: {
41
- width: contentWidth ? contentWidth : '100%'
42
- }
43
- }, "\xA0") : children);
42
+ }, children);
44
43
  };
45
44
  var _default = exports.default = ToolbarButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilemotion/oui-react-js",
3
- "version": "1.8.57",
3
+ "version": "1.8.59",
4
4
  "description": "AgileMotion React UI Component Library - A comprehensive collection of dashboard components, forms, media controls, and more",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -54,16 +54,16 @@
54
54
  "@mui/styles": "^6.4.6",
55
55
  "@mui/x-date-pickers": "^7.27.1",
56
56
  "@mui/x-tree-view": "^7.26.0",
57
- "@syncfusion/ej2-base": "^26.2.10",
58
- "@syncfusion/ej2-buttons": "^26.2.10",
59
- "@syncfusion/ej2-documenteditor": "^26.2.14",
60
- "@syncfusion/ej2-lists": "^26.2.14",
61
- "@syncfusion/ej2-navigations": "^26.2.12",
62
- "@syncfusion/ej2-react-base": "^26.2.10",
63
- "@syncfusion/ej2-react-documenteditor": "^26.2.14",
64
- "@syncfusion/ej2-react-popups": "^26.2.11",
57
+ "@syncfusion/ej2-base": "^31.2.2",
58
+ "@syncfusion/ej2-buttons": "^31.2.2",
59
+ "@syncfusion/ej2-documenteditor": "^31.2.2",
60
+ "@syncfusion/ej2-lists": "^31.2.2",
61
+ "@syncfusion/ej2-navigations": "^31.2.2",
62
+ "@syncfusion/ej2-react-base": "^31.2.2",
63
+ "@syncfusion/ej2-react-documenteditor": "^31.2.2",
64
+ "@syncfusion/ej2-react-popups": "^31.2.2",
65
65
  "@syncfusion/ej2-react-splitbuttons": "^31.2.2",
66
- "@syncfusion/ej2-splitbuttons": "^26.2.10",
66
+ "@syncfusion/ej2-splitbuttons": "^31.2.2",
67
67
  "@testing-library/dom": "^10.4.0",
68
68
  "@testing-library/jest-dom": "^6.6.3",
69
69
  "@testing-library/react": "^16.3.0",
@@ -1,584 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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;
11
- require("./DocumentTemplateDesignerComponent.css");
12
- var _ApplicationManager = _interopRequireDefault(require("../ApplicationManager"));
13
- 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
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- 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); }
20
- (0, _ej2Base.registerLicense)('ORg4AjUWIQA/Gnt2U1hhQlJBfV5AQmBIYVp/TGpJfl96cVxMZVVBJAtUQF1hTX5adkJiWHtWdXBXT2Je');
21
- _ej2ReactDocumenteditor.DocumentEditorContainerComponent.Inject(_ej2ReactDocumenteditor.Toolbar);
22
- const DocumentTemplateDesignerComponent = props => {
23
- const {
24
- contractTemplate,
25
- uploadTrigger,
26
- valueChangeHandler,
27
- addDocumentMetaDataHandler,
28
- value
29
- } = props;
30
- const [container, setContainer] = React.useState(null);
31
- const model = React.useRef({});
32
- const [doc, setDoc] = React.useState(null);
33
- const [file, setFile] = React.useState(null);
34
- const [documentData, setDocumentData] = React.useState(null);
35
- const [contentState] = React.useState({
36
- changed: false
37
- });
38
- const btnRef = (0, _react.useRef)(null);
39
- const currentVal = (0, _react.useRef)(null);
40
- const propertiesFormHandle = React.useRef({});
41
- const onToolbarClick = args => {
42
- switch (args.item.id) {
43
- case "Custom":
44
- break;
45
- default:
46
- break;
47
- }
48
- };
49
- const onWrapText = text => {
50
- let content = '';
51
- const index = text.lastIndexOf(' ');
52
- if (index !== -1) {
53
- content = text.slice(0, index) + "<div class='e-de-text-wrap'>" + text.slice(index + 1) + "</div>";
54
- } else {
55
- content = text;
56
- }
57
- return content;
58
- };
59
- const findNext = () => {
60
- container.documentEditor.search.searchResults.index = container.documentEditor.search.searchResults.index + 1;
61
- };
62
- const findPrev = () => {
63
- container.documentEditor.search.searchResults.index = container.documentEditor.search.searchResults.index - 1;
64
- };
65
- let next = {
66
- prefixIcon: "e-chevron-down",
67
- click: findNext.bind(void 0),
68
- tooltipText: 'Next placeholder',
69
- text: '',
70
- id: "NextPlaceHolder"
71
- };
72
- let previous = {
73
- prefixIcon: "e-chevron-up",
74
- click: findPrev.bind(void 0),
75
- tooltipText: 'Previous placeholder',
76
- text: '',
77
- id: "PrevPlaceHolder"
78
- };
79
- let apply = {
80
- prefixIcon: "e-icons e-save",
81
- click: applyChanges.bind(void 0),
82
- tooltipText: 'Previous placeholder',
83
- text: 'Apply',
84
- id: "PrevPlaceHolder"
85
- };
86
- let items = ["Open", apply, "Undo", "Redo", "Separator", {
87
- tooltipText: 'Bold',
88
- prefixIcon: 'e-icons e-bold',
89
- command: 'Bold'
90
- }, {
91
- tooltipText: 'Italic',
92
- prefixIcon: 'e-icons e-italic',
93
- command: 'Italic'
94
- }, "Separator", "Image", "Table", "Separator", "Header", "Footer", "PageSetup", "PageNumber", "InsertFootnote", "Separator", "Find"];
95
- let searchHighlightColor = {
96
- searchHighlightColor: 'Red'
97
- };
98
- const saveDoc = () => {
99
- return new Promise((accept, reject) => {
100
- if (container && container.documentEditor) {
101
- container.documentEditor.saveAsBlob('Docx').then(blob => {
102
- accept(blob);
103
- }).catch(e => {
104
- console.error("Error saving document");
105
- reject(e);
106
- });
107
- }
108
- });
109
- };
110
- const onContentChange = () => {
111
- contentState.changed = true;
112
- };
113
- (0, _react.useEffect)(() => {
114
- if (uploadTrigger != null && btnRef.current) {
115
- btnRef.current.click();
116
- }
117
- }, [uploadTrigger]);
118
- (0, _react.useEffect)(() => {
119
- if (value) {
120
- let i = 0;
121
- for (const property of value.properties) {
122
- property.id = i++;
123
- }
124
- propertiesFormHandle.current.api.model = {
125
- properties: value.properties
126
- };
127
- if (value.file && value.file.url) {
128
- let tokens = value.file.url.split(';base64,');
129
- let type = tokens[0].replace("data:", "");
130
- let base64 = tokens[1];
131
- const arrayBuffer = _Utils.default.base64ToArrayBuffer(base64);
132
- const file = new Blob([arrayBuffer], {
133
- type
134
- });
135
- const formData = new FormData();
136
- formData.append('files', file, 'document.docx');
137
- (0, _reactPromiseTracker.trackPromise)(fetch('https://ej2services.syncfusion.com/production/web-services/api/documenteditor/Import', {
138
- method: 'POST',
139
- body: formData
140
- }).then(response => {
141
- (0, _reactPromiseTracker.trackPromise)(response.json().then(json => {
142
- setDocumentData(json);
143
- }));
144
- }));
145
- }
146
- }
147
- }, [value]);
148
- const getFooterText = () => {
149
- container.documentEditor.selection.goToFooter();
150
- container.documentEditor.selection.selectAll();
151
- let footerText = container.documentEditor.selection.getText();
152
- container.documentEditor.selection.closeHeaderFooter();
153
- container.documentEditor.selection.clear();
154
- return footerText;
155
- };
156
- function applyChanges() {
157
- setup();
158
- }
159
- function setup() {
160
- let initialFormValue = {
161
- properties: []
162
- };
163
- if (container) {
164
- container.documentEditor.selection.selectAll();
165
- const text = container.documentEditor.selection.getText();
166
- container.documentEditor.selection.clear();
167
- const bodyMatches = removeNextLineCharsFromPlaceholders(text, '<<', '>>');
168
- const footerText = getFooterText();
169
- let footerMatches = removeNextLineCharsFromPlaceholders(footerText, '<<', '>>');
170
- const matches = bodyMatches.concat(footerMatches);
171
-
172
- //container.documentEditor.editor.enforceProtection('password', 'CommentsOnly');
173
- //container.documentEditor.search.findAll(/<<[\s\S]*?>>/g);
174
-
175
- if (model.current.properties) {
176
- matches.forEach(match => {
177
- let prop = model.current.properties.find(p => p.placeHolder === match.text);
178
- let indexData = {
179
- start: match.start,
180
- end: match.end,
181
- linePositions: match.linePositions
182
- };
183
- if (!prop) {
184
- prop = {
185
- placeHolder: match.text,
186
- indexes: [indexData]
187
- };
188
- } else {
189
- if (!prop.indexes) {
190
- prop.indexes = [];
191
- }
192
- prop.indexes.push(indexData);
193
- }
194
- if (!initialFormValue.properties.find(p => p.placeHolder === match.text)) {
195
- initialFormValue.properties.push(prop);
196
- }
197
- });
198
- let i = 0;
199
- for (const property of initialFormValue.properties) {
200
- property.id = i++;
201
- }
202
- propertiesFormHandle.current.api.bindData(initialFormValue);
203
- saveDoc().then(blob => {
204
- const newFile = new File([blob], props.documentName, {
205
- type: blob.type
206
- });
207
- setFile(newFile);
208
- if (contentState.changed) {
209
- if (!initialFormValue) {
210
- valueChangeHandler(null);
211
- } else {
212
- let newVal = validateProps(initialFormValue.properties) ? {
213
- properties: initialFormValue.properties,
214
- file: newFile
215
- } : null;
216
- valueChangeHandler(newVal);
217
- }
218
- }
219
- contentState.changed = false;
220
- });
221
- }
222
- }
223
- }
224
- (0, _react.useEffect)(() => {
225
- setup();
226
- }, [doc]);
227
- (0, _react.useEffect)(() => {
228
- if (container && documentData) {
229
- container.documentEditor.open(JSON.stringify(documentData));
230
- }
231
- }, [documentData]);
232
- const validateProps = properties => {
233
- let valid = properties && properties.length > 0;
234
- if (valid) {
235
- for (const property of properties) {
236
- if (!property.valueField) {
237
- valid = false;
238
- break;
239
- }
240
- }
241
- }
242
- return valid;
243
- };
244
- const getLinePositions = (line, anchorPosition) => {
245
- let linePositions = [];
246
- container.documentEditor.search.find(line);
247
- let searchList = container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList;
248
- let startPosition = getSearchStartPosition(anchorPosition, searchList);
249
- let endPosition = getSearchEndPosition(anchorPosition, searchList);
250
- console.log("\n\n\n\n\n\nSEARCH LIST : ", endPosition.location.yIn);
251
- console.log(endPosition);
252
- for (const textSearchResult of searchList) {
253
- console.log(textSearchResult.endIn.location.yIn);
254
- }
255
- console.log("CHECKING WORD WRAP [" + line + "] : " + startPosition.location.yIn + " - " + endPosition.location.yIn);
256
- // We have a word wrap if this condition is true
257
- console.log("WORD WRAP JOINT ", detectWordWrap(anchorPosition, startPosition, endPosition, container.documentEditor, line, endPosition.location.yIn));
258
- if (startPosition.location.yIn < endPosition.location.yIn) {
259
- linePositions.push({
260
- startX: startPosition.location.xIn,
261
- startY: startPosition.location.yIn,
262
- endX: endPosition.location.xIn,
263
- endY: endPosition.location.yIn
264
- });
265
- console.log("\n\n\n\n\n\nMATHATA : [" + line + "]");
266
- console.log(startPosition.location.xIn + " : " + endPosition.location.xIn);
267
- console.log(startPosition.location.yIn + " : " + endPosition.location.yIn);
268
- } else {
269
- linePositions.push({
270
- startX: startPosition.location.xIn,
271
- startY: startPosition.location.yIn,
272
- endX: endPosition.location.xIn,
273
- endY: endPosition.location.yIn
274
- });
275
- }
276
- return {
277
- endPosition,
278
- linePositions
279
- };
280
- };
281
- const removeNextLineCharsFromPlaceholders = (text, startTag, endTag) => {
282
- const matches = [];
283
- let index = 0;
284
- let anchorPosition = null;
285
- while (index < text.length) {
286
- const startIndex = text.indexOf(startTag, index);
287
- if (startIndex === -1) break;
288
- const endIndex = text.indexOf(endTag, startIndex + startTag.length);
289
- if (endIndex === -1) break;
290
- let find = text.substring(startIndex, endIndex + endTag.length);
291
- let split = find.split("\r");
292
- let linePositions = [];
293
-
294
- //container.documentEditor.selection.start.setPositionInternal(startIndex);
295
-
296
- if (split.length > 1) {
297
- container.documentEditor.search.find(split[0]);
298
- let startPosition = getSearchStartPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
299
- container.documentEditor.search.find(split[split.length - 1]);
300
- let endPosition = getSearchEndPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
301
- let selection = container.documentEditor.selection;
302
- selection.selectRange(startPosition, endPosition);
303
- if (selection && selection.start && selection.end) {
304
- let selectedText = selection.getText();
305
- container.documentEditor.editor.delete();
306
- container.documentEditor.editor.insertText(selectedText.replace(/(\r\n|\n|\r)/gm, ""));
307
- for (const token of split) {
308
- let placeholderLinePositions = getLinePositions(token, anchorPosition);
309
- anchorPosition = placeholderLinePositions.endPosition;
310
- linePositions.push(placeholderLinePositions.linePositions);
311
- }
312
- } else {
313
- console.error("No valid selection found");
314
- }
315
- } else {
316
- let placeholderLinePositions = getLinePositions(split[0], anchorPosition);
317
- anchorPosition = placeholderLinePositions.endPosition;
318
- linePositions.push(placeholderLinePositions.linePositions);
319
- }
320
- matches.push({
321
- start: startIndex,
322
- end: endIndex + endTag.length,
323
- text: find.replace(/(\r\n|\n|\r)/gm, ""),
324
- linePositions: linePositions
325
- });
326
- index = endIndex + endTag.length;
327
- }
328
- return matches;
329
- };
330
- const comparePositions = (a, b) => {
331
- if (a.location.yIn === b.location.yIn && a.location.xIn === b.location.xIn) {
332
- return 0;
333
- }
334
- if (a.location.yIn > b.location.yIn) {
335
- return 1;
336
- }
337
- if (a.location.yIn < b.location.yIn) {
338
- return -1;
339
- }
340
- if (a.location.yIn === b.location.yIn) {
341
- if (a.location.xIn < b.location.xIn) {
342
- return -1;
343
- } else {
344
- return 1;
345
- }
346
- }
347
- return 0;
348
- };
349
- const getSearchStartPosition = (anchorPosition, searchList) => {
350
- if (!anchorPosition) {
351
- return searchList[0].startIn;
352
- }
353
- for (const searchListElement of searchList) {
354
- if (comparePositions(searchListElement.startIn, anchorPosition) >= 0) {
355
- return searchListElement.startIn;
356
- }
357
- }
358
- return anchorPosition;
359
- };
360
- const getSearchEndPosition = (anchorPosition, searchList) => {
361
- if (!anchorPosition) {
362
- return searchList[0].endIn;
363
- }
364
- for (const searchListElement of searchList) {
365
- if (comparePositions(searchListElement.endIn, anchorPosition) >= 0) {
366
- return searchListElement.endIn;
367
- }
368
- }
369
- return anchorPosition;
370
- };
371
- function detectWordWrap(anchorPosition, startPosition, endPosition, editor, sentence, startY) {
372
- let substrings = generateSubstrings(sentence);
373
- let wordWrapPositions = [];
374
- let wordWrapAnchorPosition = anchorPosition;
375
-
376
- //container.documentEditor.selection.select(startPosition, endPosition);
377
-
378
- let prevPosition = startPosition;
379
- let currentY = startY;
380
- console.log("SUBSTRINGS FOR [" + sentence + "] : ", substrings);
381
- console.log("ANCHOR : ", anchorPosition);
382
- for (const substring of substrings) {
383
- container.documentEditor.search.find(substring);
384
- let endPosition = getSearchEndPosition(wordWrapAnchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
385
- wordWrapAnchorPosition = endPosition;
386
- //container.documentEditor.selection.select(startPosition, endPosition);
387
-
388
- console.log("[" + sentence + "] " + endPosition.location.yIn + " : " + currentY);
389
- if (endPosition.location.yIn > currentY) {
390
- wordWrapPositions.push({
391
- prevPosition,
392
- endPosition
393
- });
394
- currentY = endPosition.location.yIn;
395
- prevPosition = endPosition;
396
- }
397
- console.log(substring + " - " + endPosition.location.yIn);
398
- }
399
- if (wordWrapPositions.length === 0) {
400
- wordWrapPositions.push({
401
- startPosition,
402
- endPosition
403
- });
404
- }
405
- return wordWrapPositions;
406
- }
407
- function generateSubstrings(sentence) {
408
- let substrings = [];
409
- for (let i = 0; i < sentence.length; i++) {
410
- substrings.push(sentence.substring(0, i + 1)); // Add substring from index 0 to i
411
- }
412
- return substrings;
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 index of property.indexes) {
428
- for (const linePosition of index.linePositions) {
429
- console.log(property.placeHolder + "START X : " + linePosition.startX + " END X : " + linePosition.endX + " - CURSOR X : " + startPosition.location.xIn + " CURSOR Y : " + startPosition.location.yIn);
430
- if (linePosition.startY === startPosition.location.yIn && linePosition.startX <= startPosition.location.xIn && linePosition.endX >= startPosition.location.xIn) {
431
- console.log("PHAKATI");
432
- selectedProperty = property;
433
- break;
434
- } else {
435
- console.log("TEST 1 : " + (linePosition.startY === startPosition.location.yIn) + " TEST 2 " + (linePosition.startX <= startPosition.location.xIn) + " TEST 3 " + (linePosition.endX >= startPosition.location.xIn));
436
- }
437
- }
438
- if (selectedProperty) {
439
- break;
440
- }
441
- }
442
- }
443
- if (selectedProperty) {
444
- console.log("\n\n\n\n\nPREVENTING DEFAULT [" + selectedProperty.placeHolder + "]");
445
- event.event.preventDefault();
446
- }
447
- });
448
- }
449
- }, [container]);
450
- (0, _react.useEffect)(() => {
451
- props.handle.api = api();
452
- });
453
- (0, _react.useEffect)(() => {
454
- props.handle.api = api();
455
- let eventHandlingConfig = {};
456
- let defaultAction = {
457
- actionType: 'script',
458
- script: {
459
- lines: ["@#{this}.highlightSelection($event.data)"]
460
- }
461
- };
462
- eventHandlingConfig.subscriptions = [];
463
- let subscription = {
464
- publisher: 'propertiesGrid',
465
- eventType: _EventType.default.SELECTION_CHANGE,
466
- actions: [defaultAction]
467
- };
468
- eventHandlingConfig.subscriptions.push(subscription);
469
- _Observable.default.addSubscriptions(_Utils.default.parseConfig({
470
- id: props.id + "DocTemplateDesigner",
471
- eventHandlingConfig
472
- }, props.viewId).eventHandlingConfig, props.handle, props.viewId);
473
- return () => {
474
- _Observable.default.clearComponentEventListeners(props.handle);
475
- };
476
- }, []);
477
- const doHighlightSelection = selectedPropertyRows => {
478
- if (container && selectedPropertyRows && selectedPropertyRows.length > 0) {
479
- container.documentEditor.selection.clear();
480
- container.documentEditor.search.find(selectedPropertyRows[0].placeHolder);
481
- }
482
- };
483
- const api = () => {
484
- return {
485
- get id() {
486
- return props.id + "DocTemplateDesigner";
487
- },
488
- highlightSelection: selectedPropertyRow => {
489
- doHighlightSelection(selectedPropertyRow);
490
- }
491
- };
492
- };
493
- return /*#__PURE__*/React.createElement("div", {
494
- className: 'row no-margin no-padding',
495
- style: {
496
- height: "100%"
497
- }
498
- }, /*#__PURE__*/React.createElement("div", {
499
- style: {
500
- width: "40%",
501
- overflow: "auto",
502
- minHeight: "250px",
503
- height: "100%",
504
- border: "1px solid #e1e1e1",
505
- borderRadius: '4px',
506
- marginRight: "4px"
507
- }
508
- }, /*#__PURE__*/React.createElement("div", {
509
- style: {
510
- width: "100%",
511
- fontSize: "12px",
512
- backgroundColor: "#fafafa",
513
- padding: "8px",
514
- height: "77px",
515
- color: "rgba(0, 0, 0, 0.87)",
516
- borderBottom: "#f1f1f1",
517
- display: "flex",
518
- alignItems: "center"
519
- }
520
- }, "Properties"), /*#__PURE__*/React.createElement("div", {
521
- style: {
522
- width: "100%",
523
- marginTop: "4px",
524
- padding: "0 8px"
525
- }
526
- }, /*#__PURE__*/React.createElement(_Form.default, {
527
- config: props.propertiesFormConfig,
528
- handle: propertiesFormHandle.current,
529
- valueChangeHandler: React.useCallback(val => {
530
- model.current = val;
531
- let newVal = validateProps(val.properties) ? val : null;
532
- if (JSON.stringify(currentVal.current) !== JSON.stringify(newVal === null || newVal === void 0 ? void 0 : newVal.properties)) {
533
- if (newVal) {
534
- valueChangeHandler({
535
- properties: val.properties,
536
- file
537
- });
538
- currentVal.current = val.properties;
539
- } else {
540
- if (currentVal.current) {
541
- currentVal.current = null;
542
- valueChangeHandler(null);
543
- }
544
- }
545
- }
546
- }, [file]),
547
- viewId: props.viewId,
548
- className: 'defaultForm'
549
- }))), props.visible && /*#__PURE__*/React.createElement("div", {
550
- className: 'col no-margin no-padding',
551
- style: {
552
- maxWidth: 'calc(60% - 16px)',
553
- height: '100%'
554
- }
555
- }, /*#__PURE__*/React.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
556
- id: "container",
557
- height: '590px',
558
- ref: scope => {
559
- setContainer(scope);
560
- },
561
- created: () => {
562
- if (container) {
563
- container.resize();
564
- container.documentEditor.resize();
565
- }
566
- },
567
- documentChange: doc => {
568
- if (container) {
569
- setupContainer();
570
- }
571
- setDoc(doc);
572
- }
573
- //documentEditorSettings={searchHighlightColor}
574
- ,
575
- showPropertiesPane: false,
576
- enableTrackChanges: false,
577
- toolbarItems: items,
578
- toolbarClick: onToolbarClick,
579
- contentChange: onContentChange,
580
- serviceUrl: "https://services.syncfusion.com/react/production/api/documenteditor/",
581
- enableToolbar: true
582
- })));
583
- };
584
- var _default = exports.default = DocumentTemplateDesignerComponent;