Skip to content

Commit

Permalink
chore(playground): set src in setEditorContent()
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Apr 19, 2024
1 parent 0aa0177 commit d02610b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions client/src/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,20 @@ export default function Playground() {
[getEditorContent]
);

const setEditorContent = ({
html,
css,
js,
}: Pick<EditorContent, "html" | "css" | "js">) => {
const setEditorContent = ({ html, css, js, src }: EditorContent) => {
htmlRef.current?.setContent(html);
cssRef.current?.setContent(css);
jsRef.current?.setContent(js);
if (src) {
setCodeSrc(src.split("/").slice(0, -1).join("/"));
}
setIsEmpty(!html && !css && !js);
};

useEffect(() => {
if (state === State.initial || state === State.remote) {
if (initialCode && Object.values(initialCode).some(Boolean)) {
setEditorContent(initialCode);
if (initialCode.src) {
setCodeSrc(
initialCode?.src &&
`${initialCode.src.split("/").slice(0, -1).join("/")}`
);
}
} else {
setEditorContent({
html: HTML_DEFAULT,
Expand Down

0 comments on commit d02610b

Please sign in to comment.