Skip to content

Commit 4fed6cf

Browse files
feat: add inline file previews and attachment chips across surfaces (pingdotgg#11265)
Co-authored-by: Julius Marminge <[email protected]>
1 parent ca6416e commit 4fed6cf

260 files changed

Lines changed: 21441 additions & 4843 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ node_modules/
4040
*.log
4141
.env*
4242
!.env.example
43+
44+
# pnpm content-addressable store; never belongs in the repo.
45+
.pnpm-store/

‎.pnpm-store/v11/index.db‎

8 KB
Binary file not shown.

‎apps/desktop/src/electron/ElectronProtocol.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ describe("ElectronProtocol", () => {
226226
"https:",
227227
]);
228228
assert.deepEqual(directives["media-src"], ["'self'", "t3code:", "blob:", "http:", "https:"]);
229+
assert.deepEqual(directives["frame-src"], ["'self'", "blob:", "http:", "https:"]);
229230
assert.deepEqual(directives["font-src"], ["'self'", "t3code:", "data:"]);
230231
});
231232
});

‎apps/desktop/src/electron/ElectronProtocol.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ export function makeDesktopContentSecurityPolicy(input: DesktopProtocolRegistrat
9191
"style-src 'self' 'unsafe-inline'",
9292
`font-src 'self' ${input.scheme}: data:`,
9393
"worker-src 'self' blob:",
94-
"frame-src 'self' https://challenges.cloudflare.com",
94+
// Document viewers use local Blob URLs and signed assets from runtime environments.
95+
// HTML viewers retain their own sandbox; the renderer's script policy stays unchanged.
96+
"frame-src 'self' blob: http: https:",
9597
"form-action 'self'",
9698
].join("; ");
9799
}

‎apps/mobile/generated-uniwind-default-theme-variables.json‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@
6060
"--color-md-blockquote-bg": "rgba(0, 0, 0, 0.02)",
6161
"--color-md-code-bg": "rgba(0, 0, 0, 0.04)",
6262
"--color-md-code-text": "#262626",
63-
"--color-md-user-code-bg": "rgba(255, 255, 255, 0.22)",
64-
"--color-md-user-code-text": "#ffffff",
65-
"--color-md-user-fence-bg": "rgba(0, 0, 0, 0.16)",
66-
"--color-md-user-fence-text": "#ffffff",
63+
"--color-md-user-code-bg": "rgba(0, 0, 0, 0.04)",
64+
"--color-md-user-code-text": "#262626",
65+
"--color-md-user-fence-bg": "rgba(0, 0, 0, 0.06)",
66+
"--color-md-user-fence-text": "#262626",
6767
"--color-md-hr": "rgba(0, 0, 0, 0.08)",
68-
"--color-user-bubble": "#007aff",
69-
"--color-user-bubble-foreground": "#ffffff",
70-
"--color-user-bubble-foreground-muted": "rgba(255, 255, 255, 0.78)",
71-
"--color-user-bubble-skill-foreground": "#f0abfc",
68+
"--color-user-bubble": "#ffffff",
69+
"--color-user-bubble-foreground": "#262626",
70+
"--color-user-bubble-foreground-muted": "rgba(38, 38, 38, 0.78)",
71+
"--color-user-bubble-skill-foreground": "#2563eb",
7272
"--color-backdrop": "rgba(0, 0, 0, 0.22)",
7373
"--color-drawer": "rgba(255, 255, 255, 0.99)",
7474
"--color-drawer-shadow": "rgba(0, 0, 0, 0.12)",
@@ -137,15 +137,15 @@
137137
"--color-md-blockquote-bg": "rgba(255, 255, 255, 0.03)",
138138
"--color-md-code-bg": "rgba(255, 255, 255, 0.06)",
139139
"--color-md-code-text": "#e5e5e5",
140-
"--color-md-user-code-bg": "rgba(255, 255, 255, 0.18)",
141-
"--color-md-user-code-text": "#ffffff",
142-
"--color-md-user-fence-bg": "rgba(0, 0, 0, 0.28)",
143-
"--color-md-user-fence-text": "#ffffff",
140+
"--color-md-user-code-bg": "rgba(255, 255, 255, 0.06)",
141+
"--color-md-user-code-text": "#e5e5e5",
142+
"--color-md-user-fence-bg": "rgba(255, 255, 255, 0.09)",
143+
"--color-md-user-fence-text": "#e5e5e5",
144144
"--color-md-hr": "rgba(255, 255, 255, 0.08)",
145-
"--color-user-bubble": "#0a84ff",
146-
"--color-user-bubble-foreground": "#ffffff",
147-
"--color-user-bubble-foreground-muted": "rgba(255, 255, 255, 0.78)",
148-
"--color-user-bubble-skill-foreground": "#f0abfc",
145+
"--color-user-bubble": "#171717",
146+
"--color-user-bubble-foreground": "#f5f5f5",
147+
"--color-user-bubble-foreground-muted": "rgba(245, 245, 245, 0.78)",
148+
"--color-user-bubble-skill-foreground": "#60a5fa",
149149
"--color-backdrop": "rgba(0, 0, 0, 0.48)",
150150
"--color-drawer": "rgba(14, 14, 14, 0.99)",
151151
"--color-drawer-shadow": "rgba(0, 0, 0, 0.32)",

