mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
#89 Fix Mailvelope hasPrivateKey() detection
Proper rename OpenPGP Key viewer
This commit is contained in:
parent
b06b04a579
commit
76226f45ca
41 changed files with 252 additions and 200 deletions
45
dev/View/Popup/OpenPgpKey.js
Normal file
45
dev/View/Popup/OpenPgpKey.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { Scope } from 'Common/Enums';
|
||||
import { doc } from 'Common/Globals';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
|
||||
class OpenPgpKeyPopupView extends AbstractViewPopup {
|
||||
constructor() {
|
||||
super('OpenPgpKey');
|
||||
|
||||
this.addObservables({
|
||||
key: '',
|
||||
keyDom: null
|
||||
});
|
||||
}
|
||||
|
||||
selectKey() {
|
||||
const el = this.keyDom();
|
||||
if (el) {
|
||||
let sel = getSelection(),
|
||||
range = doc.createRange();
|
||||
sel.removeAllRanges();
|
||||
range.selectNodeContents(el);
|
||||
sel.addRange(range);
|
||||
}
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(this.key()).then(
|
||||
() => console.log('Copied to clipboard'),
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onShow(openPgpKey) {
|
||||
// TODO: show more info
|
||||
this.key(openPgpKey ? openPgpKey.armor : '');
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
shortcuts.add('a', 'meta', Scope.OpenPgpKey, () => {
|
||||
this.selectKey();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { OpenPgpKeyPopupView, OpenPgpKeyPopupView as default };
|
||||
Loading…
Add table
Add a link
Reference in a new issue