hyper/lib/utils/paste.js
Derrick Pelletier 280f14e239 Pasting a copied file or dir provides full path to resource (#2364)
* Added a utility for processing clipboard data

* using paste processing utility in term component to expand filepath

* removed linux case

* moved active tab to guard so only process when active

* commenting paste event handler for clarity
2017-10-22 23:16:52 +02:00

21 lines
535 B
JavaScript

import {clipboard} from 'electron';
const getPath = platform => {
switch (platform) {
case 'darwin': {
const filepath = clipboard.read('public.file-url');
return filepath.replace('file://', '');
}
case 'win32': {
const filepath = clipboard.read('FileNameW');
return filepath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
}
// linux already pastes full path
default:
return null;
}
};
export default function processClipboard() {
return getPath(process.platform);
}