mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
53 lines
974 B
JavaScript
53 lines
974 B
JavaScript
import { KeyState } from 'Common/Enums';
|
|
|
|
import { popup } from 'Knoin/Knoin';
|
|
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
|
|
|
@popup({
|
|
name: 'View/Popup/ViewOpenPgpKey',
|
|
templateID: 'PopupsViewOpenPgpKey'
|
|
})
|
|
class ViewOpenPgpKeyPopupView extends AbstractViewNext {
|
|
constructor() {
|
|
super();
|
|
|
|
this.addObservables({
|
|
key: '',
|
|
keyDom: null
|
|
});
|
|
|
|
this.sDefaultKeyScope = KeyState.PopupViewOpenPGP;
|
|
}
|
|
|
|
clearPopup() {
|
|
this.key('');
|
|
}
|
|
|
|
selectKey() {
|
|
const el = this.keyDom();
|
|
if (el) {
|
|
let sel = getSelection(),
|
|
range = document.createRange();
|
|
sel.removeAllRanges();
|
|
range.selectNodeContents(el);
|
|
sel.addRange(range);
|
|
}
|
|
}
|
|
|
|
onShow(openPgpKey) {
|
|
this.clearPopup();
|
|
|
|
if (openPgpKey) {
|
|
this.key(openPgpKey.armor);
|
|
}
|
|
}
|
|
|
|
onBuild() {
|
|
shortcuts.add('a', 'meta', KeyState.PopupViewOpenPGP, () => {
|
|
this.selectKey();
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
|
|
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };
|