Skip to content

Commit d35896a

Browse files
Add option for specifying the capture attr on the file input (#415)
1 parent efbdb76 commit d35896a

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ If you are using Vue 3, you can pass Array and Object props normally: [Passing D
209209
Otherwise, you need to pass those props as strings. For example: `[messages]="JSON.stringify(messages)"`
210210

211211
| <div style="width:230px">Prop</div> | Type | Required | Default |
212-
| ----------------------------------- | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
212+
|-------------------------------------| ---------------- | -------- |-------------------------------------------------------------------------------------------------------------------|
213213
| `height` | String | - | `600px` |
214214
| `current-user-id`(1) | String | `true` | - |
215215
| `rooms` | [String, Array] | - | `[]` |
@@ -255,7 +255,8 @@ Otherwise, you need to pass those props as strings. For example: `[messages]="JS
255255
| `scroll-distance`(25) | Number | - | `60` |
256256
| `theme`(26) | `light` / `dark` | - | `light` |
257257
| `accepted-files`(27) | String | - | `*` |
258-
| `styles`(28) | [String, Object] | - | (26) |
258+
| `capture-files`(28) | String | - | `undefined` |
259+
| `styles`(29) | [String, Object] | - | (26) |
259260
| `emoji-data-source` | String | - | `https://cdn.jsdelivr.net/npm/emoji-picker-element-data@%5E1/en/emojibase/data.json` |
260261

261262
**(1)** `current-user-id` is required to display UI and trigger actions according to the user using the chat (ex: messages position on the right, etc.)
@@ -473,9 +474,11 @@ You can then use the [textarea-action-handler](#events-api) event to call your o
473474

474475
**(27)** `accepted-files` can be used to set specifics file types allowed in chat. By default, all file types are allowed: `"*"`.
475476

476-
Example: set `"accepted-files="image/png, image/jpeg, application/pdf"` to allow `JPG` `PNG` and `PDF` files only
477+
Example: set `accepted-files="image/png, image/jpeg, application/pdf"` to allow `JPG` `PNG` and `PDF` files only
477478

478-
**(28)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
479+
**(28)** `capture-files` can be used to enable direct capturing of photos and videos on mobile browsers, as opposed to just uploading existing photos and videos which are already on the device. See [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture) for more information and recognized values. By default, the attribute is omitted and mobile browsers will only offer the gallery to choose photos and videos. Note: this only affects file attachments. Audio messages are always recorded using the device's microphone.
480+
481+
**(29)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
479482

480483
```javascript
481484
styles="{

src/lib/ChatWindow.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
:emojis-suggestion-enabled="emojisSuggestionEnabledCasted"
6666
:scroll-distance="scrollDistance"
6767
:accepted-files="acceptedFiles"
68+
:capture-files="captureFiles"
6869
:templates-text="templatesTextCasted"
6970
:username-options="usernameOptionsCasted"
7071
:emoji-data-source="emojiDataSource"
@@ -203,6 +204,7 @@ export default {
203204
roomMessage: { type: String, default: '' },
204205
scrollDistance: { type: Number, default: 60 },
205206
acceptedFiles: { type: String, default: '*' },
207+
captureFiles: { type: String, default: undefined },
206208
templatesText: { type: [Array, String], default: () => [] },
207209
mediaPreviewEnabled: { type: [Boolean, String], default: true },
208210
usernameOptions: {

src/lib/Room/Room.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
:show-emojis="showEmojis"
141141
:show-footer="showFooter"
142142
:accepted-files="acceptedFiles"
143+
:capture-files="captureFiles"
143144
:textarea-action-enabled="textareaActionEnabled"
144145
:textarea-auto-focus="textareaAutoFocus"
145146
:user-tags-enabled="userTagsEnabled"
@@ -210,6 +211,7 @@ export default {
210211
showNewMessagesDivider: { type: Boolean, required: true },
211212
showFooter: { type: Boolean, required: true },
212213
acceptedFiles: { type: String, required: true },
214+
captureFiles: { type: String, required: true },
213215
textFormatting: { type: Object, required: true },
214216
linkOptions: { type: Object, required: true },
215217
loadingRooms: { type: Boolean, required: true },

src/lib/Room/RoomFooter/RoomFooter.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
type="file"
164164
multiple
165165
:accept="acceptedFiles"
166+
:capture="captureFiles"
166167
style="display: none"
167168
@change="onFileChange($event.target.files)"
168169
/>
@@ -234,6 +235,7 @@ export default {
234235
showEmojis: { type: Boolean, required: true },
235236
showFooter: { type: Boolean, required: true },
236237
acceptedFiles: { type: String, required: true },
238+
captureFiles: { type: String, required: true },
237239
textareaActionEnabled: { type: Boolean, required: true },
238240
textareaAutoFocus: { type: Boolean, required: true },
239241
userTagsEnabled: { type: Boolean, required: true },

tests/unit/mock-data.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const responsiveBreakpoint = 10
3434
const singleRoom = false
3535
const theme = 'dark'
3636
const acceptedFiles = '*'
37+
const captureFiles = undefined
3738
const linkOptions = { disabled: false, target: '_blank' }
3839
const styles = { general: { color: '#0a0a0a' } }
3940

@@ -66,6 +67,7 @@ export default {
6667
singleRoom,
6768
theme,
6869
acceptedFiles,
70+
captureFiles,
6971
linkOptions,
7072
styles
7173
}

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export interface Props {
168168
'scroll-distance'?: number
169169
theme?: 'light' | 'dark'
170170
'accepted-files'?: string
171+
'capture-files'?: string
171172
styles?: Record<string, Record<string, string>>
172173
}
173174

0 commit comments

Comments
 (0)