vue-intergrall-plugins 1.1.89 → 1.2.0

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 (45) hide show
  1. package/README.md +220 -220
  2. package/dist/dist/vue-intergrall-plugins.css +1 -1
  3. package/dist/vue-intergrall-plugins.esm.js +193 -78
  4. package/dist/vue-intergrall-plugins.min.js +7 -7
  5. package/dist/vue-intergrall-plugins.ssr.js +245 -136
  6. package/package.json +61 -61
  7. package/src/lib-components/Buttons/IconButton.vue +27 -27
  8. package/src/lib-components/Buttons/SimpleButton.vue +140 -140
  9. package/src/lib-components/Cards/Card.vue +490 -490
  10. package/src/lib-components/Cards/CardCheck.vue +35 -35
  11. package/src/lib-components/Cards/CardFile.vue +163 -163
  12. package/src/lib-components/Chat/BtnDownloadAllFiles.vue +36 -36
  13. package/src/lib-components/Chat/BtnEmojis.vue +118 -118
  14. package/src/lib-components/Chat/BtnExpand.vue +17 -17
  15. package/src/lib-components/Chat/BtnFiles.vue +486 -486
  16. package/src/lib-components/Chat/BtnMic.vue +60 -60
  17. package/src/lib-components/Chat/BtnScreenShare.vue +31 -31
  18. package/src/lib-components/Chat/BtnStandardMessages.vue +17 -17
  19. package/src/lib-components/Chat/ExpandTextarea.vue +427 -427
  20. package/src/lib-components/Chat/MultipleFilePreview.vue +291 -291
  21. package/src/lib-components/Chat/Picker.vue +525 -525
  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 +252 -252
  26. package/src/lib-components/Chat/TextFooter.vue +1007 -1007
  27. package/src/lib-components/Email/EmailExpanded.vue +270 -270
  28. package/src/lib-components/Email/EmailFile.vue +192 -192
  29. package/src/lib-components/Email/EmailFrom.vue +66 -66
  30. package/src/lib-components/Email/EmailItem.vue +867 -850
  31. package/src/lib-components/Email/EmailTo.vue +64 -64
  32. package/src/lib-components/Loader/Loader.vue +78 -78
  33. package/src/lib-components/Messages/AnexoMensagem.vue +534 -497
  34. package/src/lib-components/Messages/CardAttachment.vue +61 -61
  35. package/src/lib-components/Messages/CardMessages.vue +687 -687
  36. package/src/lib-components/Messages/InteratividadeBotoes.vue +197 -197
  37. package/src/lib-components/Messages/InteratividadeContato.vue +32 -32
  38. package/src/lib-components/Messages/InteratividadeContatoItem.vue +235 -235
  39. package/src/lib-components/Messages/InteratividadeFormulario.vue +334 -334
  40. package/src/lib-components/Messages/InteratividadePopup.vue +95 -95
  41. package/src/lib-components/Messages/LinkPreview.vue +176 -176
  42. package/src/lib-components/Scroll/ScrollContent.vue +166 -166
  43. package/src/lib-components/Templates/TemplateGenerator.vue +640 -640
  44. package/src/lib-components/Templates/TemplateMessage.vue +83 -83
  45. package/src/lib-components/Templates/TemplateSingle.vue +478 -478
