diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index e011bd5f5..4d7ae7b9c 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -122,20 +122,20 @@ export function PreCode(props: { children: any }) { } }, []); - const [collapsed, setCollapsed] = useState(true); - const [showToggle, setShowToggle] = useState(false); + // const [collapsed, setCollapsed] = useState(true); + // const [showToggle, setShowToggle] = useState(false); - useEffect(() => { - if (ref.current) { - const codeHeight = ref.current.scrollHeight; - setShowToggle(codeHeight > 400); - ref.current.scrollTop = ref.current.scrollHeight; - } - }, [props.children]); + // useEffect(() => { + // if (ref.current) { + // const codeHeight = ref.current.scrollHeight; + // setShowToggle(codeHeight > 400); + // ref.current.scrollTop = ref.current.scrollHeight; + // } + // }, [props.children]); - const toggleCollapsed = () => { - setCollapsed(!collapsed); - }; + // const toggleCollapsed = () => { + // setCollapsed(collapsed=>!collapsed); + // }; return ( <> @@ -143,8 +143,8 @@ export function PreCode(props: { children: any }) {
           
           {props.children}
-          {showToggle && collapsed && (
+          {/* {showToggle && collapsed && (
             
- )} + )} */}
{mermaidCode.length > 0 && ( @@ -191,6 +186,46 @@ export function PreCode(props: { children: any }) { ); } +function CustomCode(props: { children: any }) { + const ref = useRef(null); + const [collapsed, setCollapsed] = useState(true); + const [showToggle, setShowToggle] = useState(false); + + useEffect(() => { + if (ref.current) { + const codeHeight = ref.current.scrollHeight; + setShowToggle(codeHeight > 400); + ref.current.scrollTop = ref.current.scrollHeight; + } + }, [props.children]); + + const toggleCollapsed = () => { + setCollapsed((collapsed) => !collapsed); + }; + return ( + <> + + {props.children} + {showToggle && collapsed && ( +
+ +
+ )} +
+ + ); +} + function escapeDollarNumber(text: string) { let escapedText = ""; @@ -231,6 +266,8 @@ function _MarkDownContent(props: { content: string }) { return escapeBrackets(escapeDollarNumber(props.content)); }, [props.content]); + console.log(escapedContent, 11233); + return (

, a: (aProps) => { const href = aProps.href || ""; diff --git a/app/styles/globals.scss b/app/styles/globals.scss index 14075a0a8..ce0e8281d 100644 --- a/app/styles/globals.scss +++ b/app/styles/globals.scss @@ -301,10 +301,15 @@ pre { opacity: 1; } } +} +code{ .show-hide-button { + border-radius: 10px; position: absolute; top: 0; + left: 0; + right: 0; width: 100%; margin: auto; height: fit-content; @@ -322,11 +327,15 @@ pre { background: #464e4e; } } - + + .expanded { + background-image: none; + } + .collapsed { + background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.06)); + } } - - .clickable { cursor: pointer;