vue-intergrall-plugins 1.1.15 → 1.1.17

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.
Files changed (46) hide show
  1. package/README.md +0 -0
  2. package/dist/vue-intergrall-plugins.esm.js +27 -14
  3. package/dist/vue-intergrall-plugins.min.js +1 -1
  4. package/dist/vue-intergrall-plugins.ssr.js +39 -27
  5. package/package.json +66 -66
  6. package/src/lib-components/Buttons/IconButton.vue +0 -0
  7. package/src/lib-components/Buttons/SimpleButton.vue +0 -0
  8. package/src/lib-components/Cards/Card.vue +0 -0
  9. package/src/lib-components/Cards/CardCheck.vue +0 -0
  10. package/src/lib-components/Cards/CardFile.vue +0 -0
  11. package/src/lib-components/Chat/AudioSpeedControl.vue +0 -0
  12. package/src/lib-components/Chat/BtnDownloadAllFiles.vue +0 -0
  13. package/src/lib-components/Chat/BtnEmojis.vue +0 -0
  14. package/src/lib-components/Chat/BtnExpand.vue +0 -0
  15. package/src/lib-components/Chat/BtnFiles.vue +0 -0
  16. package/src/lib-components/Chat/BtnMic.vue +0 -0
  17. package/src/lib-components/Chat/BtnScreenShare.vue +0 -0
  18. package/src/lib-components/Chat/BtnStandardMessages.vue +0 -0
  19. package/src/lib-components/Chat/ExpandTextarea.vue +0 -0
  20. package/src/lib-components/Chat/MultipleFilePreview.vue +0 -0
  21. package/src/lib-components/Chat/Picker.vue +0 -0
  22. package/src/lib-components/Chat/RemainingCharacters.vue +0 -0
  23. package/src/lib-components/Chat/SingleFilePreview.vue +0 -0
  24. package/src/lib-components/Chat/SkeletonPicker.vue +0 -0
  25. package/src/lib-components/Chat/StandardMessages.vue +0 -0
  26. package/src/lib-components/Chat/TextFooter.vue +0 -0
  27. package/src/lib-components/Email/EmailExpanded.vue +0 -0
  28. package/src/lib-components/Email/EmailFile.vue +0 -0
  29. package/src/lib-components/Email/EmailFrom.vue +0 -0
  30. package/src/lib-components/Email/EmailItem.vue +1017 -1010
  31. package/src/lib-components/Email/EmailTo.vue +8 -1
  32. package/src/lib-components/Loader/Loader.vue +0 -0
  33. package/src/lib-components/Messages/AnexoMensagem.vue +0 -0
  34. package/src/lib-components/Messages/CardAttachment.vue +0 -0
  35. package/src/lib-components/Messages/CardMessages.vue +0 -0
  36. package/src/lib-components/Messages/ChatMessages.vue +0 -0
  37. package/src/lib-components/Messages/InteratividadeBotoes.vue +0 -0
  38. package/src/lib-components/Messages/InteratividadeContato.vue +0 -0
  39. package/src/lib-components/Messages/InteratividadeContatoItem.vue +0 -0
  40. package/src/lib-components/Messages/InteratividadeFormulario.vue +0 -0
  41. package/src/lib-components/Messages/InteratividadePopup.vue +0 -0
  42. package/src/lib-components/Messages/LinkPreview.vue +0 -0
  43. package/src/lib-components/Scroll/ScrollContent.vue +0 -0
  44. package/src/lib-components/Templates/TemplateGenerator.vue +0 -0
  45. package/src/lib-components/Templates/TemplateMessage.vue +0 -0
  46. package/src/lib-components/Templates/TemplateSingle.vue +0 -0
