@subiz/widget-v4 4.0.82 → 4.0.86
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/ChatButton.js +4 -8
- package/compiled_src/chatbox/TextMessage.js +1 -2
- package/compiled_src/chatbox/Typing.js +1 -1
- package/compiled_src/chatbox/Widget.js +9 -1
- package/compiled_src/popup/popup.js +7 -0
- package/compiled_src/store/store.js +4 -6
- package/dist/132.js +162 -44
- package/dist/178.js +174 -341
- package/dist/18224b3b0f8.132.js +1 -0
- package/dist/18224b3b0f8.178.js +1 -0
- package/dist/{17f00e48d38.213.js → 18224b3b0f8.213.js} +1 -1
- package/dist/{17f00e48d38.335.js → 18224b3b0f8.335.js} +1 -1
- package/dist/18224b3b0f8.362.js +1 -0
- package/dist/18224b3b0f8.441.js +1 -0
- package/dist/{17f00e48d38.605.js → 18224b3b0f8.605.js} +0 -0
- package/dist/18224b3b0f8.678.js +1 -0
- package/dist/18224b3b0f8.782.js +1 -0
- package/dist/18224b3b0f8.app.js +1 -0
- package/dist/{17f00e48d38.index.html → 18224b3b0f8.index.html} +7 -3
- package/dist/{17f00e48d38.library.html → 18224b3b0f8.library.html} +7 -3
- package/dist/18224b3b0f8.library.js +1 -0
- package/dist/{17f00e48d38.preview.html → 18224b3b0f8.preview.html} +1 -1
- package/dist/18224b3b0f8.preview.js +1 -0
- package/dist/18224b3b0f8.screenshoot.js +1 -0
- package/dist/213.js +16 -0
- package/dist/335.js +2 -2
- package/dist/362.js +21 -71
- package/dist/441.js +150 -56
- package/dist/678.js +20 -70
- package/dist/782.js +21 -118
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +185 -133
- package/package.json +14 -14
- package/src/chatbox/ChatButton.js +4 -4
- package/src/chatbox/TextMessage.js +4 -2
- package/src/chatbox/Typing.js +10 -11
- package/src/chatbox/Widget.js +7 -2
- package/src/popup/popup.js +23 -11
- package/src/store/store.js +3 -4
- package/dist/0b82fa7e5c3b07b40a44.png +0 -1
- package/dist/0f4af006e38ee8b93633.png +0 -1
- package/dist/17f00e48d38.132.js +0 -1
- package/dist/17f00e48d38.178.js +0 -1
- package/dist/17f00e48d38.362.js +0 -1
- package/dist/17f00e48d38.441.js +0 -1
- package/dist/17f00e48d38.678.js +0 -1
- package/dist/17f00e48d38.782.js +0 -1
- package/dist/17f00e48d38.app.js +0 -1
- package/dist/17f00e48d38.library.js +0 -1
- package/dist/17f00e48d38.preview.js +0 -1
- package/dist/17f00e48d38.screenshoot.js +0 -1
- package/dist/1ea1c6cd21d25176810c.png +0 -1
- package/dist/292d42404e1b03398f61.png +0 -1
- package/dist/312d376370831b7bea83.png +0 -1
- package/dist/313d1bfc1cf776d1aefe.png +0 -1
- package/dist/4aa58bb7a66bb44975aa.png +0 -1
- package/dist/56ce063bc6c81adb7322.png +0 -1
- package/dist/6a411166ef5cc79e0714.png +0 -1
- package/dist/6faf403782fefacc1649.png +0 -1
- package/dist/79dca33c68fab79c067f.png +0 -1
- package/dist/82da1578fa84f9debaeb.png +0 -1
- package/dist/8b8e0f0824743974b282.png +0 -1
- package/dist/8d551390d81e39130a3c.png +0 -1
- package/dist/9fc61b9479877ebdb6c7.png +0 -1
- package/dist/a165d31dcb3dc90f1057.png +0 -1
- package/dist/a98d4a5698812c4426b3.png +0 -1
- package/dist/c41606bf9d1b604e46d5.png +0 -1
- package/dist/ce1f7450ce6c1aacd330.png +0 -1
- package/dist/cf8c01e88f4770a6e3e5.png +0 -1
- package/dist/dfbcfeab1d5622a737e2.png +0 -1
- package/dist/e4893ed8c2f7b8329919.png +0 -1
- package/dist/ec2ab4eb4ef73d186186.png +0 -1
|
@@ -247,21 +247,17 @@ class ChatButton extends _common.Com {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
onProfileReady() {
|
|
250
|
-
if (this.
|
|
250
|
+
if (this._buttonLoaded) this.setState({
|
|
251
251
|
opacity: 1
|
|
252
252
|
});
|
|
253
|
-
this.
|
|
254
|
-
profileLoaded: true
|
|
255
|
-
});
|
|
253
|
+
this._profileLoaded = true;
|
|
256
254
|
}
|
|
257
255
|
|
|
258
256
|
onButtonReady() {
|
|
259
|
-
if (this.
|
|
257
|
+
if (this._profileLoaded) this.setState({
|
|
260
258
|
opacity: 1
|
|
261
259
|
});
|
|
262
|
-
this.
|
|
263
|
-
buttonLoaded: true
|
|
264
|
-
});
|
|
260
|
+
this._buttonLoaded = true;
|
|
265
261
|
}
|
|
266
262
|
|
|
267
263
|
renderButton() {
|
|
@@ -105,11 +105,10 @@ class TextMessage extends _common.Com {
|
|
|
105
105
|
deltas = _index.default.parseJSON(deltas) || {};
|
|
106
106
|
deltas = deltas.ops || [];
|
|
107
107
|
|
|
108
|
-
let isMarkdown = _index.default.find(deltas, delta => _index.default.get(delta, 'attributes.bold') || _index.default.get(delta, 'attributes.italic') || _index.default.get(delta, 'attributes.underline'));
|
|
108
|
+
let isMarkdown = _index.default.find(deltas, delta => _index.default.get(delta, 'attributes.bold') || _index.default.get(delta, 'attributes.italic') || _index.default.get(delta, 'attributes.underline') || _index.default.get(delta, 'insert.emoji'));
|
|
109
109
|
|
|
110
110
|
if (isMarkdown) {
|
|
111
111
|
var text = deltaToMarkdown(deltas);
|
|
112
|
-
console.log('text', text);
|
|
113
112
|
return this.renderMarkdown(text);
|
|
114
113
|
}
|
|
115
114
|
|
|
@@ -41,7 +41,7 @@ class Typing extends _common.Com {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
let ag = this.props.store.matchAgent(ev.by.id);
|
|
44
|
+
let ag = this.props.store.matchAgent(ev.by.id) || {};
|
|
45
45
|
if (ag.type == 'agent') return;
|
|
46
46
|
if (_index.default.get(ev, 'type') !== 'conversation_typing') return;
|
|
47
47
|
this.setState({
|
|
@@ -189,11 +189,14 @@ class Widget extends _common.Com {
|
|
|
189
189
|
|
|
190
190
|
let user = _index.default.cloneDeep(this.props.store.matchUser());
|
|
191
191
|
|
|
192
|
+
let is_lead = false;
|
|
193
|
+
|
|
192
194
|
_index.default.map(data, (field, key) => {
|
|
193
195
|
if (!key.startsWith('attr:')) return;
|
|
194
196
|
var attr = {
|
|
195
197
|
key: key.substr(5)
|
|
196
198
|
};
|
|
199
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
197
200
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
198
201
|
if (field.type === 'datetime') attr.datetime = new _index.default.Date(field.value).toISOString();
|
|
199
202
|
if (field.type === 'list') attr.list = field.value;
|
|
@@ -202,6 +205,11 @@ class Widget extends _common.Com {
|
|
|
202
205
|
_index.default.setUserAttr(user, attr);
|
|
203
206
|
});
|
|
204
207
|
|
|
208
|
+
if (is_lead) _index.default.setUserAttr(user, {
|
|
209
|
+
key: 'lead_source',
|
|
210
|
+
text: 'widget'
|
|
211
|
+
});
|
|
212
|
+
|
|
205
213
|
let firstmsg = _index.default.get(data, 'question.value');
|
|
206
214
|
|
|
207
215
|
let groupid = _index.default.get(data, 'group.value', '');
|
|
@@ -241,11 +249,11 @@ class Widget extends _common.Com {
|
|
|
241
249
|
this.setState({
|
|
242
250
|
creatingError: null
|
|
243
251
|
});
|
|
252
|
+
await this.props.store.setUser(user);
|
|
244
253
|
const {
|
|
245
254
|
error,
|
|
246
255
|
convo
|
|
247
256
|
} = await this.props.store.startConvo(req);
|
|
248
|
-
this.props.store.setUser(user);
|
|
249
257
|
|
|
250
258
|
if (error) {
|
|
251
259
|
this.setState({
|
|
@@ -280,6 +280,8 @@ class Popup extends _common.Com {
|
|
|
280
280
|
|
|
281
281
|
let user = _index.default.cloneDeep(this.props.store.matchUser());
|
|
282
282
|
|
|
283
|
+
let is_lead = false;
|
|
284
|
+
|
|
283
285
|
for (var pair of formData.entries()) {
|
|
284
286
|
let page = _index.default.get(this.props.plugin.popup, `pages.${this.getPageIndex()}`);
|
|
285
287
|
|
|
@@ -298,6 +300,7 @@ class Popup extends _common.Com {
|
|
|
298
300
|
let key = pair[0];
|
|
299
301
|
if (key === 'email') key = 'emails';
|
|
300
302
|
if (key === 'phone') key = 'phones';
|
|
303
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
301
304
|
|
|
302
305
|
_index.default.setUserAttr(user, {
|
|
303
306
|
key: key,
|
|
@@ -305,6 +308,10 @@ class Popup extends _common.Com {
|
|
|
305
308
|
});
|
|
306
309
|
}
|
|
307
310
|
|
|
311
|
+
if (is_lead) _index.default.setUserAttr(user, {
|
|
312
|
+
key: 'lead_source',
|
|
313
|
+
text: 'plugin.' + this.props.plugin.id
|
|
314
|
+
});
|
|
308
315
|
this.props.store.sendConversion(this.props.plugin.id, summitFields, this.impressionToken);
|
|
309
316
|
this.props.store.setUser(user);
|
|
310
317
|
}
|
|
@@ -1232,7 +1232,10 @@ function sendToFBPixel(category, action, label) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
function sendToGA(category, action, label) {
|
|
1235
|
-
|
|
1235
|
+
if (window.gtag) window.gtag('event', category, {
|
|
1236
|
+
Action: action,
|
|
1237
|
+
Label: label
|
|
1238
|
+
});
|
|
1236
1239
|
|
|
1237
1240
|
if (window.ga && window.ga.getAll) {
|
|
1238
1241
|
const allTrackers = window.ga.getAll() || [];
|
|
@@ -1240,11 +1243,6 @@ function sendToGA(category, action, label) {
|
|
|
1240
1243
|
const name = tracker.get('name');
|
|
1241
1244
|
window.ga(name + '.send', 'event', category, action, label);
|
|
1242
1245
|
});
|
|
1243
|
-
} else {
|
|
1244
|
-
if (window.gtag) window.gtag('event', category, {
|
|
1245
|
-
Action: action,
|
|
1246
|
-
Label: label
|
|
1247
|
-
});
|
|
1248
1246
|
}
|
|
1249
1247
|
}
|
|
1250
1248
|
|
package/dist/132.js
CHANGED
|
@@ -161,8 +161,9 @@ class ChatButton extends common/* Com */.up {
|
|
|
161
161
|
let accountSetting = this.props.plugin.chatbox;
|
|
162
162
|
if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
163
163
|
let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
|
|
164
|
+
let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
|
|
164
165
|
|
|
165
|
-
if (!
|
|
166
|
+
if (!text || !greeting.enabled) {
|
|
166
167
|
this.setState({
|
|
167
168
|
previewEvent: {}
|
|
168
169
|
});
|
|
@@ -257,21 +258,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
onProfileReady() {
|
|
260
|
-
if (this.
|
|
261
|
+
if (this._buttonLoaded) this.setState({
|
|
261
262
|
opacity: 1
|
|
262
263
|
});
|
|
263
|
-
this.
|
|
264
|
-
profileLoaded: true
|
|
265
|
-
});
|
|
264
|
+
this._profileLoaded = true;
|
|
266
265
|
}
|
|
267
266
|
|
|
268
267
|
onButtonReady() {
|
|
269
|
-
if (this.
|
|
268
|
+
if (this._profileLoaded) this.setState({
|
|
270
269
|
opacity: 1
|
|
271
270
|
});
|
|
272
|
-
this.
|
|
273
|
-
buttonLoaded: true
|
|
274
|
-
});
|
|
271
|
+
this._buttonLoaded = true;
|
|
275
272
|
}
|
|
276
273
|
|
|
277
274
|
renderButton() {
|
|
@@ -1295,7 +1292,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1295
1292
|
href: 'tel:' + button.phone_number,
|
|
1296
1293
|
key: index,
|
|
1297
1294
|
title: button.title
|
|
1298
|
-
}, button.title);
|
|
1295
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1299
1296
|
}
|
|
1300
1297
|
|
|
1301
1298
|
if (button.type === 'url_button') {
|
|
@@ -1305,7 +1302,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1305
1302
|
target: "_blank",
|
|
1306
1303
|
key: index,
|
|
1307
1304
|
title: button.title
|
|
1308
|
-
}, button.title || button.url);
|
|
1305
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || button.url);
|
|
1309
1306
|
}
|
|
1310
1307
|
|
|
1311
1308
|
if (button.type === 'postback_button') {
|
|
@@ -1313,7 +1310,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1313
1310
|
class: "url-button-attachment",
|
|
1314
1311
|
href: "javascript:;",
|
|
1315
1312
|
onClick: _ => this.props.onSelect(button)
|
|
1316
|
-
}, button.title);
|
|
1313
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1317
1314
|
}
|
|
1318
1315
|
|
|
1319
1316
|
if (button.type === 'widget_ask_desktop_notify_button') return null;
|
|
@@ -1347,7 +1344,8 @@ class ButtonAttachments extends common/* Com */.up {
|
|
|
1347
1344
|
});
|
|
1348
1345
|
return (0,preact_module.h)(Buttons, {
|
|
1349
1346
|
store: this.props.store,
|
|
1350
|
-
buttons: buttons
|
|
1347
|
+
buttons: buttons,
|
|
1348
|
+
t: this.props.t
|
|
1351
1349
|
});
|
|
1352
1350
|
}
|
|
1353
1351
|
|
|
@@ -1956,7 +1954,10 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1956
1954
|
this.setState({
|
|
1957
1955
|
focusing: eleindex
|
|
1958
1956
|
});
|
|
1959
|
-
this.galleryRef.current.
|
|
1957
|
+
this.galleryRef.current.scrollTo({
|
|
1958
|
+
left: 220 * eleindex,
|
|
1959
|
+
behavior: 'smooth'
|
|
1960
|
+
});
|
|
1960
1961
|
}
|
|
1961
1962
|
|
|
1962
1963
|
render() {
|
|
@@ -1967,21 +1968,26 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1967
1968
|
if (generics.length === 0) return null;
|
|
1968
1969
|
var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
|
|
1969
1970
|
var $eles = util/* default.map */.Z.map(gen.elements, ele => {
|
|
1970
|
-
let
|
|
1971
|
+
let title = this.props.t.i18n(ele.i18n_title) || ele.title;
|
|
1972
|
+
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
|
|
1973
|
+
let $title = title ? (0,preact_module.h)("div", {
|
|
1971
1974
|
class: "generic-attachment--element-title"
|
|
1972
|
-
},
|
|
1973
|
-
let $subtitle =
|
|
1975
|
+
}, title) : null;
|
|
1976
|
+
let $subtitle = subtitle ? (0,preact_module.h)("div", {
|
|
1974
1977
|
class: "generic-attachment--element-subtitle"
|
|
1975
|
-
},
|
|
1978
|
+
}, subtitle) : null;
|
|
1976
1979
|
return (0,preact_module.h)("div", {
|
|
1977
1980
|
class: "generic-attachment--element swiper-slide"
|
|
1978
1981
|
}, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
|
|
1979
1982
|
alt: "generic attachment element",
|
|
1980
1983
|
class: "generic-attachment--element-img",
|
|
1981
1984
|
src: this.props.store.replaceFileUrl(ele.image_url)
|
|
1982
|
-
})),
|
|
1985
|
+
})), (0,preact_module.h)("div", {
|
|
1986
|
+
class: "generic-attachment--element-content"
|
|
1987
|
+
}, $title, $subtitle), (0,preact_module.h)(Buttons, {
|
|
1983
1988
|
buttons: ele.buttons,
|
|
1984
|
-
onSelect: button => this.props.onSelect(button)
|
|
1989
|
+
onSelect: button => this.props.onSelect(button),
|
|
1990
|
+
t: this.props.t
|
|
1985
1991
|
}));
|
|
1986
1992
|
});
|
|
1987
1993
|
let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
|
|
@@ -2031,17 +2037,53 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2031
2037
|
let acc = this.props.store.matchAccount();
|
|
2032
2038
|
let $products = util/* default.map */.Z.map(products, (att, index) => {
|
|
2033
2039
|
let product = att.product;
|
|
2034
|
-
let $
|
|
2040
|
+
let $detailbtns = [];
|
|
2035
2041
|
let url = product.url || product.mobile_url;
|
|
2036
2042
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
2037
|
-
if (url)
|
|
2043
|
+
if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
|
|
2038
2044
|
class: "product_attachment__btn",
|
|
2039
2045
|
href: url,
|
|
2040
2046
|
target: "_blank"
|
|
2041
2047
|
}, this.props.t('detail'), (0,preact_module.h)("img", {
|
|
2042
2048
|
src: __webpack_require__(8453),
|
|
2043
2049
|
class: "product_attachment__btn_external_link"
|
|
2044
|
-
}));
|
|
2050
|
+
})));
|
|
2051
|
+
console.log('P', product);
|
|
2052
|
+
|
|
2053
|
+
if (util/* default.size */.Z.size(product.buttons) > 0) {
|
|
2054
|
+
$detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
|
|
2055
|
+
if (button.type === 'call_button') {
|
|
2056
|
+
return (0,preact_module.h)("a", {
|
|
2057
|
+
class: "product_attachment__btn",
|
|
2058
|
+
href: 'tel:' + button.phone_number,
|
|
2059
|
+
key: index,
|
|
2060
|
+
title: button.title
|
|
2061
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
if (button.type === 'url_button') {
|
|
2065
|
+
return (0,preact_module.h)("a", {
|
|
2066
|
+
class: "product_attachment__btn",
|
|
2067
|
+
href: button.url,
|
|
2068
|
+
target: "_blank",
|
|
2069
|
+
key: index,
|
|
2070
|
+
title: button.title
|
|
2071
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
|
|
2072
|
+
src: __webpack_require__(8453),
|
|
2073
|
+
class: "product_attachment__btn_external_link"
|
|
2074
|
+
}));
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
if (button.type === 'postback_button') {
|
|
2078
|
+
return (0,preact_module.h)("a", {
|
|
2079
|
+
class: "product_attachment__btn",
|
|
2080
|
+
href: "javascript:;",
|
|
2081
|
+
onClick: _ => this.props.onPostback(button)
|
|
2082
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2083
|
+
}
|
|
2084
|
+
}));
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2045
2087
|
let $title = (0,preact_module.h)("a", {
|
|
2046
2088
|
href: url,
|
|
2047
2089
|
class: "product_attachment__title",
|
|
@@ -2070,7 +2112,7 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2070
2112
|
src: this.props.store.replaceFileUrl(product.image)
|
|
2071
2113
|
}))), $title, $subtitle, $price, (0,preact_module.h)("div", {
|
|
2072
2114
|
class: "product_attachment__btns"
|
|
2073
|
-
}, $
|
|
2115
|
+
}, $detailbtns));
|
|
2074
2116
|
});
|
|
2075
2117
|
return $products;
|
|
2076
2118
|
}
|
|
@@ -2226,8 +2268,7 @@ img { max-width: 100%; display: block; margin: 10px auto; }
|
|
|
2226
2268
|
* { white-space: normal }
|
|
2227
2269
|
ul > li { margin-bottom: 5px }
|
|
2228
2270
|
ul:last-child { margin-bottom: 0 }
|
|
2229
|
-
p
|
|
2230
|
-
p:last-child { margin-bottom: 0;}
|
|
2271
|
+
p { margin-bottom: 0; margin-top: 0;}
|
|
2231
2272
|
</style>
|
|
2232
2273
|
<div>${html}</div>`;
|
|
2233
2274
|
let links = this.shadowRoot.querySelectorAll('a');
|
|
@@ -2271,6 +2312,11 @@ class TextMessage extends common/* Com */.up {
|
|
|
2271
2312
|
render() {
|
|
2272
2313
|
var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2273
2314
|
if (format === 'markdown') return this.renderMarkdown();
|
|
2315
|
+
if (format === 'delta') return this.renderDelta();
|
|
2316
|
+
return this.renderPlainText();
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
renderPlainText() {
|
|
2274
2320
|
var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2275
2321
|
text = util/* default.trim */.Z.trim(text);
|
|
2276
2322
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
@@ -2316,8 +2362,22 @@ class TextMessage extends common/* Com */.up {
|
|
|
2316
2362
|
}, tags);
|
|
2317
2363
|
}
|
|
2318
2364
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2365
|
+
renderDelta() {
|
|
2366
|
+
let deltas = util/* default.get */.Z.get(this.props.ev, 'data.message.quill_delta');
|
|
2367
|
+
deltas = util/* default.parseJSON */.Z.parseJSON(deltas) || {};
|
|
2368
|
+
deltas = deltas.ops || [];
|
|
2369
|
+
let isMarkdown = util/* default.find */.Z.find(deltas, delta => util/* default.get */.Z.get(delta, 'attributes.bold') || util/* default.get */.Z.get(delta, 'attributes.italic') || util/* default.get */.Z.get(delta, 'attributes.underline') || util/* default.get */.Z.get(delta, 'insert.emoji'));
|
|
2370
|
+
|
|
2371
|
+
if (isMarkdown) {
|
|
2372
|
+
var text = deltaToMarkdown(deltas);
|
|
2373
|
+
return this.renderMarkdown(text);
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
return this.renderPlainText();
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
renderMarkdown(text) {
|
|
2380
|
+
if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2321
2381
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2322
2382
|
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2323
2383
|
text = util/* default.trim */.Z.trim(text);
|
|
@@ -2341,6 +2401,48 @@ class TextMessage extends common/* Com */.up {
|
|
|
2341
2401
|
}
|
|
2342
2402
|
|
|
2343
2403
|
}
|
|
2404
|
+
|
|
2405
|
+
function deltaToMarkdown(deltas) {
|
|
2406
|
+
let output = '';
|
|
2407
|
+
util/* default.each */.Z.each(deltas, (delta, idx) => {
|
|
2408
|
+
let text = '';
|
|
2409
|
+
let insert = delta.insert;
|
|
2410
|
+
let attributes = delta.attributes;
|
|
2411
|
+
if (insert.emoji) text = emojiCodes[insert.emoji] || '';
|
|
2412
|
+
|
|
2413
|
+
if (attributes) {
|
|
2414
|
+
if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
if (insert.dynamicField) text = `${util/* default.get */.Z.get(insert, 'dynamicField.text', '')}`;
|
|
2418
|
+
|
|
2419
|
+
if (!insert.emoji && !attributes && !insert.dynamicField) {
|
|
2420
|
+
text = insert || '';
|
|
2421
|
+
text = text.replace(/\n/g, '<br/>');
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
output += text;
|
|
2425
|
+
});
|
|
2426
|
+
return output;
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
const emojiCodes = {
|
|
2430
|
+
like: '👍',
|
|
2431
|
+
unlike: '👎',
|
|
2432
|
+
angry: '😠',
|
|
2433
|
+
confused: '😕',
|
|
2434
|
+
crying: '😢',
|
|
2435
|
+
grinning: '😀',
|
|
2436
|
+
'heart-eyes': '😍',
|
|
2437
|
+
neutral: '😐',
|
|
2438
|
+
sleepy: '😪',
|
|
2439
|
+
sad: '😞',
|
|
2440
|
+
smiling: '😄',
|
|
2441
|
+
'tongue-out': '😛',
|
|
2442
|
+
tired: '😩',
|
|
2443
|
+
surprised: '😮',
|
|
2444
|
+
wink: '😉'
|
|
2445
|
+
};
|
|
2344
2446
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2345
2447
|
|
|
2346
2448
|
var g_pub = new util/* default.Pubsub */.Z.Pubsub();
|
|
@@ -2679,7 +2781,8 @@ class Event extends common/* Com */.up {
|
|
|
2679
2781
|
ev: ev
|
|
2680
2782
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2681
2783
|
store: this.props.store,
|
|
2682
|
-
ev: ev
|
|
2784
|
+
ev: ev,
|
|
2785
|
+
t: this.props.t
|
|
2683
2786
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2684
2787
|
store: this.props.store,
|
|
2685
2788
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -2693,9 +2796,11 @@ class Event extends common/* Com */.up {
|
|
|
2693
2796
|
}), (0,preact_module.h)(GenericTemplateAttachments, {
|
|
2694
2797
|
store: this.props.store,
|
|
2695
2798
|
ev: ev,
|
|
2696
|
-
onSelect: e => this.choosePostbackBtn(e)
|
|
2799
|
+
onSelect: e => this.choosePostbackBtn(e),
|
|
2800
|
+
t: this.props.t
|
|
2697
2801
|
}), (0,preact_module.h)(ProductAttachments, {
|
|
2698
2802
|
t: this.props.t,
|
|
2803
|
+
onPostback: e => this.choosePostbackBtn(e),
|
|
2699
2804
|
store: this.props.store,
|
|
2700
2805
|
ev: ev
|
|
2701
2806
|
}), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
|
|
@@ -2767,7 +2872,8 @@ class Event extends common/* Com */.up {
|
|
|
2767
2872
|
ev: ev
|
|
2768
2873
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2769
2874
|
store: this.props.store,
|
|
2770
|
-
ev: ev
|
|
2875
|
+
ev: ev,
|
|
2876
|
+
t: this.props.t
|
|
2771
2877
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2772
2878
|
store: this.props.store,
|
|
2773
2879
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -3149,6 +3255,8 @@ class Typing extends common/* Com */.up {
|
|
|
3149
3255
|
return;
|
|
3150
3256
|
}
|
|
3151
3257
|
|
|
3258
|
+
let ag = this.props.store.matchAgent(ev.by.id) || {};
|
|
3259
|
+
if (ag.type == 'agent') return;
|
|
3152
3260
|
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3153
3261
|
this.setState({
|
|
3154
3262
|
ev: ev,
|
|
@@ -3161,7 +3269,7 @@ class Typing extends common/* Com */.up {
|
|
|
3161
3269
|
this.setState({
|
|
3162
3270
|
isShow: false
|
|
3163
3271
|
});
|
|
3164
|
-
},
|
|
3272
|
+
}, 5000);
|
|
3165
3273
|
});
|
|
3166
3274
|
}
|
|
3167
3275
|
|
|
@@ -4061,6 +4169,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4061
4169
|
loading: true,
|
|
4062
4170
|
order: {},
|
|
4063
4171
|
err: {},
|
|
4172
|
+
shipping_address: 'new',
|
|
4064
4173
|
selectedProvince: null,
|
|
4065
4174
|
selectedDistrict: null,
|
|
4066
4175
|
selectedWard: null,
|
|
@@ -4353,16 +4462,17 @@ class order_Order extends common/* Com */.up {
|
|
|
4353
4462
|
|
|
4354
4463
|
order_defineProperty(this, "onCancel", () => {
|
|
4355
4464
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4356
|
-
this.close();
|
|
4357
|
-
});
|
|
4358
4465
|
|
|
4359
|
-
order_defineProperty(this, "close", () => {
|
|
4360
4466
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4361
4467
|
let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
|
|
4362
4468
|
order.user_confirmation = 'rejected';
|
|
4363
4469
|
this.props.store.updateOrder(order);
|
|
4364
4470
|
}
|
|
4365
4471
|
|
|
4472
|
+
this.close();
|
|
4473
|
+
});
|
|
4474
|
+
|
|
4475
|
+
order_defineProperty(this, "close", () => {
|
|
4366
4476
|
if (this.props.onClose) this.props.onClose();
|
|
4367
4477
|
});
|
|
4368
4478
|
|
|
@@ -4432,7 +4542,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4432
4542
|
return null;
|
|
4433
4543
|
let editmode = false;
|
|
4434
4544
|
|
|
4435
|
-
if (!order.status || order.status == '
|
|
4545
|
+
if (!order.status || order.status == 'open') {
|
|
4436
4546
|
editmode = !order.user_confirmation;
|
|
4437
4547
|
}
|
|
4438
4548
|
|
|
@@ -4523,7 +4633,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4523
4633
|
renderDesktopShipping(order) {
|
|
4524
4634
|
let editmode = false;
|
|
4525
4635
|
|
|
4526
|
-
if (!order.status || order.status == '
|
|
4636
|
+
if (!order.status || order.status == 'open') {
|
|
4527
4637
|
editmode = !order.user_confirmation;
|
|
4528
4638
|
}
|
|
4529
4639
|
|
|
@@ -4824,7 +4934,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4824
4934
|
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default.get */.Z.get(order, 'shipping.fee', 0), " d"));
|
|
4825
4935
|
let editmode = false;
|
|
4826
4936
|
|
|
4827
|
-
if (!order.status || order.status == '
|
|
4937
|
+
if (!order.status || order.status == 'open') {
|
|
4828
4938
|
editmode = !order.user_confirmation;
|
|
4829
4939
|
}
|
|
4830
4940
|
|
|
@@ -4860,7 +4970,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4860
4970
|
}
|
|
4861
4971
|
|
|
4862
4972
|
renderStatusBadge(order) {
|
|
4863
|
-
let status = order.status || '
|
|
4973
|
+
let status = order.status || 'open';
|
|
4864
4974
|
return (0,preact_module.h)("div", {
|
|
4865
4975
|
style: "float: right !important;",
|
|
4866
4976
|
class: 'order_status order_status__' + status
|
|
@@ -4868,7 +4978,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4868
4978
|
}
|
|
4869
4979
|
|
|
4870
4980
|
renderShippingInfo(order) {
|
|
4871
|
-
if (order.status != '
|
|
4981
|
+
if (order.status != 'open' || order.user_confirmation) {}
|
|
4872
4982
|
|
|
4873
4983
|
let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
|
|
4874
4984
|
if (!shipping_provider) return null;
|
|
@@ -4968,7 +5078,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4968
5078
|
let $products = null;
|
|
4969
5079
|
let editmode = false;
|
|
4970
5080
|
|
|
4971
|
-
if (!order.status || order.status == '
|
|
5081
|
+
if (!order.status || order.status == 'open') {
|
|
4972
5082
|
editmode = !order.user_confirmation;
|
|
4973
5083
|
}
|
|
4974
5084
|
|
|
@@ -5072,7 +5182,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5072
5182
|
onClick: this.onCancel
|
|
5073
5183
|
}, this.props.t('cancel_order'));
|
|
5074
5184
|
|
|
5075
|
-
if (order.user_confirmation || order.status != '
|
|
5185
|
+
if (order.user_confirmation || order.status != 'open') {
|
|
5076
5186
|
$status = null;
|
|
5077
5187
|
if (this.props.cid) $close = (0,preact_module.h)("div", {
|
|
5078
5188
|
class: "order_btn order__btn__light mt-3",
|
|
@@ -5104,7 +5214,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5104
5214
|
let $actions = null;
|
|
5105
5215
|
let editmode = false;
|
|
5106
5216
|
|
|
5107
|
-
if (!order.status || order.status == '
|
|
5217
|
+
if (!order.status || order.status == 'open') {
|
|
5108
5218
|
editmode = !order.user_confirmation;
|
|
5109
5219
|
}
|
|
5110
5220
|
|
|
@@ -5644,17 +5754,23 @@ class Widget extends common/* Com */.up {
|
|
|
5644
5754
|
if (hasError) return this.forceUpdate();
|
|
5645
5755
|
let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
5646
5756
|
let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
|
|
5757
|
+
let is_lead = false;
|
|
5647
5758
|
util/* default.map */.Z.map(data, (field, key) => {
|
|
5648
5759
|
if (!key.startsWith('attr:')) return;
|
|
5649
5760
|
var attr = {
|
|
5650
5761
|
key: key.substr(5)
|
|
5651
5762
|
};
|
|
5763
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
5652
5764
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
5653
5765
|
if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
|
|
5654
5766
|
if (field.type === 'list') attr.list = field.value;
|
|
5655
5767
|
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
5656
5768
|
util/* default.setUserAttr */.Z.setUserAttr(user, attr);
|
|
5657
5769
|
});
|
|
5770
|
+
if (is_lead) util/* default.setUserAttr */.Z.setUserAttr(user, {
|
|
5771
|
+
key: 'lead_source',
|
|
5772
|
+
text: 'widget'
|
|
5773
|
+
});
|
|
5658
5774
|
let firstmsg = util/* default.get */.Z.get(data, 'question.value');
|
|
5659
5775
|
let groupid = util/* default.get */.Z.get(data, 'group.value', '');
|
|
5660
5776
|
|
|
@@ -5693,11 +5809,11 @@ class Widget extends common/* Com */.up {
|
|
|
5693
5809
|
this.setState({
|
|
5694
5810
|
creatingError: null
|
|
5695
5811
|
});
|
|
5812
|
+
await this.props.store.setUser(user);
|
|
5696
5813
|
const {
|
|
5697
5814
|
error,
|
|
5698
5815
|
convo
|
|
5699
5816
|
} = await this.props.store.startConvo(req);
|
|
5700
|
-
this.props.store.setUser(user);
|
|
5701
5817
|
|
|
5702
5818
|
if (error) {
|
|
5703
5819
|
this.setState({
|
|
@@ -6563,11 +6679,13 @@ class Main extends common/* Com */.up {
|
|
|
6563
6679
|
}
|
|
6564
6680
|
|
|
6565
6681
|
function restoreViewport() {
|
|
6682
|
+
if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
|
|
6566
6683
|
let metatag = document.getElementById('subiz-meta-viewport');
|
|
6567
6684
|
if (metatag) metatag.remove();
|
|
6568
6685
|
}
|
|
6569
6686
|
|
|
6570
6687
|
function modifyViewport() {
|
|
6688
|
+
if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
|
|
6571
6689
|
let metatag = document.createElement('meta');
|
|
6572
6690
|
metatag.httpEquiv = 'X-UA-Compatible';
|
|
6573
6691
|
metatag.name = 'viewport';
|