Skip to content

Commit

Permalink
feat: adding run cells to markdown cells also datalayer#247
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Alves committed Jun 26, 2024
1 parent 3b452ca commit 22a31b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/react/src/components/cell/CellAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@ export class CellAdapter {
});
handler.editor = editor;

if (this._type === 'code') {
CellCommands(commands, (this._codeCell as CodeCell)!, this._sessionContext, handler);
}
CellCommands(commands, this._codeCell!, this._sessionContext, handler);
completer.hide();
completer.addClass('jp-Completer-Cell');
Widget.attach(completer, document.body);
Expand Down Expand Up @@ -347,6 +345,7 @@ export class CellAdapter {
this._panel.spacing = 0;
this._panel.addWidget(toolbar);
this._panel.addWidget(this._codeCell);

BoxPanel.setStretch(toolbar, 0);
BoxPanel.setStretch(this._codeCell, 1);
window.addEventListener('resize', () => {
Expand Down
12 changes: 9 additions & 3 deletions packages/react/src/components/cell/CellCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CommandRegistry } from '@lumino/commands';
import { CompletionHandler } from '@jupyterlab/completer';
import { CodeCell } from '@jupyterlab/cells';
import { CodeCell, MarkdownCell, RawCell } from '@jupyterlab/cells';
import { SessionContext } from '@jupyterlab/apputils';

const cmdIds = {
Expand All @@ -16,7 +16,7 @@ const cmdIds = {

export const CellCommands = (
commandRegistry: CommandRegistry,
codeCell: CodeCell,
codeCell: CodeCell | MarkdownCell | RawCell,
sessionContext: SessionContext,
completerHandler: CompletionHandler
): void => {
Expand All @@ -29,7 +29,13 @@ export const CellCommands = (
execute: () => completerHandler.completer.selectActive(),
});
commandRegistry.addCommand('run:cell', {
execute: () => CodeCell.execute(codeCell, sessionContext),
execute: () => {
if (codeCell instanceof CodeCell) {
CodeCell.execute(codeCell, sessionContext)
} else if (codeCell instanceof MarkdownCell) {
(codeCell as MarkdownCell).rendered = true;
}
},
});
commandRegistry.addKeyBinding({
selector: '.jp-InputArea-editor.jp-mod-completer-enabled',
Expand Down

0 comments on commit 22a31b3

Please sign in to comment.