@agilemotion/oui-react-js 1.8.3 → 1.8.5
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/ApplicationManager.js +9 -0
- package/dist/DynamicJS.js +32 -8
- package/dist/RestService.js +1 -3
- package/dist/Utils.js +17 -8
- package/dist/components/Button.js +8 -1
- package/dist/components/Calendar.js +30 -23
- package/dist/components/DataGrid.js +44 -10
- package/dist/components/DocumentTemplateDesignerComponent.js +169 -0
- package/dist/components/DocumentTemplateDesignerComponent2.js +585 -0
- package/dist/components/Icon.js +10 -0
- package/dist/components/TableCellContent.js +35 -23
- package/dist/components/Toolbar.js +10 -1
- package/dist/components/form/BaseField.js +50 -27
- package/dist/components/form/Checkbox.js +3 -0
- package/dist/components/form/CurrencyField.js +109 -0
- package/dist/components/form/DatePicker.js +1 -0
- package/dist/components/form/FieldSet.js +18 -3
- package/dist/components/form/Form.js +14 -3
- package/dist/components/form/GridField.js +34 -25
- package/dist/components/form/LookupField.js +5 -4
- package/dist/components/form/RadioGroup.js +22 -9
- package/dist/components/form/SelectItem.js +9 -5
- package/dist/components/form/TransferList.js +2 -2
- package/dist/components/layout/CollapsiblePanel.css +9 -9
- package/dist/components/layout/View.css +68 -68
- package/dist/components/layout/ViewContainer.js +11 -2
- package/dist/components/layout/Window.js +2 -0
- package/dist/components/loader.css +36 -36
- package/dist/components/media/TrainingRoom.js +5 -0
- package/dist/components/media/Video.css +4 -4
- package/dist/components/signatures/ResponsiveTable.css +91 -91
- package/dist/components/signatures/widgets.css +126 -126
- package/dist/js/Validators.js +73 -2
- package/dist/view/Dashboard.js +13 -13
- package/package.json +10 -2
|
@@ -0,0 +1,585 @@
|
|
|
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 _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
(0, _ej2Base.registerLicense)('ORg4AjUWIQA/Gnt2U1hhQlJBfV5AQmBIYVp/TGpJfl96cVxMZVVBJAtUQF1hTX5adkJiWHtWdXBXT2Je');
|
|
22
|
+
_ej2ReactDocumenteditor.DocumentEditorContainerComponent.Inject(_ej2ReactDocumenteditor.Toolbar);
|
|
23
|
+
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({});
|
|
33
|
+
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('https://ej2services.syncfusion.com/production/web-services/api/documenteditor/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
|
+
function setup() {
|
|
161
|
+
let initialFormValue = {
|
|
162
|
+
properties: []
|
|
163
|
+
};
|
|
164
|
+
if (container) {
|
|
165
|
+
container.documentEditor.selection.selectAll();
|
|
166
|
+
const text = container.documentEditor.selection.getText();
|
|
167
|
+
container.documentEditor.selection.clear();
|
|
168
|
+
const bodyMatches = removeNextLineCharsFromPlaceholders(text, '<<', '>>');
|
|
169
|
+
const footerText = getFooterText();
|
|
170
|
+
let footerMatches = removeNextLineCharsFromPlaceholders(footerText, '<<', '>>');
|
|
171
|
+
const matches = bodyMatches.concat(footerMatches);
|
|
172
|
+
|
|
173
|
+
//container.documentEditor.editor.enforceProtection('password', 'CommentsOnly');
|
|
174
|
+
//container.documentEditor.search.findAll(/<<[\s\S]*?>>/g);
|
|
175
|
+
|
|
176
|
+
if (model.current.properties) {
|
|
177
|
+
matches.forEach(match => {
|
|
178
|
+
let prop = model.current.properties.find(p => p.placeHolder === match.text);
|
|
179
|
+
let indexData = {
|
|
180
|
+
start: match.start,
|
|
181
|
+
end: match.end,
|
|
182
|
+
linePositions: match.linePositions
|
|
183
|
+
};
|
|
184
|
+
if (!prop) {
|
|
185
|
+
prop = {
|
|
186
|
+
placeHolder: match.text,
|
|
187
|
+
indexes: [indexData]
|
|
188
|
+
};
|
|
189
|
+
} else {
|
|
190
|
+
if (!prop.indexes) {
|
|
191
|
+
prop.indexes = [];
|
|
192
|
+
}
|
|
193
|
+
prop.indexes.push(indexData);
|
|
194
|
+
}
|
|
195
|
+
if (!initialFormValue.properties.find(p => p.placeHolder === match.text)) {
|
|
196
|
+
initialFormValue.properties.push(prop);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
let i = 0;
|
|
200
|
+
for (const property of initialFormValue.properties) {
|
|
201
|
+
property.id = i++;
|
|
202
|
+
}
|
|
203
|
+
propertiesFormHandle.current.api.bindData(initialFormValue);
|
|
204
|
+
saveDoc().then(blob => {
|
|
205
|
+
const newFile = new File([blob], props.documentName, {
|
|
206
|
+
type: blob.type
|
|
207
|
+
});
|
|
208
|
+
setFile(newFile);
|
|
209
|
+
if (contentState.changed) {
|
|
210
|
+
if (!initialFormValue) {
|
|
211
|
+
valueChangeHandler(null);
|
|
212
|
+
} else {
|
|
213
|
+
let newVal = validateProps(initialFormValue.properties) ? {
|
|
214
|
+
properties: initialFormValue.properties,
|
|
215
|
+
file: newFile
|
|
216
|
+
} : null;
|
|
217
|
+
valueChangeHandler(newVal);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
contentState.changed = false;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
(0, _react.useEffect)(() => {
|
|
226
|
+
setup();
|
|
227
|
+
}, [doc]);
|
|
228
|
+
(0, _react.useEffect)(() => {
|
|
229
|
+
if (container && documentData) {
|
|
230
|
+
container.documentEditor.open(JSON.stringify(documentData));
|
|
231
|
+
}
|
|
232
|
+
}, [documentData]);
|
|
233
|
+
const validateProps = properties => {
|
|
234
|
+
let valid = properties && properties.length > 0;
|
|
235
|
+
if (valid) {
|
|
236
|
+
for (const property of properties) {
|
|
237
|
+
if (!property.valueField) {
|
|
238
|
+
valid = false;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return valid;
|
|
244
|
+
};
|
|
245
|
+
const getLinePositions = (line, anchorPosition) => {
|
|
246
|
+
let linePositions = [];
|
|
247
|
+
container.documentEditor.search.find(line);
|
|
248
|
+
let searchList = container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList;
|
|
249
|
+
let startPosition = getSearchStartPosition(anchorPosition, searchList);
|
|
250
|
+
let endPosition = getSearchEndPosition(anchorPosition, searchList);
|
|
251
|
+
console.log("\n\n\n\n\n\nSEARCH LIST : ", endPosition.location.yIn);
|
|
252
|
+
console.log(endPosition);
|
|
253
|
+
for (const textSearchResult of searchList) {
|
|
254
|
+
console.log(textSearchResult.endIn.location.yIn);
|
|
255
|
+
}
|
|
256
|
+
console.log("CHECKING WORD WRAP [" + line + "] : " + startPosition.location.yIn + " - " + endPosition.location.yIn);
|
|
257
|
+
// We have a word wrap if this condition is true
|
|
258
|
+
console.log("WORD WRAP JOINT ", detectWordWrap(anchorPosition, startPosition, endPosition, container.documentEditor, line, endPosition.location.yIn));
|
|
259
|
+
if (startPosition.location.yIn < endPosition.location.yIn) {
|
|
260
|
+
linePositions.push({
|
|
261
|
+
startX: startPosition.location.xIn,
|
|
262
|
+
startY: startPosition.location.yIn,
|
|
263
|
+
endX: endPosition.location.xIn,
|
|
264
|
+
endY: endPosition.location.yIn
|
|
265
|
+
});
|
|
266
|
+
console.log("\n\n\n\n\n\nMATHATA : [" + line + "]");
|
|
267
|
+
console.log(startPosition.location.xIn + " : " + endPosition.location.xIn);
|
|
268
|
+
console.log(startPosition.location.yIn + " : " + endPosition.location.yIn);
|
|
269
|
+
} else {
|
|
270
|
+
linePositions.push({
|
|
271
|
+
startX: startPosition.location.xIn,
|
|
272
|
+
startY: startPosition.location.yIn,
|
|
273
|
+
endX: endPosition.location.xIn,
|
|
274
|
+
endY: endPosition.location.yIn
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
endPosition,
|
|
279
|
+
linePositions
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
const removeNextLineCharsFromPlaceholders = (text, startTag, endTag) => {
|
|
283
|
+
const matches = [];
|
|
284
|
+
let index = 0;
|
|
285
|
+
let anchorPosition = null;
|
|
286
|
+
while (index < text.length) {
|
|
287
|
+
const startIndex = text.indexOf(startTag, index);
|
|
288
|
+
if (startIndex === -1) break;
|
|
289
|
+
const endIndex = text.indexOf(endTag, startIndex + startTag.length);
|
|
290
|
+
if (endIndex === -1) break;
|
|
291
|
+
let find = text.substring(startIndex, endIndex + endTag.length);
|
|
292
|
+
let split = find.split("\r");
|
|
293
|
+
let linePositions = [];
|
|
294
|
+
|
|
295
|
+
//container.documentEditor.selection.start.setPositionInternal(startIndex);
|
|
296
|
+
|
|
297
|
+
if (split.length > 1) {
|
|
298
|
+
container.documentEditor.search.find(split[0]);
|
|
299
|
+
let startPosition = getSearchStartPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
|
|
300
|
+
container.documentEditor.search.find(split[split.length - 1]);
|
|
301
|
+
let endPosition = getSearchEndPosition(anchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
|
|
302
|
+
let selection = container.documentEditor.selection;
|
|
303
|
+
selection.selectRange(startPosition, endPosition);
|
|
304
|
+
if (selection && selection.start && selection.end) {
|
|
305
|
+
let selectedText = selection.getText();
|
|
306
|
+
container.documentEditor.editor.delete();
|
|
307
|
+
container.documentEditor.editor.insertText(selectedText.replace(/(\r\n|\n|\r)/gm, ""));
|
|
308
|
+
for (const token of split) {
|
|
309
|
+
let placeholderLinePositions = getLinePositions(token, anchorPosition);
|
|
310
|
+
anchorPosition = placeholderLinePositions.endPosition;
|
|
311
|
+
linePositions.push(placeholderLinePositions.linePositions);
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
console.error("No valid selection found");
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
let placeholderLinePositions = getLinePositions(split[0], anchorPosition);
|
|
318
|
+
anchorPosition = placeholderLinePositions.endPosition;
|
|
319
|
+
linePositions.push(placeholderLinePositions.linePositions);
|
|
320
|
+
}
|
|
321
|
+
matches.push({
|
|
322
|
+
start: startIndex,
|
|
323
|
+
end: endIndex + endTag.length,
|
|
324
|
+
text: find.replace(/(\r\n|\n|\r)/gm, ""),
|
|
325
|
+
linePositions: linePositions
|
|
326
|
+
});
|
|
327
|
+
index = endIndex + endTag.length;
|
|
328
|
+
}
|
|
329
|
+
return matches;
|
|
330
|
+
};
|
|
331
|
+
const comparePositions = (a, b) => {
|
|
332
|
+
if (a.location.yIn === b.location.yIn && a.location.xIn === b.location.xIn) {
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
if (a.location.yIn > b.location.yIn) {
|
|
336
|
+
return 1;
|
|
337
|
+
}
|
|
338
|
+
if (a.location.yIn < b.location.yIn) {
|
|
339
|
+
return -1;
|
|
340
|
+
}
|
|
341
|
+
if (a.location.yIn === b.location.yIn) {
|
|
342
|
+
if (a.location.xIn < b.location.xIn) {
|
|
343
|
+
return -1;
|
|
344
|
+
} else {
|
|
345
|
+
return 1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return 0;
|
|
349
|
+
};
|
|
350
|
+
const getSearchStartPosition = (anchorPosition, searchList) => {
|
|
351
|
+
if (!anchorPosition) {
|
|
352
|
+
return searchList[0].startIn;
|
|
353
|
+
}
|
|
354
|
+
for (const searchListElement of searchList) {
|
|
355
|
+
if (comparePositions(searchListElement.startIn, anchorPosition) >= 0) {
|
|
356
|
+
return searchListElement.startIn;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return anchorPosition;
|
|
360
|
+
};
|
|
361
|
+
const getSearchEndPosition = (anchorPosition, searchList) => {
|
|
362
|
+
if (!anchorPosition) {
|
|
363
|
+
return searchList[0].endIn;
|
|
364
|
+
}
|
|
365
|
+
for (const searchListElement of searchList) {
|
|
366
|
+
if (comparePositions(searchListElement.endIn, anchorPosition) >= 0) {
|
|
367
|
+
return searchListElement.endIn;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return anchorPosition;
|
|
371
|
+
};
|
|
372
|
+
function detectWordWrap(anchorPosition, startPosition, endPosition, editor, sentence, startY) {
|
|
373
|
+
let substrings = generateSubstrings(sentence);
|
|
374
|
+
let wordWrapPositions = [];
|
|
375
|
+
let wordWrapAnchorPosition = anchorPosition;
|
|
376
|
+
|
|
377
|
+
//container.documentEditor.selection.select(startPosition, endPosition);
|
|
378
|
+
|
|
379
|
+
let prevPosition = startPosition;
|
|
380
|
+
let currentY = startY;
|
|
381
|
+
console.log("SUBSTRINGS FOR [" + sentence + "] : ", substrings);
|
|
382
|
+
console.log("ANCHOR : ", anchorPosition);
|
|
383
|
+
for (const substring of substrings) {
|
|
384
|
+
container.documentEditor.search.find(substring);
|
|
385
|
+
let endPosition = getSearchEndPosition(wordWrapAnchorPosition, container.documentEditor.search.searchResults.searchModule.textSearchResults.innerList);
|
|
386
|
+
wordWrapAnchorPosition = endPosition;
|
|
387
|
+
//container.documentEditor.selection.select(startPosition, endPosition);
|
|
388
|
+
|
|
389
|
+
console.log("[" + sentence + "] " + endPosition.location.yIn + " : " + currentY);
|
|
390
|
+
if (endPosition.location.yIn > currentY) {
|
|
391
|
+
wordWrapPositions.push({
|
|
392
|
+
prevPosition,
|
|
393
|
+
endPosition
|
|
394
|
+
});
|
|
395
|
+
currentY = endPosition.location.yIn;
|
|
396
|
+
prevPosition = endPosition;
|
|
397
|
+
}
|
|
398
|
+
console.log(substring + " - " + endPosition.location.yIn);
|
|
399
|
+
}
|
|
400
|
+
if (wordWrapPositions.length === 0) {
|
|
401
|
+
wordWrapPositions.push({
|
|
402
|
+
startPosition,
|
|
403
|
+
endPosition
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
return wordWrapPositions;
|
|
407
|
+
}
|
|
408
|
+
function generateSubstrings(sentence) {
|
|
409
|
+
let substrings = [];
|
|
410
|
+
for (let i = 0; i < sentence.length; i++) {
|
|
411
|
+
substrings.push(sentence.substring(0, i + 1)); // Add substring from index 0 to i
|
|
412
|
+
}
|
|
413
|
+
return substrings;
|
|
414
|
+
}
|
|
415
|
+
function setupContainer() {
|
|
416
|
+
container.documentEditor.currentUser = _ApplicationManager.default.getUserDetails().name + " " + _ApplicationManager.default.getUserDetails().surname;
|
|
417
|
+
}
|
|
418
|
+
(0, _react.useEffect)(() => {
|
|
419
|
+
if (container) {
|
|
420
|
+
setupContainer();
|
|
421
|
+
//autoSave();
|
|
422
|
+
|
|
423
|
+
const editor = container.documentEditor;
|
|
424
|
+
editor.addEventListener("keyDown", event => {
|
|
425
|
+
const startPosition = container.documentEditor.selection.start;
|
|
426
|
+
let selectedProperty;
|
|
427
|
+
for (const property of model.current.properties) {
|
|
428
|
+
for (const index of property.indexes) {
|
|
429
|
+
for (const linePosition of index.linePositions) {
|
|
430
|
+
console.log(property.placeHolder + "START X : " + linePosition.startX + " END X : " + linePosition.endX + " - CURSOR X : " + startPosition.location.xIn + " CURSOR Y : " + startPosition.location.yIn);
|
|
431
|
+
if (linePosition.startY === startPosition.location.yIn && linePosition.startX <= startPosition.location.xIn && linePosition.endX >= startPosition.location.xIn) {
|
|
432
|
+
console.log("PHAKATI");
|
|
433
|
+
selectedProperty = property;
|
|
434
|
+
break;
|
|
435
|
+
} else {
|
|
436
|
+
console.log("TEST 1 : " + (linePosition.startY === startPosition.location.yIn) + " TEST 2 " + (linePosition.startX <= startPosition.location.xIn) + " TEST 3 " + (linePosition.endX >= startPosition.location.xIn));
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (selectedProperty) {
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (selectedProperty) {
|
|
445
|
+
console.log("\n\n\n\n\nPREVENTING DEFAULT [" + selectedProperty.placeHolder + "]");
|
|
446
|
+
event.event.preventDefault();
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}, [container]);
|
|
451
|
+
(0, _react.useEffect)(() => {
|
|
452
|
+
props.handle.api = api();
|
|
453
|
+
});
|
|
454
|
+
(0, _react.useEffect)(() => {
|
|
455
|
+
props.handle.api = api();
|
|
456
|
+
let eventHandlingConfig = {};
|
|
457
|
+
let defaultAction = {
|
|
458
|
+
actionType: 'script',
|
|
459
|
+
script: {
|
|
460
|
+
lines: [`@#{this}.highlightSelection($event.data)`]
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
eventHandlingConfig.subscriptions = [];
|
|
464
|
+
let subscription = {
|
|
465
|
+
publisher: 'propertiesGrid',
|
|
466
|
+
eventType: _EventType.default.SELECTION_CHANGE,
|
|
467
|
+
actions: [defaultAction]
|
|
468
|
+
};
|
|
469
|
+
eventHandlingConfig.subscriptions.push(subscription);
|
|
470
|
+
_Observable.default.addSubscriptions(_Utils.default.parseConfig({
|
|
471
|
+
id: props.id + "DocTemplateDesigner",
|
|
472
|
+
eventHandlingConfig
|
|
473
|
+
}, props.viewId).eventHandlingConfig, props.handle, props.viewId);
|
|
474
|
+
return () => {
|
|
475
|
+
_Observable.default.clearComponentEventListeners(props.handle);
|
|
476
|
+
};
|
|
477
|
+
}, []);
|
|
478
|
+
const doHighlightSelection = selectedPropertyRows => {
|
|
479
|
+
if (container && selectedPropertyRows && selectedPropertyRows.length > 0) {
|
|
480
|
+
container.documentEditor.selection.clear();
|
|
481
|
+
container.documentEditor.search.find(selectedPropertyRows[0].placeHolder);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const api = () => {
|
|
485
|
+
return {
|
|
486
|
+
get id() {
|
|
487
|
+
return props.id + "DocTemplateDesigner";
|
|
488
|
+
},
|
|
489
|
+
highlightSelection: selectedPropertyRow => {
|
|
490
|
+
doHighlightSelection(selectedPropertyRow);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
495
|
+
className: 'row no-margin no-padding',
|
|
496
|
+
style: {
|
|
497
|
+
height: "100%"
|
|
498
|
+
}
|
|
499
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
500
|
+
style: {
|
|
501
|
+
width: "40%",
|
|
502
|
+
overflow: "auto",
|
|
503
|
+
minHeight: "250px",
|
|
504
|
+
height: "100%",
|
|
505
|
+
border: "1px solid #e1e1e1",
|
|
506
|
+
borderRadius: '4px',
|
|
507
|
+
marginRight: "4px"
|
|
508
|
+
}
|
|
509
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
510
|
+
style: {
|
|
511
|
+
width: "100%",
|
|
512
|
+
fontSize: "12px",
|
|
513
|
+
backgroundColor: "#fafafa",
|
|
514
|
+
padding: "8px",
|
|
515
|
+
height: "77px",
|
|
516
|
+
color: "rgba(0, 0, 0, 0.87)",
|
|
517
|
+
borderBottom: "#f1f1f1",
|
|
518
|
+
display: "flex",
|
|
519
|
+
alignItems: "center"
|
|
520
|
+
}
|
|
521
|
+
}, "Properties"), /*#__PURE__*/React.createElement("div", {
|
|
522
|
+
style: {
|
|
523
|
+
width: "100%",
|
|
524
|
+
marginTop: "4px",
|
|
525
|
+
padding: "0 8px"
|
|
526
|
+
}
|
|
527
|
+
}, /*#__PURE__*/React.createElement(_Form.default, {
|
|
528
|
+
config: props.propertiesFormConfig,
|
|
529
|
+
handle: propertiesFormHandle.current,
|
|
530
|
+
valueChangeHandler: React.useCallback(val => {
|
|
531
|
+
model.current = val;
|
|
532
|
+
let newVal = validateProps(val.properties) ? val : null;
|
|
533
|
+
if (JSON.stringify(currentVal.current) !== JSON.stringify(newVal?.properties)) {
|
|
534
|
+
if (newVal) {
|
|
535
|
+
valueChangeHandler({
|
|
536
|
+
properties: val.properties,
|
|
537
|
+
file
|
|
538
|
+
});
|
|
539
|
+
currentVal.current = val.properties;
|
|
540
|
+
} else {
|
|
541
|
+
if (currentVal.current) {
|
|
542
|
+
currentVal.current = null;
|
|
543
|
+
valueChangeHandler(null);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}, [file]),
|
|
548
|
+
viewId: props.viewId,
|
|
549
|
+
className: 'defaultForm'
|
|
550
|
+
}))), props.visible && /*#__PURE__*/React.createElement("div", {
|
|
551
|
+
className: 'col no-margin no-padding',
|
|
552
|
+
style: {
|
|
553
|
+
maxWidth: 'calc(60% - 16px)',
|
|
554
|
+
height: '100%'
|
|
555
|
+
}
|
|
556
|
+
}, /*#__PURE__*/React.createElement(_ej2ReactDocumenteditor.DocumentEditorContainerComponent, {
|
|
557
|
+
id: "container",
|
|
558
|
+
height: '590px',
|
|
559
|
+
ref: scope => {
|
|
560
|
+
setContainer(scope);
|
|
561
|
+
},
|
|
562
|
+
created: () => {
|
|
563
|
+
if (container) {
|
|
564
|
+
container.resize();
|
|
565
|
+
container.documentEditor.resize();
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
documentChange: doc => {
|
|
569
|
+
if (container) {
|
|
570
|
+
setupContainer();
|
|
571
|
+
}
|
|
572
|
+
setDoc(doc);
|
|
573
|
+
}
|
|
574
|
+
//documentEditorSettings={searchHighlightColor}
|
|
575
|
+
,
|
|
576
|
+
showPropertiesPane: false,
|
|
577
|
+
enableTrackChanges: false,
|
|
578
|
+
toolbarItems: items,
|
|
579
|
+
toolbarClick: onToolbarClick,
|
|
580
|
+
contentChange: onContentChange,
|
|
581
|
+
serviceUrl: "https://services.syncfusion.com/react/production/api/documenteditor/",
|
|
582
|
+
enableToolbar: true
|
|
583
|
+
})));
|
|
584
|
+
};
|
|
585
|
+
var _default = exports.default = DocumentTemplateDesignerComponent;
|
package/dist/components/Icon.js
CHANGED
|
@@ -41,6 +41,8 @@ var _Dock = _interopRequireDefault(require("@mui/icons-material/Dock"));
|
|
|
41
41
|
var _Settings = _interopRequireDefault(require("@mui/icons-material/Settings"));
|
|
42
42
|
var _WarningRounded = _interopRequireDefault(require("@mui/icons-material/WarningRounded"));
|
|
43
43
|
var _Help = _interopRequireDefault(require("@mui/icons-material/Help"));
|
|
44
|
+
var _Link = _interopRequireDefault(require("@mui/icons-material/Link"));
|
|
45
|
+
var _Visibility = _interopRequireDefault(require("@mui/icons-material/Visibility"));
|
|
44
46
|
var _iconsMaterial = require("@mui/icons-material");
|
|
45
47
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
48
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -218,6 +220,8 @@ class Icon extends _react.Component {
|
|
|
218
220
|
});
|
|
219
221
|
} else if (this.props.id === 'RECORD') {
|
|
220
222
|
return /*#__PURE__*/_react.default.createElement(_iconsMaterial.FiberManualRecord, null);
|
|
223
|
+
} else if (this.props.id === 'LINK') {
|
|
224
|
+
return /*#__PURE__*/_react.default.createElement(_Link.default, null);
|
|
221
225
|
} else if (this.props.id === 'PLAY') {
|
|
222
226
|
return /*#__PURE__*/_react.default.createElement(_iconsMaterial.PlayArrow, null);
|
|
223
227
|
} else if (this.props.id === 'STOP') {
|
|
@@ -226,6 +230,12 @@ class Icon extends _react.Component {
|
|
|
226
230
|
color: this.props.color
|
|
227
231
|
}
|
|
228
232
|
});
|
|
233
|
+
} else if (this.props.id === 'VIEW') {
|
|
234
|
+
return /*#__PURE__*/_react.default.createElement(_Visibility.default, {
|
|
235
|
+
style: {
|
|
236
|
+
color: this.props.color
|
|
237
|
+
}
|
|
238
|
+
});
|
|
229
239
|
}
|
|
230
240
|
return null;
|
|
231
241
|
}
|