vue-intergrall-plugins 0.0.300 → 0.0.500

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 (41) hide show
  1. package/README.md +185 -185
  2. package/dist/vue-intergrall-plugins.esm.js +818 -427
  3. package/dist/vue-intergrall-plugins.min.js +1 -1
  4. package/dist/vue-intergrall-plugins.ssr.js +788 -457
  5. package/package.json +66 -66
  6. package/src/lib-components/Buttons/IconButton.vue +27 -27
  7. package/src/lib-components/Buttons/SimpleButton.vue +140 -140
  8. package/src/lib-components/Cards/Card.vue +412 -412
  9. package/src/lib-components/Cards/CardCheck.vue +35 -35
  10. package/src/lib-components/Cards/CardFile.vue +157 -157
  11. package/src/lib-components/Chat/AudioSpeedControl.vue +60 -0
  12. package/src/lib-components/Chat/BtnDownloadAllFiles.vue +32 -32
  13. package/src/lib-components/Chat/BtnEmojis.vue +131 -125
  14. package/src/lib-components/Chat/BtnExpand.vue +17 -17
  15. package/src/lib-components/Chat/BtnFiles.vue +415 -415
  16. package/src/lib-components/Chat/BtnMic.vue +60 -60
  17. package/src/lib-components/Chat/BtnScreenShare.vue +32 -32
  18. package/src/lib-components/Chat/BtnStandardMessages.vue +17 -17
  19. package/src/lib-components/Chat/ExpandTextarea.vue +410 -410
  20. package/src/lib-components/Chat/MultipleFilePreview.vue +266 -266
  21. package/src/lib-components/Chat/Picker.vue +405 -368
  22. package/src/lib-components/Chat/RemainingCharacters.vue +28 -28
  23. package/src/lib-components/Chat/SingleFilePreview.vue +94 -94
  24. package/src/lib-components/Chat/SkeletonPicker.vue +110 -110
  25. package/src/lib-components/Chat/StandardMessages.vue +245 -245
  26. package/src/lib-components/Chat/TextFooter.vue +1075 -817
  27. package/src/lib-components/Email/EmailFile.vue +125 -125
  28. package/src/lib-components/Email/EmailItem.vue +185 -185
  29. package/src/lib-components/Loader/Loader.vue +78 -78
  30. package/src/lib-components/Messages/AnexoMensagem.vue +458 -385
  31. package/src/lib-components/Messages/CardAttachment.vue +61 -61
  32. package/src/lib-components/Messages/CardMessages.vue +666 -394
  33. package/src/lib-components/Messages/ChatMessages.vue +1077 -573
  34. package/src/lib-components/Messages/InteratividadeBotoes.vue +165 -165
  35. package/src/lib-components/Messages/InteratividadeFormulario.vue +392 -392
  36. package/src/lib-components/Messages/InteratividadePopup.vue +88 -88
  37. package/src/lib-components/Messages/LinkPreview.vue +163 -163
  38. package/src/lib-components/Scroll/ScrollContent.vue +150 -150
  39. package/src/lib-components/Templates/TemplateGenerator.vue +576 -576
  40. package/src/lib-components/Templates/TemplateMessage.vue +83 -83
  41. package/src/lib-components/Templates/TemplateSingle.vue +481 -481
