Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

T3MarkdownTextSelectionModule.ts

30 lines1.2 KB

1import { requireOptionalNativeModule } from "expo";
2​
3interface T3MarkdownTextSelectionNativeModule {
4 readonly setSelectionHandleColor?: (reactTag: number, color: number) => void;
5 readonly installCopySanitizer: (reactTag: number, contextClipboardConfig: string) => void;
6 readonly renderContextChip?: (payloadJson: string) => {
7 readonly uri: string;
8 readonly width: number;
9 readonly height: number;
10 /** Inline box height: the paragraph font's ascent, so the line box never grows. */
11 readonly boxHeight: number;
12 /** Bitmap top relative to the box top; negative when the chip overhangs the box. */
13 readonly offsetY: number;
14 } | null;
16​
17const nativeModule =
18 requireOptionalNativeModule<T3MarkdownTextSelectionNativeModule>("T3MarkdownTextSelection");
19​
20export function installMarkdownCopySanitizer(reactTag: number, contextClipboardConfig = ""): void {
21 nativeModule?.installCopySanitizer(reactTag, contextClipboardConfig);
23​
24export function setMarkdownSelectionHandleColor(reactTag: number, color: number): void {
25 nativeModule?.setSelectionHandleColor?.(reactTag, color);
27​
28export function renderAndroidContextChip(payloadJson: string) {
29 return nativeModule?.renderContextChip?.(payloadJson) ?? null;