Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(markdown): preserve descriptive file-link labels #15509

Mergedmaria-rcksmerged 4 commits intomain fromrefs/pull/15509/headmerged by maria-rcks View on GitHub

Showing 6 changed files with 111 additions and 29 deletions (loading 4).

x
0 of 6 viewed, 6 left
72 additions and 6 deletionsapps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.tsModified
View file
@@ -1,4 +1,5 @@
import type { MarkdownNode } from "react-native-nitro-markdown/headless";
+import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links";
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
import { imageMimeType } from "@t3tools/shared/image";
import { isWindowsAbsolutePath } from "@t3tools/shared/path";
@@ -109,7 +110,8 @@
}>,
) {
let offset = 0;
- return runs.flatMap(({ run, text, inlineImageLength }) => {
+ const ranges: Array<{ start: number; end: number; text: string }> = [];
+ for (const [index, { run, text, inlineImageLength }] of runs.entries()) {
const start = offset;
offset += text.length + inlineImageLength;
const reference = parseComposerContextHref(run.href ?? "");
@@ -117,11 +119,25 @@
? formatComposerContextReference({ ...reference, label: run.text })
: run.skillName
? `$${run.skillName}`
- : run.fileIcon && run.href
- ? (run.sourceText ?? `[${run.text}](<${run.href}>)`)
- : null;
- return source === null ? [] : [{ start, end: offset, text: source }];
- });
+ : run.sourceText !== undefined
+ ? run.sourceText
+ : run.fileIcon && run.href
+ ? `[${run.text}](<${run.href}>)`