@@ -1,1011 +1,1018 @@
1
- <template>
2
- <div
3
- :class="['email-item box-shadow-active', isOpen ? isOpenClass : `${isClosedClass} cursor-pointer`, showInfos ? 'info-open' : '', origem, customClass]"
4
- @click="openByItem($event)">
5
- <div v-if="showInfos" class="email-overlay"></div>
6
- <div class="email-author" v-if="autor" :class="[origem, isMainEmail ? 'main' : '']" @click.stop="toggleIsOpen"
7
- :key="autor">
8
- <span :title="statusTitle"><fa-icon :icon="['fas', status !== 'C' ? 'reply' : 'times']" :class="[origem]" /></span>
9
- <p class="email-author-name" v-text="returnAuthorName" :title="returnAuthorName"></p>
10
- <span :title="`E-mail ${origem === 'outros' ? 'recebido' : 'enviado'}`">
11
- <fa-icon :icon="['fas', origem === 'outros' ? 'user' : 'headset']" class="email-to-svg" />
12
- </span>
13
- </div>
14
- <div class="email-custom-buttons" v-if="customButtons && customButtons.length" @click.stop>
15
- <span v-for="(button, index) in customButtons" :key="button.id || index" v-show="button.use"
16
- @click="button.callback ? button.callback(returnParams(button.params)) : $emit(button.emitName, returnParams(button.params))" :class="`${button.customClass || 'menu-mensagem'}`"
17
- v-tippy :content="button.tippyContent">
18
- <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
19
- <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
20
- </span>
21
- </div>
22
- <div class="email-custom-action-buttons" v-if="customActionButtons && customActionButtons.length" @click.stop>
23
- <button v-for="(button, index) in customActionButtons" :key="button.id || index" v-show="button.use"
24
- @click="button.callback(returnParams(button.params))"
25
- :class="`${button.customClass || 'email-custom-action-button'}`" v-tippy :content="button.tippyContent">
26
- <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
27
- <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
28
- <span v-if="button.label" class="email-custom-action-label" v-text="button.label"></span>
29
- </button>
30
- </div>
31
- <div class="email-header" @click.stop="toggleIsOpen">
32
- <p class="email-subject" :title="returnMainValue()">
33
- {{ returnMainValue() }}
34
- </p>
35
- <div class="divBtnReplyEmail" v-if="status === 'C'">
36
- <strong class="strongMsg">{{ status_msg }} </strong>
37
- <button
38
- class="btnReplyEmail"
39
- @click.stop="emitReplyEmail"
40
- ><strong>Reenviar</strong>
41
- </button>
42
- </div>
43
- <div class="header-container">
44
- <div :class="`email-header-content${isOpen ? ' open' : ''}`">
45
- <div class="email-header-infos">
46
- <template v-if="para && para.length">
47
- <div class="email-to-from-container" ref="emailToContainer">
48
- <EmailTo v-for="(recipient, index) in paraCopia" :key="`to-${recipient.email}`"
49
- :currentName="formattedToName(recipient.name, index, paraCopia.length)" :email="recipient.email"
50
- :showMail="isOpen" />
51
- <div class="email-to-btn" v-show="isOpen" @click.stop="toggleShowInfos()">
52
- <fa-icon :icon="['fas', 'caret-down']" />
53
- </div>
54
- </div>
55
- </template>
56
- <div v-if="!isMainEmail && isOpen" class="email-subject-secondary">
57
- <span class="email-subject-span"
58
- v-text="`Assunto: ${htmlEntityToEmoji(replaceUnicodeWithEmoji(assunto)) || '(Sem assunto)'}`"></span>
59
- </div>
60
- </div>
61
- </div>
62
- <span :class="`email-date ${isOpen ? isOpenClass : isClosedClass}`" :title="formattedDate" ref="emailDate"
63
- v-show="formattedDate">
64
- <fa-icon :icon="['fas', 'calendar']" />
65
- {{ formattedDate }}
66
- </span>
67
- </div>
68
- <ul v-if="showInfos" ref="emailToInfos" class="email-to-infos box-shadow" v-clickaway="() => showInfos = false"
69
- @click.stop>
70
- <li v-for="(info, index) in mailInfos" :key="`info-${index}`" class="email-info">
71
- <span v-text="info.label"></span>
72
- {{ info.value }}
73
- </li>
74
- </ul>
75
- <span v-if="isOpen" :class="['email-actions box-shadow', { active: actionsOpen }, { main: isMainEmail }]"
76
- @click.stop="toggleActions">
77
- <span></span>
78
- <span></span>
79
- <span></span>
80
- </span>
81
- <ul class="email-actions-list box-shadow" v-if="actionsOpen && isOpen" v-clickaway="closeActions" @click.stop>
82
- <li class="email-action" @click.stop="toggleOpenMessage">
83
- {{ !openMessage ? 'Visualizar' : 'Esconder' }} texto do e-mail
84
- </li>
85
- </ul>
86
- </div>
87
- <div class="email-content" v-show="isOpen" ref="emailIframeParent">
88
- <VueLoader v-if="isIframeLoading" />
89
- <div v-if="hasError" class="email-error-content">
90
- <p>Erro ao carregar o e-mail</p>
91
- <button class="box-shadow" @click="handleTryAgain()">Tentar novamente</button>
92
- </div>
93
- <iframe v-show="!hasError" ref="emailIframe"
94
- :class="`email-html ${isIframeLoading ? 'visibility-hidden' : ''}`"></iframe>
95
- <span class="email-raw" v-if="openMessage">{{ mensagem }}</span>
96
- </div>
97
- <div v-if="filteredFiles && filteredFiles.length" class="email-files" v-show="isOpen || isMainEmail">
98
- <EmailFile v-for="(anexo, index) in filteredFiles" :key="index" :anexo="anexo" :dominio="dominio" />
99
- </div>
100
- </div>
101
- </template>
102
-
103
- <script>
104
- import EmailFile from "./EmailFile.vue";
105
- import EmailTo from "./EmailTo.vue";
106
- import { textoLongo } from "@/mixins/formatarTexto";
107
- import Clickaway from '@/directives/clickaway';
108
-
109
- export default {
110
- mixins: [textoLongo],
111
- directives: {
112
- clickaway: Clickaway
113
- },
114
- components: { EmailFile, EmailTo },
115
- props: {
116
- dominio: {
117
- type: String,
118
- required: true
119
- },
120
- dicionario: {
121
- type: Object,
122
- required: true
123
- },
124
- customClass: {
125
- type: String,
126
- default: ''
127
- },
128
- from: {
129
- type: Array,
130
- default: () => []
131
- },
132
- para: {
133
- type: Array,
134
- default: () => []
135
- },
136
- copia: {
137
- type: Array,
138
- default: () => []
139
- },
140
- html: {
141
- type: String,
142
- default: ""
143
- },
144
- assunto: {
145
- type: String,
146
- default: ""
147
- },
148
- dataHora: {
149
- type: String,
150
- default: ""
151
- },
152
- mensagem: {
153
- type: String,
154
- default: ""
155
- },
156
- anexos: {
157
- type: [Array, String],
158
- default: () => []
159
- },
160
- iniciarAberto: {
161
- type: Boolean,
162
- default: false
163
- },
164
- dataServer: {
165
- type: String,
166
- default: ""
167
- },
168
- isOpenClass: {
169
- type: String,
170
- default: 'bg-dark-white-2'
171
- },
172
- isClosedClass: {
173
- type: String,
174
- default: 'bg-white'
175
- },
176
- refKey: {
177
- type: String,
178
- },
179
- showRawMessageInsideEmail: {
180
- type: Boolean,
181
- default: false
182
- },
183
- origem: {
184
- type: String,
185
- default: 'outros'
186
- },
187
- autor: {
188
- type: String
189
- },
190
- isMainEmail: {
191
- type: Boolean,
192
- default: true
193
- },
194
- customButtons: {
195
- type: Array
196
- },
197
- customActionButtons: {
198
- type: Array
199
- },
200
- status: {
201
- type: String,
202
- default: ''
203
- },
204
- status_msg: {
205
- type: String,
206
- default: ''
207
- }
208
- },
209
- data() {
210
- return {
211
- isOpen: this.iniciarAberto,
212
- openMessage: false,
213
- actionsOpen: false,
214
- showInfos: false,
215
- isIframeLoading: true,
216
- hasError: false,
217
- errorCount: 0
218
- };
219
- },
220
- computed: {
221
- statusTitle() {
222
- if(this.status !== 'C') {
223
- return `Enviado por: ${this.autor}`
224
- }
225
-
226
- if(!this.status_msg) {
227
- return `Enviado com erro por: ${this.autor}`
228
- }
229
-
230
- return `Enviado com erro por: ${this.autor} - ${this.status_msg}`
231
- },
232
- paraCopia() {
233
- if (!this.copia || !this.copia.length) return this.para && this.para.length ? this.para : []
234
- return this.para && this.para.length ? this.para.concat(this.copia) : this.copia
235
- },
236
- formattedDate() {
237
- return this.formataDateHoraDateFns(this.dataHora, this.dataServer, this.dicionario);
238
- },
239
- mailInfos() {
240
- const formatAsString = (arr) => {
241
- let str = ''
242
- arr.forEach(({ name, email }, index) => {
243
- if (!name && !email) str += ''
244
- else str += `${name || ''} ${email ? `<${email}>` : ''}${((name || email) && index !== arr.length - 1) ? ', ' : ''}`
245
- })
246
- return str
247
- }
248
-
249
- const infos = [
250
- {
251
- label: 'De:',
252
- value: this.from && this.from.length ? formatAsString(this.from) : '--'
253
- },
254
- {
255
- label: 'Para:',
256
- value: this.para && this.para.length ? formatAsString(this.para) : '--'
257
- },
258
- {
259
- label: 'Assunto:',
260
- value: this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
261
- },
262
- {
263
- label: 'Data:',
264
- value: this.formataDataHora(this.dataHora) || '--'
265
- },
266
- ]
267
-
268
- if (this.copia && this.copia.length) {
269
- infos.push({
270
- label: this.dicionario.tit_copia,
271
- value: formatAsString(this.copia)
272
- })
273
- }
274
-
275
- return infos
276
- },
277
- filteredFiles() {
278
- if (!this.anexos || !this.anexos.length) return
279
-
280
- return this.anexos.filter(anexo => {
281
- return !this.html.includes(anexo.name);
282
- })
283
- },
284
- returnAuthorName() {
285
- if (!this.from || !this.from.length) return this.autor || ''
286
- const { email, name } = this.from[0]
287
- if (!name) return email
288
- if (!email) return name
289
- if (this.isOpen) return `${name} (${email})`
290
- return name
291
- },
292
- formattedToName() {
293
- return (name, index, length) => {
294
- let addVirgulaDps = index < length - 1
295
- let addVirgulaAntes = index === 1 && length >= 2
296
- const text = index === 0 ? `Para: ${name || ''}` : name ? `${addVirgulaAntes ? ', ' : ''}${name}${addVirgulaDps ? ', ' : ''}` : '';
297
- return text
298
- }
299
- }
300
- },
301
- watch: {
302
- isOpen: 'updateIframeContent'
303
- },
304
- mounted() {
305
- this.updateIframeContent();
306
- this.adjustMaxWidth()
307
-
308
- if (this.refKey) this.$root.$refs[`${refKey}`] = this
309
-
310
- setTimeout(() => {
311
- if (this.isIframeLoading) this.adjustIframeHeight()
312
- }, 15000);
313
- },
314
- methods: {
315
- handleTryAgain() {
316
- this.isOpen = true
317
- this.isIframeLoading = true
318
- this.hasError = false
319
-
320
- this.$nextTick(this.updateIframeContent())
321
- },
322
-
323
- emitReplyEmail() {
324
- this.$emit('reply-email', {
325
- html: this.html,
326
- mensagem: this.mensagem,
327
- assunto: this.assunto,
328
- from: this.from,
329
- para: this.para,
330
- dataHora: this.dataHora,
331
- anexos: this.anexos,
332
- status: this.status,
333
- status_msg: this.status_msg,
334
- copia: this.copia,
335
- origem: this.origem,
336
- autor: this.autor,
337
- });
338
- },
339
-
340
- gerarMensagemEstilizada(msg) {
341
- try {
342
- const currentStyles = [
343
- { tagAbertura: "<i>", tagFechamento: "</i>", find: /_(.*?)_/g },
344
- { tagAbertura: "<b>", tagFechamento: "</b>", find: /\*(.*?)\*/g },
345
- { tagAbertura: "<del>", tagFechamento: "</del>", find: /~(.*?)~/g }
346
- ]
347
-
348
- const isLetterOrUnderscore = (char) => {
349
- return /[a-zA-Z_]/.test(char)
350
- }
351
-
352
- const isValidMatch = (message, fullMatch, startIndex) => {
353
- const beforeChar = message[startIndex - 1]
354
- const afterChar = message[startIndex + fullMatch.length]
355
- return (
356
- (beforeChar === undefined || !isLetterOrUnderscore(beforeChar)) &&
357
- (afterChar === undefined || !isLetterOrUnderscore(afterChar))
358
- )
359
- }
360
-
361
- let message = msg
362
-
363
- for (const { tagAbertura, tagFechamento, find } of currentStyles) {
364
- let match
365
- while ((match = find.exec(message)) !== null) {
366
- const fullMatch = match[0]
367
- const content = match[1]
368
- const startIndex = match.index
369
-
370
- if (isValidMatch(message, fullMatch, startIndex)) {
371
- const endIndex = startIndex + fullMatch.length
372
- const replacedContent = `${tagAbertura}${content}${tagFechamento}`
373
- message = message.slice(0, startIndex) + replacedContent + message.slice(endIndex)
374
- }
375
- }
376
- }
377
-
378
- return message
379
- } catch (err) {
380
- console.error('Erro ao gerar mensagem estilizada: ', err)
381
- return msg
382
- }
383
- },
384
- updateIframeContent() {
385
- this.$nextTick(() => {
386
- if (this.isOpen && this.isIframeLoading) {
387
- const iframe = this.$refs.emailIframe;
388
- if (!iframe) return
389
- const doc = iframe.contentDocument || iframe.contentWindow.document;
390
- if (!doc) return
391
- let content = this.html
392
- if (!/<[a-z][\s\S]*>/i.test(content)) {
393
- content = content.replace(/\n/g, '<br>');
394
- content = this.gerarMensagemEstilizada(content)
395
- content = `<p>${content}</p>`;
396
- }
397
-
398
- doc.open();
399
- doc.write(content);
400
- doc.close();
401
-
402
- const images = doc.getElementsByTagName('img');
403
- let imagesLoaded = 0;
404
-
405
- const imageLoadHandler = () => {
406
- imagesLoaded++;
407
- if (imagesLoaded === images.length) {
408
- this.adjustIframeHeight();
409
- }
410
- };
411
-
412
- if (images.length === 0) {
413
- this.adjustIframeHeight();
414
- } else {
415
- for (let img of images) {
416
- img.addEventListener('load', imageLoadHandler);
417
- img.addEventListener('error', imageLoadHandler);
418
- }
419
- }
420
- }
421
- });
422
- },
423
- adjustIframeHeight() {
424
- this.$nextTick(() => {
425
- const iframe = this.$refs.emailIframe;
426
- const emailParent = this.$refs.emailIframeParent
427
- if (iframe && emailParent) {
428
- setTimeout(() => {
429
- const doc = iframe.contentDocument || iframe.contentWindow.document;
430
- const margin = 20
431
- const value = doc.documentElement.offsetHeight + margin
432
- if (value === 0 || doc.documentElement.querySelector('body').innerHTML === '') {
433
- this.errorCount++
434
- if (this.errorCount > 3) {
435
- this.hasError = true
436
- if (this.isIframeLoading) this.isIframeLoading = false
437
- return
438
- }
439
- this.isIframeLoading = true
440
- this.updateIframeContent()
441
- return
442
- }
443
- if (this.hasError || this.errorCount > 0) {
444
- this.hasError = false
445
- this.errorCount = 0
446
- }
447
- iframe.style.height = `${value}px`;
448
- emailParent.style.minHeight = `${value}px`
449
- }, 100)
450
- }
451
-
452
- if (this.isIframeLoading) this.isIframeLoading = false
453
- });
454
- },
455
- toggleShowInfos() {
456
- this.showInfos = !this.showInfos;
457
- if (this.showInfos) {
458
- this.$nextTick(() => {
459
- this.adjustTopPosition();
460
- });
461
- }
462
- },
463
- adjustTopPosition() {
464
- const ulElement = this.$refs.emailToInfos;
465
- if (!ulElement) return
466
- const ulHeight = ulElement.offsetHeight;
467
- const maxHeight = 300
468
- const finalHeight = ulHeight < maxHeight ? ulHeight : maxHeight
469
- ulElement.style.bottom = `-${finalHeight}px`;
470
- },
471
- toggleIsOpen() {
472
- this.isOpen = !this.isOpen;
473
- if (!this.isOpen) {
474
- this.actionsOpen = false;
475
- this.openMessage = false;
476
- this.showInfos = false
477
- }
478
- },
479
- adjustMaxWidth() {
480
- this.$nextTick(() => {
481
- const toContainer = this.$refs.emailToContainer
482
- const dateContainer = this.$refs.emailDate
483
- if (!toContainer || !dateContainer) return
484
- toContainer.style.maxWidth = `calc(100% - ${dateContainer.offsetWidth}px)`
485
- })
486
- },
487
- toggleActions() {
488
- this.actionsOpen = !this.actionsOpen;
489
- },
490
- toggleOpenMessage() {
491
- if (this.showRawMessageInsideEmail) {
492
- this.openMessage = !this.openMessage;
493
- }
494
-
495
- this.$emit('open-message', {
496
- dicionario: this.dicionario,
497
- from: this.from,
498
- para: this.para,
499
- html: this.html,
500
- assunto: this.assunto,
501
- dataHora: this.dataHora,
502
- mensagem: this.mensagem,
503
- anexos: this.filteredFiles,
504
- dataServer: this.dataServer,
505
- dominio: this.dominio
506
- })
507
- },
508
- closeActions() {
509
- this.actionsOpen = false;
510
- },
511
- returnMainValue() {
512
- if (this.isMainEmail) return this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
513
- return ''
514
- },
515
- openByItem(event) {
516
- if (this.isOpen) return;
517
-
518
- event.preventDefault();
519
- event.stopPropagation();
520
-
521
- this.toggleIsOpen();
522
- },
523
- returnParams(params) {
524
- const defaultParams = {
525
- message: this.mensagem,
526
- };
527
-
528
- if (!params) return defaultParams;
529
-
530
- const keys = params.instanceKeys.split("|");
531
- if (!keys || !keys.length)
532
- return {
533
- defaultParams,
534
- ...params.values,
535
- };
536
-
537
- const customParams = { ...params.values };
538
- keys.forEach((key) => {
539
- if (this[key]) customParams[key] = this[key];
540
- else console.warn(`Cant find ${key} on 'this' instance`);
541
- });
542
-
543
- return Object.keys(customParams).length ? customParams : defaultParams;
544
- }
545
- }
546
- };
547
- </script>
548
-
549
- <style scoped>
550
- .show-y-top-enter-active,
551
- .show-y-top-leave-enter {
552
- opacity: 1;
553
- transform: translateY(0);
554
- transition: all 200ms linear;
555
- }
556
-
557
- .show-y-top-enter,
558
- .show-y-top-leave-to {
559
- opacity: 0;
560
- transform: translateY(-2%);
561
- }
562
- </style>
563
-
564
- <style>
565
- .visibility-hidden {
566
- visibility: hidden;
567
- }
568
-
569
- .box-shadow-active {
570
- box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.25);
571
- }
572
-
573
- .bg-dark-white-2 {
574
- background-color: #f7f7f7;
575
- }
576
-
577
- .bg-white {
578
- background-color: #FFF;
579
- }
580
-
581
- .cursor-pointer {
582
- cursor: pointer;
583
- }
584
-
585
- .email-overlay {
586
- width: 100%;
587
- height: 100%;
588
- background-color: transparent;
589
- z-index: 1;
590
- position: absolute;
591
- top: 0;
592
- left: 0;
593
- }
594
-
595
- .email-item {
596
- --konecta-gray-3: #515050;
597
- --konecta-light: #f8f9fa;
598
- --blue-silver-4: #dae0e5;
599
- --email-principal: #faa732;
600
- --email-outros: #86b7fe;
601
- font-family: "Roboto", sans-serif;
602
- flex: 1;
603
- margin: 0 0 10px 0;
604
- color: #222;
605
- min-height: 60px;
606
- display: flex;
607
- flex-wrap: wrap;
608
- padding: 10px;
609
- border-radius: 5px;
610
- transition: all 150ms ease-in-out;
611
- max-width: 100%;
612
- width: 100%;
613
- overflow: hidden;
614
- position: relative;
615
- }
616
-
617
- .divBtnReplyEmail {
618
- display: flex;
619
- align-items: center;
620
- background-color: #f0adad;
621
- border-radius: 6px;
622
- padding: 7px 9px;
623
- margin: 7px 0;
624
- width: calc(100% - 10px * 2);
625
- gap: 8px;
626
- }
627
-
628
- .btnReplyEmail {
629
- display: block;
630
- background-color: #faa732;
631
- border: 1px solid #da8205;
632
- margin: 8px 0 8px 5px;
633
- padding: 7px 9px;
634
- font-size: 16px;
635
- border-radius: 3px;
636
- color: #000000;
637
- cursor: pointer;
638
- }
639
-
640
- .strongMsg {
641
- flex: 1;
642
- }
643
-
644
- .email-custom-action-buttons {
645
- display: flex;
646
- gap: 7px;
647
- align-items: center;
648
- flex-wrap: wrap;
649
- max-width: 100%;
650
- cursor: default;
651
- }
652
-
653
- .email-custom-action-button {
654
- margin-top: 10px;
655
- background-color: var(--konecta-light) !important;
656
- color: var(--konecta-dark) !important;
657
- border: 1px solid var(--blue-silver-4) !important;
658
- flex: 1;
659
- min-width: 100px;
660
- display: flex;
661
- align-items: center;
662
- justify-content: center;
663
- gap: 5px;
664
- padding: 5px;
665
- overflow: hidden;
666
- border-radius: 5px;
667
- text-overflow: ellipsis;
668
- white-space: nowrap;
669
- transition: all 100ms ease-in-out;
670
- max-width: 100%;
671
- cursor: pointer
672
- }
673
-
674
- .email-custom-action-button:hover {
675
- background-color: #e9ecef !important;
676
- }
677
-
678
- .email-custom-action-button:disabled {
679
- background-color: var(--konecta-gray-3) !important;
680
- border: 1px solid #25282b !important;
681
- cursor: not-allowed !important;
682
- }
683
-
684
- .email-item.outros {
685
- border-left: 3px solid var(--email-outros);
686
- }
687
-
688
- .email-author-name {
689
- margin: 0 5px;
690
- max-width: 100%;
691
- overflow: hidden;
692
- text-overflow: ellipsis;
693
- white-space: nowrap;
694
- }
695
-
696
- .email-author.outros {
697
- color: var(--email-outros);
698
- }
699
-
700
- .email-author.outros>svg:nth-child(1) {
701
- transform: rotate(180deg);
702
- }
703
-
704
- .email-author.principal {
705
- color: var(--email-principal);
706
- }
707
-
708
- .email-author.main {
709
- font-size: 16.4px;
710
- }
711
-
712
- .email-item.principal {
713
- border-left: 3px solid var(--email-principal);
714
- }
715
-
716
- .email-item.info-open {
717
- overflow: visible
718
- }
719
-
720
- .email-header {
721
- width: 100%;
722
- display: flex;
723
- flex-direction: column;
724
- cursor: pointer;
725
- border-top-right-radius: 5px;
726
- border-top-left-radius: 5px;
727
- position: relative;
728
- overflow: visible;
729
- }
730
-
731
- .header-container {
732
- display: flex;
733
- overflow: hidden;
734
- position: relative;
735
- }
736
-
737
- .email-header-content {
738
- display: flex;
739
- align-items: center;
740
- flex: 1;
741
- min-width: 250px;
742
- }
743
-
744
- .email-header-infos {
745
- display: flex;
746
- flex-direction: column;
747
- flex: 1;
748
- }
749
-
750
- .email-subject {
751
- margin: 5px 0 0 0;
752
- font-size: 16.4px;
753
- cursor: pointer;
754
- }
755
-
756
- .email-date {
757
- --width: 245px;
758
- font-size: 12.8px;
759
- text-overflow: ellipsis;
760
- white-space: nowrap;
761
- overflow: hidden;
762
- position: absolute;
763
- right: 0;
764
- top: 0;
765
- min-width: var(--width);
766
- width: var(--width);
767
- max-width: var(--width);
768
- display: flex;
769
- justify-content: flex-end;
770
- gap: 3px;
771
- align-items: center;
772
- }
773
-
774
- .email-content {
775
- display: flex;
776
- flex-direction: column;
777
- align-items: center;
778
- justify-content: flex-start;
779
- width: 100%;
780
- background-color: #FFF;
781
- position: relative;
782
- max-width: 100%;
783
- }
784
-
785
- .email-actions {
786
- align-self: flex-end;
787
- display: flex;
788
- border-radius: 10px;
789
- cursor: pointer;
790
- align-items: center;
791
- justify-content: center;
792
- gap: 3px;
793
- padding: 5px 7px;
794
- background-color: #dddddd;
795
- position: absolute;
796
- right: 0;
797
- top: 30px;
798
- z-index: 1;
799
- }
800
-
801
- .email-actions.main {
802
- top: 10px
803
- }
804
-
805
- .email-actions.active {
806
- background-color: #dfdfdf;
807
- }
808
-
809
- .email-actions>span {
810
- width: 4px;
811
- height: 4px;
812
- min-width: 4px;
813
- min-height: 4px;
814
- max-width: 4px;
815
- max-height: 4px;
816
- background-color: #222;
817
- border-radius: 50%;
818
- }
819
-
820
- .email-actions-list {
821
- position: absolute;
822
- right: 45px;
823
- width: 250px;
824
- top: 5px;
825
- margin: 0;
826
- list-style-type: none;
827
- padding: 0;
828
- border-radius: 5px;
829
- z-index: 1;
830
- }
831
-
832
- .email-action {
833
- background-color: #dfdfdf;
834
- padding: 5px 10px;
835
- cursor: pointer;
836
- transition: background-color 150ms ease-in-out;
837
- font-size: 14.4px;
838
- user-select: none;
839
- }
840
-
841
- .email-action:nth-child(1) {
842
- border-top-left-radius: 5px;
843
- border-top-right-radius: 5px;
844
- }
845
-
846
- .email-action:last-child {
847
- border-bottom-left-radius: 5px;
848
- border-bottom-right-radius: 5px;
849
- }
850
-
851
- .email-action:hover {
852
- background-color: #CCC;
853
- }
854
-
855
- .email-html {
856
- width: 100%;
857
- min-width: 300px;
858
- max-width: 100%;
859
- border: none;
860
- overflow: auto;
861
- }
862
-
863
- .email-raw {
864
- width: 100%;
865
- max-width: 100%;
866
- padding: 15px;
867
- font-size: 14.4px;
868
- color: #222;
869
- }
870
-
871
- .email-files {
872
- display: flex;
873
- gap: 10px;
874
- flex-wrap: wrap;
875
- width: 100%;
876
- margin-top: 5px;
877
- }
878
-
879
- .email-header-content,
880
- .email-header-infos {
881
- max-width: 100%;
882
- overflow: hidden;
883
- }
884
-
885
- .email-to-from-container {
886
- margin-bottom: 5px;
887
- max-width: 100%;
888
- min-width: 250px;
889
- overflow: hidden;
890
- display: flex;
891
- align-items: center;
892
- flex-wrap: wrap;
893
- flex: 1;
894
- gap: 5px;
895
- }
896
-
897
- .email-to-btn {
898
- padding: 0 5px;
899
- font-size: 14.4px;
900
- cursor: pointer;
901
- color: #666;
902
- }
903
-
904
- .email-to-infos {
905
- position: absolute;
906
- bottom: -325px;
907
- border: 1px solid #CCC;
908
- z-index: 2;
909
- padding: 10px;
910
- background-color: #FFF;
911
- max-height: 300px;
912
- overflow-y: auto;
913
- overflow-x: hidden;
914
- width: 300px;
915
- display: flex;
916
- flex-direction: column;
917
- gap: 5px;
918
- margin: 0;
919
- cursor: default;
920
- }
921
-
922
- .email-info {
923
- width: 100%;
924
- font-size: 12.8px;
925
- }
926
-
927
- .email-info>span {
928
- font-size: 12px;
929
- color: gray;
930
- margin-right: 3px;
931
- }
932
-
933
- .email-author {
934
- display: flex;
935
- align-items: center;
936
- height: 5px;
937
- font-size: 12px;
938
- font-weight: bold;
939
- transform: translateY(-2px);
940
- width: 100%;
941
- cursor: pointer;
942
- }
943
-
944
- .email-subject-secondary {
945
- margin-top: -5px;
946
- }
947
-
948
- .email-subject-span {
949
- font-size: 11.2px;
950
- color: gray;
951
- }
952
-
953
- .email-to-svg {
954
- font-size: 13.6px;
955
- }
956
-
957
- .email-custom-buttons {
958
- display: flex;
959
- gap: 7px;
960
- position: absolute;
961
- top: 5px;
962
- right: 5px;
963
- z-index: 1;
964
- font-size: 12.8px;
965
- }
966
-
967
- .menu-mensagem {
968
- cursor: pointer;
969
- padding: 1px;
970
- opacity: .7;
971
- transition: opacity 100ms ease-in-out;
972
- }
973
-
974
- .menu-mensagem:hover,
975
- .menu-mensagem:focus,
976
- .menu-mensagem:active {
977
- opacity: 1;
978
- }
979
-
980
- .email-error-content {
981
- display: flex;
982
- justify-content: center;
983
- align-items: center;
984
- flex-direction: column;
985
- gap: 5px;
986
- padding: 10px;
987
- }
988
-
989
- .email-error-content p {
990
- margin: 0;
991
- color: #E74C3C;
992
- }
993
-
994
- .email-error-content button {
995
- border: 1px solid #CCC;
996
- border-radius: 3px;
997
- padding: 5px 10px;
998
- background-color: #FFF;
999
- cursor: pointer;
1000
- transition: background-color 150ms ease-in-out;
1001
- }
1002
-
1003
- .email-error-content button:hover {
1004
- background-color: #EEE;
1005
- }
1006
-
1007
- .btnReplyEmail:hover, .btnReplyEmail:active {
1008
- background-color: #da8205;
1009
- color: #000000;
1010
- }
1
+ <template>
2
+ <div
3
+ :class="['email-item box-shadow-active', isOpen ? isOpenClass : `${isClosedClass} cursor-pointer`, showInfos ? 'info-open' : '', origem, customClass]"
4
+ @click="openByItem($event)">
5
+ <div v-if="showInfos" class="email-overlay"></div>
6
+ <div class="email-author" v-if="autor" :class="[origem, isMainEmail ? 'main' : '']" @click.stop="toggleIsOpen"
7
+ :key="autor">
8
+ <span :title="statusTitle"><fa-icon :icon="['fas', status !== 'C' ? 'reply' : 'times']" :class="[origem]" /></span>
9
+ <p class="email-author-name" v-text="returnAuthorName" :title="returnAuthorName"></p>
10
+ <span :title="`E-mail ${origem === 'outros' ? 'recebido' : 'enviado'}`">
11
+ <fa-icon :icon="['fas', origem === 'outros' ? 'user' : 'headset']" class="email-to-svg" />
12
+ </span>
13
+ </div>
14
+ <div class="email-custom-buttons" v-if="customButtons && customButtons.length" @click.stop>
15
+ <span v-for="(button, index) in customButtons" :key="button.id || index" v-show="button.use"
16
+ @click="button.callback ? button.callback(returnParams(button.params)) : $emit(button.emitName, returnParams(button.params))" :class="`${button.customClass || 'menu-mensagem'}`"
17
+ v-tippy :content="button.tippyContent">
18
+ <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
19
+ <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
20
+ </span>
21
+ </div>
22
+ <div class="email-custom-action-buttons" v-if="customActionButtons && customActionButtons.length" @click.stop>
23
+ <button v-for="(button, index) in customActionButtons" :key="button.id || index" v-show="button.use"
24
+ @click="button.callback(returnParams(button.params))"
25
+ :class="`${button.customClass || 'email-custom-action-button'}`" v-tippy :content="button.tippyContent">
26
+ <fa-icon :icon="['fas', button.icon || 'question-circle']" v-if="!button.svgIcon" />
27
+ <span v-else v-html="button.svgIcon" :class="button.svgClass ? button.svgClass : ''"></span>
28
+ <span v-if="button.label" class="email-custom-action-label" v-text="button.label"></span>
29
+ </button>
30
+ </div>
31
+ <div class="email-header" @click.stop="toggleIsOpen">
32
+ <p class="email-subject" :title="returnMainValue()">
33
+ {{ returnMainValue() }}
34
+ </p>
35
+ <div class="divBtnReplyEmail" v-if="status === 'C'">
36
+ <strong class="strongMsg">{{ status_msg }} </strong>
37
+ <button
38
+ v-if="hasReplyEmail"
39
+ class="btnReplyEmail"
40
+ @click.stop="emitReplyEmail"
41
+ ><strong>Reenviar</strong>
42
+ </button>
43
+ </div>
44
+ <div class="header-container">
45
+ <div :class="`email-header-content${isOpen ? ' open' : ''}`">
46
+ <div class="email-header-infos">
47
+ <template v-if="para && para.length">
48
+ <div class="email-to-from-container" ref="emailToContainer">
49
+ <EmailTo v-for="(recipient, index) in paraCopia" :key="`to-${recipient.email}`"
50
+ :currentName="formattedToName(recipient.name, index, paraCopia.length)" :email="recipient.email"
51
+ :showMail="isOpen" />
52
+ <div class="email-to-btn" v-show="isOpen" @click.stop="toggleShowInfos()">
53
+ <fa-icon :icon="['fas', 'caret-down']" />
54
+ </div>
55
+ </div>
56
+ </template>
57
+ <div v-if="!isMainEmail && isOpen" class="email-subject-secondary">
58
+ <span class="email-subject-span"
59
+ v-text="`Assunto: ${htmlEntityToEmoji(replaceUnicodeWithEmoji(assunto)) || '(Sem assunto)'}`"></span>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ <span :class="`email-date ${isOpen ? isOpenClass : isClosedClass}`" :title="formattedDate" ref="emailDate"
64
+ v-show="formattedDate">
65
+ <fa-icon :icon="['fas', 'calendar']" />
66
+ {{ formattedDate }}
67
+ </span>
68
+ </div>
69
+ <ul v-if="showInfos" ref="emailToInfos" class="email-to-infos box-shadow" v-clickaway="() => showInfos = false"
70
+ @click.stop>
71
+ <li v-for="(info, index) in mailInfos" :key="`info-${index}`" class="email-info">
72
+ <span v-text="info.label"></span>
73
+ {{ info.value }}
74
+ </li>
75
+ </ul>
76
+ <span v-if="isOpen" :class="['email-actions box-shadow', { active: actionsOpen }, { main: isMainEmail }]"
77
+ @click.stop="toggleActions">
78
+ <span></span>
79
+ <span></span>
80
+ <span></span>
81
+ </span>
82
+ <ul class="email-actions-list box-shadow" v-if="actionsOpen && isOpen" v-clickaway="closeActions" @click.stop>
83
+ <li class="email-action" @click.stop="toggleOpenMessage">
84
+ {{ !openMessage ? 'Visualizar' : 'Esconder' }} texto do e-mail
85
+ </li>
86
+ </ul>
87
+ </div>
88
+ <div class="email-content" v-show="isOpen" ref="emailIframeParent">
89
+ <VueLoader v-if="isIframeLoading" />
90
+ <div v-if="hasError" class="email-error-content">
91
+ <p>Erro ao carregar o e-mail</p>
92
+ <button class="box-shadow" @click="handleTryAgain()">Tentar novamente</button>
93
+ </div>
94
+ <iframe v-show="!hasError" ref="emailIframe"
95
+ :class="`email-html ${isIframeLoading ? 'visibility-hidden' : ''}`"></iframe>
96
+ <span class="email-raw" v-if="openMessage">{{ mensagem }}</span>
97
+ </div>
98
+ <div v-if="filteredFiles && filteredFiles.length" class="email-files" v-show="isOpen || isMainEmail">
99
+ <EmailFile v-for="(anexo, index) in filteredFiles" :key="index" :anexo="anexo" :dominio="dominio" />
100
+ </div>
101
+ </div>
102
+ </template>
103
+
104
+ <script>
105
+ import EmailFile from "./EmailFile.vue";
106
+ import EmailTo from "./EmailTo.vue";
107
+ import { textoLongo } from "@/mixins/formatarTexto";
108
+ import Clickaway from '@/directives/clickaway';
109
+
110
+ export default {
111
+ mixins: [textoLongo],
112
+ directives: {
113
+ clickaway: Clickaway
114
+ },
115
+ components: { EmailFile, EmailTo },
116
+ props: {
117
+ dominio: {
118
+ type: String,
119
+ required: true
120
+ },
121
+ dicionario: {
122
+ type: Object,
123
+ required: true
124
+ },
125
+ customClass: {
126
+ type: String,
127
+ default: ''
128
+ },
129
+ from: {
130
+ type: Array,
131
+ default: () => []
132
+ },
133
+ para: {
134
+ type: Array,
135
+ default: () => []
136
+ },
137
+ copia: {
138
+ type: Array,
139
+ default: () => []
140
+ },
141
+ html: {
142
+ type: String,
143
+ default: ""
144
+ },
145
+ assunto: {
146
+ type: String,
147
+ default: ""
148
+ },
149
+ dataHora: {
150
+ type: String,
151
+ default: ""
152
+ },
153
+ mensagem: {
154
+ type: String,
155
+ default: ""
156
+ },
157
+ anexos: {
158
+ type: [Array, String],
159
+ default: () => []
160
+ },
161
+ iniciarAberto: {
162
+ type: Boolean,
163
+ default: false
164
+ },
165
+ dataServer: {
166
+ type: String,
167
+ default: ""
168
+ },
169
+ isOpenClass: {
170
+ type: String,
171
+ default: 'bg-dark-white-2'
172
+ },
173
+ isClosedClass: {
174
+ type: String,
175
+ default: 'bg-white'
176
+ },
177
+ refKey: {
178
+ type: String,
179
+ },
180
+ showRawMessageInsideEmail: {
181
+ type: Boolean,
182
+ default: false
183
+ },
184
+ origem: {
185
+ type: String,
186
+ default: 'outros'
187
+ },
188
+ autor: {
189
+ type: String
190
+ },
191
+ isMainEmail: {
192
+ type: Boolean,
193
+ default: true
194
+ },
195
+ customButtons: {
196
+ type: Array
197
+ },
198
+ customActionButtons: {
199
+ type: Array
200
+ },
201
+ status: {
202
+ type: String,
203
+ default: ''
204
+ },
205
+ status_msg: {
206
+ type: String,
207
+ default: ''
208
+ },
209
+ hasReplyEmail: {
210
+ type: Boolean,
211
+ default: false
212
+ }
213
+ },
214
+ data() {
215
+ return {
216
+ isOpen: this.iniciarAberto,
217
+ openMessage: false,
218
+ actionsOpen: false,
219
+ showInfos: false,
220
+ isIframeLoading: true,
221
+ hasError: false,
222
+ errorCount: 0
223
+ };
224
+ },
225
+ computed: {
226
+ statusTitle() {
227
+ if(this.status !== 'C') {
228
+ return `Enviado por: ${this.autor}`
229
+ }
230
+
231
+ if(!this.status_msg) {
232
+ return `Enviado com erro por: ${this.autor}`
233
+ }
234
+
235
+ return `Enviado com erro por: ${this.autor} - ${this.status_msg}`
236
+ },
237
+ paraCopia() {
238
+ if (!this.copia || !this.copia.length) return this.para && this.para.length ? this.para : []
239
+ return this.para && this.para.length ? this.para.concat(this.copia) : this.copia
240
+ },
241
+ formattedDate() {
242
+ return this.formataDateHoraDateFns(this.dataHora, this.dataServer, this.dicionario);
243
+ },
244
+ mailInfos() {
245
+ const formatAsString = (arr) => {
246
+ let str = ''
247
+ arr.forEach(({ name, email }, index) => {
248
+ if (!name && !email) str += ''
249
+ else str += `${name || ''} ${email ? `<${email}>` : ''}${((name || email) && index !== arr.length - 1) ? ', ' : ''}`
250
+ })
251
+ return str
252
+ }
253
+
254
+ const infos = [
255
+ {
256
+ label: 'De:',
257
+ value: this.from && this.from.length ? formatAsString(this.from) : '--'
258
+ },
259
+ {
260
+ label: 'Para:',
261
+ value: this.para && this.para.length ? formatAsString(this.para) : '--'
262
+ },
263
+ {
264
+ label: 'Assunto:',
265
+ value: this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
266
+ },
267
+ {
268
+ label: 'Data:',
269
+ value: this.formataDataHora(this.dataHora) || '--'
270
+ },
271
+ ]
272
+
273
+ if (this.copia && this.copia.length) {
274
+ infos.push({
275
+ label: this.dicionario.tit_copia,
276
+ value: formatAsString(this.copia)
277
+ })
278
+ }
279
+
280
+ return infos
281
+ },
282
+ filteredFiles() {
283
+ if (!this.anexos || !this.anexos.length) return
284
+
285
+ return this.anexos.filter(anexo => {
286
+ return !this.html.includes(anexo.name);
287
+ })
288
+ },
289
+ returnAuthorName() {
290
+ if (!this.from || !this.from.length) return this.autor || ''
291
+ const { email, name } = this.from[0]
292
+ if (!name) return email
293
+ if (!email) return name
294
+ if (this.isOpen) return `${name} (${email})`
295
+ return name
296
+ },
297
+ formattedToName() {
298
+ return (name, index, length) => {
299
+ let addVirgulaDps = index < length - 1
300
+ let addVirgulaAntes = index === 1 && length >= 2
301
+ const text = index === 0 ? `Para: ${name || ''}` : name ? `${addVirgulaAntes ? ', ' : ''}${name}${addVirgulaDps ? ', ' : ''}` : '';
302
+ return text
303
+ }
304
+ }
305
+ },
306
+ watch: {
307
+ isOpen: 'updateIframeContent'
308
+ },
309
+ mounted() {
310
+ this.updateIframeContent();
311
+ this.adjustMaxWidth()
312
+
313
+ if (this.refKey) this.$root.$refs[`${refKey}`] = this
314
+
315
+ setTimeout(() => {
316
+ if (this.isIframeLoading) this.adjustIframeHeight()
317
+ }, 15000);
318
+ },
319
+ methods: {
320
+ handleTryAgain() {
321
+ this.isOpen = true
322
+ this.isIframeLoading = true
323
+ this.hasError = false
324
+
325
+ this.$nextTick(this.updateIframeContent())
326
+ },
327
+
328
+ emitReplyEmail() {
329
+ if(!this.hasReplyEmail) return
330
+
331
+ this.$emit('reply-email', {
332
+ html: this.html,
333
+ mensagem: this.mensagem,
334
+ assunto: this.assunto,
335
+ from: this.from,
336
+ para: this.para,
337
+ dataHora: this.dataHora,
338
+ anexos: this.anexos,
339
+ status: this.status,
340
+ status_msg: this.status_msg,
341
+ copia: this.copia,
342
+ origem: this.origem,
343
+ autor: this.autor,
344
+ });
345
+ },
346
+
347
+ gerarMensagemEstilizada(msg) {
348
+ try {
349
+ const currentStyles = [
350
+ { tagAbertura: "<i>", tagFechamento: "</i>", find: /_(.*?)_/g },
351
+ { tagAbertura: "<b>", tagFechamento: "</b>", find: /\*(.*?)\*/g },
352
+ { tagAbertura: "<del>", tagFechamento: "</del>", find: /~(.*?)~/g }
353
+ ]
354
+
355
+ const isLetterOrUnderscore = (char) => {
356
+ return /[a-zA-Z_]/.test(char)
357
+ }
358
+
359
+ const isValidMatch = (message, fullMatch, startIndex) => {
360
+ const beforeChar = message[startIndex - 1]
361
+ const afterChar = message[startIndex + fullMatch.length]
362
+ return (
363
+ (beforeChar === undefined || !isLetterOrUnderscore(beforeChar)) &&
364
+ (afterChar === undefined || !isLetterOrUnderscore(afterChar))
365
+ )
366
+ }
367
+
368
+ let message = msg
369
+
370
+ for (const { tagAbertura, tagFechamento, find } of currentStyles) {
371
+ let match
372
+ while ((match = find.exec(message)) !== null) {
373
+ const fullMatch = match[0]
374
+ const content = match[1]
375
+ const startIndex = match.index
376
+
377
+ if (isValidMatch(message, fullMatch, startIndex)) {
378
+ const endIndex = startIndex + fullMatch.length
379
+ const replacedContent = `${tagAbertura}${content}${tagFechamento}`
380
+ message = message.slice(0, startIndex) + replacedContent + message.slice(endIndex)
381
+ }
382
+ }
383
+ }
384
+
385
+ return message
386
+ } catch (err) {
387
+ console.error('Erro ao gerar mensagem estilizada: ', err)
388
+ return msg
389
+ }
390
+ },
391
+ updateIframeContent() {
392
+ this.$nextTick(() => {
393
+ if (this.isOpen && this.isIframeLoading) {
394
+ const iframe = this.$refs.emailIframe;
395
+ if (!iframe) return
396
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
397
+ if (!doc) return
398
+ let content = this.html
399
+ if (!/<[a-z][\s\S]*>/i.test(content)) {
400
+ content = content.replace(/\n/g, '<br>');
401
+ content = this.gerarMensagemEstilizada(content)
402
+ content = `<p>${content}</p>`;
403
+ }
404
+
405
+ doc.open();
406
+ doc.write(content);
407
+ doc.close();
408
+
409
+ const images = doc.getElementsByTagName('img');
410
+ let imagesLoaded = 0;
411
+
412
+ const imageLoadHandler = () => {
413
+ imagesLoaded++;
414
+ if (imagesLoaded === images.length) {
415
+ this.adjustIframeHeight();
416
+ }
417
+ };
418
+
419
+ if (images.length === 0) {
420
+ this.adjustIframeHeight();
421
+ } else {
422
+ for (let img of images) {
423
+ img.addEventListener('load', imageLoadHandler);
424
+ img.addEventListener('error', imageLoadHandler);
425
+ }
426
+ }
427
+ }
428
+ });
429
+ },
430
+ adjustIframeHeight() {
431
+ this.$nextTick(() => {
432
+ const iframe = this.$refs.emailIframe;
433
+ const emailParent = this.$refs.emailIframeParent
434
+ if (iframe && emailParent) {
435
+ setTimeout(() => {
436
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
437
+ const margin = 20
438
+ const value = doc.documentElement.offsetHeight + margin
439
+ if (value === 0 || doc.documentElement.querySelector('body').innerHTML === '') {
440
+ this.errorCount++
441
+ if (this.errorCount > 3) {
442
+ this.hasError = true
443
+ if (this.isIframeLoading) this.isIframeLoading = false
444
+ return
445
+ }
446
+ this.isIframeLoading = true
447
+ this.updateIframeContent()
448
+ return
449
+ }
450
+ if (this.hasError || this.errorCount > 0) {
451
+ this.hasError = false
452
+ this.errorCount = 0
453
+ }
454
+ iframe.style.height = `${value}px`;
455
+ emailParent.style.minHeight = `${value}px`
456
+ }, 100)
457
+ }
458
+
459
+ if (this.isIframeLoading) this.isIframeLoading = false
460
+ });
461
+ },
462
+ toggleShowInfos() {
463
+ this.showInfos = !this.showInfos;
464
+ if (this.showInfos) {
465
+ this.$nextTick(() => {
466
+ this.adjustTopPosition();
467
+ });
468
+ }
469
+ },
470
+ adjustTopPosition() {
471
+ const ulElement = this.$refs.emailToInfos;
472
+ if (!ulElement) return
473
+ const ulHeight = ulElement.offsetHeight;
474
+ const maxHeight = 300
475
+ const finalHeight = ulHeight < maxHeight ? ulHeight : maxHeight
476
+ ulElement.style.bottom = `-${finalHeight}px`;
477
+ },
478
+ toggleIsOpen() {
479
+ this.isOpen = !this.isOpen;
480
+ if (!this.isOpen) {
481
+ this.actionsOpen = false;
482
+ this.openMessage = false;
483
+ this.showInfos = false
484
+ }
485
+ },
486
+ adjustMaxWidth() {
487
+ this.$nextTick(() => {
488
+ const toContainer = this.$refs.emailToContainer
489
+ const dateContainer = this.$refs.emailDate
490
+ if (!toContainer || !dateContainer) return
491
+ toContainer.style.maxWidth = `calc(100% - ${dateContainer.offsetWidth}px)`
492
+ })
493
+ },
494
+ toggleActions() {
495
+ this.actionsOpen = !this.actionsOpen;
496
+ },
497
+ toggleOpenMessage() {
498
+ if (this.showRawMessageInsideEmail) {
499
+ this.openMessage = !this.openMessage;
500
+ }
501
+
502
+ this.$emit('open-message', {
503
+ dicionario: this.dicionario,
504
+ from: this.from,
505
+ para: this.para,
506
+ html: this.html,
507
+ assunto: this.assunto,
508
+ dataHora: this.dataHora,
509
+ mensagem: this.mensagem,
510
+ anexos: this.filteredFiles,
511
+ dataServer: this.dataServer,
512
+ dominio: this.dominio
513
+ })
514
+ },
515
+ closeActions() {
516
+ this.actionsOpen = false;
517
+ },
518
+ returnMainValue() {
519
+ if (this.isMainEmail) return this.htmlEntityToEmoji(this.replaceUnicodeWithEmoji(this.assunto)) || '(Sem assunto)'
520
+ return ''
521
+ },
522
+ openByItem(event) {
523
+ if (this.isOpen) return;
524
+
525
+ event.preventDefault();
526
+ event.stopPropagation();
527
+
528
+ this.toggleIsOpen();
529
+ },
530
+ returnParams(params) {
531
+ const defaultParams = {
532
+ message: this.mensagem,
533
+ };
534
+
535
+ if (!params) return defaultParams;
536
+
537
+ const keys = params.instanceKeys.split("|");
538
+ if (!keys || !keys.length)
539
+ return {
540
+ defaultParams,
541
+ ...params.values,
542
+ };
543
+
544
+ const customParams = { ...params.values };
545
+ keys.forEach((key) => {
546
+ if (this[key]) customParams[key] = this[key];
547
+ else console.warn(`Cant find ${key} on 'this' instance`);
548
+ });
549
+
550
+ return Object.keys(customParams).length ? customParams : defaultParams;
551
+ }
552
+ }
553
+ };
554
+ </script>
555
+
556
+ <style scoped>
557
+ .show-y-top-enter-active,
558
+ .show-y-top-leave-enter {
559
+ opacity: 1;
560
+ transform: translateY(0);
561
+ transition: all 200ms linear;
562
+ }
563
+
564
+ .show-y-top-enter,
565
+ .show-y-top-leave-to {
566
+ opacity: 0;
567
+ transform: translateY(-2%);
568
+ }
569
+ </style>
570
+
571
+ <style>
572
+ .visibility-hidden {
573
+ visibility: hidden;
574
+ }
575
+
576
+ .box-shadow-active {
577
+ box-shadow: 0px 0px 4px 2px rgba(0, 0, 0, 0.25);
578
+ }
579
+
580
+ .bg-dark-white-2 {
581
+ background-color: #f7f7f7;
582
+ }
583
+
584
+ .bg-white {
585
+ background-color: #FFF;
586
+ }
587
+
588
+ .cursor-pointer {
589
+ cursor: pointer;
590
+ }
591
+
592
+ .email-overlay {
593
+ width: 100%;
594
+ height: 100%;
595
+ background-color: transparent;
596
+ z-index: 1;
597
+ position: absolute;
598
+ top: 0;
599
+ left: 0;
600
+ }
601
+
602
+ .email-item {
603
+ --konecta-gray-3: #515050;
604
+ --konecta-light: #f8f9fa;
605
+ --blue-silver-4: #dae0e5;
606
+ --email-principal: #faa732;
607
+ --email-outros: #86b7fe;
608
+ font-family: "Roboto", sans-serif;
609
+ flex: 1;
610
+ margin: 0 0 10px 0;
611
+ color: #222;
612
+ min-height: 60px;
613
+ display: flex;
614
+ flex-wrap: wrap;
615
+ padding: 10px;
616
+ border-radius: 5px;
617
+ transition: all 150ms ease-in-out;
618
+ max-width: 100%;
619
+ width: 100%;
620
+ overflow: hidden;
621
+ position: relative;
622
+ }
623
+
624
+ .divBtnReplyEmail {
625
+ display: flex;
626
+ align-items: center;
627
+ background-color: #f0adad;
628
+ border-radius: 6px;
629
+ padding: 7px 9px;
630
+ margin: 7px 0;
631
+ width: calc(100% - 10px * 2);
632
+ gap: 8px;
633
+ }
634
+
635
+ .btnReplyEmail {
636
+ display: block;
637
+ background-color: #faa732;
638
+ border: 1px solid #da8205;
639
+ margin: 8px 0 8px 5px;
640
+ padding: 7px 9px;
641
+ font-size: 16px;
642
+ border-radius: 3px;
643
+ color: #000000;
644
+ cursor: pointer;
645
+ }
646
+
647
+ .strongMsg {
648
+ flex: 1;
649
+ }
650
+
651
+ .email-custom-action-buttons {
652
+ display: flex;
653
+ gap: 7px;
654
+ align-items: center;
655
+ flex-wrap: wrap;
656
+ max-width: 100%;
657
+ cursor: default;
658
+ }
659
+
660
+ .email-custom-action-button {
661
+ margin-top: 10px;
662
+ background-color: var(--konecta-light) !important;
663
+ color: var(--konecta-dark) !important;
664
+ border: 1px solid var(--blue-silver-4) !important;
665
+ flex: 1;
666
+ min-width: 100px;
667
+ display: flex;
668
+ align-items: center;
669
+ justify-content: center;
670
+ gap: 5px;
671
+ padding: 5px;
672
+ overflow: hidden;
673
+ border-radius: 5px;
674
+ text-overflow: ellipsis;
675
+ white-space: nowrap;
676
+ transition: all 100ms ease-in-out;
677
+ max-width: 100%;
678
+ cursor: pointer
679
+ }
680
+
681
+ .email-custom-action-button:hover {
682
+ background-color: #e9ecef !important;
683
+ }
684
+
685
+ .email-custom-action-button:disabled {
686
+ background-color: var(--konecta-gray-3) !important;
687
+ border: 1px solid #25282b !important;
688
+ cursor: not-allowed !important;
689
+ }
690
+
691
+ .email-item.outros {
692
+ border-left: 3px solid var(--email-outros);
693
+ }
694
+
695
+ .email-author-name {
696
+ margin: 0 5px;
697
+ max-width: 100%;
698
+ overflow: hidden;
699
+ text-overflow: ellipsis;
700
+ white-space: nowrap;
701
+ }
702
+
703
+ .email-author.outros {
704
+ color: var(--email-outros);
705
+ }
706
+
707
+ .email-author.outros>svg:nth-child(1) {
708
+ transform: rotate(180deg);
709
+ }
710
+
711
+ .email-author.principal {
712
+ color: var(--email-principal);
713
+ }
714
+
715
+ .email-author.main {
716
+ font-size: 16.4px;
717
+ }
718
+
719
+ .email-item.principal {
720
+ border-left: 3px solid var(--email-principal);
721
+ }
722
+
723
+ .email-item.info-open {
724
+ overflow: visible
725
+ }
726
+
727
+ .email-header {
728
+ width: 100%;
729
+ display: flex;
730
+ flex-direction: column;
731
+ cursor: pointer;
732
+ border-top-right-radius: 5px;
733
+ border-top-left-radius: 5px;
734
+ position: relative;
735
+ overflow: visible;
736
+ }
737
+
738
+ .header-container {
739
+ display: flex;
740
+ overflow: hidden;
741
+ position: relative;
742
+ }
743
+
744
+ .email-header-content {
745
+ display: flex;
746
+ align-items: center;
747
+ flex: 1;
748
+ min-width: 250px;
749
+ }
750
+
751
+ .email-header-infos {
752
+ display: flex;
753
+ flex-direction: column;
754
+ flex: 1;
755
+ }
756
+
757
+ .email-subject {
758
+ margin: 5px 0 0 0;
759
+ font-size: 16.4px;
760
+ cursor: pointer;
761
+ }
762
+
763
+ .email-date {
764
+ --width: 245px;
765
+ font-size: 12.8px;
766
+ text-overflow: ellipsis;
767
+ white-space: nowrap;
768
+ overflow: hidden;
769
+ position: absolute;
770
+ right: 0;
771
+ top: 0;
772
+ min-width: var(--width);
773
+ width: var(--width);
774
+ max-width: var(--width);
775
+ display: flex;
776
+ justify-content: flex-end;
777
+ gap: 3px;
778
+ align-items: center;
779
+ }
780
+
781
+ .email-content {
782
+ display: flex;
783
+ flex-direction: column;
784
+ align-items: center;
785
+ justify-content: flex-start;
786
+ width: 100%;
787
+ background-color: #FFF;
788
+ position: relative;
789
+ max-width: 100%;
790
+ }
791
+
792
+ .email-actions {
793
+ align-self: flex-end;
794
+ display: flex;
795
+ border-radius: 10px;
796
+ cursor: pointer;
797
+ align-items: center;
798
+ justify-content: center;
799
+ gap: 3px;
800
+ padding: 5px 7px;
801
+ background-color: #dddddd;
802
+ position: absolute;
803
+ right: 0;
804
+ top: 30px;
805
+ z-index: 1;
806
+ }
807
+
808
+ .email-actions.main {
809
+ top: 10px
810
+ }
811
+
812
+ .email-actions.active {
813
+ background-color: #dfdfdf;
814
+ }
815
+
816
+ .email-actions>span {
817
+ width: 4px;
818
+ height: 4px;
819
+ min-width: 4px;
820
+ min-height: 4px;
821
+ max-width: 4px;
822
+ max-height: 4px;
823
+ background-color: #222;
824
+ border-radius: 50%;
825
+ }
826
+
827
+ .email-actions-list {
828
+ position: absolute;
829
+ right: 45px;
830
+ width: 250px;
831
+ top: 5px;
832
+ margin: 0;
833
+ list-style-type: none;
834
+ padding: 0;
835
+ border-radius: 5px;
836
+ z-index: 1;
837
+ }
838
+
839
+ .email-action {
840
+ background-color: #dfdfdf;
841
+ padding: 5px 10px;
842
+ cursor: pointer;
843
+ transition: background-color 150ms ease-in-out;
844
+ font-size: 14.4px;
845
+ user-select: none;
846
+ }
847
+
848
+ .email-action:nth-child(1) {
849
+ border-top-left-radius: 5px;
850
+ border-top-right-radius: 5px;
851
+ }
852
+
853
+ .email-action:last-child {
854
+ border-bottom-left-radius: 5px;
855
+ border-bottom-right-radius: 5px;
856
+ }
857
+
858
+ .email-action:hover {
859
+ background-color: #CCC;
860
+ }
861
+
862
+ .email-html {
863
+ width: 100%;
864
+ min-width: 300px;
865
+ max-width: 100%;
866
+ border: none;
867
+ overflow: auto;
868
+ }
869
+
870
+ .email-raw {
871
+ width: 100%;
872
+ max-width: 100%;
873
+ padding: 15px;
874
+ font-size: 14.4px;
875
+ color: #222;
876
+ }
877
+
878
+ .email-files {
879
+ display: flex;
880
+ gap: 10px;
881
+ flex-wrap: wrap;
882
+ width: 100%;
883
+ margin-top: 5px;
884
+ }
885
+
886
+ .email-header-content,
887
+ .email-header-infos {
888
+ max-width: 100%;
889
+ overflow: hidden;
890
+ }
891
+
892
+ .email-to-from-container {
893
+ margin-bottom: 5px;
894
+ max-width: 100%;
895
+ min-width: 250px;
896
+ overflow: hidden;
897
+ display: flex;
898
+ align-items: center;
899
+ flex-wrap: wrap;
900
+ flex: 1;
901
+ gap: 5px;
902
+ }
903
+
904
+ .email-to-btn {
905
+ padding: 0 5px;
906
+ font-size: 14.4px;
907
+ cursor: pointer;
908
+ color: #666;
909
+ }
910
+
911
+ .email-to-infos {
912
+ position: absolute;
913
+ bottom: -325px;
914
+ border: 1px solid #CCC;
915
+ z-index: 2;
916
+ padding: 10px;
917
+ background-color: #FFF;
918
+ max-height: 300px;
919
+ overflow-y: auto;
920
+ overflow-x: hidden;
921
+ width: 300px;
922
+ display: flex;
923
+ flex-direction: column;
924
+ gap: 5px;
925
+ margin: 0;
926
+ cursor: default;
927
+ }
928
+
929
+ .email-info {
930
+ width: 100%;
931
+ font-size: 12.8px;
932
+ }
933
+
934
+ .email-info>span {
935
+ font-size: 12px;
936
+ color: gray;
937
+ margin-right: 3px;
938
+ }
939
+
940
+ .email-author {
941
+ display: flex;
942
+ align-items: center;
943
+ height: 5px;
944
+ font-size: 12px;
945
+ font-weight: bold;
946
+ transform: translateY(-2px);
947
+ width: 100%;
948
+ cursor: pointer;
949
+ }
950
+
951
+ .email-subject-secondary {
952
+ margin-top: -5px;
953
+ }
954
+
955
+ .email-subject-span {
956
+ font-size: 11.2px;
957
+ color: gray;
958
+ }
959
+
960
+ .email-to-svg {
961
+ font-size: 13.6px;
962
+ }
963
+
964
+ .email-custom-buttons {
965
+ display: flex;
966
+ gap: 7px;
967
+ position: absolute;
968
+ top: 5px;
969
+ right: 5px;
970
+ z-index: 1;
971
+ font-size: 12.8px;
972
+ }
973
+
974
+ .menu-mensagem {
975
+ cursor: pointer;
976
+ padding: 1px;
977
+ opacity: .7;
978
+ transition: opacity 100ms ease-in-out;
979
+ }
980
+
981
+ .menu-mensagem:hover,
982
+ .menu-mensagem:focus,
983
+ .menu-mensagem:active {
984
+ opacity: 1;
985
+ }
986
+
987
+ .email-error-content {
988
+ display: flex;
989
+ justify-content: center;
990
+ align-items: center;
991
+ flex-direction: column;
992
+ gap: 5px;
993
+ padding: 10px;
994
+ }
995
+
996
+ .email-error-content p {
997
+ margin: 0;
998
+ color: #E74C3C;
999
+ }
1000
+
1001
+ .email-error-content button {
1002
+ border: 1px solid #CCC;
1003
+ border-radius: 3px;
1004
+ padding: 5px 10px;
1005
+ background-color: #FFF;
1006
+ cursor: pointer;
1007
+ transition: background-color 150ms ease-in-out;
1008
+ }
1009
+
1010
+ .email-error-content button:hover {
1011
+ background-color: #EEE;
1012
+ }
1013
+
1014
+ .btnReplyEmail:hover, .btnReplyEmail:active {
1015
+ background-color: #da8205;
1016
+ color: #000000;
1017
+ }
1011
1018
  </style>