diff --git a/README.md b/README.md index 6afa4b7..3d58c58 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 **Save 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 @@ -197,9 +198,16 @@ it looks. it, for the question it answers; the next key goes on with the deck. - **Undo** or `Cmd/Ctrl+Z` takes back one change. × on a row in the list of unsaved edits removes just that edit. -- **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** opens a menu with two choices: + - **Save**, or `Cmd/Ctrl+S` straight away, 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 public copy…** makes a 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. The menu + says what it leaves out, then it 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 +315,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..a4a8dce 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', saveAs: 'M6.5 3v7M3.5 7l3 3 3-3M2.5 13.5h11M12.5 2v4M10.5 4h4', chevron: 'M4.5 6.5 8 10l3.5-3.5', 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,10 +1178,21 @@

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 Save can write, under its button: the deck, or a public copy and what that leaves out */ + html.editing #edit-copy{position:fixed;z-index:30;display:flex;flex-direction:column;gap:2px;width:320px;box-sizing:border-box;padding:6px;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 button{display:grid;grid-template-columns:16px 1fr;gap:10px;align-items:start;padding:8px 10px;border:0;border-radius:3px;background:none;color:inherit; + font:inherit;text-align:left;cursor:pointer} + #edit-copy button:hover{background:rgba(0,0,0,.06)} + #edit-copy svg{margin-top:1px} + #edit-copy b{display:block;font-weight:500} + #edit-copy small{display:block;margin-top:2px;color:#6B6B66;font-size:12px} + #edit-bar .e-save svg:last-child{margin-left:-2px;color:#6B6B66} .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)} #edit-bar .e-mode button{height:26px} + #edit-bar button[aria-expanded=true]{background:rgba(0,0,0,.06)} #edit-bar button[aria-pressed=true]{background:#111110;color:#fff} #edit-bar button:disabled,.e-foot button:disabled{opacity:.4;pointer-events:none} html.editing #edit-rail{display:block;top:${BAR_H}px;left:0;bottom:${STATUS_H}px;width:${RAIL_W}px;overflow:auto;padding:12px 14px 12px 6px; @@ -1268,7 +1284,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'); @@ -1290,7 +1306,8 @@

Start from template.html

tool('e-do-drop-slide', 'Delete slide', 'trash') + '
' + '
' + 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') + + tool('e-do-undo', 'Undo', 'reset') + + `` + tool('e-show', 'Slide Show', 'play') + tool('e-present', 'Presenter View', 'display'); bar.firstChild.textContent = document.title; const rail = document.createElement('div'); @@ -1316,9 +1333,15 @@

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; + const option = (cls, name, title) => ``; + copyBox.innerHTML = option('e-save-go', 'save', 'Save') + option('e-copy-go', 'saveAs', 'Save public copy…'); + copyBox.querySelector('.e-save-go small').textContent = 'Writes the deck to its file, with your changes. Cmd/Ctrl+S'; 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, 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 +1362,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.save.contains(e.target)) showCopy(false); if (!notes.contains(e.target)) notes.blur(); }, true); addEventListener('resize', () => { if (ed.open) placeAsk(); }); @@ -1352,7 +1376,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 = { @@ -1371,7 +1395,7 @@

Start from template.html

'.e-do-skip-slide': skipSlide, '.e-do-drop-slide': () => deleteSlide(slides[i]), '.e-do-undo': undoChange, - '.e-save': saveDeck, + '.e-save': () => 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 +1447,9 @@

Start from template.html

showSlide(from); }); stage.append(layer); - document.body.append(bar, rail, status, panel, ask, menu); + copyBox.querySelector('.e-save-go').addEventListener('click', () => { showCopy(false); saveDeck(); }); + copyBox.querySelector('.e-copy-go').addEventListener('click', publicCopy); + document.body.append(bar, rail, status, panel, ask, menu, copyBox); } // the layouts New slide offers: those in the deck's