-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aligned active text and notebook editor more towards vscode (#14190)
* active notebook editor now undefined when a text editor is selected Signed-off-by: Jonah Iden <[email protected]> * working vscode api active text editor for cells Signed-off-by: Jonah Iden <[email protected]> * fixed backend focused cell when creating new Signed-off-by: Jonah Iden <[email protected]> * fixed notebook and text editors side by side not being set as active correctly Signed-off-by: Jonah Iden <[email protected]> --------- Signed-off-by: Jonah Iden <[email protected]>
- Loading branch information
1 parent
5312708
commit 0f1ebdf
Showing
14 changed files
with
214 additions
and
31 deletions.
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
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
56 changes: 56 additions & 0 deletions
56
packages/notebook/src/browser/service/notebook-cell-editor-service.ts
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 Typefox and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { Emitter, URI } from '@theia/core'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { SimpleMonacoEditor } from '@theia/monaco/lib/browser/simple-monaco-editor'; | ||
|
||
@injectable() | ||
export class NotebookCellEditorService { | ||
|
||
protected onDidChangeCellEditorsEmitter = new Emitter<void>(); | ||
readonly onDidChangeCellEditors = this.onDidChangeCellEditorsEmitter.event; | ||
|
||
protected onDidChangeFocusedCellEditorEmitter = new Emitter<SimpleMonacoEditor | undefined>(); | ||
readonly onDidChangeFocusedCellEditor = this.onDidChangeFocusedCellEditorEmitter.event; | ||
|
||
protected currentActiveCell?: SimpleMonacoEditor; | ||
|
||
protected currentCellEditors: Map<string, SimpleMonacoEditor> = new Map(); | ||
|
||
get allCellEditors(): SimpleMonacoEditor[] { | ||
return Array.from(this.currentCellEditors.values()); | ||
} | ||
|
||
editorCreated(uri: URI, editor: SimpleMonacoEditor): void { | ||
this.currentCellEditors.set(uri.toString(), editor); | ||
this.onDidChangeCellEditorsEmitter.fire(); | ||
} | ||
|
||
editorDisposed(uri: URI): void { | ||
this.currentCellEditors.delete(uri.toString()); | ||
this.onDidChangeCellEditorsEmitter.fire(); | ||
} | ||
|
||
editorFocusChanged(editor?: SimpleMonacoEditor): void { | ||
this.currentActiveCell = editor; | ||
this.onDidChangeFocusedCellEditorEmitter.fire(editor); | ||
} | ||
|
||
getActiveCell(): SimpleMonacoEditor | undefined { | ||
return this.currentActiveCell; | ||
} | ||
} |
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
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
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.