@zohodesk/dot 1.0.0-temp-198.3.3 → 1.0.0-temp-199

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.
Files changed (120) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +39 -0
  3. package/assets/Appearance/dark/mode/Dot_DarkMode.module.css +1 -0
  4. package/assets/Appearance/light/mode/Dot_LightMode.module.css +1 -0
  5. package/assets/Appearance/pureDark/mode/Dot_PureDarkMode.module.css +1 -0
  6. package/es/ActionButton/ActionButton.module.css +192 -192
  7. package/es/AlphabeticList/AlphabeticList.module.css +57 -57
  8. package/es/AttachmentViewer/AttachmentImage.js +68 -32
  9. package/es/AttachmentViewer/AttachmentViewer.js +120 -41
  10. package/es/AttachmentViewer/AttachmentViewer.module.css +364 -352
  11. package/es/AttachmentViewer/__tests__/AttachmentImage.spec.js +63 -13
  12. package/es/AttachmentViewer/__tests__/__snapshots__/AttachmentImage.spec.js.snap +9 -5
  13. package/es/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +16 -117
  14. package/es/AttachmentViewer/props/defaultProps.js +5 -1
  15. package/es/AttachmentViewer/props/propTypes.js +7 -3
  16. package/es/AttachmentViewer/utils.js +49 -0
  17. package/es/ChannelIcon/ChannelIcon.module.css +225 -225
  18. package/es/FormAction/FormAction.module.css +100 -100
  19. package/es/IconButton/IconButton.module.css +22 -22
  20. package/es/Image/Image.js +6 -2
  21. package/es/Image/props/propTypes.js +3 -1
  22. package/es/TagWithIcon/TagWithIcon.module.css +66 -66
  23. package/es/avatar/AvatarIcon/AvatarIcon.module.css +58 -58
  24. package/es/emptystate/CommonEmptyState/CommonEmptyState.module.css +92 -92
  25. package/es/form/fields/CurrencyField/CurrencyField.js +2 -1
  26. package/es/form/fields/TextEditor/TextEditor.js +64 -64
  27. package/es/form/fields/TextEditor/TextEditor.module.css +73 -61
  28. package/es/form/fields/TextEditor/__tests__/__snapshots__/TextEditor.spec.js.snap +1 -1
  29. package/es/form/fields/TextEditor/props/defaultProps.js +4 -1
  30. package/es/form/fields/TextEditor/props/propTypes.js +10 -3
  31. package/es/form/fields/ValidationMessage/ValidationMessage.module.css +27 -27
  32. package/es/layout/SubtabLayout/SubtabLayout.module.css +164 -164
  33. package/es/list/Comment/Comment.module.css +29 -29
  34. package/es/list/Dot/Dot.module.css +15 -15
  35. package/es/list/ListLayout/ListLayout.module.css +79 -79
  36. package/es/list/Subject/Subject.module.css +34 -34
  37. package/es/list/Thread/Thread.module.css +42 -42
  38. package/es/list/status/StatusDropdown/StatusDropdown.js +8 -2
  39. package/es/list/status/StatusDropdown/__tests__/StatusDropdown.spec.js +16 -0
  40. package/es/list/status/StatusDropdown/__tests__/__snapshots__/StatusDropdown.spec.js.snap +14 -0
  41. package/es/list/status/StatusDropdown/props/propTypes.js +2 -0
  42. package/es/lookup/header/Search/LookupSearch.module.css +26 -26
  43. package/es/lookup/header/Search/Search.js +55 -38
  44. package/es/lookup/header/Search/props/defaultProps.js +2 -1
  45. package/es/lookup/header/Search/props/propTypes.js +5 -1
  46. package/es/utils/editorUtils.js +6 -6
  47. package/es/v1/AttachmentViewer/AttachmentImage.js +44 -23
  48. package/es/v1/AttachmentViewer/AttachmentViewer.js +120 -41
  49. package/es/v1/AttachmentViewer/props/propTypes.js +7 -3
  50. package/es/v1/Image/Image.js +6 -2
  51. package/es/v1/Image/props/propTypes.js +3 -1
  52. package/es/v1/form/fields/CurrencyField/CurrencyField.js +2 -1
  53. package/es/v1/form/fields/TextEditor/TextEditor.js +63 -64
  54. package/es/v1/form/fields/TextEditor/props/defaultProps.js +4 -1
  55. package/es/v1/form/fields/TextEditor/props/propTypes.js +10 -3
  56. package/es/v1/list/status/StatusDropdown/StatusDropdown.js +8 -2
  57. package/es/v1/list/status/StatusDropdown/props/propTypes.js +2 -0
  58. package/es/v1/utils/editorUtils.js +6 -6
  59. package/es/version2/GlobalNotification/GlobalNotification.module.css +177 -177
  60. package/es/version2/lookup/AlertHeader/css/AlertHeaderNew.module.css +87 -87
  61. package/es/version2/notification/DesktopNotificationHeader/DesktopNotificationHeader.module.css +132 -132
  62. package/lib/ActionButton/ActionButton.module.css +192 -192
  63. package/lib/AlphabeticList/AlphabeticList.module.css +57 -57
  64. package/lib/AttachmentViewer/AttachmentImage.js +74 -36
  65. package/lib/AttachmentViewer/AttachmentViewer.js +151 -70
  66. package/lib/AttachmentViewer/AttachmentViewer.module.css +364 -352
  67. package/lib/AttachmentViewer/__tests__/AttachmentImage.spec.js +64 -13
  68. package/lib/AttachmentViewer/__tests__/__snapshots__/AttachmentImage.spec.js.snap +9 -5
  69. package/lib/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +16 -117
  70. package/lib/AttachmentViewer/props/defaultProps.js +5 -1
  71. package/lib/AttachmentViewer/props/propTypes.js +7 -3
  72. package/lib/AttachmentViewer/utils.js +60 -1
  73. package/lib/ChannelIcon/ChannelIcon.module.css +225 -225
  74. package/lib/FormAction/FormAction.module.css +100 -100
  75. package/lib/IconButton/IconButton.module.css +22 -22
  76. package/lib/Image/Image.js +6 -2
  77. package/lib/Image/props/propTypes.js +3 -1
  78. package/lib/TagWithIcon/TagWithIcon.module.css +66 -66
  79. package/lib/avatar/AvatarIcon/AvatarIcon.module.css +58 -58
  80. package/lib/emptystate/CommonEmptyState/CommonEmptyState.module.css +92 -92
  81. package/lib/form/fields/CurrencyField/CurrencyField.js +2 -1
  82. package/lib/form/fields/TextEditor/TextEditor.js +74 -74
  83. package/lib/form/fields/TextEditor/TextEditor.module.css +73 -61
  84. package/lib/form/fields/TextEditor/__tests__/__snapshots__/TextEditor.spec.js.snap +1 -1
  85. package/lib/form/fields/TextEditor/props/defaultProps.js +4 -1
  86. package/lib/form/fields/TextEditor/props/propTypes.js +10 -3
  87. package/lib/form/fields/ValidationMessage/ValidationMessage.module.css +27 -27
  88. package/lib/layout/SubtabLayout/SubtabLayout.module.css +164 -164
  89. package/lib/list/Comment/Comment.module.css +29 -29
  90. package/lib/list/Dot/Dot.module.css +15 -15
  91. package/lib/list/ListLayout/ListLayout.module.css +79 -79
  92. package/lib/list/Subject/Subject.module.css +34 -34
  93. package/lib/list/Thread/Thread.module.css +42 -42
  94. package/lib/list/status/StatusDropdown/StatusDropdown.js +8 -2
  95. package/lib/list/status/StatusDropdown/__tests__/StatusDropdown.spec.js +14 -0
  96. package/lib/list/status/StatusDropdown/__tests__/__snapshots__/StatusDropdown.spec.js.snap +14 -0
  97. package/lib/list/status/StatusDropdown/props/propTypes.js +1 -1
  98. package/lib/lookup/header/Search/LookupSearch.module.css +26 -26
  99. package/lib/lookup/header/Search/Search.js +73 -64
  100. package/lib/lookup/header/Search/props/defaultProps.js +2 -1
  101. package/lib/lookup/header/Search/props/propTypes.js +9 -3
  102. package/lib/utils/editorUtils.js +6 -5
  103. package/lib/v1/AttachmentViewer/AttachmentImage.js +52 -24
  104. package/lib/v1/AttachmentViewer/AttachmentViewer.js +151 -70
  105. package/lib/v1/AttachmentViewer/props/propTypes.js +7 -3
  106. package/lib/v1/Image/Image.js +6 -2
  107. package/lib/v1/Image/props/propTypes.js +3 -1
  108. package/lib/v1/form/fields/CurrencyField/CurrencyField.js +2 -1
  109. package/lib/v1/form/fields/TextEditor/TextEditor.js +73 -74
  110. package/lib/v1/form/fields/TextEditor/props/defaultProps.js +4 -1
  111. package/lib/v1/form/fields/TextEditor/props/propTypes.js +10 -3
  112. package/lib/v1/list/status/StatusDropdown/StatusDropdown.js +8 -2
  113. package/lib/v1/list/status/StatusDropdown/props/propTypes.js +1 -1
  114. package/lib/v1/utils/editorUtils.js +6 -5
  115. package/lib/version2/GlobalNotification/GlobalNotification.module.css +177 -177
  116. package/lib/version2/lookup/AlertHeader/css/AlertHeaderNew.module.css +87 -87
  117. package/lib/version2/notification/DesktopNotificationHeader/DesktopNotificationHeader.module.css +132 -132
  118. package/package.json +6 -6
  119. package/result.json +1 -1
  120. package/unittest/index.html +6 -2
