From ba73086b36ac2b7c167086eb101dc8a6a04d29b2 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 13 Sep 2023 22:05:57 +0200 Subject: [PATCH 1/3] CSS: make export small buttons floating --- frontend/editor.css | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/editor.css b/frontend/editor.css index 6cf6bf7617..7d92b004a4 100644 --- a/frontend/editor.css +++ b/frontend/editor.css @@ -502,7 +502,7 @@ aside#export div#container { flex-direction: row; display: flex; max-width: 1000px; - padding-right: 20px; + padding-right: 10em; margin: 0 auto; } header aside#export div#container { @@ -553,10 +553,14 @@ a.export_card section { padding: 3px; } aside#export .export_small_btns { - margin-left: auto; - height: 60px; display: flex; flex-direction: row; + padding: 0.9em; + border-radius: 0.9em; + position: absolute; + right: 0.8em; + top: 0em; + background: var(--export-bg-color); } body.static_preview button.toggle_export { display: none; From a86709b0108261181bb915bd40beb292ca853c0d Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Fri, 15 Sep 2023 14:12:31 -0500 Subject: [PATCH 2/3] Fix typo in docstring (#2648) --- src/runner/PlutoRunner.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runner/PlutoRunner.jl b/src/runner/PlutoRunner.jl index 030de8cd48..bb496c4d7e 100644 --- a/src/runner/PlutoRunner.jl +++ b/src/runner/PlutoRunner.jl @@ -671,7 +671,7 @@ Notebook code does run in `Main` - it runs in workspace modules. Every time that The trick boils down to two things: 1. When we create a new workspace module, we move over some of the global from the old workspace. (But not the ones that we want to 'delete'!) -2. If a function used to be defined, but now we want to delete it, then we go through the method table of that function and snoop out all methods that we defined by us, and not by another package. This is how we reverse extending external functions. For example, if you run a cell with `Base.sqrt(s::String) = "the square root of" * s`, and then delete that cell, then you can still call `sqrt(1)` but `sqrt("one")` will err. Cool right! +2. If a function used to be defined, but now we want to delete it, then we go through the method table of that function and snoop out all methods that were defined by us, and not by another package. This is how we reverse extending external functions. For example, if you run a cell with `Base.sqrt(s::String) = "the square root of" * s`, and then delete that cell, then you can still call `sqrt(1)` but `sqrt("one")` will err. Cool right! """ function move_vars( old_workspace_name::Symbol, From ea894795b7c84b3fe159617475e0ad5a53a5ecde Mon Sep 17 00:00:00 2001 From: Alberto Mengali Date: Sat, 16 Sep 2023 22:50:02 +0200 Subject: [PATCH 3/3] add keyboard shortcuts (LeftArrow and RightArrow) to move slides in presentation mode (#2611) --- frontend/components/SlideControls.js | 51 +++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/frontend/components/SlideControls.js b/frontend/components/SlideControls.js index 60a6380eb0..0b096d6996 100644 --- a/frontend/components/SlideControls.js +++ b/frontend/components/SlideControls.js @@ -1,6 +1,35 @@ -import { html } from "../imports/Preact.js" +import { html, useRef, useState, useLayoutEffect, useEffect } from "../imports/Preact.js" +import { open_pluto_popup } from "./Popup.js" export const SlideControls = () => { + const button_prev_ref = useRef(/** @type {HTMLButtonElement?} */ (null)) + const button_next_ref = useRef(/** @type {HTMLButtonElement?} */ (null)) + + const [presenting, set_presenting] = useState(false) + + const move_slides_with_keyboard = (/** @type {KeyboardEvent} */ e) => { + const activeElement = document.activeElement + if ( + activeElement != null && + activeElement !== document.body && + activeElement !== button_prev_ref.current && + activeElement !== button_next_ref.current + ) { + // We do not move slides with arrow if we have an active element + return + } + if (e.key === "ArrowLeft" || e.key === "PageUp") { + button_prev_ref.current?.click() + } else if (e.key === "ArrowRight" || e.key === " " || e.key === "PageDown") { + button_next_ref.current?.click() + } else if (e.key === "Escape") { + set_presenting(false) + } else { + return + } + e.preventDefault() + } + const calculate_slide_positions = (/** @type {Event} */ e) => { const notebook_node = /** @type {HTMLElement?} */ (e.target)?.closest("pluto-editor")?.querySelector("pluto-notebook") if (!notebook_node) return [] @@ -40,15 +69,29 @@ export const SlideControls = () => { if (pos) window.scrollTo(window.pageXOffset, pos) } + const presenting_ref = useRef(false) + presenting_ref.current = presenting // @ts-ignore window.present = () => { - document.body.classList.toggle("presentation") + set_presenting(!presenting_ref.current) } + useLayoutEffect(() => { + document.body.classList.toggle("presentation", presenting) + + if (!presenting) return // We do not add listeners if not presenting + + window.addEventListener("keydown", move_slides_with_keyboard) + + return () => { + window.removeEventListener("keydown", move_slides_with_keyboard) + } + }, [presenting]) + return html` ` }