@@ -1,427 +1,427 @@
1
- <template>
2
- <div class="expand-textarea" @drop.stop="dropFile" @dragenter.prevent @dragover.prevent v-clickaway="away">
3
- <slot name="btn-close" />
4
- <div class="expand-textarea-content">
5
- <h1 class="expand-textarea-title" v-text="textareaSettings.title"></h1>
6
- <textarea :ref="identifier" :placeholder="textareaSettings.placeholderMessage" v-model="message"
7
- @input="sendFinalMessage" @paste="pasteImage">
8
- </textarea>
9
- <div class="expand-textarea-footer">
10
- <BtnEmojis v-show="buttons.hasEmojis" :ref="`${identifier}-emojis`" :emojiId="`${identifier}-em`" :left="false"
11
- @insert-emoji="insertEmoji" />
12
- <BtnFiles v-if="buttons.hasFiles" :textId="identifier" :dictionary="dictionary" :fileSettings="fileSettings"
13
- :ref="`${identifier}-file`" :externalFiles="externalFiles" @set-file-vars="setFileVars"
14
- @open-image="openImage" @open-file-system="openFileSystem" @reset-file-system="resetFileSystem"
15
- @handle-file-preview="$emit('handle-file-preview')" @handle-file-click="$emit('handle-file-click')" />
16
- <slot name="btn-1"></slot>
17
- <slot name="btn-2"></slot>
18
- <!-- "expand-textarea-button" -->
19
- </div>
20
- </div>
21
- </div>
22
- </template>
23
-
24
- <script>
25
- import Clickaway from "@/directives/clickaway";
26
- import BtnEmojis from "./BtnEmojis";
27
- import BtnFiles from "./BtnFiles";
28
-
29
- export default {
30
- components: { BtnEmojis, BtnFiles },
31
- directives: {
32
- clickaway: Clickaway,
33
- },
34
- props: {
35
- identifier: {
36
- type: String,
37
- required: true,
38
- },
39
- dictionary: {
40
- type: Object,
41
- required: true,
42
- },
43
- envioEmAndamento: {
44
- type: Boolean,
45
- required: false,
46
- },
47
- externalFiles: {
48
- type: Array,
49
- required: false,
50
- },
51
- buttons: {
52
- type: Object,
53
- default: () => {
54
- return { hasEmojis: false, hasSendButton: true, hasFiles: true };
55
- },
56
- required: false,
57
- },
58
- fileSettings: {
59
- type: Object,
60
- default: () => {
61
- return { docsExtensions: "", imagesExtensions: "", multiple: false };
62
- },
63
- required: false,
64
- },
65
- textareaSettings: {
66
- type: Object,
67
- default: () => {
68
- return { placeholderMessage: "", title: "Nova mensagem" };
69
- },
70
- required: false,
71
- },
72
- },
73
- data() {
74
- return {
75
- message: "",
76
- file: [],
77
- hasAnyFile: false,
78
- imagePreview: "",
79
- isDoc: false,
80
- fileFormatError: false,
81
- };
82
- },
83
- methods: {
84
- away() {
85
- if (this.$refs[`${this.identifier}-file`])
86
- this.$refs[`${this.identifier}-file`].openFiles = false;
87
- },
88
- removeHTMLElementsFromMessage(message) {
89
- const regexTags = /<\/?[\d\w\s=\-:./'";]+>/gi;
90
- if (message.match(regexTags)) message = message.replace(regexTags, " ");
91
- return message;
92
- },
93
- formatMessage(message) {
94
- if (!message) return "";
95
- message = message.trim();
96
- message = message.replace(/\n$/, "", message);
97
- // message = returnMessageWithHexa(message);
98
- message = this.removeHTMLElementsFromMessage(message);
99
- return message;
100
- },
101
- sendFinalMessage() {
102
- const messageAux = this.formatMessage(this.message);
103
- this.$emit("final-message", messageAux);
104
- },
105
- emitirEnvio() {
106
- if (this.envioEmAndamento) return;
107
- if (!this.buttons.hasSendButton) return;
108
- try {
109
- if (this.verifyMessage()) {
110
- const messageAux = this.formatMessage(this.message);
111
- if (messageAux || this.hasAnyFile) {
112
- const objMessage = this.returnObjectMessage(messageAux);
113
- this.$emit("send-message", messageAux);
114
- this.$emit("obj-message", objMessage);
115
-
116
- // this.reset() // Deve ser chamada de fora do plugin
117
- }
118
- }
119
- } catch (e) {
120
- console.error("Erro ao emitir envio da mensagem");
121
- console.error(e);
122
- }
123
- },
124
- verifyMessage() {
125
- if ((!this.message || !this.message.trim()) && !this.hasAnyFile) return false;
126
-
127
- if (this.fileFormatError) {
128
- if (!document.querySelector(".toasted.toasted-primary.error"))
129
- this.$toasted.global.defaultError({
130
- msg: this.dictionary.msg_formato_invalido,
131
- });
132
- const str = {
133
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
134
- doc: this.fileSettings.docsExtensions.split("|").join(", "),
135
- };
136
- if (!document.querySelector(".toasted.toasted-primary.info"))
137
- this.$toasted.global.showValidFormats({
138
- msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
139
- });
140
- return false;
141
- }
142
-
143
- return true;
144
- },
145
- returnObjectMessage(message) {
146
- return {
147
- message,
148
- attachment: this.hasAnyFile ? this.file : false,
149
- isDoc: this.isDoc,
150
- imagePreview: this.imagePreview,
151
- };
152
- },
153
- reset() {
154
- if (
155
- this.buttons.hasEmojis &&
156
- this.$refs[`emoji-text-${this.identifier}-emoji`].showEmojis
157
- )
158
- this.$refs[`emoji-text-${this.identifier}-emoji`].toggleEmojiSelection();
159
- if (this.hasAnyFile) this.$refs[`${this.identifier}-file`].deleteFile();
160
- this.message = "";
161
- this.sendFinalMessage();
162
- this.focusTextarea();
163
- },
164
- dropFile(e) {
165
- try {
166
- e.stopPropagation();
167
- e.preventDefault();
168
- const files = e.dataTransfer.files.length ? e.dataTransfer.files : "";
169
- this.filesHandler(files);
170
- } catch (e) {
171
- console.error("Erro drop file");
172
- console.error(e);
173
- }
174
- },
175
- returnFileType(file, stopAlert) {
176
- const imgRegex = new RegExp("\.(" + this.fileSettings.imagesExtensions + ")", "i");
177
- if (imgRegex.test(file.name)) return "img";
178
-
179
- const docRegex = new RegExp("\.(" + this.fileSettings.docsExtensions + ")", "i");
180
- if (docRegex.test(file.name)) return "doc";
181
-
182
- if (!stopAlert) return;
183
- if (!document.querySelector(".toasted.toasted-primary.error"))
184
- this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido });
185
- const str = {
186
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
187
- doc: this.fileSettings.docsExtensions.split("|").join(", "),
188
- };
189
- if (!document.querySelector(".toasted.toasted-primary.info"))
190
- this.$toasted.global.showValidFormats({
191
- msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
192
- });
193
- return false;
194
- },
195
- filesHandler(files) {
196
- if (!Array.isArray(files)) files = Array.from(files);
197
- const fileType = this.returnFileType(files[0], true);
198
- let invalidFile = false;
199
- try {
200
- files.forEach((file) => {
201
- const singleFileType = this.returnFileType(file, true);
202
- if (!singleFileType) {
203
- invalidFile = true;
204
- file.invalid = true;
205
- }
206
- file.imgOrDoc = singleFileType ? singleFileType : "";
207
- });
208
- } catch (e) {
209
- console.error("Erro ao tentar percorrer os arquivos");
210
- console.error(e);
211
- invalidFile = true;
212
- }
213
-
214
- if (!invalidFile) {
215
- this.$refs[`${this.identifier}-file`].fileUpload(files, fileType, true);
216
- } else {
217
- if (!document.querySelector(".toasted.toasted-primary.error"))
218
- this.$toasted.global.defaultError({
219
- msg: this.dictionary.msg_formato_invalido,
220
- });
221
- const str = {
222
- img: this.fileSettings.imagesExtensions.split("|").join(", "),
223
- doc: this.fileSettings.docsExtensions.split("|").join(", "),
224
- };
225
- if (!document.querySelector(".toasted.toasted-primary.info"))
226
- this.$toasted.global.showValidFormats({
227
- msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
228
- });
229
- }
230
- },
231
- focusTextarea() {
232
- this.$refs[`${this.identifier}`].focus();
233
- },
234
- setFileVars(fileObj) {
235
- const { file, imagePreview, isDoc, fileFormatError, hasAnyFile } = fileObj;
236
-
237
- this.file = file;
238
- this.imagePreview = imagePreview ? imagePreview : "";
239
- this.isDoc = isDoc;
240
- this.fileFormatError = fileFormatError;
241
- this.hasAnyFile = hasAnyFile;
242
-
243
- this.$emit("set-file-vars", fileObj);
244
- },
245
- openImage(imagePreview) {
246
- this.$emit("open-image", imagePreview);
247
- },
248
- pasteImage(e) {
249
- try {
250
- if (e.clipboardData.files.length && !this.buttons.hasFiles) {
251
- e.preventDefault();
252
- return;
253
- } else if (e.clipboardData.files.length && this.buttons.hasFiles) {
254
- const files = e.clipboardData.files;
255
- this.filesHandler(files);
256
- }
257
- } catch (e) {
258
- console.error("Nao foi possivel colar a/o imagem/documento");
259
- console.error(e);
260
- }
261
- },
262
- insertEmoji(emoji) {
263
- try {
264
- if (!emoji) return;
265
- const textarea = this.$refs[`${this.identifier}`];
266
- if (document.activeElement === textarea) {
267
- const cursorStart = textarea.selectionStart;
268
- const cursorEnd = textarea.selectionEnd;
269
- if (cursorEnd == textarea.value.length) {
270
- this.message += emoji.finalEmoji;
271
- textarea.setSelectionRange(textarea.value.length, textarea.value.length);
272
- } else {
273
- const initValue = textarea.value.slice(0, cursorStart) + emoji.finalEmoji;
274
- const endValue = textarea.value.slice(cursorEnd);
275
- this.message = initValue + endValue;
276
- textarea.setSelectionRange(initValue.length, initValue.length);
277
- }
278
- } else {
279
- this.message += emoji.finalEmoji;
280
- }
281
- this.sendFinalMessage();
282
- } catch (e) {
283
- console.error("Erro ao inserir emoji");
284
- console.error(e);
285
- }
286
- },
287
- openFileSystem() {
288
- this.$emit("open-file-system");
289
- },
290
- resetFileSystem() {
291
- this.$emit("reset-file-system");
292
- },
293
- },
294
- };
295
- </script>
296
-
297
- <style>
298
- .expand-textarea {
299
- position: relative;
300
- width: 90%;
301
- height: 90%;
302
- z-index: 1;
303
- }
304
-
305
- .expand-textarea-content {
306
- overflow-x: hidden;
307
- overflow-y: auto;
308
- background-color: #fff;
309
- width: 100%;
310
- height: 100%;
311
- display: flex;
312
- flex-direction: column;
313
- }
314
-
315
- .expand-textarea-title {
316
- padding: 2.5px 8px;
317
- min-height: 38px;
318
- display: flex;
319
- align-items: center;
320
- width: 100%;
321
- font-size: 20.8px;
322
- background-color: #222;
323
- color: #fff;
324
- }
325
-
326
- .expand-textarea-content textarea {
327
- padding: 10px;
328
- flex: 1;
329
- width: 100%;
330
- border: unset;
331
- resize: none;
332
- outline: none;
333
- overflow-x: hidden;
334
- }
335
-
336
- .expand-textarea-content textarea:hover,
337
- .expand-textarea-content textarea:active {
338
- outline: none;
339
- }
340
-
341
- .expand-textarea-footer {
342
- display: flex;
343
- justify-content: flex-end;
344
- align-items: center;
345
- padding: 10px;
346
- background-color: #f7f7f7;
347
- position: relative;
348
- }
349
-
350
- .expand-textarea-footer .old-footer-preview-container {
351
- position: absolute;
352
- top: -200px;
353
- right: 145px;
354
- height: 200px;
355
- background: #f7f7f7;
356
- }
357
-
358
- .expand-textarea-footer .text-footer-actions--btn {
359
- width: 36px;
360
- height: 36px;
361
- border-radius: 50%;
362
- background-color: rgba(255, 255, 255, 0);
363
- color: #333;
364
- padding: 2.5px;
365
- margin: 0 15px 0 10px;
366
- display: flex;
367
- justify-content: center;
368
- align-items: center;
369
- font-size: 20.8px;
370
- cursor: pointer;
371
- opacity: 0.9;
372
- transition: all 300ms;
373
- }
374
-
375
- .expand-textarea-footer .text-footer-actions--btn:hover {
376
- opacity: 1;
377
- background-color: rgba(30, 30, 30, 0.1);
378
- }
379
-
380
- .expand-textarea-button {
381
- width: 125px;
382
- height: 30px;
383
- display: flex;
384
- justify-content: center;
385
- align-items: center;
386
-
387
- transition-duration: 300ms;
388
- user-select: none;
389
- cursor: pointer;
390
- box-shadow: inset 0 -2px rgba(0, 0, 0, 0.2);
391
- opacity: 0.9;
392
- border-radius: 5px;
393
-
394
- padding: 5px 10px;
395
- border-radius: 2.5px;
396
- position: relative;
397
- }
398
-
399
- .expand-textarea-button.green {
400
- background-color: #2a963a;
401
- color: #fff;
402
- margin-right: 10px;
403
- }
404
-
405
- .expand-textarea-button.red {
406
- background-color: #e74c3c;
407
- color: #fff;
408
- }
409
-
410
- .expand-textarea-button:hover {
411
- opacity: 1;
412
- }
413
-
414
- .expand-textarea-button:active {
415
- opacity: 1;
416
- box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
417
- -webkit-transform: translateY(1px);
418
- -moz-transform: translateY(1px);
419
- -o-transform: translateY(1px);
420
- -ms-transform: translateY(1px);
421
- transform: translateY(1px);
422
- }
423
-
424
- .expand-textarea-button.carregando {
425
- background-color: #777;
426
- }
427
- </style>
1
+ <template>
2
+ <div class="expand-textarea" @drop.stop="dropFile" @dragenter.prevent @dragover.prevent v-clickaway="away">
3
+ <slot name="btn-close" />
4
+ <div class="expand-textarea-content">
5
+ <h1 class="expand-textarea-title" v-text="textareaSettings.title"></h1>
6
+ <textarea :ref="identifier" :placeholder="textareaSettings.placeholderMessage" v-model="message"
7
+ @input="sendFinalMessage" @paste="pasteImage">
8
+ </textarea>
9
+ <div class="expand-textarea-footer">
10
+ <BtnEmojis v-show="buttons.hasEmojis" :ref="`${identifier}-emojis`" :emojiId="`${identifier}-em`" :left="false"
11
+ @insert-emoji="insertEmoji" />
12
+ <BtnFiles v-if="buttons.hasFiles" :textId="identifier" :dictionary="dictionary" :fileSettings="fileSettings"
13
+ :ref="`${identifier}-file`" :externalFiles="externalFiles" @set-file-vars="setFileVars"
14
+ @open-image="openImage" @open-file-system="openFileSystem" @reset-file-system="resetFileSystem"
15
+ @handle-file-preview="$emit('handle-file-preview')" @handle-file-click="$emit('handle-file-click')" />
16
+ <slot name="btn-1"></slot>
17
+ <slot name="btn-2"></slot>
18
+ <!-- "expand-textarea-button" -->
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ import Clickaway from "@/directives/clickaway";
26
+ import BtnEmojis from "./BtnEmojis";
27
+ import BtnFiles from "./BtnFiles";
28
+
29
+ export default {
30
+ components: { BtnEmojis, BtnFiles },
31
+ directives: {
32
+ clickaway: Clickaway,
33
+ },
34
+ props: {
35
+ identifier: {
36
+ type: String,
37
+ required: true,
38
+ },
39
+ dictionary: {
40
+ type: Object,
41
+ required: true,
42
+ },
43
+ envioEmAndamento: {
44
+ type: Boolean,
45
+ required: false,
46
+ },
47
+ externalFiles: {
48
+ type: Array,
49
+ required: false,
50
+ },
51
+ buttons: {
52
+ type: Object,
53
+ default: () => {
54
+ return { hasEmojis: false, hasSendButton: true, hasFiles: true };
55
+ },
56
+ required: false,
57
+ },
58
+ fileSettings: {
59
+ type: Object,
60
+ default: () => {
61
+ return { docsExtensions: "", imagesExtensions: "", multiple: false };
62
+ },
63
+ required: false,
64
+ },
65
+ textareaSettings: {
66
+ type: Object,
67
+ default: () => {
68
+ return { placeholderMessage: "", title: "Nova mensagem" };
69
+ },
70
+ required: false,
71
+ },
72
+ },
73
+ data() {
74
+ return {
75
+ message: "",
76
+ file: [],
77
+ hasAnyFile: false,
78
+ imagePreview: "",
79
+ isDoc: false,
80
+ fileFormatError: false,
81
+ };
82
+ },
83
+ methods: {
84
+ away() {
85
+ if (this.$refs[`${this.identifier}-file`])
86
+ this.$refs[`${this.identifier}-file`].openFiles = false;
87
+ },
88
+ removeHTMLElementsFromMessage(message) {
89
+ const regexTags = /<\/?[\d\w\s=\-:./'";]+>/gi;
90
+ if (message.match(regexTags)) message = message.replace(regexTags, " ");
91
+ return message;
92
+ },
93
+ formatMessage(message) {
94
+ if (!message) return "";
95
+ message = message.trim();
96
+ message = message.replace(/\n$/, "", message);
97
+ // message = returnMessageWithHexa(message);
98
+ message = this.removeHTMLElementsFromMessage(message);
99
+ return message;
100
+ },
101
+ sendFinalMessage() {
102
+ const messageAux = this.formatMessage(this.message);
103
+ this.$emit("final-message", messageAux);
104
+ },
105
+ emitirEnvio() {
106
+ if (this.envioEmAndamento) return;
107
+ if (!this.buttons.hasSendButton) return;
108
+ try {
109
+ if (this.verifyMessage()) {
110
+ const messageAux = this.formatMessage(this.message);
111
+ if (messageAux || this.hasAnyFile) {
112
+ const objMessage = this.returnObjectMessage(messageAux);
113
+ this.$emit("send-message", messageAux);
114
+ this.$emit("obj-message", objMessage);
115
+
116
+ // this.reset() // Deve ser chamada de fora do plugin
117
+ }
118
+ }
119
+ } catch (e) {
120
+ console.error("Erro ao emitir envio da mensagem");
121
+ console.error(e);
122
+ }
123
+ },
124
+ verifyMessage() {
125
+ if ((!this.message || !this.message.trim()) && !this.hasAnyFile) return false;
126
+
127
+ if (this.fileFormatError) {
128
+ if (!document.querySelector(".toasted.toasted-primary.error"))
129
+ this.$toasted.global.defaultError({
130
+ msg: this.dictionary.msg_formato_invalido,
131
+ });
132
+ const str = {
133
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
134
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
135
+ };
136
+ if (!document.querySelector(".toasted.toasted-primary.info"))
137
+ this.$toasted.global.showValidFormats({
138
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
139
+ });
140
+ return false;
141
+ }
142
+
143
+ return true;
144
+ },
145
+ returnObjectMessage(message) {
146
+ return {
147
+ message,
148
+ attachment: this.hasAnyFile ? this.file : false,
149
+ isDoc: this.isDoc,
150
+ imagePreview: this.imagePreview,
151
+ };
152
+ },
153
+ reset() {
154
+ if (
155
+ this.buttons.hasEmojis &&
156
+ this.$refs[`emoji-text-${this.identifier}-emoji`].showEmojis
157
+ )
158
+ this.$refs[`emoji-text-${this.identifier}-emoji`].toggleEmojiSelection();
159
+ if (this.hasAnyFile) this.$refs[`${this.identifier}-file`].deleteFile();
160
+ this.message = "";
161
+ this.sendFinalMessage();
162
+ this.focusTextarea();
163
+ },
164
+ dropFile(e) {
165
+ try {
166
+ e.stopPropagation();
167
+ e.preventDefault();
168
+ const files = e.dataTransfer.files.length ? e.dataTransfer.files : "";
169
+ this.filesHandler(files);
170
+ } catch (e) {
171
+ console.error("Erro drop file");
172
+ console.error(e);
173
+ }
174
+ },
175
+ returnFileType(file, stopAlert) {
176
+ const imgRegex = new RegExp("\.(" + this.fileSettings.imagesExtensions + ")", "i");
177
+ if (imgRegex.test(file.name)) return "img";
178
+
179
+ const docRegex = new RegExp("\.(" + this.fileSettings.docsExtensions + ")", "i");
180
+ if (docRegex.test(file.name)) return "doc";
181
+
182
+ if (!stopAlert) return;
183
+ if (!document.querySelector(".toasted.toasted-primary.error"))
184
+ this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido });
185
+ const str = {
186
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
187
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
188
+ };
189
+ if (!document.querySelector(".toasted.toasted-primary.info"))
190
+ this.$toasted.global.showValidFormats({
191
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
192
+ });
193
+ return false;
194
+ },
195
+ filesHandler(files) {
196
+ if (!Array.isArray(files)) files = Array.from(files);
197
+ const fileType = this.returnFileType(files[0], true);
198
+ let invalidFile = false;
199
+ try {
200
+ files.forEach((file) => {
201
+ const singleFileType = this.returnFileType(file, true);
202
+ if (!singleFileType) {
203
+ invalidFile = true;
204
+ file.invalid = true;
205
+ }
206
+ file.imgOrDoc = singleFileType ? singleFileType : "";
207
+ });
208
+ } catch (e) {
209
+ console.error("Erro ao tentar percorrer os arquivos");
210
+ console.error(e);
211
+ invalidFile = true;
212
+ }
213
+
214
+ if (!invalidFile) {
215
+ this.$refs[`${this.identifier}-file`].fileUpload(files, fileType, true);
216
+ } else {
217
+ if (!document.querySelector(".toasted.toasted-primary.error"))
218
+ this.$toasted.global.defaultError({
219
+ msg: this.dictionary.msg_formato_invalido,
220
+ });
221
+ const str = {
222
+ img: this.fileSettings.imagesExtensions.split("|").join(", "),
223
+ doc: this.fileSettings.docsExtensions.split("|").join(", "),
224
+ };
225
+ if (!document.querySelector(".toasted.toasted-primary.info"))
226
+ this.$toasted.global.showValidFormats({
227
+ msg: `Imagens: ${str.img} - Documentos: ${str.doc} ${this.dictionary.msg_extensoes_aceitas}`,
228
+ });
229
+ }
230
+ },
231
+ focusTextarea() {
232
+ this.$refs[`${this.identifier}`].focus();
233
+ },
234
+ setFileVars(fileObj) {
235
+ const { file, imagePreview, isDoc, fileFormatError, hasAnyFile } = fileObj;
236
+
237
+ this.file = file;
238
+ this.imagePreview = imagePreview ? imagePreview : "";
239
+ this.isDoc = isDoc;
240
+ this.fileFormatError = fileFormatError;
241
+ this.hasAnyFile = hasAnyFile;
242
+
243
+ this.$emit("set-file-vars", fileObj);
244
+ },
245
+ openImage(imagePreview) {
246
+ this.$emit("open-image", imagePreview);
247
+ },
248
+ pasteImage(e) {
249
+ try {
250
+ if (e.clipboardData.files.length && !this.buttons.hasFiles) {
251
+ e.preventDefault();
252
+ return;
253
+ } else if (e.clipboardData.files.length && this.buttons.hasFiles) {
254
+ const files = e.clipboardData.files;
255
+ this.filesHandler(files);
256
+ }
257
+ } catch (e) {
258
+ console.error("Nao foi possivel colar a/o imagem/documento");
259
+ console.error(e);
260
+ }
261
+ },
262
+ insertEmoji(emoji) {
263
+ try {
264
+ if (!emoji) return;
265
+ const textarea = this.$refs[`${this.identifier}`];
266
+ if (document.activeElement === textarea) {
267
+ const cursorStart = textarea.selectionStart;
268
+ const cursorEnd = textarea.selectionEnd;
269
+ if (cursorEnd == textarea.value.length) {
270
+ this.message += emoji.finalEmoji;
271
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
272
+ } else {
273
+ const initValue = textarea.value.slice(0, cursorStart) + emoji.finalEmoji;
274
+ const endValue = textarea.value.slice(cursorEnd);
275
+ this.message = initValue + endValue;
276
+ textarea.setSelectionRange(initValue.length, initValue.length);
277
+ }
278
+ } else {
279
+ this.message += emoji.finalEmoji;
280
+ }
281
+ this.sendFinalMessage();
282
+ } catch (e) {
283
+ console.error("Erro ao inserir emoji");
284
+ console.error(e);
285
+ }
286
+ },
287
+ openFileSystem() {
288
+ this.$emit("open-file-system");
289
+ },
290
+ resetFileSystem() {
291
+ this.$emit("reset-file-system");
292
+ },
293
+ },
294
+ };
295
+ </script>
296
+
297
+ <style>
298
+ .expand-textarea {
299
+ position: relative;
300
+ width: 90%;
301
+ height: 90%;
302
+ z-index: 1;
303
+ }
304
+
305
+ .expand-textarea-content {
306
+ overflow-x: hidden;
307
+ overflow-y: auto;
308
+ background-color: #fff;
309
+ width: 100%;
310
+ height: 100%;
311
+ display: flex;
312
+ flex-direction: column;
313
+ }
314
+
315
+ .expand-textarea-title {
316
+ padding: 2.5px 8px;
317
+ min-height: 38px;
318
+ display: flex;
319
+ align-items: center;
320
+ width: 100%;
321
+ font-size: 20.8px;
322
+ background-color: #222;
323
+ color: #fff;
324
+ }
325
+
326
+ .expand-textarea-content textarea {
327
+ padding: 10px;
328
+ flex: 1;
329
+ width: 100%;
330
+ border: unset;
331
+ resize: none;
332
+ outline: none;
333
+ overflow-x: hidden;
334
+ }
335
+
336
+ .expand-textarea-content textarea:hover,
337
+ .expand-textarea-content textarea:active {
338
+ outline: none;
339
+ }
340
+
341
+ .expand-textarea-footer {
342
+ display: flex;
343
+ justify-content: flex-end;
344
+ align-items: center;
345
+ padding: 10px;
346
+ background-color: #f7f7f7;
347
+ position: relative;
348
+ }
349
+
350
+ .expand-textarea-footer .old-footer-preview-container {
351
+ position: absolute;
352
+ top: -200px;
353
+ right: 145px;
354
+ height: 200px;
355
+ background: #f7f7f7;
356
+ }
357
+
358
+ .expand-textarea-footer .text-footer-actions--btn {
359
+ width: 36px;
360
+ height: 36px;
361
+ border-radius: 50%;
362
+ background-color: rgba(255, 255, 255, 0);
363
+ color: #333;
364
+ padding: 2.5px;
365
+ margin: 0 15px 0 10px;
366
+ display: flex;
367
+ justify-content: center;
368
+ align-items: center;
369
+ font-size: 20.8px;
370
+ cursor: pointer;
371
+ opacity: 0.9;
372
+ transition: all 300ms;
373
+ }
374
+
375
+ .expand-textarea-footer .text-footer-actions--btn:hover {
376
+ opacity: 1;
377
+ background-color: rgba(30, 30, 30, 0.1);
378
+ }
379
+
380
+ .expand-textarea-button {
381
+ width: 125px;
382
+ height: 30px;
383
+ display: flex;
384
+ justify-content: center;
385
+ align-items: center;
386
+
387
+ transition-duration: 300ms;
388
+ user-select: none;
389
+ cursor: pointer;
390
+ box-shadow: inset 0 -2px rgba(0, 0, 0, 0.2);
391
+ opacity: 0.9;
392
+ border-radius: 5px;
393
+
394
+ padding: 5px 10px;
395
+ border-radius: 2.5px;
396
+ position: relative;
397
+ }
398
+
399
+ .expand-textarea-button.green {
400
+ background-color: #2a963a;
401
+ color: #fff;
402
+ margin-right: 10px;
403
+ }
404
+
405
+ .expand-textarea-button.red {
406
+ background-color: #e74c3c;
407
+ color: #fff;
408
+ }
409
+
410
+ .expand-textarea-button:hover {
411
+ opacity: 1;
412
+ }
413
+
414
+ .expand-textarea-button:active {
415
+ opacity: 1;
416
+ box-shadow: inset 0 -1px rgba(0, 0, 0, 0.2);
417
+ -webkit-transform: translateY(1px);
418
+ -moz-transform: translateY(1px);
419
+ -o-transform: translateY(1px);
420
+ -ms-transform: translateY(1px);
421
+ transform: translateY(1px);
422
+ }
423
+
424
+ .expand-textarea-button.carregando {
425
+ background-color: #777;
426
+ }
427
+ </style>