mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 01:15:06 +02:00
Add:Support for pasting semicolon separated strings in multi select inputs #1198
This commit is contained in:
parent
b447cf5c1c
commit
db9d5c9d43
2 changed files with 56 additions and 2 deletions
|
@ -11,7 +11,7 @@
|
|||
</div>
|
||||
{{ item }}
|
||||
</div>
|
||||
<input v-show="!readonly" ref="input" v-model="textInput" :disabled="disabled" style="min-width: 40px; width: 40px" class="h-full bg-primary focus:outline-none px-1" @keydown="keydownInput" @focus="inputFocus" @blur="inputBlur" />
|
||||
<input v-show="!readonly" ref="input" v-model="textInput" :disabled="disabled" style="min-width: 40px; width: 40px" class="h-full bg-primary focus:outline-none px-1" @keydown="keydownInput" @focus="inputFocus" @blur="inputBlur" @paste="inputPaste" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -145,6 +145,31 @@ export default {
|
|||
this.menu.style.left = boundingBox.x + 'px'
|
||||
this.menu.style.width = boundingBox.width + 'px'
|
||||
},
|
||||
inputPaste(evt) {
|
||||
setTimeout(() => {
|
||||
const pastedText = evt.target?.value || ''
|
||||
console.log('Pasted text=', pastedText)
|
||||
const pastedItems = [
|
||||
...new Set(
|
||||
pastedText
|
||||
.split(';')
|
||||
.map((i) => i.trim())
|
||||
.filter((i) => i)
|
||||
)
|
||||
]
|
||||
|
||||
// Filter out items already selected
|
||||
const itemsToAdd = pastedItems.filter((i) => !this.selected.some((_i) => _i.toLowerCase() === i.toLowerCase()))
|
||||
if (pastedItems.length && !itemsToAdd.length) {
|
||||
this.textInput = null
|
||||
this.currentSearch = null
|
||||
} else {
|
||||
for (const itemToAdd of itemsToAdd) {
|
||||
this.insertNewItem(itemToAdd)
|
||||
}
|
||||
}
|
||||
}, 10)
|
||||
},
|
||||
inputFocus() {
|
||||
if (!this.menu) {
|
||||
this.unmountMountMenu()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue