Support binary responses!

This commit is contained in:
Gregory Schier
2023-04-13 18:48:40 -07:00
parent 29309500a6
commit f9f1ba9e24
25 changed files with 455 additions and 231 deletions

View File

@@ -24,10 +24,10 @@ export interface EditorProps {
type?: 'text' | 'password';
className?: string;
heightMode?: 'auto' | 'full';
contentType?: string;
contentType?: string | null;
forceUpdateKey?: string;
autoFocus?: boolean;
defaultValue?: string;
defaultValue?: string | null;
placeholder?: string;
tooltipContainer?: HTMLElement;
useTemplating?: boolean;

View File

@@ -32,7 +32,7 @@ export const IconButton = forwardRef<HTMLButtonElement, Props>(function IconButt
) {
const [confirmed, setConfirmed] = useTimedBoolean();
const handleClick = useCallback(
(e: MouseEvent<HTMLElement>) => {
(e: MouseEvent<HTMLButtonElement>) => {
if (showConfirm) setConfirmed();
onClick?.(e);
},

View File

@@ -1,28 +0,0 @@
import { useMemo } from 'react';
interface Props {
body: string;
contentType: string;
url: string;
}
export function Webview({ body, url, contentType }: Props) {
const contentForIframe: string | undefined = useMemo(() => {
if (!contentType.includes('html')) return;
if (body.includes('<head>')) {
return body.replace(/<head>/gi, `<head><base href="${url}"/>`);
}
return body;
}, [url, body, contentType]);
return (
<div className="h-full pb-3">
<iframe
title="Response preview"
srcDoc={contentForIframe}
sandbox="allow-scripts allow-same-origin"
className="h-full w-full rounded border border-highlightSecondary"
/>
</div>
);
}