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

Commit798c249

Browse files
committed
Add support for opening a document with a factory
1 parent3d05890 commit798c249

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ 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+
constroute=
44+
widgetName!=='Notebook'||ext!=='.ipynb' ?'edit' :'notebooks';
45+
window.open(`${baseUrl}${route}/${path}?factory=${widgetName}`);
4546
returnundefined;
4647
};
4748
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp