docs: Added Drag and drop files Fiddle example (#20472)
This commit is contained in:
parent
eb0e55c514
commit
4e88633d89
3 changed files with 161 additions and 0 deletions
21
docs/fiddles/native-ui/drag-and-drop/renderer.js
Normal file
21
docs/fiddles/native-ui/drag-and-drop/renderer.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const { ipcRenderer } = require('electron')
|
||||
const shell = require('electron').shell
|
||||
|
||||
const links = document.querySelectorAll('a[href]')
|
||||
|
||||
Array.prototype.forEach.call(links, (link) => {
|
||||
const url = link.getAttribute('href')
|
||||
if (url.indexOf('http') === 0) {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
shell.openExternal(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const dragFileLink = document.getElementById('drag-file-link')
|
||||
|
||||
dragFileLink.addEventListener('dragstart', event => {
|
||||
event.preventDefault()
|
||||
ipcRenderer.send('ondragstart', __filename)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue