File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 22import { useImperativeModal } from "@/components/modal/ImperativeModal" ;
33import { toast } from "@/components/ui/use-toast" ;
44import { sendCopy } from "@/core/network/requests" ;
5+ import { openNotebook } from "@/utils/links" ;
56import { PathBuilder , Paths } from "@/utils/paths" ;
67
78export function useCopyNotebook ( source : string | null ) {
@@ -31,7 +32,7 @@ export function useCopyNotebook(source: string | null) {
3132 title : "Notebook copied" ,
3233 description : "A copy of the notebook has been created." ,
3334 } ) ;
34- window . open ( `/?file= ${ destination } ` , "_blank" ) ;
35+ openNotebook ( destination ) ;
3536 } ) ;
3637 } ,
3738 } ) ;
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ import { ErrorBanner } from "@/plugins/impl/common/error-banner";
5757import { cn } from "@/utils/cn" ;
5858import { copyToClipboard } from "@/utils/copy" ;
5959import { downloadBlob } from "@/utils/download" ;
60+ import { openNotebook } from "@/utils/links" ;
6061import type { FilePath } from "@/utils/paths" ;
6162import { fileSplit } from "@/utils/pathUtils" ;
6263import { FileViewer } from "./file-viewer" ;
@@ -675,5 +676,5 @@ function openMarimoNotebook(
675676) {
676677 event . stopPropagation ( ) ;
677678 event . preventDefault ( ) ;
678- window . open ( `/?file= ${ path } ` , "_blank" ) ;
679+ openNotebook ( path ) ;
679680}
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ import {
3030import { Constants } from "@/core/constants" ;
3131import { openTutorial } from "@/core/network/requests" ;
3232import type { TutorialId } from "@/core/network/types" ;
33+ import { openNotebook } from "@/utils/links" ;
3334import { Objects } from "@/utils/objects" ;
34- import { asURL } from "@/utils/url" ;
3535
3636const TUTORIALS : Record <
3737 TutorialId ,
@@ -89,7 +89,7 @@ export const OpenTutorialDropDown: React.FC = () => {
8989 if ( ! file ) {
9090 return ;
9191 }
92- window . open ( asURL ( `? file= ${ file . path } ` ) . toString ( ) , "_blank" ) ;
92+ openNotebook ( file . path ) ;
9393 } }
9494 >
9595 < Icon
Original file line number Diff line number Diff line change 1+ /* Copyright 2024 Marimo. All rights reserved. */
2+ import { asURL } from "./url" ;
3+
4+ /**
5+ * Open a notebook in a new tab.
6+ * @param path - The path to the notebook.
7+ */
8+ export function openNotebook ( path : string ) {
9+ // There is no leading `/` in the path in order to work when marimo is at a subpath.
10+ window . open ( asURL ( `?file=${ path } ` ) . toString ( ) , "_blank" ) ;
11+ }
You can’t perform that action at this time.
0 commit comments