snappymail/dev/View/Popup/ViewOpenPgpKey.js

39 lines
773 B
JavaScript
Raw Normal View History

import { Scope } from 'Common/Enums';
import { doc } from 'Common/Globals';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
class ViewOpenPgpKeyPopupView extends AbstractViewPopup {
constructor() {
super('ViewOpenPgpKey');
this.addObservables({
key: '',
keyDom: null
});
}
selectKey() {
const el = this.keyDom();
2019-07-05 03:19:24 +08:00
if (el) {
let sel = getSelection(),
range = doc.createRange();
sel.removeAllRanges();
range.selectNodeContents(el);
sel.addRange(range);
}
2016-06-30 08:02:45 +08:00
}
2016-09-30 21:42:38 +08:00
onShow(openPgpKey) {
2021-11-03 21:58:34 +08:00
this.key(openPgpKey ? openPgpKey.armor : '');
2016-06-30 08:02:45 +08:00
}
2015-09-02 03:50:30 +08:00
onBuild() {
shortcuts.add('a', 'meta', Scope.ViewOpenPgpKey, () => {
this.selectKey();
return false;
});
}
}
2019-07-05 03:19:24 +08:00
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };