Skip to content

Commit 0959e55

Browse files
committed
chore: sync link menu fix with main
2 parents 79baca9 + cd64ad3 commit 0959e55

9 files changed

Lines changed: 97 additions & 17 deletions

File tree

‎apps/mobile/modules/t3-markdown-text/android/build.gradle‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ android {
88
namespace 'expo.modules.t3markdowntext'
99
compileSdk rootProject.ext.compileSdkVersion
1010

11+
testOptions {
12+
unitTests.includeAndroidResources = true
13+
}
14+
1115
defaultConfig {
1216
minSdkVersion rootProject.ext.minSdkVersion
1317
targetSdkVersion rootProject.ext.targetSdkVersion
@@ -17,4 +21,12 @@ android {
1721
dependencies {
1822
implementation project(':expo-modules-core')
1923
implementation 'com.facebook.react:react-android'
24+
testImplementation 'junit:junit:4.13.2'
25+
testImplementation 'org.robolectric:robolectric:4.16.1'
26+
}
27+
28+
tasks.withType(Test).configureEach {
29+
javaLauncher = javaToolchains.launcherFor {
30+
languageVersion = JavaLanguageVersion.of(21)
31+
}
2032
}

‎apps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.kt‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@ private object MarkdownSpannableFactory : Spannable.Factory() {
2828
SpannableStringBuilder(source)
2929
}
3030

31-
private fun copyTextWithoutInlineImages(
31+
internal fun copyTextWithoutInlineImages(
3232
text: CharSequence,
3333
start: Int,
3434
end: Int
3535
): String {
3636
if (text !is Spanned) return text.subSequence(start, end).toString()
3737

38+
fun isInlineImage(index: Int): Boolean =
39+
index >= 0 && text[index].toString() == OBJECT_REPLACEMENT_CHARACTER &&
40+
text.getSpans(index, index + 1, ReplacementSpan::class.java).isNotEmpty()
41+
3842
return buildString {
3943
for (index in start until end) {
40-
val isInlineImage =
41-
text[index].toString() == OBJECT_REPLACEMENT_CHARACTER &&
42-
text.getSpans(index, index + 1, ReplacementSpan::class.java).isNotEmpty()
43-
if (!isInlineImage) append(text[index])
44+
// The renderer inserts one NBSP after each image to keep its label on the same line.
45+
// Inspect the original text even when selection starts after the image.
46+
val isIconSpacer = text[index] == '\u00A0' && isInlineImage(index - 1)
47+
if (!isInlineImage(index) && !isIconSpacer) append(text[index])
4448
}
4549
}
4650
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package expo.modules.t3markdowntext
2+
3+
import android.graphics.drawable.ColorDrawable
4+
import android.text.SpannableString
5+
import android.text.Spanned
6+
import android.text.style.ImageSpan
7+
import org.junit.Assert.assertEquals
8+
import org.junit.Test
9+
import org.junit.runner.RunWith
10+
import org.robolectric.RobolectricTestRunner
11+
import org.robolectric.annotation.Config
12+
13+
@RunWith(RobolectricTestRunner::class)
14+
@Config(sdk = [36], manifest = Config.NONE)
15+
class MarkdownSelectionCopyTest {
16+
private fun withIcon(value: String): SpannableString = SpannableString(value).apply {
17+
val index = value.indexOf('\uFFFC')
18+
setSpan(ImageSpan(ColorDrawable()), index, index + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
19+
}
20+
21+
@Test
22+
fun removesIconAndInjectedSpacer() {
23+
val text = withIcon("\uFFFC\u00A0main.go:12 starts the server.")
24+
assertEquals("main.go:12 starts the server.", copyTextWithoutInlineImages(text, 0, text.length))
25+
}
26+
27+
@Test
28+
fun removesSpacerWhenSelectionStartsAfterIcon() {
29+
val text = withIcon("\uFFFC\u00A0main.go:12 starts the server.")
30+
assertEquals("main.go:12", copyTextWithoutInlineImages(text, 1, 12))
31+
}
32+
33+
@Test
34+
fun preservesAuthoredWhitespaceAndLiteralObjectCharacters() {
35+
val text = withIcon("before\u00A0 \uFFFC\u00A0\u00A0 main.go after\u00A0\uFFFC\u00A0")
36+
assertEquals(
37+
"before\u00A0 \u00A0 main.go after\u00A0\uFFFC\u00A0",
38+
copyTextWithoutInlineImages(text, 0, text.length)
39+
)
40+
}
41+
42+
@Test
43+
fun preservesTextWithoutImageSpans() {
44+
val text = "\uFFFC\u00A0main.go"
45+
assertEquals(text, copyTextWithoutInlineImages(text, 0, text.length))
46+
assertEquals(text, copyTextWithoutInlineImages(SpannableString(text), 0, text.length))
47+
}
48+
}

‎apps/mobile/modules/t3-markdown-text/src/NativeMarkdownSelectableText.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ export function NativeMarkdownSelectableText(props: {
222222
}
223223
}
224224

225+
// Android renders the icon as an inline Image before the text. A regular space
226+
// lets the line break between them, stranding the icon on the previous line.
227+
if (Platform.OS === "android" && (run.fileIcon || linkIcon)) {
228+
text = `\u00A0${text}`;
229+
}
230+
225231
return { key: `${signature}:${occurrence}`, run, text, linkIcon };
226232
});
227233
// T3MarkdownText only rebuilds its attributed string during native layout. A

‎apps/web/src/components/GitActionsControl.tsx‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function getMenuActionDisabledReason({
303303

304304
if (item.id === "push") {
305305
if (!hasBranch) {
306-
return "Detached HEAD: checkout a refName before pushing.";
306+
return "Detached HEAD: check out a branch before pushing.";
307307
}
308308
if (hasChanges) {
309309
return "Commit or stash local changes before pushing.";
@@ -324,7 +324,7 @@ function getMenuActionDisabledReason({
324324
return `View ${terminology.singular} is currently unavailable.`;
325325
}
326326
if (!hasBranch) {
327-
return `Detached HEAD: checkout a refName before creating a ${terminology.singular}.`;
327+
return `Detached HEAD: check out a branch before creating a ${terminology.singular}.`;
328328
}
329329
if (hasChanges) {
330330
return `Commit local changes before creating a ${terminology.singular}.`;
@@ -1754,7 +1754,7 @@ export default function GitActionsControl({
17541754
) : null}
17551755
{gitStatusForActions?.refName === null && (
17561756
<p className="px-2 py-1.5 text-xs text-warning">
1757-
Detached HEAD: create and checkout a refName to enable push and pull request
1757+
Detached HEAD: create and check out a branch to enable push and pull request
17581758
actions.
17591759
</p>
17601760
)}
@@ -1799,9 +1799,7 @@ export default function GitActionsControl({
17991799
<span className="font-medium">
18001800
{gitStatusForActions?.refName ?? "(detached HEAD)"}
18011801
</span>
1802-
{isDefaultRef && (
1803-
<span className="text-right text-warning">Warning: default refName</span>
1804-
)}
1802+
{isDefaultRef && <span className="text-right text-warning">Default branch</span>}
18051803
</span>
18061804
</div>
18071805
<div className="space-y-1">
@@ -1932,7 +1930,7 @@ export default function GitActionsControl({
19321930
disabled={noneSelected}
19331931
onClick={runDialogActionOnNewBranch}
19341932
>
1935-
Commit on new refName
1933+
Commit on new branch
19361934
</Button>
19371935
<Button size="sm" disabled={noneSelected} onClick={runDialogAction}>
19381936
Commit
@@ -1960,7 +1958,7 @@ export default function GitActionsControl({
19601958
<DialogPopup className="max-w-xl">
19611959
<DialogHeader>
19621960
<DialogTitle>
1963-
{pendingDefaultBranchActionCopy?.title ?? "Run action on default refName?"}
1961+
{pendingDefaultBranchActionCopy?.title ?? "Run action on default branch?"}
19641962
</DialogTitle>
19651963
<DialogDescription>{pendingDefaultBranchActionCopy?.description}</DialogDescription>
19661964
</DialogHeader>
@@ -1986,7 +1984,7 @@ export default function GitActionsControl({
19861984
size="sm"
19871985
onClick={checkoutFeatureBranchAndContinuePendingAction}
19881986
>
1989-
Checkout feature branch & continue
1987+
Check out feature branch & continue
19901988
</Button>
19911989
</DialogFooter>
19921990
</DialogPopup>

‎apps/web/src/components/pullRequest/PullRequestRow.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function PullRequestRowImpl({
104104
aria-current={selected ? "true" : undefined}
105105
onClick={() => onSelect(entry)}
106106
className={cn(
107-
"@container/pr-row grid w-full grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
107+
"@container/pr-row grid w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
108108
// Offscreen rows are skipped for style, layout and paint: a long list costs what the
109109
// viewport shows, not what the pages have loaded. The intrinsic size keeps the
110110
// scrollbar honest while a row is skipped.

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ export function PullRequestSummaryTab({
806806
onClick={() => check.url && openCheck(check.url)}
807807
className={cn(
808808
"flex min-w-0 flex-1 items-start gap-2 rounded-md px-2 py-2 text-left text-xs leading-5 [&>svg]:mt-0.5",
809-
check.url ? undefined : "cursor-default",
809+
check.url ? "cursor-pointer" : "cursor-default",
810810
)}
811811
>
812812
<PullRequestCheckStatusIcon status={check.status} />

‎apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function CommitEvent({
385385
return (
386386
<button
387387
type="button"
388-
className="group relative mb-5 block w-full rounded-sm pl-12 text-left outline-none [contain-intrinsic-block-size:48px] [content-visibility:auto] focus-visible:ring-2 focus-visible:ring-ring"
388+
className="group relative mb-5 block w-full cursor-pointer rounded-sm pl-12 text-left outline-none [contain-intrinsic-block-size:48px] [content-visibility:auto] focus-visible:ring-2 focus-visible:ring-ring"
389389
aria-label={`View commit ${event.id}`}
390390
onClick={() => onOpen(event.id)}
391391
>

‎apps/web/src/index.css‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,18 @@ html[data-theme-id] [data-workspace-titlebar-controls] [data-slot="tooltip-trigg
13031303
color: var(--contrast-toolbar-foreground);
13041304
}
13051305

1306+
html[data-theme-id] [data-panel-layout-controls] [data-slot="toggle"]:disabled,
1307+
html[data-theme-id] [data-panel-layout-controls] [data-slot="tooltip-trigger"]:disabled,
1308+
html[data-theme-id] [data-workspace-titlebar-controls] [data-slot="toggle"]:disabled,
1309+
html[data-theme-id] [data-workspace-titlebar-controls] [data-slot="tooltip-trigger"]:disabled {
1310+
--control-icon-color: color-mix(
1311+
in oklab,
1312+
var(--contrast-toolbar-foreground) 55%,
1313+
var(--toolbar-background)
1314+
);
1315+
color: color-mix(in oklab, var(--contrast-toolbar-foreground) 55%, var(--toolbar-background));
1316+
}
1317+
13061318
html[data-theme-id] [data-chat-header] [data-slot="button"]:hover,
13071319
html[data-theme-id] [data-chat-header] [data-slot="button"][data-pressed],
13081320
html[data-theme-id] [data-chat-header] [data-slot="menu-trigger"]:hover,

0 commit comments

Comments
 (0)