@@ -11,6 +11,8 @@ import Link from "../Link/Link";
11
11
  import IconButton from "../IconButton/IconButton";
12
12
  import FreezeLayer from "../FreezeLayer/FreezeLayer";
13
13
  import { isAudioFile, getExtensionFromFileName } from "../../AttachmentViewer/Attachment";
14
+ import { checkFileSourcesValidation } from "../../AttachmentViewer/utils";
15
+ import audioThumbNail from "../../../images/audio_thumbnail.png";
14
16
  import { shallowDiff } from "../../utils/General";
15
17
  import style from "../../AttachmentViewer/AttachmentViewer.module.css";
16
18
  export default class AttachmentViewer extends Component {
@@ -25,7 +27,10 @@ export default class AttachmentViewer extends Component {
25
27
  index: this.props.previewObj.selectedIndex,
26
28
  data: this.props.previewObj ? this.props.previewObj.previewData : [],
27
29
  dataList: []
28
- })
30
+ }),
31
+ canOpenInNewTab: false,
32
+ canZoom: false,
33
+ isPreviewAttachmentValid: false
29
34
  };
30
35
  this.togglePViewList = this.togglePViewList.bind(this);
31
36
  this.changeSelectedIndex = this.changeSelectedIndex.bind(this);
@@ -37,12 +42,20 @@ export default class AttachmentViewer extends Component {
37
42
  this.getNextId = getUniqueId(this);
38
43
  this.getUpdateDataList = this.getUpdateDataList.bind(this);
39
44
  this.zoomMaintain = this.zoomMaintain.bind(this);
45
+ this.handleMenuValidation = this.handleMenuValidation.bind(this);
46
+ }
47
+
48
+ componentDidMount() {
49
+ this.handleMenuValidation();
40
50
  }
