Spaces:
Running
Running
try to set active path
Browse files
components/editor/index.tsx
CHANGED
|
@@ -356,6 +356,7 @@ export const AppEditor = ({
|
|
| 356 |
ref={preview}
|
| 357 |
device={device}
|
| 358 |
pages={pages}
|
|
|
|
| 359 |
setCurrentPage={setCurrentPage}
|
| 360 |
currentTab={currentTab}
|
| 361 |
isEditableModeEnabled={isEditableModeEnabled}
|
|
|
|
| 356 |
ref={preview}
|
| 357 |
device={device}
|
| 358 |
pages={pages}
|
| 359 |
+
currentPage={currentPage}
|
| 360 |
setCurrentPage={setCurrentPage}
|
| 361 |
currentTab={currentTab}
|
| 362 |
isEditableModeEnabled={isEditableModeEnabled}
|
components/editor/preview/index.tsx
CHANGED
|
@@ -25,6 +25,7 @@ export const Preview = ({
|
|
| 25 |
currentTab,
|
| 26 |
iframeRef,
|
| 27 |
pages,
|
|
|
|
| 28 |
// setCurrentPage,
|
| 29 |
isEditableModeEnabled,
|
| 30 |
}: // onClickElement,
|
|
@@ -33,6 +34,7 @@ export const Preview = ({
|
|
| 33 |
isResizing: boolean;
|
| 34 |
isAiWorking: boolean;
|
| 35 |
pages: Page[];
|
|
|
|
| 36 |
setCurrentPage: React.Dispatch<React.SetStateAction<string>>;
|
| 37 |
ref: React.RefObject<HTMLDivElement | null>;
|
| 38 |
iframeRef?: React.RefObject<SandpackPreviewRef | null>;
|
|
@@ -186,6 +188,7 @@ export const Preview = ({
|
|
| 186 |
"sp-layout": "!w-full !h-full",
|
| 187 |
"sp-stack": "!w-full !h-full",
|
| 188 |
},
|
|
|
|
| 189 |
}}
|
| 190 |
files={formattedPages}
|
| 191 |
>
|
|
@@ -212,8 +215,8 @@ const SandpackPreviewClient = ({
|
|
| 212 |
if (client && clientId) {
|
| 213 |
// console.log({ client });
|
| 214 |
// console.log(sandpack.clients[clientId]);
|
| 215 |
-
const iframe = client.iframe;
|
| 216 |
-
console.log(iframe.contentWindow);
|
| 217 |
}
|
| 218 |
/**
|
| 219 |
* NOTE: In order to make sure that the client will be available
|
|
@@ -221,5 +224,11 @@ const SandpackPreviewClient = ({
|
|
| 221 |
*/
|
| 222 |
}, [sandpack]);
|
| 223 |
|
| 224 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
};
|
|
|
|
| 25 |
currentTab,
|
| 26 |
iframeRef,
|
| 27 |
pages,
|
| 28 |
+
currentPage,
|
| 29 |
// setCurrentPage,
|
| 30 |
isEditableModeEnabled,
|
| 31 |
}: // onClickElement,
|
|
|
|
| 34 |
isResizing: boolean;
|
| 35 |
isAiWorking: boolean;
|
| 36 |
pages: Page[];
|
| 37 |
+
currentPage: string;
|
| 38 |
setCurrentPage: React.Dispatch<React.SetStateAction<string>>;
|
| 39 |
ref: React.RefObject<HTMLDivElement | null>;
|
| 40 |
iframeRef?: React.RefObject<SandpackPreviewRef | null>;
|
|
|
|
| 188 |
"sp-layout": "!w-full !h-full",
|
| 189 |
"sp-stack": "!w-full !h-full",
|
| 190 |
},
|
| 191 |
+
activeFile: currentPage,
|
| 192 |
}}
|
| 193 |
files={formattedPages}
|
| 194 |
>
|
|
|
|
| 215 |
if (client && clientId) {
|
| 216 |
// console.log({ client });
|
| 217 |
// console.log(sandpack.clients[clientId]);
|
| 218 |
+
// const iframe = client.iframe;
|
| 219 |
+
// console.log(iframe.contentWindow);
|
| 220 |
}
|
| 221 |
/**
|
| 222 |
* NOTE: In order to make sure that the client will be available
|
|
|
|
| 224 |
*/
|
| 225 |
}, [sandpack]);
|
| 226 |
|
| 227 |
+
return (
|
| 228 |
+
<SandpackPreview
|
| 229 |
+
ref={ref}
|
| 230 |
+
showRefreshButton={false}
|
| 231 |
+
showOpenInCodeSandbox={false}
|
| 232 |
+
/>
|
| 233 |
+
);
|
| 234 |
};
|