MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / TextWidget

Function TextWidget

client/src/containers/Chart/TextWidget.jsx:29–555  ·  view source on GitHub ↗
({
  chart,
  onEditLayout,
  editingLayout,
  onCancelChanges,
  onSaveChanges,
  onEditContent,
  isPublic = false,
})

Source from the content-addressed store, hash-verified

27import { ButtonSpinner } from "../../components/ButtonSpinner";
28
29function TextWidget({
30 chart,
31 onEditLayout,
32 editingLayout,
33 onCancelChanges,
34 onSaveChanges,
35 onEditContent,
36 isPublic = false,
37}) {
38 const [content, setContent] = useState(chart.content || "");
39 const [isEditing, setIsEditing] = useState(false);
40 const [chartLoading, setChartLoading] = useState(false);
41 const [deleteModal, setDeleteModal] = useState(false);
42 const [isPreview, setIsPreview] = useState(false);
43
44 const dispatch = useDispatch();
45 const user = useSelector(selectUser);
46 const team = useSelector(selectTeam);
47 const params = useParams();
48 const textareaRef = useRef(null);
49
50 useEffect(() => {
51 setIsEditing(chart.staged)
52 }, [chart])
53
54 // Add a new handler for interactive elements
55 const handleInteractiveMouseDown = (e) => {
56 e.stopPropagation();
57 };
58
59 const components = {
60 // code: ({ children }) => {
61 // const formattedText = String(children).replace(/^`|`$/g, ""); // Remove backticks
62
63 // return (
64 // <Code>
65 // {formattedText}
66 // </Code>
67 // );
68 // },
69 code: ({ children, className }) => {
70 const formattedText = String(children).replace(/^`|`$/g, ""); // Strip backticks
71
72 return className ? (
73 // Block code (if it has a class, meaning it's a code block)
74 <pre className="bg-content2 text-foreground p-2 rounded-md overflow-auto">
75 <code className={className}>{formattedText}</code>
76 </pre>
77 ) : (
78 // Inline code (if no class)
79 <span className="bg-content2 text-foreground px-1 rounded-sm">{formattedText}</span>
80 );
81 },
82 li: ({ children, className }) => {
83 // If this is a task list item, remove the bullet point and reduce padding
84 if (className?.includes("task-list-item")) {
85 return <li className={`${className} list-none -ml-6`}>{children}</li>;
86 }

Callers

nothing calls this directly

Calls 3

insertMarkdownFunction · 0.85
_onEditContentFunction · 0.85
_canAccessFunction · 0.70

Tested by

no test coverage detected