@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 CHANGED
@@ -4,11 +4,11 @@ In this Library, we Provide Some Basic Components to Build Your Application
4
4
 
5
5
  # 1.5.5
6
6
  - **TextEditor (v0&v1)**
7
- - `inlineImageProps={allowedFileExtensions, fileNameMaxCharacters, fileSizeMax}` props added.
7
+ - `inlineImageProps={allowedFileExtensions, fileNameMaxCharacters, fileSizeMaxBytes}` props added.
8
8
  - default props,
9
9
  - `allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"]`
10
10
  - `fileNameMaxCharacters: 200,`
11
- - `fileSizeMax: 3 * 1024 * 1024`
11
+ - `fileSizeMaxBytes: 3 * 1024 * 1024`
12
12
  - `customInitOptions` prop added, using this can initialize the editor details.
13
13
  - `customCSS` prop suppported to customize the style to apply for editor, it adds css in style tag.
14
14
  - In `handleUpload` method reverted the `TicketReply` editor specific case handle.
@@ -25,7 +25,8 @@ export default class TextEditor extends Component {
25
25
  isResourceLoaded: false,
26
26
  isEditorShow: false
27
27
  };
28
- let methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', 'handleDropUpload', 'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
28
+ let methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', // 'handleDropUpload',
29
+ 'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
29
30
  bind.apply(this, methods);
30
31
  }
31
32
 
