diff --git a/.gitignore b/.gitignore
index a24c6e047..2ff556f64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,5 @@ dev
*.key
*.key.pub
+
+masks.json
diff --git a/app/components/artifact.module.scss b/app/components/artifact.module.scss
new file mode 100644
index 000000000..1e166f418
--- /dev/null
+++ b/app/components/artifact.module.scss
@@ -0,0 +1,12 @@
+.artifact {
+ display: block;
+ width: 100%;
+ height: 100%;
+ position: relative;
+}
+
+.artifact-iframe {
+ width: 100%;
+ border: var(--border-in-light);
+ border-radius: 6px;
+}
diff --git a/app/components/artifact.tsx b/app/components/artifact.tsx
index c06573b09..64a6ad652 100644
--- a/app/components/artifact.tsx
+++ b/app/components/artifact.tsx
@@ -13,6 +13,7 @@ import { Modal, showToast } from "./ui-lib";
import { copyToClipboard, downloadAs } from "../utils";
import { Path, ApiPath, REPO_URL } from "@/app/constant";
import { Loading } from "./home";
+import styles from "./artifact.module.scss";
export function HTMLPreview(props: {
code: string;
@@ -61,17 +62,22 @@ export function HTMLPreview(props: {
return props.code + script;
}, [props.code]);
+ const handleOnLoad = () => {
+ if (props?.onLoad) {
+ props.onLoad(title);
+ }
+ };
+
return (
+ onLoad={handleOnLoad}
+ />
);
}
@@ -186,14 +192,7 @@ export function Artifact() {
}, [id]);
return (
-
+
)}
{htmlCode.length > 0 && (
-
+
htmlCode}
/>
void;
+ onClick?: (e: React.MouseEvent) => void;
}) {
return (
(props: {
onClose?: () => void;
multiple?: boolean;
}) {
+ const [selectedValues, setSelectedValues] = useState
(
+ Array.isArray(props.defaultSelectedValue)
+ ? props.defaultSelectedValue
+ : props.defaultSelectedValue !== undefined
+ ? [props.defaultSelectedValue]
+ : [],
+ );
+
+ const handleSelection = (
+ e: React.MouseEvent,
+ value: T,
+ ) => {
+ if (props.multiple) {
+ e.stopPropagation();
+ const newSelectedValues = selectedValues.includes(value)
+ ? selectedValues.filter((v) => v !== value)
+ : [...selectedValues, value];
+ setSelectedValues(newSelectedValues);
+ props.onSelection?.(newSelectedValues);
+ } else {
+ setSelectedValues([value]);
+ props.onSelection?.([value]);
+ props.onClose?.();
+ }
+ };
+
return (
props.onClose?.()}>
{props.items.map((item, i) => {
- const selected = props.multiple
- ? // @ts-ignore
- props.defaultSelectedValue?.includes(item.value)
- : props.defaultSelectedValue === item.value;
+ const selected = selectedValues.includes(item.value);
return (
{
- props.onSelection?.([item.value]);
- props.onClose?.();
- }}
+ onClick={(e) => handleSelection(e, item.value)}
>
{selected ? (
(props: {
);
}
-
export function FullScreen(props: any) {
const { children, right = 10, top = 10, ...rest } = props;
const ref = useRef();