-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notebook API Support #12442
Merged
Merged
Notebook API Support #12442
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
b17fe8a
Add notebook package to Theia
msujew e60b44f
working getting notebook contributions
jonah-iden 0e5f2b6
working onNotebook activation event;
jonah-iden c84990b
basic backend frontend communication with registering serializers
jonah-iden a98e3b1
render messaging rpc api
jonah-iden 76bf6e8
basic widget for notebooks working
jonah-iden 77230ba
titles for noetbook editor + and working language support for cell ed…
jonah-iden 0f0d9dc
fixed activating serializers before opening notebook document; added …
jonah-iden 63ff3eb
notebook document dirty and save listeners
jonah-iden a450866
document dirty and save listeners
jonah-iden ecadf6c
baisc saving of notebooks implemented
jonah-iden ba6ca53
basic toolbar implementation for selected cell
jonah-iden 2c989f1
notebook edit framework and edit and delete actions
jonah-iden a301b32
context key basics
jonah-iden d0e5726
notebook editor closable; removed when clause since no support for it…
jonah-iden ff50115
fixed saving
jonah-iden 6ffcbd4
hardcoded flag for deactivating unfinished notebook support
jonah-iden 3e09a16
basic add cell buttons (no functionality)
jonah-iden 3f3ea80
all smaller review comments
jonah-iden 409f36d
notebookModel and notebookCellModel injectable
jonah-iden 2df5b29
better dependency injection for notebookEditor widget and the cell re…
jonah-iden 6513d4f
fixed activation events. explicit onNotebook, implicit on NotebookSer…
jonah-iden d493d0b
correct dirty change after saving
jonah-iden c675a88
updated notebook package to 1.36.0
jonah-iden 82f20d6
removed uneccessary comment
jonah-iden 7461bd9
react key for cellDivider
jonah-iden 04f6830
removed duplicate interface
jonah-iden edf747c
update notebook packege to 1.37.0
jonah-iden 43e9058
review comments
jonah-iden 157b49e
stop using createInline()
jonah-iden c19dd8c
more review comment changes:
jonah-iden 80deb5e
renamed Event
jonah-iden 7870a2b
updated version to 1.38.0
jonah-iden 39a299b
basics for notebook ContextKeys implemented
jonah-iden 73321be
context keys working for cells
jonah-iden 9c4b12b
cell toolbar menu item order; fixed cell editor sizing
jonah-iden c394140
added basic logic for adding new cells
jonah-iden b6529ca
fixed file headers
jonah-iden 0b9fc42
include vscode.ipynb by default
jonah-iden 3809ce2
basiscs for notebook cell Execution API
jonah-iden a3b01e4
basic api for cell execution and jupyter extension support
jonah-iden 77ca418
basic kernel creation and selection
jonah-iden 021a227
increased version to 1.39.0
jonah-iden 8e5a462
basic showing cell outputs
jonah-iden 7247029
cleanup, correct cell updating and basic api for notebook-edits (not …
jonah-iden 928161c
fixed Element already has context attribute Error
jonah-iden 3195f48
fixed cell document odes allready exists error
jonah-iden 35849da
fixed notebook not scrollable when mouse in editor
jonah-iden 6e3079e
api and contributions for notebook renderers
jonah-iden cb7dc84
Improve editor performance
msujew cdd8739
basic cell rendering in iframes working
jonah-iden 7ea5f8f
actually fixed document allready exists error
jonah-iden 3a7f070
only display output webview when outputs
jonah-iden a1f5f8c
some fixes for displaying outputs
jonah-iden d237e9e
small fix for images, so the output height is determined correctly
jonah-iden 49ec33c
scrolling propagation from output webview to parent working
jonah-iden f37cce4
smaller output layouting changes
jonah-iden 8e08f1c
added sidebar menu for cells
jonah-iden 098077d
Improve a few rendering issues, cleanup CSS
msujew 0545249
Fix notebook widget startup rendering
msujew ac5244a
working sidebar and change presentation for outputs
jonah-iden f6ca0dd
merge issue fixes
jonah-iden 4220260
quickfix for ouput action menu
jonah-iden e62a686
small fix for ouput webview horizontal size
jonah-iden a1ed1ca
fix for previous css fix
jonah-iden 65b58bf
save outputs and notebook dirty on output change
jonah-iden 1233170
basic cell status view (still kind of bugged
jonah-iden e2f5699
fixed notebook code-cell status-bar
jonah-iden 9cbf5ac
renamed Dto methods since they dont
jonah-iden 13e5746
fixed issue with no document found when notebook is restored
jonah-iden 7b18f0f
basic notebook toolbar
jonah-iden 305f4fc
working kernel chooser
jonah-iden 1880a57
persisting kernel selection
jonah-iden c02e5a6
upgraded notebook to 1.40
jonah-iden 26b2324
fixed no document error with adding new code cell;
jonah-iden f00e110
added notebook/cell/execution contribution menu;
jonah-iden 3c1664a
basic undo redo for notebook-editor
jonah-iden fbf1662
fixes for setting current active editor
jonah-iden 976741c
added drag and drop moving of cells
jonah-iden 1527850
Set editor dirty on any edit operation
msujew 55a5435
Fix formatting
msujew 04859d7
Fix notebook editor resize behavior
msujew 474faf9
Fix broken monaco editor
msujew 9cb19ff
removed @stubbed for most of notebook-api;
jonah-iden 6a0a3b9
fixed build for api changes
jonah-iden 374dcdb
fixed lint
jonah-iden ab1727a
basics for creating new untitled notebooks
jonah-iden e8dd288
Fix issues after latest commit
msujew 0ef597d
Don't cache matched notebook types
msujew f3a031c
fixed multiple smaller issues
jonah-iden 6409051
basic wokring creating new empty notebook;
jonah-iden a89eb2e
basic saveAs functionality for untitle notebooks
jonah-iden b7fcb31
Fix bugs, typos, and improve notebook behavior
msujew 9add50f
Fix notebook header rendering
msujew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
removed @stubbed for most of notebook-api;
implemented more of the api; Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
- Loading branch information
commit 9cb19ffe677f6f7d8172fe80d295e126f79b166f
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ import { URI as TheiaURI } from '../types-impl'; | |
import * as theia from '@theia/plugin'; | ||
import { | ||
CommandRegistryExt, ModelAddedData, NotebookCellStatusBarListDto, NotebookDataDto, | ||
NotebookDocumentsAndEditorsDelta, NotebookDocumentsMain, NotebookEditorAddData, NotebooksExt, NotebooksMain, Plugin, | ||
NotebookDocumentsAndEditorsDelta, NotebookDocumentShowOptions, NotebookDocumentsMain, NotebookEditorAddData, NotebookEditorsMain, NotebooksExt, NotebooksMain, Plugin, | ||
PLUGIN_RPC_CONTEXT | ||
} from '../../common'; | ||
import { Cache } from '../../common/cache'; | ||
|
@@ -70,6 +70,7 @@ export class NotebooksExtImpl implements NotebooksExt { | |
|
||
private notebookProxy: NotebooksMain; | ||
private notebookDocumentsProxy: NotebookDocumentsMain; | ||
private notebookEditors: NotebookEditorsMain; | ||
|
||
constructor( | ||
rpc: RPCProtocol, | ||
|
@@ -79,6 +80,7 @@ export class NotebooksExtImpl implements NotebooksExt { | |
) { | ||
this.notebookProxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOKS_MAIN); | ||
this.notebookDocumentsProxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOK_DOCUMENTS_MAIN); | ||
this.notebookEditors = rpc.getProxy(PLUGIN_RPC_CONTEXT.NOTEBOOK_EDITORS_MAIN); | ||
|
||
commands.registerArgumentProcessor({ | ||
processArgument: (arg: { uri: URI }) => { | ||
|
@@ -191,6 +193,10 @@ export class NotebooksExtImpl implements NotebooksExt { | |
return editor; | ||
} | ||
|
||
getAllApiDocuments(): theia.NotebookDocument[] { | ||
return [...this.documents.values()].map(doc => doc.apiNotebook); | ||
} | ||
|
||
async $acceptDocumentsAndEditorsDelta(delta: NotebookDocumentsAndEditorsDelta): Promise<void> { | ||
if (delta.removedDocuments) { | ||
for (const uri of delta.removedDocuments) { | ||
|
@@ -305,9 +311,9 @@ export class NotebooksExtImpl implements NotebooksExt { | |
} | ||
} | ||
|
||
getNotebookDocument(uri: URI, relaxed: true): NotebookDocument | undefined; | ||
getNotebookDocument(uri: URI): NotebookDocument; | ||
getNotebookDocument(uri: URI, relaxed?: true): NotebookDocument | undefined { | ||
getNotebookDocument(uri: TheiaURI, relaxed: true): NotebookDocument | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't found a call site that uses the "relaxed" parameter. let's remove it. |
||
getNotebookDocument(uri: TheiaURI): NotebookDocument; | ||
getNotebookDocument(uri: TheiaURI, relaxed?: true): NotebookDocument | undefined { | ||
const result = this.documents.get(uri.toString()); | ||
if (!result && !relaxed) { | ||
throw new Error(`NO notebook document for '${uri}'`); | ||
|
@@ -332,4 +338,58 @@ export class NotebooksExtImpl implements NotebooksExt { | |
this.editors.set(editorId, editor); | ||
} | ||
|
||
async createNotebookDocument(options: { viewType: string; content?: theia.NotebookData }): Promise<TheiaURI> { | ||
const canonicalUri = await this.notebookDocumentsProxy.$tryCreateNotebook({ | ||
viewType: options.viewType, | ||
content: options.content && typeConverters.NotebookData.from(options.content) | ||
}); | ||
return TheiaURI.from(canonicalUri); | ||
} | ||
|
||
async openNotebookDocument(uri: TheiaURI): Promise<theia.NotebookDocument> { | ||
const cached = this.documents.get(uri.toString()); | ||
if (cached) { | ||
return cached.apiNotebook; | ||
} | ||
const canonicalUri = await this.notebookDocumentsProxy.$tryOpenNotebook(uri); | ||
const document = this.documents.get(URI.fromComponents(canonicalUri).toString()); | ||
return document?.apiNotebook!; | ||
} | ||
|
||
async showNotebookDocument(notebookOrUri: theia.NotebookDocument | TheiaURI, options?: theia.NotebookDocumentShowOptions): Promise<theia.NotebookEditor> { | ||
|
||
if (URI.isUri(notebookOrUri)) { | ||
notebookOrUri = await this.openNotebookDocument(notebookOrUri as TheiaURI); | ||
} | ||
|
||
const notebook = notebookOrUri as theia.NotebookDocument; | ||
|
||
let resolvedOptions: NotebookDocumentShowOptions; | ||
if (typeof options === 'object') { | ||
resolvedOptions = { | ||
position: typeConverters.ViewColumn.from(options.viewColumn), | ||
preserveFocus: options.preserveFocus, | ||
selections: options.selections && options.selections.map(typeConverters.NotebookRange.from), | ||
pinned: typeof options.preview === 'boolean' ? !options.preview : undefined | ||
}; | ||
} else { | ||
resolvedOptions = { | ||
preserveFocus: false | ||
}; | ||
} | ||
|
||
const editorId = await this.notebookEditors.$tryShowNotebookDocument(notebook.uri, notebook.notebookType, resolvedOptions); | ||
const editor = editorId && this.editors.get(editorId)?.apiEditor; | ||
|
||
if (editor) { | ||
return editor; | ||
} | ||
|
||
if (editorId) { | ||
throw new Error(`Could NOT open editor for "${notebook.uri.toString()}" because another editor opened in the meantime.`); | ||
} else { | ||
throw new Error(`Could NOT open editor for "${notebook.uri.toString()}".`); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need this method: documents can become dirty by being a new untitled document or by being changed. We are aware of both events on the plugin side: couldn't we decide on the dirty state without being explicitly told?