From c4d6731401d3b6dc111a74d086df28704473070d Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Sat, 17 Sep 2022 23:23:51 -0400
Subject: fix updater for new installs, fix file picker patch, fix scrolling on
 patch notes, fix tasks dir

---
 frontend/src/components/Markdown.tsx | 39 +++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

(limited to 'frontend/src/components/Markdown.tsx')

diff --git a/frontend/src/components/Markdown.tsx b/frontend/src/components/Markdown.tsx
index 7b187f14..cefced91 100644
--- a/frontend/src/components/Markdown.tsx
+++ b/frontend/src/components/Markdown.tsx
@@ -1,9 +1,42 @@
-import { FunctionComponent } from 'react';
+import { Focusable } from 'decky-frontend-lib';
+import { FunctionComponent, useRef } from 'react';
 import ReactMarkdown, { Options as ReactMarkdownOptions } from 'react-markdown';
 import remarkGfm from 'remark-gfm';
 
-const Markdown: FunctionComponent<ReactMarkdownOptions> = (props) => {
-  return <ReactMarkdown remarkPlugins={[remarkGfm]} {...props} />;
+interface MarkdownProps extends ReactMarkdownOptions {
+  onDismiss?: () => void;
+}
+
+const Markdown: FunctionComponent<MarkdownProps> = (props) => {
+  return (
+    <Focusable>
+      <ReactMarkdown
+        remarkPlugins={[remarkGfm]}
+        components={{
+          div: (nodeProps) => <Focusable {...nodeProps.node.properties}>{nodeProps.children}</Focusable>,
+          a: (nodeProps) => {
+            console.log(nodeProps.node, nodeProps);
+            const aRef = useRef<HTMLAnchorElement>(null);
+            return (
+              // TODO fix focus ring
+              <Focusable
+                onActivate={() => {}}
+                onOKButton={() => {
+                  aRef?.current?.click();
+                  props.onDismiss?.();
+                }}
+              >
+                <a ref={aRef} {...nodeProps.node.properties}>
+                  {nodeProps.children}
+                </a>
+              </Focusable>
+            );
+          },
+        }}
+        {...props}
+      />
+    </Focusable>
+  );
 };
 
 export default Markdown;
-- 
cgit v1.2.3

