vue-intergrall-plugins 1.1.13 → 1.1.15

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