hyper/lib/utils/paste.js
Umberto Lentini ba93421933 Fixed file paste (#3383)
Fixes #3340
2019-01-06 15:55:16 +01:00

27 lines
743 B
JavaScript

import {clipboard} from 'electron';
import plist from 'plist';
const getPath = platform => {
switch (platform) {
case 'darwin': {
if (clipboard.has('NSFilenamesPboardType')) {
// Parse plist file containing the path list of copied files
const list = plist.parse(clipboard.read('NSFilenamesPboardType'));
return "'" + list.join("' '") + "'";
} else {
return null;
}
}
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);
}