Skip to content

Commit cad322b

Browse files
Remove markdown cell rendered preview (#10872)
Addresses #10455 This updates markdown cells so that they: - show a `pencil` icon in action bar (instead of chevron down) to toggle edit mode - show a `checkmark` icon in action bar (instead of chevron up) to toggle view mode - do not show a rendered preview of the cell contents when in edit mode **AFTER** https://github.com/user-attachments/assets/bec306bf-dcb3-41ac-8cba-b80dd993c45f ### Release Notes <!-- Optionally, replace `N/A` with text to be included in the next release notes. The `N/A` bullets are ignored. If you refer to one or more Positron issues, these issues are used to collect information about the feature or bugfix, such as the relevant language pack as determined by Github labels of type `lang: `. The note will automatically be tagged with the language. These notes are typically filled by the Positron team. If you are an external contributor, you may ignore this section. --> #### New Features - N/A #### Bug Fixes - N/A ### QA Notes @:positron-notebooks <!-- Positron team members: please add relevant e2e test tags, so the tests can be run when you open this pull request. - Instructions: https://github.com/posit-dev/positron/blob/main/test/e2e/README.md#pull-requests-and-test-tags - Available tags: https://github.com/posit-dev/positron/blob/main/test/e2e/infra/test-runner/test-tags.ts --> <!-- Add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the linked issues. -->
1 parent b39253f commit cad322b

File tree

5 files changed

+52
-29
lines changed

5 files changed

+52
-29
lines changed

src/vs/workbench/contrib/positronNotebook/browser/notebookCells/NotebookCellSelection.css

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,25 @@
9999
border: none;
100100
}
101101

