From 2d1d34361556b4bdc098073fb146875390f00004 Mon Sep 17 00:00:00 2001 From: Victor Bahl Date: Sat, 14 Nov 2026 15:44:04 +0100 Subject: [PATCH 1/2] feat: Save as, with a public copy of the deck to hand out The Save as button in the edit view makes a public copy: the deck as it is now under a name of its own, without the speaker notes, the skipped slides, the layouts and the comments between the slides. It says what it leaves out first. The copy opens without the edit view, and an engine inlined in it loses the code of that view. --- README.md | 10 +++ skills/deck/assets/template.html | 108 +++++++++++++++++++++++++------ src/deck.js | 108 +++++++++++++++++++++++++------ template.html | 108 +++++++++++++++++++++++++------ test/deck.spec.mjs | 85 ++++++++++++++++++++++++ 5 files changed, 365 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 6afa4b7..610f218 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ The engine needs very little markup: | `data-auto="600"` on a section | its builds reveal by themselves, one every 600 ms (500 without a number), as soon as the slide shows; `→` and `←` take over | | `data-skip` on a section | the slide is skipped: left out of the show, the slide numbers and the print, and still there in the edit view | | `
` inside a slide | speaker notes, for the presenter and edit views | +| `data-public` on the stage | set by **Public copy** on the copy it makes: the deck opens without the edit view | The engine sets `.current` on the slide shown and `.on` on each build it reveals, and adds a `` with the slide number to every @@ -200,6 +201,12 @@ it looks. - **Save** or `Cmd/Ctrl+S` writes the deck: to a file you choose in Chromium, as a download elsewhere. It overwrites what is there, so reload first if an agent or editor changed the file since you opened it. +- **Save as…** makes a **Public copy** to send to your audience, named + `…-public.html`: the deck as it is now, without the speaker notes, the + skipped slides, the layouts and the comments between the slides. It says + what it leaves out first, then asks where to put the copy in Chromium and + downloads it elsewhere. The copy has no edit view, and not the code for it + either; it still presents and prints. **Suggest** leaves the deck alone and collects notes for whoever edits the file: @@ -307,6 +314,9 @@ Or copy or symlink [`skills/deck`](skills/deck) into `~/.claude/skills/`. read it: self-closed SVG tags, `` in tables, entities. Comments and indentation stay, and later saves change only what you changed. - Photos sit beside the file, so a deck with photos travels as a folder. +- A public copy has the engine without the code of the edit view, which + makes the file a good deal smaller. `update` puts the whole engine back; + the edit view then stays off until `data-public` is removed from the stage. ## Development diff --git a/skills/deck/assets/template.html b/skills/deck/assets/template.html index 4e58d0d..18aeaf6 100644 --- a/skills/deck/assets/template.html +++ b/skills/deck/assets/template.html @@ -625,6 +625,7 @@

Start from template.html

class="build" on any element revealed one at a time with → data-auto="500" on a section its builds reveal by themselves, one every 500 ms data-skip on a section left out of the show, its numbers and the print; the edit view still shows it + data-public on the stage a public copy made in the edit view, to hand out: it has no edit view The engine sets .current on the slide shown, .on on each build revealed, and adds a to every slide. URL: ?print opens the print dialog once loaded; ?presenter is the presenter window; ?view is one read-only slide, used for the presenter's panes and the edit view's thumbnails and layout previews. @@ -638,6 +639,7 @@

Start from template.html

// ?presenter is the window that S opens, ?view is one read-only slide in an iframe; anything else is the deck const params = new URLSearchParams(location.search); const mode = params.has('presenter') ? 'presenter' : params.has('view') ? 'view' : 'deck'; + const canEdit = mode === 'deck' && !document.querySelector('#stage[data-public]'); // a public copy has no edit view const here = location.href.split(/[?#]/)[0]; const KEY = 'deck:' + location.pathname; const EDIT_KEY = KEY + ':edit'; @@ -776,7 +778,7 @@

Start from template.html

help: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM6.2 6.2a1.9 1.9 0 1 1 2.8 1.7c-.6.3-1 .8-1 1.4M8 11.6v.1', bubble: 'M3 2.5h10A1.5 1.5 0 0 1 14.5 4v6a1.5 1.5 0 0 1-1.5 1.5H8L4.5 14v-2.5H3A1.5 1.5 0 0 1 1.5 10V4A1.5 1.5 0 0 1 3 2.5z', save: 'M8 2v8M4.5 6.5 8 10l3.5-3.5M2.5 13.5h11', down: 'M8 3v10M3.5 8.5 8 13l4.5-4.5', check: 'M3 8.5 6.5 12 13 4.5', - plus: 'M8 3v10M3 8h10', skip: 'M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8zM8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM3 2.5l10 11' + plus: 'M8 3v10M3 8h10', share: 'M8 10V2M4.5 5.5 8 2l3.5 3.5M2.5 13.5h11', skip: 'M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8zM8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM3 2.5l10 11' }; const icon = (name, size = 16) => ``; @@ -826,10 +828,11 @@

Start from template.html

