Skip to content

Commit 87c7e92

Browse files
committed
fix: sf connector docs
1 parent cf193de commit 87c7e92

File tree

3 files changed

+100
-5
lines changed

3 files changed

+100
-5
lines changed

web/src/components/Field.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { transformLinkUri } from "@/lib/utils";
3737
import FileInput from "@/app/admin/connectors/[connector]/pages/ConnectorInput/FileInput";
3838
import { DatePicker } from "./ui/datePicker";
3939
import { Textarea, TextareaProps } from "./ui/textarea";
40+
import { RichTextSubtext } from "./RichTextSubtext";
4041

4142
export function SectionHeader({
4243
children,
@@ -85,6 +86,18 @@ export function SubLabel({ children }: { children: string | JSX.Element }) {
8586
// Add whitespace-pre-wrap for multiline descriptions (when children is a string with newlines)
8687
const hasNewlines = typeof children === "string" && children.includes("\n");
8788

89+
// If children is a string, use RichTextSubtext to parse and render links
90+
if (typeof children === "string") {
91+
return (
92+
<div className="text-sm text-neutral-600 dark:text-neutral-300 mb-2">
93+
<RichTextSubtext
94+
text={children}
95+
className={hasNewlines ? "whitespace-pre-wrap" : ""}
96+
/>
97+
</div>
98+
);
99+
}
100+
88101
return (
89102
<div
90103
className={`text-sm text-neutral-600 dark:text-neutral-300 mb-2 ${hasNewlines ? "whitespace-pre-wrap" : ""}`}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import React from "react";
2+
3+
interface RichTextSubtextProps {
4+
text: string;
5+
className?: string;
6+
}
7+
8+
/**
9+
* Component that renders text with clickable links.
10+
* Detects URLs in the text and converts them to clickable links.
11+
* Also supports markdown-style links like [text](url).
12+
*/
13+
export function RichTextSubtext({
14+
text,
15+
className = "",
16+
}: RichTextSubtextProps) {
17+
// Function to parse text and create React elements
18+
const parseText = (input: string): React.ReactNode[] => {
19+
const elements: React.ReactNode[] = [];
20+
21+
// Regex to match markdown links [text](url) and plain URLs
22+
const combinedRegex = /(\[([^\]]+)\]\(([^)]+)\))|(https?:\/\/[^\s]+)/g;
23+
24+
let lastIndex = 0;
25+
let match;
26+
let key = 0;
27+
28+
while ((match = combinedRegex.exec(input)) !== null) {
29+
// Add text before the match
30+
if (match.index > lastIndex) {
31+
elements.push(
32+
<span key={`text-${key++}`}>
33+
{input.slice(lastIndex, match.index)}
34+
</span>
35+
);
36+
}
37+
38+
if (match[1]) {
39+
// Markdown-style link [text](url)
40+
const linkText = match[2];
41+
const url = match[3];
42+
elements.push(
43+
<a
44+
key={`link-${key++}`}
45+
href={url}
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
className="text-link hover:text-link-hover underline"
49+
onClick={(e) => e.stopPropagation()}
50+
>
51+
{linkText}
52+
</a>
53+
);
54+
} else if (match[4]) {
55+
// Plain URL
56+
const url = match[4];
57+
elements.push(
58+
<a
59+
key={`link-${key++}`}
60+
href={url}
61+
target="_blank"
62+
rel="noopener noreferrer"
63+
className="text-link hover:text-link-hover underline"
64+
onClick={(e) => e.stopPropagation()}
65+
>
66+
{url}
67+
</a>
68+
);
69+
}
70+
71+
lastIndex = match.index + match[0].length;
72+
}
73+
74+
// Add remaining text after the last match
75+
if (lastIndex < input.length) {
76+
elements.push(
77+
<span key={`text-${key++}`}>{input.slice(lastIndex)}</span>
78+
);
79+
}
80+
81+
return elements;
82+
};
83+
84+
return <div className={className}>{parseText(text)}</div>;
85+
}

web/src/lib/connectors/connectors.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,12 @@ Example:
638638
"Account": {
639639
"fields": ["Id", "Name", "Industry"],
640640
"associations": {
641-
"Contact": {
642-
"fields": ["Id", "FirstName", "LastName", "Email"],
643-
"associations": {}
644-
}
641+
"Contact": ["Id", "FirstName", "LastName", "Email"]
645642
}
646643
}
647644
}
648645
649-
See our docs for more details.`,
646+
[See our docs](https://docs.onyx.app/connectors/salesforce) for more details.`,
650647
},
651648
],
652649
},

0 commit comments

Comments
 (0)