41
51
 
42
- componentDidUpdate(prevProps) {
52
+ componentDidUpdate(prevProps, prevState) {
43
53
  let {
44
54
  previewObj
45
55
  } = this.props;
56
+ const {
57
+ selectedIndex
58
+ } = this.state;
46
59
  let indexChanged = previewObj.selectedIndex != prevProps.previewObj.selectedIndex;
47
60
 
48
61
  if (previewObj.previewData.length != prevProps.previewObj.previewData.length || indexChanged) {
@@ -63,6 +76,35 @@ export default class AttachmentViewer extends Component {
63
76
  });
64
77
  }
65
78
  }
79
+
80
+ if (prevState.selectedIndex != selectedIndex) {
81
+ this.handleMenuValidation();
82
+ }
83
+ }
84
+
85
+ handleMenuValidation() {
86
+ const {
87
+ data,
88
+ selectedIndex
89
+ } = this.state;
90
+ const selectedAttachment = data[selectedIndex] || {};
91
+ const selectedAttachmentViewUrl = selectedAttachment.viewUrl;
92
+ const selectedAttachmentDownloadUrl = selectedAttachment.downloadUrl;
93
+ const selectedAttachmentName = selectedAttachment.name;
94
+ checkFileSourcesValidation({
95
+ fileName: selectedAttachmentName,
96
+ viewURL: selectedAttachmentViewUrl
97
+ }).then(fileSourceValidation => {
98
+ const {
99
+ isViewURLValid,
100
+ canZoom
101
+ } = fileSourceValidation;
102
+ this.setState({
103
+ isPreviewAttachmentValid: isViewURLValid,
104
+ canZoom,
105
+ canOpenInNewTab: isViewURLValid
106
+ });
107
+ });
66
108
  }
67
109
 
