@daeryun/dr_components 0.7.93 → 0.7.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +8 -2
- package/dist/components/Daeryuntalk/ChatConversation.tsx +17 -2
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +1 -2
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +5 -2
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +8 -36
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +11 -36
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +28 -11
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +35 -11
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +1 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +9 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +9 -0
- package/dist/components/Daeryuntalk/_types/message.js +2 -1
- package/dist/components/Daeryuntalk/_types/message.ts +3 -1
- package/dist/styles/globals.css +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -8,7 +8,7 @@ import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
|
8
8
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
9
9
|
import Image from 'next/image';
|
|
10
10
|
import { InquiryStatus } from './_enums/ask-status';
|
|
11
|
-
const ChatConversation = ({ onBackClick, isActive }) => {
|
|
11
|
+
const ChatConversation = ({ onBackClick, onChatNew, isActive }) => {
|
|
12
12
|
const { inquiryStatus, messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, sendInquiryJoined } = useDaeryuntalk();
|
|
13
13
|
const [isHovered, setIsHovered] = useState(false);
|
|
14
14
|
const messagesEndRef = useRef(null);
|
|
@@ -108,7 +108,13 @@ const ChatConversation = ({ onBackClick, isActive }) => {
|
|
|
108
108
|
</div>
|
|
109
109
|
|
|
110
110
|
<div className="border-t border-gray-200 p-4">
|
|
111
|
-
<
|
|
111
|
+
{inquiryStatus === InquiryStatus.CLOSED ? (<div className="">
|
|
112
|
+
<button className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" onClick={() => {
|
|
113
|
+
onChatNew && onChatNew();
|
|
114
|
+
}}>
|
|
115
|
+
새 문의하기
|
|
116
|
+
</button>
|
|
117
|
+
</div>) : (<ChatInput />)}
|
|
112
118
|
</div>
|
|
113
119
|
</div>);
|
|
114
120
|
};
|
|
@@ -10,13 +10,15 @@ import Image from 'next/image';
|
|
|
10
10
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
11
11
|
import { getMessageFileDownloadUrl } from './_api';
|
|
12
12
|
import { InquiryStatus } from './_enums/ask-status';
|
|
13
|
+
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
13
14
|
|
|
14
15
|
type ChatConversationProps = {
|
|
15
16
|
onBackClick?: () => void;
|
|
17
|
+
onChatNew?: () => void;
|
|
16
18
|
isActive: boolean;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActive }) => {
|
|
21
|
+
const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChatNew, isActive }) => {
|
|
20
22
|
const {
|
|
21
23
|
inquiryStatus,
|
|
22
24
|
messages,
|
|
@@ -183,7 +185,20 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
183
185
|
</div>
|
|
184
186
|
|
|
185
187
|
<div className="border-t border-gray-200 p-4">
|
|
186
|
-
|
|
188
|
+
{inquiryStatus === InquiryStatus.CLOSED ? (
|
|
189
|
+
<div className="">
|
|
190
|
+
<button
|
|
191
|
+
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white"
|
|
192
|
+
onClick={() => {
|
|
193
|
+
onChatNew && onChatNew();
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
새 문의하기
|
|
197
|
+
</button>
|
|
198
|
+
</div>
|
|
199
|
+
) : (
|
|
200
|
+
<ChatInput />
|
|
201
|
+
)}
|
|
187
202
|
</div>
|
|
188
203
|
</div>
|
|
189
204
|
);
|
|
@@ -88,7 +88,6 @@ const ChatHomeView = () => {
|
|
|
88
88
|
try {
|
|
89
89
|
setIsLoading(true);
|
|
90
90
|
const res = yield startSelectedChat(chatNumber);
|
|
91
|
-
console.log('res', res);
|
|
92
91
|
setViewState('conversation');
|
|
93
92
|
}
|
|
94
93
|
catch (e) {
|
|
@@ -102,7 +101,7 @@ const ChatHomeView = () => {
|
|
|
102
101
|
if (viewState === 'conversation') {
|
|
103
102
|
return (<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
104
103
|
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
105
|
-
<ChatConversation onBackClick={handleBackToHome} isActive={viewState === 'conversation'}/>
|
|
104
|
+
<ChatConversation onBackClick={handleBackToHome} isActive={viewState === 'conversation'} onChatNew={handleNewStartChat}/>
|
|
106
105
|
</div>
|
|
107
106
|
</main>);
|
|
108
107
|
}
|
|
@@ -104,7 +104,6 @@ const ChatHomeView: React.FC = () => {
|
|
|
104
104
|
try {
|
|
105
105
|
setIsLoading(true);
|
|
106
106
|
const res = await startSelectedChat(chatNumber);
|
|
107
|
-
console.log('res', res);
|
|
108
107
|
setViewState('conversation');
|
|
109
108
|
} catch (e) {
|
|
110
109
|
console.error('e', e);
|
|
@@ -118,7 +117,11 @@ const ChatHomeView: React.FC = () => {
|
|
|
118
117
|
return (
|
|
119
118
|
<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
120
119
|
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
121
|
-
<ChatConversation
|
|
120
|
+
<ChatConversation
|
|
121
|
+
onBackClick={handleBackToHome}
|
|
122
|
+
isActive={viewState === 'conversation'}
|
|
123
|
+
onChatNew={handleNewStartChat}
|
|
124
|
+
/>
|
|
122
125
|
</div>
|
|
123
126
|
</main>
|
|
124
127
|
);
|
|
@@ -55,7 +55,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
55
55
|
return (<div className={`flex w-full items-end justify-start gap-[4px]`}>
|
|
56
56
|
{media.images.length > 1 ? (<div className={`flex flex-col`}>
|
|
57
57
|
{/* grid로 감싸진 짝수 개수 또는 홀수에서 마지막 전까지 */}
|
|
58
|
-
<div className="grid grid-cols-2 gap-2 rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]">
|
|
58
|
+
<div className="group grid grid-cols-2 gap-2 rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]">
|
|
59
59
|
{media.images.map((file, index) => {
|
|
60
60
|
const isLastOdd = media.images.length % 2 === 1 && index === media.images.length - 1;
|
|
61
61
|
if (isLastOdd)
|
|
@@ -69,7 +69,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
69
69
|
<button onClick={(e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
70
|
e.stopPropagation();
|
|
71
71
|
yield handleDownload(file);
|
|
72
|
-
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full">
|
|
72
|
+
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100">
|
|
73
73
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white"/>
|
|
74
74
|
</button>
|
|
75
75
|
</div>);
|
|
@@ -89,7 +89,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
89
89
|
if (media.type === 'image') {
|
|
90
90
|
yield handleDownload(media.images[media.images.length - 1]);
|
|
91
91
|
}
|
|
92
|
-
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full">
|
|
92
|
+
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100">
|
|
93
93
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full text-[#777777] "/>
|
|
94
94
|
</button>
|
|
95
95
|
</div>
|
|
@@ -108,42 +108,11 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
108
108
|
if (media.type === 'image') {
|
|
109
109
|
yield handleDownload(media.images[0]);
|
|
110
110
|
}
|
|
111
|
-
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full">
|
|
111
|
+
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100">
|
|
112
112
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white"/>
|
|
113
113
|
</button>
|
|
114
114
|
</div>
|
|
115
115
|
</div>)}
|
|
116
|
-
{/*<div*/}
|
|
117
|
-
{/* className={`*/}
|
|
118
|
-
{/* grid rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]*/}
|
|
119
|
-
{/* ${media.images.length > 1 ? 'grid-cols-2 gap-2' : ''}*/}
|
|
120
|
-
{/*`}*/}
|
|
121
|
-
{/*>*/}
|
|
122
|
-
{/* {media.images.map((file, index) => (*/}
|
|
123
|
-
{/* <div*/}
|
|
124
|
-
{/* key={index}*/}
|
|
125
|
-
{/* className={`group/image relative overflow-hidden rounded-[5px] */}
|
|
126
|
-
{/* ${media.images.length > 1 ? 'aspect-square w-[120px]' : 'aspect-auto h-[100px] w-[160px]'} `}*/}
|
|
127
|
-
{/* >*/}
|
|
128
|
-
{/* <Image*/}
|
|
129
|
-
{/* src={file.thumbnailUrl}*/}
|
|
130
|
-
{/* alt={file.name}*/}
|
|
131
|
-
{/* width={media.images.length > 1 ? 113 : 160}*/}
|
|
132
|
-
{/* height={media.images.length > 1 ? 100 : 100}*/}
|
|
133
|
-
{/* className={`h-full w-full cursor-pointer rounded-md object-cover `}*/}
|
|
134
|
-
{/* onClick={() => {}}*/}
|
|
135
|
-
{/* />*/}
|
|
136
|
-
{/* <button*/}
|
|
137
|
-
{/* onClick={e => {*/}
|
|
138
|
-
{/* e.stopPropagation();*/}
|
|
139
|
-
{/* }}*/}
|
|
140
|
-
{/* className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full"*/}
|
|
141
|
-
{/* >*/}
|
|
142
|
-
{/* <FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />*/}
|
|
143
|
-
{/* </button>*/}
|
|
144
|
-
{/* </div>*/}
|
|
145
|
-
{/* ))}*/}
|
|
146
|
-
{/*</div>*/}
|
|
147
116
|
<div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
|
|
148
117
|
</div>);
|
|
149
118
|
}
|
|
@@ -166,7 +135,10 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
166
135
|
{formatFileSize(file.size)} | {file.name.split('.').pop()}
|
|
167
136
|
</span>
|
|
168
137
|
</div>
|
|
169
|
-
<button onClick={() =>
|
|
138
|
+
<button onClick={(e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
yield handleDownload(file);
|
|
141
|
+
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100">
|
|
170
142
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white"/>
|
|
171
143
|
</button>
|
|
172
144
|
</div>
|
|
@@ -62,7 +62,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
62
62
|
{media.images.length > 1 ? (
|
|
63
63
|
<div className={`flex flex-col`}>
|
|
64
64
|
{/* grid로 감싸진 짝수 개수 또는 홀수에서 마지막 전까지 */}
|
|
65
|
-
<div className="grid grid-cols-2 gap-2 rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]">
|
|
65
|
+
<div className="group grid grid-cols-2 gap-2 rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]">
|
|
66
66
|
{media.images.map((file, index) => {
|
|
67
67
|
const isLastOdd =
|
|
68
68
|
media.images.length % 2 === 1 && index === media.images.length - 1;
|
|
@@ -91,7 +91,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
91
91
|
e.stopPropagation();
|
|
92
92
|
await handleDownload(file);
|
|
93
93
|
}}
|
|
94
|
-
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full"
|
|
94
|
+
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100"
|
|
95
95
|
>
|
|
96
96
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />
|
|
97
97
|
</button>
|
|
@@ -126,7 +126,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
126
126
|
await handleDownload(media.images[media.images.length - 1]);
|
|
127
127
|
}
|
|
128
128
|
}}
|
|
129
|
-
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full"
|
|
129
|
+
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100"
|
|
130
130
|
>
|
|
131
131
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full text-[#777777] " />
|
|
132
132
|
</button>
|
|
@@ -160,44 +160,13 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
160
160
|
await handleDownload(media.images[0]);
|
|
161
161
|
}
|
|
162
162
|
}}
|
|
163
|
-
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full"
|
|
163
|
+
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100"
|
|
164
164
|
>
|
|
165
165
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />
|
|
166
166
|
</button>
|
|
167
167
|
</div>
|
|
168
168
|
</div>
|
|
169
169
|
)}
|
|
170
|
-
{/*<div*/}
|
|
171
|
-
{/* className={`*/}
|
|
172
|
-
{/* grid rounded-[10px] border-[1px] border-[#EDEDED] p-[8px]*/}
|
|
173
|
-
{/* ${media.images.length > 1 ? 'grid-cols-2 gap-2' : ''}*/}
|
|
174
|
-
{/*`}*/}
|
|
175
|
-
{/*>*/}
|
|
176
|
-
{/* {media.images.map((file, index) => (*/}
|
|
177
|
-
{/* <div*/}
|
|
178
|
-
{/* key={index}*/}
|
|
179
|
-
{/* className={`group/image relative overflow-hidden rounded-[5px] */}
|
|
180
|
-
{/* ${media.images.length > 1 ? 'aspect-square w-[120px]' : 'aspect-auto h-[100px] w-[160px]'} `}*/}
|
|
181
|
-
{/* >*/}
|
|
182
|
-
{/* <Image*/}
|
|
183
|
-
{/* src={file.thumbnailUrl}*/}
|
|
184
|
-
{/* alt={file.name}*/}
|
|
185
|
-
{/* width={media.images.length > 1 ? 113 : 160}*/}
|
|
186
|
-
{/* height={media.images.length > 1 ? 100 : 100}*/}
|
|
187
|
-
{/* className={`h-full w-full cursor-pointer rounded-md object-cover `}*/}
|
|
188
|
-
{/* onClick={() => {}}*/}
|
|
189
|
-
{/* />*/}
|
|
190
|
-
{/* <button*/}
|
|
191
|
-
{/* onClick={e => {*/}
|
|
192
|
-
{/* e.stopPropagation();*/}
|
|
193
|
-
{/* }}*/}
|
|
194
|
-
{/* className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full"*/}
|
|
195
|
-
{/* >*/}
|
|
196
|
-
{/* <FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />*/}
|
|
197
|
-
{/* </button>*/}
|
|
198
|
-
{/* </div>*/}
|
|
199
|
-
{/* ))}*/}
|
|
200
|
-
{/*</div>*/}
|
|
201
170
|
<div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
|
|
202
171
|
</div>
|
|
203
172
|
);
|
|
@@ -228,7 +197,13 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
228
197
|
{formatFileSize(file.size)} | {file.name.split('.').pop()}
|
|
229
198
|
</span>
|
|
230
199
|
</div>
|
|
231
|
-
<button
|
|
200
|
+
<button
|
|
201
|
+
onClick={async e => {
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
await handleDownload(file);
|
|
204
|
+
}}
|
|
205
|
+
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover/image:opacity-100"
|
|
206
|
+
>
|
|
232
207
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />
|
|
233
208
|
</button>
|
|
234
209
|
</div>
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { EditorContent, useEditor } from '@tiptap/react';
|
|
2
2
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
4
|
+
import HardBreak from '@tiptap/extension-hard-break'; // 추가
|
|
4
5
|
import Document from '@tiptap/extension-document';
|
|
5
6
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
6
7
|
import Text from '@tiptap/extension-text';
|
|
7
8
|
const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
8
9
|
const editor = useEditor({
|
|
9
|
-
extensions: [
|
|
10
|
+
extensions: [
|
|
11
|
+
Document,
|
|
12
|
+
Paragraph,
|
|
13
|
+
Text,
|
|
14
|
+
Placeholder.configure({ placeholder }),
|
|
15
|
+
HardBreak.configure({
|
|
16
|
+
keepMarks: false,
|
|
17
|
+
HTMLAttributes: {
|
|
18
|
+
class: 'my-custom-hard-break'
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
],
|
|
10
22
|
content: '',
|
|
11
23
|
enableInputRules: false,
|
|
12
24
|
enablePasteRules: false,
|
|
@@ -24,21 +36,25 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
24
36
|
},
|
|
25
37
|
editorProps: {
|
|
26
38
|
attributes: {
|
|
27
|
-
class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap'
|
|
39
|
+
class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere'
|
|
28
40
|
},
|
|
29
41
|
handleKeyDown: (view, event) => {
|
|
30
42
|
if (event.key === 'Enter') {
|
|
31
43
|
if (event.shiftKey) {
|
|
32
|
-
// 줄바꿈
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
// Shift+Enter: 줄바꿈 (hard break) 삽입
|
|
45
|
+
if (editor) {
|
|
46
|
+
editor.commands.setHardBreak();
|
|
47
|
+
// 줄바꿈 이후 스크롤 이동 보장
|
|
48
|
+
requestAnimationFrame(() => {
|
|
49
|
+
if (view && view.dom) {
|
|
50
|
+
view.dom.scrollTop = view.dom.scrollHeight;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return true; // 기본 동작 방지
|
|
40
55
|
}
|
|
41
56
|
else {
|
|
57
|
+
// Enter: 메시지 전송
|
|
42
58
|
event.preventDefault();
|
|
43
59
|
const content = editor === null || editor === void 0 ? void 0 : editor.getText();
|
|
44
60
|
if (content && content.trim() && onEnterKeyPress) {
|
|
@@ -74,7 +90,8 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
74
90
|
}));
|
|
75
91
|
if (!editor)
|
|
76
92
|
return null;
|
|
77
|
-
return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white"/>;
|
|
93
|
+
// return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
94
|
+
return (<EditorContent editor={editor} tabIndex={0} className="w-full overflow-hidden rounded-md border text-black dark:text-white"/>);
|
|
78
95
|
});
|
|
79
96
|
Tiptap.displayName = 'Tiptap';
|
|
80
97
|
export default Tiptap;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EditorContent, useEditor } from '@tiptap/react';
|
|
2
2
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
3
3
|
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
4
|
+
import HardBreak from '@tiptap/extension-hard-break'; // 추가
|
|
5
|
+
|
|
4
6
|
import { JSONContent } from '@tiptap/core'; // 추가 필요
|
|
5
7
|
import Document from '@tiptap/extension-document';
|
|
6
8
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
@@ -25,7 +27,18 @@ interface TiptapProps {
|
|
|
25
27
|
const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
26
28
|
({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
27
29
|
const editor = useEditor({
|
|
28
|
-
extensions: [
|
|
30
|
+
extensions: [
|
|
31
|
+
Document,
|
|
32
|
+
Paragraph,
|
|
33
|
+
Text,
|
|
34
|
+
Placeholder.configure({ placeholder }),
|
|
35
|
+
HardBreak.configure({
|
|
36
|
+
keepMarks: false,
|
|
37
|
+
HTMLAttributes: {
|
|
38
|
+
class: 'my-custom-hard-break'
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
],
|
|
29
42
|
content: '',
|
|
30
43
|
enableInputRules: false,
|
|
31
44
|
enablePasteRules: false,
|
|
@@ -43,20 +56,24 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
43
56
|
},
|
|
44
57
|
editorProps: {
|
|
45
58
|
attributes: {
|
|
46
|
-
class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap'
|
|
59
|
+
class: 'focus:outline-none min-h-[34px] max-h-[72px] overflow-y-auto resize-none px-[10px] mt-[4px] pt-[4px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere'
|
|
47
60
|
},
|
|
48
61
|
handleKeyDown: (view, event) => {
|
|
49
62
|
if (event.key === 'Enter') {
|
|
50
63
|
if (event.shiftKey) {
|
|
51
|
-
// 줄바꿈
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
// Shift+Enter: 줄바꿈 (hard break) 삽입
|
|
65
|
+
if (editor) {
|
|
66
|
+
editor.commands.setHardBreak();
|
|
67
|
+
// 줄바꿈 이후 스크롤 이동 보장
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
if (view && view.dom) {
|
|
70
|
+
view.dom.scrollTop = view.dom.scrollHeight;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return true; // 기본 동작 방지
|
|
59
75
|
} else {
|
|
76
|
+
// Enter: 메시지 전송
|
|
60
77
|
event.preventDefault();
|
|
61
78
|
const content = editor?.getText();
|
|
62
79
|
if (content && content.trim() && onEnterKeyPress) {
|
|
@@ -96,7 +113,14 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
96
113
|
|
|
97
114
|
if (!editor) return null;
|
|
98
115
|
|
|
99
|
-
return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
116
|
+
// return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
117
|
+
return (
|
|
118
|
+
<EditorContent
|
|
119
|
+
editor={editor}
|
|
120
|
+
tabIndex={0}
|
|
121
|
+
className="w-full overflow-hidden rounded-md border text-black dark:text-white"
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
100
124
|
}
|
|
101
125
|
);
|
|
102
126
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const formatFileSize: (size: number) => string;
|
|
2
2
|
export declare const formatDateToKorean: (timestamp: string) => string;
|
|
3
3
|
export declare const onlyNumbers: (phoneNumber: string) => string;
|
|
4
|
+
export declare const isEmptyHtml: (html: string | null | undefined) => boolean;
|
|
4
5
|
export declare const phoneCheck: (value: string) => {
|
|
5
6
|
phoneNumber: string;
|
|
6
7
|
isValid: boolean;
|
|
@@ -17,6 +17,15 @@ export const formatDateToKorean = (timestamp) => {
|
|
|
17
17
|
export const onlyNumbers = (phoneNumber) => {
|
|
18
18
|
return phoneNumber.replace(/\D/g, '');
|
|
19
19
|
};
|
|
20
|
+
export const isEmptyHtml = (html) => {
|
|
21
|
+
if (!html)
|
|
22
|
+
return true;
|
|
23
|
+
const trimmed = html
|
|
24
|
+
.replace(/<p><br><\/p>/g, '')
|
|
25
|
+
.replace(/<p>\s*<\/p>/g, '')
|
|
26
|
+
.trim();
|
|
27
|
+
return trimmed === '';
|
|
28
|
+
};
|
|
20
29
|
export const phoneCheck = (value) => {
|
|
21
30
|
const phoneNumber = onlyNumbers(value);
|
|
22
31
|
// 10자리 또는 11자리만 통과
|
|
@@ -20,6 +20,15 @@ export const onlyNumbers = (phoneNumber: string): string => {
|
|
|
20
20
|
return phoneNumber.replace(/\D/g, '');
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
export const isEmptyHtml = (html: string | null | undefined): boolean => {
|
|
24
|
+
if (!html) return true;
|
|
25
|
+
const trimmed = html
|
|
26
|
+
.replace(/<p><br><\/p>/g, '')
|
|
27
|
+
.replace(/<p>\s*<\/p>/g, '')
|
|
28
|
+
.trim();
|
|
29
|
+
return trimmed === '';
|
|
30
|
+
};
|
|
31
|
+
|
|
23
32
|
export const phoneCheck = (
|
|
24
33
|
value: string
|
|
25
34
|
): {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// todo 올바른 타입 정의 필요
|
|
2
2
|
import { InquiryMessageTemplateType } from '../_enums/template';
|
|
3
|
+
import { isEmptyHtml } from '../_lib/utils';
|
|
3
4
|
// 메시지에 특정 컨텐츠가 있는지 확인하는 헬퍼 함수들
|
|
4
5
|
export const hasBlocks = (message) => !!message.blocks && message.blocks.length > 0;
|
|
5
6
|
//
|
|
6
|
-
export const hasRichForm = (message) => !!message.richText && message.richText.structuredData;
|
|
7
|
+
export const hasRichForm = (message) => { var _a; return !!message.richText && message.richText.structuredData && isEmptyHtml((_a = message === null || message === void 0 ? void 0 : message.richText) === null || _a === void 0 ? void 0 : _a.htmlContent); };
|
|
7
8
|
// 사용자가 워크플로우 대답 클릭한거
|
|
8
9
|
export const hasCustomerWorkFlowClickData = (message) => message.templateType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_3;
|
|
9
10
|
export const hasButtons = (message) => !!message.buttons && message.buttons.length > 0;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// 텍스트 블록 타입
|
|
4
4
|
import exp from 'constants';
|
|
5
5
|
import { InquiryMessageTemplateType } from '../_enums/template';
|
|
6
|
+
import { isEmptyHtml } from '../_lib/utils';
|
|
6
7
|
|
|
7
8
|
export interface TextBlock {
|
|
8
9
|
type: string;
|
|
@@ -125,7 +126,8 @@ export interface Message {
|
|
|
125
126
|
export const hasBlocks = (message: Message): boolean => !!message.blocks && message.blocks.length > 0;
|
|
126
127
|
|
|
127
128
|
//
|
|
128
|
-
export const hasRichForm = (message: Message): boolean =>
|
|
129
|
+
export const hasRichForm = (message: Message): boolean =>
|
|
130
|
+
!!message.richText && message.richText.structuredData && isEmptyHtml(message?.richText?.htmlContent);
|
|
129
131
|
|
|
130
132
|
// 사용자가 워크플로우 대답 클릭한거
|
|
131
133
|
export const hasCustomerWorkFlowClickData = (message: Message): boolean =>
|
package/dist/styles/globals.css
CHANGED
|
@@ -1908,10 +1908,6 @@ video {
|
|
|
1908
1908
|
aspect-ratio: 6/11;
|
|
1909
1909
|
}
|
|
1910
1910
|
|
|
1911
|
-
.aspect-auto {
|
|
1912
|
-
aspect-ratio: auto;
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
1911
|
.aspect-square {
|
|
1916
1912
|
aspect-ratio: 1 / 1;
|
|
1917
1913
|
}
|
|
@@ -8550,6 +8546,10 @@ body {
|
|
|
8550
8546
|
text-decoration-line: underline;
|
|
8551
8547
|
}
|
|
8552
8548
|
|
|
8549
|
+
.group\/image:hover .group-hover\/image\:opacity-100 {
|
|
8550
|
+
opacity: 1;
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8553
8553
|
.group:hover .group-hover\:opacity-100 {
|
|
8554
8554
|
opacity: 1;
|
|
8555
8555
|
}
|