whyuzeim 1.1.55 → 1.1.57
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/cjs/HighlyCustomChat/CodeMsg/index.d.ts +2 -1
- package/cjs/HighlyCustomChat/CodeMsg/index.js +18 -24
- package/cjs/HighlyCustomChat/CodeMsg/style/index.moduel.scss +202 -0
- package/cjs/HighlyCustomChat/index.js +20 -36
- package/es/HighlyCustomChat/CodeMsg/index.d.ts +2 -1
- package/es/HighlyCustomChat/CodeMsg/index.js +18 -24
- package/es/HighlyCustomChat/CodeMsg/style/index.moduel.scss +202 -0
- package/es/HighlyCustomChat/index.js +20 -36
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
2
|
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
-
import 'highlight.js/styles/
|
|
3
|
+
import 'highlight.js/styles/default.css';
|
|
4
4
|
import React from "react";
|
|
5
|
+
import "./style/index.moduel.scss";
|
|
5
6
|
interface ICodeMsg {
|
|
6
7
|
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
8
|
isMySelf: boolean;
|
|
@@ -4,12 +4,13 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray')
|
|
|
4
4
|
var _setTimeout = require('@babel/runtime-corejs3/core-js-stable/set-timeout');
|
|
5
5
|
var agoraChatUikit = require('agora-chat-uikit');
|
|
6
6
|
var hljs = require('highlight.js');
|
|
7
|
-
require('highlight.js/styles/
|
|
7
|
+
require('highlight.js/styles/default.css');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var copy = require('copy-to-clipboard');
|
|
10
|
+
require('./style/index.moduel.scss');
|
|
10
11
|
|
|
11
12
|
var CodeMsg = function CodeMsg(props) {
|
|
12
|
-
var _msg$customExts, _msg$customExts2;
|
|
13
|
+
var _msg$customExts, _msg$customExts2, _msg$customExts3;
|
|
13
14
|
var msg = props.msg,
|
|
14
15
|
isMySelf = props.isMySelf,
|
|
15
16
|
avatar = props.avatar,
|
|
@@ -18,10 +19,11 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
18
19
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
20
|
copyStatus = _useState2[0],
|
|
20
21
|
setCopyStatus = _useState2[1];
|
|
21
|
-
|
|
22
|
+
var codeType = ((_msg$customExts = msg.customExts) === null || _msg$customExts === void 0 ? void 0 : _msg$customExts.code_type) || "python";
|
|
23
|
+
if (!((_msg$customExts2 = msg.customExts) !== null && _msg$customExts2 !== void 0 && _msg$customExts2.code)) {
|
|
22
24
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
23
25
|
}
|
|
24
|
-
var rawCode = (_msg$
|
|
26
|
+
var rawCode = (_msg$customExts3 = msg.customExts) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.code) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.replace(/\\n/g, "\n")) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.replace(/\\"/g, '"')) === null || _msg$customExts3 === void 0 ? void 0 : _msg$customExts3.replace(/\\\\/g, "\\");
|
|
25
27
|
// 复制代码到剪贴板
|
|
26
28
|
var copyToClipboard = function copyToClipboard() {
|
|
27
29
|
if (!rawCode) return;
|
|
@@ -65,13 +67,13 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
65
67
|
}, /*#__PURE__*/React.createElement("div", {
|
|
66
68
|
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
67
69
|
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: "inline-block w-full rounded-lg overflow-hidden relative mb-2",
|
|
68
71
|
style: {
|
|
69
72
|
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
70
73
|
borderRadius: "9px",
|
|
71
74
|
padding: "10px 12px",
|
|
72
75
|
color: isMySelf ? "var(--im-msg-bubble-right-font-color)" : "var(--im-msg-bubble-font-color)"
|
|
73
|
-
}
|
|
74
|
-
className: "inline-block w-full"
|
|
76
|
+
}
|
|
75
77
|
}, /*#__PURE__*/React.createElement("div", {
|
|
76
78
|
className: "flex-1 flex justify-between items-center"
|
|
77
79
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -88,8 +90,8 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
88
90
|
d: "M8 0.0214844H2.58333V2.5396H0.0214844V8.01198H2.58333V10.5301H8V8.01198H10.5618V2.5396H8V0.0214844Z",
|
|
89
91
|
fill: "#0083FF"
|
|
90
92
|
})), /*#__PURE__*/React.createElement("span", {
|
|
91
|
-
className: "text
|
|
92
|
-
},
|
|
93
|
+
className: "filename-text"
|
|
94
|
+
}, codeType)), /*#__PURE__*/React.createElement("button", {
|
|
93
95
|
onClick: function onClick() {
|
|
94
96
|
onApply && onApply(msg.customExts.code);
|
|
95
97
|
!onApply && copyToClipboard();
|
|
@@ -101,28 +103,20 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
101
103
|
className: "code-scroll-container w-full max-h-[300px] overflow-y-auto"
|
|
102
104
|
}, /*#__PURE__*/React.createElement("pre", {
|
|
103
105
|
className: "bg-transparent w-full h-full"
|
|
104
|
-
}, /*#__PURE__*/React.createElement("
|
|
105
|
-
className: "
|
|
106
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "code-block-container",
|
|
106
108
|
style: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
lineHeight: "1.5",
|
|
112
|
-
fontFamily: "Monaco, Consolas, monospace",
|
|
113
|
-
whiteSpace: "pre-wrap",
|
|
114
|
-
wordWrap: "break-word",
|
|
115
|
-
width: "100%",
|
|
116
|
-
maxWidth: "100%",
|
|
117
|
-
padding: "0.5rem"
|
|
118
|
-
},
|
|
109
|
+
border: "none"
|
|
110
|
+
}
|
|
111
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
112
|
+
className: "language-".concat(codeType, " hljs"),
|
|
119
113
|
dangerouslySetInnerHTML: {
|
|
120
114
|
__html: hljs.highlight(rawCode, {
|
|
121
|
-
language:
|
|
115
|
+
language: codeType,
|
|
122
116
|
ignoreIllegals: true
|
|
123
117
|
}).value
|
|
124
118
|
}
|
|
125
|
-
})))))));
|
|
119
|
+
}))))))));
|
|
126
120
|
};
|
|
127
121
|
|
|
128
122
|
module.exports = CodeMsg;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/* 代码高亮样式,支持暗色和亮色主题 */
|
|
2
|
+
|
|
3
|
+
/* 通用样式 */
|
|
4
|
+
.code-block-container {
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
margin: 4px 0;
|
|
7
|
+
padding: 8px 4px;
|
|
8
|
+
background: transparent !important;
|
|
9
|
+
border: none !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* 通用代码样式 */
|
|
13
|
+
code.hljs {
|
|
14
|
+
display: block;
|
|
15
|
+
overflow: auto;
|
|
16
|
+
background: transparent !important;
|
|
17
|
+
font-size: 13px;
|
|
18
|
+
line-height: 1.4;
|
|
19
|
+
font-family: Monaco, Consolas, 'Courier New', monospace;
|
|
20
|
+
white-space: pre-wrap;
|
|
21
|
+
word-wrap: break-word;
|
|
22
|
+
width: 100%;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* 深色主题下的代码高亮 - 适用于深蓝/黑色背景 */
|
|
28
|
+
.im-dark, .im-custom {
|
|
29
|
+
/* 基础文本颜色 */
|
|
30
|
+
.hljs {
|
|
31
|
+
color: #f8f8f2 !important;
|
|
32
|
+
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* 关键字 */
|
|
36
|
+
.hljs-keyword,
|
|
37
|
+
.hljs-selector-tag,
|
|
38
|
+
.hljs-tag,
|
|
39
|
+
.hljs-name {
|
|
40
|
+
color: #ff79c6 !important;
|
|
41
|
+
font-weight: bold;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* 字符串 */
|
|
45
|
+
.hljs-string,
|
|
46
|
+
.hljs-title,
|
|
47
|
+
.hljs-section,
|
|
48
|
+
.hljs-attribute,
|
|
49
|
+
.hljs-literal,
|
|
50
|
+
.hljs-template-tag,
|
|
51
|
+
.hljs-template-variable,
|
|
52
|
+
.hljs-type,
|
|
53
|
+
.hljs-addition {
|
|
54
|
+
color: #f1fa8c !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* 数字、布尔值 */
|
|
58
|
+
.hljs-number,
|
|
59
|
+
.hljs-selector-attr,
|
|
60
|
+
.hljs-selector-pseudo,
|
|
61
|
+
.hljs-meta-string,
|
|
62
|
+
.hljs-built_in {
|
|
63
|
+
color: #bd93f9 !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* 属性、变量 */
|
|
67
|
+
.hljs-attr,
|
|
68
|
+
.hljs-variable,
|
|
69
|
+
.hljs-property,
|
|
70
|
+
.hljs-params,
|
|
71
|
+
.hljs-class .hljs-title {
|
|
72
|
+
color: #8be9fd !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* 注释 */
|
|
76
|
+
.hljs-comment,
|
|
77
|
+
.hljs-quote,
|
|
78
|
+
.hljs-doctag {
|
|
79
|
+
color: #6272a4 !important;
|
|
80
|
+
font-style: italic;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 函数 */
|
|
84
|
+
.hljs-function .hljs-title {
|
|
85
|
+
color: #50fa7b !important;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* 操作符 */
|
|
90
|
+
.hljs-operator,
|
|
91
|
+
.hljs-entity,
|
|
92
|
+
.hljs-url,
|
|
93
|
+
.language-css .hljs-string,
|
|
94
|
+
.style .hljs-string {
|
|
95
|
+
color: #ff79c6 !important;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* 浅色主题下的代码高亮 - 适用于浅色/蓝色背景 */
|
|
100
|
+
.im-light {
|
|
101
|
+
/* 基础文本颜色 */
|
|
102
|
+
.hljs {
|
|
103
|
+
color: #24292e !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* 关键字 */
|
|
107
|
+
.hljs-keyword,
|
|
108
|
+
.hljs-selector-tag,
|
|
109
|
+
.hljs-tag,
|
|
110
|
+
.hljs-name {
|
|
111
|
+
color: #d73a49 !important;
|
|
112
|
+
font-weight: bold;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* 字符串 */
|
|
116
|
+
.hljs-string,
|
|
117
|
+
.hljs-title,
|
|
118
|
+
.hljs-section,
|
|
119
|
+
.hljs-attribute,
|
|
120
|
+
.hljs-literal,
|
|
121
|
+
.hljs-template-tag,
|
|
122
|
+
.hljs-template-variable,
|
|
123
|
+
.hljs-type,
|
|
124
|
+
.hljs-addition {
|
|
125
|
+
color: #032f62 !important;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* 数字、布尔值 */
|
|
129
|
+
.hljs-number,
|
|
130
|
+
.hljs-selector-attr,
|
|
131
|
+
.hljs-selector-pseudo,
|
|
132
|
+
.hljs-meta-string,
|
|
133
|
+
.hljs-built_in {
|
|
134
|
+
color: #005cc5 !important;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* 属性、变量 */
|
|
138
|
+
.hljs-attr,
|
|
139
|
+
.hljs-variable,
|
|
140
|
+
.hljs-property,
|
|
141
|
+
.hljs-params,
|
|
142
|
+
.hljs-class .hljs-title {
|
|
143
|
+
color: #6f42c1 !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* 注释 */
|
|
147
|
+
.hljs-comment,
|
|
148
|
+
.hljs-quote,
|
|
149
|
+
.hljs-doctag {
|
|
150
|
+
color: #6a737d !important;
|
|
151
|
+
font-style: italic;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* 函数 */
|
|
155
|
+
.hljs-function .hljs-title {
|
|
156
|
+
color: #6f42c1 !important;
|
|
157
|
+
font-weight: bold;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* 操作符 */
|
|
161
|
+
.hljs-operator,
|
|
162
|
+
.hljs-entity,
|
|
163
|
+
.hljs-url,
|
|
164
|
+
.language-css .hljs-string,
|
|
165
|
+
.style .hljs-string {
|
|
166
|
+
color: #d73a49 !important;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* 强调 */
|
|
171
|
+
.hljs-emphasis {
|
|
172
|
+
font-style: italic;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.hljs-strong {
|
|
176
|
+
font-weight: bold;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* 确保pre元素和其他容器也没有边框 */
|
|
180
|
+
pre, .code-scroll-container {
|
|
181
|
+
border: none !important;
|
|
182
|
+
outline: none !important;
|
|
183
|
+
background: transparent !important;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* 文件名样式,根据主题自动调整颜色 */
|
|
187
|
+
.filename-text {
|
|
188
|
+
font-size: 10px;
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
|
|
191
|
+
/* 深色模式 - 白色文本 */
|
|
192
|
+
.im-dark &, .im-custom & {
|
|
193
|
+
color: white;
|
|
194
|
+
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* 浅色模式 - 黑色文本 */
|
|
198
|
+
.im-light & {
|
|
199
|
+
color: #000000;
|
|
200
|
+
text-shadow: 0px 0px 1px rgba(255, 255, 255, 0.5);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -425,7 +425,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
425
425
|
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
426
426
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
427
427
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, extInfo) {
|
|
428
|
-
var txtMessage, cuiScrollList, cuiScrollListWrap,
|
|
428
|
+
var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
|
|
429
429
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
430
430
|
while (1) switch (_context2.prev = _context2.next) {
|
|
431
431
|
case 0:
|
|
@@ -447,26 +447,19 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
447
447
|
return agoraChatUikit.rootStore.messageStore.sendMessage(txtMessage);
|
|
448
448
|
case 6:
|
|
449
449
|
if (isAgent) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
node
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
cuiScrollListWrap.scrollTo({
|
|
463
|
-
top: 1000000000
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
}
|
|
450
|
+
cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
451
|
+
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
452
|
+
if (cuiScrollList) {
|
|
453
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
454
|
+
template = document.createElement('template');
|
|
455
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
456
|
+
node = template.content.firstChild;
|
|
457
|
+
if (node) {
|
|
458
|
+
cuiScrollList.appendChild(node);
|
|
459
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
460
|
+
top: 1000000000
|
|
461
|
+
});
|
|
467
462
|
}
|
|
468
|
-
} catch (error) {
|
|
469
|
-
console.error("Error adding generating loader:", error);
|
|
470
463
|
}
|
|
471
464
|
}
|
|
472
465
|
afterSendMsg(txtMessage, extInfo);
|
|
@@ -503,22 +496,13 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
503
496
|
};
|
|
504
497
|
}();
|
|
505
498
|
React.useEffect(function () {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
514
|
-
// 使用contains方法安全地检查父子关系
|
|
515
|
-
if (cuiScrollList.contains(generatingLoader)) {
|
|
516
|
-
generatingLoader.remove(); // 更安全的移除方法
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
} catch (error) {
|
|
520
|
-
// 捕获并记录任何DOM操作错误,防止应用崩溃
|
|
521
|
-
console.error("Error handling generating loader:", error);
|
|
499
|
+
var _conversationList$fin;
|
|
500
|
+
var cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
501
|
+
var generatingLoader = document.querySelector("#agent-generating-loader");
|
|
502
|
+
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
503
|
+
return item.conversationId === props.conversationId;
|
|
504
|
+
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
505
|
+
cuiScrollList.removeChild(generatingLoader);
|
|
522
506
|
}
|
|
523
507
|
}, [conversationList, props.conversationId]);
|
|
524
508
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
2
|
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
-
import 'highlight.js/styles/
|
|
3
|
+
import 'highlight.js/styles/default.css';
|
|
4
4
|
import React from "react";
|
|
5
|
+
import "./style/index.moduel.scss";
|
|
5
6
|
interface ICodeMsg {
|
|
6
7
|
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
8
|
isMySelf: boolean;
|
|
@@ -2,12 +2,13 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
|
2
2
|
import _setTimeout from '@babel/runtime-corejs3/core-js-stable/set-timeout';
|
|
3
3
|
import { BaseMessage } from 'agora-chat-uikit';
|
|
4
4
|
import hljs from 'highlight.js';
|
|
5
|
-
import 'highlight.js/styles/
|
|
5
|
+
import 'highlight.js/styles/default.css';
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
import copy from 'copy-to-clipboard';
|
|
8
|
+
import './style/index.moduel.scss';
|
|
8
9
|
|
|
9
10
|
var CodeMsg = function CodeMsg(props) {
|
|
10
|
-
var _msg$customExts, _msg$customExts2;
|
|
11
|
+
var _msg$customExts, _msg$customExts2, _msg$customExts3;
|
|
11
12
|
var msg = props.msg,
|
|
12
13
|
isMySelf = props.isMySelf,
|
|
13
14
|
avatar = props.avatar,
|
|
@@ -16,10 +17,11 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
16
17
|
_useState2 = _slicedToArray(_useState, 2),
|
|
17
18
|
copyStatus = _useState2[0],
|
|
18
19
|
setCopyStatus = _useState2[1];
|
|
19
|
-
|
|
20
|
+
var codeType = ((_msg$customExts = msg.customExts) === null || _msg$customExts === void 0 ? void 0 : _msg$customExts.code_type) || "python";
|
|
21
|
+
if (!((_msg$customExts2 = msg.customExts) !== null && _msg$customExts2 !== void 0 && _msg$customExts2.code)) {
|
|
20
22
|
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
21
23
|
}
|
|
22
|
-
var rawCode = (_msg$
|
|
24
|
+
var rawCode = (_msg$customExts3 = msg.customExts) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.code) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.replace(/\\n/g, "\n")) === null || _msg$customExts3 === void 0 || (_msg$customExts3 = _msg$customExts3.replace(/\\"/g, '"')) === null || _msg$customExts3 === void 0 ? void 0 : _msg$customExts3.replace(/\\\\/g, "\\");
|
|
23
25
|
// 复制代码到剪贴板
|
|
24
26
|
var copyToClipboard = function copyToClipboard() {
|
|
25
27
|
if (!rawCode) return;
|
|
@@ -63,13 +65,13 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
63
65
|
}, /*#__PURE__*/React.createElement("div", {
|
|
64
66
|
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
65
67
|
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "inline-block w-full rounded-lg overflow-hidden relative mb-2",
|
|
66
69
|
style: {
|
|
67
70
|
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
68
71
|
borderRadius: "9px",
|
|
69
72
|
padding: "10px 12px",
|
|
70
73
|
color: isMySelf ? "var(--im-msg-bubble-right-font-color)" : "var(--im-msg-bubble-font-color)"
|
|
71
|
-
}
|
|
72
|
-
className: "inline-block w-full"
|
|
74
|
+
}
|
|
73
75
|
}, /*#__PURE__*/React.createElement("div", {
|
|
74
76
|
className: "flex-1 flex justify-between items-center"
|
|
75
77
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -86,8 +88,8 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
86
88
|
d: "M8 0.0214844H2.58333V2.5396H0.0214844V8.01198H2.58333V10.5301H8V8.01198H10.5618V2.5396H8V0.0214844Z",
|
|
87
89
|
fill: "#0083FF"
|
|
88
90
|
})), /*#__PURE__*/React.createElement("span", {
|
|
89
|
-
className: "text
|
|
90
|
-
},
|
|
91
|
+
className: "filename-text"
|
|
92
|
+
}, codeType)), /*#__PURE__*/React.createElement("button", {
|
|
91
93
|
onClick: function onClick() {
|
|
92
94
|
onApply && onApply(msg.customExts.code);
|
|
93
95
|
!onApply && copyToClipboard();
|
|
@@ -99,28 +101,20 @@ var CodeMsg = function CodeMsg(props) {
|
|
|
99
101
|
className: "code-scroll-container w-full max-h-[300px] overflow-y-auto"
|
|
100
102
|
}, /*#__PURE__*/React.createElement("pre", {
|
|
101
103
|
className: "bg-transparent w-full h-full"
|
|
102
|
-
}, /*#__PURE__*/React.createElement("
|
|
103
|
-
className: "
|
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: "code-block-container",
|
|
104
106
|
style: {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
lineHeight: "1.5",
|
|
110
|
-
fontFamily: "Monaco, Consolas, monospace",
|
|
111
|
-
whiteSpace: "pre-wrap",
|
|
112
|
-
wordWrap: "break-word",
|
|
113
|
-
width: "100%",
|
|
114
|
-
maxWidth: "100%",
|
|
115
|
-
padding: "0.5rem"
|
|
116
|
-
},
|
|
107
|
+
border: "none"
|
|
108
|
+
}
|
|
109
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
110
|
+
className: "language-".concat(codeType, " hljs"),
|
|
117
111
|
dangerouslySetInnerHTML: {
|
|
118
112
|
__html: hljs.highlight(rawCode, {
|
|
119
|
-
language:
|
|
113
|
+
language: codeType,
|
|
120
114
|
ignoreIllegals: true
|
|
121
115
|
}).value
|
|
122
116
|
}
|
|
123
|
-
})))))));
|
|
117
|
+
}))))))));
|
|
124
118
|
};
|
|
125
119
|
|
|
126
120
|
export { CodeMsg as default };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/* 代码高亮样式,支持暗色和亮色主题 */
|
|
2
|
+
|
|
3
|
+
/* 通用样式 */
|
|
4
|
+
.code-block-container {
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
margin: 4px 0;
|
|
7
|
+
padding: 8px 4px;
|
|
8
|
+
background: transparent !important;
|
|
9
|
+
border: none !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* 通用代码样式 */
|
|
13
|
+
code.hljs {
|
|
14
|
+
display: block;
|
|
15
|
+
overflow: auto;
|
|
16
|
+
background: transparent !important;
|
|
17
|
+
font-size: 13px;
|
|
18
|
+
line-height: 1.4;
|
|
19
|
+
font-family: Monaco, Consolas, 'Courier New', monospace;
|
|
20
|
+
white-space: pre-wrap;
|
|
21
|
+
word-wrap: break-word;
|
|
22
|
+
width: 100%;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* 深色主题下的代码高亮 - 适用于深蓝/黑色背景 */
|
|
28
|
+
.im-dark, .im-custom {
|
|
29
|
+
/* 基础文本颜色 */
|
|
30
|
+
.hljs {
|
|
31
|
+
color: #f8f8f2 !important;
|
|
32
|
+
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* 关键字 */
|
|
36
|
+
.hljs-keyword,
|
|
37
|
+
.hljs-selector-tag,
|
|
38
|
+
.hljs-tag,
|
|
39
|
+
.hljs-name {
|
|
40
|
+
color: #ff79c6 !important;
|
|
41
|
+
font-weight: bold;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* 字符串 */
|
|
45
|
+
.hljs-string,
|
|
46
|
+
.hljs-title,
|
|
47
|
+
.hljs-section,
|
|
48
|
+
.hljs-attribute,
|
|
49
|
+
.hljs-literal,
|
|
50
|
+
.hljs-template-tag,
|
|
51
|
+
.hljs-template-variable,
|
|
52
|
+
.hljs-type,
|
|
53
|
+
.hljs-addition {
|
|
54
|
+
color: #f1fa8c !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* 数字、布尔值 */
|
|
58
|
+
.hljs-number,
|
|
59
|
+
.hljs-selector-attr,
|
|
60
|
+
.hljs-selector-pseudo,
|
|
61
|
+
.hljs-meta-string,
|
|
62
|
+
.hljs-built_in {
|
|
63
|
+
color: #bd93f9 !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* 属性、变量 */
|
|
67
|
+
.hljs-attr,
|
|
68
|
+
.hljs-variable,
|
|
69
|
+
.hljs-property,
|
|
70
|
+
.hljs-params,
|
|
71
|
+
.hljs-class .hljs-title {
|
|
72
|
+
color: #8be9fd !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* 注释 */
|
|
76
|
+
.hljs-comment,
|
|
77
|
+
.hljs-quote,
|
|
78
|
+
.hljs-doctag {
|
|
79
|
+
color: #6272a4 !important;
|
|
80
|
+
font-style: italic;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 函数 */
|
|
84
|
+
.hljs-function .hljs-title {
|
|
85
|
+
color: #50fa7b !important;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* 操作符 */
|
|
90
|
+
.hljs-operator,
|
|
91
|
+
.hljs-entity,
|
|
92
|
+
.hljs-url,
|
|
93
|
+
.language-css .hljs-string,
|
|
94
|
+
.style .hljs-string {
|
|
95
|
+
color: #ff79c6 !important;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* 浅色主题下的代码高亮 - 适用于浅色/蓝色背景 */
|
|
100
|
+
.im-light {
|
|
101
|
+
/* 基础文本颜色 */
|
|
102
|
+
.hljs {
|
|
103
|
+
color: #24292e !important;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* 关键字 */
|
|
107
|
+
.hljs-keyword,
|
|
108
|
+
.hljs-selector-tag,
|
|
109
|
+
.hljs-tag,
|
|
110
|
+
.hljs-name {
|
|
111
|
+
color: #d73a49 !important;
|
|
112
|
+
font-weight: bold;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* 字符串 */
|
|
116
|
+
.hljs-string,
|
|
117
|
+
.hljs-title,
|
|
118
|
+
.hljs-section,
|
|
119
|
+
.hljs-attribute,
|
|
120
|
+
.hljs-literal,
|
|
121
|
+
.hljs-template-tag,
|
|
122
|
+
.hljs-template-variable,
|
|
123
|
+
.hljs-type,
|
|
124
|
+
.hljs-addition {
|
|
125
|
+
color: #032f62 !important;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* 数字、布尔值 */
|
|
129
|
+
.hljs-number,
|
|
130
|
+
.hljs-selector-attr,
|
|
131
|
+
.hljs-selector-pseudo,
|
|
132
|
+
.hljs-meta-string,
|
|
133
|
+
.hljs-built_in {
|
|
134
|
+
color: #005cc5 !important;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* 属性、变量 */
|
|
138
|
+
.hljs-attr,
|
|
139
|
+
.hljs-variable,
|
|
140
|
+
.hljs-property,
|
|
141
|
+
.hljs-params,
|
|
142
|
+
.hljs-class .hljs-title {
|
|
143
|
+
color: #6f42c1 !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* 注释 */
|
|
147
|
+
.hljs-comment,
|
|
148
|
+
.hljs-quote,
|
|
149
|
+
.hljs-doctag {
|
|
150
|
+
color: #6a737d !important;
|
|
151
|
+
font-style: italic;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* 函数 */
|
|
155
|
+
.hljs-function .hljs-title {
|
|
156
|
+
color: #6f42c1 !important;
|
|
157
|
+
font-weight: bold;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* 操作符 */
|
|
161
|
+
.hljs-operator,
|
|
162
|
+
.hljs-entity,
|
|
163
|
+
.hljs-url,
|
|
164
|
+
.language-css .hljs-string,
|
|
165
|
+
.style .hljs-string {
|
|
166
|
+
color: #d73a49 !important;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* 强调 */
|
|
171
|
+
.hljs-emphasis {
|
|
172
|
+
font-style: italic;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.hljs-strong {
|
|
176
|
+
font-weight: bold;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* 确保pre元素和其他容器也没有边框 */
|
|
180
|
+
pre, .code-scroll-container {
|
|
181
|
+
border: none !important;
|
|
182
|
+
outline: none !important;
|
|
183
|
+
background: transparent !important;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* 文件名样式,根据主题自动调整颜色 */
|
|
187
|
+
.filename-text {
|
|
188
|
+
font-size: 10px;
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
|
|
191
|
+
/* 深色模式 - 白色文本 */
|
|
192
|
+
.im-dark &, .im-custom & {
|
|
193
|
+
color: white;
|
|
194
|
+
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* 浅色模式 - 黑色文本 */
|
|
198
|
+
.im-light & {
|
|
199
|
+
color: #000000;
|
|
200
|
+
text-shadow: 0px 0px 1px rgba(255, 255, 255, 0.5);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -423,7 +423,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
423
423
|
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
424
424
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
425
425
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, extInfo) {
|
|
426
|
-
var txtMessage, cuiScrollList, cuiScrollListWrap,
|
|
426
|
+
var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
|
|
427
427
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
428
428
|
while (1) switch (_context2.prev = _context2.next) {
|
|
429
429
|
case 0:
|
|
@@ -445,26 +445,19 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
445
445
|
return rootStore.messageStore.sendMessage(txtMessage);
|
|
446
446
|
case 6:
|
|
447
447
|
if (isAgent) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
node
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
cuiScrollListWrap.scrollTo({
|
|
461
|
-
top: 1000000000
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
448
|
+
cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
449
|
+
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
450
|
+
if (cuiScrollList) {
|
|
451
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
452
|
+
template = document.createElement('template');
|
|
453
|
+
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
454
|
+
node = template.content.firstChild;
|
|
455
|
+
if (node) {
|
|
456
|
+
cuiScrollList.appendChild(node);
|
|
457
|
+
cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
|
|
458
|
+
top: 1000000000
|
|
459
|
+
});
|
|
465
460
|
}
|
|
466
|
-
} catch (error) {
|
|
467
|
-
console.error("Error adding generating loader:", error);
|
|
468
461
|
}
|
|
469
462
|
}
|
|
470
463
|
afterSendMsg(txtMessage, extInfo);
|
|
@@ -501,22 +494,13 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
501
494
|
};
|
|
502
495
|
}();
|
|
503
496
|
useEffect(function () {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
512
|
-
// 使用contains方法安全地检查父子关系
|
|
513
|
-
if (cuiScrollList.contains(generatingLoader)) {
|
|
514
|
-
generatingLoader.remove(); // 更安全的移除方法
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
} catch (error) {
|
|
518
|
-
// 捕获并记录任何DOM操作错误,防止应用崩溃
|
|
519
|
-
console.error("Error handling generating loader:", error);
|
|
497
|
+
var _conversationList$fin;
|
|
498
|
+
var cuiScrollList = document.querySelector(".cui-messageList .cui-scrollList div");
|
|
499
|
+
var generatingLoader = document.querySelector("#agent-generating-loader");
|
|
500
|
+
if (cuiScrollList && generatingLoader && ((_conversationList$fin = _findInstanceProperty(conversationList).call(conversationList, function (item) {
|
|
501
|
+
return item.conversationId === props.conversationId;
|
|
502
|
+
})) === null || _conversationList$fin === void 0 || (_conversationList$fin = _conversationList$fin.lastMessage) === null || _conversationList$fin === void 0 ? void 0 : _conversationList$fin.to) !== props.conversationId) {
|
|
503
|
+
cuiScrollList.removeChild(generatingLoader);
|
|
520
504
|
}
|
|
521
505
|
}, [conversationList, props.conversationId]);
|
|
522
506
|
return /*#__PURE__*/React.createElement("div", {
|