mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-14 19:54:43 +08:00
eff92c3152
Simplify KeyState/Focused as Scope enum
46 lines
838 B
JavaScript
46 lines
838 B
JavaScript
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
|
|
});
|
|
}
|
|
|
|
clearPopup() {
|
|
this.key('');
|
|
}
|
|
|
|
selectKey() {
|
|
const el = this.keyDom();
|
|
if (el) {
|
|
let sel = getSelection(),
|
|
range = doc.createRange();
|
|
sel.removeAllRanges();
|
|
range.selectNodeContents(el);
|
|
sel.addRange(range);
|
|
}
|
|
}
|
|
|
|
onShow(openPgpKey) {
|
|
this.clearPopup();
|
|
|
|
if (openPgpKey) {
|
|
this.key(openPgpKey.armor);
|
|
}
|
|
}
|
|
|
|
onBuild() {
|
|
shortcuts.add('a', 'meta', Scope.ViewOpenPgpKey, () => {
|
|
this.selectKey();
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
|
|
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };
|