Skip to content

Commit 682b1f3

Browse files
fix(mobile): route Markdown preview menu actions
1 parent d077458 commit 682b1f3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎apps/mobile/src/native/EnrichedMarkdownText.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
formatComposerContextReference,
66
} from "@t3tools/shared/composerContextReferences";
77
import { useCallback, useMemo, useState } from "react";
8-
import { ActionSheetIOS, Platform, StyleSheet, View } from "react-native";
8+
import { ActionSheetIOS, Platform, Share, StyleSheet, View } from "react-native";
99
import {
1010
EnrichedMarkdownText,
1111
type DocumentAssetsEvent,
@@ -171,24 +171,26 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
171171
(url: string, actionId: string) => {
172172
if (actionId === "enriched-open-link") onLinkPress?.(url);
173173
else if (actionId === "enriched-copy-link") copyTextWithHaptic(url);
174+
else if (actionId === "enriched-share-link") void Share.share({ message: url });
174175
else onFileContextMenuAction?.(url, actionId);
175176
},
176177
[onLinkPress, onFileContextMenuAction],
177178
);
178179
const linkContextMenuItems = useMemo(
179180
() =>
180-
Platform.OS === "ios" && fileContextMenu
181+
Platform.OS === "ios" && (fileContextMenu || onLinkPress)
181182
? Object.fromEntries(
182183
[
183184
...new Set(
184185
documentAssets.filter((asset) => asset.kind === "link").map((asset) => asset.url),
185186
),
186187
].map((url) => {
187-
const menu = fileContextMenu(url) ?? {
188+
const menu = fileContextMenu?.(url) ?? {
188189
title: url,
189190
actions: [
190191
{ id: "enriched-open-link", title: "Open link" },
191192
{ id: "enriched-copy-link", title: "Copy link" },
193+
{ id: "enriched-share-link", title: "Share link" },
192194
],
193195
};
194196
return [
@@ -202,7 +204,7 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
202204
}),
203205
)
204206
: undefined,
205-
[documentAssets, fileContextMenu, performMenuAction],
207+
[documentAssets, fileContextMenu, onLinkPress, performMenuAction],
206208
);
207209
const selectionClipboard = useMemo(() => {
208210
const fragment = decodeComposerContextFragment(props.contextClipboardFragment);

0 commit comments

Comments
 (0)