‎apps/mobile/global.css‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@
9797
--color-md-blockquote-bg: rgba(0, 0, 0, 0.02);
9898
--color-md-code-bg: rgba(0, 0, 0, 0.04);
9999
--color-md-code-text: #262626;
100-
--color-md-user-code-bg: rgba(255, 255, 255, 0.22);
101-
--color-md-user-code-text: #ffffff;
102-
--color-md-user-fence-bg: rgba(0, 0, 0, 0.16);
103-
--color-md-user-fence-text: #ffffff;
100+
--color-md-user-code-bg: rgba(0, 0, 0, 0.04);
101+
--color-md-user-code-text: #262626;
102+
--color-md-user-fence-bg: rgba(0, 0, 0, 0.06);
103+
--color-md-user-fence-text: #262626;
104104
--color-md-hr: rgba(0, 0, 0, 0.08);
105105

106-
/* iMessage-style user bubble */
107-
--color-user-bubble: #007aff;
108-
--color-user-bubble-foreground: #ffffff;
109-
--color-user-bubble-foreground-muted: rgba(255, 255, 255, 0.78);
110-
--color-user-bubble-skill-foreground: #f0abfc;
106+
/* User bubble: a raised card on the thread canvas, matching web's message surface */
107+
--color-user-bubble: #ffffff;
108+
--color-user-bubble-foreground: #262626;
109+
--color-user-bubble-foreground-muted: rgba(38, 38, 38, 0.78);
110+
--color-user-bubble-skill-foreground: #2563eb;
111111

112112
/* Drawer / modal backdrop */
113113
--color-backdrop: rgba(0, 0, 0, 0.22);
@@ -208,17 +208,17 @@
208208
--color-md-blockquote-bg: rgba(255, 255, 255, 0.03);
209209
--color-md-code-bg: rgba(255, 255, 255, 0.06);
210210
--color-md-code-text: #e5e5e5;
211-
--color-md-user-code-bg: rgba(255, 255, 255, 0.18);
212-
--color-md-user-code-text: #ffffff;
213-
--color-md-user-fence-bg: rgba(0, 0, 0, 0.28);
214-
--color-md-user-fence-text: #ffffff;
211+
--color-md-user-code-bg: rgba(255, 255, 255, 0.06);
212+
--color-md-user-code-text: #e5e5e5;
213+
--color-md-user-fence-bg: rgba(255, 255, 255, 0.09);
214+
--color-md-user-fence-text: #e5e5e5;
215215
--color-md-hr: rgba(255, 255, 255, 0.08);
216216

217-
/* iMessage-style user bubble */
218-
--color-user-bubble: #0a84ff;
219-
--color-user-bubble-foreground: #ffffff;
220-
--color-user-bubble-foreground-muted: rgba(255, 255, 255, 0.78);
221-
--color-user-bubble-skill-foreground: #f0abfc;
217+
/* User bubble: a raised card on the thread canvas, matching web's message surface */
218+
--color-user-bubble: #171717;
219+
--color-user-bubble-foreground: #f5f5f5;
220+
--color-user-bubble-foreground-muted: rgba(245, 245, 245, 0.78);
221+
--color-user-bubble-skill-foreground: #60a5fa;
222222

223223
/* Drawer / modal backdrop */
224224
--color-backdrop: rgba(0, 0, 0, 0.48);

