@zohoim/chat-components 1.0.9-alpha.0 → 1.0.9-beta.2
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/ActionIcon/ActionIcon.js +3 -1
- package/es/ActionIcon/props/propTypes.js +2 -1
- package/es/ActionIconWrapper/ActionIconWrapper.js +6 -3
- package/es/ActionIconWrapper/css/ActionIconWrapper.module.css +1 -1
- package/es/ActionIconWrapper/css/cssJSLogic.js +4 -2
- package/es/ActionIconWrapper/props/propTypes.js +2 -1
- package/es/AttachmentHandler/AttachmentHandler.js +84 -0
- package/es/AttachmentHandler/css/AttachmentHandler.module.css +17 -0
- package/es/AttachmentHandler/index.js +1 -0
- package/es/AttachmentHandler/props/defaultProps.js +10 -0
- package/es/AttachmentHandler/props/propTypes.js +17 -0
- package/es/AttachmentPreview/AttachmentPreview.js +113 -0
- package/es/AttachmentPreview/css/AttachmentPreview.module.css +30 -0
- package/es/AttachmentPreview/index.js +1 -0
- package/es/AttachmentPreview/props/defaultProps.js +7 -0
- package/es/AttachmentPreview/props/propTypes.js +31 -0
- package/es/AttachmentPreviewBody/AttachmentPreviewBody.js +81 -0
- package/es/AttachmentPreviewBody/css/AttachmentPreviewBody.module.css +68 -0
- package/es/AttachmentPreviewBody/index.js +1 -0
- package/es/AttachmentPreviewBody/props/defaultProps.js +7 -0
- package/es/AttachmentPreviewBody/props/propTypes.js +20 -0
- package/es/AttachmentPreviewHeader/AttachmentPreviewHeader.js +84 -0
- package/es/AttachmentPreviewHeader/css/AttachmentPreviewHeader.module.css +47 -0
- package/es/AttachmentPreviewHeader/index.js +1 -0
- package/es/AttachmentPreviewHeader/props/defaultProps.js +7 -0
- package/es/AttachmentPreviewHeader/props/propTypes.js +16 -0
- package/es/Emoji/Emoji.js +72 -0
- package/es/Emoji/css/Emoji.module.css +47 -0
- package/es/Emoji/css/cssJSLogic.js +18 -0
- package/es/Emoji/index.js +1 -0
- package/es/Emoji/props/defaultProps.js +8 -0
- package/es/Emoji/props/propTypes.js +16 -0
- package/es/EmojiPopup/EmojiPopup.js +116 -0
- package/es/EmojiPopup/css/EmojiPopup.module.css +50 -0
- package/es/EmojiPopup/index.js +1 -0
- package/es/EmojiPopup/props/defaultProps.js +11 -0
- package/es/EmojiPopup/props/propTypes.js +21 -0
- package/es/Emojis/Emojis.js +81 -0
- package/es/Emojis/index.js +1 -0
- package/es/Emojis/props/defaultProps.js +10 -0
- package/es/Emojis/props/propTypes.js +19 -0
- package/es/EmojisEmptyState/EmojisEmptyState.js +50 -0
- package/es/EmojisEmptyState/css/EmojisEmptyState.module.css +18 -0
- package/es/EmojisEmptyState/index.js +1 -0
- package/es/EmojisEmptyState/props/defaultProps.js +9 -0
- package/es/EmojisEmptyState/props/propTypes.js +8 -0
- package/es/EmojisFooter/EmojisFooter.js +71 -0
- package/es/EmojisFooter/css/EmojisFooter.module.css +40 -0
- package/es/EmojisFooter/index.js +1 -0
- package/es/EmojisFooter/props/defaultProps.js +7 -0
- package/es/EmojisFooter/props/propTypes.js +12 -0
- package/es/EmojisHeader/EmojisHeader.js +65 -0
- package/es/EmojisHeader/css/EmojisHeader.module.css +36 -0
- package/es/EmojisHeader/index.js +1 -0
- package/es/EmojisHeader/props/defaultProps.js +8 -0
- package/es/EmojisHeader/props/propTypes.js +13 -0
- package/es/EmojisList/EmojisList.js +133 -0
- package/es/EmojisList/css/EmojisList.module.css +50 -0
- package/es/EmojisList/css/cssJSLogic.js +25 -0
- package/es/EmojisList/index.js +1 -0
- package/es/EmojisList/props/defaultProps.js +10 -0
- package/es/EmojisList/props/propTypes.js +20 -0
- package/es/MessageAction/MessageAction.js +2 -0
- package/es/MessageAction/props/propTypes.js +2 -1
- package/es/MessageActions/MessageActions.js +2 -1
- package/es/MessageActionsMore/MessageActionsMore.js +6 -4
- package/es/MessageActionsMore/css/MessageActionsMore.module.css +1 -0
- package/es/MessageActionsMore/props/propTypes.js +5 -2
- package/es/MessageActionsWrapper/MessageActionsWrapper.js +2 -1
- package/es/MessageActionsWrapper/css/MessageActionsWrapper.module.css +4 -0
- package/es/Theme/ThemeAssets.js +2 -20
- package/es/Theme/ThemeWrapper.js +23 -14
- package/es/Theme/TooltipWrapper.js +1 -1
- package/es/Theme/props/defaultProps.js +2 -1
- package/es/Theme/props/propTypes.js +2 -1
- package/es/Theme/themeVariables/commonThemeColorVariable.js +17 -0
- package/es/Theme/themeVariables/dark/blueTheme.js +130 -0
- package/es/Theme/themeVariables/dark/commonColorVariable.js +35 -0
- package/es/Theme/themeVariables/dark/greenTheme.js +129 -0
- package/es/Theme/themeVariables/dark/orangeTheme.js +129 -0
- package/es/Theme/themeVariables/dark/redTheme.js +129 -0
- package/es/Theme/themeVariables/dark/yellowTheme.js +129 -0
- package/es/Theme/themeVariables/light/blueTheme.js +132 -0
- package/es/Theme/themeVariables/light/commonColorVariable.js +54 -0
- package/es/Theme/themeVariables/light/greenTheme.js +127 -0
- package/es/Theme/themeVariables/light/orangeTheme.js +127 -0
- package/es/Theme/themeVariables/light/redTheme.js +127 -0
- package/es/Theme/themeVariables/light/yellowTheme.js +127 -0
- package/es/Theme/themeVariables/pureDark/blueTheme.js +129 -0
- package/es/Theme/themeVariables/pureDark/commonColorVariable.js +37 -0
- package/es/Theme/themeVariables/pureDark/greenTheme.js +129 -0
- package/es/Theme/themeVariables/pureDark/orangeTheme.js +129 -0
- package/es/Theme/themeVariables/pureDark/redTheme.js +129 -0
- package/es/Theme/themeVariables/pureDark/yellowTheme.js +129 -0
- package/es/Theme/utils/getThemeConfigurations.js +56 -2
- package/es/constants/index.js +7 -1
- package/es/constants/propConstants/editorPropConstants.js +3 -0
- package/es/constants/propConstants/popupPropConstants.js +2 -0
- package/es/im/IMAttachmentHandler/IMAttachmentHandler.js +50 -0
- package/es/im/IMAttachmentHandler/index.js +1 -0
- package/es/im/IMAttachmentHandler/props/defaultProps.js +10 -0
- package/es/im/IMAttachmentHandler/props/propTypes.js +28 -0
- package/es/im/IMIntegrationIcon/css/IMIntegrationIcon.module.css +2 -2
- package/es/im/ReplyComposer/ReplyComposer.js +137 -0
- package/es/im/ReplyComposer/css/ReplyComposer.module.css +5 -0
- package/es/im/ReplyComposer/index.js +1 -0
- package/es/im/ReplyComposer/props/defaultProps.js +7 -0
- package/es/im/ReplyComposer/props/propTypes.js +60 -0
- package/es/im/ReplyComposerFooter/ReplyComposerFooter.js +41 -0
- package/es/im/ReplyComposerFooter/css/ReplyComposerFooter.module.css +5 -0
- package/es/im/ReplyComposerFooter/index.js +1 -0
- package/es/im/ReplyComposerFooter/props/defaultProps.js +8 -0
- package/es/im/ReplyComposerFooter/props/propTypes.js +17 -0
- package/es/im/ReplyEditor/ReplyEditor.js +103 -0
- package/es/im/ReplyEditor/css/ReplyEditor.module.css +38 -0
- package/es/im/ReplyEditor/css/cssJSLogic.js +10 -0
- package/es/im/ReplyEditor/index.js +1 -0
- package/es/im/ReplyEditor/props/defaultProps.js +8 -0
- package/es/im/ReplyEditor/props/propTypes.js +27 -0
- package/es/im/ReplyEditorExtensions/ReplyEditorExtensions.js +149 -0
- package/es/im/ReplyEditorExtensions/css/ReplyEditorExtensions.module.css +5 -0
- package/es/im/ReplyEditorExtensions/index.js +1 -0
- package/es/im/ReplyEditorExtensions/props/defaultProps.js +6 -0
- package/es/im/ReplyEditorExtensions/props/propTypes.js +16 -0
- package/es/im/ReplyEditorSuggestions/ReplyEditorSuggestions.js +87 -0
- package/es/im/ReplyEditorSuggestions/css/ReplyEditorSuggestions.module.css +8 -0
- package/es/im/ReplyEditorSuggestions/index.js +1 -0
- package/es/im/ReplyEditorSuggestions/props/defaultProps.js +6 -0
- package/es/im/ReplyEditorSuggestions/props/propTypes.js +20 -0
- package/es/im/ReplyEditorSuggestionsPopup/ReplyEditorSuggestionsPopup.js +90 -0
- package/es/im/ReplyEditorSuggestionsPopup/css/ReplyEditorSuggestionsPopup.module.css +7 -0
- package/es/im/ReplyEditorSuggestionsPopup/index.js +1 -0
- package/es/im/ReplyEditorSuggestionsPopup/props/defaultProps.js +10 -0
- package/es/im/ReplyEditorSuggestionsPopup/props/propTypes.js +21 -0
- package/es/im/index.js +8 -1
- package/es/index.js +13 -2
- package/es/rte/Editor/Editor.js +80 -0
- package/es/rte/Editor/css/Editor.module.css +19 -0
- package/es/rte/Editor/index.js +1 -0
- package/es/rte/Editor/props/defaultProps.js +21 -0
- package/es/rte/Editor/props/propTypes.js +52 -0
- package/es/rte/index.js +1 -0
- package/package.json +13 -20
- package/assets/Appearance/dark/mode/General_DarkMode.module.css +0 -71
- package/assets/Appearance/dark/themes/blue/blue_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/green/green_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/orange/orange_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/red/red_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/dark/themes/yellow/yellow_General_DarkTheme.module.css +0 -35
- package/assets/Appearance/light/mode/General_LightMode.module.css +0 -71
- package/assets/Appearance/light/themes/blue/blue_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/green/green_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/orange/orange_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/red/red_General_LightTheme.module.css +0 -35
- package/assets/Appearance/light/themes/yellow/yellow_General_LightTheme.module.css +0 -35
- package/assets/Appearance/pureDark/mode/General_PureDarkMode.module.css +0 -71
- package/assets/Appearance/pureDark/themes/blue/blue_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/green/green_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/orange/orange_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/red/red_General_PureDarkTheme.module.css +0 -35
- package/assets/Appearance/pureDark/themes/yellow/yellow_General_PureDarkTheme.module.css +0 -35
- package/es/Theme/constants/index.js +0 -41
- package/lib/index.js +0 -382
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import ReplyEditorExtensions from "../ReplyEditorExtensions/ReplyEditorExtensions";
|
|
6
|
+
/** ** Hooks *** */
|
|
7
|
+
|
|
8
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
9
|
+
/** ** Constants *** */
|
|
10
|
+
|
|
11
|
+
import replyComposerFooterDefaultProps from "./props/defaultProps";
|
|
12
|
+
import replyComposerFooterPropTypes from "./props/propTypes";
|
|
13
|
+
/** ** Methods *** */
|
|
14
|
+
|
|
15
|
+
import renderHandler from '@zohoim/chat-components-utils/es/common/renderHandler';
|
|
16
|
+
/** ** Styles *** */
|
|
17
|
+
|
|
18
|
+
import style from "./css/ReplyComposerFooter.module.css";
|
|
19
|
+
export default function ReplyComposerFooter(props) {
|
|
20
|
+
const {
|
|
21
|
+
customStyle,
|
|
22
|
+
editor,
|
|
23
|
+
isHTMLContent,
|
|
24
|
+
extensions,
|
|
25
|
+
renderButtons
|
|
26
|
+
} = props;
|
|
27
|
+
/* External customization */
|
|
28
|
+
|
|
29
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
30
|
+
const footerButtons = useMemo(() => renderHandler(renderButtons)(), [renderButtons]);
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: newStyle.replyComposerFooter
|
|
33
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReplyEditorExtensions, {
|
|
34
|
+
editor: editor,
|
|
35
|
+
extensions: extensions,
|
|
36
|
+
isHTMLContent: isHTMLContent
|
|
37
|
+
})), footerButtons || null);
|
|
38
|
+
}
|
|
39
|
+
ReplyComposerFooter.propTypes = replyComposerFooterPropTypes;
|
|
40
|
+
ReplyComposerFooter.defaultProps = replyComposerFooterDefaultProps;
|
|
41
|
+
ReplyComposerFooter.displayName = 'ReplyComposerFooter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReplyComposerFooter } from "./ReplyComposerFooter";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** ** Constants *** */
|
|
2
|
+
import { dummyArray, dummyObject } from '@zohoim/chat-components-utils/es/constants';
|
|
3
|
+
const replyComposerFooterDefaultProps = {
|
|
4
|
+
customStyle: dummyObject,
|
|
5
|
+
isHTMLContent: dummyArray,
|
|
6
|
+
extensions: dummyArray
|
|
7
|
+
};
|
|
8
|
+
export default replyComposerFooterDefaultProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const replyComposerFooterPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
editor: PropTypes.object.isRequired,
|
|
6
|
+
isHTMLContent: PropTypes.bool,
|
|
7
|
+
extensions: PropTypes.shape({
|
|
8
|
+
details: PropTypes.objectOf(PropTypes.shape({
|
|
9
|
+
componentProps: PropTypes.object,
|
|
10
|
+
id: PropTypes.string,
|
|
11
|
+
renderItem: PropTypes.func
|
|
12
|
+
})),
|
|
13
|
+
order: PropTypes.array
|
|
14
|
+
}).isRequired,
|
|
15
|
+
renderButtons: PropTypes.func
|
|
16
|
+
};
|
|
17
|
+
export default replyComposerFooterPropTypes;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import Editor from "../../rte/Editor/Editor";
|
|
6
|
+
import { Container } from '@zohodesk/components/es/Layout';
|
|
7
|
+
/** ** Hooks *** */
|
|
8
|
+
|
|
9
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
10
|
+
import useReplyEditor from '@zohoim/chat-components-hooks/es/im/ReplyEditor/useReplyEditor';
|
|
11
|
+
/** ** Constants *** */
|
|
12
|
+
|
|
13
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
14
|
+
import replyEditorDefaultProps from "./props/defaultProps";
|
|
15
|
+
import replyEditorPropTypes from "./props/propTypes";
|
|
16
|
+
/** ** Methods *** */
|
|
17
|
+
|
|
18
|
+
import cssJSLogic from "./css/cssJSLogic";
|
|
19
|
+
/** ** Styles *** */
|
|
20
|
+
|
|
21
|
+
import style from "./css/ReplyEditor.module.css";
|
|
22
|
+
export default function ReplyEditor(props) {
|
|
23
|
+
const {
|
|
24
|
+
id,
|
|
25
|
+
content,
|
|
26
|
+
EDITORURL,
|
|
27
|
+
placeHolder,
|
|
28
|
+
features,
|
|
29
|
+
formats,
|
|
30
|
+
isHTMLContent,
|
|
31
|
+
onChange,
|
|
32
|
+
onKeyDown,
|
|
33
|
+
onPaste,
|
|
34
|
+
onEnter,
|
|
35
|
+
onErrorCallback: propOnErrorCallback,
|
|
36
|
+
onReadyCallback: propOnReadyCallback,
|
|
37
|
+
customStyle,
|
|
38
|
+
customProps = dummyObject,
|
|
39
|
+
getEditorState,
|
|
40
|
+
themeVariables
|
|
41
|
+
} = props;
|
|
42
|
+
const {
|
|
43
|
+
editorProps = dummyObject
|
|
44
|
+
} = customProps;
|
|
45
|
+
const {
|
|
46
|
+
customStyle: editorCustomStyle = dummyObject
|
|
47
|
+
} = editorProps;
|
|
48
|
+
const {
|
|
49
|
+
onReadyCallback,
|
|
50
|
+
onErrorCallback,
|
|
51
|
+
isRenderEditor,
|
|
52
|
+
isShowEditor,
|
|
53
|
+
appearance,
|
|
54
|
+
isRTL
|
|
55
|
+
} = useReplyEditor({
|
|
56
|
+
onErrorCallback: propOnErrorCallback,
|
|
57
|
+
onReadyCallback: propOnReadyCallback,
|
|
58
|
+
getEditorState,
|
|
59
|
+
onEnter,
|
|
60
|
+
themeVariables
|
|
61
|
+
});
|
|
62
|
+
/* External customization */
|
|
63
|
+
|
|
64
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
65
|
+
/* CSS classnames added based on logic */
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
editorClass
|
|
69
|
+
} = cssJSLogic(props, newStyle, {
|
|
70
|
+
isShowEditor
|
|
71
|
+
});
|
|
72
|
+
const editorNewCustomStyle = useMemo(() => ({
|
|
73
|
+
editorWrapper: newStyle.editorWrapper,
|
|
74
|
+
editor: newStyle.editor,
|
|
75
|
+
$editableDiv: newStyle.editableDiv,
|
|
76
|
+
...editorCustomStyle
|
|
77
|
+
}), [newStyle, editorCustomStyle]);
|
|
78
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
79
|
+
className: newStyle.replyEditor
|
|
80
|
+
}, isRenderEditor ? /*#__PURE__*/React.createElement(Container, {
|
|
81
|
+
className: editorClass
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Editor, {
|
|
83
|
+
appearance: appearance,
|
|
84
|
+
content: content,
|
|
85
|
+
customStyle: editorNewCustomStyle,
|
|
86
|
+
EDITORURL: EDITORURL,
|
|
87
|
+
features: features,
|
|
88
|
+
formats: formats,
|
|
89
|
+
id: id,
|
|
90
|
+
isHTMLContent: isHTMLContent,
|
|
91
|
+
isRTL: isRTL,
|
|
92
|
+
onChange: onChange,
|
|
93
|
+
onErrorCallback: onErrorCallback,
|
|
94
|
+
onKeyDown: onKeyDown,
|
|
95
|
+
onPaste: onPaste,
|
|
96
|
+
onReadyCallback: onReadyCallback,
|
|
97
|
+
placeHolder: placeHolder,
|
|
98
|
+
...editorProps
|
|
99
|
+
})) : null);
|
|
100
|
+
}
|
|
101
|
+
ReplyEditor.propTypes = replyEditorPropTypes;
|
|
102
|
+
ReplyEditor.defaultProps = replyEditorDefaultProps;
|
|
103
|
+
ReplyEditor.displayName = 'ReplyEditor';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** ** Styles *** */
|
|
2
|
+
|
|
3
|
+
.replyEditor {
|
|
4
|
+
/** ** Use this class for css customisations *** */
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.hiddenEditor {
|
|
8
|
+
/** ** Use this class for css customisations *** */
|
|
9
|
+
/* display: none; */
|
|
10
|
+
/* visibility: hidden; */
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.editableDiv {
|
|
14
|
+
max-height: var(--zd_size250) !important;
|
|
15
|
+
min-height: var(--zd_size80) !important;
|
|
16
|
+
overflow: auto !important;
|
|
17
|
+
font-size: var(--zd_font_size14) !important;
|
|
18
|
+
font-family: var(--zd_regular) !important;
|
|
19
|
+
line-height: 22px !important;
|
|
20
|
+
|
|
21
|
+
--rte-text-color: var(--imlib_chat_components_replyEditor_color) !important;
|
|
22
|
+
--rte-bg-color: var(--imlib_chat_components_replyEditor_bg) !important;
|
|
23
|
+
--rte-placeholder-color: var(
|
|
24
|
+
--imlib_chat_components_replyEditor_placeholder
|
|
25
|
+
) !important;
|
|
26
|
+
--rte-link-text-color: var(
|
|
27
|
+
--imlib_chat_components_replyEditor_color
|
|
28
|
+
) !important;
|
|
29
|
+
padding: 0 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.editorWrapper {
|
|
33
|
+
/** ** Use this class for css customisations *** */
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.editor {
|
|
37
|
+
/** ** Use this class for css customisations *** */
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** ** Methods *** */
|
|
2
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
3
|
+
export default function cssJSLogic(props, style, state) {
|
|
4
|
+
const editorClass = compileClassNames({
|
|
5
|
+
[style.hiddenEditor]: !state.isShowEditor
|
|
6
|
+
});
|
|
7
|
+
return {
|
|
8
|
+
editorClass
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReplyEditor } from "./ReplyEditor";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** ** Constants *** */
|
|
2
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
3
|
+
const replyEditorDefaultProps = {
|
|
4
|
+
customStyle: dummyObject,
|
|
5
|
+
customProps: dummyObject,
|
|
6
|
+
themeVariables: dummyObject
|
|
7
|
+
};
|
|
8
|
+
export default replyEditorDefaultProps;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
/** ** Constants *** */
|
|
4
|
+
|
|
5
|
+
import { features, formats } from "../../../constants/propConstants/editorPropConstants";
|
|
6
|
+
const replyEditorPropTypes = {
|
|
7
|
+
customStyle: PropTypes.object,
|
|
8
|
+
id: PropTypes.string,
|
|
9
|
+
content: PropTypes.string.isRequired,
|
|
10
|
+
EDITORURL: PropTypes.string,
|
|
11
|
+
placeHolder: PropTypes.string,
|
|
12
|
+
features: PropTypes.arrayOf(PropTypes.oneOf(features)),
|
|
13
|
+
formats: PropTypes.arrayOf(PropTypes.oneOf(formats)),
|
|
14
|
+
isHTMLContent: PropTypes.bool,
|
|
15
|
+
onChange: PropTypes.func.isRequired,
|
|
16
|
+
onKeyDown: PropTypes.func,
|
|
17
|
+
onPaste: PropTypes.func,
|
|
18
|
+
onEnter: PropTypes.func,
|
|
19
|
+
onErrorCallback: PropTypes.func,
|
|
20
|
+
onReadyCallback: PropTypes.func,
|
|
21
|
+
themeVariables: PropTypes.object,
|
|
22
|
+
customProps: PropTypes.shape({
|
|
23
|
+
editorProps: PropTypes.object
|
|
24
|
+
}),
|
|
25
|
+
getEditorState: PropTypes.func
|
|
26
|
+
};
|
|
27
|
+
export default replyEditorPropTypes;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import { Container, Box } from '@zohodesk/components/es/Layout';
|
|
6
|
+
import IMAttachmentHandler from "../IMAttachmentHandler/IMAttachmentHandler";
|
|
7
|
+
import EmojiPopup from "../../EmojiPopup/EmojiPopup";
|
|
8
|
+
/** ** Hooks *** */
|
|
9
|
+
|
|
10
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
11
|
+
import useReplyEditorExtensions from '@zohoim/chat-components-hooks/es/im/ReplyEditorExtensions/useReplyEditorExtensions';
|
|
12
|
+
/** ** Constants *** */
|
|
13
|
+
|
|
14
|
+
import { dummyArray, dummyObject } from '@zohoim/chat-components-utils/es/constants/emptyConstants';
|
|
15
|
+
import replyEditorExtensionsDefaultProps from "./props/defaultProps";
|
|
16
|
+
import replyEditorExtensionsPropTypes from "./props/propTypes";
|
|
17
|
+
/** ** Styles *** */
|
|
18
|
+
|
|
19
|
+
import style from "./css/ReplyEditorExtensions.module.css";
|
|
20
|
+
export default function ReplyEditorExtensions(props) {
|
|
21
|
+
const {
|
|
22
|
+
customStyle,
|
|
23
|
+
extensions = dummyObject,
|
|
24
|
+
isHTMLContent,
|
|
25
|
+
editor
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
details = dummyObject,
|
|
29
|
+
order = dummyArray
|
|
30
|
+
} = extensions;
|
|
31
|
+
const handleRenderEmojiExtension = useCallback(_ref => {
|
|
32
|
+
let {
|
|
33
|
+
id,
|
|
34
|
+
onSelect,
|
|
35
|
+
onPopupOpen,
|
|
36
|
+
onPopupClose,
|
|
37
|
+
componentProps
|
|
38
|
+
} = _ref;
|
|
39
|
+
const {
|
|
40
|
+
needFocusOnSelect
|
|
41
|
+
} = componentProps;
|
|
42
|
+
return /*#__PURE__*/React.createElement(EmojiPopup, {
|
|
43
|
+
key: id,
|
|
44
|
+
onPopupClose: onPopupClose,
|
|
45
|
+
onPopupOpen: onPopupOpen,
|
|
46
|
+
onSelect: value => {
|
|
47
|
+
onSelect({
|
|
48
|
+
content: value,
|
|
49
|
+
needFocus: needFocusOnSelect
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
...componentProps
|
|
53
|
+
});
|
|
54
|
+
}, []);
|
|
55
|
+
const handleRenderImageExtension = useCallback(_ref2 => {
|
|
56
|
+
let {
|
|
57
|
+
id,
|
|
58
|
+
componentProps
|
|
59
|
+
} = _ref2;
|
|
60
|
+
return /*#__PURE__*/React.createElement(IMAttachmentHandler, {
|
|
61
|
+
key: id,
|
|
62
|
+
attachmentType: "image",
|
|
63
|
+
iconName: "ZD-TT-image",
|
|
64
|
+
iconSize: "14",
|
|
65
|
+
...componentProps
|
|
66
|
+
});
|
|
67
|
+
}, []);
|
|
68
|
+
const handleRenderFileExtension = useCallback(_ref3 => {
|
|
69
|
+
let {
|
|
70
|
+
id,
|
|
71
|
+
componentProps
|
|
72
|
+
} = _ref3;
|
|
73
|
+
return /*#__PURE__*/React.createElement(IMAttachmentHandler, {
|
|
74
|
+
key: id,
|
|
75
|
+
attachmentType: "document",
|
|
76
|
+
iconName: "ZD-TT-ttAttach",
|
|
77
|
+
iconSize: "14",
|
|
78
|
+
...componentProps
|
|
79
|
+
});
|
|
80
|
+
}, []);
|
|
81
|
+
const defaultRenderMethod = useMemo(() => ({
|
|
82
|
+
emoji: {
|
|
83
|
+
id: 'emoji',
|
|
84
|
+
renderItem: handleRenderEmojiExtension
|
|
85
|
+
},
|
|
86
|
+
image: {
|
|
87
|
+
id: 'image',
|
|
88
|
+
renderItem: handleRenderImageExtension
|
|
89
|
+
},
|
|
90
|
+
file: {
|
|
91
|
+
id: 'file',
|
|
92
|
+
renderItem: handleRenderFileExtension
|
|
93
|
+
}
|
|
94
|
+
}), [handleRenderEmojiExtension, handleRenderFileExtension, handleRenderImageExtension]);
|
|
95
|
+
const {
|
|
96
|
+
onSelect,
|
|
97
|
+
onPopupOpen,
|
|
98
|
+
onPopupClose,
|
|
99
|
+
onRetainSelection,
|
|
100
|
+
onRemoveSelection
|
|
101
|
+
} = useReplyEditorExtensions({
|
|
102
|
+
extensions,
|
|
103
|
+
isHTMLContent,
|
|
104
|
+
editor
|
|
105
|
+
});
|
|
106
|
+
/* External customization */
|
|
107
|
+
|
|
108
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
109
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
110
|
+
alignBox: "row",
|
|
111
|
+
className: newStyle.replyEditorExtensions
|
|
112
|
+
}, order.map(extension => {
|
|
113
|
+
const {
|
|
114
|
+
id,
|
|
115
|
+
renderItem,
|
|
116
|
+
componentProps = dummyObject
|
|
117
|
+
} = details[extension] || {};
|
|
118
|
+
const {
|
|
119
|
+
renderItem: renderMethod
|
|
120
|
+
} = defaultRenderMethod[id] || dummyObject;
|
|
121
|
+
const props = {
|
|
122
|
+
id,
|
|
123
|
+
onSelect,
|
|
124
|
+
componentProps,
|
|
125
|
+
editor,
|
|
126
|
+
onPopupOpen,
|
|
127
|
+
onPopupClose,
|
|
128
|
+
onRetainSelection,
|
|
129
|
+
onRemoveSelection
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if (renderItem) {
|
|
133
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
134
|
+
key: id
|
|
135
|
+
}, renderItem(props));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (renderMethod) {
|
|
139
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
140
|
+
key: id
|
|
141
|
+
}, renderMethod(props));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
ReplyEditorExtensions.propTypes = replyEditorExtensionsPropTypes;
|
|
148
|
+
ReplyEditorExtensions.defaultProps = replyEditorExtensionsDefaultProps;
|
|
149
|
+
ReplyEditorExtensions.displayName = 'ReplyEditorExtensions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReplyEditorExtensions } from "./ReplyEditorExtensions";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const replyEditorExtensionsPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
editor: PropTypes.object.isRequired,
|
|
6
|
+
isHTMLContent: PropTypes.bool,
|
|
7
|
+
extensions: PropTypes.shape({
|
|
8
|
+
details: PropTypes.objectOf(PropTypes.shape({
|
|
9
|
+
componentProps: PropTypes.object,
|
|
10
|
+
id: PropTypes.string,
|
|
11
|
+
renderItem: PropTypes.func
|
|
12
|
+
})),
|
|
13
|
+
order: PropTypes.array
|
|
14
|
+
}).isRequired
|
|
15
|
+
};
|
|
16
|
+
export default replyEditorExtensionsPropTypes;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React, { useMemo, useCallback } from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import { Container } from '@zohodesk/components/es/Layout';
|
|
6
|
+
import Emojis from "../../Emojis/Emojis";
|
|
7
|
+
import ReplyEditorSuggestionsPopup from "../ReplyEditorSuggestionsPopup/ReplyEditorSuggestionsPopup";
|
|
8
|
+
/** ** Hooks *** */
|
|
9
|
+
|
|
10
|
+
import useReplyEditorSuggestions from '@zohoim/chat-components-hooks/es/im/ReplyEditorSuggestions/useReplyEditorSuggestions';
|
|
11
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
12
|
+
/** ** Constants *** */
|
|
13
|
+
|
|
14
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants';
|
|
15
|
+
import replyEditorSuggestionsDefaultProps from "./props/defaultProps";
|
|
16
|
+
import replyEditorSuggestionsPropTypes from "./props/propTypes";
|
|
17
|
+
/** ** Styles *** */
|
|
18
|
+
|
|
19
|
+
import style from "./css/ReplyEditorSuggestions.module.css";
|
|
20
|
+
export default function ReplyEditorSuggestions(props) {
|
|
21
|
+
const {
|
|
22
|
+
customStyle,
|
|
23
|
+
suggestionDetails = dummyObject,
|
|
24
|
+
suggestionsMapping,
|
|
25
|
+
onSelect,
|
|
26
|
+
customProps,
|
|
27
|
+
getMethods,
|
|
28
|
+
onClose
|
|
29
|
+
} = props;
|
|
30
|
+
const {
|
|
31
|
+
position = dummyObject
|
|
32
|
+
} = suggestionDetails;
|
|
33
|
+
const {
|
|
34
|
+
replyEditorSuggestionsPopupProps = dummyObject
|
|
35
|
+
} = customProps || dummyObject;
|
|
36
|
+
/* External customization */
|
|
37
|
+
|
|
38
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
39
|
+
const handleRenderEmoji = useCallback(function () {
|
|
40
|
+
let {
|
|
41
|
+
onSelect,
|
|
42
|
+
searchText,
|
|
43
|
+
componentProps
|
|
44
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
45
|
+
const isShowEmojiPopup = searchText.length > 1;
|
|
46
|
+
return isShowEmojiPopup ? /*#__PURE__*/React.createElement(Emojis, {
|
|
47
|
+
emojisRowType: "single",
|
|
48
|
+
isShowGroupBasedList: false,
|
|
49
|
+
isShowOnlyContent: true,
|
|
50
|
+
isShowSearchBox: false,
|
|
51
|
+
needAutoFocus: false,
|
|
52
|
+
onSelect: value => {
|
|
53
|
+
onSelect && onSelect({
|
|
54
|
+
content: value
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
searchString: searchText,
|
|
58
|
+
...componentProps
|
|
59
|
+
}) : null;
|
|
60
|
+
}, []);
|
|
61
|
+
const defaultRenderMethod = useMemo(() => ({
|
|
62
|
+
':': handleRenderEmoji
|
|
63
|
+
}), [handleRenderEmoji]);
|
|
64
|
+
const {
|
|
65
|
+
suggestionElement,
|
|
66
|
+
popupProps = dummyObject
|
|
67
|
+
} = useReplyEditorSuggestions({
|
|
68
|
+
defaultRenderMethod,
|
|
69
|
+
suggestionDetails,
|
|
70
|
+
suggestionsMapping,
|
|
71
|
+
onSelect,
|
|
72
|
+
getMethods,
|
|
73
|
+
onClose
|
|
74
|
+
});
|
|
75
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
76
|
+
className: newStyle.suggestionPopup
|
|
77
|
+
}, /*#__PURE__*/React.createElement(ReplyEditorSuggestionsPopup, {
|
|
78
|
+
onClose: onClose,
|
|
79
|
+
suggestionElement: suggestionElement,
|
|
80
|
+
targetPosition: position,
|
|
81
|
+
...replyEditorSuggestionsPopupProps,
|
|
82
|
+
...popupProps
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
ReplyEditorSuggestions.propTypes = replyEditorSuggestionsPropTypes;
|
|
86
|
+
ReplyEditorSuggestions.defaultProps = replyEditorSuggestionsDefaultProps;
|
|
87
|
+
ReplyEditorSuggestions.displayName = 'ReplyEditorSuggestions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReplyEditorSuggestions } from "./ReplyEditorSuggestions";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
const replyEditorSuggestionsPropTypes = {
|
|
4
|
+
customStyle: PropTypes.object,
|
|
5
|
+
suggestionDetails: PropTypes.shape({
|
|
6
|
+
editor: PropTypes.object,
|
|
7
|
+
searchText: PropTypes.string,
|
|
8
|
+
triggerDetails: PropTypes.shape({
|
|
9
|
+
trigger: PropTypes.string
|
|
10
|
+
})
|
|
11
|
+
}).isRequired,
|
|
12
|
+
suggestionsMapping: PropTypes.objectOf(PropTypes.shape({
|
|
13
|
+
componentProps: PropTypes.object,
|
|
14
|
+
renderItem: PropTypes.func
|
|
15
|
+
})).isRequired,
|
|
16
|
+
onSelect: PropTypes.func,
|
|
17
|
+
getMethods: PropTypes.func,
|
|
18
|
+
onClose: PropTypes.func
|
|
19
|
+
};
|
|
20
|
+
export default replyEditorSuggestionsPropTypes;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** ** Libraries *** */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/** ** Components *** */
|
|
4
|
+
|
|
5
|
+
import Popup from '@zohodesk/components/es/Popup/Popup';
|
|
6
|
+
import DropBox from '@zohodesk/components/es/DropBox/DropBox';
|
|
7
|
+
/** ** Hooks *** */
|
|
8
|
+
|
|
9
|
+
import useMergeStyle from '@zohodesk/hooks/es/utils/useMergeStyle';
|
|
10
|
+
import useReplyEditorSuggestionsPopup from '@zohoim/chat-components-hooks/es/im/ReplyEditorSuggestionsPopup/useReplyEditorSuggestionsPopup';
|
|
11
|
+
/** ** Constants *** */
|
|
12
|
+
|
|
13
|
+
import replyEditorSuggestionsPopupDefaultProps from "./props/defaultProps";
|
|
14
|
+
import replyEditorSuggestionsPopupPropTypes from "./props/propTypes";
|
|
15
|
+
import { dummyObject } from '@zohoim/chat-components-utils/es/constants';
|
|
16
|
+
import { EDITOR_POPUP_PORTAL } from "../../constants";
|
|
17
|
+
/** ** Styles *** */
|
|
18
|
+
|
|
19
|
+
import style from "./css/ReplyEditorSuggestionsPopup.module.css";
|
|
20
|
+
export function ReplyEditorSuggestionsPopupComp(props) {
|
|
21
|
+
const {
|
|
22
|
+
customStyle,
|
|
23
|
+
targetPosition = dummyObject,
|
|
24
|
+
onClose,
|
|
25
|
+
popupSize,
|
|
26
|
+
customProps,
|
|
27
|
+
suggestionElement,
|
|
28
|
+
needPositionUpdate,
|
|
29
|
+
defaultPosition,
|
|
30
|
+
|
|
31
|
+
/** ** Popup Props *** */
|
|
32
|
+
getTargetRef,
|
|
33
|
+
getContainerRef,
|
|
34
|
+
position,
|
|
35
|
+
togglePopup,
|
|
36
|
+
isPopupReady,
|
|
37
|
+
isPopupOpen,
|
|
38
|
+
removeClose,
|
|
39
|
+
openPopupOnly,
|
|
40
|
+
closePopupOnly,
|
|
41
|
+
isAbsolutePositioningNeeded,
|
|
42
|
+
positionsOffset
|
|
43
|
+
} = props;
|
|
44
|
+
const {
|
|
45
|
+
dropBoxProps = dummyObject
|
|
46
|
+
} = customProps || dummyObject;
|
|
47
|
+
const {
|
|
48
|
+
targetElementStyle
|
|
49
|
+
} = useReplyEditorSuggestionsPopup({
|
|
50
|
+
suggestionElement,
|
|
51
|
+
targetPosition,
|
|
52
|
+
needPositionUpdate,
|
|
53
|
+
defaultPosition,
|
|
54
|
+
onClose,
|
|
55
|
+
openPopupOnly,
|
|
56
|
+
closePopupOnly,
|
|
57
|
+
isPopupOpen,
|
|
58
|
+
togglePopup
|
|
59
|
+
});
|
|
60
|
+
/* External customization */
|
|
61
|
+
|
|
62
|
+
const newStyle = useMergeStyle(style, customStyle);
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
ref: getTargetRef,
|
|
65
|
+
className: newStyle.hiddenTarget,
|
|
66
|
+
style: targetElementStyle
|
|
67
|
+
}), isPopupOpen ? /*#__PURE__*/React.createElement(DropBox, {
|
|
68
|
+
boxPosition: position,
|
|
69
|
+
customStyle: dummyObject,
|
|
70
|
+
getRef: getContainerRef,
|
|
71
|
+
isAbsolutePositioningNeeded: isAbsolutePositioningNeeded,
|
|
72
|
+
isActive: isPopupReady,
|
|
73
|
+
isAnimate: true,
|
|
74
|
+
isArrow: false,
|
|
75
|
+
onClick: removeClose,
|
|
76
|
+
portalId: EDITOR_POPUP_PORTAL,
|
|
77
|
+
positionsOffset: positionsOffset,
|
|
78
|
+
size: popupSize,
|
|
79
|
+
...dropBoxProps
|
|
80
|
+
}, suggestionElement) : null);
|
|
81
|
+
}
|
|
82
|
+
const ReplyEditorSuggestionsPopup = Popup(ReplyEditorSuggestionsPopupComp, undefined, undefined, {
|
|
83
|
+
isAbsolutePositioningNeeded: false
|
|
84
|
+
});
|
|
85
|
+
ReplyEditorSuggestionsPopupComp.propTypes = replyEditorSuggestionsPopupPropTypes;
|
|
86
|
+
ReplyEditorSuggestionsPopupComp.defaultProps = replyEditorSuggestionsPopupDefaultProps;
|
|
87
|
+
ReplyEditorSuggestionsPopup.propTypes = replyEditorSuggestionsPopupPropTypes;
|
|
88
|
+
ReplyEditorSuggestionsPopup.defaultProps = replyEditorSuggestionsPopupDefaultProps;
|
|
89
|
+
ReplyEditorSuggestionsPopup.displayName = 'ReplyEditorSuggestionsPopup';
|
|
90
|
+
export default ReplyEditorSuggestionsPopup;
|