diff --git a/apps/mobile/deps/README.md b/apps/mobile/deps/README.md
index 82ca9c7f8c..d65a835a63 100644
--- a/apps/mobile/deps/README.md
+++ b/apps/mobile/deps/README.md
@@ -1,4 +1,4 @@
-The Enriched Markdown tarball comes from `main` of [aislopware/enriched-markdown](https://github.com/aislopware/enriched-markdown). Its `oni-fork.json` records the exact source commit and upstream base. React block renderers, signed image sources, the `onLinksChange` link list (`renderers`, `resolveImageSource`, `onLinksChange`) and the iOS streaming memory bounds are upstream. The fork carries only changes with an open upstream PR: clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)) and hash-route link fragments ([mity/md4c#454](https://github.com/mity/md4c/pull/454), arriving through [md4c#7](https://github.com/software-mansion-labs/md4c/pull/7)), `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [mity/md4c#477](https://github.com/mity/md4c/pull/477)), GitHub's strikethrough rules for `~` ([md4c#6](https://github.com/software-mansion-labs/md4c/pull/6)), `\(…\)` and `\[…\]` math delimiters ([#1043](https://github.com/software-mansion/enriched-markdown/pull/1043), [md4c#4](https://github.com/software-mansion-labs/md4c/pull/4)), iOS Copy as Markdown keeping bold spans whole ([#1143](https://github.com/software-mansion/enriched-markdown/pull/1143)), line breaks in copied table cells written as `
` ([#1144](https://github.com/software-mansion/enriched-markdown/pull/1144)), and Android measuring text in the span order its view draws it, so code blocks nested in list items no longer make a reply overlap the next message ([#1145](https://github.com/software-mansion/enriched-markdown/pull/1145)). It also carries two fork-only changes, both from T3 Code's fork: iOS code blocks too big for one backing store draw through tiles, so a tall block with long lines no longer shows an empty pane ([pingdotgg/enriched-markdown#15](https://github.com/pingdotgg/enriched-markdown/pull/15)), and a long-pressed iOS blockquote lifts on the background it sits on instead of drawing its text over the thread.
+The Enriched Markdown tarball comes from `main` of [aislopware/enriched-markdown](https://github.com/aislopware/enriched-markdown). Its `oni-fork.json` records the exact source commit and upstream base. React block renderers, signed image sources, the `onLinksChange` link list (`renderers`, `resolveImageSource`, `onLinksChange`) and the iOS streaming memory bounds are upstream. The fork carries only changes with an open upstream PR: clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)) and hash-route link fragments ([mity/md4c#454](https://github.com/mity/md4c/pull/454), arriving through [md4c#7](https://github.com/software-mansion-labs/md4c/pull/7)), `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [mity/md4c#477](https://github.com/mity/md4c/pull/477)), GitHub's strikethrough rules for `~` ([md4c#6](https://github.com/software-mansion-labs/md4c/pull/6)), `\(…\)` and `\[…\]` math delimiters ([#1043](https://github.com/software-mansion/enriched-markdown/pull/1043), [md4c#4](https://github.com/software-mansion-labs/md4c/pull/4)), iOS Copy as Markdown keeping bold spans whole ([#1143](https://github.com/software-mansion/enriched-markdown/pull/1143)), line breaks in copied table cells written as `
` ([#1144](https://github.com/software-mansion/enriched-markdown/pull/1144)), and Android measuring text in the span order its view draws it, so code blocks nested in list items no longer make a reply overlap the next message ([#1145](https://github.com/software-mansion/enriched-markdown/pull/1145)). It also carries three fork-only changes. `writingDirection="word-majority"` sets each paragraph, list item, heading and table cell right to left when its right-to-left words outnumber its left-to-right ones. It counts words as the desktop client does, but decides per paragraph where desktop decides per top-level block (Android API 29+; older Android keeps first-strong). The other two come from T3 Code's fork: iOS code blocks too big for one backing store draw through tiles, so a tall block with long lines no longer shows an empty pane ([pingdotgg/enriched-markdown#15](https://github.com/pingdotgg/enriched-markdown/pull/15)), and a long-pressed iOS blockquote lifts on the background it sits on instead of drawing its text over the thread.
To replace it, commit the fork changes on `main` with the next `1.2.0-oni.N` version, run `yarn install --immutable` and `yarn workspace react-native-enriched-markdown prepare` in the fork checkout, then `yarn workspace react-native-enriched-markdown pack:onicode /absolute/path/to/onicode/apps/mobile/deps`. Tag the source commit `oni-v` and push `main` and the tag to the fork. Rename the archive to include the first eight characters of the source commit, as in `react-native-enriched-markdown--.tgz`, so each build has a distinct dependency path. Update the tarball path in `apps/mobile/package.json` and `pnpm-workspace.yaml`'s `allowBuilds`, and run `vp i` to update the lockfile. Native clients need rebuilding when this dependency changes.
diff --git a/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz b/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz
deleted file mode 100644
index 2f09cc2925..0000000000
Binary files a/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz and /dev/null differ
diff --git a/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz b/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz
new file mode 100644
index 0000000000..a7b7a0f6af
Binary files /dev/null and b/apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz differ
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index b8a0dc3420..1139e5b15d 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -104,7 +104,7 @@
"react": "catalog:",
"react-dom": "catalog:",
"react-native": "0.88.1",
- "react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz",
+ "react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz",
"react-native-gesture-handler": "~3.5.0",
"react-native-image-viewing": "^0.2.2",
"react-native-keyboard-controller": "1.23.0",
diff --git a/apps/mobile/src/features/threads/PendingUserInputCard.tsx b/apps/mobile/src/features/threads/PendingUserInputCard.tsx
index e86aa90214..56b28a4680 100644
--- a/apps/mobile/src/features/threads/PendingUserInputCard.tsx
+++ b/apps/mobile/src/features/threads/PendingUserInputCard.tsx
@@ -109,7 +109,8 @@ function QuestionText(props: {
{
"Try (model:codex/gpt-6.1).",
"Try [model:codex/gpt-6.1] next",
'"model:codex/gpt-6.1"',
- "model:codex/gpt-6.1 هذا شرح",
]) {
const source = regex?.exec(text)?.[0];
expect(source, text).toBe("model:codex/gpt-6.1");
diff --git a/apps/mobile/src/lib/enrichedLinkPresentation.ts b/apps/mobile/src/lib/enrichedLinkPresentation.ts
index 3436469116..83b58c5108 100644
--- a/apps/mobile/src/lib/enrichedLinkPresentation.ts
+++ b/apps/mobile/src/lib/enrichedLinkPresentation.ts
@@ -174,9 +174,8 @@ export function enrichedModelLinkRegex(models?: ReadonlyArray model.source)
.sort((a, b) => b.length - a.length)
.map((source) => source.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
- // LRM and RLM can open a paragraph whose first word runs against the text direction.
return new RegExp(
- `(?` would break the reference or autolink.
-function firstLeafOffset(node: MarkdownNode): number | undefined {
- if (
- !("children" in node) ||
- node.children.length === 0 ||
- node.type === "link" ||
- node.type === "linkReference"
- ) {
- return node.position?.start.offset;
- }
- return firstLeafOffset(node.children[0]!);
-}
-
-/**
- * The native renderer gives each paragraph the direction of its first letter, so an Arabic
- * line that opens with an English name renders left to right. Like the web's
- * `rehypeTextDirection`, each top-level block follows the majority of its words, and a
- * paragraph whose first letter disagrees gets a direction mark that the renderer reads first.
- */
-export function markdownWithTextDirection(markdown: string): string {
- if (!hasRightToLeftLetter(markdown)) return markdown;
- const edits: MarkdownEdit[] = [];
- for (const block of parser.parse(markdown).children) {
- if (block.type === "code" || block.type === "html") continue;
- const direction = textDirection(proseText(block));
- if (!direction) continue;
- const mark = (node: MarkdownNode) => {
- if (node.type === "paragraph" || node.type === "heading" || node.type === "tableCell") {
- const offset = firstLeafOffset(node);
- const first = renderedText(node).match(/\p{L}/u)?.[0];
- if (offset !== undefined && first && textDirection(first) !== direction) {
- edits.push({ start: offset, end: offset, content: DIRECTION_MARK[direction] });
- }
- return;
- }
- if ("children" in node) node.children.forEach(mark);
- };
- mark(block);
- }
- return applyMarkdownEdits(markdown, edits);
-}
diff --git a/apps/mobile/src/lib/markdownTextDirection.test.ts b/apps/mobile/src/lib/markdownTextDirection.test.ts
deleted file mode 100644
index e4493df809..0000000000
--- a/apps/mobile/src/lib/markdownTextDirection.test.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import { describe, expect, it } from "vite-plus/test";
-import { markdownWithTextDirection } from "./markdownDocument";
-
-const LRM = "";
-const RLM = "";
-
-describe("markdownWithTextDirection", () => {
- it("marks Arabic list items that open with an English name", () => {
- const markdown = [
- "## للنمو والتقوية",
- "",
- "- **Plantur**، Haarserum 100 مل، 14,95 €. سيروم مخصص للشعر الطويل بالكافيين، أغلى واحد في القائمة.",
- "- **Bali Curls**، زيت إكليل الجبل للفروة والشعر، موجه للشعر اللي بيخف.",
- ].join("\n");
-
- expect(markdownWithTextDirection(markdown)).toBe(
- [
- "## للنمو والتقوية",
- "",
- `- **${RLM}Plantur**، Haarserum 100 مل، 14,95 €. سيروم مخصص للشعر الطويل بالكافيين، أغلى واحد في القائمة.`,
- `- **${RLM}Bali Curls**، زيت إكليل الجبل للفروة والشعر، موجه للشعر اللي بيخف.`,
- ].join("\n"),
- );
- });
-
- it("keeps an English list on one side when one item opens in Arabic", () => {
- const markdown = "- Install the package first.\n- مرحبا then run the build and tests.";
- expect(markdownWithTextDirection(markdown)).toBe(
- `- Install the package first.\n- ${LRM}مرحبا then run the build and tests.`,
- );
- });
-
- it("skips code and keeps task list checkboxes intact", () => {
- const markdown = "```\nconst a = 'مرحبا';\n```\n\n- [ ] npm تشغيل الأوامر من المجلد الرئيسي";
- expect(markdownWithTextDirection(markdown)).toBe(
- `\`\`\`\nconst a = 'مرحبا';\n\`\`\`\n\n- [ ] ${RLM}npm تشغيل الأوامر من المجلد الرئيسي`,
- );
- });
-
- it("keeps words apart across table cells", () => {
- const markdown = "| Name | الاسم | الوصف |\n| --- | --- | --- |\n| Price | السعر | القيمة |";
- expect(markdownWithTextDirection(markdown)).toBe(
- `| ${RLM}Name | الاسم | الوصف |\n| --- | --- | --- |\n| ${RLM}Price | السعر | القيمة |`,
- );
- });
-
- it("puts the mark before a link so references and autolinks still parse", () => {
- const markdown = [
- "[Plantur] هذا شرح عربي طويل للمنتج",
- "",
- " هذا شرح عربي طويل للرابط",
- "",
- "[Plantur]: /product",
- ].join("\n");
- expect(markdownWithTextDirection(markdown)).toBe(
- [
- `${RLM}[Plantur] هذا شرح عربي طويل للمنتج`,
- "",
- `${RLM} هذا شرح عربي طويل للرابط`,
- "",
- "[Plantur]: /product",
- ].join("\n"),
- );
- });
-
- it("marks Arabic paragraphs that open with inline code", () => {
- expect(markdownWithTextDirection("`npm` تشغيل الأوامر من المجلد الرئيسي")).toBe(
- `${RLM}\`npm\` تشغيل الأوامر من المجلد الرئيسي`,
- );
- });
-});
diff --git a/apps/mobile/src/native/EnrichedMarkdownText.tsx b/apps/mobile/src/native/EnrichedMarkdownText.tsx
index d9be7e9a18..a51ceffd0a 100644
--- a/apps/mobile/src/native/EnrichedMarkdownText.tsx
+++ b/apps/mobile/src/native/EnrichedMarkdownText.tsx
@@ -10,7 +10,6 @@ import {
markdownForNativeParsing,
markdownWithInlineFileLinks,
markdownWithTableBreaks,
- markdownWithTextDirection,
} from "../lib/markdownDocument";
import { useGT } from "gt-react-native";
import { isValidElement, useMemo, useState, type ReactElement, type ReactNode } from "react";
@@ -250,9 +249,7 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
const { markdown, fileHrefs } = useMemo(() => {
if (!fileEmbedLabel) {
return {
- markdown: markdownWithTextDirection(
- markdownForNativeRendering(props.markdown, ENRICHED_INLINE_FILE_LINK_REGEX),
- ),
+ markdown: markdownForNativeRendering(props.markdown, ENRICHED_INLINE_FILE_LINK_REGEX),
fileHrefs: new Set(),
};
}
@@ -261,10 +258,7 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
ENRICHED_INLINE_FILE_LINK_REGEX,
);
const files = markdownWithFileEmbeds(content, fileEmbedLabel);
- return {
- ...files,
- markdown: markdownWithTextDirection(markdownWithTableBreaks(files.markdown)),
- };
+ return { ...files, markdown: markdownWithTableBreaks(files.markdown) };
}, [props.markdown, fileEmbedLabel]);
const [parsedLinkUrls, setParsedLinkUrls] = useState>([]);
const onLinksChange = (links: MarkdownLinkOccurrence[]) => {
@@ -440,7 +434,8 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
ltr ? "rtl" : "ltr";
}
-export function hasRightToLeftLetter(text: string): boolean {
- return RTL_LETTER.test(text);
-}
-
function wordDirection(word: string): TextDirection | undefined {
const letter = LETTER.exec(word)?.[0];
if (!letter) return undefined;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6b447908fa..fc217c111f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -661,8 +661,8 @@ importers:
specifier: 0.88.1
version: 0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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-native-enriched-markdown:
- specifier: file:deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz
- version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz(katex@0.19.1)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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)
+ specifier: file:deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz
+ version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz(katex@0.19.1)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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)
react-native-gesture-handler:
specifier: 3.5.0
version: 3.5.0(patch_hash=171379dd378f8f11e9187876dec2116e5cbf5f21cef6576cdde6956518324f98)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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)
@@ -10394,9 +10394,9 @@ packages:
'@types/react': '>=18'
react: '>=18'
- react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz:
- resolution: {integrity: sha512-5EqiGtTxgmhORccH0MhccAR1ufofK7wcusubNpZAG4QE8FIdAxFsueFKaAs4xAY8MPG7e9OIC8im9bNnySFMew==, tarball: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz}
- version: 1.2.0-oni.21
+ react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz:
+ resolution: {integrity: sha512-9lON2T//R08HyuFASxt1ZhAFvAG8xZMjJRAMcBwGtby8jsJcLezcHrqDbeBiCDsQw0TGaH7yqMw582bMqYExUw==, tarball: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz}
+ version: 1.2.0-oni.22
peerDependencies:
katex: '>=0.16.0'
react: '*'
@@ -20045,7 +20045,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
- react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz(katex@0.19.1)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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):
+ react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz(katex@0.19.1)(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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):
dependencies:
react: 19.3.0
react-native: 0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@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)
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index d46c88fecf..a4fdf97a21 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -25,7 +25,7 @@ allowBuilds:
objc-js: false
# Its postinstall only prints a banner.
react-native-pdf-jsi: false
- "react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.21-a423deee.tgz": true
+ "react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-oni.22-0c421a6f.tgz": true
sharp: true
utf-8-validate: false
# Verifies the workerd binary for the push gateway's local dev server.
diff --git a/scripts/upstream-sync.ledger.tsv b/scripts/upstream-sync.ledger.tsv
index 45e15e678e..f566ab9ded 100644
--- a/scripts/upstream-sync.ledger.tsv
+++ b/scripts/upstream-sync.ledger.tsv
@@ -2667,7 +2667,7 @@ bc6621d73a take CONFLICT resolved: kept Onicode's untrimmed-root check (and befo
2c7bfcec84 skip already in Onicode: the floating dictation pill already carries [-webkit-app-region:no-drag] (kept Onicode's: same fix, plus its shadow-popup tokens and a comment on why)
470ca63499 take taken as is
2a411317d9 take fix(web): PDF pages no longer turn black while the panel is resized
-0317d4f4e5 take fix(mobile): Arabic paragraphs that open with an English word render right to left
+0317d4f4e5 take fix(mobile): Arabic paragraphs that open with an English word render right to left; JS marks replaced by the enriched-markdown fork's native word-majority writing direction (1.2.0-oni.22), since a mark before a bare link broke its autolink
25854935ba take fix(server): theme publish refuses a directory under the theme's file name; scenario cli-theme-publish-keeps-existing-directory ported (WEB runs on Onicode's desktop target)
60c6952430 take fix(mobile): a missing image no longer stops its gallery opening on Android (#39128)
4113f8fee5 take fix(web): block invalid project monograms before save (#39131)