@@ -1,817 +1,1075 @@
1
- <template>
2
- <div class="text-footer-container" :class="{'bigger' : cssStyle.height}" v-on-clickaway="away" v-if="textId" @drop.stop="dropFile" @dragenter.prevent @dragover.prevent>
3
- <div class="text-footer" :class="cssStyle.width ? cssStyle.width: ''" :style="`background-color: ${cssStyle.backgroundColor}`">
4
- <BtnEmojis
5
- v-show="buttons.hasEmojis && !audioFile"
6
- :ref="`${this.textId}`"
7
- :emojiId="`${this.textId}`"
8
- :down="emojiSettings.openEmojisFrom == 'top' ? false : true"
9
- :small="emojiSettings.smallEmojis"
10
- :biggerTextarea="cssStyle.height ? true : false"
11
- @insert-emoji="insertEmoji"
12
- />
13
- <transition name="fade">
14
- <Loader v-if="isSending" />
15
- </transition>
16
- <textarea
17
- class="js-autoresize"
18
- v-if="!audioFile"
19
- v-model="message"
20
- :id="`text-footer-${this.textId}`"
21
- :disabled="textareaSettings.disabled"
22
- :placeholder="textareaSettings.placeholderMessage"
23
- @input="sendFinalMessage"
24
- @keydown.up="toggleStandardMessages"
25
- @keydown.down="toggleStandardMessages"
26
- @keydown.esc="closeEmojis"
27
- @keydown.enter="sendMessageHandler"
28
- @paste="pasteImage"
29
- ></textarea>
30
- <div class="text-footer-audio" v-else>
31
- <audio :src="audioSource" controls="controls"></audio>
32
- <span class="delete-audio" title="Cancelar" @click="deleteAudio">
33
- <fa-icon :icon="['fas', 'times']" />
34
- </span>
35
- </div>
36
- <RemainingCharacters
37
- :class="{'d-none' : audioFile}"
38
- :message="message"
39
- :maxCharacters="textareaSettings.maxCharacters"
40
- />
41
- <div v-if="buttons.hasFiles || buttons.hasAudio || buttons.hasExpand || formattedMessageSettings.hasStandardMessages || buttons.hasScreenShare || buttons.hasDownloadAll" class="text-footer-actions" :class="{'outside-buttons' : cssStyle.outsideButtons && !audioFile}">
42
- <BtnDownloadAllFiles
43
- v-show="buttons.hasDownloadAll && !audioFile"
44
- @click-trigger="$emit('handle-download-files')"
45
- :dictionary="dictionary"
46
- :ref="`${textId}-download-files`"
47
- />
48
- <BtnScreenShare
49
- v-show="buttons.hasScreenShare && !audioFile"
50
- @handle-screen-share="handleScreenShare"
51
- :dictionary="dictionary"
52
- :ref="`${textId}-screen-share`"
53
- />
54
- <BtnMic
55
- v-show="buttons.hasAudio && !audioFile"
56
- :dictionary="dictionary"
57
- @set-audio="setAudio"
58
- :ref="`${textId}-mic`"
59
- />
60
- <BtnStandardMessages
61
- v-show="formattedMessageSettings.hasStandardMessages && !audioFile"
62
- :dictionary="dictionary"
63
- :ref="`${textId}-standard-messages`"
64
- @toggle-standard-messages="toggleStandardMessages"
65
- />
66
- <BtnFiles
67
- v-show="buttons.hasFiles && !audioFile"
68
- :textId="textId"
69
- :dictionary="dictionary"
70
- :fileSettings="fileSettings"
71
- :cssStyle="cssStyle"
72
- :ref="`${textId}-file`"
73
- :hasButtonFiles="hasButtonFiles"
74
- :externalFiles="externalFiles"
75
- @set-file-vars="setFileVars"
76
- @open-image="openImage"
77
- @open-file-system="openFileSystem"
78
- @reset-file-system="resetFileSystem"
79
- @handle-file-preview="$emit('handle-file-preview')"
80
- @handle-file-click="$emit('handle-file-click')"
81
- />
82
- <BtnExpand
83
- v-show="buttons.hasExpand && !audioFile"
84
- :ref="`${textId}-expand`"
85
- @expand-textarea="$emit('expand-textarea')"
86
- :dictionary="dictionary"
87
- />
88
- </div>
89
- <div class="text-footer-actions" v-if="buttons.hasSendButton">
90
- <span class="text-footer-actions--btn" :title="dictionary.title_enviar_msg" @click="sendMessageHandler">
91
- <fa-icon :icon="['fas', 'paper-plane']" />
92
- </span>
93
- </div>
94
- </div>
95
- <transition name="fade">
96
- <StandardMessages
97
- v-if="showStandardMessages"
98
- :class="cssStyle.width ? cssStyle.width: ''"
99
- :dictionary="dictionary"
100
- :backgroundColor="cssStyle.backgroundColor"
101
- :token_cliente="formattedMessageSettings.token_cliente ? formattedMessageSettings.token_cliente : ''"
102
- :message="message"
103
- :messageType="messageType"
104
- :hasStandardMessages="formattedMessageSettings.hasStandardMessages && showStandardMessages"
105
-
106
- @close-standard-messages="closeStandardMessages"
107
- @open-blocker-standard-message="openBlockerStandardMessage"
108
- @close-blocker-standard-message="closeBlockerStandardMessage"
109
- @set-message-type="setMessageType"
110
- @set-standard-infos="setStandardInfos"
111
- @add-standard-message="addStandardMessage"
112
- @error-standard-message="$emit('error-standard-message')"
113
- />
114
- </transition>
115
- </div>
116
- </template>
117
-
118
- <script>
119
- import { setResizeListeners, resetTargets } from "../../services/autoResize"
120
- import { mixin as clickaway } from "vue-clickaway"
121
- import { returnMessageWithHexa } from "../../services/textFormatting"
122
-
123
- import BtnEmojis from "./BtnEmojis"
124
- import Loader from "../Loader/Loader"
125
- import RemainingCharacters from "./RemainingCharacters"
126
- import BtnMic from "./BtnMic"
127
- import BtnFiles from "./BtnFiles"
128
- import BtnExpand from "./BtnExpand"
129
- import BtnStandardMessages from "./BtnStandardMessages"
130
- import StandardMessages from "./StandardMessages"
131
- import BtnScreenShare from "./BtnScreenShare"
132
- import BtnDownloadAllFiles from './BtnDownloadAllFiles'
133
-
134
- export default {
135
- components: { BtnEmojis, Loader, BtnMic, BtnFiles, BtnExpand, RemainingCharacters, BtnStandardMessages, StandardMessages, BtnScreenShare, BtnDownloadAllFiles },
136
- mixins: [ clickaway ],
137
- props: {
138
- buttons: {
139
- type: Object,
140
- default: () => { return { hasEmojis: false, hasSendButton: false, hasFiles: false, hasAudio: false, hasExpand: false, hasScreenShare: false } },
141
- required: false
142
- },
143
- cssStyle: {
144
- type: Object,
145
- default: () => { return { height: false, width: "full", backgroundColor: "#FFF", outsideButtons: false } },
146
- required: false
147
- },
148
- textareaSettings: {
149
- type: Object,
150
- default: () => { return { placeholderMessage: "", maxCharacters: 0, sendOnEnter: false, disabled: false } },
151
- required: false
152
- },
153
- emojiSettings: {
154
- type: Object,
155
- default: () => { return { openEmojisFrom: "top", smallEmojis: false } },
156
- required: false
157
- },
158
- formattedMessageSettings: {
159
- type: Object,
160
- default: () => { return { hasStandardMessages: false, msgType: 0, token_cliente: "" } },
161
- required: false
162
- },
163
- fileSettings: {
164
- type: Object,
165
- default: () => { return { docsExtensions: "", imagesExtensions: "", multiple: false, systemButton: false, max: 3, handleFilePreview: false, filePreviewStyle: 1, stackFiles: false, handleFileClick: false } },
166
- required: false
167
- },
168
- textId: {
169
- type: String,
170
- required: true
171
- },
172
- isMainChat: {
173
- type: Boolean,
174
- default: false,
175
- required: false
176
- },
177
- isSending: {
178
- type: Boolean,
179
- default: false,
180
- required: false
181
- },
182
- dictionary: {
183
- type: Object,
184
- required: true
185
- },
186
- hasButtonFiles: {
187
- type: Boolean,
188
- required: false
189
- },
190
- externalFiles: {
191
- type: Array,
192
- required: false
193
- }
194
- },
195
- data() {
196
- return {
197
- message: "",
198
- openFiles: false,
199
- file: [],
200
- hasAnyFile: false,
201
- imagePreview: "",
202
- isDoc: false,
203
- fileFormatError: false,
204
- audioFile: "",
205
- audioSource: "",
206
- showStandardMessages: false,
207
- messageType: 1
208
- }
209
- },
210
- created() {
211
- this.$root.$refs[`tf-${this.textId}`] = this
212
- },
213
- mounted() {
214
- setResizeListeners(this.$el, ".js-autoresize", ".js-parentresize")
215
- window.addEventListener("message", this.listenerPostMessage, false)
216
-
217
- // this.$root.$on("drop-file", (file, type) => { if(this.buttons.hasFiles) this.fileUpload(file, type, true) })
218
- // this.$root.$on("toggle-msg-formatada", () => { this.toggleStandardMessages() })
219
- // this.$root.$on("textarea-focus", () => { this.focusTextarea() })
220
- // this.$root.$on("resize-footer-template", () => { this.adjustChatHeight() })
221
- // this.$root.$on("clear-footer-message", () => { this.message = "" })
222
- // if(this.cssStyle.outsideButtons) if(this.$root.$refs.chatCorpo) this.$root.$refs.chatCorpo.setOutsideButtons(this.cssStyle.outsideButtons)
223
- },
224
- methods: {
225
- listenerPostMessage(event){
226
- const baseURL = window.location.hostname == 'localhost' ? `https://linux07` : `https://${window.location.hostname}`
227
- if(!this.formattedMessageSettings.hasStandardMessages) return
228
- if(event.data.gerenciador || event.data.abrirFishing || event.data.multiplos_contatos || event.data.inserir_cliente_omni || event.data.multiple_contatos) return
229
- if(event.origin == baseURL) {
230
- if(event.data == '' && this.showStandardMessages){
231
- this.closeBlockerStandardMessage()
232
- this.toggleStandardMessages()
233
- this.$toasted.global.defaultInfo({msg: this.dictionary.msg_erro_sem_msg_formatada})
234
- }else if(typeof event.data === "string" && this.showStandardMessages){
235
- this.message = event.data
236
- this.focusTextarea()
237
- this.closeBlockerStandardMessage()
238
- this.toggleStandardMessages()
239
- }
240
- }
241
- },
242
- closeEmojis() {
243
- try {
244
- this.$root.$refs[`etf-${this.textId}`].showEmojis ? this.$root.$refs[`etf-${this.textId}`].away() : ''
245
- }catch(e) {
246
- console.error("Nao foi possivel fechar os emojis")
247
- console.error(e)
248
- }
249
- },
250
- away() {
251
- if(this.$refs[`${this.textId}-file`]) this.$refs[`${this.textId}-file`].openFiles = false
252
- },
253
- setDefaultMessage(msg) {
254
- this.message = msg
255
- this.sendFinalMessage()
256
- },
257
- insertEmoji(emoji) {
258
- try {
259
- if(!emoji) return
260
- const textarea = document.querySelector(`#text-footer-${this.textId}`)
261
- if (document.activeElement === textarea) {
262
- const cursorStart = textarea.selectionStart
263
- const cursorEnd = textarea.selectionEnd
264
- if (cursorEnd == textarea.value.length) {
265
- this.message += emoji.finalEmoji
266
- textarea.setSelectionRange(textarea.value.length, textarea.value.length);
267
- } else {
268
- const initValue = textarea.value.slice(0, cursorStart) + emoji.finalEmoji;
269
- const endValue = textarea.value.slice(cursorEnd)
270
- this.message = initValue + endValue
271
- textarea.setSelectionRange(initValue.length, initValue.length);
272
- }
273
- } else {
274
- this.message += emoji.finalEmoji
275
- }
276
- this.sendFinalMessage()
277
- }catch(e) {
278
- console.error("Erro ao inserir emoji")
279
- console.error(e)
280
- }
281
- },
282
- verifyMessage() {
283
- if(this.textareaSettings.maxCharacters && this.message) {
284
- if(this.message.length > this.textareaSettings.maxCharacters) {
285
- if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.limiteCaracter()
286
- return false
287
- }
288
- }
289
-
290
- if((!this.message || !this.message.trim()) && !this.hasAnyFile && !this.audioFile) return false
291
-
292
- if(this.textareaSettings.disabled) return false
293
-
294
- if(this.fileFormatError && this.hasAnyFile) {
295
- if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
296
- const str = {
297
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
298
- doc: this.fileSettings.docsExtensions.split("|").join(", ")
299
- }
300
- if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
301
- return false
302
- }
303
-
304
- return true
305
- },
306
- removeHTMLElementsFromMessage(message) {
307
- const regexTags = /<\/?[\d\w\s=\-:./'";]+>/gi
308
- if(message.match(regexTags)) message = message.replace(regexTags, ' ')
309
- return message
310
- },
311
- formatMessage(message) {
312
- if(!message) return ""
313
- message = message.trim()
314
- message = message.replace(/\n$/, "", message)
315
- message = returnMessageWithHexa(message)
316
- message = this.removeHTMLElementsFromMessage(message)
317
- return message
318
- },
319
- sendFinalMessage() {
320
- const messageAux = this.formatMessage(this.message)
321
- this.$emit("final-message", messageAux)
322
- },
323
- sendMessageHandler(event) {
324
- this.sendMessage(event)
325
- },
326
- sendMessage(event) {
327
- if(this.isSending) return
328
-
329
- if(this.isMainChat && event){
330
- if(this.textareaSettings.sendOnEnter){
331
- if(event.keyCode == 13 && !event.shiftKey) event.preventDefault()
332
- if(event.shiftKey) return
333
- }else{
334
- if(event.keyCode == 13) {
335
- if(!event.shiftKey) return
336
- event.preventDefault()
337
- }
338
- }
339
- }
340
-
341
- if(!this.buttons.hasSendButton) return
342
-
343
- const messageAux = this.formatMessage(this.message)
344
- if(this.verifyMessage()){
345
- if(messageAux || this.hasAnyFile || this.audioFile) {
346
- this.$emit("send-message", messageAux)
347
- const objMessage = this.returnObjectMessage(messageAux)
348
- this.$emit("obj-message", objMessage)
349
-
350
- if(this.$refs[`emoji-text-${this.textId}`] && this.$refs[`emoji-text-${this.textId}`].showEmojis) this.$refs[`emoji-text-${this.textId}`].toggleEmojiSelection()
351
-
352
- this.resetFooterData()
353
- }
354
- }
355
- },
356
- focusTextarea() {
357
- const textarea = document.querySelector(`#text-footer-${this.textId}`)
358
- if(textarea) textarea.focus()
359
- },
360
- resetFooterData() {
361
- if(this.audioFile) this.deleteAudio()
362
- if(this.hasAnyFile) this.$refs[`${this.textId}-file`].deleteFile()
363
- this.message = ""
364
- this.sendFinalMessage()
365
- resetTargets(this.$el, ".js-autoresize", ".js-parentresize", "38px")
366
- this.focusTextarea()
367
- },
368
- returnObjectMessage(message) {
369
- return {
370
- message,
371
- attachment: this.hasAnyFile ? this.file : false,
372
- isDoc: this.isDoc,
373
- imagePreview: this.imagePreview,
374
- isAudio: this.audioFile ? true : false,
375
- audioAttachment: this.audioSource
376
- }
377
- },
378
- setFileVars(fileObj) {
379
- const { file, imagePreview, isDoc, fileFormatError, hasAnyFile } = fileObj;
380
-
381
- this.file = file
382
- this.imagePreview = imagePreview ? imagePreview : ""
383
- this.isDoc = isDoc
384
- this.fileFormatError = fileFormatError
385
- this.hasAnyFile = hasAnyFile
386
-
387
- this.$emit("set-file-vars", fileObj)
388
- },
389
- openImage(imagePreview) {
390
- this.$emit("open-image", imagePreview)
391
- },
392
- openFileSystem() {
393
- this.$emit("open-file-system")
394
- },
395
- resetFileSystem() {
396
- this.$emit("reset-file-system")
397
- },
398
- setAudio(audioObj) {
399
- const { audioFile, audioSource } = audioObj
400
- this.audioFile = audioFile
401
- this.audioSource = audioSource
402
- },
403
- deleteAudio() {
404
- this.$refs[`${this.textId}-mic`].deleteMediaRecorder()
405
- this.audioFile = ""
406
- this.audioSource = ""
407
- },
408
- returnFileType(file, stopAlert) {
409
- if(!this.fileSettings.imagesExtensions && !this.fileSettings.docsExtensions) return false
410
- const imgRegex = new RegExp("\.("+this.fileSettings.imagesExtensions+")", "i")
411
- if(imgRegex.test(file.name)) return "img"
412
-
413
- const docRegex = new RegExp("\.("+this.fileSettings.docsExtensions+")", "i")
414
- if(docRegex.test(file.name)) return "doc"
415
-
416
- if(!stopAlert) return false
417
- if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
418
- const str = {
419
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
420
- doc: this.fileSettings.docsExtensions.split("|").join(", ")
421
- }
422
- if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
423
- return false
424
- },
425
- filesHandler(files) {
426
- if(!Array.isArray(files)) files = Array.from(files)
427
- const fileType = this.returnFileType(files[0], true)
428
- let invalidFile = false
429
- try {
430
- files.forEach(file => {
431
- const singleFileType = this.returnFileType(file, true)
432
- if(!singleFileType) {
433
- invalidFile = true
434
- file.invalid = true
435
- }
436
- file.imgOrDoc = singleFileType ? singleFileType : ""
437
- })
438
- }catch(e) {
439
- console.error("Erro ao tentar percorrer os arquivos")
440
- console.error(e)
441
- invalidFile = true
442
- }
443
-
444
- if(!invalidFile) {
445
- this.$refs[`${this.textId}-file`].fileUpload(files, fileType, true)
446
- }else {
447
- if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
448
- const str = {
449
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
450
- doc: this.fileSettings.docsExtensions.split("|").join(", ")
451
- }
452
- if (!document.querySelector(".toasted.toasted-primary.info")) this.$toasted.global.showValidFormats({ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}` })
453
- }
454
- },
455
- dropFile(e) {
456
- try {
457
- e.stopPropagation()
458
- e.preventDefault()
459
- if(!this.buttons.hasFiles || this.fileSettings.handleFileClick) return false
460
- const files = e.dataTransfer.files.length ? e.dataTransfer.files : ""
461
- this.filesHandler(files)
462
- }catch(e) {
463
- console.error("Erro drop file")
464
- console.error(e)
465
- }
466
- },
467
- pasteImage(e) {
468
- try {
469
- if(e.clipboardData.files.length && !this.buttons.hasFiles) {
470
- e.preventDefault()
471
- return
472
- }else if(e.clipboardData.files.length && this.buttons.hasFiles) {
473
- const files = e.clipboardData.files
474
- this.filesHandler(files)
475
- }
476
- }catch(e) {
477
- console.error("Nao foi possivel colar a/o imagem/documento")
478
- console.error(e)
479
- }
480
- },
481
- handleScreenShare() {
482
- this.$emit("handle-screen-share")
483
- },
484
- toggleStandardMessages() {
485
- this.showStandardMessages = !this.showStandardMessages
486
- },
487
- openBlockerStandardMessage() {
488
- this.$emit("open-blocker-standard-message")
489
- },
490
- closeBlockerStandardMessage() {
491
- this.$emit("close-blocker-standard-message")
492
- },
493
- setMessageType(type) {
494
- this.messageType = type
495
- },
496
- setStandardInfos(infos) {
497
- this.$emit("set-standard-infos", infos)
498
- },
499
- addStandardMessage(message) {
500
- this.message = message
501
- this.sendFinalMessage()
502
- },
503
- closeStandardMessages() {
504
- this.showStandardMessages = false
505
- }
506
- },
507
- destroyed() {
508
- // this.$root.$off("drop-file")
509
- // this.$root.$off("toggle-msg-formatada")
510
- // this.$root.$off("textarea-focus")
511
- // this.$root.$off("clear-footer-message")
512
- // this.$root.$off("resize-footer-template")
513
-
514
- window.removeEventListener("message", this.listenerPostMessage)
515
- }
516
- }
517
- </script>
518
-
519
- <style>
520
- .toasted svg {
521
- margin-right: 10px; }
522
-
523
- .d-none {
524
- display: none; }
525
-
526
- ul {
527
- list-style-type: none; }
528
-
529
- .text-footer-container {
530
- display: flex;
531
- justify-content: center;
532
- align-items: center;
533
- flex-direction: column;
534
- width: 100%;
535
- position: relative; }
536
- .text-footer-container .text-footer {
537
- min-height: 48px;
538
- box-shadow: 0px 3px 7px -2px rgba(0, 0, 0, 0.45);
539
- position: relative;
540
- display: flex;
541
- justify-content: center;
542
- align-items: center;
543
- border: 1px solid #ccc;
544
- padding: 5px 2px 5px 5px;
545
- border-radius: 5px; }
546
- .text-footer-container .text-footer.full {
547
- width: 100%; }
548
- .text-footer-container .text-footer.almostFull {
549
- width: 95%; }
550
- .text-footer-container .text-footer.medium {
551
- width: 75%; }
552
- .text-footer-container.bigger .text-footer {
553
- height: 80px;
554
- }
555
- .text-footer-container.bigger .text-footer > textarea {
556
- font-size: .875rem;
557
- height: 75px;
558
- max-height: 75px;
559
- min-height: 75px;
560
- }
561
- .text-footer-container textarea {
562
- margin: 0 5px;
563
- border: unset;
564
- flex: 1;
565
- resize: none;
566
- min-height: 30px;
567
- max-height: 60px;
568
- font-size: .875rem;
569
- font-family: inherit;
570
- background: inherit; }
571
- .text-footer-container textarea:focus {
572
- outline: unset; }
573
- .text-footer-container textarea::placeholder {
574
- font-size: .75rem;
575
- }
576
- .text-footer-container .text-footer-audio {
577
- flex: 1;
578
- display: flex;
579
- justify-content: center;
580
- align-items: center; }
581
- .text-footer-container audio {
582
- flex: 1;
583
- outline: unset;
584
- width: auto;
585
- height: 38px; }
586
- .text-footer-container .delete-audio {
587
- display: flex;
588
- justify-content: center;
589
- align-items: center;
590
- color: #E74C3C;
591
- transition: background 300ms;
592
- border-radius: 50%;
593
- font-size: 1rem;
594
- padding: 10px;
595
- cursor: pointer;
596
- margin: 0 5px;
597
- width: 31px;
598
- height: 31px; }
599
- .text-footer-container .delete-audio:hover {
600
- background-color: rgba(208, 0, 0, 0.2); }
601
- .text-footer-container .max-characters {
602
- font-size: .575rem;
603
- z-index: 1;
604
- color: #444;
605
- position: relative;
606
- top: 30px;
607
- left: -30px; }
608
- .text-footer-container .max-characters.no-width {
609
- width: 0; }
610
- .text-footer-container .text-footer-actions {
611
- display: flex; }
612
- .text-footer-container .text-footer-actions.outside-buttons {
613
- display: flex;
614
- align-items: center;
615
- justify-content: flex-end;
616
- position: absolute;
617
- top: -30px;
618
- right: 35px;
619
- background-color: #FAFAFA;
620
- }
621
- .text-footer-container .text-footer-actions .text-footer-actions--btn {
622
- display: flex;
623
- justify-content: center;
624
- align-items: center;
625
- color: #777;
626
- border-radius: 50%;
627
- transition: background 300ms;
628
- padding: 10px;
629
- font-size: 1rem;
630
- width: 36px;
631
- height: 36px;
632
- cursor: pointer;
633
- margin-right: 2.5px; }
634
- .text-footer-container .text-footer-actions .text-footer-actions--btn:last-child {
635
- margin-right: unset; }
636
- .text-footer-container .text-footer-actions .text-footer-actions--btn:hover {
637
- background-color: rgba(0, 0, 0, 0.1); }
638
- .text-footer-container .text-footer-actions .text-footer-actions--btn.files-activated {
639
- background-color: rgba(0, 0, 0, 0.1); }
640
- .text-footer-container .text-footer-actions .text-footer-actions--btn.audio-activated {
641
- background-color: rgba(208, 0, 0, 0.7);
642
- color: #fff; }
643
- .text-footer-container .text-footer-actions .text-footer-actions--btn.left-button {
644
- position: absolute;
645
- left: 0; }
646
- .text-footer-container .text-footer-hsm-container {
647
- margin: 12px 0 7px 0; }
648
- .text-footer-container .text-footer-hsm-container.full {
649
- width: 100%; }
650
- .text-footer-container .text-footer-hsm-container.almostFull {
651
- width: 95%; }
652
- .text-footer-container .text-footer-hsm-container.medium {
653
- width: 75%; }
654
- .text-footer-container .text-footer-hsm-container .text-footer-v-select {
655
- border-radius: 5px;
656
- margin-bottom: 5px; }
657
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 {
658
- display: flex;
659
- align-items: center;
660
- flex: 1;
661
- width: 100%; }
662
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 .text-footer-v-select {
663
- flex: 1; }
664
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 .text-footer--btn-select-03 {
665
- transition-duration: 300ms;
666
- user-select: none;
667
- cursor: pointer;
668
- box-shadow: inset 0 -3px rgba(0, 0, 0, 0.2);
669
- opacity: 0.9;
670
- border-radius: 2.5px;
671
- display: flex;
672
- justify-content: center;
673
- align-items: center;
674
- margin-left: 5px;
675
- margin-bottom: 5px;
676
- background-color: #F7FE72;
677
- width: 32px;
678
- height: 32px; }
679
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 .text-footer--btn-select-03:hover {
680
- opacity: 1; }
681
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 .text-footer--btn-select-03:active {
682
- opacity: 1;
683
- box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
684
- -webkit-transform: translateY(1px);
685
- -moz-transform: translateY(1px);
686
- -o-transform: translateY(1px);
687
- -ms-transform: translateY(1px);
688
- transform: translateY(1px); }
689
- .text-footer-container .text-footer-hsm-container .text-footer-select-03 .text-footer--btn-select-03 svg {
690
- font-size: 1rem; }
691
- .text-footer-container .text-footer-files-container {
692
- position: absolute;
693
- right: 0;
694
- top: -55px;
695
- padding: 5px;
696
- background-color: rgba(0, 0, 0, 0.4);
697
- border-radius: 5px;
698
- display: flex;
699
- align-items: center;
700
- justify-content: space-between;
701
- z-index: 1; }
702
- .text-footer-container .text-footer-files-container.horizontal {
703
- right: -55px;
704
- flex-direction: column; }
705
- .text-footer-container .text-footer-files-container .files-btn {
706
- transition-duration: 300ms;
707
- transition-property: opacity;
708
- opacity: .8;
709
- cursor: pointer;
710
- display: flex;
711
- justify-content: center;
712
- align-items: center;
713
- border-radius: 10px;
714
- padding: 3px;
715
- width: 40px;
716
- height: 40px;
717
- font-size: 1rem;
718
- color: #FFF; }
719
- .text-footer-container .text-footer-files-container .files-btn:hover {
720
- opacity: 1; }
721
- .text-footer-container .text-footer-files-container .files-btn svg {
722
- color: #FFF; }
723
- .text-footer-container .text-footer-files-container .files-btn.images {
724
- background-color: #9575cd;
725
- margin-right: 5px; }
726
- .text-footer-container .text-footer-files-container .files-btn.images.margin-bottom {
727
- margin-right: unset;
728
- margin-bottom: 5px; }
729
- .text-footer-container .text-footer-files-container .files-btn.docs {
730
- background-color: #7986cb; }
731
- .text-footer-container .text-footer-files-container .files-btn.system {
732
- background-color: #49a349;
733
- margin-left: 5px }
734
- .text-footer-container .text-footer-files-container .files-btn.both {
735
- font-size: .95rem;
736
- background-color: rgb(85, 85, 236);
737
- flex-direction: column;
738
- }
739
- .text-footer-container .text-footer-files-container .files-btn.both svg:nth-child(1) {
740
- transform: translateX(5px)
741
- }
742
- .text-footer-container .text-footer-files-container .files-btn.both svg:nth-child(2) {
743
- transform: translateX(-5px)
744
- }
745
-
746
- .text-footer-container .text-footer-preview-container {
747
- width: 100%;
748
- cursor: default;
749
- position: absolute;
750
- left: 0;
751
- background-color: #F1f1f1;
752
- border: 2px solid #CCC;
753
- border-bottom: unset;
754
- border-top-left-radius: 2.5px;
755
- border-top-right-radius: 2.5px; }
756
- .text-footer-container .text-footer-preview-container.isDoc {
757
- top: -50px;
758
- width: 100%;
759
- height: 45px; }
760
- .text-footer-container .text-footer-preview-container.isImg, .text-footer-container .text-footer-preview-container.isMultiple {
761
- top: -205px;
762
- width: 100%;
763
- height: 200px; }
764
- .text-footer-container .text-footer-preview-container.isImg .text-footer-image-preview {
765
- height: 170px; }
766
- .text-footer-container .text-footer-preview-container.isError {
767
- top: -80px;
768
- width: 100%;
769
- height: 75px; }
770
-
771
- .text-footer-container .text-footer-alt {
772
- margin-top: -12px;
773
- width: 100%;
774
- padding: 0 10px; }
775
- .text-footer-container .text-footer-alt .text-footer-out-session {
776
- margin-top: 12px; }
777
- .text-footer-container .text-footer-alt .text-footer-sem-24h {
778
- font-size: .8rem;
779
- text-align: right;
780
- font-weight: 600;
781
- letter-spacing: -0.5px;
782
- color: #dd7f0c;
783
- margin-top: 5px;
784
- position: absolute;
785
- right: 0; }
786
- .text-footer-container .text-footer-alt .sem-templates {
787
- margin-top: 10px;
788
- font-size: .8rem;
789
- text-align: right;
790
- font-weight: 600;
791
- letter-spacing: -0.5px;
792
- color: #921e12; }
793
- .text-footer-container .text-footer-alt .text-footer-templates {
794
- position: relative;
795
- width: 100%; }
796
- .text-footer-container .text-footer-alt .text-footer-templates .text-footer-group-selection {
797
- width: 100%;
798
- display: flex;
799
- align-items: center; }
800
- .text-footer-container .text-footer-alt .text-footer-templates .text-footer-group-selection h4 {
801
- margin-right: 5px; }
802
- .text-footer-container .text-footer-alt .text-footer-templates .text-footer-group-selection .sm__select {
803
- flex: 1; }
804
-
805
- .vs__dropdown-menu {
806
- font-size: 0.85rem !important; }
807
-
808
- .emoji-mart-anchor, .emoji-mart-emoji span {
809
- cursor: pointer !important; }
810
-
811
- .emoji-mart {
812
- z-index: 2 !important; }
813
-
814
- .emoji-mart-scroll {
815
- overflow-x: hidden; }
816
-
817
- </style>
1
+ <template>
2
+ <div
3
+ class="text-footer-container"
4
+ :class="{ bigger: cssStyle.height }"
5
+ v-on-clickaway="away"
6
+ v-if="textId"
7
+ @drop.stop="dropFile"
8
+ @dragenter.prevent
9
+ @dragover.prevent
10
+ >
11
+ <div
12
+ class="text-footer"
13
+ :class="cssStyle.width ? cssStyle.width : ''"
14
+ :style="`background-color: ${cssStyle.backgroundColor}`"
15
+ >
16
+ <BtnEmojis
17
+ v-show="buttons.hasEmojis && !audioFile"
18
+ :ref="`${this.textId}`"
19
+ :emojiId="`${this.textId}`"
20
+ :down="emojiSettings.openEmojisFrom == 'top' ? false : true"
21
+ :small="emojiSettings.smallEmojis"
22
+ :biggerTextarea="cssStyle.height ? true : false"
23
+ @insert-emoji="insertEmoji"
24
+ />
25
+ <transition name="fade">
26
+ <Loader v-if="isSending" />
27
+ </transition>
28
+ <textarea
29
+ class="js-autoresize"
30
+ v-if="!audioFile"
31
+ v-model="message"
32
+ :id="`text-footer-${this.textId}`"
33
+ :disabled="textareaSettings.disabled"
34
+ :placeholder="textareaSettings.placeholderMessage"
35
+ @input="sendFinalMessage"
36
+ @keydown.up="toggleStandardMessages"
37
+ @keydown.down="toggleStandardMessages"
38
+ @keydown.esc="closeEmojis"
39
+ @keydown.enter="sendMessageHandler"
40
+ @paste="pasteImage"
41
+ ></textarea>
42
+ <div class="text-footer-audio" v-else>
43
+ <div>
44
+ <audio :src="audioSource" controls="controls"></audio>
45
+ </div>
46
+
47
+ <span class="delete-audio" title="Cancelar" @click="deleteAudio">
48
+ <fa-icon :icon="['fas', 'times']" />
49
+ </span>
50
+ </div>
51
+ <RemainingCharacters
52
+ :class="{ 'd-none': audioFile }"
53
+ :message="message"
54
+ :maxCharacters="textareaSettings.maxCharacters"
55
+ />
56
+ <div
57
+ v-if="
58
+ buttons.hasFiles ||
59
+ buttons.hasAudio ||
60
+ buttons.hasExpand ||
61
+ formattedMessageSettings.hasStandardMessages ||
62
+ buttons.hasScreenShare ||
63
+ buttons.hasDownloadAll
64
+ "
65
+ class="text-footer-actions"
66
+ :class="{ 'outside-buttons': cssStyle.outsideButtons && !audioFile }"
67
+ >
68
+ <BtnDownloadAllFiles
69
+ v-show="buttons.hasDownloadAll && !audioFile"
70
+ @click-trigger="$emit('handle-download-files')"
71
+ :dictionary="dictionary"
72
+ :ref="`${textId}-download-files`"
73
+ />
74
+ <BtnScreenShare
75
+ v-show="buttons.hasScreenShare && !audioFile"
76
+ @handle-screen-share="handleScreenShare"
77
+ :dictionary="dictionary"
78
+ :ref="`${textId}-screen-share`"
79
+ />
80
+ <BtnMic
81
+ v-show="buttons.hasAudio && !audioFile"
82
+ :dictionary="dictionary"
83
+ @set-audio="setAudio"
84
+ :ref="`${textId}-mic`"
85
+ />
86
+ <BtnStandardMessages
87
+ v-show="formattedMessageSettings.hasStandardMessages && !audioFile"
88
+ :dictionary="dictionary"
89
+ :ref="`${textId}-standard-messages`"
90
+ @toggle-standard-messages="toggleStandardMessages"
91
+ />
92
+ <BtnFiles
93
+ v-show="buttons.hasFiles && !audioFile"
94
+ :textId="textId"
95
+ :dictionary="dictionary"
96
+ :fileSettings="fileSettings"
97
+ :cssStyle="cssStyle"
98
+ :ref="`${textId}-file`"
99
+ :hasButtonFiles="hasButtonFiles"
100
+ :externalFiles="externalFiles"
101
+ @set-file-vars="setFileVars"
102
+ @open-image="openImage"
103
+ @open-file-system="openFileSystem"
104
+ @reset-file-system="resetFileSystem"
105
+ @handle-file-preview="$emit('handle-file-preview')"
106
+ @handle-file-click="$emit('handle-file-click')"
107
+ />
108
+ <BtnExpand
109
+ v-show="buttons.hasExpand && !audioFile"
110
+ :ref="`${textId}-expand`"
111
+ @expand-textarea="$emit('expand-textarea')"
112
+ :dictionary="dictionary"
113
+ />
114
+ </div>
115
+ <div class="text-footer-actions" v-if="buttons.hasSendButton">
116
+ <span
117
+ class="text-footer-actions--btn"
118
+ :title="dictionary.title_enviar_msg"
119
+ @click="sendMessageHandler"
120
+ >
121
+ <fa-icon :icon="['fas', 'paper-plane']" />
122
+ </span>
123
+ </div>
124
+ </div>
125
+ <transition name="fade">
126
+ <StandardMessages
127
+ v-if="showStandardMessages"
128
+ :class="cssStyle.width ? cssStyle.width : ''"
129
+ :dictionary="dictionary"
130
+ :backgroundColor="cssStyle.backgroundColor"
131
+ :token_cliente="
132
+ formattedMessageSettings.token_cliente
133
+ ? formattedMessageSettings.token_cliente
134
+ : ''
135
+ "
136
+ :message="message"
137
+ :messageType="messageType"
138
+ :hasStandardMessages="
139
+ formattedMessageSettings.hasStandardMessages && showStandardMessages
140
+ "
141
+ @close-standard-messages="closeStandardMessages"
142
+ @open-blocker-standard-message="openBlockerStandardMessage"
143
+ @close-blocker-standard-message="closeBlockerStandardMessage"
144
+ @set-message-type="setMessageType"
145
+ @set-standard-infos="setStandardInfos"
146
+ @add-standard-message="addStandardMessage"
147
+ @error-standard-message="$emit('error-standard-message')"
148
+ />
149
+ </transition>
150
+ </div>
151
+ </template>
152
+
153
+ <script>
154
+ import { setResizeListeners, resetTargets } from "../../services/autoResize";
155
+ import { mixin as clickaway } from "vue-clickaway";
156
+ import { returnMessageWithHexa } from "../../services/textFormatting";
157
+
158
+ import BtnEmojis from "./BtnEmojis";
159
+ import Loader from "../Loader/Loader";
160
+ import RemainingCharacters from "./RemainingCharacters";
161
+ import BtnMic from "./BtnMic";
162
+ import BtnFiles from "./BtnFiles";
163
+ import BtnExpand from "./BtnExpand";
164
+ import BtnStandardMessages from "./BtnStandardMessages";
165
+ import StandardMessages from "./StandardMessages";
166
+ import BtnScreenShare from "./BtnScreenShare";
167
+ import BtnDownloadAllFiles from "./BtnDownloadAllFiles";
168
+
169
+ export default {
170
+ components: {
171
+ BtnEmojis,
172
+ Loader,
173
+ BtnMic,
174
+ BtnFiles,
175
+ BtnExpand,
176
+ RemainingCharacters,
177
+ BtnStandardMessages,
178
+ StandardMessages,
179
+ BtnScreenShare,
180
+ BtnDownloadAllFiles,
181
+ },
182
+ mixins: [clickaway],
183
+ props: {
184
+ buttons: {
185
+ type: Object,
186
+ default: () => {
187
+ return {
188
+ hasEmojis: false,
189
+ hasSendButton: false,
190
+ hasFiles: false,
191
+ hasAudio: false,
192
+ hasExpand: false,
193
+ hasScreenShare: false,
194
+ };
195
+ },
196
+ required: false,
197
+ },
198
+ cssStyle: {
199
+ type: Object,
200
+ default: () => {
201
+ return {
202
+ height: false,
203
+ width: "full",
204
+ backgroundColor: "#FFF",
205
+ outsideButtons: false,
206
+ };
207
+ },
208
+ required: false,
209
+ },
210
+ textareaSettings: {
211
+ type: Object,
212
+ default: () => {
213
+ return {
214
+ placeholderMessage: "",
215
+ maxCharacters: 0,
216
+ sendOnEnter: false,
217
+ disabled: false,
218
+ };
219
+ },
220
+ required: false,
221
+ },
222
+ emojiSettings: {
223
+ type: Object,
224
+ default: () => {
225
+ return { openEmojisFrom: "top", smallEmojis: false };
226
+ },
227
+ required: false,
228
+ },
229
+ formattedMessageSettings: {
230
+ type: Object,
231
+ default: () => {
232
+ return { hasStandardMessages: false, msgType: 0, token_cliente: "" };
233
+ },
234
+ required: false,
235
+ },
236
+ fileSettings: {
237
+ type: Object,
238
+ default: () => {
239
+ return {
240
+ docsExtensions: "",
241
+ imagesExtensions: "",
242
+ multiple: false,
243
+ systemButton: false,
244
+ max: 3,
245
+ handleFilePreview: false,
246
+ filePreviewStyle: 1,
247
+ stackFiles: false,
248
+ handleFileClick: false,
249
+ };
250
+ },
251
+ required: false,
252
+ },
253
+ textId: {
254
+ type: String,
255
+ required: true,
256
+ },
257
+ isMainChat: {
258
+ type: Boolean,
259
+ default: false,
260
+ required: false,
261
+ },
262
+ isSending: {
263
+ type: Boolean,
264
+ default: false,
265
+ required: false,
266
+ },
267
+ dictionary: {
268
+ type: Object,
269
+ required: true,
270
+ },
271
+ hasButtonFiles: {
272
+ type: Boolean,
273
+ required: false,
274
+ },
275
+ externalFiles: {
276
+ type: Array,
277
+ required: false,
278
+ },
279
+ },
280
+ data() {
281
+ return {
282
+ message: "",
283
+ openFiles: false,
284
+ file: [],
285
+ hasAnyFile: false,
286
+ imagePreview: "",
287
+ isDoc: false,
288
+ fileFormatError: false,
289
+ audioFile: "",
290
+ audioSource: "",
291
+ showStandardMessages: false,
292
+ messageType: 1,
293
+ };
294
+ },
295
+ created() {
296
+ this.$root.$refs[`tf-${this.textId}`] = this;
297
+ },
298
+ mounted() {
299
+ setResizeListeners(this.$el, ".js-autoresize", ".js-parentresize");
300
+ window.addEventListener("message", this.listenerPostMessage, false);
301
+
302
+ // this.$root.$on("drop-file", (file, type) => { if(this.buttons.hasFiles) this.fileUpload(file, type, true) })
303
+ // this.$root.$on("toggle-msg-formatada", () => { this.toggleStandardMessages() })
304
+ // this.$root.$on("textarea-focus", () => { this.focusTextarea() })
305
+ // this.$root.$on("resize-footer-template", () => { this.adjustChatHeight() })
306
+ // this.$root.$on("clear-footer-message", () => { this.message = "" })
307
+ // if(this.cssStyle.outsideButtons) if(this.$root.$refs.chatCorpo) this.$root.$refs.chatCorpo.setOutsideButtons(this.cssStyle.outsideButtons)
308
+ },
309
+ methods: {
310
+ listenerPostMessage(event) {
311
+ const baseURL =
312
+ window.location.hostname == "localhost"
313
+ ? `https://linux07`
314
+ : `https://${window.location.hostname}`;
315
+ if (!this.formattedMessageSettings.hasStandardMessages) return;
316
+ if (
317
+ event.data.gerenciador ||
318
+ event.data.abrirFishing ||
319
+ event.data.multiplos_contatos ||
320
+ event.data.inserir_cliente_omni ||
321
+ event.data.multiple_contatos
322
+ )
323
+ return;
324
+ if (event.origin == baseURL) {
325
+ if (event.data == "" && this.showStandardMessages) {
326
+ this.closeBlockerStandardMessage();
327
+ this.toggleStandardMessages();
328
+ this.$toasted.global.defaultInfo({
329
+ msg: this.dictionary.msg_erro_sem_msg_formatada,
330
+ });
331
+ } else if (
332
+ typeof event.data === "string" &&
333
+ this.showStandardMessages
334
+ ) {
335
+ this.message = event.data;
336
+ this.focusTextarea();
337
+ this.closeBlockerStandardMessage();
338
+ this.toggleStandardMessages();
339
+ }
340
+ }
341
+ },
342
+ closeEmojis() {
343
+ try {
344
+ this.$root.$refs[`etf-${this.textId}`].showEmojis
345
+ ? this.$root.$refs[`etf-${this.textId}`].away()
346
+ : "";
347
+ } catch (e) {
348
+ console.error("Nao foi possivel fechar os emojis");
349
+ console.error(e);
350
+ }
351
+ },
352
+ away() {
353
+ if (this.$refs[`${this.textId}-file`])
354
+ this.$refs[`${this.textId}-file`].openFiles = false;
355
+ },
356
+ setDefaultMessage(msg) {
357
+ this.message = msg;
358
+ this.sendFinalMessage();
359
+ },
360
+ insertEmoji(emoji) {
361
+ try {
362
+ if (!emoji) return;
363
+ const textarea = document.querySelector(`#text-footer-${this.textId}`);
364
+ if (document.activeElement === textarea) {
365
+ const cursorStart = textarea.selectionStart;
366
+ const cursorEnd = textarea.selectionEnd;
367
+ if (cursorEnd == textarea.value.length) {
368
+ this.message += emoji.finalEmoji;
369
+ textarea.setSelectionRange(
370
+ textarea.value.length,
371
+ textarea.value.length
372
+ );
373
+ } else {
374
+ const initValue =
375
+ textarea.value.slice(0, cursorStart) + emoji.finalEmoji;
376
+ const endValue = textarea.value.slice(cursorEnd);
377
+ this.message = initValue + endValue;
378
+ textarea.setSelectionRange(initValue.length, initValue.length);
379
+ }
380
+ } else {
381
+ this.message += emoji.finalEmoji;
382
+ }
383
+ this.sendFinalMessage();
384
+ } catch (e) {
385
+ console.error("Erro ao inserir emoji");
386
+ console.error(e);
387
+ }
388
+ },
389
+ verifyMessage() {
390
+ if (this.textareaSettings.maxCharacters && this.message) {
391
+ if (this.message.length > this.textareaSettings.maxCharacters) {
392
+ if (!document.querySelector(".toasted.toasted-primary.error"))
393
+ this.$toasted.global.limiteCaracter();
394
+ return false;
395
+ }
396
+ }
397
+
398
+ if (
399
+ (!this.message || !this.message.trim()) &&
400
+ !this.hasAnyFile &&
401
+ !this.audioFile
402
+ )
403
+ return false;
404
+
405
+ if (this.textareaSettings.disabled) return false;
406
+
407
+ if (this.fileFormatError && this.hasAnyFile) {
408
+ if (!document.querySelector(".toasted.toasted-primary.error"))
409
+ this.$toasted.global.defaultError({
410
+ msg: this.dictionary.msg_formato_invalido,
411
+ });
412
+ const str = {
413
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
414
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
415
+ };
416
+ if (!document.querySelector(".toasted.toasted-primary.info"))
417
+ this.$toasted.global.showValidFormats({
418
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
419
+ });
420
+ return false;
421
+ }
422
+
423
+ return true;
424
+ },
425
+ removeHTMLElementsFromMessage(message) {
426
+ const regexTags = /<\/?[\d\w\s=\-:./'";]+>/gi;
427
+ if (message.match(regexTags)) message = message.replace(regexTags, " ");
428
+ return message;
429
+ },
430
+ formatMessage(message) {
431
+ if (!message) return "";
432
+ message = message.trim();
433
+ message = message.replace(/\n$/, "", message);
434
+ message = returnMessageWithHexa(message);
435
+ message = this.removeHTMLElementsFromMessage(message);
436
+ return message;
437
+ },
438
+ sendFinalMessage() {
439
+ const messageAux = this.formatMessage(this.message);
440
+ this.$emit("final-message", messageAux);
441
+ },
442
+ sendMessageHandler(event) {
443
+ this.sendMessage(event);
444
+ },
445
+ sendMessage(event) {
446
+ if (this.isSending) return;
447
+
448
+ if (this.isMainChat && event) {
449
+ if (this.textareaSettings.sendOnEnter) {
450
+ if (event.keyCode == 13 && !event.shiftKey) event.preventDefault();
451
+ if (event.shiftKey) return;
452
+ } else {
453
+ if (event.keyCode == 13) {
454
+ if (!event.shiftKey) return;
455
+ event.preventDefault();
456
+ }
457
+ }
458
+ }
459
+
460
+ if (!this.buttons.hasSendButton) return;
461
+
462
+ const messageAux = this.formatMessage(this.message);
463
+ if (this.verifyMessage()) {
464
+ if (messageAux || this.hasAnyFile || this.audioFile) {
465
+ this.$emit("send-message", messageAux);
466
+ const objMessage = this.returnObjectMessage(messageAux);
467
+ this.$emit("obj-message", objMessage);
468
+
469
+ if (
470
+ this.$refs[`emoji-text-${this.textId}`] &&
471
+ this.$refs[`emoji-text-${this.textId}`].showEmojis
472
+ )
473
+ this.$refs[`emoji-text-${this.textId}`].toggleEmojiSelection();
474
+
475
+ this.resetFooterData();
476
+ }
477
+ }
478
+ },
479
+ focusTextarea() {
480
+ const textarea = document.querySelector(`#text-footer-${this.textId}`);
481
+ if (textarea) textarea.focus();
482
+ },
483
+ resetFooterData() {
484
+ if (this.audioFile) this.deleteAudio();
485
+ if (this.hasAnyFile) this.$refs[`${this.textId}-file`].deleteFile();
486
+ this.message = "";
487
+ this.sendFinalMessage();
488
+ resetTargets(this.$el, ".js-autoresize", ".js-parentresize", "38px");
489
+ this.focusTextarea();
490
+ },
491
+ returnObjectMessage(message) {
492
+ return {
493
+ message,
494
+ attachment: this.hasAnyFile ? this.file : false,
495
+ isDoc: this.isDoc,
496
+ imagePreview: this.imagePreview,
497
+ isAudio: this.audioFile ? true : false,
498
+ audioAttachment: this.audioSource,
499
+ };
500
+ },
501
+ setFileVars(fileObj) {
502
+ const {
503
+ file,
504
+ imagePreview,
505
+ isDoc,
506
+ fileFormatError,
507
+ hasAnyFile,
508
+ } = fileObj;
509
+
510
+ this.file = file;
511
+ this.imagePreview = imagePreview ? imagePreview : "";
512
+ this.isDoc = isDoc;
513
+ this.fileFormatError = fileFormatError;
514
+ this.hasAnyFile = hasAnyFile;
515
+
516
+ this.$emit("set-file-vars", fileObj);
517
+ },
518
+ openImage(imagePreview) {
519
+ this.$emit("open-image", imagePreview);
520
+ },
521
+ openFileSystem() {
522
+ this.$emit("open-file-system");
523
+ },
524
+ resetFileSystem() {
525
+ this.$emit("reset-file-system");
526
+ },
527
+ setAudio(audioObj) {
528
+ const { audioFile, audioSource } = audioObj;
529
+ this.audioFile = audioFile;
530
+ this.audioSource = audioSource;
531
+ },
532
+ deleteAudio() {
533
+ this.$refs[`${this.textId}-mic`].deleteMediaRecorder();
534
+ this.audioFile = "";
535
+ this.audioSource = "";
536
+ },
537
+ returnFileType(file, stopAlert) {
538
+ if (
539
+ !this.fileSettings.imagesExtensions &&
540
+ !this.fileSettings.docsExtensions
541
+ )
542
+ return false;
543
+ const imgRegex = new RegExp(
544
+ "\.(" + this.fileSettings.imagesExtensions + ")",
545
+ "i"
546
+ );
547
+ if (imgRegex.test(file.name)) return "img";
548
+
549
+ const docRegex = new RegExp(
550
+ "\.(" + this.fileSettings.docsExtensions + ")",
551
+ "i"
552
+ );
553
+ if (docRegex.test(file.name)) return "doc";
554
+
555
+ if (!stopAlert) return false;
556
+ if (!document.querySelector(".toasted.toasted-primary.error"))
557
+ this.$toasted.global.defaultError({
558
+ msg: this.dictionary.msg_formato_invalido,
559
+ });
560
+ const str = {
561
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
562
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
563
+ };
564
+ if (!document.querySelector(".toasted.toasted-primary.info"))
565
+ this.$toasted.global.showValidFormats({
566
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
567
+ });
568
+ return false;
569
+ },
570
+ filesHandler(files) {
571
+ if (!Array.isArray(files)) files = Array.from(files);
572
+ const fileType = this.returnFileType(files[0], true);
573
+ let invalidFile = false;
574
+ try {
575
+ files.forEach((file) => {
576
+ const singleFileType = this.returnFileType(file, true);
577
+ if (!singleFileType) {
578
+ invalidFile = true;
579
+ file.invalid = true;
580
+ }
581
+ file.imgOrDoc = singleFileType ? singleFileType : "";
582
+ });
583
+ } catch (e) {
584
+ console.error("Erro ao tentar percorrer os arquivos");
585
+ console.error(e);
586
+ invalidFile = true;
587
+ }
588
+
589
+ if (!invalidFile) {
590
+ this.$refs[`${this.textId}-file`].fileUpload(files, fileType, true);
591
+ } else {
592
+ if (!document.querySelector(".toasted.toasted-primary.error"))
593
+ this.$toasted.global.defaultError({
594
+ msg: this.dictionary.msg_formato_invalido,
595
+ });
596
+ const str = {
597
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
598
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
599
+ };
600
+ if (!document.querySelector(".toasted.toasted-primary.info"))
601
+ this.$toasted.global.showValidFormats({
602
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
603
+ });
604
+ }
605
+ },
606
+ dropFile(e) {
607
+ try {
608
+ e.stopPropagation();
609
+ e.preventDefault();
610
+ if (!this.buttons.hasFiles || this.fileSettings.handleFileClick)
611
+ return false;
612
+ const files = e.dataTransfer.files.length ? e.dataTransfer.files : "";
613
+ this.filesHandler(files);
614
+ } catch (e) {
615
+ console.error("Erro drop file");
616
+ console.error(e);
617
+ }
618
+ },
619
+ pasteImage(e) {
620
+ try {
621
+ if (e.clipboardData.files.length && !this.buttons.hasFiles) {
622
+ e.preventDefault();
623
+ return;
624
+ } else if (e.clipboardData.files.length && this.buttons.hasFiles) {
625
+ const files = e.clipboardData.files;
626
+ this.filesHandler(files);
627
+ }
628
+ } catch (e) {
629
+ console.error("Nao foi possivel colar a/o imagem/documento");
630
+ console.error(e);
631
+ }
632
+ },
633
+ handleScreenShare() {
634
+ this.$emit("handle-screen-share");
635
+ },
636
+ toggleStandardMessages() {
637
+ this.showStandardMessages = !this.showStandardMessages;
638
+ },
639
+ openBlockerStandardMessage() {
640
+ this.$emit("open-blocker-standard-message");
641
+ },
642
+ closeBlockerStandardMessage() {
643
+ this.$emit("close-blocker-standard-message");
644
+ },
645
+ setMessageType(type) {
646
+ this.messageType = type;
647
+ },
648
+ setStandardInfos(infos) {
649
+ this.$emit("set-standard-infos", infos);
650
+ },
651
+ addStandardMessage(message) {
652
+ this.message = message;
653
+ this.sendFinalMessage();
654
+ },
655
+ closeStandardMessages() {
656
+ this.showStandardMessages = false;
657
+ },
658
+ },
659
+ destroyed() {
660
+ // this.$root.$off("drop-file")
661
+ // this.$root.$off("toggle-msg-formatada")
662
+ // this.$root.$off("textarea-focus")
663
+ // this.$root.$off("clear-footer-message")
664
+ // this.$root.$off("resize-footer-template")
665
+
666
+ window.removeEventListener("message", this.listenerPostMessage);
667
+ },
668
+ };
669
+ </script>
670
+
671
+ <style>
672
+ .toasted svg {
673
+ margin-right: 10px;
674
+ }
675
+
676
+ .d-none {
677
+ display: none;
678
+ }
679
+
680
+ ul {
681
+ list-style-type: none;
682
+ }
683
+
684
+ .text-footer-container {
685
+ display: flex;
686
+ justify-content: center;
687
+ align-items: center;
688
+ flex-direction: column;
689
+ width: 100%;
690
+ position: relative;
691
+ }
692
+ .text-footer-container .text-footer {
693
+ min-height: 48px;
694
+ box-shadow: 0px 3px 7px -2px rgba(0, 0, 0, 0.45);
695
+ position: relative;
696
+ display: flex;
697
+ justify-content: center;
698
+ align-items: center;
699
+ border: 1px solid #ccc;
700
+ padding: 5px 2px 5px 5px;
701
+ border-radius: 5px;
702
+ }
703
+ .text-footer-container .text-footer.full {
704
+ width: 100%;
705
+ }
706
+ .text-footer-container .text-footer.almostFull {
707
+ width: 95%;
708
+ }
709
+ .text-footer-container .text-footer.medium {
710
+ width: 75%;
711
+ }
712
+ .text-footer-container.bigger .text-footer {
713
+ height: 80px;
714
+ }
715
+ .text-footer-container.bigger .text-footer > textarea {
716
+ font-size: 0.875rem;
717
+ height: 75px;
718
+ max-height: 75px;
719
+ min-height: 75px;
720
+ }
721
+ .text-footer-container textarea {
722
+ margin: 0 5px;
723
+ border: unset;
724
+ flex: 1;
725
+ resize: none;
726
+ min-height: 30px;
727
+ max-height: 60px;
728
+ font-size: 0.875rem;
729
+ font-family: inherit;
730
+ background: inherit;
731
+ }
732
+ .text-footer-container textarea:focus {
733
+ outline: unset;
734
+ }
735
+ .text-footer-container textarea::placeholder {
736
+ font-size: 0.75rem;
737
+ }
738
+ .text-footer-container .text-footer-audio {
739
+ flex: 1;
740
+ display: flex;
741
+ justify-content: center;
742
+ align-items: center;
743
+ }
744
+ .text-footer-container audio {
745
+ flex: 1;
746
+ outline: unset;
747
+ width: auto;
748
+ height: 38px;
749
+ }
750
+ .text-footer-container .delete-audio {
751
+ display: flex;
752
+ justify-content: center;
753
+ align-items: center;
754
+ color: #e74c3c;
755
+ transition: background 300ms;
756
+ border-radius: 50%;
757
+ font-size: 1rem;
758
+ padding: 10px;
759
+ cursor: pointer;
760
+ margin: 0 5px;
761
+ width: 31px;
762
+ height: 31px;
763
+ }
764
+ .text-footer-container .delete-audio:hover {
765
+ background-color: rgba(208, 0, 0, 0.2);
766
+ }
767
+ .text-footer-container .max-characters {
768
+ font-size: 0.575rem;
769
+ z-index: 1;
770
+ color: #444;
771
+ position: relative;
772
+ top: 30px;
773
+ left: -30px;
774
+ }
775
+ .text-footer-container .max-characters.no-width {
776
+ width: 0;
777
+ }
778
+ .text-footer-container .text-footer-actions {
779
+ display: flex;
780
+ }
781
+ .text-footer-container .text-footer-actions.outside-buttons {
782
+ display: flex;
783
+ align-items: center;
784
+ justify-content: flex-end;
785
+ position: absolute;
786
+ top: -30px;
787
+ right: 35px;
788
+ background-color: #fafafa;
789
+ }
790
+ .text-footer-container .text-footer-actions .text-footer-actions--btn {
791
+ display: flex;
792
+ justify-content: center;
793
+ align-items: center;
794
+ color: #777;
795
+ border-radius: 50%;
796
+ transition: background 300ms;
797
+ padding: 10px;
798
+ font-size: 1rem;
799
+ width: 36px;
800
+ height: 36px;
801
+ cursor: pointer;
802
+ margin-right: 2.5px;
803
+ }
804
+ .text-footer-container
805
+ .text-footer-actions
806
+ .text-footer-actions--btn:last-child {
807
+ margin-right: unset;
808
+ }
809
+ .text-footer-container .text-footer-actions .text-footer-actions--btn:hover {
810
+ background-color: rgba(0, 0, 0, 0.1);
811
+ }
812
+ .text-footer-container
813
+ .text-footer-actions
814
+ .text-footer-actions--btn.files-activated {
815
+ background-color: rgba(0, 0, 0, 0.1);
816
+ }
817
+ .text-footer-container
818
+ .text-footer-actions
819
+ .text-footer-actions--btn.audio-activated {
820
+ background-color: rgba(208, 0, 0, 0.7);
821
+ color: #fff;
822
+ }
823
+ .text-footer-container
824
+ .text-footer-actions
825
+ .text-footer-actions--btn.left-button {
826
+ position: absolute;
827
+ left: 0;
828
+ }
829
+ .text-footer-container .text-footer-hsm-container {
830
+ margin: 12px 0 7px 0;
831
+ }
832
+ .text-footer-container .text-footer-hsm-container.full {
833
+ width: 100%;
834
+ }
835
+ .text-footer-container .text-footer-hsm-container.almostFull {
836
+ width: 95%;
837
+ }
838
+ .text-footer-container .text-footer-hsm-container.medium {
839
+ width: 75%;
840
+ }
841
+ .text-footer-container .text-footer-hsm-container .text-footer-v-select {
842
+ border-radius: 5px;
843
+ margin-bottom: 5px;
844
+ }
845
+ .text-footer-container .text-footer-hsm-container .text-footer-select-03 {
846
+ display: flex;
847
+ align-items: center;
848
+ flex: 1;
849
+ width: 100%;
850
+ }
851
+ .text-footer-container
852
+ .text-footer-hsm-container
853
+ .text-footer-select-03
854
+ .text-footer-v-select {
855
+ flex: 1;
856
+ }
857
+ .text-footer-container
858
+ .text-footer-hsm-container
859
+ .text-footer-select-03
860
+ .text-footer--btn-select-03 {
861
+ transition-duration: 300ms;
862
+ user-select: none;
863
+ cursor: pointer;
864
+ box-shadow: inset 0 -3px rgba(0, 0, 0, 0.2);
865
+ opacity: 0.9;
866
+ border-radius: 2.5px;
867
+ display: flex;
868
+ justify-content: center;
869
+ align-items: center;
870
+ margin-left: 5px;
871
+ margin-bottom: 5px;
872
+ background-color: #f7fe72;
873
+ width: 32px;
874
+ height: 32px;
875
+ }
876
+ .text-footer-container
877
+ .text-footer-hsm-container
878
+ .text-footer-select-03
879
+ .text-footer--btn-select-03:hover {
880
+ opacity: 1;
881
+ }
882
+ .text-footer-container
883
+ .text-footer-hsm-container
884
+ .text-footer-select-03
885
+ .text-footer--btn-select-03:active {
886
+ opacity: 1;
887
+ box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
888
+ -webkit-transform: translateY(1px);
889
+ -moz-transform: translateY(1px);
890
+ -o-transform: translateY(1px);
891
+ -ms-transform: translateY(1px);
892
+ transform: translateY(1px);
893
+ }
894
+ .text-footer-container
895
+ .text-footer-hsm-container
896
+ .text-footer-select-03
897
+ .text-footer--btn-select-03
898
+ svg {
899
+ font-size: 1rem;
900
+ }
901
+ .text-footer-container .text-footer-files-container {
902
+ position: absolute;
903
+ right: 0;
904
+ top: -55px;
905
+ padding: 5px;
906
+ background-color: rgba(0, 0, 0, 0.4);
907
+ border-radius: 5px;
908
+ display: flex;
909
+ align-items: center;
910
+ justify-content: space-between;
911
+ z-index: 1;
912
+ }
913
+ .text-footer-container .text-footer-files-container.horizontal {
914
+ right: -55px;
915
+ flex-direction: column;
916
+ }
917
+ .text-footer-container .text-footer-files-container .files-btn {
918
+ transition-duration: 300ms;
919
+ transition-property: opacity;
920
+ opacity: 0.8;
921
+ cursor: pointer;
922
+ display: flex;
923
+ justify-content: center;
924
+ align-items: center;
925
+ border-radius: 10px;
926
+ padding: 3px;
927
+ width: 40px;
928
+ height: 40px;
929
+ font-size: 1rem;
930
+ color: #fff;
931
+ }
932
+ .text-footer-container .text-footer-files-container .files-btn:hover {
933
+ opacity: 1;
934
+ }
935
+ .text-footer-container .text-footer-files-container .files-btn svg {
936
+ color: #fff;
937
+ }
938
+ .text-footer-container .text-footer-files-container .files-btn.images {
939
+ background-color: #9575cd;
940
+ margin-right: 5px;
941
+ }
942
+ .text-footer-container
943
+ .text-footer-files-container
944
+ .files-btn.images.margin-bottom {
945
+ margin-right: unset;
946
+ margin-bottom: 5px;
947
+ }
948
+ .text-footer-container .text-footer-files-container .files-btn.docs {
949
+ background-color: #7986cb;
950
+ }
951
+ .text-footer-container .text-footer-files-container .files-btn.system {
952
+ background-color: #49a349;
953
+ margin-left: 5px;
954
+ }
955
+ .text-footer-container .text-footer-files-container .files-btn.both {
956
+ font-size: 0.95rem;
957
+ background-color: rgb(85, 85, 236);
958
+ flex-direction: column;
959
+ }
960
+ .text-footer-container
961
+ .text-footer-files-container
962
+ .files-btn.both
963
+ svg:nth-child(1) {
964
+ transform: translateX(5px);
965
+ }
966
+ .text-footer-container
967
+ .text-footer-files-container
968
+ .files-btn.both
969
+ svg:nth-child(2) {
970
+ transform: translateX(-5px);
971
+ }
972
+
973
+ .text-footer-container .text-footer-preview-container {
974
+ width: 100%;
975
+ cursor: default;
976
+ position: absolute;
977
+ left: 0;
978
+ background-color: #f1f1f1;
979
+ border: 2px solid #ccc;
980
+ border-bottom: unset;
981
+ border-top-left-radius: 2.5px;
982
+ border-top-right-radius: 2.5px;
983
+ }
984
+ .text-footer-container .text-footer-preview-container.isDoc {
985
+ top: -50px;
986
+ width: 100%;
987
+ height: 45px;
988
+ }
989
+ .text-footer-container .text-footer-preview-container.isImg,
990
+ .text-footer-container .text-footer-preview-container.isMultiple {
991
+ top: -205px;
992
+ width: 100%;
993
+ height: 200px;
994
+ }
995
+ .text-footer-container
996
+ .text-footer-preview-container.isImg
997
+ .text-footer-image-preview {
998
+ height: 170px;
999
+ }
1000
+ .text-footer-container .text-footer-preview-container.isError {
1001
+ top: -80px;
1002
+ width: 100%;
1003
+ height: 75px;
1004
+ }
1005
+
1006
+ .text-footer-container .text-footer-alt {
1007
+ margin-top: -12px;
1008
+ width: 100%;
1009
+ padding: 0 10px;
1010
+ }
1011
+ .text-footer-container .text-footer-alt .text-footer-out-session {
1012
+ margin-top: 12px;
1013
+ }
1014
+ .text-footer-container .text-footer-alt .text-footer-sem-24h {
1015
+ font-size: 0.8rem;
1016
+ text-align: right;
1017
+ font-weight: 600;
1018
+ letter-spacing: -0.5px;
1019
+ color: #dd7f0c;
1020
+ margin-top: 5px;
1021
+ position: absolute;
1022
+ right: 0;
1023
+ }
1024
+ .text-footer-container .text-footer-alt .sem-templates {
1025
+ margin-top: 10px;
1026
+ font-size: 0.8rem;
1027
+ text-align: right;
1028
+ font-weight: 600;
1029
+ letter-spacing: -0.5px;
1030
+ color: #921e12;
1031
+ }
1032
+ .text-footer-container .text-footer-alt .text-footer-templates {
1033
+ position: relative;
1034
+ width: 100%;
1035
+ }
1036
+ .text-footer-container
1037
+ .text-footer-alt
1038
+ .text-footer-templates
1039
+ .text-footer-group-selection {
1040
+ width: 100%;
1041
+ display: flex;
1042
+ align-items: center;
1043
+ }
1044
+ .text-footer-container
1045
+ .text-footer-alt
1046
+ .text-footer-templates
1047
+ .text-footer-group-selection
1048
+ h4 {
1049
+ margin-right: 5px;
1050
+ }
1051
+ .text-footer-container
1052
+ .text-footer-alt
1053
+ .text-footer-templates
1054
+ .text-footer-group-selection
1055
+ .sm__select {
1056
+ flex: 1;
1057
+ }
1058
+
1059
+ .vs__dropdown-menu {
1060
+ font-size: 0.85rem !important;
1061
+ }
1062
+
1063
+ .emoji-mart-anchor,
1064
+ .emoji-mart-emoji span {
1065
+ cursor: pointer !important;
1066
+ }
1067
+
1068
+ .emoji-mart {
1069
+ z-index: 2 !important;
1070
+ }
1071
+
1072
+ .emoji-mart-scroll {
1073
+ overflow-x: hidden;
1074
+ }
1075
+ </style>