68
110
  togglePViewList() {
@@ -76,13 +118,11 @@ export default class AttachmentViewer extends Component {
76
118
  zoomOut(ele) {
77
119
  this.setState({
78
120
  isZoomed: false
79
- });
80
- const img = document.getElementById(`img${ele}`);
81
-
82
- if (img) {
83
- img.classList.remove(style.zoomedImg);
84
- img.classList.add(style.normalImg);
85
- }
121
+ }); // const img = document.getElementById(`img${ele}`);
122
+ // if (img) {
123
+ // img.classList.remove(style.zoomedImg);
124
+ // img.classList.add(style.normalImg);
125
+ // }
86
126
  }
87
127
 
88
128
  zoomIn(event, ele) {
@@ -113,12 +153,11 @@ export default class AttachmentViewer extends Component {
113
153
  top: 0,
114
154
  left: 0
115
155
  };
116
- }
156
+ } // if (img) {
157
+ // img.classList.remove(style.normalImg);
158
+ // img.classList.add(style.zoomedImg);
159
+ // }
117
160
 
118
- if (img) {
119
- img.classList.remove(style.normalImg);
120
- img.classList.add(style.zoomedImg);
121
- }
122
161
 
123
162
  if (moveToPosition) {
124
163
  imgContainer.scrollLeft = (event.pageX - imgContainerPosition.left - imgUnits.left) * imgRatio.width;
@@ -217,7 +256,9 @@ export default class AttachmentViewer extends Component {
217
256
  const {
218
257
  dataList,
219
258
  selectedIndex,
220
- isZoomed
259
+ isZoomed,
260
+ canZoom,
261
+ isPreviewAttachmentValid
221
262
  } = this.state;
222
263
  const {
223
264
  maintainZoom,
@@ -252,7 +293,23 @@ export default class AttachmentViewer extends Component {
252
293
  return dataList.length && dataList.map(function () {
253
294
  let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
254
295
  let i = arguments.length > 1 ? arguments[1] : undefined;
255
- const selectedImgUrl = data.viewUrl;
296
+ const {
297
+ viewUrl,
298
+ name,
299
+ children,
300
+ dataId = 'attachViewer',
301
+ customClass = {},
302
+ customProps = {}
303
+ } = data;
304
+ const {
305
+ audioProps = {},
306
+ imageProps = {}
307
+ } = customProps;
308
+ const {
309
+ customImageClass = '',
310
+ customChildrenClass = ''
311
+ } = customClass;
312
+ const retainZoom = canZoom && selectedIndex == i && maintainZoom;
256
313
  return /*#__PURE__*/React.createElement(Container, {
257
314
  className: style.imgBox,
258
315
  id: `imgBox${i}`,
@@ -263,27 +320,32 @@ export default class AttachmentViewer extends Component {
263
320
  }, /*#__PURE__*/React.createElement(Box, {
264
321
  className: style.imgRef,
265
322
  id: `imgPreviewRef${i}`
266
- }, isAudioFile(data.name) ? selectedIndex == i ? /*#__PURE__*/React.createElement("video", {
323
+ }, isAudioFile(name) ? selectedIndex == i ? /*#__PURE__*/React.createElement("video", {
267
324
  autoPlay: true,
268
325
  controls: true,
269
326
  className: style.zoomIn,
270
327
  "data-id": `${dataId}_videoPreview`,
271
- "data-test-id": `${dataId}_videoPreview`
328
+ "data-test-id": `${dataId}_videoPreview`,
329
+ ...audioProps
272
330
  }, /*#__PURE__*/React.createElement("source", {
273
- src: data.viewUrl,
274
- type: `audio/${getExtensionFromFileName(data.name)}`
331
+ src: viewUrl,
332
+ type: `audio/${getExtensionFromFileName(name)}`
275
333
  })) : null : /*#__PURE__*/React.createElement(AttachmentImage, {
276
- className: `${style.img} ${selectedIndex == i && maintainZoom ? isZoomed ? style.zoomedImg : style.normalImg : ''}`,
277
- src: selectedImgUrl,
278
- onClick: isZoomed ? _this.zoomOut.bind(_this, i) : e => {
279
- _this.zoomIn(e, i, true);
334
+ customClass: {
335
+ customImageClass: `${style.img} ${style.altText}
336
+ ${canZoom || retainZoom ? isZoomed ? `${style.zoomedImg} ${style.zoomOutCursor}` : `${style.normalImg} ${style.zoomInCursor}` : ''} ${customImageClass}`,
337
+ customChildrenClass
280
338
  },
281
- alt: "Preview",
282
- dataId: "attachViewer",
339
+ src: viewUrl,
340
+ onClick: isPreviewAttachmentValid ? isZoomed ? _this.zoomOut.bind(_this, i) : e => {
341
+ _this.zoomIn(e, i, true);
342
+ } : undefined,
343
+ alt: name,
344
+ dataId: dataId,
283
345
  id: `img${i}`,
284
- isImage: true,
285
- isCover: false
286
- })));
346
+ isCover: false,
347
+ ...imageProps
348
+ }, children)));
287
349
  });
288
350
  }
289
351
 
@@ -292,7 +354,9 @@ export default class AttachmentViewer extends Component {
292
354
  isPViewListOpen,
293
355
  selectedIndex,
294
356
  data,
295
- isZoomed
357
+ isZoomed,
358
+ canZoom,
359
+ canOpenInNewTab
296
360
  } = this.state;
297
361
  const {
298
362
  responsiveId,
@@ -354,7 +418,7 @@ export default class AttachmentViewer extends Component {
354
418
  align: uptoTablet ? 'bottom' : 'center',
355
419
  wrap: "wrap",
356
420
  isCover: false
357
- }, isZoomed ? /*#__PURE__*/React.createElement("div", {
421
+ }, canZoom ? isZoomed ? /*#__PURE__*/React.createElement("div", {
358
422
  className: uptoTablet ? style.mobileMenu : style.menu,
359
423
  onClick: this.zoomOut.bind(this, selectedIndex),
360
424
  "data-id": "zoomOut",
@@ -382,7 +446,7 @@ export default class AttachmentViewer extends Component {
382
446
  a11y: {
383
447
  ariaLabel: i18nKeys.zoomInText
384
448
  }
385
- })), /*#__PURE__*/React.createElement("div", {
449
+ })) : null, canOpenInNewTab ? /*#__PURE__*/React.createElement("div", {
386
450
  className: uptoTablet ? style.mobileMenu : style.menu
387
451
  }, /*#__PURE__*/React.createElement(Link, {
388
452
  href: selectedImgUrl,
@@ -398,7 +462,7 @@ export default class AttachmentViewer extends Component {
398
462
  a11y: {
399
463
  ariaLabel: i18nKeys.newTabText
400
464
  }
401
- }))), needDownload ? /*#__PURE__*/React.createElement("div", {
465
+ }))) : null, needDownload ? /*#__PURE__*/React.createElement("div", {
402
466
  className: uptoTablet ? style.mobileMenu : style.menu
403
467
  }, /*#__PURE__*/React.createElement(Link, {
404
468
  href: downloadUrl,
@@ -504,24 +568,39 @@ export default class AttachmentViewer extends Component {
504
568
  }, data.map((item, index) => {
505
569
  const {
506
570
  name,
507
- viewUrl
571
+ viewUrl,
572
+ children,
573
+ customClass = {},
574
+ dataId = 'AttachmentImage',
575
+ customProps = {}
508
576
  } = item;
509
- const isAudio = isAudioFile(name);
577
+ let {
578
+ thumbnail
579
+ } = item;
580
+ const {
581
+ customImageClass = '',
582
+ customChildrenClass = ''
583
+ } = customClass;
584
+ thumbnail = isAudioFile(name) ? thumbnail || audioThumbNail : thumbnail; //fallback thumbnail for audio
585
+
510
586
  return /*#__PURE__*/React.createElement(Box, {
511
- className: `${style.imgItem} ${index === selectedIndex ? style.selected : ''} ${isAudio ? style.isAudio : ''}`,
587
+ className: `${style.imgItem} ${index === selectedIndex ? style.selected : ''}`,
512
588
  key: index,
513
589
  onClick: this.changeSelectedIndex.bind(this, index),
514
590
  eleRef: el => this[`img_${index}`] = el,
515
591
  dataId: "attachPreviewList",
516
592
  "data-title": name
517
593
  }, /*#__PURE__*/React.createElement(AttachmentImage, {
518
- src: viewUrl,
594
+ src: thumbnail || viewUrl,
519
595
  size: "small",
520
596
  alt: name,
521
- className: style.image,
522
- isImage: !isAudio,
523
- dataId: "AttachmentImage"
524
- }));
597
+ customClass: {
598
+ customImageClass: `${style.image} ${style.altText} ${customImageClass}`,
599
+ customChildrenClass: `${style.crsrPointer} ${customChildrenClass}`
600
+ },
601
+ dataId: dataId,
602
+ ...customProps
603
+ }, children));
525
604
  }))))), totalLen !== 1 && /*#__PURE__*/React.createElement(IconButton, {
526
605
  dataId: "attachToggle",
527
606
  onClick: this.togglePViewList,
@@ -1,14 +1,18 @@
1
1
  import PropTypes from 'prop-types';
2
2
  export const AttachmentImage_propTypes = {
3
3
  alt: PropTypes.string,
4
- className: PropTypes.string,
4
+ customClass: PropTypes.shape({
5
+ customImageClass: PropTypes.string,
6
+ customChildrenClass: PropTypes.string
7
+ }),
5
8
  dataId: PropTypes.string,
6
9
  id: PropTypes.string,
7
10
  isCover: PropTypes.bool,
8
- isImage: PropTypes.bool,
9
11
  onClick: PropTypes.func,
10
12
  onLoad: PropTypes.func,
11
- src: PropTypes.string
13
+ onError: PropTypes.func,
14
+ src: PropTypes.string,
15
+ children: PropTypes.node
12
16
  };
13
17
  export const AttachmentViewer_propTypes = {
14
18
  hideAttachmentViewer: PropTypes.func,
@@ -13,7 +13,9 @@ export default function Image(props) {
13
13
  dataId,
14
14
  htmlId,
15
15
  eleRef,
16
- original
16
+ original,
17
+ onLoad,
18
+ onError
17
19
  } = props;
18
20
  return /*#__PURE__*/React.createElement("img", {
19
21
  src: src,
@@ -25,7 +27,9 @@ export default function Image(props) {
25
27
  onClick: onClick,
26
28
  id: htmlId,
27
29
  ref: eleRef,
28
- "data-original": original
30
+ "data-original": original,
31
+ onLoad: onLoad,
32
+ onError: onError
29
33
  });
30
34
  }
31
35
  Image.propTypes = propTypes;
@@ -9,5 +9,7 @@ export const propTypes = {
9
9
  onClick: PropTypes.func,
10
10
  original: PropTypes.string,
11
11
  src: PropTypes.string.isRequired,
12
- title: PropTypes.string
12
+ title: PropTypes.string,
13
+ onLoad: PropTypes.func,
14
+ onError: PropTypes.func
13
15
  };
@@ -72,6 +72,7 @@ function CurrencyField(props) {
72
72
  }
73
73
 
74
74
  let uniqueId = htmlId ? htmlId : getNextId();
75
+ const isFocusable = !needReadOnlyStyle || !isReadOnly && needReadOnlyStyle;
75
76
 
76
77
  function handleChange(value) {
77
78
  onChange && onChange(id, value);
@@ -124,7 +125,7 @@ function CurrencyField(props) {
124
125
  onChange: handleChange,
125
126
  dataId: dataId,
126
127
  onBlur: handleonBlur,
127
- onFocus: handleonFocus,
128
+ onFocus: isFocusable && handleonFocus,
128
129
  onKeyDown: onKeyDown,
129
130
  placeHolder: placeHolder,
130
131
  borderColor: borderColor,
@@ -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
+ customInitOption
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 (!customInitOption) {
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, customInitOption);
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,12 @@ 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
+ customStyleTag.type = 'text/css';
245
+ const customizedCSS = `pre {white-space: pre-wrap} ${customCSS}`;
246
+ 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')}`;
247
+ customStyleTag.textContent = `${customizedCSS} ${fontCSS}`;
248
+ iframeHead.appendChild(customStyleTag);
251
249
  }
252
250
  }
253
251
 
@@ -255,13 +253,26 @@ export default class TextEditor extends Component {
255
253
  let {
256
254
  id,
257
255
  setInlineAttachmentInProgress: progress,
258
- i18nKeys
256
+ i18nKeys,
257
+ inlineImageProps
259
258
  } = this.props;
260
-
261
- if (!isFileNameSizeInvalid(file.name)) {
259
+ const {
260
+ fileUploadError,
261
+ fileNotSupported,
262
+ fileSizeLimitExceed,
263
+ fileEmptyError,
264
+ fileNameLimitExceed
265
+ } = i18nKeys;
266
+ const {
267
+ allowedFileExtensions = ["jpeg", "jpg", "png", "gif", "bmp", "ico"],
268
+ fileNameMaxCharacters = 200,
269
+ fileSizeMaxBytes = 3 * 1024 * 1024
270
+ } = inlineImageProps;
271
+
272
+ if (!isFileNameSizeInvalid(file.name, fileNameMaxCharacters)) {
262
273
  if (file.size != 0) {
263
- if (file.size <= 3 * 1024 * 1024) {
264
- if (isImageFormat(file.name)) {
274
+ if (file.size <= fileSizeMaxBytes) {
275
+ if (isImageFormat(file.name, allowedFileExtensions)) {
265
276
  progress && progress(true);
266
277
  this.handleUpload(file).then(res => {
267
278
  successCallback(res);
@@ -271,37 +282,33 @@ export default class TextEditor extends Component {
271
282
  triggerKeyup(editorObj.doc);
272
283
  }
273
284
  }, () => {
274
- failureCallback(i18nKeys.fileUploadError);
285
+ failureCallback(fileUploadError);
275
286
  });
276
287
  } else {
277
- failureCallback(i18nKeys.fileNotSupported);
288
+ failureCallback(fileNotSupported);
278
289
  }
279
290
  } else {
280
- failureCallback(i18nKeys.fileSizeLimitExceed);
291
+ failureCallback(fileSizeLimitExceed);
281
292
  }
282
293
  } else {
283
- failureCallback(i18nKeys.fileEmptyError);
294
+ failureCallback(fileEmptyError);
284
295
  }
285
296
  } else {
286
- failureCallback(i18nKeys.fileNameLimitExceed);
297
+ failureCallback(fileNameLimitExceed);
287
298
  }
288
- }
299
+ } // handleDropUpload(file, successCallback, failureCallback) {
300
+ // let e = { target: { files: [file] } };
301
+ // let { handleDropUpload } = this.props;
302
+ // handleDropUpload(e).then(
303
+ // (res) => {
304
+ // successCallback(res);
305
+ // },
306
+ // () => {
307
+ // failureCallback();
308
+ // }
309
+ // );
310
+ // }
289
311
 
290
- handleDropUpload(file, successCallback, failureCallback) {
291
- let e = {
292
- target: {
293
- files: [file]
294
- }
295
- };
296
- let {
297
- handleDropUpload
298
- } = this.props;
299
- handleDropUpload(e).then(res => {
300
- successCallback(res);
301
- }, () => {
302
- failureCallback();
303
- });
304
- }
305
312
 
306
313
  blurCallback() {
307
314
  let {
@@ -327,15 +334,7 @@ export default class TextEditor extends Component {
327
334
  formData.append(getCSRFCookieName(), getCSRFCookie());
328
335
  }
329
336
 
330
- return onUpload(formData, file).then(res => {
331
- if (editorMode === 'TicketReply') {
332
- return `${res.data}&from=r`;
333
- }
334
-
335
- return res.data;
336
- }, err => {
337
- throw err;
338
- });
337
+ return onUpload(formData, file);
339
338
  } catch (err) {
340
339
  return Promise.reject();
341
340
  }
@@ -355,7 +354,6 @@ export default class TextEditor extends Component {
355
354
  let cont = value;
356
355
 
357
356
  if (typeof editor !== 'undefined') {
358
- // eslint-disable-next-line
359
357
  cont = editor['addFormEditor'] && editor['addFormEditor'].getContent();
360
358
  }
361
359
 
@@ -384,7 +382,8 @@ export default class TextEditor extends Component {
384
382
  loadingComponent,
385
383
  isNightMode,
386
384
  isReadOnly,
387
- dataSelectorId
385
+ dataSelectorId,
386
+ isDisabled
388
387
  } = this.props;
389
388
  let {
390
389
  isEditorLoad,
@@ -393,7 +392,7 @@ export default class TextEditor extends Component {
393
392
  let editorDoc = ImgLazyLoad && global.editor && global.editor[id] ? global.editor[id].doc : null;
394
393
  return /*#__PURE__*/React.createElement(Container, {
395
394
  className: `${styles.textEditor} ${styles[type]} ${styles[border]}
396
- ${isNightMode ? styles.night : styles.light} ${isReadOnly ? styles.readOnly : ''} ${!isEditorShow ? styles.editorHide : ''}`,
395
+ ${isNightMode ? styles.night : styles.light} ${isReadOnly ? styles.readOnly : ''} ${isReadOnly || isDisabled ? styles.disable : ''} ${!isEditorShow ? styles.editorHide : ''}`,
397
396
  dataId: dataId,
398
397
  "data-isEditor": true,
399
398
  dataSelectorId: dataSelectorId
@@ -403,7 +402,7 @@ export default class TextEditor extends Component {
403
402
  dataId: dataId
404
403
  }), editorDoc && ImgLazyLoad ? /*#__PURE__*/React.createElement(ImgLazyLoad, {
405
404
  node: editorDoc
406
- }) : null, isReadOnly ? /*#__PURE__*/React.createElement("div", {
405
+ }) : null, isReadOnly || isDisabled ? /*#__PURE__*/React.createElement("div", {
407
406
  className: styles.readOnlyMask
408
407
  }) : null);
409
408
  }
@@ -9,5 +9,8 @@ export const defaultProps = {
9
9
  needInlineAttachment: false,
10
10
  isNightMode: false,
11
11
  isReadOnly: false,
12
- dataSelectorId: 'textEditor'
12
+ dataSelectorId: 'textEditor',
13
+ customCSS: '',
14
+ isDisabled: false,
15
+ inlineImageProps: {}
13
16
  };
@@ -12,7 +12,6 @@ export const propTypes = {
12
12
  fontSize: PropTypes.string,
13
13
  getRef: PropTypes.func,
14
14
  handleAlertMessage: PropTypes.func,
15
- handleDropUpload: PropTypes.func,
16
15
  i18nKeys: PropTypes.shape({
17
16
  fileUploadError: PropTypes.string,
18
17
  fileNotSupported: PropTypes.string,
@@ -21,7 +20,7 @@ export const propTypes = {
21
20
  fileSizeLimitExceed: PropTypes.string
22
21
  }),
23
22
  id: PropTypes.string,
24
- initCallback: PropTypes.func.isRequired,
23
+ initCallback: PropTypes.func,
25
24
  isCustomScroll: PropTypes.bool,
26
25
  loadingComponent: PropTypes.node,
27
26
  mode: PropTypes.string,
@@ -42,5 +41,13 @@ export const propTypes = {
42
41
  getCSRFCookie: PropTypes.string,
43
42
  isEditorDefaultOpen: PropTypes.bool,
44
43
  toggleEdit: PropTypes.func,
45
- dataSelectorId: PropTypes.string
44
+ dataSelectorId: PropTypes.string,
45
+ customInitOption: PropTypes.object,
46
+ customCSS: PropTypes.string,
47
+ isDisabled: PropTypes.bool,
48
+ inlineImageProps: PropTypes.shape({
49
+ allowedFileExtensions: PropTypes.array,
50
+ fileNameMaxCharacters: PropTypes.number,
51
+ fileSizeMaxBytes: PropTypes.number
52
+ })
46
53
  };
@@ -73,6 +73,8 @@ function StatusDropdown(props) {
73
73
  isRestrictScroll,
74
74
  positionsOffset,
75
75
  targetOffset,
76
+ renderTargetElement,
77
+ renderFooterElement,
76
78
  a11y = {}
77
79
  } = props;
78
80
  const [optionsList, setOptionsList] = useState(options);
@@ -149,7 +151,11 @@ function StatusDropdown(props) {
149
151
  className: style.posRel,
150
152
  onMouseEnter: showOnHover && !isDisabled && !isReadOnly && isEditable ? handleTogglePopup : undefined,
151
153
  onMouseLeave: showOnHover && !isDisabled && !isReadOnly && isEditable ? handleTogglePopup : undefined
152
- }, /*#__PURE__*/React.createElement(Container, {
154
+ }, renderTargetElement ? renderTargetElement({
155
+ handleTogglePopup,
156
+ isPopupOpen,
157
+ getTargetRef
158
+ }) : /*#__PURE__*/React.createElement(Container, {
153
159
  tagName: "button",
154
160
  alignBox: "row",
155
161
  className: `${style.container} ${containerClass} ${btnStyle.buttonReset}`,
@@ -289,7 +295,7 @@ function StatusDropdown(props) {
289
295
  getEmptyState: emptySearchSVG
290
296
  }) : /*#__PURE__*/React.createElement("div", {
291
297
  className: style.loader
292
- }, /*#__PURE__*/React.createElement(Loader, null)))));
298
+ }, /*#__PURE__*/React.createElement(Loader, null))), renderFooterElement ? renderFooterElement : null));
293
299
  }) : null);
294
300
  }
295
301
 
@@ -54,5 +54,7 @@ export const propTypes = {
54
54
  isRestrictScroll: PropTypes.bool,
55
55
  positionsOffset: PropTypes.object,
56
56
  targetOffset: PropTypes.object,
57
+ renderTargetElement: PropTypes.func,
58
+ renderFooterElement: PropTypes.node,
57
59
  a11y: PropTypes.object
58
60
  };