The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
feat(mobile): Mermaid and math fences render like they do on web (#32190)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 8, 2026 at 18:08 UTC
d0807b705f36a79dc194fb2281d064d8103f3745
9 files changed
+505
-12
apps/mobile/package.json
+1
@@ -118,6 +118,7 @@
118
"expo-video": "58.0.11",
119
"expo-web-browser": "~58.0.6",
120
"expo-widgets": "58.0.20",
121
+ "pele": "catalog:",
122
"react": "catalog:",
123
"react-dom": "catalog:",
124
"react-native": "0.88.0",
apps/mobile/src/components/ui/AppSymbol.tsx
+2
@@ -124,6 +124,7 @@ import IconTool from "@tabler/icons-react-native/IconTool";
124
import IconTrash from "@tabler/icons-react-native/IconTrash";
125
import IconTypography from "@tabler/icons-react-native/IconTypography";
126
import IconDownload from "@tabler/icons-react-native/IconDownload";
127
+import IconSitemap from "@tabler/icons-react-native/IconSitemap";
128
import IconUpload from "@tabler/icons-react-native/IconUpload";
129
import IconUserCircle from "@tabler/icons-react-native/IconUserCircle";
130
import IconUserCheck from "@tabler/icons-react-native/IconUserCheck";
@@ -248,6 +249,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
249
"slash.circle": IconBan,
250
"qrcode.viewfinder": IconQrcode,
251
"point.3.connected.trianglepath.dotted": IconNetwork,
252
+ flowchart: IconSitemap,
253
"point.topleft.down.curvedto.point.bottomright.up": IconGitMerge,
254
safari: IconExternalLink,
255
"server.rack": IconServer,
apps/mobile/src/lib/mermaidSvg.test.ts
new
+37
@@ -0,0 +1,37 @@
1
+import { render } from "pele";
2
+import { describe, expect, it } from "vite-plus/test";
3
+
4
+import { mermaidSvgForNative, withDiagramBackground } from "./mermaidSvg";
5
+
6
+describe("mermaidSvgForNative", () => {
7
+ it("turns Pele's CSS variables and styles into attributes react-native-svg draws", () => {
8
+ const { svg } = render(
9
+ 'flowchart LR\n A[Client] -->|ws| B(Server)\n B --> C["var(--pele-fg)"]',
10
+ {
11
+ links: false,
12
+ images: false,
13
+ },
14
+ );
15
+
16
+ const native = mermaidSvgForNative(svg, {
17
+ "--pele-fg": "#111111",
18
+ "--pele-line": "#222222",
19
+ "--pele-font": "Helvetica",
20
+ });
21
+
22
+ expect(native).not.toMatch(/="[^"]*var\(|style=/);
23
+ // A label that reads like a variable keeps its text.
24
+ expect(native).toContain(">var(--pele-fg)<");
25
+ expect(native).toMatch(
26
+ /^<svg[^>]* fill="#111111"[^>]* font-family="Helvetica" font-size="16">/,
27
+ );
28
+ expect(native).toContain('stroke="#222222"');
29
+ // Colors the theme leaves out keep Pele's fallback, and the corner radius becomes geometry.
30
+ expect(native).toContain('fill="#f3f3f3"');
31
+ expect(native).toMatch(/<rect[^>]* rx="4"/);
32
+ // The exported image fills the viewBox before anything else draws.
33
+ expect(withDiagramBackground(native, "#fafafa")).toMatch(
34
+ /^<svg[^>]*><rect x="0" y="0" width="\d+(\.\d+)?" height="\d+(\.\d+)?" fill="#fafafa"\/>/,
35
+ );
36
+ });
37
+});
apps/mobile/src/lib/mermaidSvg.ts
new
+63
@@ -0,0 +1,63 @@
1
+/**
2
+ * react-native-svg applies neither the CSS custom properties Pele colors with
3
+ * nor CSS-only geometry such as `rx` in a style, so both become attributes.
4
+ * `theme` sets `--pele-*` values; the rest keep Pele's fallbacks.
5
+ */
6
+export function mermaidSvgForNative(svg: string, theme: Readonly<Record<string, string>>): string {
7
+ const rootTag = /^<svg\b[^>]*>/.exec(svg)?.[0];
8
+ if (!rootTag) return svg;
9
+ const declared = styleDeclarations(/\sstyle="([^"]*)"/.exec(rootTag)?.[1] ?? "");
10
+ const resolve = (value: string, depth = 0): string =>
11
+ depth > 8
12
+ ? value
13
+ : value.replace(
14
+ /var\((--[\w-]+)(?:,\s*((?:[^()]|\([^()]*\))*))?\)/g,
15
+ (_match, name: string, fallback: string | undefined) =>
16
+ resolve(theme[name] ?? declared.get(name) ?? fallback ?? "", depth + 1),
17
+ );
18
+
19
+ const fontSize = /(\d+(?:\.\d+)?)px/.exec(declared.get("font") ?? "")?.[1] ?? "16";
20
+ const fontFamily = resolve(declared.get("font-family") ?? "sans-serif").replaceAll('"', "'");
21
+ const root = resolve(rootTag.replace(/\sstyle="[^"]*"/, "")).replace(
22
+ />$/,
23
+ ` font-family="${fontFamily}" font-size="${fontSize}">`,
24
+ );
25
+ const body = svg
26
+ .slice(rootTag.length)
27
+ .replace(/\sstyle="([^"]*)"/g, (_match, style: string) =>
28
+ [...styleDeclarations(style)]
29
+ .map(([name, value]) => ` ${name}="${resolve(value).replace(/^(-?[\d.]+)px$/, "$1")}"`)
30
+ .join(""),
31
+ );
32
+ // Attribute values only: a label's text can itself read `var(--…)`.
33
+ return (
34
+ root +
35
+ body.replace(
36
+ /(\s[\w:-]+=")([^"]*)"/g,
37
+ (_match, prefix: string, value: string) => `${prefix}${resolve(value)}"`,
38
+ )
39
+ );
40
+}
41
+
42
+/** Fills the diagram's viewBox, so an exported image reads on any background. */
43
+export function withDiagramBackground(svg: string, color: string): string {
44
+ const rootTag = /^<svg\b[^>]*>/.exec(svg)?.[0];
45
+ const box = /\sviewBox="([^"]*)"/
46
+ .exec(rootTag ?? "")?.[1]
47
+ ?.trim()
48
+ .split(/[\s,]+/);
49
+ if (!rootTag || box?.length !== 4) return svg;
50
+ const [x, y, width, height] = box;
51
+ return `${rootTag}<rect x="${x}" y="${y}" width="${width}" height="${height}" fill="${color}"/>${svg.slice(rootTag.length)}`;
52
+}
53
+
54
+function styleDeclarations(style: string): Map<string, string> {
55
+ const declarations = new Map<string, string>();
56
+ for (const declaration of style.split(";")) {
57
+ const colon = declaration.indexOf(":");
58
+ if (colon > 0) {
59
+ declarations.set(declaration.slice(0, colon).trim(), declaration.slice(colon + 1).trim());
60
+ }
61
+ }
62
+ return declarations;
63
+}
apps/mobile/src/native/EnrichedMarkdownText.tsx
+48
-10
@@ -11,14 +11,16 @@ import {
11
markdownWithInlineFileLinks,
12
markdownWithTableBreaks,
13
} from "../lib/markdownDocument";
14
-import { isValidElement, useMemo, useState, type ReactNode } from "react";
14
+import { isValidElement, useMemo, useState, type ReactElement, type ReactNode } from "react";
15
import { Platform, Share, StyleSheet, useWindowDimensions, View } from "react-native";
16
import {
17
EnrichedMarkdownText,
18
+ type MarkdownCodeBlock,
19
type MarkdownImageBlock,
20
type MarkdownLinkOccurrence,
21
type MarkdownStyle,
22
} from "react-native-enriched-markdown";
23
+import { MermaidCodeBlock } from "./MermaidCodeBlock";
24
import type { SelectableMarkdownTextProps } from "./SelectableMarkdownText.types";
25
26
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
@@ -161,6 +163,35 @@ function enrichedStyle(
163
};
164
}
165
166
+/** Diagram and math fences, as web draws them. A fence streams as native code until it closes. */
167
+function codeBlockElement(
168
+ block: MarkdownCodeBlock,
169
+ textStyle: SelectableMarkdownTextProps["textStyle"],
170
+ markdownStyle: MarkdownStyle,
171
+ mathRenderingEnabled: boolean,
172
+): ReactElement | undefined {
173
+ if (!block.isComplete) return undefined;
174
+ if (block.language === "mermaid") {
175
+ return <MermaidCodeBlock code={block.code} textStyle={textStyle} />;
176
+ }
177
+ if (block.language === "math" && mathRenderingEnabled) {
178
+ return (
179
+ <EnrichedMarkdownText
180
+ // A blank line would end the paragraph, and so the math, early.
181
+ markdown={`$$\n${block.code.replace(/\n\s*\n/g, "\n").trim()}\n$$`}
182
+ markdownStyle={markdownStyle}
183
+ md4cFlags={{ latexMath: true }}
184
+ containerStyle={{ flexShrink: 1, minWidth: 0 }}
185
+ flavor="github"
186
+ selectable
187
+ selectionColor={textStyle.selectionColor}
188
+ selectionHandleColor={textStyle.selectionHandleColor}
189
+ />
190
+ );
191
+ }
192
+ return undefined;
193
+}
194
+
195
export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
196
const { renderImage, resolveImageSource, fileEmbedLabel } = props;
197
const { themeAppearance, mathRenderingEnabled } = useAppearancePreferences();
@@ -264,28 +295,35 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
295
};
296
}, [props.contextClipboardFragment, props.markdown]);
297
const { fontScale } = useWindowDimensions();
267
- const markdownStyle = useMemo(() => {
298
+ const baseMarkdownStyle = useMemo(() => {
299
const style = enrichedStyle(props.textStyle, themeAppearance === "dark", fontScale);
300
return {
301
...style,
302
paragraph: props.textAlign
303
? { ...style.paragraph, textAlign: props.textAlign }
304
: style.paragraph,
274
- linkVariants,
305
};
276
- }, [props.textStyle, props.textAlign, themeAppearance, fontScale, linkVariants]);
277
- const renderers = renderImage
278
- ? {
279
- image: (block: MarkdownImageBlock) => {
306
+ }, [props.textStyle, props.textAlign, themeAppearance, fontScale]);
307
+ // Link variants change as a message streams. The code renderer reads only the base style, so
308
+ // it stays the same function and the library keeps its rendered blocks.
309
+ const markdownStyle = useMemo(
310
+ () => ({ ...baseMarkdownStyle, linkVariants }),
311
+ [baseMarkdownStyle, linkVariants],
312
+ );
313
+ const renderers = {
314
+ image: renderImage
315
+ ? (block: MarkdownImageBlock) => {
316
const element = renderImage({
317
href: block.url,
318
alt: block.altText || null,
319
title: block.title || null,
320
});
321
return isValidElement(element) ? element : undefined;
286
- },
287
- }
288
- : undefined;
322
+ }
323
+ : undefined,
324
+ code: (block: MarkdownCodeBlock) =>
325
+ codeBlockElement(block, props.textStyle, baseMarkdownStyle, mathRenderingEnabled),
326
+ };
327
const resolveNativeImageSource = useRetryingImageSource(resolveImageSource);
328
const renderMarkdown = (openAndroidMenu?: () => void) => {
329
const onLinkLongPress =
apps/mobile/src/native/MermaidCodeBlock.tsx
new
+345
@@ -0,0 +1,345 @@
1
+import * as Hash from "effect/Hash";
2
+import { File, Paths } from "expo-file-system";
3
+import * as Haptics from "expo-haptics";
4
+import type { DiagramType } from "pele/lazy";
5
+import { Suspense, use, useRef, useState } from "react";
6
+import { PixelRatio, Platform, Pressable, StyleSheet, Text, View } from "react-native";
7
+import { parse, Svg, SvgXml } from "react-native-svg";
8
+
9
+import { MediaImagePreview } from "../components/MediaImagePreview";
10
+import { SymbolView, type AppSymbolName } from "../components/ui/AppSymbol";
11
+import { copyTextWithHaptic } from "../lib/copyTextWithHaptic";
12
+import { mermaidSvgForNative, withDiagramBackground } from "../lib/mermaidSvg";
13
+import { themeColorWithAlpha } from "../lib/mobileTheme";
14
+import type { NativeMarkdownTextStyle } from "./SelectableMarkdownText.types";
15
+
16
+type Pele = typeof import("pele/lazy");
17
+type Diagram =
18
+ | {
19
+ readonly status: "ready";
20
+ readonly svg: string;
21
+ readonly width: number;
22
+ readonly height: number;
23
+ }
24
+ | { readonly status: "error"; readonly message: string };
25
+
26
+let peleLoad: Promise<Pele | null> | null = null;
27
+// Each diagram type is its own chunk, so a thread with one flowchart only
28
+// evaluates the flowchart parser and layout.
29
+const typeLoads = new Map<DiagramType, Promise<boolean>>();
30
+// A message scrolled back into view reuses its settled promise, which `use`
31
+// reads without suspending, instead of flashing the source.
32
+const diagramLoads = new Map<string, Promise<Diagram>>();
33
+const DIAGRAM_CACHE_LIMIT = 64;
34
+
35
+function loadDiagram(source: string): Promise<Diagram> {
36
+ let load = diagramLoads.get(source);
37
+ if (!load) {
38
+ if (diagramLoads.size >= DIAGRAM_CACHE_LIMIT) {
39
+ diagramLoads.delete(diagramLoads.keys().next().value!);
40
+ }
41
+ load = renderDiagram(source);
42
+ diagramLoads.set(source, load);
43
+ }
44
+ return load;
45
+}
46
+
47
+const MONOSPACE = Platform.OS === "ios" ? "Menlo" : "monospace";
48
+// Pele measures labels with metrics close to Helvetica when no canvas is available.
49
+const DIAGRAM_FONT = Platform.OS === "ios" ? "Helvetica" : "sans-serif";
50
+
51
+async function renderDiagram(source: string): Promise<Diagram> {
52
+ peleLoad ??= import("pele/lazy").catch(() => null);
53
+ const pele = await peleLoad;
54
+ if (!pele) {
55
+ // Not cached, so the next mount tries again.
56
+ peleLoad = null;
57
+ diagramLoads.delete(source);
58
+ return { status: "error", message: "The diagram renderer failed to load." };
59
+ }
60
+ let type: DiagramType | null = null;
61
+ try {
62
+ type = pele.detectType(source);
63
+ } catch {
64
+ // An unknown type falls through to render, which reports why.
65
+ }
66
+ if (type) {
67
+ let load = typeLoads.get(type);
68
+ if (!load) {
69
+ load = pele.load(type).then(
70
+ () => true,
71
+ () => false,
72
+ );
73
+ typeLoads.set(type, load);
74
+ }
75
+ if (!(await load)) {
76
+ typeLoads.delete(type);
77
+ diagramLoads.delete(source);
78
+ return { status: "error", message: "The diagram renderer failed to load." };
79
+ }
80
+ }
81
+ try {
82
+ const { svg, width, height } = pele.render(source, {
83
+ links: false,
84
+ images: false,
85
+ // Keep the author's direction; a wide diagram scales down to fit instead of turning vertical.
86
+ autoDirection: false,
87
+ });
88
+ return { status: "ready", svg, width, height };
89
+ } catch (error) {
90
+ return {
91
+ status: "error",
92
+ message: error instanceof Error ? error.message : "The diagram could not be rendered.",
93
+ };
94
+ }
95
+}
96
+
97
+// The image viewer zooms a bitmap: about twice a phone's screen leaves room to zoom while
98
+// bounding the memory one image takes.
99
+const EXPORT_LONGEST_SIDE = 3072;
100
+
101
+/** Named by content, so a theme change never shows a stale image cached under the same URI. */
102
+async function writeDiagramImage(xml: string, base64: string): Promise<string> {
103
+ const file = new File(Paths.cache, "t3-diagrams", `${(Hash.string(xml) >>> 0).toString(36)}.png`);
104
+ file.create({ intermediates: true, overwrite: true });
105
+ await file.write(base64, { encoding: "base64" });
106
+ return file.uri;
107
+}
108
+
109
+type Expansion =
110
+ | { readonly status: "exporting" }
111
+ | { readonly status: "open"; readonly uri: string };
112
+
113
+type MermaidCodeBlockProps = {
114
+ readonly code: string;
115
+ readonly textStyle: NativeMarkdownTextStyle;
116
+};
117
+
118
+/** A complete ```mermaid fence, drawn as its diagram with a toggle back to the source. */
119
+export function MermaidCodeBlock(props: MermaidCodeBlockProps) {
120
+ return (
121
+ <Suspense fallback={<MermaidBlock {...props} diagram={null} />}>
122
+ <RenderedMermaidBlock {...props} />
123
+ </Suspense>
124
+ );
125
+}
126
+
127
+function RenderedMermaidBlock(props: MermaidCodeBlockProps) {
128
+ return <MermaidBlock {...props} diagram={use(loadDiagram(props.code.trim()))} />;
129
+}
130
+
131
+function MermaidBlock(props: MermaidCodeBlockProps & { readonly diagram: Diagram | null }) {
132
+ const { code, textStyle, diagram } = props;
133
+ const [showCode, setShowCode] = useState(false);
134
+ const [expansion, setExpansion] = useState<Expansion | null>(null);
135
+ const exportSvg = useRef<Svg>(null);
136
+ const secondaryColor = themeColorWithAlpha(textStyle.codeColor, 0.6);
137
+ const codeFontSize = textStyle.fontSize * 0.9;
138
+ const svg =
139
+ diagram?.status === "ready"
140
+ ? mermaidSvgForNative(diagram.svg, {
141
+ "--pele-bg": textStyle.codeBlockBackgroundColor,
142
+ "--pele-fg": textStyle.color,
143
+ "--pele-muted": themeColorWithAlpha(textStyle.color, 0.65),
144
+ "--pele-line": themeColorWithAlpha(textStyle.color, 0.55),
145
+ "--pele-surface": themeColorWithAlpha(textStyle.color, 0.06),
146
+ "--pele-surface-alt": themeColorWithAlpha(textStyle.color, 0.12),
147
+ "--pele-border": themeColorWithAlpha(textStyle.color, 0.28),
148
+ "--pele-accent": textStyle.linkColor,
149
+ "--pele-font": DIAGRAM_FONT,
150
+ "--pele-font-mono": MONOSPACE,
151
+ })
152
+ : null;
153
+ const exportXml =
154
+ expansion?.status === "exporting" && svg
155
+ ? withDiagramBackground(svg, textStyle.codeBlockBackgroundColor)
156
+ : null;
157
+ const exportTree = exportXml ? parse(exportXml) : null;
158
+ const exportScale =
159
+ diagram?.status === "ready" ? EXPORT_LONGEST_SIDE / Math.max(diagram.width, diagram.height) : 0;
160
+ // In points. iOS draws the copy at its own size and the screen scale, Android at the
161
+ // requested pixels, so the copy is laid out at the export size for both.
162
+ const exportSize =
163
+ diagram?.status === "ready"
164
+ ? {
165
+ width: (diagram.width * exportScale) / PixelRatio.get(),
166
+ height: (diagram.height * exportScale) / PixelRatio.get(),
167
+ }
168
+ : null;
169
+
170
+ // Runs once the hidden export copy has laid out.
171
+ const exportDiagram = () => {
172
+ if (!exportSvg.current || !exportXml || !exportSize) return;
173
+ const pixels = Platform.OS === "ios" ? 1 : PixelRatio.get();
174
+ exportSvg.current.toDataURL(
175
+ (base64) => {
176
+ // A failed capture calls back with nothing; let the next tap try again.
177
+ if (!base64) {
178
+ setExpansion(null);
179
+ return;
180
+ }
181
+ // iOS wraps the encoding in line feeds.
182
+ writeDiagramImage(exportXml, base64.replace(/\s/g, "")).then(
183
+ (uri) => setExpansion({ status: "open", uri }),
184
+ () => setExpansion(null),
185
+ );
186
+ },
187
+ {
188
+ width: Math.round(exportSize.width * pixels),
189
+ height: Math.round(exportSize.height * pixels),
190
+ },
191
+ );
192
+ };
193
+
194
+ // The header copies the native code block's, which this block replaces once the fence closes.
195
+ return (
196
+ <View
197
+ style={[
198
+ styles.block,
199
+ {
200
+ backgroundColor: textStyle.codeBlockBackgroundColor,
201
+ borderColor: textStyle.dividerColor,
202
+ },
203
+ ]}
204
+ >
205
+ <View
206
+ style={[
207
+ styles.header,
208
+ { borderBottomColor: themeColorWithAlpha(textStyle.codeColor, 0.2) },
209
+ ]}
210
+ >
211
+ <Text style={[styles.language, { color: secondaryColor, fontSize: codeFontSize * 0.85 }]}>
212
+ Mermaid
213
+ </Text>
214
+ <View style={styles.actions}>
215
+ {svg ? (
216
+ <HeaderButton
217
+ icon={showCode ? "flowchart" : "chevron.left.forwardslash.chevron.right"}
218
+ label={showCode ? "Show diagram" : "Show code"}
219
+ color={secondaryColor}
220
+ onPress={() => setShowCode((value) => !value)}
221
+ />
222
+ ) : null}
223
+ <HeaderButton
224
+ icon="doc.on.doc"
225
+ label="Copy code"
226
+ color={secondaryColor}
227
+ onPress={() => copyTextWithHaptic(code)}
228
+ />
229
+ </View>
230
+ </View>
231
+ <View style={styles.content}>
232
+ {diagram?.status === "error" ? (
233
+ <Text style={[styles.error, { color: secondaryColor, fontSize: codeFontSize * 0.85 }]}>
234
+ Unable to render diagram: {diagram.message}
235
+ </Text>
236
+ ) : null}
237
+ {svg && diagram?.status === "ready" && !showCode ? (
238
+ // In a row the width resolves first, so the height follows the shrunk width;
239
+ // a column with maxWidth would size the height from the full width.
240
+ <View style={styles.diagramRow}>
241
+ <Pressable
242
+ accessibilityRole="imagebutton"
243
+ accessibilityLabel="Mermaid diagram"
244
+ accessibilityHint="Opens the diagram full screen"
245
+ onPress={() => {
246
+ if (expansion) return;
247
+ void Haptics.selectionAsync();
248
+ setExpansion({ status: "exporting" });
249
+ }}
250
+ style={{
251
+ flexBasis: diagram.width,
252
+ flexShrink: 1,
253
+ aspectRatio: diagram.width / diagram.height,
254
+ }}
255
+ >
256
+ <SvgXml xml={svg} width="100%" height="100%" />
257
+ </Pressable>
258
+ </View>
259
+ ) : (
260
+ <Text
261
+ selectable
262
+ style={{
263
+ color: textStyle.codeColor,
264
+ fontFamily: MONOSPACE,
265
+ fontSize: codeFontSize,
266
+ lineHeight: codeFontSize * 1.45,
267
+ }}
268
+ >
269
+ {code}
270
+ </Text>
271
+ )}
272
+ </View>
273
+ {expansion?.status === "exporting" && exportTree && exportSize ? (
274
+ <View pointerEvents="none" style={[styles.exportCopy, exportSize]} onLayout={exportDiagram}>
275
+ <Svg ref={exportSvg} {...exportTree.props} width="100%" height="100%">
276
+ {exportTree.children}
277
+ </Svg>
278
+ </View>
279
+ ) : null}
280
+ {expansion?.status === "open" ? (
281
+ <MediaImagePreview
282
+ source={{
283
+ kind: "image",
284
+ selectedIndex: 0,
285
+ images: [
286
+ {
287
+ kind: "image",
288
+ uri: expansion.uri,
289
+ name: "Mermaid diagram",
290
+ mimeType: "image/png",
291
+ actionsSource: {
292
+ uri: expansion.uri,
293
+ name: "Mermaid diagram.png",
294
+ mimeType: "image/png",
295
+ },
296
+ },
297
+ ],
298
+ }}
299
+ onRequestClose={() => setExpansion(null)}
300
+ />
301
+ ) : null}
302
+ </View>
303
+ );
304
+}
305
+
306
+function HeaderButton(props: {
307
+ readonly icon: AppSymbolName;
308
+ readonly label: string;
309
+ readonly color: string;
310
+ readonly onPress: () => void;
311
+}) {
312
+ return (
313
+ <Pressable
314
+ accessibilityRole="button"
315
+ accessibilityLabel={props.label}
316
+ hitSlop={10}
317
+ onPress={props.onPress}
318
+ >
319
+ <SymbolView name={props.icon} size={14} tintColor={props.color} type="monochrome" />
320
+ </Pressable>
321
+ );
322
+}
323
+
324
+// The block slot already applies the code block's outer margins.
325
+const styles = StyleSheet.create({
326
+ block: {
327
+ borderRadius: 8,
328
+ borderWidth: StyleSheet.hairlineWidth,
329
+ overflow: "hidden",
330
+ },
331
+ header: {
332
+ height: 32,
333
+ paddingHorizontal: 12,
334
+ flexDirection: "row",
335
+ alignItems: "center",
336
+ justifyContent: "space-between",
337
+ borderBottomWidth: StyleSheet.hairlineWidth,
338
+ },
339
+ language: { fontWeight: "500" },
340
+ actions: { flexDirection: "row", alignItems: "center", gap: 14 },
341
+ content: { padding: 12 },
342
+ diagramRow: { flexDirection: "row", justifyContent: "center" },
343
+ error: { marginBottom: 8 },
344
+ exportCopy: { position: "absolute", opacity: 0 },
345
+});
apps/web/package.json
+1
-1
@@ -74,7 +74,7 @@
74
"micromark-util-combine-extensions": "^2.0.1",
75
"morphicons": "^1.7.1",
76
"pdfjs-dist": "6.4.299",
77
- "pele": "^1.8.0",
77
+ "pele": "catalog:",
78
"react": "catalog:",
79
"react-dom": "catalog:",
80
"react-markdown": "^10.1.0",
pnpm-lock.yaml
+7
-1
@@ -227,6 +227,9 @@ catalogs:
227
micromark-util-types:
228
specifier: 2.0.2
229
version: 2.0.2
230
+ pele:
231
+ specifier: ^1.8.0
232
+ version: 1.8.0
233
plist:
234
specifier: 3.1.1
235
version: 3.1.1
@@ -722,6 +725,9 @@ importers:
725
expo-widgets:
726
specifier: 58.0.20
727
version: 58.0.20(patch_hash=8bf49067f93742855e15f29559ac75c8b50230b47069060993c9ea01dac11171)(@babel/core@7.29.7(supports-color@8.1.1))(expo@58.0.14)(react-dom@19.3.0(react@19.3.0))(react-native-worklets@0.13.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
728
+ pele:
729
+ specifier: 'catalog:'
730
+ version: 1.8.0
731
react:
732
specifier: 'catalog:'
733
version: 19.3.0
@@ -1199,7 +1205,7 @@ importers:
1205
specifier: 6.4.299
1206
version: 6.4.299
1207
pele:
1202
- specifier: ^1.8.0
1208
+ specifier: 'catalog:'
1209
version: 1.8.0
1210
react:
1211
specifier: 'catalog:'
pnpm-workspace.yaml
+1
@@ -73,6 +73,7 @@ catalog:
73
jose: 6.2.2
74
lightningcss: 1.33.0
75
objc-js: 1.5.0
76
+ pele: ^1.8.0
77
plist: 3.1.1
78
react: 19.3.0
79
react-dom: 19.3.0