foliate icon indicating copy to clipboard operation
foliate copied to clipboard

Add drag and drop in library component

Open digitalethics opened this issue 5 years ago • 3 comments

It would be great to be able to position book covers in any order in the library component (drag & drop) to better resemble the freedom one has with an analogue bookshelf.¹

¹Could you add a library label here in GitHub to better track all related (and upcoming) issues?

digitalethics avatar Jun 10 '20 12:06 digitalethics

The ability to drag files into the library window to automatically open them would also be very convenient.

digitalethics avatar Aug 19 '20 12:08 digitalethics

@digitalethics I want this feature to do you want to work on a pull request with me?

BlazarKnight avatar May 16 '25 13:05 BlazarKnight

we could probably use this bit of code from https://github.com/johnfactotum/foliate-js/blob/052123beafed921a9a2a45ef6330c235289a634e/reader.js

const dragOverHandler = e => e.preventDefault()
const dropHandler = e => {
    e.preventDefault()
    const item = Array.from(e.dataTransfer.items)
        .find(item => item.kind === 'file')
    if (item) {
        const entry = item.webkitGetAsEntry()
        open(entry.isFile ? item.getAsFile() : entry).catch(e => console.error(e))
    }

BlazarKnight avatar May 16 '25 14:05 BlazarKnight