mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 08:59:07 +01:00
Codemirror initial value support
This commit is contained in:
@@ -3,15 +3,12 @@ import './Editor.css';
|
||||
|
||||
interface Props {
|
||||
contentType: string;
|
||||
value: string;
|
||||
initialValue?: string;
|
||||
value?: string;
|
||||
onChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export default function Editor(props: Props) {
|
||||
const { ref } = useCodeMirror({
|
||||
value: props.value,
|
||||
contentType: props.contentType,
|
||||
onChange: props.onChange,
|
||||
});
|
||||
const { ref } = useCodeMirror(props);
|
||||
return <div ref={ref} className="cm-wrapper" />;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
import { HStack } from './Stacks';
|
||||
import { DropdownMenuRadio } from './Dropdown';
|
||||
import { Button } from './Button';
|
||||
import { Input } from './Input';
|
||||
import { FormEvent, useState } from 'react';
|
||||
import { FormEvent } from 'react';
|
||||
import { IconButton } from './IconButton';
|
||||
|
||||
interface Props {
|
||||
sendRequest: () => Promise<void>;
|
||||
sendRequest: () => void;
|
||||
loading: boolean;
|
||||
method: { label: string; value: string };
|
||||
url: string;
|
||||
onMethodChange: (method: { label: string; value: string }) => void;
|
||||
onUrlChange: (url: string) => void;
|
||||
}
|
||||
|
||||
export function UrlBar({ sendRequest, onMethodChange, method, onUrlChange, url }: Props) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
export function UrlBar({ sendRequest, loading, onMethodChange, method, onUrlChange, url }: Props) {
|
||||
const handleSendRequest = async (e: FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
if (loading) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
await sendRequest();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
sendRequest();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user