mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-28 19:22:39 +01:00
Share Yaak's request and response panes (#815)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad0533901
commit
08a98d5f82
85 files changed
+5567
-2872
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
type EditorHost,
|
||||
EditorHostProvider,
|
||||
MultipartViewer,
|
||||
type MultipartViewerProps,
|
||||
TextViewer,
|
||||
type TextViewerProps,
|
||||
} from "@yaakapp-internal/ui";
|
||||
import { type ReactNode, useMemo } from "react";
|
||||
import { formatText as engineFormatText } from "../lib/body";
|
||||
|
||||
/**
|
||||
* Gives the shared panes the proxy's formatting. Everything else keeps the shared defaults:
|
||||
* plain editors with no templating, state kept for the session, no dialogs.
|
||||
*/
|
||||
export function ProxyEditorHost({
|
||||
children,
|
||||
formatText = engineFormatText,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
/** Pretty-prints a body; the engine's formatter unless replaced */
|
||||
formatText?: TextViewerProps["formatText"];
|
||||
}) {
|
||||
// Components made once per formatter, so viewers aren't remounted on every render
|
||||
const host = useMemo<Partial<EditorHost>>(
|
||||
() => ({
|
||||
TextViewer: (props: TextViewerProps) => <TextViewer formatText={formatText} {...props} />,
|
||||
MultipartViewer: (props: MultipartViewerProps) => (
|
||||
<MultipartViewer textViewerProps={{ formatText }} {...props} />
|
||||
),
|
||||
}),
|
||||
[formatText],
|
||||
);
|
||||
return <EditorHostProvider value={host}>{children}</EditorHostProvider>;
|
||||
}
|
||||
Reference in new issue
Block a user