102-
/* When selected/editing AND no outputs: restore bottom rounding */
103-
.positron-notebook-cell.selected:has(.positron-notebook-cell-outputs.no-outputs) .positron-notebook-editor-container::after,
104-
.positron-notebook-cell.editing:has(.positron-notebook-cell-outputs.no-outputs) .positron-notebook-editor-container::after,
105-
.positron-notebook-cell:not(.selected):not(.editing):hover:has(.positron-notebook-cell-outputs.no-outputs) .positron-notebook-editor-container::after {
106-
border-bottom-left-radius: var(--_positron-notebook-selection-bar-radius);
102+
/* Restore bottom rounding when no outputs are shown */
103+
.positron-notebook-cell {
104+
/* Code cells with no outputs */
105+
&.selected:has(.positron-notebook-cell-outputs.no-outputs),
106+
&.editing:has(.positron-notebook-cell-outputs.no-outputs),
107+
&:not(.selected):not(.editing):hover:has(.positron-notebook-cell-outputs.no-outputs) {
108+
.positron-notebook-editor-container::after {
109+
border-bottom-left-radius: var(--_positron-notebook-selection-bar-radius);
110+
}
111+
}
112+
113+
/* Markdown cells in edit mode (no output element) */
114+
&.selected:not(:has(.positron-notebook-cell-outputs)),
115+
&.editing:not(:has(.positron-notebook-cell-outputs)),
116+
&:not(.selected):not(.editing):hover:not(:has(.positron-notebook-cell-outputs)) {
117+
.positron-notebook-editor-container::after {
118+
border-bottom-left-radius: var(--_positron-notebook-selection-bar-radius);
119+
}
120+
}
107121
}
108122

109123
/* When editor container is empty, round both corners of outputs bar (This is the case when markdown has been rendered but doesn't have an editor open) */

src/vs/workbench/contrib/positronNotebook/browser/notebookCells/NotebookMarkdownCell.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,26 @@ export function NotebookMarkdownCell({ cell }: { cell: PositronNotebookMarkdownC
3333
<div className={`positron-notebook-editor-container ${editorShown ? '' : 'editor-hidden'}`}>
3434
{editorShown ? <CellEditorMonacoWidget cell={cell} /> : null}
3535
</div>
36-
<div className='cell-contents positron-notebook-cell-outputs'>
37-
<div className='positron-notebook-markdown-rendered' onDoubleClick={() => {
38-
cell.toggleEditor();
39-
}}>
40-
{
41-
markdownString.length > 0 ?
42-
<Markdown content={markdownString} />
43-
: <div className='empty-output-msg'>
44-
{emptyMarkdownCell}
45-
{!editorShown && doubleClickToEdit}
46-
</div>
47-
}
48-
</div>
49-
</div>
36+
{!editorShown
37+
? (
38+
<div className='cell-contents positron-notebook-cell-outputs'>
39+
<div
40+
className='positron-notebook-markdown-rendered'
41+
onDoubleClick={() => cell.toggleEditor()}
42+
>
43+
{
44+
markdownString.length > 0
45+
? <Markdown content={markdownString} />
46+
: <div className='empty-output-msg'>
47+
{emptyMarkdownCell}
48+
{doubleClickToEdit}
49+
</div>
50+
}
51+
</div>
52+
</div>
53+
)
54+
: null
55+
}
5056
</NotebookCellWrapper>
5157
);
5258
}

src/vs/workbench/contrib/positronNotebook/browser/positronNotebook.contribution.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ registerAction2(class extends NotebookAction2 {
442442
* This command handles the keybinding for all cell types.
443443
*
444444
* This action has a counterpart command called
445-
* `positronNotebook.cell.collapseMarkdownEditor` that is
445+
* `positronNotebook.cell.viewMarkdown` that is
446446
* used to contribute the same functionality to markdown
447447
* cell action bars. We should keep both commands in sync
448448
* to ensure consistent behavior.
@@ -864,7 +864,7 @@ registerAction2(class extends NotebookAction2 {
864864
super({
865865
id: 'positronNotebook.cell.openMarkdownEditor',
866866
title: localize2('positronNotebook.cell.openMarkdownEditor', "Open Markdown Editor"),
867-
icon: ThemeIcon.fromId('chevron-down'),
867+
icon: ThemeIcon.fromId('edit'),
868868
menu: {
869869
id: MenuId.PositronNotebookCellActionBarLeft,
870870
order: 10,
@@ -887,7 +887,7 @@ registerAction2(class extends NotebookAction2 {
887887
});
888888

889889
/**
890-
* Collapse markdown editor (For action bar)
890+
* View markdown (For action bar)
891891
*
892892
* Handles contributing the behavior of
893893
* `positronNotebook.cell.quitEdit` to markdown cell
@@ -897,9 +897,9 @@ registerAction2(class extends NotebookAction2 {
897897
registerAction2(class extends NotebookAction2 {
898898
constructor() {
899899
super({
900-
id: 'positronNotebook.cell.collapseMarkdownEditor',
901-
title: localize2('positronNotebook.cell.collapseMarkdownEditor', "Collapse Markdown Editor"),
902-
icon: ThemeIcon.fromId('chevron-up'),
900+
id: 'positronNotebook.cell.viewMarkdown',
901+
title: localize2('positronNotebook.cell.viewMarkdown', "View Markdown"),
902+
icon: ThemeIcon.fromId('check'),
903903
menu: {
904904
id: MenuId.PositronNotebookCellActionBarLeft,
905905
order: 10,

test/e2e/pages/notebooksPositron.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class PositronNotebooks extends Notebooks {
5050
private spinnerAtIndex = (index: number) => this.cell.nth(index).getByLabel(/cell is executing/i);
5151
private executionStatusAtIndex = (index: number) => this.cell.nth(index).locator('[data-execution-status]');
5252
private deleteCellButton = this.cell.getByRole('button', { name: /Delete Cell/i });
53-
collapseMarkdownEditor = this.code.driver.page.getByRole('button', { name: 'Collapse markdown editor' });
53+
viewMarkdown = this.code.driver.page.getByRole('button', { name: 'View markdown' });
5454
expandMarkdownEditor = this.code.driver.page.getByRole('button', { name: 'Open markdown editor' });
5555

5656
constructor(code: Code, quickinput: QuickInput, quickaccess: QuickAccess, hotKeys: HotKeys, private contextMenu: ContextMenu) {
@@ -76,7 +76,7 @@ export class PositronNotebooks extends Notebooks {
7676

7777
if (cellType === 'markdown') {
7878
// Enter edit mode to ensure the monaco view-lines are present
79-
const inEditMode = await this.cell.nth(cellIndex).getByRole('button', { name: 'Collapse markdown editor' }).isVisible();
79+
const inEditMode = await this.cell.nth(cellIndex).getByRole('button', { name: 'View markdown' }).isVisible();
8080
if (!inEditMode) {
8181
await this.selectCellAtIndex(cellIndex, { editMode: true });
8282
}
@@ -94,7 +94,7 @@ export class PositronNotebooks extends Notebooks {
9494
});
9595

9696
if (cellType === 'markdown') {
97-
await this.collapseMarkdownEditor.click();
97+
await this.viewMarkdown.click();
9898
}
9999

100100
return content;

test/e2e/tests/notebooks-positron/notebook-markdown.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ test.describe('Positron Notebooks: Markdown Cells', {
3838
const markdownContent = '# Heading 1\n\n## Heading 2\n\n**Bold Text**\n\n*Italic Text*';
3939
await notebooksPositron.addCodeToCell(1, markdownContent);
4040

41+
await notebooksPositron.viewMarkdown.click();
42+
await notebooksPositron.expectCellIndexToBeSelected(1, { inEditMode: false });
43+
4144
// verify markdown rendered correctly
4245
await notebooksPositron.expectMarkdownTagToBe('h1', 'Heading 1');
4346
await notebooksPositron.expectMarkdownTagToBe('h2', 'Heading 2');
@@ -62,7 +65,7 @@ test.describe('Positron Notebooks: Markdown Cells', {
6265
await notebooksPositron.expectCellIndexToBeSelected(1, { inEditMode: true });
6366

6467
// switch to preview mode and verify
65-
await notebooksPositron.collapseMarkdownEditor.click();
68+
await notebooksPositron.viewMarkdown.click();
6669
await notebooksPositron.expectCellIndexToBeSelected(1, { inEditMode: false });
6770
await notebooksPositron.expectMarkdownTagToBe('strong', 'bold');
6871
await notebooksPositron.expectMarkdownTagToBe('em', 'italic');

0 commit comments

Comments
 (0)