case 's': case 'S': if (mode === 'deck') presenterWin = open(here + '?presenter', 'deck-presenter', 'popup,width=1280,height=800'); break; - case 'e': case 'E': if (mode === 'deck') edit(!editing); break; + case 'e': case 'E': if (canEdit) edit(!editing); break; case 'Escape': if (!editing) return false; if (!ed.menu.hidden) showLayouts(false); + else if (!ed.copyBox.hidden) showCopy(false); else if (ed.sel) select(null); else edit(false); break; @@ -906,11 +909,11 @@

Start from template.html

``; const KEYS = [['→ Space PgDn', 'Next'], ['← PgUp', 'Previous'], ['↓ ↑', 'Whole slide forward / back'], ['Home End', 'First / last slide'], ['F', 'Fullscreen'], ['P', 'Print to PDF'], - ['S', 'Presenter view'], ['E', 'Edit view'], ['Esc', 'Close']]; + ['S', 'Presenter view'], ...canEdit ? [['E', 'Edit view']] : [], ['Esc', 'Close']]; box.innerHTML = '' + button('c-back', 'Back', 'Back (←)', 'back') + button('c-present', 'Presenter view', 'Presenter view (S)', 'display') + - button('c-edit', 'Edit view', 'Edit view (E)', 'pencil') + button('c-help', 'Keyboard shortcuts', 'Keyboard shortcuts', 'help') + + (canEdit ? button('c-edit', 'Edit view', 'Edit view (E)', 'pencil') : '') + button('c-help', 'Keyboard shortcuts', 'Keyboard shortcuts', 'help') + button('c-fwd', 'Forward', 'Forward (→)', 'forward'); const help = box.firstChild, helpButton = box.querySelector('.c-help'); // the shortcuts stay up, with the buttons, until dismissed @@ -923,7 +926,7 @@

Start from template.html

box.addEventListener('mousedown', e => e.preventDefault()); helpButton.addEventListener('click', () => showHelp(help.hidden)); box.querySelector('.c-back').addEventListener('click', () => act('ArrowLeft')); - box.querySelector('.c-edit').addEventListener('click', () => { showHelp(false); act('e'); }); + box.querySelector('.c-edit')?.addEventListener('click', () => { showHelp(false); act('e'); }); box.querySelector('.c-fwd').addEventListener('click', () => act('ArrowRight')); box.querySelector('.c-present').addEventListener('click', () => { showHelp(false); act('s'); }); // a click elsewhere only dismisses them: seen first, so the slide does not advance as well @@ -1112,6 +1115,7 @@

Start from template.html

status(); } + // ---- the edit view: a public copy leaves out everything from here to the line that ends it, so nothing above may need it there ---- // edit view (E, deck window only): thumbnails left, the slide with its notes below, unsaved edits or suggestions right function edit(on) { if (!ed) buildEdit(); @@ -1119,6 +1123,7 @@

Start from template.html

settle(); select(null); showLayouts(false); + showCopy(false); } editing = on; store.set(on ? '1' : '', EDIT_KEY); @@ -1132,7 +1137,7 @@

Start from template.html

