-
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.
Added Keybindings to notebook editor (#13497)
* Fixed context keys for notebook editor contexts this makes commands from jupyter available Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * smaller fix and removed unnecessary change Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * fixed build Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * review comments Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * fixed context key management for notebook main toolbar Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * refactored notebook context key management Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * contextKey scope refactor and markdown close editor keybinding Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * more keybindings Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * added insert cell commands Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * smaller fixes, refactoring, changing cell type command Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * review changes remove unused inject * remove unneccessary import Signed-off-by: Jonah Iden <jonah.iden@typefox.io> * update cell context when selecte cell has been replaced Signed-off-by: Jonah Iden <jonah.iden@typefox.io> --------- Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
- Loading branch information
1 parent
d76ec39
commit 3e16157
Showing
18 changed files
with
392 additions
and
165 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
38 changes: 38 additions & 0 deletions
38
packages/notebook/src/browser/contributions/cell-operations.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,38 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 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 { CellEditType, CellKind } from '../../common'; | ||
import { NotebookCellModel } from '../view-model/notebook-cell-model'; | ||
import { NotebookModel } from '../view-model/notebook-model'; | ||
|
||
/** | ||
* a collection of different reusable notbook cell operations | ||
*/ | ||
|
||
export function changeCellType(notebookModel: NotebookModel, cell: NotebookCellModel, type: CellKind): void { | ||
if (cell.cellKind === type) { | ||
return; | ||
} | ||
notebookModel.applyEdits([{ | ||
editType: CellEditType.Replace, | ||
index: notebookModel.cells.indexOf(cell), | ||
count: 1, | ||
cells: [{ | ||
...cell.getData(), | ||
cellKind: type | ||
}] | ||
}], true); | ||
} |
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.