@subiz/widget-v4 4.1.116 → 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/compiled_src/chatbox/MessageInput.js +6 -0
- 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/MessageInput.js +5 -0
- 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
|
@@ -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();
|
|
@@ -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"
|
|
@@ -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()
|
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')
|