function editCss() { return ` @media screen{ - #edit,#edit-bar,#edit-rail,#edit-status,#edit-layer,#edit-layouts{display:none} + #edit,#edit-bar,#edit-rail,#edit-status,#edit-layer,#edit-layouts,#edit-copy{display:none} html.editing,html.editing body{background:#EFEFEC} html.editing #stage{left:var(--edit-x);top:var(--edit-y);box-shadow:0 0 0 calc(1px / var(--scale)) rgba(0,0,0,.16)} /* nothing moves here: outlines are measured from what is on the slide */ @@ -1173,6 +1178,14 @@

Start from template.html

box-shadow:0 0 0 1px rgba(0,0,0,.16),0 8px 24px rgba(0,0,0,.12);font:500 13px/1 system-ui,sans-serif;-webkit-font-smoothing:antialiased} #edit-layouts button{display:flex;flex-direction:column;gap:6px;padding:6px;border:0;border-radius:3px;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer} #edit-layouts button:hover{background:rgba(0,0,0,.06)} + /* what Public copy leaves out, under its button */ + html.editing #edit-copy{position:fixed;z-index:30;display:block;width:300px;box-sizing:border-box;padding:14px 16px;border-radius:4px;background:#fff;color:#111110; + box-shadow:0 0 0 1px rgba(0,0,0,.16),0 8px 24px rgba(0,0,0,.12);font:400 13px/1.45 system-ui,sans-serif;-webkit-font-smoothing:antialiased} + #edit-copy p{margin:0 0 12px} + #edit-copy button{display:inline-flex;align-items:center;gap:6px;max-width:100%;height:30px;padding:0 12px;border:0;border-radius:3px;background:#111110;color:#fff; + font:500 13px/1 system-ui,sans-serif;cursor:pointer} + #edit-copy button:hover{background:#3A3A37} + #edit-copy button span{overflow:hidden;white-space:nowrap;text-overflow:ellipsis} .e-tools,.e-ask-tools,.e-slide-tools{display:flex;align-items:center;gap:2px;margin-right:8px;padding-right:8px;border-right:1px solid rgba(0,0,0,.1)} .e-tools-label{margin:0 6px;color:#6B6B66;font:500 11px/1 system-ui,sans-serif;letter-spacing:.08em;text-transform:uppercase} .e-mode{display:flex;gap:2px;margin:0 8px;padding:2px;border-radius:4px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.16)} @@ -1268,7 +1281,7 @@

Start from template.html

.e-ask-send{background:#111110;color:#fff} #edit-ask .e-ask-send:disabled{background:#D1D1D6;cursor:default} } - @media print{#edit,#edit-bar,#edit-rail,#edit-status,#edit-layer,#edit-ask,#edit-layouts{display:none}}`; + @media print{#edit,#edit-bar,#edit-rail,#edit-status,#edit-layer,#edit-ask,#edit-layouts,#edit-copy{display:none}}`; } function buildEdit() { const css = document.createElement('style'); @@ -1291,6 +1304,7 @@

Start from template.html

'
' + labelled('e-mode-edit', 'Edit', 'pencil', 'A click on the slide selects, a double-click types') + labelled('e-mode-suggest', 'Suggest', 'bubble', 'A click on the slide suggests a change') + '
' + tool('e-do-undo', 'Undo', 'reset') + labelled('e-save', 'Save', 'save', 'Save the deck to its file') + + labelled('e-copy-out', 'Save as…', 'copy', 'A copy of the deck to hand out') + tool('e-show', 'Slide Show', 'play') + tool('e-present', 'Presenter View', 'display'); bar.firstChild.textContent = document.title; const rail = document.createElement('div'); @@ -1316,9 +1330,13 @@

Start from template.html

ask.hidden = true; ask.innerHTML = '
' + tool('e-ask-del', 'Delete suggestion', 'trash') + tool('e-ask-send', 'Save suggestion', 'up') + '
'; + const copyBox = document.createElement('div'); + copyBox.id = 'edit-copy'; + copyBox.hidden = true; + copyBox.innerHTML = '

' + labelled('e-copy-go', 'Public copy', 'share'); const layouts = deckLayouts(), menu = layoutMenu(layouts); const $ = s => panel.querySelector(s); - ed = { layer, menu, marks: layer.firstChild, draft: layer.children[1], hover: layer.lastChild, list: $('.e-list'), empty: $('.e-empty'), copy: $('.e-copy'), + ed = { layer, menu, copyBox, copyOut: bar.querySelector('.e-copy-out'), marks: layer.firstChild, draft: layer.children[1], hover: layer.lastChild, list: $('.e-list'), empty: $('.e-empty'), copy: $('.e-copy'), clear: $('.e-clear'), undoSuggestions: $('.e-undo'), rail, thumbs: [], dragged: null, where: status.firstChild, skipped: status.children[1], ask, ta: ask.querySelector('textarea'), path: ask.firstChild, send: ask.querySelector('.e-ask-send'), open: null, chain: [], level: 0, saved: [], undoTimer: null, key: 'deck:edit:' + location.pathname, items: [], outline: layer.children[2], tools: bar.querySelector('.e-tools'), modes: bar.querySelectorAll('.e-mode button'), undo: bar.querySelector('.e-do-undo'), @@ -1339,6 +1357,7 @@

Start from template.html

if (ed.open && !ask.contains(e.target) && !ed.askTools.contains(e.target) && closeAsk()) drawEdit(); if (ed.typing && !ed.typing.el.contains(e.target)) commitText(); if (!menu.contains(e.target) && !ed.add.contains(e.target)) showLayouts(false); + if (!copyBox.contains(e.target) && !ed.copyOut.contains(e.target)) showCopy(false); if (!notes.contains(e.target)) notes.blur(); }, true); addEventListener('resize', () => { if (ed.open) placeAsk(); }); @@ -1352,7 +1371,7 @@

Start from template.html

}); // the buttons never take focus, so Space and the arrows keep steering the deck, and the composer keeps what is typed in it - for (const p of [bar, rail, panel, status, menu, ed.path]) p.addEventListener('mousedown', e => { if (e.target.closest('button')) e.preventDefault(); }); + for (const p of [bar, rail, panel, status, menu, copyBox, ed.path]) p.addEventListener('mousedown', e => { if (e.target.closest('button')) e.preventDefault(); }); ed.modes.forEach((b, n) => b.addEventListener('click', () => setSuggesting(n === 1))); setSuggesting(suggesting); const clicks = { @@ -1372,6 +1391,7 @@

Start from template.html

'.e-do-drop-slide': () => deleteSlide(slides[i]), '.e-do-undo': undoChange, '.e-save': saveDeck, + '.e-copy-out': () => showCopy(copyBox.hidden), // the show starts on this slide as a show does, with its builds still to come; E leaves with the slide as it looks here '.e-show': () => { edit(false); show(i); }, '.e-present': () => act('s') @@ -1423,7 +1443,8 @@

Start from template.html

showSlide(from); }); stage.append(layer); - document.body.append(bar, rail, status, panel, ask, menu); + copyBox.lastChild.addEventListener('click', publicCopy); + document.body.append(bar, rail, status, panel, ask, menu, copyBox); } // the layouts New slide offers: those in the deck's