@@ -53,7 +54,7 @@ export default class TextEditor extends Component {
53
54
  editorMode = '',
54
55
  editorOptions = {},
55
56
  needEditorFocus = true,
56
- handleDropUpload,
57
+ // handleDropUpload,
57
58
  fontFamily,
58
59
  fontSize,
59
60
  initCallback,
@@ -68,7 +69,7 @@ export default class TextEditor extends Component {
68
69
  content: fixEncoding(value),
69
70
  callback: this.editorCallback,
70
71
  imageuploadcallback: this.handleInlineUpload,
71
- handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
72
+ // handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
72
73
  contentChanged: this.handleChange,
73
74
  focusCallback: this.focusCallback,
74
75
  lineHeight: 'Normal',
@@ -126,7 +127,7 @@ export default class TextEditor extends Component {
126
127
  getRef && getRef(null);
127
128
  }
128
129
 
129
- componentWillReceiveProps(np) {
130
+ UNSAFE_componentWillReceiveProps(np) {
130
131
  let {
131
132
  changeEditorContent
132
133
  } = this.props;
@@ -224,18 +225,6 @@ export default class TextEditor extends Component {
224
225
  global.editor[id] = editorObj;
225
226
  }
226
227
 
227
- const css = `pre {white-space: pre-wrap}, ${customCSS}`,
228
- head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
229
- style = document.createElement('style');
230
- style.type = 'text/css';
231
-
232
- if (style.styleSheet) {
233
- style.styleSheet.cssText = css;
234
- } else {
235
- style.appendChild(editorObj.doc.createTextNode(css));
236
- }
237
-
238
- head.appendChild(style);
239
228
  editorCallback && editorCallback(editorObj);
240
229
  const iframe = selectn('iframe.contentDocument.body', editorObj) || null;
241
230
  const iframeHead = selectn('iframe.contentDocument.head', editorObj) || null;
@@ -251,9 +240,11 @@ export default class TextEditor extends Component {
251
240
  iframe.classList.add('scroll');
252
241
  }
253
242
 
254
- let customFonts = document.createElement('style');
255
- customFonts.innerText = `@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')}`;
256
- iframeHead.appendChild(customFonts);
243
+ let customStyleTag = document.createElement('style');
244
+ const customizedCSS = `pre {white-space: pre-wrap} ${customCSS}`;
245
+ const 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')}`;
246
+ customStyleTag.innerText = `${customizedCSS} ${fontCSS}`;
247
+ iframeHead.appendChild(customStyleTag);
257
248
  }
258
249
  }
259
250
 
@@ -274,12 +265,12 @@ export default class TextEditor extends Component {
274
265
  const {
275
266
  allowedFileExtensions,
276
267
  fileNameMaxCharacters,
277
- fileSizeMax
268
+ fileSizeMaxBytes
278
269
  } = inlineImageProps;
279
270
 
280
271
  if (!isFileNameSizeInvalid(file.name, fileNameMaxCharacters)) {
281
272
  if (file.size != 0) {
282
- if (file.size <= fileSizeMax) {
273
+ if (file.size <= fileSizeMaxBytes) {
283
274
  if (isImageFormat(file.name, allowedFileExtensions)) {
284
275
  progress && progress(true);
285
276
  this.handleUpload(file).then(res => {
@@ -304,23 +295,19 @@ export default class TextEditor extends Component {
304
295
  } else {
305
296
  failureCallback(fileNameLimitExceed);
306
297
  }
307
- }
298
+ } // handleDropUpload(file, successCallback, failureCallback) {
299
+ // let e = { target: { files: [file] } };
300
+ // let { handleDropUpload } = this.props;
301
+ // handleDropUpload(e).then(
302
+ // (res) => {
303
+ // successCallback(res);
304
+ // },
305
+ // () => {
306
+ // failureCallback();
307
+ // }
308
+ // );
309
+ // }
308
310
 
309
- handleDropUpload(file, successCallback, failureCallback) {
310
- let e = {
311
- target: {
312
- files: [file]
313
- }
314
- };
315
- let {
316
- handleDropUpload
317
- } = this.props;
318
- handleDropUpload(e).then(res => {
319
- successCallback(res);
320
- }, () => {
321
- failureCallback();
322
- });
323
- }
324
311
 
325
312
  blurCallback() {
326
313
  let {
@@ -414,7 +401,7 @@ export default class TextEditor extends Component {
414
401
  }), editorDoc && ImgLazyLoad ? /*#__PURE__*/React.createElement(ImgLazyLoad, {
415
402
  node: editorDoc
416
403
  }) : null, isReadOnly ? /*#__PURE__*/React.createElement("div", {
417
- class: styles.readOnlyMask
404
+ className: styles.readOnlyMask
418
405
  }) : null);
419
406
  }
420
407
 
@@ -10,9 +10,10 @@ export const defaultProps = {
10
10
  isNightMode: false,
11
11
  isReadOnly: false,
12
12
  dataSelectorId: 'textEditor',
13
+ customCSS: '',
13
14
  inlineImageProps: {
14
15
  allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
15
16
  fileNameMaxCharacters: 200,
16
- fileSizeMax: 3 * 1024 * 1024
17
+ fileSizeMaxBytes: 3 * 1024 * 1024
17
18
  }
18
19
  };
@@ -21,7 +21,7 @@ export const propTypes = {
21
21
  fileSizeLimitExceed: PropTypes.string
22
22
  }),
23
23
  id: PropTypes.string,
24
- initCallback: PropTypes.func.isRequired,
24
+ initCallback: PropTypes.func,
25
25
  isCustomScroll: PropTypes.bool,
26
26
  loadingComponent: PropTypes.node,
27
27
  mode: PropTypes.string,
@@ -45,9 +45,9 @@ export const propTypes = {
45
45
  dataSelectorId: PropTypes.string,
46
46
  customInitOptions: PropTypes.object,
47
47
  customCSS: PropTypes.string,
48
- inlineImageProps: {
48
+ inlineImageProps: PropTypes.shape({
49
49
  allowedFileExtensions: PropTypes.array,
50
50
  fileNameMaxCharacters: PropTypes.number,
51
- fileSizeMax: PropTypes.number
52
- }
51
+ fileSizeMaxBytes: PropTypes.number
52
+ })
53
53
  };
@@ -25,7 +25,8 @@ export default class TextEditor extends Component {
25
25
  isResourceLoaded: false,
26
26
  isEditorShow: false
27
27
  };
28
- let methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', 'handleDropUpload', 'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
28
+ let methods = ['editorCallback', 'handleUpload', 'handleChange', 'focusCallback', 'handleInlineUpload', // 'handleDropUpload',
29
+ 'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
29
30
  bind.apply(this, methods);
30
31
  }
31
32
 
@@ -53,12 +54,13 @@ export default class TextEditor extends Component {
53
54
  editorMode = '',
54
55
  editorOptions = {},
55
56
  needEditorFocus = true,
56
- handleDropUpload,
57
+ // handleDropUpload,
57
58
  fontFamily,
58
59
  fontSize,
59
60
  initCallback,
60
61
  handleAlertMessage,
61
- needInlineAttachment
62
+ needInlineAttachment,
63
+ customInitOptions
62
64
  } = this.props;
63
65
 
64
66
  if (id && global.ZohoDeskEditor) {
@@ -67,7 +69,7 @@ export default class TextEditor extends Component {
67
69
  content: fixEncoding(value),
68
70
  callback: this.editorCallback,
69
71
  imageuploadcallback: this.handleInlineUpload,
70
- handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
72
+ // handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
71
73
  contentChanged: this.handleChange,
72
74
  focusCallback: this.focusCallback,
73
75
  lineHeight: 'Normal',
@@ -90,13 +92,17 @@ export default class TextEditor extends Component {
90
92
  htmlVersion: '<!Doctype html>'
91
93
  };
92
94
 
93
- if (!ZohoDeskEditor_Init.init) {
94
- global.editorInitialize && global.editorInitialize();
95
+ if (!customInitOptions) {
96
+ if (!ZohoDeskEditor_Init.init) {
97
+ global.editorInitialize && global.editorInitialize();
98
+ }
99
+
100
+ ZohoDeskEditor_Init.init(editorMode, fontFamily, initCallback, fontSize);
95
101
  }
96
102
 
97
103
  defaultObj = Object.assign(defaultObj, editorOptions);
98
- ZohoDeskEditor_Init.init(editorMode, fontFamily, initCallback, fontSize);
99
- ZohoDeskEditor.create && ZohoDeskEditor.create(defaultObj);
104
+ const globalEditor = global.ZohoDeskEditor;
105
+ globalEditor && typeof globalEditor.create == 'function' && globalEditor.create(defaultObj, customInitOptions);
100
106
  }
101
107
  }
102
108
 
@@ -121,7 +127,7 @@ export default class TextEditor extends Component {
121
127
  getRef && getRef(null);
122
128
  }
123
129
 
124
- componentWillReceiveProps(np) {
130
+ UNSAFE_componentWillReceiveProps(np) {
125
131
  let {
126
132
  changeEditorContent
127
133
  } = this.props;
@@ -203,7 +209,8 @@ export default class TextEditor extends Component {
203
209
  let {
204
210
  editorCallback,
205
211
  getRef,
206
- isCustomScroll
212
+ isCustomScroll,
213
+ customCSS
207
214
  } = this.props;
208
215
  this.setState({
209
216
  isEditorLoad: true,
@@ -218,18 +225,6 @@ export default class TextEditor extends Component {
218
225
  global.editor[id] = editorObj;
219
226
  }
220
227
 
221
- const css = 'pre {white-space: pre-wrap}',
222
- head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
223
- style = document.createElement('style');
224
- style.type = 'text/css';
225
-
226
- if (style.styleSheet) {
227
- style.styleSheet.cssText = css;
228
- } else {
229
- style.appendChild(editorObj.doc.createTextNode(css));
230
- }
231
-
232
- head.appendChild(style);
233
228
  editorCallback && editorCallback(editorObj);
234
229
  const iframe = selectn('iframe.contentDocument.body', editorObj) || null;
235
230
  const iframeHead = selectn('iframe.contentDocument.head', editorObj) || null;
@@ -245,9 +240,11 @@ export default class TextEditor extends Component {
245
240
  iframe.classList.add('scroll');
246
241
  }
247
242
 
248
- let customFonts = document.createElement('style');
249
- customFonts.innerText = `@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')}`;
250
- iframeHead.appendChild(customFonts);
243
+ let customStyleTag = document.createElement('style');
244
+ const customizedCSS = `pre {white-space: pre-wrap} ${customCSS}`;
245
+ const 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')}`;
246
+ customStyleTag.innerText = `${customizedCSS} ${fontCSS}`;
247
+ iframeHead.appendChild(customStyleTag);
251
248
  }
252
249
  }
253
250
 
@@ -268,12 +265,12 @@ export default class TextEditor extends Component {
268
265
  const {
269
266
  allowedFileExtensions,
270
267
  fileNameMaxCharacters,
271
- fileSizeMax
268
+ fileSizeMaxBytes
272
269
  } = inlineImageProps;
273
270
 
274
271
  if (!isFileNameSizeInvalid(file.name, fileNameMaxCharacters)) {
275
272
  if (file.size != 0) {
276
- if (file.size <= fileSizeMax) {
273
+ if (file.size <= fileSizeMaxBytes) {
277
274
  if (isImageFormat(file.name, allowedFileExtensions)) {
278
275
  progress && progress(true);
279
276
  this.handleUpload(file).then(res => {
@@ -298,23 +295,19 @@ export default class TextEditor extends Component {
298
295
  } else {
299
296
  failureCallback(fileNameLimitExceed);
300
297
  }
301
- }
298
+ } // handleDropUpload(file, successCallback, failureCallback) {
299
+ // let e = { target: { files: [file] } };
300
+ // let { handleDropUpload } = this.props;
301
+ // handleDropUpload(e).then(
302
+ // (res) => {
303
+ // successCallback(res);
304
+ // },
305
+ // () => {
306
+ // failureCallback();
307
+ // }
308
+ // );
309
+ // }
302
310
 
303
- handleDropUpload(file, successCallback, failureCallback) {
304
- let e = {
305
- target: {
306
- files: [file]
307
- }
308
- };
309
- let {
310
- handleDropUpload
311
- } = this.props;
312
- handleDropUpload(e).then(res => {
313
- successCallback(res);
314
- }, () => {
315
- failureCallback();
316
- });
317
- }
318
311
 
319
312
  blurCallback() {
320
313
  let {
@@ -340,15 +333,7 @@ export default class TextEditor extends Component {
340
333
  formData.append(getCSRFCookieName(), getCSRFCookie());
341
334
  }
342
335
 
343
- return onUpload(formData, file).then(res => {
344
- if (editorMode === 'TicketReply') {
345
- return `${res.data}&from=r`;
346
- }
347
-
348
- return res.data;
349
- }, err => {
350
- throw err;
351
- });
336
+ return onUpload(formData, file);
352
337
  } catch (err) {
353
338
  return Promise.reject();
354
339
  }
@@ -368,7 +353,6 @@ export default class TextEditor extends Component {
368
353
  let cont = value;
369
354
 
370
355
  if (typeof editor !== 'undefined') {
371
- // eslint-disable-next-line
372
356
  cont = editor['addFormEditor'] && editor['addFormEditor'].getContent();
373
357
  }
374
358
 
@@ -10,9 +10,10 @@ export const defaultProps = {
10
10
  isNightMode: false,
11
11
  isReadOnly: false,
12
12
  dataSelectorId: 'textEditor',
13
+ customCSS: '',
13
14
  inlineImageProps: {
14
15
  allowedFileExtensions: ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
15
16
  fileNameMaxCharacters: 200,
16
- fileSizeMax: 3 * 1024 * 1024
17
+ fileSizeMaxBytes: 3 * 1024 * 1024
17
18
  }
18
19
  };
@@ -21,7 +21,7 @@ export const propTypes = {
21
21
  fileSizeLimitExceed: PropTypes.string
22
22
  }),
23
23
  id: PropTypes.string,
24
- initCallback: PropTypes.func.isRequired,
24
+ initCallback: PropTypes.func,
25
25
  isCustomScroll: PropTypes.bool,
26
26
  loadingComponent: PropTypes.node,
27
27
  mode: PropTypes.string,
@@ -43,9 +43,9 @@ export const propTypes = {
43
43
  isEditorDefaultOpen: PropTypes.bool,
44
44
  toggleEdit: PropTypes.func,
45
45
  dataSelectorId: PropTypes.string,
46
- inlineImageProps: {
46
+ inlineImageProps: PropTypes.shape({
47
47
  allowedFileExtensions: PropTypes.array,
48
48
  fileNameMaxCharacters: PropTypes.number,
49
- fileSizeMax: PropTypes.number
50
- }
49
+ fileSizeMaxBytes: PropTypes.number
50
+ })
51
51
  };
@@ -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', 'blurCallback', 'handleGetContent', 'initializeEditor', 'clearEditorData', 'plainTextSwitchCallback', 'onWindowClick', 'toggleEditor'];
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,7 +108,6 @@ 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,
@@ -118,14 +116,12 @@ var TextEditor = /*#__PURE__*/function (_Component) {
118
116
  customInitOptions = _this$props.customInitOptions;
119
117
 
120
118
  if (id && global.ZohoDeskEditor) {
121
- var _defaultObj;
122
-
123
- var defaultObj = (_defaultObj = {
119
+ var defaultObj = {
124
120
  id: id,
125
121
  content: (0, _editorUtils.fixEncoding)(value),
126
122
  callback: this.editorCallback,
127
123
  imageuploadcallback: this.handleInlineUpload,
128
- handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
124
+ // handleInlineDropImage: handleDropUpload ? this.handleDropUpload : undefined,
129
125
  contentChanged: this.handleChange,
130
126
  focusCallback: this.focusCallback,
131
127
  lineHeight: 'Normal',
@@ -138,10 +134,15 @@ var TextEditor = /*#__PURE__*/function (_Component) {
138
134
  mode: mode,
139
135
  handleAlertMessage: handleAlertMessage,
140
136
  plainTextSwitchCallback: this.plainTextSwitchCallback,
141
- imgAspect: true
142
- }, _defineProperty(_defaultObj, "handleInlineDropImage", needInlineAttachment ? this.handleInlineUpload : null), _defineProperty(_defaultObj, "needInlineAttachHandling", needInlineAttachment), _defineProperty(_defaultObj, "hookOnInsertHTML", _editorUtils.validateEditorContentOnInsertHtml), _defineProperty(_defaultObj, "needCustomPaste", function needCustomPaste(event, editorObj) {
143
- return true; // By default reply editor needs customPaste, so returning true.
144
- }), _defineProperty(_defaultObj, "htmlVersion", '<!Doctype html>'), _defaultObj);
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
+ };
145
146
 
146
147
  if (!customInitOptions) {
147
148
  if (!ZohoDeskEditor_Init.init) {
@@ -177,8 +178,8 @@ var TextEditor = /*#__PURE__*/function (_Component) {
177
178
  getRef && getRef(null);
178
179
  }
179
180
  }, {
180
- key: "componentWillReceiveProps",
181
- value: function componentWillReceiveProps(np) {
181
+ key: "UNSAFE_componentWillReceiveProps",
182
+ value: function UNSAFE_componentWillReceiveProps(np) {
182
183
  var changeEditorContent = this.props.changeEditorContent;
183
184
  var id = np.id;
184
185
  var editorObj = global.editor ? global.editor[id] ? global.editor[id] : {} : {};
@@ -269,18 +270,6 @@ var TextEditor = /*#__PURE__*/function (_Component) {
269
270
  global.editor[id] = editorObj;
270
271
  }
271
272
 
272
- var css = "pre {white-space: pre-wrap}, ".concat(customCSS),
273
- head = editorObj.doc.head || editorObj.doc.getElementsByTagName('head')[0],
274
- style = document.createElement('style');
275
- style.type = 'text/css';
276
-
277
- if (style.styleSheet) {
278
- style.styleSheet.cssText = css;
279
- } else {
280
- style.appendChild(editorObj.doc.createTextNode(css));
281
- }
282
-
283
- head.appendChild(style);
284
273
  editorCallback && editorCallback(editorObj);
285
274
  var iframe = (0, _selectn["default"])('iframe.contentDocument.body', editorObj) || null;
286
275
  var iframeHead = (0, _selectn["default"])('iframe.contentDocument.head', editorObj) || null;
@@ -298,9 +287,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
298
287
  iframe.classList.add('scroll');
299
288
  }
300
289
 
301
- var customFonts = document.createElement('style');
302
- customFonts.innerText = "@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')}";
303
- iframeHead.appendChild(customFonts);
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);
304
295
  }
305
296
  }
306
297
  }, {
@@ -318,11 +309,11 @@ var TextEditor = /*#__PURE__*/function (_Component) {
318
309
  fileNameLimitExceed = i18nKeys.fileNameLimitExceed;
319
310
  var allowedFileExtensions = inlineImageProps.allowedFileExtensions,
320
311
  fileNameMaxCharacters = inlineImageProps.fileNameMaxCharacters,
321
- fileSizeMax = inlineImageProps.fileSizeMax;
312
+ fileSizeMaxBytes = inlineImageProps.fileSizeMaxBytes;
322
313
 
323
314
  if (!(0, _editorUtils.isFileNameSizeInvalid)(file.name, fileNameMaxCharacters)) {
324
315
  if (file.size != 0) {
325
- if (file.size <= fileSizeMax) {
316
+ if (file.size <= fileSizeMaxBytes) {
326
317
  if ((0, _editorUtils.isImageFormat)(file.name, allowedFileExtensions)) {
327
318
  progress && progress(true);
328
319
  this.handleUpload(file).then(function (res) {
@@ -347,22 +338,19 @@ var TextEditor = /*#__PURE__*/function (_Component) {
347
338
  } else {
348
339
  failureCallback(fileNameLimitExceed);
349
340
  }
350
- }
351
- }, {
352
- key: "handleDropUpload",
353
- value: function handleDropUpload(file, successCallback, failureCallback) {
354
- var e = {
355
- target: {
356
- files: [file]
357
- }
358
- };
359
- var handleDropUpload = this.props.handleDropUpload;
360
- handleDropUpload(e).then(function (res) {
361
- successCallback(res);
362
- }, function () {
363
- failureCallback();
364
- });
365
- }
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
+
366
354
  }, {
367
355
  key: "blurCallback",
368
356
  value: function blurCallback() {
@@ -451,7 +439,7 @@ var TextEditor = /*#__PURE__*/function (_Component) {
451
439
  }), editorDoc && ImgLazyLoad ? /*#__PURE__*/_react["default"].createElement(ImgLazyLoad, {
452
440
  node: editorDoc
453
441
  }) : null, isReadOnly ? /*#__PURE__*/_react["default"].createElement("div", {
454
- "class": _TextEditorModule["default"].readOnlyMask
442
+ className: _TextEditorModule["default"].readOnlyMask
455
443
  }) : null);
456
444
  }
457
445
  }]);
@@ -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
- fileSizeMax: 3 * 1024 * 1024
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.isRequired,
34
+ initCallback: _propTypes["default"].func,
35
35
  isCustomScroll: _propTypes["default"].bool,
36
36
  loadingComponent: _propTypes["default"].node,
37
37
  mode: _propTypes["default"].string,
@@ -55,10 +55,10 @@ var propTypes = {
55
55
  dataSelectorId: _propTypes["default"].string,
56
56
  customInitOptions: _propTypes["default"].object,
57
57
  customCSS: _propTypes["default"].string,
58
- inlineImageProps: {
58
+ inlineImageProps: _propTypes["default"].shape({
59
59
  allowedFileExtensions: _propTypes["default"].array,
60
60
  fileNameMaxCharacters: _propTypes["default"].number,
61
- fileSizeMax: _propTypes["default"].number
62
- }
61
+ fileSizeMaxBytes: _propTypes["default"].number
62
+ })
63
63
  };
64
64
  exports.propTypes = propTypes;