picosh 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +21 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,44 +16,35 @@ function saveClipboardImage(clipboard) {
|
|
|
16
16
|
return filepath;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
exports.
|
|
20
|
-
if (action.type === 'SESSION_PTY_DATA') {
|
|
21
|
-
return next(action);
|
|
22
|
-
}
|
|
23
|
-
return next(action);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.decorateTerm = (Term, {React, notify}) => {
|
|
19
|
+
exports.decorateTerm = (Term, {React}) => {
|
|
27
20
|
return class extends React.Component {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
21
|
+
componentDidMount() {
|
|
22
|
+
this._onKeyDown = (e) => {
|
|
23
|
+
if (!((e.ctrlKey || e.metaKey) && e.key === 'v')) return;
|
|
32
24
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
try {
|
|
26
|
+
const {clipboard} = require('electron');
|
|
27
|
+
const filepath = saveClipboardImage(clipboard);
|
|
28
|
+
if (!filepath) return;
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const filepath = saveClipboardImage(clipboard);
|
|
40
|
-
if (!filepath) return;
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
e.stopPropagation();
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
if (this.props.onData) {
|
|
34
|
+
this.props.onData(filepath);
|
|
35
|
+
}
|
|
36
|
+
} catch (_) {}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
document.addEventListener('keydown', this._onKeyDown, true);
|
|
40
|
+
}
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
} catch (err) {
|
|
49
|
-
// clipboard had no image, let default paste happen
|
|
50
|
-
}
|
|
42
|
+
componentWillUnmount() {
|
|
43
|
+
document.removeEventListener('keydown', this._onKeyDown, true);
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
render() {
|
|
54
|
-
return React.createElement(Term,
|
|
55
|
-
onKeyDown: this._handleKeyDown,
|
|
56
|
-
}));
|
|
47
|
+
return React.createElement(Term, this.props);
|
|
57
48
|
}
|
|
58
49
|
};
|
|
59
50
|
};
|