mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 21:20:25 +08:00
the primary purpose of this PR is to fix a showstopper bug in the CodeEditor component by setting "path" to a stable UUID. the bug was that it started as empty string, so it created a shared model between all of the codeeditor components. now each will get their own monaco model. also took this opportunity to do more more preview view refactoring, splitting up code, and more tailwind migrations.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { Markdown } from "@/element/markdown";
|
|
import { getOverrideConfigAtom } from "@/store/global";
|
|
import { useAtomValue } from "jotai";
|
|
import { useMemo } from "react";
|
|
import type { SpecializedViewProps } from "./preview";
|
|
|
|
function MarkdownPreview({ model }: SpecializedViewProps) {
|
|
const connName = useAtomValue(model.connection);
|
|
const fileInfo = useAtomValue(model.statFile);
|
|
const fontSizeOverride = useAtomValue(getOverrideConfigAtom(model.blockId, "markdown:fontsize"));
|
|
const fixedFontSizeOverride = useAtomValue(getOverrideConfigAtom(model.blockId, "markdown:fixedfontsize"));
|
|
const resolveOpts: MarkdownResolveOpts = useMemo<MarkdownResolveOpts>(() => {
|
|
return {
|
|
connName: connName,
|
|
baseDir: fileInfo.dir,
|
|
};
|
|
}, [connName, fileInfo.dir]);
|
|
return (
|
|
<div className="flex flex-row h-full overflow-auto items-start justify-start">
|
|
<Markdown
|
|
textAtom={model.fileContent}
|
|
showTocAtom={model.markdownShowToc}
|
|
resolveOpts={resolveOpts}
|
|
fontSizeOverride={fontSizeOverride}
|
|
fixedFontSizeOverride={fixedFontSizeOverride}
|
|
contentClassName="pt-[5px] pr-[15px] pb-[10px] pl-[15px]"
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export { MarkdownPreview };
|