@zohodesk/dot 1.0.0-temp-197.2 → 1.0.0-temp-197.4
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/README.md +2 -2
- package/es/form/fields/TextEditor/TextEditor.js +25 -38
- package/es/form/fields/TextEditor/props/defaultProps.js +2 -1
- package/es/form/fields/TextEditor/props/propTypes.js +4 -4
- package/es/v1/form/fields/TextEditor/TextEditor.js +37 -53
- package/es/v1/form/fields/TextEditor/props/defaultProps.js +2 -1
- package/es/v1/form/fields/TextEditor/props/propTypes.js +4 -4
- package/lib/form/fields/TextEditor/TextEditor.js +36 -48
- package/lib/form/fields/TextEditor/props/defaultProps.js +2 -1
- package/lib/form/fields/TextEditor/props/propTypes.js +4 -4
- package/lib/v1/form/fields/TextEditor/TextEditor.js +48 -63
- package/lib/v1/form/fields/TextEditor/props/defaultProps.js +2 -1
- package/lib/v1/form/fields/TextEditor/props/propTypes.js +4 -4
- package/package.json +1 -1
- package/result.json +1 -1
- package/unittest/index.html +1 -1
|
@@ -27,8 +27,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
|
|
30
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
|
|
32
30
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
33
31
|
|
|
34
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -70,7 +68,8 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
70
68
|
isResourceLoaded: false,
|
|
71
69
|
isEditorShow: false
|
|
72
70
|
};
|
|
73
|
-
var methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', 'handleDropUpload',
|
|
71
|
+
var methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', // 'handleDropUpload',
|
|
72
|
+
'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
|
|
74
73
|
|
|
75
74
|
_editorUtils.bind.apply(_assertThisInitialized(_this), methods);
|
|
76
75
|
|
|
@@ -109,22 +108,20 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
109
108
|
editorOptions = _this$props$editorOpt === void 0 ? {} : _this$props$editorOpt,
|
|
110
109
|
_this$props$needEdito = _this$props.needEditorFocus,
|
|
111
110
|
needEditorFocus = _this$props$needEdito === void 0 ? true : _this$props$needEdito,
|
|
112
|
-
handleDropUpload = _this$props.handleDropUpload,
|
|
113
111
|
fontFamily = _this$props.fontFamily,
|
|
114
112
|
fontSize = _this$props.fontSize,
|
|
115
113
|
initCallback = _this$props.initCallback,
|
|
116
114
|
handleAlertMessage = _this$props.handleAlertMessage,
|
|
117
|
-
needInlineAttachment = _this$props.needInlineAttachment
|
|
115
|
+
needInlineAttachment = _this$props.needInlineAttachment,
|
|
116
|
+
customInitOptions = _this$props.customInitOptions;
|
|
118
117
|
|
|
119
118
|
if (id && global.ZohoDeskEditor) {
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
var defaultObj = (_defaultObj = {
|
|
119
|
+
var defaultObj = {
|
|
123
120
|
id: id,
|
|
124
121
|
content: (0, _editorUtils.fixEncoding)(value),
|
|
125
122
|
callback: this.editorCallback,
|
|
126
123
|
imageuploadcallback: this.handleInlineUpload,
|
|
127
|
-
handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
|
|
124
|
+
// handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
|
|
128
125
|
contentChanged: this.handleChange,
|
|
129
126
|
focusCallback: this.focusCallback,
|
|
130
127
|
lineHeight: 'Normal',
|
|
@@ -137,18 +134,27 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
137
134
|
mode: mode,
|
|
138
135
|
handleAlertMessage: handleAlertMessage,
|
|
139
136
|
plainTextSwitchCallback: this.plainTextSwitchCallback,
|
|
140
|
-
imgAspect: true
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
imgAspect: true,
|
|
138
|
+
handleInlineDropImage: needInlineAttachment ? this.handleInlineUpload : null,
|
|
139
|
+
needInlineAttachHandling: needInlineAttachment,
|
|
140
|
+
hookOnInsertHTML: _editorUtils.validateEditorContentOnInsertHtml,
|
|
141
|
+
needCustomPaste: function needCustomPaste(event, editorObj) {
|
|
142
|
+
return true; // By default reply editor needs customPaste, so returning true.
|
|
143
|
+
},
|
|
144
|
+
htmlVersion: '<!Doctype html>'
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
if (!customInitOptions) {
|
|
148
|
+
if (!ZohoDeskEditor_Init.init) {
|
|
149
|
+
global.editorInitialize && global.editorInitialize();
|
|
150
|
+
}
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
global.editorInitialize && global.editorInitialize();
|
|
152
|
+
ZohoDeskEditor_Init.init(editorMode, fontFamily, initCallback, fontSize);
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
defaultObj = Object.assign(defaultObj, editorOptions);
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
var globalEditor = global.ZohoDeskEditor;
|
|
157
|
+
globalEditor && typeof globalEditor.create == 'function' && globalEditor.create(defaultObj, customInitOptions);
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
}, {
|
|
@@ -172,8 +178,8 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
172
178
|
getRef && getRef(null);
|
|
173
179
|
}
|
|
174
180
|
}, {
|
|
175
|
-
key: "
|
|
176
|
-
value: function
|
|
181
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
182
|
+
value: function UNSAFE_componentWillReceiveProps(np) {
|
|
177
183
|
var changeEditorContent = this.props.changeEditorContent;
|
|
178
184
|
var id = np.id;
|
|
179
185
|
var editorObj = global.editor ? global.editor[id] ? global.editor[id] : {} : {};
|
|
@@ -251,7 +257,8 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
251
257
|
var _this$props5 = this.props,
|
|
252
258
|
editorCallback = _this$props5.editorCallback,
|
|
253
259
|
getRef = _this$props5.getRef,
|
|
254
|
-
isCustomScroll = _this$props5.isCustomScroll
|
|
260
|
+
isCustomScroll = _this$props5.isCustomScroll,
|
|
261
|
+
customCSS = _this$props5.customCSS;
|
|
255
262
|
this.setState({
|
|
256
263
|
isEditorLoad: true,
|
|
257
264
|
isEditorShow: true
|
|
@@ -263,18 +270,6 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
263
270
|
global.editor[id] = editorObj;
|
|
264
271
|
}
|
|
265
272
|
|
|
266
|
-
var css = 'pre {white-space: pre-wrap}',
|
|
267
|
-
head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
|
|
268
|
-
style = document.createElement('style');
|
|
269
|
-
style.type = 'text/css';
|
|
270
|
-
|
|
271
|
-
if (style.styleSheet) {
|
|
272
|
-
style.styleSheet.cssText = css;
|
|
273
|
-
} else {
|
|
274
|
-
style.appendChild(editorObj.doc.createTextNode(css));
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
head.appendChild(style);
|
|
278
273
|
editorCallback && editorCallback(editorObj);
|
|
279
274
|
var iframe = (0, _selectn["default"])('iframe.contentDocument.body', editorObj) || null;
|
|
280
275
|
var iframeHead = (0, _selectn["default"])('iframe.contentDocument.head', editorObj) || null;
|
|
@@ -292,9 +287,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
292
287
|
iframe.classList.add('scroll');
|
|
293
288
|
}
|
|
294
289
|
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
290
|
+
var customStyleTag = document.createElement('style');
|
|
291
|
+
var customizedCSS = "pre {white-space: pre-wrap} ".concat(customCSS);
|
|
292
|
+
var fontCSS = "@font-face {font-family: 'ZohoPuviRegular';src: url('https://static.zohocdn.com/zohofonts/zohopuvi/4.0/Zoho_Puvi_Regular.woff2') format('woff2');font-style: normal;font-weight: normal;text-rendering: optimizeLegibility;font-display: swap}@font-face {font-family: Regular;src: url('https://static.zohocdn.com/webfonts/lato2regular/font.woff2') format('woff2');font-weight: 400;font-style: normal;font-display: swap}@font-face {font-family: 'RobotoRegular';font-weight: 400;font-style: normal;font-display: swa;src: url('https://static.zohocdn.com/webfonts/robotoregular/font.woff2')}";
|
|
293
|
+
customStyleTag.innerText = "".concat(customizedCSS, " ").concat(fontCSS);
|
|
294
|
+
iframeHead.appendChild(customStyleTag);
|
|
298
295
|
}
|
|
299
296
|
}
|
|
300
297
|
}, {
|
|
@@ -312,11 +309,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
312
309
|
fileNameLimitExceed = i18nKeys.fileNameLimitExceed;
|
|
313
310
|
var allowedFileExtensions = inlineImageProps.allowedFileExtensions,
|
|
314
311
|
fileNameMaxCharacters = inlineImageProps.fileNameMaxCharacters,
|
|
315
|
-
|
|
312
|
+
fileSizeMaxBytes = inlineImageProps.fileSizeMaxBytes;
|
|
316
313
|
|
|
317
314
|
if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name, fileNameMaxCharacters)) {
|
|
318
315
|
if (file.size != 0) {
|
|
319
|
-
if (file.size <=
|
|
316
|
+
if (file.size <= fileSizeMaxBytes) {
|
|
320
317
|
if ((0, _editorUtils.isImageFormat)(file.name, allowedFileExtensions)) {
|
|
321
318
|
progress && progress(true);
|
|
322
319
|
this.handleUpload(file).then(function (res) {
|
|
@@ -341,22 +338,19 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
341
338
|
} else {
|
|
342
339
|
failureCallback(fileNameLimitExceed);
|
|
343
340
|
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
failureCallback();
|
|
358
|
-
});
|
|
359
|
-
}
|
|
341
|
+
} // handleDropUpload(file, successCallback, failureCallback) {
|
|
342
|
+
// let e = { target: { files: [file] } };
|
|
343
|
+
// let { handleDropUpload } = this.props;
|
|
344
|
+
// handleDropUpload(e).then(
|
|
345
|
+
// (res) => {
|
|
346
|
+
// successCallback(res);
|
|
347
|
+
// },
|
|
348
|
+
// () => {
|
|
349
|
+
// failureCallback();
|
|
350
|
+
// }
|
|
351
|
+
// );
|
|
352
|
+
// }
|
|
353
|
+
|
|
360
354
|
}, {
|
|
361
355
|
key: "blurCallback",
|
|
362
356
|
value: function blurCallback() {
|
|
@@ -381,15 +375,7 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
381
375
|
formData.append(getCSRFCookieName(), getCSRFCookie());
|
|
382
376
|
}
|
|
383
377
|
|
|
384
|
-
return onUpload(formData, file)
|
|
385
|
-
if (editorMode === 'TicketReply') {
|
|
386
|
-
return "".concat(res.data, "&from=r");
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
return res.data;
|
|
390
|
-
}, function (err) {
|
|
391
|
-
throw err;
|
|
392
|
-
});
|
|
378
|
+
return onUpload(formData, file);
|
|
393
379
|
} catch (err) {
|
|
394
380
|
return Promise.reject();
|
|
395
381
|
}
|
|
@@ -408,7 +394,6 @@ var TextEditor = /*#__PURE__*/function (_Component) {
|
|
|
408
394
|
var cont = value;
|
|
409
395
|
|
|
410
396
|
if (typeof editor !== 'undefined') {
|
|
411
|
-
// eslint-disable-next-line
|
|
412
397
|
cont = editor['addFormEditor'] && editor['addFormEditor'].getContent();
|
|
413
398
|
}
|
|
414
399
|
|
|
@@ -16,10 +16,11 @@ var defaultProps = {
|
|
|
16
16
|
isNightMode: false,
|
|
17
17
|
isReadOnly: false,
|
|
18
18
|
dataSelectorId: 'textEditor',
|
|
19
|
+
customCSS: '',
|
|
19
20
|
inlineImageProps: {
|
|
20
21
|
allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
|
|
21
22
|
fileNameMaxCharacters: 200,
|
|
22
|
-
|
|
23
|
+
fileSizeMaxBytes: 3 * 1024 * 1024
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
exports.defaultProps = defaultProps;
|
|
@@ -31,7 +31,7 @@ var propTypes = {
|
|
|
31
31
|
fileSizeLimitExceed: _propTypes["default"].string
|
|
32
32
|
}),
|
|
33
33
|
id: _propTypes["default"].string,
|
|
34
|
-
initCallback: _propTypes["default"].func
|
|
34
|
+
initCallback: _propTypes["default"].func,
|
|
35
35
|
isCustomScroll: _propTypes["default"].bool,
|
|
36
36
|
loadingComponent: _propTypes["default"].node,
|
|
37
37
|
mode: _propTypes["default"].string,
|
|
@@ -53,10 +53,10 @@ var propTypes = {
|
|
|
53
53
|
isEditorDefaultOpen: _propTypes["default"].bool,
|
|
54
54
|
toggleEdit: _propTypes["default"].func,
|
|
55
55
|
dataSelectorId: _propTypes["default"].string,
|
|
56
|
-
inlineImageProps: {
|
|
56
|
+
inlineImageProps: _propTypes["default"].shape({
|
|
57
57
|
allowedFileExtensions: _propTypes["default"].array,
|
|
58
58
|
fileNameMaxCharacters: _propTypes["default"].number,
|
|
59
|
-
|
|
60
|
-
}
|
|
59
|
+
fileSizeMaxBytes: _propTypes["default"].number
|
|
60
|
+
})
|
|
61
61
|
};
|
|
62
62
|
exports.propTypes = propTypes;
|