@chat21/chat21-web-widget 5.0.46-rc.4 → 5.0.47-rc.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.0.46-rc.4",
4
+ "version": "5.0.47-rc.1",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -679,7 +679,9 @@ chat-root {
679
679
  .c21-title {
680
680
  position: absolute;
681
681
  left: 0;
682
- display: inline-block;
682
+ // display: inline-block;
683
+ display: flex;
684
+ align-items: center;
683
685
  width: calc(100% - 200px);
684
686
  height: 1.6em;
685
687
  line-height: 1.6em;
@@ -602,7 +602,10 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
602
602
  this.logger.debug('[APP-COMP] ============ idConversation ===============', recipientId, this.g.recipientId);
603
603
  // this.g.recipientId = null;
604
604
  this.logger.debug('[APP-COMP] singleConversation conv da ...', this.g.recipientId)
605
- if(this.g.recipientId && this.g.singleConversation){
605
+ if(this.g.restartConversation && this.g.singleConversation){
606
+ this.logger.debug('[APP-COMP] RESTART-CONVERSARION::: start a new conversations...', this.g.restartConversation)
607
+ this.onNewConversation();
608
+ }else if(this.g.recipientId && this.g.singleConversation){
606
609
  //start widget from current recipientId conversation
607
610
  this.logger.debug('[APP-COMP] singleConversation conv da API', this.g.recipientId)
608
611
  this.isOpenHome = false;
@@ -781,6 +784,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
781
784
  if (location.href) {
782
785
  attributes['sourcePage'] = location.href;
783
786
  }
787
+ if(document.title){
788
+ attributes['sourceTitle'] = document.title;
789
+ }
784
790
  if (projectid) {
785
791
  attributes['projectId'] = projectid;
786
792
  }
@@ -38,7 +38,8 @@
38
38
  position: absolute;
39
39
  left: 50px;
40
40
  right: 100px;
41
- display: inline-block;
41
+ display: flex;
42
+ align-items: center;
42
43
  width: auto;
43
44
  height: 42px;
44
45
  padding: 0px;
@@ -25,7 +25,8 @@
25
25
  position: absolute;
26
26
  left: 50px;
27
27
  right: 100px;
28
- display: inline-block;
28
+ display: flex;
29
+ align-items: center;
29
30
  width: auto;
30
31
  height: 42px;
31
32
  padding: 0px;
@@ -16,7 +16,8 @@
16
16
  position: absolute;
17
17
  left: 50px;
18
18
  right: 100px;
19
- display: inline-block;
19
+ display: flex;
20
+ align-items: center;
20
21
  width: auto;
21
22
  height: 42px;
22
23
  padding: 0px;
@@ -27,7 +27,8 @@
27
27
  position: absolute;
28
28
  left: 50px;
29
29
  right: 100px;
30
- display: inline-block;
30
+ display: flex;
31
+ align-items: center;
31
32
  width: auto;
32
33
  height: 42px;
33
34
  padding: 0px;
@@ -9,6 +9,7 @@
9
9
  background-position: center;
10
10
  background-size: cover;
11
11
  overflow-x: hidden;
12
+ overflow-y: hidden;
12
13
  }
13
14
  .c21-ico-schedule {
14
15
  background-image: url("../../../../assets/images/f21ico-schedule.svg");
@@ -44,7 +44,8 @@
44
44
  position: absolute;
45
45
  left: 45px;
46
46
  right: 45px;
47
- display: inline-block;
47
+ display: flex;
48
+ align-items: center;
48
49
  width: auto;
49
50
  height: 1.6em;
50
51
  line-height: 1.6em;
@@ -962,6 +962,11 @@ export class GlobalSettingsService {
962
962
  if (TEMP !== undefined) {
963
963
  globals.singleConversation = (TEMP === true) ? true : false;
964
964
  }
965
+ TEMP = tiledeskSettings['restartConversation'];
966
+ // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > continueConversationBeforeTime:: ', TEMP]);
967
+ if (TEMP !== undefined) {
968
+ globals.restartConversation = (TEMP === true) ? true : false;
969
+ }
965
970
  TEMP = tiledeskSettings['nativeRating'];
966
971
  // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > nativeRating:: ', TEMP]);
967
972
  if (TEMP !== undefined) {
@@ -1226,6 +1231,10 @@ export class GlobalSettingsService {
1226
1231
  if (TEMP !== null) {
1227
1232
  this.globals.singleConversation = (TEMP === true) ? true : false;
1228
1233
  }
1234
+ TEMP = el.nativeElement.getAttribute('restartConversation');
1235
+ if (TEMP !== null) {
1236
+ this.globals.restartConversation = (TEMP === true) ? true : false;;
1237
+ }
1229
1238
  TEMP = el.nativeElement.getAttribute('nativeRating');
1230
1239
  if (TEMP !== null) {
1231
1240
  this.globals.nativeRating = (TEMP === true) ? true : false;
@@ -1653,6 +1662,11 @@ export class GlobalSettingsService {
1653
1662
  globals.singleConversation = stringToBoolean(TEMP);;
1654
1663
  }
1655
1664
 
1665
+ TEMP = getParameterByName(windowContext, 'tiledesk_restartConversation');
1666
+ if (TEMP) {
1667
+ globals.restartConversation = TEMP;
1668
+ }
1669
+
1656
1670
  TEMP = getParameterByName(windowContext, 'tiledesk_nativeRating');
1657
1671
  if (TEMP) {
1658
1672
  globals.nativeRating = stringToBoolean(TEMP);
@@ -210,6 +210,7 @@ export class Globals {
210
210
  buttonHoverBackgroundColor: string // ******* new ********
211
211
  buttonHoverTextColor: string // ******* new ********
212
212
  singleConversation: boolean; // ******* new ********
213
+ restartConversation: boolean; // ******* new ********
213
214
  nativeRating: boolean; // ******* new ********
214
215
  showInfoMessage: Array<string>; // ******* new ********
215
216
  typingLocation: string; // ******* new ********
@@ -377,6 +378,8 @@ export class Globals {
377
378
  /** set the text size of attachment-buttons */
378
379
  this.singleConversation = false;
379
380
  /** set the single conversation mode for the widget */
381
+ this.restartConversation = true;
382
+ /** allow you to always restart a new converazioe */
380
383
  this.nativeRating = true;
381
384
  /** set if native rating componet has to be shown */
382
385
  this.showInfoMessage = 'MEMBER_JOINED_GROUP'.split(',').map(key => { return key.trim()});
@@ -538,6 +541,7 @@ export class Globals {
538
541
  'preChatForm': this.preChatForm, 'preChatFormJson': this.preChatFormJson,
539
542
  'projectid': this.projectid,
540
543
  'recipientId': this.recipientId,
544
+ 'restartConversation': this.restartConversation,
541
545
  'singleConversation': this.singleConversation,
542
546
  'showInfoMessage': this.showInfoMessage, 'showAllConversations': this.showAllConversations,
543
547
  'showWaitTime': this.showWaitTime, 'showAvailableAgents': this.showAvailableAgents,
@@ -550,7 +554,6 @@ export class Globals {
550
554
  'userEmail': this.userEmail, 'userFullname': this.userFullname,
551
555
  'widgetTitle': this.widgetTitle,
552
556
  'welcomeMsg': this.welcomeMsg, 'welcomeTitle': this.welcomeTitle,
553
-
554
557
  };
555
558
  }
556
559
 
@@ -801,6 +801,13 @@
801
801
  window.Tiledesk('restart')
802
802
  }
803
803
 
804
+ function onClickRestartConversation(){
805
+ let status = document.querySelector('input[name="restartConversation"]:checked').value
806
+ window.tiledeskSettings['restart'] = stringToBoolean(status)
807
+ console.log('onClickRestartConversation: status-->',window.tiledeskSettings);
808
+ window.Tiledesk('restart')
809
+ }
810
+
804
811
  function onClickHideSettings(){
805
812
  let status = document.querySelector('input[name="hideSettings"]:checked').value
806
813
  window.tiledeskSettings['hideSettings'] = stringToBoolean(status)
@@ -1694,6 +1701,17 @@
1694
1701
  <button class="btn btn-light" onclick="onClickSingleConversation()">Test this setting <i class="fa fa-magic" aria-hidden="true"></i></button>
1695
1702
  </div>
1696
1703
  </div>
1704
+ <div class="row">
1705
+ <div class="col-md-5 formElement"><span><em><strong>restartConversation</strong></em></span></div>
1706
+ <div class="col-md-5">
1707
+ <input class="form-check-input" type="radio" name="restartConversation" value="true"><label>True</label>
1708
+ <input class="form-check-input" type="radio" name="restartConversation" value="false" checked><label>False</label>
1709
+ </div>
1710
+ <div class="col-md-2">
1711
+ <button class="btn btn-light" onclick="onClickRestartConversation()">Test this setting <i class="fa fa-magic" aria-hidden="true"></i></button>
1712
+ </div>
1713
+ </div>
1714
+
1697
1715
 
1698
1716
  <div class="row">
1699
1717
  <div class="col-md-5 formElement"><span><em><strong>hideSettings</strong></em></span></div>
@@ -272,9 +272,9 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
272
272
  if (index > -1) {
273
273
  this.updateConversationWithSnapshot(this.conversations[index], conversation);
274
274
  this.logger.debug('[MQTTConversationsHandler] conversationchanged.isnew', JSON.stringify(conversation))
275
- this.conversations.sort(compareValues('timestamp', 'desc'));
276
- this.conversations.splice(index, 1, this.conversations[index])
277
275
  this.conversationChanged.next(this.conversations[index]);
276
+ this.conversations.splice(index, 1, this.conversations[index])
277
+ this.conversations.sort(compareValues('timestamp', 'desc'));
278
278
  }
279
279
  }
280
280
 
@@ -282,44 +282,44 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
282
282
  this.logger.debug('[MQTTConversationsHandler] updating conv', conv, 'with snap', snap)
283
283
  Object.keys(snap).forEach(k => {
284
284
  if (k === 'is_new') {
285
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
285
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
286
286
  conv.is_new = snap[k];
287
287
  }
288
288
  if (k === 'text') {
289
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
289
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
290
290
  conv.last_message_text = snap[k];
291
291
  conv.text = snap[k];
292
292
  }
293
293
  if (k === 'recipient') {
294
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
294
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
295
295
  conv.recipient = snap[k];
296
296
  }
297
297
  if (k === 'recipient_fullname') {
298
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
298
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
299
299
  conv.recipient_fullname = snap[k];
300
300
  }
301
301
  if (k === 'sender') {
302
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
302
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
303
303
  conv.sender = snap[k];
304
304
  }
305
305
  if (k === 'sender_fullname') {
306
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
306
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
307
307
  conv.sender_fullname = snap[k];
308
308
  }
309
309
  if (k === 'attributes') {
310
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
310
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
311
311
  conv.attributes = snap[k];
312
312
  }
313
313
  if (k === 'timestamp') {
314
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
314
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
315
315
  conv.timestamp = snap[k];
316
316
  }
317
317
  if (k === 'status') {
318
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
318
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
319
319
  conv.status = this.setStatusConversation(conv.sender, conv.uid);
320
320
  }
321
321
  if (k === 'type') {
322
- this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
322
+ // this.logger.debug('[MQTTConversationsHandler] aggiorno key:' + k);
323
323
  conv.type = snap[k];
324
324
  }
325
325
 
@@ -146,7 +146,8 @@ export function isEmojii(message: any){
146
146
  if(!message) return false;
147
147
  const onlyEmojis = message.replace(new RegExp('[\u0000-\u1eeff]', 'g'), '')
148
148
  const visibleChars = message.replace(new RegExp('[\n\r\s]+|( )+', 'g'), '')
149
- if(onlyEmojis === '' || visibleChars == '') return false
149
+ const chineseChars = message.replace(new RegExp('[\u4e00-\u9fa5]', 'g'), '')
150
+ if(onlyEmojis === '' || visibleChars == '' || chineseChars=='') return false
150
151
  return (onlyEmojis.length === visibleChars.length && onlyEmojis.length <= 2)
151
152
  } catch(e) {
152
153
  return false
package/src/launch.js CHANGED
@@ -161,6 +161,7 @@ function loadIframe(tiledeskScriptBaseLocation) {
161
161
  });
162
162
  /**** END EVENST ****/
163
163
 
164
+ // ifrm.srcdoc = srcTileDesk
164
165
  iDiv.appendChild(ifrm);
165
166
  ifrm.contentWindow.document.open();
166
167
  ifrm.contentWindow.document.write(srcTileDesk);