2021-03-16 23:06:16 +08:00
|
|
|
import { Scope } from 'Common/Enums';
|
2021-01-27 07:26:31 +08:00
|
|
|
import { doc } from 'Common/Globals';
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|
|
|
|
|
|
|
class ViewOpenPgpKeyPopupView extends AbstractViewPopup {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('ViewOpenPgpKey');
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2020-10-26 19:54:03 +08:00
|
|
|
this.addObservables({
|
|
|
|
key: '',
|
|
|
|
keyDom: null
|
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
selectKey() {
|
|
|
|
const el = this.keyDom();
|
2019-07-05 03:19:24 +08:00
|
|
|
if (el) {
|
2020-10-03 05:54:15 +08:00
|
|
|
let sel = getSelection(),
|
2021-01-27 07:26:31 +08:00
|
|
|
range = doc.createRange();
|
2020-10-03 05:54:15 +08:00
|
|
|
sel.removeAllRanges();
|
|
|
|
range.selectNodeContents(el);
|
|
|
|
sel.addRange(range);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-09-06 05:44:29 +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
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onBuild() {
|
2021-03-16 23:06:16 +08:00
|
|
|
shortcuts.add('a', 'meta', Scope.ViewOpenPgpKey, () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selectKey();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };
|