diff --git a/assets/js/session/index.js b/assets/js/session/index.js index 15cacd9da..ee68343c0 100644 --- a/assets/js/session/index.js +++ b/assets/js/session/index.js @@ -56,7 +56,7 @@ const Session = { document .querySelector(`[data-element="sections-panel-toggle"]`) .addEventListener("click", (event) => { - this.el.toggleAttribute("data-js-sections-panel-expanded"); + toggleSectionsPanel(this); }); // Server events @@ -142,6 +142,10 @@ function handleDocumentKeyDown(hook, event) { queueFocusedSectionEvaluation(hook); } else if (keyBuffer.tryMatch(["e", "j"])) { queueChildCellsEvaluation(hook); + } else if (keyBuffer.tryMatch(["s", "s"])) { + toggleSectionsPanel(hook); + } else if (keyBuffer.tryMatch(["s", "n"])) { + showNotebookSettings(hook); } else if (keyBuffer.tryMatch(["e", "x"])) { cancelFocusedCellEvaluation(hook); } else if (keyBuffer.tryMatch(["?"])) { @@ -265,6 +269,14 @@ function updateSectionListHighlight() { // User action handlers (mostly keybindings) +function toggleSectionsPanel(hook) { + hook.el.toggleAttribute("data-js-sections-panel-expanded"); +} + +function showNotebookSettings(hook) { + hook.pushEvent("show_notebook_settings", {}); +} + function deleteFocusedCell(hook) { if (hook.state.focusedCellId) { hook.pushEvent("delete_cell", { cell_id: hook.state.focusedCellId }); diff --git a/lib/livebook_web/live/session_live.ex b/lib/livebook_web/live/session_live.ex index fd15f67f8..a8346173e 100644 --- a/lib/livebook_web/live/session_live.ex +++ b/lib/livebook_web/live/session_live.ex @@ -78,19 +78,19 @@ defmodule LivebookWeb.SessionLive do Lb <% end %> - + - + <%= live_patch to: Routes.session_path(@socket, :settings, @session_id, "file"), class: "text-gray-600 hover:text-gray-50 focus:text-gray-50 #{if(@live_action == :settings, do: "text-gray-50")}" do %> <%= remix_icon("settings-4-fill", class: "text-2xl") %> <% end %>
- + <%= live_patch to: Routes.session_path(@socket, :shortcuts, @session_id), class: "text-gray-600 hover:text-gray-50 focus:text-gray-50" do %> <%= remix_icon("keyboard-box-fill", class: "text-2xl") %> @@ -313,6 +313,13 @@ defmodule LivebookWeb.SessionLive do push_patch(socket, to: Routes.session_path(socket, :shortcuts, socket.assigns.session_id))} end + def handle_event("show_notebook_settings", %{}, socket) do + {:noreply, + push_patch(socket, + to: Routes.session_path(socket, :settings, socket.assigns.session_id, "file") + )} + end + @impl true def handle_info({:operation, operation}, socket) do case Session.Data.apply_operation(socket.assigns.data, operation) do diff --git a/lib/livebook_web/live/session_live/shortcuts_component.ex b/lib/livebook_web/live/session_live/shortcuts_component.ex index fa0beee2f..6a58ea243 100644 --- a/lib/livebook_web/live/session_live/shortcuts_component.ex +++ b/lib/livebook_web/live/session_live/shortcuts_component.ex @@ -22,7 +22,9 @@ defmodule LivebookWeb.SessionLive.ShortcutsComponent do %{seq: ["es"], desc: "Evaluate section"}, %{seq: ["ea"], desc: "Evaluate all stale/new cells"}, %{seq: ["ej"], desc: "Evaluate cells below"}, - %{seq: ["ex"], desc: "Cancel cell evaluation"} + %{seq: ["ex"], desc: "Cancel cell evaluation"}, + %{seq: ["ss"], desc: "Toggle sections panel"}, + %{seq: ["sn"], desc: "Show notebook settings"} ] }