Skip to content

Commit 3e0373d

Browse files
committed
frontend/jupyter: move markdown edit button row to the cell-buttonbar, to have everything in one place. With that, the cell menu appears on markdown cells as well
1 parent a5fb1d2 commit 3e0373d

File tree

25 files changed

+132
-86
lines changed

25 files changed

+132
-86
lines changed

src/packages/frontend/frame-editors/jupyter-editor/cell-notebook/actions.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import {
1414
} from "@cocalc/frontend/jupyter/commands";
1515
import { create_key_handler } from "@cocalc/frontend/jupyter/keyboard";
1616
import Fragment from "@cocalc/frontend/misc/fragment-id";
17-
import { Cell, CellType, Scroll } from "@cocalc/jupyter/types";
17+
import { Cell, Scroll } from "@cocalc/jupyter/types";
1818
import { move_selected_cells } from "@cocalc/jupyter/util/cell-utils";
19+
import { CellType } from "@cocalc/util/jupyter/types";
1920
import {
2021
bind_methods,
2122
close,
@@ -214,7 +215,7 @@ export class NotebookFrameActions {
214215
}
215216

216217
/***
217-
* Debugging related functioanlity
218+
* Debugging related functionality
218219
***/
219220

220221
private dbg(f: string, ...args): void {
@@ -281,7 +282,7 @@ export class NotebookFrameActions {
281282
}
282283

283284
/* Run the selected cells; triggered by either clicking the play button or
284-
press shift+enter. Note that this has weird and inconsitent
285+
press shift+enter. Note that this has weird and inconsistent
285286
behavior in official Jupyter for usability reasons and due to
286287
their "modal" approach.
287288
In particular, if the selections goes to the end of the document, we
@@ -487,7 +488,7 @@ export class NotebookFrameActions {
487488
const cell = this.get_cell_by_id(id);
488489
if (cell == null) return;
489490

490-
if (cell.getIn(["metadata", "editable"]) === false) {
491+
if (!this.jupyter_actions.store.is_cell_editable(id)) {
491492
// TODO: NEVER ever silently fail!
492493
return;
493494
}
@@ -496,6 +497,30 @@ export class NotebookFrameActions {
496497
this.set_mode("edit");
497498
}
498499

500+
cell_md_is_editing(id): boolean {
501+
let md_edit_ids = this.store.get("md_edit_ids");
502+
if (md_edit_ids == null) md_edit_ids = Set();
503+
return md_edit_ids.contains(id);
504+
}
505+
506+
public toggle_md_cell_edit(id: string): void {
507+
const cell = this.get_cell_by_id(id);
508+
if (cell == null) return;
509+
if (!this.jupyter_actions.store.is_cell_editable(id)) {
510+
// TODO: NEVER ever silently fail!
511+
return;
512+
}
513+
514+
this.set_cur_id(id);
515+
if (this.cell_md_is_editing(id)) {
516+
this.set_md_cell_not_editing(id);
517+
this.set_mode("escape");
518+
} else {
519+
this.switch_md_cell_to_edit(id);
520+
this.set_mode("edit");
521+
}
522+
}
523+
499524
public switch_code_cell_to_edit(id: string): void {
500525
const cell = this.get_cell_by_id(id);
501526
if (cell == null) return;
@@ -594,7 +619,7 @@ export class NotebookFrameActions {
594619
}
595620

596621
// select all cells, possibly of a given type.
597-
select_all_cells = (cell_type?: "code" | "markdown" | "raw") => {
622+
select_all_cells = (cell_type?: CellType) => {
598623
let sel_ids;
599624
if (cell_type) {
600625
sel_ids =

src/packages/frontend/i18n/trans/ar_EG.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "تغيير Markdown إلى Heading 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "تغيير Markdown إلى العنوان 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "تغيير الخلية إلى Markdown",
667-
"jupyter.commands.change_cell_to_row.label": "تغيير الخلية إلى خام",
667+
"jupyter.commands.change_cell_to_raw.label": "تغيير الخلية إلى خام",
668668
"jupyter.commands.change_kernel": "تغيير النواة...",
669669
"jupyter.commands.change_kernel_title": "اختر من أي من النوى المتاحة",
670670
"jupyter.commands.clear_all_cells_output.label": "مسح جميع مخرجات الخلايا",

src/packages/frontend/i18n/trans/de_DE.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Ändern Sie Markdown in Überschrift 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Ändern Sie Markdown in Überschrift 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "Ändere Zelle zu Markdown",
667-
"jupyter.commands.change_cell_to_row.label": "Zelle in Rohdaten ändern",
667+
"jupyter.commands.change_cell_to_raw.label": "Zelle in Rohdaten ändern",
668668
"jupyter.commands.change_kernel": "Kernel ändern...",
669669
"jupyter.commands.change_kernel_title": "Wählen Sie aus den verfügbaren Kernels.",
670670
"jupyter.commands.clear_all_cells_output.label": "Alle Zellausgaben löschen",

src/packages/frontend/i18n/trans/es_ES.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Cambiar Markdown a Encabezado 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Cambiar Markdown a Encabezado 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "Cambiar Celda a Markdown",
667-
"jupyter.commands.change_cell_to_row.label": "Cambiar Celda a Raw",
667+
"jupyter.commands.change_cell_to_raw.label": "Cambiar Celda a Raw",
668668
"jupyter.commands.change_kernel": "Cambiar Kernel...",
669669
"jupyter.commands.change_kernel_title": "Seleccionar de cualquiera de los kernels disponibles",
670670
"jupyter.commands.clear_all_cells_output.label": "Borrar todas las salidas de celdas",

src/packages/frontend/i18n/trans/es_PV.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Aldatu Markdown 5. goiburura",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Aldatu Markdown 6. Izenburura",
666666
"jupyter.commands.change_cell_to_markdown.label": "Aldatu Zela Markdown-era",
667-
"jupyter.commands.change_cell_to_row.label": "Aldatu Zelaia Gordin bihurtzeko",
667+
"jupyter.commands.change_cell_to_raw.label": "Aldatu Zelaia Gordin bihurtzeko",
668668
"jupyter.commands.change_kernel": "Aldatu Kernel...",
669669
"jupyter.commands.change_kernel_title": "Hautatu eskuragarri dauden kernel batetik.",
670670
"jupyter.commands.clear_all_cells_output.label": "Garbitu Gelaxka Irteera Guztiak",

src/packages/frontend/i18n/trans/fr_FR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Changer Markdown en Titre 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Changer Markdown en Titre 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "Changer la cellule en Markdown",
667-
"jupyter.commands.change_cell_to_row.label": "Changer la cellule en brut",
667+
"jupyter.commands.change_cell_to_raw.label": "Changer la cellule en brut",
668668
"jupyter.commands.change_kernel": "Changer de noyau...",
669669
"jupyter.commands.change_kernel_title": "Sélectionnez parmi les noyaux disponibles.",
670670
"jupyter.commands.clear_all_cells_output.label": "Effacer tous les résultats des cellules",

src/packages/frontend/i18n/trans/he_IL.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "שנה את Markdown לכותרת 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "שנה את Markdown לכותרת 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "שנה תא למרקדאון",
667-
"jupyter.commands.change_cell_to_row.label": "שנה תא לתא גולמי",
667+
"jupyter.commands.change_cell_to_raw.label": "שנה תא לתא גולמי",
668668
"jupyter.commands.change_kernel": "שנה קרנל...",
669669
"jupyter.commands.change_kernel_title": "בחר מתוך כל הליבות הזמינות",
670670
"jupyter.commands.clear_all_cells_output.label": "נקה את כל הפלטים של התאים",

src/packages/frontend/i18n/trans/hi_IN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "मार्कडाउन से शीर्षक 5 में बदलें",
665665
"jupyter.commands.change_cell_to_heading_6.label": "मार्कडाउन को शीर्षक 6 में बदलें",
666666
"jupyter.commands.change_cell_to_markdown.label": "सेल को मार्कडाउन में बदलें",
667-
"jupyter.commands.change_cell_to_row.label": "सेल को Raw में बदलें",
667+
"jupyter.commands.change_cell_to_raw.label": "सेल को Raw में बदलें",
668668
"jupyter.commands.change_kernel": "कर्नेल बदलें...",
669669
"jupyter.commands.change_kernel_title": "किसी भी उपलब्ध कर्नल से चयन करें।",
670670
"jupyter.commands.clear_all_cells_output.label": "सभी सेल आउटपुट साफ करें",

src/packages/frontend/i18n/trans/hu_HU.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Módosítás Markdownról Címsor 5-re",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Alakítsa át a Markdown-t Fejléc 6-ra",
666666
"jupyter.commands.change_cell_to_markdown.label": "Módosítás Markdown cellára",
667-
"jupyter.commands.change_cell_to_row.label": "Cell módosítása nyersre",
667+
"jupyter.commands.change_cell_to_raw.label": "Cell módosítása nyersre",
668668
"jupyter.commands.change_kernel": "Módosítás Kernel...",
669669
"jupyter.commands.change_kernel_title": "Válasszon bármelyik elérhető kernelből.",
670670
"jupyter.commands.clear_all_cells_output.label": "Összes cellakimenet törlése",

src/packages/frontend/i18n/trans/it_IT.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@
664664
"jupyter.commands.change_cell_to_heading_5.label": "Cambia Markdown in Intestazione 5",
665665
"jupyter.commands.change_cell_to_heading_6.label": "Cambia Markdown in Intestazione 6",
666666
"jupyter.commands.change_cell_to_markdown.label": "Cambia cella in Markdown",
667-
"jupyter.commands.change_cell_to_row.label": "Cambia Celle in Grezzo",
667+
"jupyter.commands.change_cell_to_raw.label": "Cambia Celle in Grezzo",
668668
"jupyter.commands.change_kernel": "Cambia Kernel...",
669669
"jupyter.commands.change_kernel_title": "Seleziona da uno dei kernel disponibili.",
670670
"jupyter.commands.clear_all_cells_output.label": "Cancella tutti gli output delle celle",

0 commit comments

Comments
 (0)