From 5d7dfa4dbf1fa2a0f56c561d08fa6962e97cef26 Mon Sep 17 00:00:00 2001 From: MURAOKA Taro Date: Thu, 14 Aug 2025 13:56:30 +0900 Subject: [PATCH] Added a button to open the Origin Private File System For more information about the OPFS, see: https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system --- schema/plugin.json | 1 + src/index.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/schema/plugin.json b/schema/plugin.json index 8a4b9e4..a7a9be6 100644 --- a/schema/plugin.json +++ b/schema/plugin.json @@ -4,6 +4,7 @@ "jupyter.lab.toolbars": { "FileSystemAccess": [ { "name": "open-folder", "rank": 0 }, + { "name": "open-opfs", "rank": 5 }, { "name": "uploader", "rank": 10 }, { "name": "filename-searcher", "rank": 20 } ] diff --git a/src/index.ts b/src/index.ts index 432e5b5..e95db92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,7 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation'; import { listIcon, folderIcon, + trustedIcon, IScore, FilenameSearcher } from '@jupyterlab/ui-components'; @@ -116,6 +117,25 @@ const plugin: JupyterFrontEndPlugin = { } ); + toolbarRegistry.addFactory( + DRIVE_NAME, + 'open-opfs', + (browser: FileBrowser) => { + const openOPFSButton = new ToolbarButton({ + icon: trustedIcon, + onClick: async () => { + const directoryHandle = await navigator.storage.getDirectory(); + if (directoryHandle) { + drive.rootHandle = directoryHandle; + widget.model.cd('/'); + } + }, + tooltip: trans.__('Open the Origin Private File System') + }); + return openOPFSButton; + } + ); + toolbarRegistry.addFactory( DRIVE_NAME, 'uploader',