diff --git a/Android/app/default/release/output-metadata.json b/Android/app/default/release/output-metadata.json index da5dce8c..c81999e6 100644 --- a/Android/app/default/release/output-metadata.json +++ b/Android/app/default/release/output-metadata.json @@ -11,22 +11,22 @@ "type": "UNIVERSAL", "filters": [], "attributes": [], - "versionCode": 22019, - "versionName": "2.20.19", - "outputFile": "app-default-universal-release-2.20.19-22019.apk" + "versionCode": 22020, + "versionName": "2.20.20", + "outputFile": "app-default-universal-release-2.20.20-22020.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "x86" + "value": "x86_64" } ], "attributes": [], - "versionCode": 22019, - "versionName": "2.20.19", - "outputFile": "app-default-x86-release-2.20.19-22019.apk" + "versionCode": 22020, + "versionName": "2.20.20", + "outputFile": "app-default-x86_64-release-2.20.20-22020.apk" }, { "type": "ONE_OF_MANY", @@ -37,9 +37,9 @@ } ], "attributes": [], - "versionCode": 22019, - "versionName": "2.20.19", - "outputFile": "app-default-arm64-v8a-release-2.20.19-22019.apk" + "versionCode": 22020, + "versionName": "2.20.20", + "outputFile": "app-default-arm64-v8a-release-2.20.20-22020.apk" }, { "type": "ONE_OF_MANY", @@ -50,22 +50,22 @@ } ], "attributes": [], - "versionCode": 22019, - "versionName": "2.20.19", - "outputFile": "app-default-armeabi-v7a-release-2.20.19-22019.apk" + "versionCode": 22020, + "versionName": "2.20.20", + "outputFile": "app-default-armeabi-v7a-release-2.20.20-22020.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "x86_64" + "value": "x86" } ], "attributes": [], - "versionCode": 22019, - "versionName": "2.20.19", - "outputFile": "app-default-x86_64-release-2.20.19-22019.apk" + "versionCode": 22020, + "versionName": "2.20.20", + "outputFile": "app-default-x86-release-2.20.20-22020.apk" } ], "elementType": "File" diff --git a/Website/src/activitys/fragments/DrawerFragment.tsx b/Website/src/activitys/fragments/DrawerFragment.tsx index 4985c844..ffbf521b 100644 --- a/Website/src/activitys/fragments/DrawerFragment.tsx +++ b/Website/src/activitys/fragments/DrawerFragment.tsx @@ -188,7 +188,7 @@ export const DrawerFragment = (props: Props) => { hide(); }} > - + diff --git a/Website/src/components/Markdown/StyledMarkdown.tsx b/Website/src/components/Markdown/StyledMarkdown.tsx index a989c8f5..1f8b2923 100644 --- a/Website/src/components/Markdown/StyledMarkdown.tsx +++ b/Website/src/components/Markdown/StyledMarkdown.tsx @@ -74,7 +74,6 @@ export const StyledMarkdown = styled("article")(() => { borderStyle: "none", maxWidth: "100%", boxSizing: "content-box", - backgroundColor: "#ffffff", '&[align="right"]': { paddingLeft: "20px" }, '&[align="left"]': { paddingRight: "20px" }, }, diff --git a/Website/src/components/Markdown/index.tsx b/Website/src/components/Markdown/index.tsx index 034d354c..1d368c5c 100644 --- a/Website/src/components/Markdown/index.tsx +++ b/Website/src/components/Markdown/index.tsx @@ -145,7 +145,8 @@ export const Markup = (props: Props) => { React.useEffect(() => { if (ref.current) { ref.current.querySelectorAll("pre code").forEach((block) => { - hljs.highlightBlock(block); + block.removeAttribute("data-highlighted"); + hljs.highlightElement(block); }); } diff --git a/Website/src/components/ModConfView/index.tsx b/Website/src/components/ModConfView/index.tsx index 0d5dc31b..ff551c13 100644 --- a/Website/src/components/ModConfView/index.tsx +++ b/Website/src/components/ModConfView/index.tsx @@ -1,13 +1,11 @@ import { useLog } from "@Hooks/native/useLog"; import { ModFS, useModFS } from "@Hooks/useModFS"; -import { useTheme } from "@Hooks/useTheme"; import { IsolatedEval } from "@Native/IsolatedEval"; import { os } from "@Native/Os"; import * as React from "react"; import { libraries } from "./libs"; -export const ModConfView = React.forwardRef((props, ref) => { - const { theme } = useTheme(); +export const ModConfView = (props: { children: string; modid: string }) => { const { modFS } = useModFS(); const { modid, children } = props; @@ -31,14 +29,7 @@ export const ModConfView = React.forwardRef; -}); +}; diff --git a/Website/src/components/dapi/Anchor.tsx b/Website/src/components/dapi/Anchor.tsx index 042a1f48..3b027780 100644 --- a/Website/src/components/dapi/Anchor.tsx +++ b/Website/src/components/dapi/Anchor.tsx @@ -86,7 +86,7 @@ const Anchor: React.FC = (props) => { const { context } = useActivity(); const { settings } = useSettings(); const { strings } = useStrings(); - const { href, children, noIcon, module, color = theme.palette.text.link, target = "_blank" } = props; + const { href, children, noIcon, module, color = theme.palette.text.link, target = os.WindowMMRLOwn } = props; const { modules } = useRepos(); const findModule = React.useMemo(() => modules.find((m) => m.id === module), [module]); @@ -116,12 +116,7 @@ const Anchor: React.FC = (props) => { const __href = React.useMemo(() => (!(module && findModule) ? href : module), [href]); const openLink = React.useCallback(() => { - os.open(__href, { - target: target, - features: { - color: theme.palette.background.default, - }, - }); + os.openURL(__href, target, `color=${theme.palette.background.default}`); }, [__href]); return ( diff --git a/Website/src/native/Os.ts b/Website/src/native/Os.ts index b242487e..0a608939 100644 --- a/Website/src/native/Os.ts +++ b/Website/src/native/Os.ts @@ -22,14 +22,77 @@ class OsClass extends Native { super(window.__os__); } + readonly WindowMMRLOwn = "_mmrlOwn"; + readonly WindowBlank = "_blank"; + readonly WindowSelf = "_self"; + readonly WindowParent = "_parent"; + readonly WindowTop = "_top"; + readonly WindowUnfancedTop = "_unfencedTop"; + + /** + * @deprecated Use `os.openURL()` instead + */ public open(url?: string | URL | undefined, options?: OpenOptions): Window | null { if (this.isAndroid) { - return this.interface.open(url, options?.features?.color || "#fffddd"); + return this.interface.open(url, options?.features?.color || "#101010"); } else { return window.open(url, options?.target, options?.features?.window); } } + private _windowObjectReference: Window | null = null; + private _previousURL: string | URL | null | undefined = null; + + /** + * Handle opening link on Android and browsers. Android supports additional `color=#101010` feature + * @param url + * @param target + * @param features + * @returns + */ + public openURL(url?: string | URL, target?: string, features?: string): void { + const openRequestedSingleTab = (url?: string | URL, features?: string) => { + if (this._windowObjectReference === null || this._windowObjectReference.closed) { + this._windowObjectReference = open(url, this.WindowMMRLOwn, features); + } else if (this._previousURL !== url) { + this._windowObjectReference = open(url, this.WindowMMRLOwn, features); + /* if the resource to load is different, + then we load it in the already opened secondary window and then + we bring such window back on top/in front of its parent window. */ + this._windowObjectReference && this._windowObjectReference.focus(); + } else { + this._windowObjectReference.focus(); + } + this._previousURL = url; + /* explanation: we store the current url in order to compare url + in the event of another call of this function. */ + }; + + function parseWindowFeatures(features?: string) { + if (!features) return {}; + const featurePairs = features.split(","); + const featureObject = {}; + + featurePairs.forEach((pair) => { + const [key, value] = pair.split("="); + featureObject[key.trim()] = parseInt(value.trim()); // Parse value as integer + }); + + return featureObject; + } + + if (this.isAndroid) { + const parseFetures: Record = parseWindowFeatures(features); + this.interface.open(url, parseFetures.color || "#101010"); + } else { + if (target === this.WindowMMRLOwn) { + openRequestedSingleTab(url, features); + } else { + window.open(url, target, features); + } + } + } + public hasStoragePermission(): boolean { if (this.isAndroid) { return this.interface.hasStoragePermission(); diff --git a/docs/ModConf/functions/Window.md b/docs/ModConf/functions/Window.md new file mode 100644 index 00000000..4d2da052 --- /dev/null +++ b/docs/ModConf/functions/Window.md @@ -0,0 +1,23 @@ +# Window + +Here is the window API documentated, restricted. + +## `.open` + +This is currently the only method avaiable here + +```js +const windowFeatures = "left=100,top=100,width=320,height=320"; +window.open( + "https://www.mozilla.org/", + "mozillaWindow", + windowFeatures +); +``` + +Android supports a additional feature `color` + +```js +const windowFeatures = "color=#ffffff"; +window.open("https://www.mozilla.org/", "mozillaWindow", windowFeatures); +```