@subiz/widget-v4 4.1.115 → 4.1.117
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/assets/less/chatbox.less +1 -1
- package/assets/less/message.less +17 -9
- package/assets/less/order.less +1 -1
- package/assets/less/widget.less +1 -1
- package/assets/less/widget_header.less +2 -2
- package/compiled_src/chatbox/Event.js +2 -4
- package/compiled_src/chatbox/MessageInput.js +6 -0
- package/compiled_src/chatbox/TextMessage.js +10 -4
- package/compiled_src/chatbox/Widget.js +7 -1
- package/compiled_src/chatbox/main.js +3 -0
- package/compiled_src/lib.js +4 -0
- package/compiled_src/plugin.js +4 -0
- package/package.json +3 -3
- package/src/chatbox/Event.js +2 -2
- package/src/chatbox/MessageInput.js +5 -0
- package/src/chatbox/TextMessage.js +15 -5
- package/src/chatbox/Widget.js +9 -3
- package/src/chatbox/main.js +4 -0
- package/src/lib.js +5 -0
- package/src/plugin.js +5 -0
package/assets/less/chatbox.less
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
@font-family-sans-serif: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
|
|
38
38
|
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
39
39
|
|
|
40
|
-
@font-size-base:
|
|
40
|
+
@font-size-base: 16px; // Assumes the browser default, typically `16px`
|
|
41
41
|
|
|
42
42
|
@text-muted: #6c757d;
|
|
43
43
|
|
package/assets/less/message.less
CHANGED
|
@@ -100,18 +100,24 @@
|
|
|
100
100
|
.message-text--user {
|
|
101
101
|
margin: 5px 0 0;
|
|
102
102
|
display: inline-block;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
|
|
105
|
+
background-color: @primary-color;
|
|
106
|
+
.color(@text-color);
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
padding: 12px 16px 12px 16px;
|
|
106
110
|
//padding: 12px;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
.message-text--agent {
|
|
110
114
|
white-space: pre-wrap;
|
|
111
115
|
display: inline-block;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
|
|
117
|
+
background-color: @gray-200;
|
|
118
|
+
.color(@black);
|
|
119
|
+
|
|
120
|
+
padding: 12px 16px 12px 16px;
|
|
115
121
|
}
|
|
116
122
|
.message-agent.message-text--agent {
|
|
117
123
|
max-width: unset;
|
|
@@ -142,7 +148,8 @@
|
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
.message-user {
|
|
145
|
-
border-radius:
|
|
151
|
+
border-radius: 18px;
|
|
152
|
+
border-bottom-right-radius: 4px;
|
|
146
153
|
max-width: 85%;
|
|
147
154
|
align-self: flex-end;
|
|
148
155
|
word-break: break-word;
|
|
@@ -161,7 +168,8 @@
|
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
.message-agent {
|
|
164
|
-
border-radius:
|
|
171
|
+
border-radius: 18px;
|
|
172
|
+
border-bottom-left-radius: 4px;
|
|
165
173
|
max-width: 85%;
|
|
166
174
|
word-break: break-word;
|
|
167
175
|
position: relative;
|
|
@@ -342,7 +350,7 @@ a.message_error {
|
|
|
342
350
|
border-radius: 7px;
|
|
343
351
|
padding: 10px;
|
|
344
352
|
text-align: center;
|
|
345
|
-
font-size:
|
|
353
|
+
font-size: 16px;
|
|
346
354
|
&:hover {
|
|
347
355
|
.color(@text-color);
|
|
348
356
|
}
|
package/assets/less/order.less
CHANGED
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
margin-top: 0px;
|
|
130
130
|
background: #f4f4f4;
|
|
131
131
|
margin-top: 20px;
|
|
132
|
-
width:
|
|
132
|
+
width: 270px;
|
|
133
133
|
box-shadow: 0 0 0 1px hsl(0deg 0% 69% / 20%), 0 15px 35px 0 rgb(49 49 93 / 8%), 0 5px 15px 0 rgb(0 0 0 / 6%);
|
|
134
134
|
border-radius: 6px;
|
|
135
135
|
background-color: #fff;
|
package/assets/less/widget.less
CHANGED
|
@@ -171,8 +171,7 @@ class Event extends _common.Com {
|
|
|
171
171
|
let innercls = 'agent-convo-event-inner';
|
|
172
172
|
if (this.props.isLast) innercls += ' last';
|
|
173
173
|
return (0, _preact.h)("div", {
|
|
174
|
-
class: "convo-event agent-message"
|
|
175
|
-
title: t
|
|
174
|
+
class: "convo-event agent-message"
|
|
176
175
|
}, $time, $sender, (0, _preact.h)("div", {
|
|
177
176
|
class: "agent-convo-event-wrapper"
|
|
178
177
|
}, (0, _preact.h)("div", {
|
|
@@ -259,8 +258,7 @@ class Event extends _common.Com {
|
|
|
259
258
|
}));
|
|
260
259
|
}
|
|
261
260
|
return (0, _preact.h)("div", {
|
|
262
|
-
class: "convo-event user-message"
|
|
263
|
-
title: t
|
|
261
|
+
class: "convo-event user-message"
|
|
264
262
|
}, $time, $sender, (0, _preact.h)("div", {
|
|
265
263
|
class: "message-user__container"
|
|
266
264
|
}, $dot, (0, _preact.h)(_TextMessage.default, {
|
|
@@ -214,6 +214,12 @@ class MessageInput extends _common.Com {
|
|
|
214
214
|
class: "emoji-picker--item emoji--wink"
|
|
215
215
|
})));
|
|
216
216
|
}
|
|
217
|
+
applyMessage(text) {
|
|
218
|
+
this.setState({
|
|
219
|
+
msgValue: text
|
|
220
|
+
});
|
|
221
|
+
this.resizeInput();
|
|
222
|
+
}
|
|
217
223
|
focus() {
|
|
218
224
|
if (this.props.disabled) return;
|
|
219
225
|
this.refMessageInput.current && this.refMessageInput.current.focus();
|
|
@@ -21,6 +21,7 @@ class TextMessage extends _common.Com {
|
|
|
21
21
|
var text = _index.default.get(this.props.ev, 'data.message.text');
|
|
22
22
|
text = _index.default.trim(text);
|
|
23
23
|
if (_index.default.size(text) === 0) return null;
|
|
24
|
+
let t = new _index.default.Date(_index.default.get(this.props.ev, 'created')).toLocaleString();
|
|
24
25
|
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
25
26
|
if (byType !== 'user') byType = 'agent';
|
|
26
27
|
var tags = _index.default.extractText(text).map(tag => {
|
|
@@ -49,26 +50,31 @@ class TextMessage extends _common.Com {
|
|
|
49
50
|
});
|
|
50
51
|
if (_index.default.size(tags) === 0) return null;
|
|
51
52
|
if (byType === 'agent') return (0, _preact.h)("div", {
|
|
52
|
-
class: "message-agent message-text--agent"
|
|
53
|
+
class: "message-agent message-text--agent",
|
|
54
|
+
title: t
|
|
53
55
|
}, tags);
|
|
54
56
|
return (0, _preact.h)("div", {
|
|
55
|
-
class: "message-user message-text--user"
|
|
57
|
+
class: "message-user message-text--user",
|
|
58
|
+
title: t
|
|
56
59
|
}, tags);
|
|
57
60
|
}
|
|
58
61
|
renderBlock(block) {
|
|
59
62
|
if (isEmptyBlock(block)) return null;
|
|
63
|
+
let t = new _index.default.Date(_index.default.get(this.props.ev, 'created')).toLocaleString();
|
|
60
64
|
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
61
65
|
if (byType !== 'user') byType = 'agent';
|
|
62
66
|
if (byType === 'agent') {
|
|
63
67
|
return (0, _preact.h)("div", {
|
|
64
|
-
class: "message-agent message-text--agent"
|
|
68
|
+
class: "message-agent message-text--agent",
|
|
69
|
+
title: t
|
|
65
70
|
}, (0, _preact.h)(_block.default, {
|
|
66
71
|
block: block,
|
|
67
72
|
onLink: this.props.onLink
|
|
68
73
|
}));
|
|
69
74
|
}
|
|
70
75
|
return (0, _preact.h)("div", {
|
|
71
|
-
class: "message-user message-text--user"
|
|
76
|
+
class: "message-user message-text--user",
|
|
77
|
+
title: t
|
|
72
78
|
}, (0, _preact.h)(_block.default, {
|
|
73
79
|
block: block,
|
|
74
80
|
onLink: this.props.onLink
|
|
@@ -135,6 +135,9 @@ class Widget extends _common.Com {
|
|
|
135
135
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
136
136
|
this.updateFormDataFields();
|
|
137
137
|
}
|
|
138
|
+
applyMessage(text) {
|
|
139
|
+
this.focusInput(text);
|
|
140
|
+
}
|
|
138
141
|
componentDidUpdate(prevProp) {
|
|
139
142
|
if (prevProp.isShow !== this.props.isShow) {
|
|
140
143
|
if (this.props.isShow && !this.props.store.isMobile()) this.focusInput();
|
|
@@ -727,7 +730,7 @@ class Widget extends _common.Com {
|
|
|
727
730
|
_index.default.setTimeout(() => $input && $input.blur());
|
|
728
731
|
_index.default.setTimeout(() => $input && $input.blur(), 300);
|
|
729
732
|
}
|
|
730
|
-
focusInput() {
|
|
733
|
+
focusInput(text) {
|
|
731
734
|
if (this.props.store.isPreview) return;
|
|
732
735
|
if (this.shouldShowForm()) {
|
|
733
736
|
let firstemptykey = '';
|
|
@@ -745,6 +748,9 @@ class Widget extends _common.Com {
|
|
|
745
748
|
}
|
|
746
749
|
var $input = this.msgInput.current;
|
|
747
750
|
if (!$input) return;
|
|
751
|
+
if (text != undefined && typeof text === 'string') {
|
|
752
|
+
$input.applyMessage(text);
|
|
753
|
+
}
|
|
748
754
|
_index.default.setTimeout(() => $input.focus());
|
|
749
755
|
_index.default.setTimeout(() => $input.focus(), 300);
|
|
750
756
|
}
|
|
@@ -155,6 +155,9 @@ class Main extends _common.Com {
|
|
|
155
155
|
cid: p.cid
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
+
applyMessage(text) {
|
|
159
|
+
this.refWidget.current && this.refWidget.current.applyMessage(text);
|
|
160
|
+
}
|
|
158
161
|
showGreeting() {
|
|
159
162
|
this.refButton.current && this.refButton.current.ShowGreeting();
|
|
160
163
|
}
|
package/compiled_src/lib.js
CHANGED
|
@@ -260,6 +260,10 @@ class Widget {
|
|
|
260
260
|
if (this.pluginMgr) this.pluginMgr.destroy();
|
|
261
261
|
this.store.destroy();
|
|
262
262
|
}
|
|
263
|
+
async applyMessage(msg) {
|
|
264
|
+
await this.domGate.entry();
|
|
265
|
+
this.pluginMgr.applyTextToCurrentChatbox(msg);
|
|
266
|
+
}
|
|
263
267
|
_overridePlugin(plugins) {
|
|
264
268
|
this.store.overridePlugin(plugins);
|
|
265
269
|
}
|
package/compiled_src/plugin.js
CHANGED
|
@@ -264,6 +264,10 @@ class PluginMgr {
|
|
|
264
264
|
let chatbox = this.findChatbox();
|
|
265
265
|
if (chatbox) return chatbox.call('showGreeting');
|
|
266
266
|
}
|
|
267
|
+
applyTextToCurrentChatbox(text) {
|
|
268
|
+
let chatbox = this.findChatbox();
|
|
269
|
+
if (chatbox) return chatbox.call('applyMessage', text);
|
|
270
|
+
}
|
|
267
271
|
hideCurrentGreeting() {
|
|
268
272
|
let chatbox = this.findChatbox();
|
|
269
273
|
if (chatbox) return chatbox.call('hideGreeting');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subiz/widget-v4",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.117",
|
|
4
4
|
"main": "./compiled_src/lib.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npx webpack serve --config webpack.dev.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"babel-loader": "^10.0.0",
|
|
31
31
|
"babel-plugin-syntax-jsx": "^6.18.0",
|
|
32
32
|
"html-webpack-plugin": "^5.6.3",
|
|
33
|
-
"puppeteer": "^24.6.
|
|
34
|
-
"webpack": "^5.99.
|
|
33
|
+
"puppeteer": "^24.6.1",
|
|
34
|
+
"webpack": "^5.99.5",
|
|
35
35
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
36
36
|
"webpack-cli": "^6.0.1",
|
|
37
37
|
"webpack-dev-server": "^5.2.1"
|
package/src/chatbox/Event.js
CHANGED
|
@@ -170,7 +170,7 @@ export default class Event extends Com {
|
|
|
170
170
|
let innercls = 'agent-convo-event-inner'
|
|
171
171
|
if (this.props.isLast) innercls += ' last'
|
|
172
172
|
return (
|
|
173
|
-
<div class='convo-event agent-message'
|
|
173
|
+
<div class='convo-event agent-message'>
|
|
174
174
|
{$time}
|
|
175
175
|
{$sender}
|
|
176
176
|
<div class='agent-convo-event-wrapper'>
|
|
@@ -238,7 +238,7 @@ export default class Event extends Com {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
return (
|
|
241
|
-
<div class='convo-event user-message'
|
|
241
|
+
<div class='convo-event user-message'>
|
|
242
242
|
{$time}
|
|
243
243
|
{$sender}
|
|
244
244
|
<div class='message-user__container'>
|
|
@@ -226,6 +226,11 @@ export default class MessageInput extends Com {
|
|
|
226
226
|
)
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
applyMessage(text) {
|
|
230
|
+
this.setState({msgValue: text})
|
|
231
|
+
this.resizeInput()
|
|
232
|
+
}
|
|
233
|
+
|
|
229
234
|
focus() {
|
|
230
235
|
if (this.props.disabled) return
|
|
231
236
|
this.refMessageInput.current && this.refMessageInput.current.focus()
|
|
@@ -16,7 +16,7 @@ export default class TextMessage extends Com {
|
|
|
16
16
|
var text = sb.get(this.props.ev, 'data.message.text')
|
|
17
17
|
text = sb.trim(text)
|
|
18
18
|
if (sb.size(text) === 0) return null
|
|
19
|
-
|
|
19
|
+
let t = new sb.Date(sb.get(this.props.ev, 'created')).toLocaleString()
|
|
20
20
|
let byType = sb.get(this.props.ev, 'by.type')
|
|
21
21
|
if (byType !== 'user') byType = 'agent'
|
|
22
22
|
var tags = sb.extractText(text).map((tag) => {
|
|
@@ -44,23 +44,33 @@ export default class TextMessage extends Com {
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
if (sb.size(tags) === 0) return null
|
|
47
|
-
if (byType === 'agent')
|
|
48
|
-
|
|
47
|
+
if (byType === 'agent')
|
|
48
|
+
return (
|
|
49
|
+
<div class='message-agent message-text--agent' title={t}>
|
|
50
|
+
{tags}
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
return (
|
|
54
|
+
<div class='message-user message-text--user' title={t}>
|
|
55
|
+
{tags}
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
renderBlock(block) {
|
|
52
61
|
if (isEmptyBlock(block)) return null
|
|
62
|
+
let t = new sb.Date(sb.get(this.props.ev, 'created')).toLocaleString()
|
|
53
63
|
let byType = sb.get(this.props.ev, 'by.type')
|
|
54
64
|
if (byType !== 'user') byType = 'agent'
|
|
55
65
|
if (byType === 'agent') {
|
|
56
66
|
return (
|
|
57
|
-
<div class='message-agent message-text--agent'>
|
|
67
|
+
<div class='message-agent message-text--agent' title={t}>
|
|
58
68
|
<Block block={block} onLink={this.props.onLink} />
|
|
59
69
|
</div>
|
|
60
70
|
)
|
|
61
71
|
}
|
|
62
72
|
return (
|
|
63
|
-
<div class='message-user message-text--user'>
|
|
73
|
+
<div class='message-user message-text--user' title={t}>
|
|
64
74
|
<Block block={block} onLink={this.props.onLink} />
|
|
65
75
|
</div>
|
|
66
76
|
)
|
package/src/chatbox/Widget.js
CHANGED
|
@@ -49,6 +49,10 @@ export default class Widget extends Com {
|
|
|
49
49
|
this.updateFormDataFields()
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
applyMessage(text) {
|
|
53
|
+
this.focusInput(text)
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
componentDidUpdate(prevProp) {
|
|
53
57
|
if (prevProp.isShow !== this.props.isShow) {
|
|
54
58
|
if (this.props.isShow && !this.props.store.isMobile()) this.focusInput()
|
|
@@ -130,7 +134,7 @@ export default class Widget extends Com {
|
|
|
130
134
|
let position = sb.get(accountSetting, 'desktop_button.position') || 'right'
|
|
131
135
|
if (this.props.store.isMobile()) position = sb.get(accountSetting, 'mobile_button.position', position)
|
|
132
136
|
let cls = 'widget-container widget-container--' + position
|
|
133
|
-
if (
|
|
137
|
+
if (!this.props.store.isMobile() && sb.get(accountSetting, 'window_mode') === 'full')
|
|
134
138
|
cls += ' widget-container--full'
|
|
135
139
|
if (!this.props.isShow) cls += ' widget-container--hide'
|
|
136
140
|
let hideheader = sb.get(accountSetting, 'header.hidden', false)
|
|
@@ -709,9 +713,8 @@ export default class Widget extends Com {
|
|
|
709
713
|
sb.setTimeout(() => $input && $input.blur(), 300) // force lose focus
|
|
710
714
|
}
|
|
711
715
|
|
|
712
|
-
focusInput() {
|
|
716
|
+
focusInput(text) {
|
|
713
717
|
if (this.props.store.isPreview) return
|
|
714
|
-
|
|
715
718
|
if (this.shouldShowForm()) {
|
|
716
719
|
// focus on the element
|
|
717
720
|
let firstemptykey = ''
|
|
@@ -733,6 +736,9 @@ export default class Widget extends Com {
|
|
|
733
736
|
|
|
734
737
|
var $input = this.msgInput.current
|
|
735
738
|
if (!$input) return
|
|
739
|
+
if (text != undefined && typeof text === 'string') {
|
|
740
|
+
$input.applyMessage(text)
|
|
741
|
+
}
|
|
736
742
|
sb.setTimeout(() => $input.focus())
|
|
737
743
|
sb.setTimeout(() => $input.focus(), 300) // force focus
|
|
738
744
|
}
|
package/src/chatbox/main.js
CHANGED
|
@@ -168,6 +168,10 @@ export default class Main extends Com {
|
|
|
168
168
|
this.props.store.setLastview(p.view, {cid: p.cid})
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
applyMessage(text) {
|
|
172
|
+
this.refWidget.current && this.refWidget.current.applyMessage(text)
|
|
173
|
+
}
|
|
174
|
+
|
|
171
175
|
showGreeting() {
|
|
172
176
|
this.refButton.current && this.refButton.current.ShowGreeting()
|
|
173
177
|
}
|
package/src/lib.js
CHANGED
|
@@ -275,6 +275,11 @@ class Widget {
|
|
|
275
275
|
this.store.destroy()
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
async applyMessage(msg) {
|
|
279
|
+
await this.domGate.entry()
|
|
280
|
+
this.pluginMgr.applyTextToCurrentChatbox(msg)
|
|
281
|
+
}
|
|
282
|
+
|
|
278
283
|
_overridePlugin(plugins) {
|
|
279
284
|
this.store.overridePlugin(plugins)
|
|
280
285
|
}
|
package/src/plugin.js
CHANGED
|
@@ -302,6 +302,11 @@ export default class PluginMgr {
|
|
|
302
302
|
if (chatbox) return chatbox.call('showGreeting')
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
applyTextToCurrentChatbox(text) {
|
|
306
|
+
let chatbox = this.findChatbox()
|
|
307
|
+
if (chatbox) return chatbox.call('applyMessage', text)
|
|
308
|
+
}
|
|
309
|
+
|
|
305
310
|
hideCurrentGreeting() {
|
|
306
311
|
let chatbox = this.findChatbox()
|
|
307
312
|
if (chatbox) return chatbox.call('hideGreeting')
|