-
Notifications
You must be signed in to change notification settings - Fork 109
/
helpers.ts
34 lines (31 loc) · 1019 Bytes
/
helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { IContribute } from "@mtbird/shared";
import { IExtensionContext } from "@mtbird/shared";
export const generateEventHandler = (store: any, params: IContribute) => {
return () => {
switch (params.link) {
case "panel":
store.actions.togglePanel(params.feature, params);
break;
case "feature":
case "modal":
store.actions.toggleModal(params.feature, params);
break;
case "link":
const isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i
if (isJavaScriptProtocol.test(params.href)) {
break;
}
window.open(params.href);
break;
}
};
};
export const getExtensionComponentManifests = (
extensionComponents: Map<string, IExtensionContext>
) => {
const res = {};
Array.from(extensionComponents.keys()).forEach((key: string) => {
res[key] = extensionComponents.get(key);
});
return res;
};