enzostvs HF Staff commited on
Commit
b179f9d
·
1 Parent(s): 23f91e3

fix some issues

Browse files
app/layout.tsx CHANGED
@@ -114,7 +114,7 @@ export default async function RootLayout({
114
  data-domain="deepsite.hf.co"
115
  src="https://plausible.io/js/script.js"
116
  />
117
- <DomainRedirect />
118
  <IframeDetector />
119
  <Toaster richColors position="bottom-center" />
120
  <TanstackContext>
 
114
  data-domain="deepsite.hf.co"
115
  src="https://plausible.io/js/script.js"
116
  />
117
+ {/* <DomainRedirect /> */}
118
  <IframeDetector />
119
  <Toaster richColors position="bottom-center" />
120
  <TanstackContext>
components/editor/ask-ai/index.tsx CHANGED
@@ -313,7 +313,7 @@ export const AskAi = ({
313
  </div>
314
  </div>
315
  <audio ref={hookAudio} id="audio" className="hidden">
316
- <source src="/success.mp3" type="audio/mpeg" />
317
  Your browser does not support the audio element.
318
  </audio>
319
  </div>
 
313
  </div>
314
  </div>
315
  <audio ref={hookAudio} id="audio" className="hidden">
316
+ <source src="/deepsite/success.mp3" type="audio/mpeg" />
317
  Your browser does not support the audio element.
318
  </audio>
319
  </div>
components/editor/preview/index.tsx CHANGED
@@ -320,23 +320,47 @@ export const Preview = ({ isNew }: { isNew: boolean }) => {
320
  if (iframeRef?.current) {
321
  const iframeDocument = iframeRef.current.contentDocument;
322
  if (iframeDocument) {
323
- const targetElement = event.target as HTMLElement;
 
 
 
 
 
 
 
324
 
325
  const findClosestAnchor = (
326
  element: HTMLElement
327
  ): HTMLAnchorElement | null => {
328
- let current = element;
329
- while (current && current !== iframeDocument.body) {
330
- if (current.tagName === "A") {
 
331
  return current as HTMLAnchorElement;
332
  }
333
- current = current.parentElement as HTMLElement;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  }
335
  return null;
336
  };
337
 
338
  const anchorElement = findClosestAnchor(targetElement);
339
 
 
 
340
  if (anchorElement) {
341
  return;
342
  }
@@ -355,20 +379,49 @@ export const Preview = ({ isNew }: { isNew: boolean }) => {
355
  const path = event.composedPath();
356
  const actualTarget = path[0] as HTMLElement;
357
 
 
 
 
 
 
 
358
  const findClosestAnchor = (
359
  element: HTMLElement
360
  ): HTMLAnchorElement | null => {
361
  let current: HTMLElement | null = element;
362
- while (current && current !== iframeDocument.body) {
363
- if (current.tagName === "A") {
 
 
 
 
 
 
364
  return current as HTMLAnchorElement;
365
  }
 
 
 
 
366
  const parent: Node | null = current.parentNode;
367
- if (parent instanceof ShadowRoot) {
368
- current = parent.host as HTMLElement;
369
- } else if (parent instanceof HTMLElement) {
370
- current = parent;
 
 
 
 
 
 
 
 
 
 
371
  } else {
 
 
 
372
  break;
373
  }
374
  }
@@ -376,6 +429,7 @@ export const Preview = ({ isNew }: { isNew: boolean }) => {
376
  };
377
 
378
  const anchorElement = findClosestAnchor(actualTarget);
 
379
  if (anchorElement) {
380
  let href = anchorElement.getAttribute("href");
381
  if (href) {
 
320
  if (iframeRef?.current) {
321
  const iframeDocument = iframeRef.current.contentDocument;
322
  if (iframeDocument) {
323
+ const path = event.composedPath();
324
+ const targetElement = path[0] as HTMLElement;
325
+
326
+ console.log(
327
+ "[handleClick] Target element:",
328
+ targetElement.tagName,
329
+ targetElement
330
+ );
331
 
332
  const findClosestAnchor = (
333
  element: HTMLElement
334
  ): HTMLAnchorElement | null => {
335
+ let current: HTMLElement | null = element;
336
+ while (current) {
337
+ console.log("[handleClick] Checking element:", current.tagName);
338
+ if (current.tagName?.toUpperCase() === "A") {
339
  return current as HTMLAnchorElement;
340
  }
341
+ if (current === iframeDocument.body) {
342
+ break;
343
+ }
344
+ const parent: Node | null = current.parentNode;
345
+ // Use nodeType to check - works across iframe boundaries
346
+ // nodeType 1 = Element, nodeType 11 = DocumentFragment (including ShadowRoot)
347
+ if (parent && parent.nodeType === 11) {
348
+ // ShadowRoot
349
+ current = (parent as ShadowRoot).host as HTMLElement;
350
+ } else if (parent && parent.nodeType === 1) {
351
+ // Element node
352
+ current = parent as HTMLElement;
353
+ } else {
354
+ break;
355
+ }
356
  }
357
  return null;
358
  };
359
 
360
  const anchorElement = findClosestAnchor(targetElement);
361
 
362
+ console.log("[handleClick] Found anchor:", anchorElement);
363
+
364
  if (anchorElement) {
365
  return;
366
  }
 
379
  const path = event.composedPath();
380
  const actualTarget = path[0] as HTMLElement;
381
 
382
+ console.log(
383
+ "[handleCustomNavigation] Click detected in iframe:",
384
+ actualTarget.tagName,
385
+ actualTarget
386
+ );
387
+
388
  const findClosestAnchor = (
389
  element: HTMLElement
390
  ): HTMLAnchorElement | null => {
391
  let current: HTMLElement | null = element;
392
+ while (current) {
393
+ console.log(
394
+ "[handleCustomNavigation] Checking element:",
395
+ current.tagName,
396
+ current
397
+ );
398
+ if (current.tagName?.toUpperCase() === "A") {
399
+ console.log("[handleCustomNavigation] Found anchor!", current);
400
  return current as HTMLAnchorElement;
401
  }
402
+ if (current === iframeDocument.body) {
403
+ console.log("[handleCustomNavigation] Reached body, stopping");
404
+ break;
405
+ }
406
  const parent: Node | null = current.parentNode;
407
+ console.log(
408
+ "[handleCustomNavigation] Parent node:",
409
+ parent,
410
+ "nodeType:",
411
+ parent?.nodeType
412
+ );
413
+ // Use nodeType to check - works across iframe boundaries
414
+ // nodeType 1 = Element, nodeType 11 = DocumentFragment (including ShadowRoot)
415
+ if (parent && parent.nodeType === 11) {
416
+ // ShadowRoot
417
+ current = (parent as ShadowRoot).host as HTMLElement;
418
+ } else if (parent && parent.nodeType === 1) {
419
+ // Element node
420
+ current = parent as HTMLElement;
421
  } else {
422
+ console.log(
423
+ "[handleCustomNavigation] Parent is not an element node, breaking"
424
+ );
425
  break;
426
  }
427
  }
 
429
  };
430
 
431
  const anchorElement = findClosestAnchor(actualTarget);
432
+ console.log("[handleCustomNavigation] Anchor element:", anchorElement);
433
  if (anchorElement) {
434
  let href = anchorElement.getAttribute("href");
435
  if (href) {
hooks/useAi.ts CHANGED
@@ -213,7 +213,7 @@ export const useAi = (onScrollToBottom?: () => void) => {
213
  const newPages = formatPages(contentResponse, false);
214
  let projectName = contentResponse.match(/<<<<<<< PROJECT_NAME_START\s*([\s\S]*?)\s*>>>>>>> PROJECT_NAME_END/)?.[1]?.trim();
215
  if (!projectName) {
216
- projectName = prompt.substring(0, 40).replace(/[^a-zA-Z0-9]/g, "-").slice(0, 40);
217
  }
218
  setPages(newPages);
219
  setLastSavedPages([...newPages]);
@@ -373,7 +373,6 @@ export const useAi = (onScrollToBottom?: () => void) => {
373
  }
374
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
375
  } catch (error: any) {
376
- console.log(error)
377
  setIsAiWorking(false);
378
  toast.error(error.message);
379
  if (error.openLogin) {
 
213
  const newPages = formatPages(contentResponse, false);
214
  let projectName = contentResponse.match(/<<<<<<< PROJECT_NAME_START\s*([\s\S]*?)\s*>>>>>>> PROJECT_NAME_END/)?.[1]?.trim();
215
  if (!projectName) {
216
+ projectName = prompt.substring(0, 40).replace(/[^a-zA-Z0-9]/g, "-").slice(0, 40) + "-" + Math.random().toString(36).substring(2, 15);
217
  }
218
  setPages(newPages);
219
  setLastSavedPages([...newPages]);
 
373
  }
374
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
375
  } catch (error: any) {
 
376
  setIsAiWorking(false);
377
  toast.error(error.message);
378
  if (error.openLogin) {
next.config.ts CHANGED
@@ -3,6 +3,7 @@ import type { NextConfig } from "next";
3
  const nextConfig: NextConfig = {
4
  /* config options here */
5
  basePath: '/deepsite',
 
6
  async redirects() {
7
  return [
8
  {
 
3
  const nextConfig: NextConfig = {
4
  /* config options here */
5
  basePath: '/deepsite',
6
+ assetPrefix: '/deepsite',
7
  async redirects() {
8
  return [
9
  {