Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32272330
D5755.1765257424.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5755.1765257424.diff
View Options
diff --git a/native/chat/text-message-markdown-context.js b/native/chat/text-message-markdown-context.js
--- a/native/chat/text-message-markdown-context.js
+++ b/native/chat/text-message-markdown-context.js
@@ -3,7 +3,7 @@
import * as React from 'react';
import * as SimpleMarkdown from 'simple-markdown';
-import type { SingleASTNode } from 'lib/shared/markdown';
+import type { ASTNode, SingleASTNode } from 'lib/shared/markdown';
import { messageKey } from 'lib/shared/message-utils';
import type { TextMessageInfo } from 'lib/types/messages/text';
@@ -12,11 +12,27 @@
export type TextMessageMarkdownContextType = {
+messageKey: string,
+markdownAST: $ReadOnlyArray<SingleASTNode>,
+ +markdownHasPressable: boolean,
};
const TextMessageMarkdownContext: React.Context<?TextMessageMarkdownContextType> = React.createContext<?TextMessageMarkdownContextType>(
null,
);
+const pressableMarkdownTypes = new Set(['link']);
+const markdownASTHasPressable = (node: ASTNode): boolean => {
+ if (Array.isArray(node)) {
+ return node.some(markdownASTHasPressable);
+ }
+ const { type, content, items } = node;
+ if (pressableMarkdownTypes.has(type)) {
+ return true;
+ } else if (items) {
+ return markdownASTHasPressable(items);
+ } else if (content) {
+ return markdownASTHasPressable(content);
+ }
+ return false;
+};
function useTextMessageMarkdown(
messageInfo: TextMessageInfo,
@@ -37,6 +53,7 @@
() => ({
messageKey: key,
markdownAST: ast,
+ markdownHasPressable: markdownASTHasPressable(ast),
}),
[key, ast],
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 5:17 AM (15 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5852740
Default Alt Text
D5755.1765257424.diff (1 KB)
Attached To
Mode
D5755: [native] Add markdownASTHasPressable to TextMessageMarkdownContext
Attached
Detach File
Event Timeline
Log In to Comment