Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9be03f5

Browse files
authored
Merge pull request#6315 from jtpio/factories
Add support for opening a document with a different factory
2 parents3d05890 +d9e050f commit9be03f5

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

‎packages/application-extension/src/index.ts‎

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ import { DisposableDelegate, DisposableSet } from '@lumino/disposable';
4545

4646
import{Widget}from'@lumino/widgets';
4747

48-
/**
49-
* The default notebook factory.
50-
*/
51-
constNOTEBOOK_FACTORY='Notebook';
52-
53-
/**
54-
* The editor factory.
55-
*/
56-
constEDITOR_FACTORY='Editor';
57-
5848
/**
5949
* A regular expression to match path to notebooks and documents
6050
*/
@@ -179,18 +169,12 @@ const opener: JupyterFrontEndPlugin<void> = {
179169
}
180170

181171
constfile=decodeURIComponent(path);
182-
constext=PathExt.extname(file);
172+
consturlParams=newURLSearchParams(parsed.search);
173+
constfactory=urlParams.get('factory')??'default';
183174
app.restored.then(async()=>{
184-
// TODO: get factory from file type instead?
185-
if(ext==='.ipynb'){
186-
docManager.open(file,NOTEBOOK_FACTORY,undefined,{
187-
ref:'_noref'
188-
});
189-
}else{
190-
docManager.open(file,EDITOR_FACTORY,undefined,{
191-
ref:'_noref'
192-
});
193-
}
175+
docManager.open(file,factory,undefined,{
176+
ref:'_noref'
177+
});
194178
});
195179
}
196180
});

‎packages/docmanager-extension/src/index.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,19 @@ const opener: JupyterFrontEndPlugin<void> = {
4040
return;
4141
}
4242
constext=PathExt.extname(path);
43-
constroute=ext==='.ipynb' ?'notebooks' :'edit';
44-
window.open(`${baseUrl}${route}/${path}`);
43+
letroute='edit';
44+
if(
45+
(widgetName==='default'&&ext==='.ipynb')||
46+
widgetName==='Notebook'
47+
){
48+
route='notebooks';
49+
}
50+
leturl=`${baseUrl}${route}/${path}`;
51+
// append ?factory only if it's not the default
52+
if(widgetName!=='default'){
53+
url=`${url}?factory=${widgetName}`;
54+
}
55+
window.open(url);
4556
returnundefined;
4657
};
4758
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp