diff --git a/frontend/app/element/markdown.tsx b/frontend/app/element/markdown.tsx index bb33e5ac5..c1e8cf956 100644 --- a/frontend/app/element/markdown.tsx +++ b/frontend/app/element/markdown.tsx @@ -4,12 +4,11 @@ import { CopyButton } from "@/app/element/copybutton"; import { WshServer } from "@/app/store/wshserver"; import { getWebServerEndpoint } from "@/util/endpoints"; -import * as util from "@/util/util"; -import { useAtomValueSafe } from "@/util/util"; +import { isBlank, makeConnRoute, useAtomValueSafe } from "@/util/util"; import { clsx } from "clsx"; import { Atom } from "jotai"; import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react"; -import React, { CSSProperties, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; import ReactMarkdown from "react-markdown"; import rehypeRaw from "rehype-raw"; import RemarkFlexibleToc, { TocItem } from "remark-flexible-toc"; @@ -81,12 +80,12 @@ const MarkdownSource = (props: any) => { }; const MarkdownImg = (props: any) => { - const [resolvedSrc, setResolvedSrc] = React.useState(props.src); - const [resolvedStr, setResolvedStr] = React.useState(null); - const [resolving, setResolving] = React.useState(true); + const [resolvedSrc, setResolvedSrc] = useState(props.src); + const [resolvedStr, setResolvedStr] = useState(null); + const [resolving, setResolving] = useState(true); const resolveOpts: MarkdownResolveOpts = props.resolveOpts; - React.useEffect(() => { + useEffect(() => { if (props.src.startsWith("http://") || props.src.startsWith("https://")) { setResolving(false); setResolvedSrc(props.src); @@ -106,11 +105,11 @@ const MarkdownImg = (props: any) => { return; } const resolveFn = async () => { - const route = util.makeConnRoute(resolveOpts.connName); + const route = makeConnRoute(resolveOpts.connName); const fileInfo = await WshServer.RemoteFileJoinCommand([resolveOpts.baseDir, props.src], { route: route }); const usp = new URLSearchParams(); usp.set("path", fileInfo.path); - if (!util.isBlank(resolveOpts.connName)) { + if (!isBlank(resolveOpts.connName)) { usp.set("connection", resolveOpts.connName); } const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?" + usp.toString(); @@ -211,7 +210,7 @@ const Markdown = ({ text, textAtom, showTocAtom, style, className, resolveOpts, onTocClick(item.value)} > {item.value}