@subiz/widget-v4 4.0.81 → 4.0.85
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/ShadowDomRoot.js +1 -2
- package/compiled_src/chatbox/TextMessage.js +66 -3
- 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 +1 -1
- package/dist/132.js +152 -36
- package/dist/178.js +174 -341
- package/dist/181a9b734bb.132.js +1 -0
- package/dist/181a9b734bb.178.js +1 -0
- package/dist/{17f00e48d38.213.js → 181a9b734bb.213.js} +1 -1
- package/dist/{17f00e48d38.335.js → 181a9b734bb.335.js} +1 -1
- package/dist/181a9b734bb.362.js +1 -0
- package/dist/181a9b734bb.441.js +1 -0
- package/dist/{17f00e48d38.605.js → 181a9b734bb.605.js} +0 -0
- package/dist/181a9b734bb.678.js +1 -0
- package/dist/181a9b734bb.782.js +1 -0
- package/dist/181a9b734bb.app.js +1 -0
- package/dist/{17f00e48d38.index.html → 181a9b734bb.index.html} +7 -3
- package/dist/{17f00e48d38.library.html → 181a9b734bb.library.html} +7 -3
- package/dist/181a9b734bb.library.js +1 -0
- package/dist/{17f00e48d38.preview.html → 181a9b734bb.preview.html} +1 -1
- package/dist/181a9b734bb.preview.js +1 -0
- package/dist/181a9b734bb.screenshoot.js +1 -0
- package/dist/213.js +10 -0
- package/dist/335.js +2 -2
- package/dist/362.js +21 -71
- package/dist/441.js +138 -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 -131
- package/package.json +14 -14
- package/src/chatbox/ShadowDomRoot.js +1 -2
- package/src/chatbox/TextMessage.js +70 -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 +1 -1
- 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
|
@@ -31,8 +31,7 @@ img { max-width: 100%; display: block; margin: 10px auto; }
|
|
|
31
31
|
* { white-space: normal }
|
|
32
32
|
ul > li { margin-bottom: 5px }
|
|
33
33
|
ul:last-child { margin-bottom: 0 }
|
|
34
|
-
p
|
|
35
|
-
p:last-child { margin-bottom: 0;}
|
|
34
|
+
p { margin-bottom: 0; margin-top: 0;}
|
|
36
35
|
</style>
|
|
37
36
|
<div>${html}</div>`;
|
|
38
37
|
let links = this.shadowRoot.querySelectorAll('a');
|
|
@@ -45,7 +45,11 @@ class TextMessage extends _common.Com {
|
|
|
45
45
|
var format = _index.default.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
46
46
|
|
|
47
47
|
if (format === 'markdown') return this.renderMarkdown();
|
|
48
|
+
if (format === 'delta') return this.renderDelta();
|
|
49
|
+
return this.renderPlainText();
|
|
50
|
+
}
|
|
48
51
|
|
|
52
|
+
renderPlainText() {
|
|
49
53
|
var text = _index.default.get(this.props.ev, 'data.message.text');
|
|
50
54
|
|
|
51
55
|
text = _index.default.trim(text);
|
|
@@ -95,9 +99,24 @@ class TextMessage extends _common.Com {
|
|
|
95
99
|
}, tags);
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
renderDelta() {
|
|
103
|
+
let deltas = _index.default.get(this.props.ev, 'data.message.quill_delta');
|
|
104
|
+
|
|
105
|
+
deltas = _index.default.parseJSON(deltas) || {};
|
|
106
|
+
deltas = deltas.ops || [];
|
|
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') || _index.default.get(delta, 'insert.emoji'));
|
|
109
|
+
|
|
110
|
+
if (isMarkdown) {
|
|
111
|
+
var text = deltaToMarkdown(deltas);
|
|
112
|
+
return this.renderMarkdown(text);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return this.renderPlainText();
|
|
116
|
+
}
|
|
100
117
|
|
|
118
|
+
renderMarkdown(text) {
|
|
119
|
+
if (!text) text = _index.default.get(this.props.ev, 'data.message.text');
|
|
101
120
|
if (_index.default.size(text) === 0) return null;
|
|
102
121
|
|
|
103
122
|
let byType = _index.default.get(this.props.ev, 'by.type');
|
|
@@ -124,4 +143,48 @@ class TextMessage extends _common.Com {
|
|
|
124
143
|
|
|
125
144
|
}
|
|
126
145
|
|
|
127
|
-
exports.default = TextMessage;
|
|
146
|
+
exports.default = TextMessage;
|
|
147
|
+
|
|
148
|
+
function deltaToMarkdown(deltas) {
|
|
149
|
+
let output = '';
|
|
150
|
+
|
|
151
|
+
_index.default.each(deltas, (delta, idx) => {
|
|
152
|
+
let text = '';
|
|
153
|
+
let insert = delta.insert;
|
|
154
|
+
let attributes = delta.attributes;
|
|
155
|
+
if (insert.emoji) text = emojiCodes[insert.emoji] || '';
|
|
156
|
+
|
|
157
|
+
if (attributes) {
|
|
158
|
+
if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (insert.dynamicField) text = `${_index.default.get(insert, 'dynamicField.text', '')}`;
|
|
162
|
+
|
|
163
|
+
if (!insert.emoji && !attributes && !insert.dynamicField) {
|
|
164
|
+
text = insert || '';
|
|
165
|
+
text = text.replace(/\n/g, '<br/>');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
output += text;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return output;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const emojiCodes = {
|
|
175
|
+
like: '👍',
|
|
176
|
+
unlike: '👎',
|
|
177
|
+
angry: '😠',
|
|
178
|
+
confused: '😕',
|
|
179
|
+
crying: '😢',
|
|
180
|
+
grinning: '😀',
|
|
181
|
+
'heart-eyes': '😍',
|
|
182
|
+
neutral: '😐',
|
|
183
|
+
sleepy: '😪',
|
|
184
|
+
sad: '😞',
|
|
185
|
+
smiling: '😄',
|
|
186
|
+
'tongue-out': '😛',
|
|
187
|
+
tired: '😩',
|
|
188
|
+
surprised: '😮',
|
|
189
|
+
wink: '😉'
|
|
190
|
+
};
|
|
@@ -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
|
}
|
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
|
});
|
|
@@ -1295,7 +1296,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1295
1296
|
href: 'tel:' + button.phone_number,
|
|
1296
1297
|
key: index,
|
|
1297
1298
|
title: button.title
|
|
1298
|
-
}, button.title);
|
|
1299
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1299
1300
|
}
|
|
1300
1301
|
|
|
1301
1302
|
if (button.type === 'url_button') {
|
|
@@ -1305,7 +1306,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1305
1306
|
target: "_blank",
|
|
1306
1307
|
key: index,
|
|
1307
1308
|
title: button.title
|
|
1308
|
-
}, button.title || button.url);
|
|
1309
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || button.url);
|
|
1309
1310
|
}
|
|
1310
1311
|
|
|
1311
1312
|
if (button.type === 'postback_button') {
|
|
@@ -1313,7 +1314,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1313
1314
|
class: "url-button-attachment",
|
|
1314
1315
|
href: "javascript:;",
|
|
1315
1316
|
onClick: _ => this.props.onSelect(button)
|
|
1316
|
-
}, button.title);
|
|
1317
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1317
1318
|
}
|
|
1318
1319
|
|
|
1319
1320
|
if (button.type === 'widget_ask_desktop_notify_button') return null;
|
|
@@ -1347,7 +1348,8 @@ class ButtonAttachments extends common/* Com */.up {
|
|
|
1347
1348
|
});
|
|
1348
1349
|
return (0,preact_module.h)(Buttons, {
|
|
1349
1350
|
store: this.props.store,
|
|
1350
|
-
buttons: buttons
|
|
1351
|
+
buttons: buttons,
|
|
1352
|
+
t: this.props.t
|
|
1351
1353
|
});
|
|
1352
1354
|
}
|
|
1353
1355
|
|
|
@@ -1956,7 +1958,10 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1956
1958
|
this.setState({
|
|
1957
1959
|
focusing: eleindex
|
|
1958
1960
|
});
|
|
1959
|
-
this.galleryRef.current.
|
|
1961
|
+
this.galleryRef.current.scrollTo({
|
|
1962
|
+
left: 220 * eleindex,
|
|
1963
|
+
behavior: 'smooth'
|
|
1964
|
+
});
|
|
1960
1965
|
}
|
|
1961
1966
|
|
|
1962
1967
|
render() {
|
|
@@ -1967,21 +1972,26 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1967
1972
|
if (generics.length === 0) return null;
|
|
1968
1973
|
var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
|
|
1969
1974
|
var $eles = util/* default.map */.Z.map(gen.elements, ele => {
|
|
1970
|
-
let
|
|
1975
|
+
let title = this.props.t.i18n(ele.i18n_title) || ele.title;
|
|
1976
|
+
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
|
|
1977
|
+
let $title = title ? (0,preact_module.h)("div", {
|
|
1971
1978
|
class: "generic-attachment--element-title"
|
|
1972
|
-
},
|
|
1973
|
-
let $subtitle =
|
|
1979
|
+
}, title) : null;
|
|
1980
|
+
let $subtitle = subtitle ? (0,preact_module.h)("div", {
|
|
1974
1981
|
class: "generic-attachment--element-subtitle"
|
|
1975
|
-
},
|
|
1982
|
+
}, subtitle) : null;
|
|
1976
1983
|
return (0,preact_module.h)("div", {
|
|
1977
1984
|
class: "generic-attachment--element swiper-slide"
|
|
1978
1985
|
}, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
|
|
1979
1986
|
alt: "generic attachment element",
|
|
1980
1987
|
class: "generic-attachment--element-img",
|
|
1981
1988
|
src: this.props.store.replaceFileUrl(ele.image_url)
|
|
1982
|
-
})),
|
|
1989
|
+
})), (0,preact_module.h)("div", {
|
|
1990
|
+
class: "generic-attachment--element-content"
|
|
1991
|
+
}, $title, $subtitle), (0,preact_module.h)(Buttons, {
|
|
1983
1992
|
buttons: ele.buttons,
|
|
1984
|
-
onSelect: button => this.props.onSelect(button)
|
|
1993
|
+
onSelect: button => this.props.onSelect(button),
|
|
1994
|
+
t: this.props.t
|
|
1985
1995
|
}));
|
|
1986
1996
|
});
|
|
1987
1997
|
let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
|
|
@@ -2031,17 +2041,53 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2031
2041
|
let acc = this.props.store.matchAccount();
|
|
2032
2042
|
let $products = util/* default.map */.Z.map(products, (att, index) => {
|
|
2033
2043
|
let product = att.product;
|
|
2034
|
-
let $
|
|
2044
|
+
let $detailbtns = [];
|
|
2035
2045
|
let url = product.url || product.mobile_url;
|
|
2036
2046
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
2037
|
-
if (url)
|
|
2047
|
+
if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
|
|
2038
2048
|
class: "product_attachment__btn",
|
|
2039
2049
|
href: url,
|
|
2040
2050
|
target: "_blank"
|
|
2041
2051
|
}, this.props.t('detail'), (0,preact_module.h)("img", {
|
|
2042
2052
|
src: __webpack_require__(8453),
|
|
2043
2053
|
class: "product_attachment__btn_external_link"
|
|
2044
|
-
}));
|
|
2054
|
+
})));
|
|
2055
|
+
console.log('P', product);
|
|
2056
|
+
|
|
2057
|
+
if (util/* default.size */.Z.size(product.buttons) > 0) {
|
|
2058
|
+
$detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
|
|
2059
|
+
if (button.type === 'call_button') {
|
|
2060
|
+
return (0,preact_module.h)("a", {
|
|
2061
|
+
class: "product_attachment__btn",
|
|
2062
|
+
href: 'tel:' + button.phone_number,
|
|
2063
|
+
key: index,
|
|
2064
|
+
title: button.title
|
|
2065
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
if (button.type === 'url_button') {
|
|
2069
|
+
return (0,preact_module.h)("a", {
|
|
2070
|
+
class: "product_attachment__btn",
|
|
2071
|
+
href: button.url,
|
|
2072
|
+
target: "_blank",
|
|
2073
|
+
key: index,
|
|
2074
|
+
title: button.title
|
|
2075
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
|
|
2076
|
+
src: __webpack_require__(8453),
|
|
2077
|
+
class: "product_attachment__btn_external_link"
|
|
2078
|
+
}));
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
if (button.type === 'postback_button') {
|
|
2082
|
+
return (0,preact_module.h)("a", {
|
|
2083
|
+
class: "product_attachment__btn",
|
|
2084
|
+
href: "javascript:;",
|
|
2085
|
+
onClick: _ => this.props.onPostback(button)
|
|
2086
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2087
|
+
}
|
|
2088
|
+
}));
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2045
2091
|
let $title = (0,preact_module.h)("a", {
|
|
2046
2092
|
href: url,
|
|
2047
2093
|
class: "product_attachment__title",
|
|
@@ -2070,7 +2116,7 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2070
2116
|
src: this.props.store.replaceFileUrl(product.image)
|
|
2071
2117
|
}))), $title, $subtitle, $price, (0,preact_module.h)("div", {
|
|
2072
2118
|
class: "product_attachment__btns"
|
|
2073
|
-
}, $
|
|
2119
|
+
}, $detailbtns));
|
|
2074
2120
|
});
|
|
2075
2121
|
return $products;
|
|
2076
2122
|
}
|
|
@@ -2226,8 +2272,7 @@ img { max-width: 100%; display: block; margin: 10px auto; }
|
|
|
2226
2272
|
* { white-space: normal }
|
|
2227
2273
|
ul > li { margin-bottom: 5px }
|
|
2228
2274
|
ul:last-child { margin-bottom: 0 }
|
|
2229
|
-
p
|
|
2230
|
-
p:last-child { margin-bottom: 0;}
|
|
2275
|
+
p { margin-bottom: 0; margin-top: 0;}
|
|
2231
2276
|
</style>
|
|
2232
2277
|
<div>${html}</div>`;
|
|
2233
2278
|
let links = this.shadowRoot.querySelectorAll('a');
|
|
@@ -2271,6 +2316,11 @@ class TextMessage extends common/* Com */.up {
|
|
|
2271
2316
|
render() {
|
|
2272
2317
|
var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2273
2318
|
if (format === 'markdown') return this.renderMarkdown();
|
|
2319
|
+
if (format === 'delta') return this.renderDelta();
|
|
2320
|
+
return this.renderPlainText();
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
renderPlainText() {
|
|
2274
2324
|
var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2275
2325
|
text = util/* default.trim */.Z.trim(text);
|
|
2276
2326
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
@@ -2316,8 +2366,22 @@ class TextMessage extends common/* Com */.up {
|
|
|
2316
2366
|
}, tags);
|
|
2317
2367
|
}
|
|
2318
2368
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2369
|
+
renderDelta() {
|
|
2370
|
+
let deltas = util/* default.get */.Z.get(this.props.ev, 'data.message.quill_delta');
|
|
2371
|
+
deltas = util/* default.parseJSON */.Z.parseJSON(deltas) || {};
|
|
2372
|
+
deltas = deltas.ops || [];
|
|
2373
|
+
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'));
|
|
2374
|
+
|
|
2375
|
+
if (isMarkdown) {
|
|
2376
|
+
var text = deltaToMarkdown(deltas);
|
|
2377
|
+
return this.renderMarkdown(text);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
return this.renderPlainText();
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
renderMarkdown(text) {
|
|
2384
|
+
if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2321
2385
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2322
2386
|
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2323
2387
|
text = util/* default.trim */.Z.trim(text);
|
|
@@ -2341,6 +2405,48 @@ class TextMessage extends common/* Com */.up {
|
|
|
2341
2405
|
}
|
|
2342
2406
|
|
|
2343
2407
|
}
|
|
2408
|
+
|
|
2409
|
+
function deltaToMarkdown(deltas) {
|
|
2410
|
+
let output = '';
|
|
2411
|
+
util/* default.each */.Z.each(deltas, (delta, idx) => {
|
|
2412
|
+
let text = '';
|
|
2413
|
+
let insert = delta.insert;
|
|
2414
|
+
let attributes = delta.attributes;
|
|
2415
|
+
if (insert.emoji) text = emojiCodes[insert.emoji] || '';
|
|
2416
|
+
|
|
2417
|
+
if (attributes) {
|
|
2418
|
+
if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
if (insert.dynamicField) text = `${util/* default.get */.Z.get(insert, 'dynamicField.text', '')}`;
|
|
2422
|
+
|
|
2423
|
+
if (!insert.emoji && !attributes && !insert.dynamicField) {
|
|
2424
|
+
text = insert || '';
|
|
2425
|
+
text = text.replace(/\n/g, '<br/>');
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
output += text;
|
|
2429
|
+
});
|
|
2430
|
+
return output;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
const emojiCodes = {
|
|
2434
|
+
like: '👍',
|
|
2435
|
+
unlike: '👎',
|
|
2436
|
+
angry: '😠',
|
|
2437
|
+
confused: '😕',
|
|
2438
|
+
crying: '😢',
|
|
2439
|
+
grinning: '😀',
|
|
2440
|
+
'heart-eyes': '😍',
|
|
2441
|
+
neutral: '😐',
|
|
2442
|
+
sleepy: '😪',
|
|
2443
|
+
sad: '😞',
|
|
2444
|
+
smiling: '😄',
|
|
2445
|
+
'tongue-out': '😛',
|
|
2446
|
+
tired: '😩',
|
|
2447
|
+
surprised: '😮',
|
|
2448
|
+
wink: '😉'
|
|
2449
|
+
};
|
|
2344
2450
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2345
2451
|
|
|
2346
2452
|
var g_pub = new util/* default.Pubsub */.Z.Pubsub();
|
|
@@ -2679,7 +2785,8 @@ class Event extends common/* Com */.up {
|
|
|
2679
2785
|
ev: ev
|
|
2680
2786
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2681
2787
|
store: this.props.store,
|
|
2682
|
-
ev: ev
|
|
2788
|
+
ev: ev,
|
|
2789
|
+
t: this.props.t
|
|
2683
2790
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2684
2791
|
store: this.props.store,
|
|
2685
2792
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -2693,9 +2800,11 @@ class Event extends common/* Com */.up {
|
|
|
2693
2800
|
}), (0,preact_module.h)(GenericTemplateAttachments, {
|
|
2694
2801
|
store: this.props.store,
|
|
2695
2802
|
ev: ev,
|
|
2696
|
-
onSelect: e => this.choosePostbackBtn(e)
|
|
2803
|
+
onSelect: e => this.choosePostbackBtn(e),
|
|
2804
|
+
t: this.props.t
|
|
2697
2805
|
}), (0,preact_module.h)(ProductAttachments, {
|
|
2698
2806
|
t: this.props.t,
|
|
2807
|
+
onPostback: e => this.choosePostbackBtn(e),
|
|
2699
2808
|
store: this.props.store,
|
|
2700
2809
|
ev: ev
|
|
2701
2810
|
}), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
|
|
@@ -2767,7 +2876,8 @@ class Event extends common/* Com */.up {
|
|
|
2767
2876
|
ev: ev
|
|
2768
2877
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2769
2878
|
store: this.props.store,
|
|
2770
|
-
ev: ev
|
|
2879
|
+
ev: ev,
|
|
2880
|
+
t: this.props.t
|
|
2771
2881
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2772
2882
|
store: this.props.store,
|
|
2773
2883
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -3149,6 +3259,8 @@ class Typing extends common/* Com */.up {
|
|
|
3149
3259
|
return;
|
|
3150
3260
|
}
|
|
3151
3261
|
|
|
3262
|
+
let ag = this.props.store.matchAgent(ev.by.id) || {};
|
|
3263
|
+
if (ag.type == 'agent') return;
|
|
3152
3264
|
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3153
3265
|
this.setState({
|
|
3154
3266
|
ev: ev,
|
|
@@ -3161,7 +3273,7 @@ class Typing extends common/* Com */.up {
|
|
|
3161
3273
|
this.setState({
|
|
3162
3274
|
isShow: false
|
|
3163
3275
|
});
|
|
3164
|
-
},
|
|
3276
|
+
}, 5000);
|
|
3165
3277
|
});
|
|
3166
3278
|
}
|
|
3167
3279
|
|
|
@@ -4061,6 +4173,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4061
4173
|
loading: true,
|
|
4062
4174
|
order: {},
|
|
4063
4175
|
err: {},
|
|
4176
|
+
shipping_address: 'new',
|
|
4064
4177
|
selectedProvince: null,
|
|
4065
4178
|
selectedDistrict: null,
|
|
4066
4179
|
selectedWard: null,
|
|
@@ -4353,16 +4466,17 @@ class order_Order extends common/* Com */.up {
|
|
|
4353
4466
|
|
|
4354
4467
|
order_defineProperty(this, "onCancel", () => {
|
|
4355
4468
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4356
|
-
this.close();
|
|
4357
|
-
});
|
|
4358
4469
|
|
|
4359
|
-
order_defineProperty(this, "close", () => {
|
|
4360
4470
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4361
4471
|
let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
|
|
4362
4472
|
order.user_confirmation = 'rejected';
|
|
4363
4473
|
this.props.store.updateOrder(order);
|
|
4364
4474
|
}
|
|
4365
4475
|
|
|
4476
|
+
this.close();
|
|
4477
|
+
});
|
|
4478
|
+
|
|
4479
|
+
order_defineProperty(this, "close", () => {
|
|
4366
4480
|
if (this.props.onClose) this.props.onClose();
|
|
4367
4481
|
});
|
|
4368
4482
|
|
|
@@ -4432,7 +4546,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4432
4546
|
return null;
|
|
4433
4547
|
let editmode = false;
|
|
4434
4548
|
|
|
4435
|
-
if (!order.status || order.status == '
|
|
4549
|
+
if (!order.status || order.status == 'open') {
|
|
4436
4550
|
editmode = !order.user_confirmation;
|
|
4437
4551
|
}
|
|
4438
4552
|
|
|
@@ -4523,7 +4637,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4523
4637
|
renderDesktopShipping(order) {
|
|
4524
4638
|
let editmode = false;
|
|
4525
4639
|
|
|
4526
|
-
if (!order.status || order.status == '
|
|
4640
|
+
if (!order.status || order.status == 'open') {
|
|
4527
4641
|
editmode = !order.user_confirmation;
|
|
4528
4642
|
}
|
|
4529
4643
|
|
|
@@ -4824,7 +4938,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4824
4938
|
}, (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
4939
|
let editmode = false;
|
|
4826
4940
|
|
|
4827
|
-
if (!order.status || order.status == '
|
|
4941
|
+
if (!order.status || order.status == 'open') {
|
|
4828
4942
|
editmode = !order.user_confirmation;
|
|
4829
4943
|
}
|
|
4830
4944
|
|
|
@@ -4860,7 +4974,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4860
4974
|
}
|
|
4861
4975
|
|
|
4862
4976
|
renderStatusBadge(order) {
|
|
4863
|
-
let status = order.status || '
|
|
4977
|
+
let status = order.status || 'open';
|
|
4864
4978
|
return (0,preact_module.h)("div", {
|
|
4865
4979
|
style: "float: right !important;",
|
|
4866
4980
|
class: 'order_status order_status__' + status
|
|
@@ -4868,7 +4982,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4868
4982
|
}
|
|
4869
4983
|
|
|
4870
4984
|
renderShippingInfo(order) {
|
|
4871
|
-
if (order.status != '
|
|
4985
|
+
if (order.status != 'open' || order.user_confirmation) {}
|
|
4872
4986
|
|
|
4873
4987
|
let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
|
|
4874
4988
|
if (!shipping_provider) return null;
|
|
@@ -4968,7 +5082,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4968
5082
|
let $products = null;
|
|
4969
5083
|
let editmode = false;
|
|
4970
5084
|
|
|
4971
|
-
if (!order.status || order.status == '
|
|
5085
|
+
if (!order.status || order.status == 'open') {
|
|
4972
5086
|
editmode = !order.user_confirmation;
|
|
4973
5087
|
}
|
|
4974
5088
|
|
|
@@ -5072,7 +5186,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5072
5186
|
onClick: this.onCancel
|
|
5073
5187
|
}, this.props.t('cancel_order'));
|
|
5074
5188
|
|
|
5075
|
-
if (order.user_confirmation || order.status != '
|
|
5189
|
+
if (order.user_confirmation || order.status != 'open') {
|
|
5076
5190
|
$status = null;
|
|
5077
5191
|
if (this.props.cid) $close = (0,preact_module.h)("div", {
|
|
5078
5192
|
class: "order_btn order__btn__light mt-3",
|
|
@@ -5104,7 +5218,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5104
5218
|
let $actions = null;
|
|
5105
5219
|
let editmode = false;
|
|
5106
5220
|
|
|
5107
|
-
if (!order.status || order.status == '
|
|
5221
|
+
if (!order.status || order.status == 'open') {
|
|
5108
5222
|
editmode = !order.user_confirmation;
|
|
5109
5223
|
}
|
|
5110
5224
|
|
|
@@ -5693,11 +5807,11 @@ class Widget extends common/* Com */.up {
|
|
|
5693
5807
|
this.setState({
|
|
5694
5808
|
creatingError: null
|
|
5695
5809
|
});
|
|
5810
|
+
await this.props.store.setUser(user);
|
|
5696
5811
|
const {
|
|
5697
5812
|
error,
|
|
5698
5813
|
convo
|
|
5699
5814
|
} = await this.props.store.startConvo(req);
|
|
5700
|
-
this.props.store.setUser(user);
|
|
5701
5815
|
|
|
5702
5816
|
if (error) {
|
|
5703
5817
|
this.setState({
|
|
@@ -6563,11 +6677,13 @@ class Main extends common/* Com */.up {
|
|
|
6563
6677
|
}
|
|
6564
6678
|
|
|
6565
6679
|
function restoreViewport() {
|
|
6680
|
+
if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
|
|
6566
6681
|
let metatag = document.getElementById('subiz-meta-viewport');
|
|
6567
6682
|
if (metatag) metatag.remove();
|
|
6568
6683
|
}
|
|
6569
6684
|
|
|
6570
6685
|
function modifyViewport() {
|
|
6686
|
+
if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
|
|
6571
6687
|
let metatag = document.createElement('meta');
|
|
6572
6688
|
metatag.httpEquiv = 'X-UA-Compatible';
|
|
6573
6689
|
metatag.name = 'viewport';
|