‎apps/mobile/modules/t3-composer-editor/android/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ android {
1616

1717
dependencies {
1818
implementation project(':expo-modules-core')
19+
implementation project(':t3tools-mobile-markdown-text')
1920
}

‎apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorModule.kt‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,83 @@ package expo.modules.t3composereditor
22

33
import expo.modules.kotlin.modules.Module
44
import expo.modules.kotlin.modules.ModuleDefinition
5+
import android.content.ClipData
6+
import android.content.ClipboardManager
7+
import android.content.Context
8+
import org.json.JSONObject
9+
import org.json.JSONArray
10+
11+
internal object T3ComposerClipboard {
12+
fun write(context: Context, text: String, fragment: String) {
13+
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
14+
val payload = try {
15+
JSONObject(fragment)
16+
} catch (_: Exception) {
17+
null
18+
}
19+
val records = payload?.optJSONArray("records")
20+
if (payload == null || records == null) {
21+
clipboard.setPrimaryClip(ClipData.newPlainText("T3 Code", text))
22+
return
23+
}
24+
val all = (0 until records.length()).map { records.getJSONObject(it) }
25+
val selected = all.filter { text.contains("/${it.optString("contextId")})") }.toMutableList()
26+
val screenshots = selected.map { it.optString("screenshotContextId") }.toSet()
27+
selected.addAll(
28+
all.filter {
29+
screenshots.contains(it.optString("contextId")) &&
30+
!selected.contains(it)
31+
}
32+
)
33+
payload.put("records", JSONArray(selected))
34+
val encoded = java.net.URLEncoder.encode(payload.toString(), "UTF-8").replace("+", "%20")
35+
val escaped = text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
36+
clipboard.setPrimaryClip(
37+
if (selected.isEmpty()) {
38+
ClipData.newPlainText(
39+
"T3 Code",
40+
text
41+
)
42+
} else {
43+
ClipData.newHtmlText(
44+
"T3 Code",
45+
text,
46+
"<pre data-t3-context-fragment=\"$encoded\">$escaped</pre>"
47+
)
48+
}
49+
)
50+
}
51+
52+
fun read(context: Context): Map<String, String> {
53+
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
54+
val clip = clipboard.primaryClip
55+
val item = if (clip != null && clip.itemCount > 0) clip.getItemAt(0) else null
56+
return mapOf(
57+
"text" to (item?.text?.toString() ?: ""),
58+
"html" to (item?.htmlText ?: ""),
59+
"fragment" to ""
60+
)
61+
}
62+
}
563

664
class T3ComposerEditorModule : Module() {
765
override fun definition() = ModuleDefinition {
866
Name("T3ComposerEditor")
967

68+
AsyncFunction("writeContextClipboard") { text: String, fragment: String ->
69+
T3ComposerClipboard.write(requireNotNull(appContext.reactContext), text, fragment)
70+
}
71+
1072
View(T3ComposerEditorView::class) {
1173
Prop("controlledDocumentJson") { view: T3ComposerEditorView, documentJson: String ->
1274
view.setControlledDocumentJson(documentJson)
1375
}
1476
Prop("themeJson") { view: T3ComposerEditorView, themeJson: String ->
1577
view.setThemeJson(themeJson)
1678
}
79+
Prop("clipboardFragment") { view: T3ComposerEditorView, fragment: String ->
80+
view.setClipboardFragment(fragment)
81+
}
1782
Prop("placeholder") { view: T3ComposerEditorView, placeholder: String ->
1883
view.setPlaceholder(placeholder)
1984
}
@@ -36,6 +101,9 @@ class T3ComposerEditorModule : Module() {
36101
Prop("editable") { view: T3ComposerEditorView, editable: Boolean ->
37102
view.setEditable(editable)
38103
}
104+
Prop("readOnly") { view: T3ComposerEditorView, readOnly: Boolean ->
105+
view.setReadOnly(readOnly)
106+
}
39107
Prop("scrollEnabled") { view: T3ComposerEditorView, scrollEnabled: Boolean ->
40108
view.setScrollEnabled(scrollEnabled)
41109
}
@@ -55,6 +123,8 @@ class T3ComposerEditorModule : Module() {
55123
"onComposerFocus",
56124
"onComposerBlur",
57125
"onComposerPasteImages",
126+
"onComposerContextPress",
127+
"onComposerPasteContext",
58128
"onComposerContentSizeChange",
59129
)
60130

0 commit comments

Comments
 (0)