mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-04 18:59:08 +01:00
clean up imports for markdown
This commit is contained in:
parent
9f5ccddad2
commit
bd43a4b61d
@ -4,12 +4,11 @@
|
|||||||
import { CopyButton } from "@/app/element/copybutton";
|
import { CopyButton } from "@/app/element/copybutton";
|
||||||
import { WshServer } from "@/app/store/wshserver";
|
import { WshServer } from "@/app/store/wshserver";
|
||||||
import { getWebServerEndpoint } from "@/util/endpoints";
|
import { getWebServerEndpoint } from "@/util/endpoints";
|
||||||
import * as util from "@/util/util";
|
import { isBlank, makeConnRoute, useAtomValueSafe } from "@/util/util";
|
||||||
import { useAtomValueSafe } from "@/util/util";
|
|
||||||
import { clsx } from "clsx";
|
import { clsx } from "clsx";
|
||||||
import { Atom } from "jotai";
|
import { Atom } from "jotai";
|
||||||
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
|
import { OverlayScrollbarsComponent, OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
|
||||||
import React, { CSSProperties, useRef } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import ReactMarkdown from "react-markdown";
|
import ReactMarkdown from "react-markdown";
|
||||||
import rehypeRaw from "rehype-raw";
|
import rehypeRaw from "rehype-raw";
|
||||||
import RemarkFlexibleToc, { TocItem } from "remark-flexible-toc";
|
import RemarkFlexibleToc, { TocItem } from "remark-flexible-toc";
|
||||||
@ -81,12 +80,12 @@ const MarkdownSource = (props: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const MarkdownImg = (props: any) => {
|
const MarkdownImg = (props: any) => {
|
||||||
const [resolvedSrc, setResolvedSrc] = React.useState<string>(props.src);
|
const [resolvedSrc, setResolvedSrc] = useState<string>(props.src);
|
||||||
const [resolvedStr, setResolvedStr] = React.useState<string>(null);
|
const [resolvedStr, setResolvedStr] = useState<string>(null);
|
||||||
const [resolving, setResolving] = React.useState<boolean>(true);
|
const [resolving, setResolving] = useState<boolean>(true);
|
||||||
const resolveOpts: MarkdownResolveOpts = props.resolveOpts;
|
const resolveOpts: MarkdownResolveOpts = props.resolveOpts;
|
||||||
|
|
||||||
React.useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.src.startsWith("http://") || props.src.startsWith("https://")) {
|
if (props.src.startsWith("http://") || props.src.startsWith("https://")) {
|
||||||
setResolving(false);
|
setResolving(false);
|
||||||
setResolvedSrc(props.src);
|
setResolvedSrc(props.src);
|
||||||
@ -106,11 +105,11 @@ const MarkdownImg = (props: any) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const resolveFn = async () => {
|
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 fileInfo = await WshServer.RemoteFileJoinCommand([resolveOpts.baseDir, props.src], { route: route });
|
||||||
const usp = new URLSearchParams();
|
const usp = new URLSearchParams();
|
||||||
usp.set("path", fileInfo.path);
|
usp.set("path", fileInfo.path);
|
||||||
if (!util.isBlank(resolveOpts.connName)) {
|
if (!isBlank(resolveOpts.connName)) {
|
||||||
usp.set("connection", resolveOpts.connName);
|
usp.set("connection", resolveOpts.connName);
|
||||||
}
|
}
|
||||||
const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?" + usp.toString();
|
const streamingUrl = getWebServerEndpoint() + "/wave/stream-file?" + usp.toString();
|
||||||
@ -211,7 +210,7 @@ const Markdown = ({ text, textAtom, showTocAtom, style, className, resolveOpts,
|
|||||||
<a
|
<a
|
||||||
key={item.href}
|
key={item.href}
|
||||||
className="toc-item"
|
className="toc-item"
|
||||||
style={{ "--indent-factor": item.depth } as CSSProperties}
|
style={{ "--indent-factor": item.depth } as React.CSSProperties}
|
||||||
onClick={() => onTocClick(item.value)}
|
onClick={() => onTocClick(item.value)}
|
||||||
>
|
>
|
||||||
{item.value}
|
{item.value}
|
||||||
|
Loading…
Reference in New Issue
Block a user