@treasure-ai/treasure-deck 0.0.0-stage → 2026.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +109 -2
  3. package/dist/analytics.d.ts +34 -0
  4. package/dist/analytics.js +93 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/attrs.d.ts +10 -0
  7. package/dist/attrs.js +22 -0
  8. package/dist/attrs.js.map +1 -0
  9. package/dist/build.d.ts +67 -0
  10. package/dist/build.js +247 -0
  11. package/dist/build.js.map +1 -0
  12. package/dist/check.d.ts +30 -0
  13. package/dist/check.js +142 -0
  14. package/dist/check.js.map +1 -0
  15. package/dist/chrome.d.ts +20 -0
  16. package/dist/chrome.js +162 -0
  17. package/dist/chrome.js.map +1 -0
  18. package/dist/cli.d.ts +2 -0
  19. package/dist/cli.js +246 -0
  20. package/dist/cli.js.map +1 -0
  21. package/dist/dev.d.ts +28 -0
  22. package/dist/dev.js +557 -0
  23. package/dist/dev.js.map +1 -0
  24. package/dist/diagrams.d.ts +18 -0
  25. package/dist/diagrams.js +57 -0
  26. package/dist/diagrams.js.map +1 -0
  27. package/dist/highlight.d.ts +7 -0
  28. package/dist/highlight.js +26 -0
  29. package/dist/highlight.js.map +1 -0
  30. package/dist/hot.d.ts +31 -0
  31. package/dist/hot.js +34 -0
  32. package/dist/hot.js.map +1 -0
  33. package/dist/media.d.ts +24 -0
  34. package/dist/media.js +82 -0
  35. package/dist/media.js.map +1 -0
  36. package/dist/parse.d.ts +109 -0
  37. package/dist/parse.js +313 -0
  38. package/dist/parse.js.map +1 -0
  39. package/dist/patch.d.ts +22 -0
  40. package/dist/patch.js +53 -0
  41. package/dist/patch.js.map +1 -0
  42. package/dist/pdf.d.ts +10 -0
  43. package/dist/pdf.js +53 -0
  44. package/dist/pdf.js.map +1 -0
  45. package/dist/render.d.ts +101 -0
  46. package/dist/render.js +513 -0
  47. package/dist/render.js.map +1 -0
  48. package/dist/scaffold.d.ts +27 -0
  49. package/dist/scaffold.js +83 -0
  50. package/dist/scaffold.js.map +1 -0
  51. package/dist/themecheck.d.ts +34 -0
  52. package/dist/themecheck.js +228 -0
  53. package/dist/themecheck.js.map +1 -0
  54. package/docs/adrs/2026-10-03-chrome-over-devtools.md +29 -0
  55. package/docs/adrs/2026-10-03-fixed-canvas.md +25 -0
  56. package/docs/adrs/2026-10-03-four-layouts-plus-attributes.md +25 -0
  57. package/docs/adrs/2026-10-03-hybrid-pdf-over-devtools.md +25 -0
  58. package/docs/adrs/2026-10-03-keyword-lines-and-one-attribute-syntax.md +36 -0
  59. package/docs/adrs/2026-10-03-one-behavior-instead-of-settings.md +30 -0
  60. package/docs/adrs/2026-10-03-overflow-is-reported-not-hidden.md +27 -0
  61. package/docs/adrs/2026-10-03-single-file-html.md +26 -0
  62. package/docs/adrs/2026-10-03-strict-build-forgiving-preview.md +31 -0
  63. package/docs/adrs/2026-10-04-edit-in-place-by-alignment.md +28 -0
  64. package/docs/adrs/2026-10-04-editor-in-the-deck-page.md +31 -0
  65. package/docs/adrs/2026-10-04-edits-are-line-range-patches.md +35 -0
  66. package/docs/adrs/2026-10-04-per-slide-hot-swap.md +33 -0
  67. package/docs/adrs/2026-10-04-theme-colors-derive-in-css.md +32 -0
  68. package/docs/adrs/2026-10-05-host-owns-undo.md +26 -0
  69. package/docs/adrs/2026-10-07-anonymous-access-metrics.md +38 -0
  70. package/docs/adrs/2026-10-14-dev-links-media-by-url.md +25 -0
  71. package/docs/adrs/2026-10-14-media-dir-for-the-publish-limit.md +28 -0
  72. package/docs/adrs/2026-10-14-videos-are-inlined-images.md +28 -0
  73. package/docs/adrs/2026-10-15-public-npm-under-labs-terms.md +37 -0
  74. package/docs/adrs/README.md +34 -0
  75. package/docs/commands.md +104 -0
  76. package/docs/editor.md +114 -0
  77. package/docs/syntax.md +157 -0
  78. package/docs/themes.md +134 -0
  79. package/package.json +68 -4
  80. package/runtime/base.css +354 -0
  81. package/runtime/edit-core.cjs +877 -0
  82. package/runtime/embed.js +5259 -0
  83. package/runtime/hot.js +136 -0
  84. package/runtime/runtime.js +729 -0
  85. package/skills/treasure-deck/SKILL.md +136 -0
  86. package/templates/deck.md +78 -0
  87. package/templates/specimen/specimen.md +104 -0
  88. package/templates/theme/assets/mark.svg +1 -0
  89. package/templates/theme/theme.css +97 -0
  90. package/templates/theme/theme.yaml +7 -0
  91. package/themes/default/theme.css +183 -0
  92. package/themes/default/theme.yaml +6 -0
  93. package/themes/editorial/theme.css +168 -0
  94. package/themes/editorial/theme.yaml +7 -0
  95. package/themes/gold/assets/gem.svg +130 -0
  96. package/themes/gold/theme.css +303 -0
  97. package/themes/gold/theme.yaml +7 -0
  98. package/themes/pastel/theme.css +187 -0
  99. package/themes/pastel/theme.yaml +6 -0
  100. package/themes/treasure-ai/assets/gem-line.svg +7 -0
  101. package/themes/treasure-ai/assets/gem.png +0 -0
  102. package/themes/treasure-ai/assets/gem.svg +25 -0
  103. package/themes/treasure-ai/assets/glass.svg +12 -0
  104. package/themes/treasure-ai/assets/logo-white.png +0 -0
  105. package/themes/treasure-ai/assets/logo.png +0 -0
  106. package/themes/treasure-ai/theme.css +239 -0
  107. package/themes/treasure-ai/theme.yaml +6 -0
  108. package/themes/wvlet/assets/wvlet-icon.svg +27 -0
  109. package/themes/wvlet/theme.css +238 -0
  110. package/themes/wvlet/theme.yaml +6 -0
@@ -0,0 +1,28 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-04
4
+ ---
5
+
6
+ # Text is edited in place only where rendered text lines up with its source
7
+
8
+ ## Context
9
+
10
+ Typing into formatted text (bold words, links, typographic quotes) has to change the right characters of the Markdown. Turning the edited DOM back into Markdown can't tell `*x*` from `_x_`, and loses entities, attributes, and the author's spelling of markup.
11
+
12
+ ## Decision
13
+
14
+ - A block is typed in place when its rendered text lines up with its source: `alignRendered` in `edit-core` matches each rendered character to its source position, and everything between them must be markup (markers, a link's `](target)`, a span's `]{.x}`). A misreading fails instead of misplacing an edit.
15
+ - Typing within one text node is spliced into the source inside that run, and only the typed characters are escaped.
16
+ - While a block is edited, it shows its own Markdown (as in Obsidian), so what is typed is saved as typed.
17
+ - An edit that crosses formatting, or a block that can't be typed into (code, diagrams), opens its Markdown in place instead of guessing.
18
+
19
+ ## Consequences
20
+
21
+ - Untouched source stays byte for byte; formatting buttons work through the same alignment (selecting a bold word and pressing B takes the bold off).
22
+ - Some edits fall back to the block's Markdown, which is always correct.
23
+
24
+ ## Alternatives considered
25
+
26
+ - **Serialize the edited DOM to Markdown:** the WYSIWYG round trip again, block by block.
27
+ - **Rebase the edit's target after each save:** escaped text no longer equals its rendering, and the alignment would be recomputed against a DOM mid-edit; keeping the original target and moving `expected` gives the same text.
28
+ - **CodeMirror live preview (Markdown with markers hidden):** exact by construction, but a styled text editor rather than a formatted one, and a large dependency. The Markdown view covers the raw case.
@@ -0,0 +1,31 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-04
4
+ ---
5
+
6
+ # The whole editor lives in the deck's page
7
+
8
+ See `plans/2026-10-04-editor-layout.md`.
9
+
10
+ ## Context
11
+
12
+ The first design put the slides in an iframe beside Treasure Work's own source pane. In a narrow dock that left each slide small and the source pane mostly empty. Treasure Work's note editor (TipTap with `tiptap-markdown`) can't host the deck flavor: it would escape `{…}`, `=== col`, and slide headers, and has no hook for another Markdown flavor.
13
+
14
+ ## Decision
15
+
16
+ - The editor is part of the page `deck dev --embed` serves (`runtime/embed.js`): thumbnails, the current slide, and an editor below it with a formatted view and the file's Markdown. `deck editor` is the same page in a browser.
17
+ - The formatted view is the deck's own rendering of every slide's blocks, cloned with their `data-src`, so the same editing code works on it as on the slide. Images and diagrams are still picked and sized on the slide, where their size means something.
18
+ - The host's part is small and stable: one iframe, and a `postMessage` protocol (`{channel: 'treasure-deck', v: 1, type, …}`) for patches, slide changes, errors, undo, and presenting.
19
+ - The editor's chrome uses its own `--ed-*` palette and Lucide icons inlined into the page, so it needs no network.
20
+
21
+ ## Consequences
22
+
23
+ - Every host gets the same editor; Treasure Work needs no source pane or layout of its own.
24
+ - One page to test headlessly (`test/editor.test.ts` drives it through a host page).
25
+ - `embed.js` is large; pure logic goes to `edit-core.cjs`, which the tests load directly.
26
+
27
+ ## Alternatives considered
28
+
29
+ - **TipTap with a deck flavor:** needs a hook Treasure Work's editor lacks, still re-serializes unedited paragraphs, and adds a second Markdown parser that must agree with `render.ts`.
30
+ - **Keep side by side, shrink the source pane:** the slides stay small.
31
+ - **Build the layout in Treasure Work:** the note editor would rewrite deck syntax, and every host would rebuild the layout.
@@ -0,0 +1,35 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-04
4
+ ---
5
+
6
+ # Edits are compare-and-swap patches on line ranges
7
+
8
+ See `plans/2026-10-04-visual-editor.md` and `plans/2026-10-04-live-patches.md`.
9
+
10
+ ## Context
11
+
12
+ Treasure Work's WYSIWYG note editor turns Markdown into a document and back, which reflowed list markers, escaping, and blank lines, and broke the Marp decks. A deck file is also edited at the same time by Claude, the author's own editor, and the visual editor, so a whole-file rewrite would overwrite someone's change. The syntax writes each visual property in one place ([keyword lines and one attribute syntax](2026-10-03-keyword-lines-and-one-attribute-syntax.md)), so any visual control can be "rewrite this span".
13
+
14
+ ## Decision
15
+
16
+ - The editor's build marks every slide and block with its source lines (`data-src="talk.md:12-14"`), and the page carries the exact sources it was built from (`__DECK_SOURCES__`).
17
+ - Every edit is a patch `{file, start, end, expected, text}`: lines `start..end` become `text` only while they still read `expected` (`end = start - 1` inserts, `text: null` deletes, line endings are kept). `src/patch.ts` applies it; `runtime/edit-core.cjs` builds the structural ones as pure functions on a file's lines.
18
+ - Inside a host (Treasure Work), the host applies patches to its own editor buffer. Without one, `deck editor` applies them to disk at `POST /__patch` (127.0.0.1 only, same origin, JSON only, the deck and its parts only).
19
+ - Typing saves 500 ms after the last change, computed from the edit's start with the last saved text as `expected`; patches of one edit share a `group` id.
20
+ - A rejected patch means the file changed since: the page reloads.
21
+
22
+ ## Consequences
23
+
24
+ - The rest of the file stays byte for byte as written, and a concurrent change is never overwritten.
25
+ - Each action is one patch, so one undo step in the host. A move of a slide is one patch over the span it crosses.
26
+ - After a saved patch the bridge updates its copy of the sources and shifts later line numbers, so the next edit is correct before the rebuilt page arrives.
27
+
28
+ ## Alternatives considered
29
+
30
+ - **A generic WYSIWYG editor (Tiptap, Milkdown, Toast UI):** the round trip that broke Marp; it re-serializes the whole file.
31
+ - **Edit the slide AST and re-serialize with a formatter:** a canonical printer becomes the source of truth, and any concurrent text edit conflicts with it.
32
+ - **Port the build to the browser:** the build needs `fs`, image inlining, and headless Chrome; the local server costs nothing and serves exactly what `deck build` publishes.
33
+ - **Fetch source lines per edit:** latency, and a second view of the file that can drift from what was shown.
34
+ - **Always write to disk, even in a host:** races with the host's unsaved buffer and bypasses its undo.
35
+ - **A patch per keystroke:** floods the host's undo stack and the rebuilds.
@@ -0,0 +1,33 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-04
4
+ ---
5
+
6
+ # The preview swaps changed slides in place
7
+
8
+ See `plans/2026-10-04-hot-swap.md` and `plans/2026-10-04-vite-dev-server.md`.
9
+
10
+ ## Context
11
+
12
+ Every save used to reload the whole preview: the page flashed, diagrams rendered again, and the editor lost its place. With saves every half second while typing, that is constant churn. The runtime and the editor hold references to each slide's `<section>` element.
13
+
14
+ ## Decision
15
+
16
+ - The build keeps each slide's HTML separately. The server keeps the last few builds of each page (`main`, `present`) and answers `/__changes?page&build` with what changed since the build a page shows: a slide's new HTML, or, for a slide whose lines only moved, its new `data-src` values.
17
+ - The page patches each `<section>` in place (attributes and content, keeping the runtime's state classes) and re-runs per-slide setup: Mermaid, code fitting, `{fit}` zoom, table heads, notes.
18
+ - Anything outside the slides (theme, CSS, frontmatter settings shown outside them, runtime) and a change in the number of slides reload instead, keeping the slide, edit mode, and the caret.
19
+ - The bridge holds updates while a block is edited or a save is on its way, so a rebuild never replaces text being typed.
20
+ - `deck dev` runs Vite in middleware mode for file watching and the change channel (`deck:build` over its HMR WebSocket); the deck keeps its own build and endpoints.
21
+
22
+ ## Consequences
23
+
24
+ - Saving doesn't flash or lose place; a line shift touches only attributes.
25
+ - Hosts see a repeated `ready`, exactly as after a reload, so they needed no change.
26
+
27
+ ## Alternatives considered
28
+
29
+ - **Replace `<section>` elements:** every reference the runtime and bridge hold would point at detached nodes.
30
+ - **Diff on the client:** decks inline images, so sending every slide on each save could be megabytes.
31
+ - **Re-render slides after a line shift:** re-runs Mermaid and fitting for no visible change, and flashes diagrams.
32
+ - **morphdom-style diffing inside a slide:** fights the runtime's own mutations (Mermaid SVG, zoom, code sizes) and adds a dependency.
33
+ - **Our own file watcher and server-sent events:** replaced by Vite's watcher and HMR channel.
@@ -0,0 +1,32 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-04
4
+ ---
5
+
6
+ # Theme colors derive from a few seeds, in CSS
7
+
8
+ See `plans/2026-10-04-theme-tokens.md`.
9
+
10
+ ## Context
11
+
12
+ Themes had to set dozens of colors, twice (light and dark), and diagrams read them at build time. A new theme meant a long list of tokens; `accent:` had to recolor everything; and a slide can switch to dark mode on its own (`{mode=dark}`).
13
+
14
+ ## Decision
15
+
16
+ - A theme sets a few seed colors on `.slide`: `--deck-bg`, `--deck-fg`, `--deck-accent`, and optionally `--deck-accent-2`, `--deck-warn`, `--deck-ok`.
17
+ - `runtime/base.css` derives every other color on `.slide` with `color-mix()` and relative `oklch(from …)` colors: muted text, lines, cards, the text on the accent, highlights, chips, chart series, code, and the Mermaid palette.
18
+ - Derived tokens are declared on `.slide`, because a `var()` resolves where it is declared and the seeds change per slide. A theme that pins one sets it on `.slide` too.
19
+ - Mermaid colors are written into the SVG as `var(--deck-diagram-…, rgb(…))`, so diagrams follow the tokens live.
20
+ - `deck theme check` verifies a theme against a specimen deck: required tokens, every class styled, and WCAG AA contrast measured on rendered pixels.
21
+
22
+ ## Consequences
23
+
24
+ - A theme from `deck theme init` sets about six colors per mode; built-in themes still pin their brand palettes.
25
+ - Dark mode, per-slide modes, `accent:`, and a deck-local `theme.css` all follow without a build step; `d` switches light and dark live, diagrams included, with nothing re-rendered.
26
+
27
+ ## Alternatives considered
28
+
29
+ - **Derive at build time in TypeScript:** needs a color library and can't follow per-slide modes or `theme.css`. Chrome is the only renderer, so CSS color functions are safe ([one renderer](2026-10-03-chrome-over-devtools.md)).
30
+ - **Contrast from computed colors only:** wrong for every built-in theme, which paint gradients, grain, and frosted cards. Pixel sampling costs a screenshot per specimen slide.
31
+ - **Check themes against the user's deck:** misses classes the deck doesn't use; `deck check` covers the deck.
32
+ - **Contrast failures as warnings only:** built-in themes could quietly ship unreadable text. Primary text is an error; the quiet tiers warn.
@@ -0,0 +1,26 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-05
4
+ ---
5
+
6
+ # The host owns undo
7
+
8
+ ## Context
9
+
10
+ A deck in Treasure Work is open in the host's editor buffer, which already has an undo history; the visual editor's patches are applied to that buffer. Two undo histories over one file would disagree. Without a host (`deck editor`), there is no buffer, only the file.
11
+
12
+ ## Decision
13
+
14
+ - In a host's iframe, ⌘Z and ⇧⌘Z are passed to the host as `undo` / `redo` messages, and the editor keeps no history. Patches carry a `group` id so the host can undo one edit as one step.
15
+ - Without a host, the editor keeps the patches it saved, up to 200 steps, in `sessionStorage` (so they outlive a reload). A step is the patches one action submitted together; a pause in typing ends a step, and unsaved typing is saved first as a step of its own.
16
+ - An undo saves the inverses of a step's patches, last first; a redo saves them again. Each is a compare-and-swap patch ([line-range patches](2026-10-04-edits-are-line-range-patches.md)), so a change made since by someone else is never overwritten: that undo is refused, the history dropped, and the page reloads.
17
+
18
+ ## Consequences
19
+
20
+ - One history per file in a host, shared with typing in its own editor.
21
+ - Undo works the same in both views, with the caret going back to the change.
22
+
23
+ ## Alternatives considered
24
+
25
+ - **The editor's own history inside a host:** two histories over one buffer, each undoing the other's changes.
26
+ - **A host-side transaction protocol (begin/commit):** more protocol for what a `group` id on each patch already gives.
@@ -0,0 +1,38 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-07
4
+ ---
5
+
6
+ # Built decks report anonymous access metrics to one Treasure Data table
7
+
8
+ ## Context
9
+
10
+ Once a deck is published (an Apps Script web app, a shared file, a Google Sites embed), nobody can tell whether it was opened or how far people read. Treasure Data already ingests browser events through the TD JS SDK, so no server of our own is needed.
11
+
12
+ ## Decision
13
+
14
+ Every `deck build` output loads the TD JS SDK 4.4 from `cdn.treasuredata.com` and reports to `treasure_deck.views` on us01 with a write-only key that is part of treasure-deck. There is no setting and no opt-out.
15
+
16
+ - **Anonymous mode only.** No `td_client_id` cookie, no global ID, no server-side cookie.
17
+ - **Records:**
18
+ - an `open` row per page load
19
+ - a `slide` row per slide viewed, with `slide_title` and `dwell_ms`, sent when the viewer leaves the slide or the page is hidden (another tab, closed, a phone locked)
20
+ - an `action` row per feature used (full screen, presenter window, overview, share, print, …)
21
+
22
+ The presenter window sends nothing.
23
+ - **Grouping without identity.** `view_id` is random per page load and never stored, so one viewing's rows group together (completion, drop-off) without recognizing a returning viewer. `deck_id` is a hash of the deck file's path, so it doesn't change with the title and doesn't reveal the path. `host` (`apps_script`, `file`, or `web`) stands in for the URL, which in Apps Script is Google's sandbox URL.
24
+ - **Only `deck build` adds it**, after the diagrams are pre-rendered in headless Chrome, so neither that render nor `dev`, `editor`, `pdf`, or `check` sends events.
25
+ - **Our own loader line, always https**, because the SDK's stock loader picks `http:` on `file://` pages.
26
+
27
+ ## Consequences
28
+
29
+ - The single-file deck now loads a second resource from a CDN (after Google Fonts). If the CDN is unreachable, the deck works and sends nothing.
30
+ - The write key is public in every deck and in this repository. It can't read data, but anyone can write rows with it. Queries should filter on the event shape, and the key can be rotated in a release.
31
+ - Counts are of page loads, not people: there is no identity to deduplicate on.
32
+
33
+ ## Alternatives considered
34
+
35
+ - **Per-deck `analytics:` settings with the author's own database and key:** every author would need a TD account, and we'd get no single stream across decks.
36
+ - **An `analytics: false` opt-out:** rejected, the metrics are unconditional.
37
+ - **Inlining `td.min.js`:** adds tens of KB to every deck and freezes the SDK version. A deck that can't reach the CDN can't reach the ingestion endpoint either.
38
+ - **Signed mode or cookies:** would identify returning viewers, which is personal data the audience never agreed to share.
@@ -0,0 +1,25 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-14
4
+ ---
5
+
6
+ # `deck dev` links media by URL, not inlined
7
+
8
+ ## Context
9
+
10
+ `deck build` inlines every local image and video as a `data:` URI, so a deck is one file ([ADR](2026-10-03-single-file-html.md), [ADR](2026-10-14-videos-are-inlined-images.md)). `deck dev` used the same build, and it rebuilds on every save, builds again for `/present` and for each theme preview, and swaps changed slides into open pages with their HTML. With a 200 MB video (the editor accepts uploads that large), each save read and base64-encoded about 270 MB, and the editor page was as large.
11
+
12
+ ## Decision
13
+
14
+ - The renderer takes a `mediaUrl` option: when set, a local image or video is checked as before (it exists, and its type is known) but linked by that URL instead of inlined. `deck build`, `deck pdf`, and `deck check` don't set it.
15
+ - `deck dev` links each file as `/__file?p=<path from the deck folder>&v=<mtime>` and serves it there, with its type and byte ranges. The server answers only for files the latest builds linked; `v=` makes a file replaced under the same name load again, and lets the browser keep files that haven't changed.
16
+
17
+ ## Consequences
18
+
19
+ - A rebuild only stats media files, and pages and slide swaps stay small however large the videos are. Videos seek natively, without the runtime's Blob URL step.
20
+ - What `deck dev` shows is no longer byte-for-byte the built page: a problem only an inlined file would show (a huge page, a slow `data:` URI) is seen in `deck build` output, not in the preview.
21
+
22
+ ## Alternatives considered
23
+
24
+ - **A cache of `data:` URIs keyed by path and mtime:** saves the reads and the encoding, but each rebuild still joins hundreds of MB into the page and each swapped slide resends its videos.
25
+ - **Vite's static serving (its root is the deck folder):** serves any file under the folder whether the deck uses it or not, and files outside it (`../shared/x.png`) only through `/@fs/`.
@@ -0,0 +1,28 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-14
4
+ ---
5
+
6
+ # Pages past Apps Script's limit warn, and videos can leave the page
7
+
8
+ ## Context
9
+
10
+ A deck builds to one page with its images and videos inlined ([ADR](2026-10-14-videos-are-inlined-images.md)), and Treasure Work publishes that page as an Apps Script web app, as the single `index` file of a project. Apps Script's limit wasn't documented, and Treasure Work's notes disagreed (about 10 MB per file, or 50 MB per project). Measured on 2026-10-14 through Treasure Work's publish flow: pages of 5, 7.5, and 9 MiB published; 10, 25, and 45 MiB failed with "The project is too large to save". A minute of screen recording is 10 to 40 MB before base64, so one clip can make a deck unpublishable, while `deck build` only warned past 20 MB per video or 50 MB in total.
11
+
12
+ ## Decision
13
+
14
+ - `deck build` warns when the page is over 9 MiB, the largest size measured to publish, naming the three largest inlined files (at their base64 size) and pointing to `--media-dir` when a video is among them. The per-video warning (20 MB, slow to open) stays; the 50 MB total goes, as the page warning covers it.
15
+ - `deck build --media-dir <dir>` copies each local video into `<dir>`, named `<name>-<hash>.<ext>` by its contents, and links it by a relative path. Images stay inlined.
16
+ - The runtime asks `window.__DECK_MEDIA__(path)`, when a host page defines it, for the URL of each video linked by a relative path (decoded), once per path, the first time its slide is shown; a presenter window the runtime writes itself asks its opener's hook. It is the step that already turns an inlined video into a Blob URL.
17
+
18
+ ## Consequences
19
+
20
+ - A deck with a long clip can still be built and hosted: as a page plus a folder, or by a host that keeps the videos elsewhere. Treasure Work can publish one by uploading the folder to Drive and serving each file through `google.script.run` behind `__DECK_MEDIA__` (its own change).
21
+ - `deck pdf` and `deck check` still inline everything: they render one page in a temporary file.
22
+ - The 9 MiB threshold is a measurement, not a documented limit; if Apps Script changes, the constant in `src/media.ts` moves with it.
23
+
24
+ ## Alternatives considered
25
+
26
+ - **Link videos to Drive by URL:** Drive doesn't serve video reliably to `<video>` (no ranges for large files, a virus-scan page past 100 MB, sign-in cookies a sandboxed iframe may not send).
27
+ - **Transcode videos smaller in the build:** needs ffmpeg or Chrome's encoder on every machine that builds, and it chooses the quality for the author.
28
+ - **Move images out too:** they rarely push a page past the limit, and inlined they keep PDF, `deck check`, and offline sharing simple.
@@ -0,0 +1,28 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-14
4
+ ---
5
+
6
+ # Videos take image syntax and are inlined like images
7
+
8
+ ## Context
9
+
10
+ Demo clips and screen recordings are often the clearest slide in a talk. A deck builds to one self-contained HTML file ([ADR](2026-10-03-single-file-html.md)), and every image path (Markdown, the editor's controls, PDF) already finds media by `![alt](path){…}`. Videos are far larger than images: a one-minute screen recording is 10 to 40 MB, plus a third for base64.
11
+
12
+ ## Decision
13
+
14
+ - A video is written `![alt](clip.mp4){…}`, told apart by extension (`.mp4`, `.webm`, `.mov`, `.m4v`). It takes the image attributes plus `autoplay`, `loop`, and `nocontrols`; those flags fail on an image, and a video fails as `{bg}` or `{side}`.
15
+ - `deck build` inlines a local video as a `data:` URI, so the deck stays one file, and warns past 20 MB per video or 50 MB in total.
16
+ - The runtime plays a video from a Blob URL made when its slide is first shown (one per video), since seeking within a large `data:` URI is slow and some browsers won't play one.
17
+ - The runtime, not the browser, decides when a video plays: `{autoplay}` plays muted when its slide is shown (in the editor too) and pauses when it is left; the presenter window mutes its copies, and the overview and print never play.
18
+
19
+ ## Consequences
20
+
21
+ - The editor's pick, resize, move, align, delete, and Markdown controls work on videos with no new patch logic; videos add only Autoplay, Loop, and Controls toggles.
22
+ - A deck with videos is as large as its videos. HtmlService's size limit is still unmeasured, so very large decks may not publish to Apps Script.
23
+ - `deck pdf` prints each video's first frame, stopped and without its play bar.
24
+
25
+ ## Alternatives considered
26
+
27
+ - **A new syntax (a `::video` block, or `<video>` HTML):** its own finder and patcher in the editor and its own attribute rules, and HTML breaks "no markup".
28
+ - **Videos as files next to the HTML:** smaller pages and native seeking, but not one file, which breaks Apps Script publishing and sharing a single file. It can come later as a build option or as Drive-hosted media.
@@ -0,0 +1,37 @@
1
+ ---
2
+ status: accepted
3
+ date: 2026-10-15
4
+ ---
5
+
6
+ # Released to public npm as a Treasure AI Labs offering, not as open source
7
+
8
+ ## Context
9
+
10
+ The source repository, `treasure-data/treasure-deck`, is internal on GitHub. Most people who would write decks have no seat in the GitHub org: sales, marketing, support, and managers. So they couldn't install treasure-deck, read its docs, or report problems. Open-sourcing the repository would solve all three, but we don't usually take outside contributions, so it isn't the plan for now. It isn't ruled out either. `@treasuredata/tdx` already ships the same way: an internal repo published to public npm through trusted publishing on `v*` tags.
11
+
12
+ ## Decision
13
+
14
+ - **Package:** `@treasure-ai/treasure-deck` on public npm. The CLI is still `deck`; unscoped `deck` is someone else's package. `.github/workflows/release.yml` releases it through npm trusted publishing (OIDC), with no npm token in the repository:
15
+ - **Versions** are CalVer, as in tdx, and come from the tag. `package.json` stays `0.0.0-dev`.
16
+ - **A `v*` tag** publishes the tarball that `scripts/smoke-pack.sh` installed and built a deck with. It goes out under npm's `next` tag, with a GitHub prerelease.
17
+ - **Running the workflow by hand** promotes a version to `latest` (stable).
18
+ - **`pnpm release`** pushes the next tag, and **`pnpm promote`** starts the promotion, as tdx's commands do.
19
+
20
+ Unlike tdx, there is no `release` branch or PR for promotion, since treasure-deck releases don't need an approval gate. Both steps are in one workflow file because npm trusts one workflow per package.
21
+ - **License:** `LICENSE.md` puts the package under the [Treasure AI Labs Terms of Use](https://www.treasure.ai/terms/labs-terms-of-use), with `"license": "SEE LICENSE IN LICENSE.md"`. It is not an open-source license.
22
+ - **Docs:** the user guides and these records ship in the package, without `docs/design.md`. The README links them through unpkg, which anyone can read without an account. `homepage` is the npm page, and `bugs` is `treasure-data/treasure-ai-labs`, the public issue-only repo for Labs products.
23
+ - **Access metrics:** unchanged ([ADR](2026-10-07-anonymous-access-metrics.md)). The README says what a built deck sends, and the Labs terms cover it as usage data.
24
+
25
+ ## Consequences
26
+
27
+ - Anyone with npm can install it, including people outside the company. Their built decks report to the same table, under the Labs terms.
28
+ - npm attaches no provenance, because the repository isn't public.
29
+ - The first publish is by hand. npm can only register a trusted publisher on a package that already exists.
30
+ - Open-sourcing later means replacing `LICENSE.md` and one line in `package.json`. An `analytics: false` opt-out is the first change to reconsider then.
31
+
32
+ ## Alternatives considered
33
+
34
+ - **Open-source now:** it commits us to triaging outside issues and PRs, and to taking a public position on the access metrics, before there's a reason to.
35
+ - **A private registry (GitHub Packages, Artifactory):** GitHub Packages needs the same org access these users lack. Any other private registry asks every user to set up auth before installing a slide tool.
36
+ - **Ship it only inside Treasure Work:** that would tie deck releases to app releases and leave out people who write decks elsewhere. Treasure Work can depend on the npm package instead.
37
+ - **No license, like tdx:** that leaves users guessing what they may do. The Labs terms already say it.
@@ -0,0 +1,34 @@
1
+ # Architecture decision records
2
+
3
+ Each record states one decision that shapes treasure-deck's internals: the context it was made in, the decision, what follows from it, and the alternatives that were turned down. They are short on purpose; the details of how each is built are in `docs/design.md` and the implementation plans in `plans/`, in the source repository.
4
+
5
+ A record is named `YYYY-MM-DD-<decision>.md`, after the day the decision landed. When a decision changes, add a new record that supersedes the old one and mark the old one `status: superseded by <file>`, rather than rewriting history.
6
+
7
+ ## Authoring
8
+
9
+ - [2026-10-03 Slides are divided by keyword lines, styled by one `{…}` syntax](2026-10-03-keyword-lines-and-one-attribute-syntax.md)
10
+ - [2026-10-03 Four layouts, and attributes for everything else](2026-10-03-four-layouts-plus-attributes.md)
11
+ - [2026-10-03 One built-in behavior instead of settings](2026-10-03-one-behavior-instead-of-settings.md)
12
+ - [2026-10-03 Overflow is reported, not hidden](2026-10-03-overflow-is-reported-not-hidden.md)
13
+
14
+ ## Build and output
15
+
16
+ - [2026-10-03 A deck builds to one self-contained HTML file](2026-10-03-single-file-html.md)
17
+ - [2026-10-03 A fixed 1280×720 canvas](2026-10-03-fixed-canvas.md)
18
+ - [2026-10-03 Strict build, forgiving preview](2026-10-03-strict-build-forgiving-preview.md)
19
+ - [2026-10-03 Headless Chrome is the one renderer, driven over the DevTools protocol](2026-10-03-chrome-over-devtools.md)
20
+ - [2026-10-03 Hybrid PDF: backgrounds as images, content as vectors](2026-10-03-hybrid-pdf-over-devtools.md)
21
+ - [2026-10-04 Theme colors derive from a few seeds, in CSS](2026-10-04-theme-colors-derive-in-css.md)
22
+ - [2026-10-14 Videos take image syntax and are inlined like images](2026-10-14-videos-are-inlined-images.md)
23
+ - [2026-10-14 Pages past Apps Script's limit warn, and videos can leave the page](2026-10-14-media-dir-for-the-publish-limit.md)
24
+ - [2026-10-14 `deck dev` links media by URL, not inlined](2026-10-14-dev-links-media-by-url.md)
25
+ - [2026-10-15 Released to public npm as a Treasure AI Labs offering, not as open source](2026-10-15-public-npm-under-labs-terms.md)
26
+
27
+ ## Editing
28
+
29
+ - [2026-10-04 Edits are compare-and-swap patches on line ranges](2026-10-04-edits-are-line-range-patches.md)
30
+ - [2026-10-04 Text is edited in place only where rendered text lines up with its source](2026-10-04-edit-in-place-by-alignment.md)
31
+ - [2026-10-04 The whole editor lives in the deck's page](2026-10-04-editor-in-the-deck-page.md)
32
+ - [2026-10-04 The preview swaps changed slides in place](2026-10-04-per-slide-hot-swap.md)
33
+ - [2026-10-05 The host owns undo](2026-10-05-host-owns-undo.md)
34
+ - [2026-10-07 Built decks report anonymous access metrics](2026-10-07-anonymous-access-metrics.md)
@@ -0,0 +1,104 @@
1
+ # Commands
2
+
3
+ `deck --help` lists them all. Install with `npm install -g @treasure-ai/treasure-deck`, or run it without installing as `npx @treasure-ai/treasure-deck …`; in a checkout of the repository, `pnpm deck …`. `deck --version` prints the installed version. `--theme` takes a built-in name or a theme folder (`./my-theme`) on every command that builds.
4
+
5
+ ## Starting a deck: `deck new`, `deck skill install`
6
+
7
+ ```sh
8
+ deck new talks/q3-review --theme treasure-ai # talks/q3-review/q3-review.md + images/
9
+ deck new talk.md --title "Q3 review" --author "…"
10
+ deck skill install # teach Claude Code the syntax and house style
11
+ ```
12
+
13
+ `deck new` writes a starter deck that already builds: title, a lead slide, sections, columns with a card, code, and a table, with the date and your git user name filled in. `deck skill install [dir]` copies the bundled `treasure-deck` skill to `~/.claude/skills` (or the folder you name). With it, Claude writes decks from outlines and notes in the house style, and runs `deck check` before calling a deck done.
14
+
15
+ ## Live preview: `deck dev`
16
+
17
+ ```sh
18
+ deck dev talk.md # http://localhost:4300
19
+ deck dev talk.md --theme wvlet --port 4302 # another theme, side by side
20
+ ```
21
+
22
+ Without `--port`, the server takes 4300, or the next free port when 4300 is in use (another `deck dev`, say), and prints the URL it serves. A port given with `--port` is used or the command fails. Open the URL and edit the Markdown in any editor. Saving updates only the slides that changed, in place, so the page doesn't flash and stays where it was. A change outside the slides reloads the page on the slide you were viewing, with the table of contents still open if it was: the theme, a `theme.css` next to the deck, the frontmatter's settings, the runtime, or adding, removing, or hiding slides. The server runs [Vite](https://vite.dev) for file watching and live updates; Ctrl-C (or SIGTERM) stops both. Unlike `deck build`, it links the deck's images and videos by URL rather than inlining them, so saving stays quick and the page small however large the videos are.
23
+
24
+ A slide that can't be built (a typo in its header, a missing image, an unclosed code fence) shows its error and its source in its place, and the rest of the deck stays as it is; fixing it swaps the slide back. An error outside the slides, such as in the frontmatter, shows in a bar over the slides you had, until the next good save. `deck build`, `deck pdf`, and `deck check` still fail on the first error. Diagrams render from the bundled Mermaid, so the preview works offline.
25
+
26
+ Everything in [Presenting](#presenting) works here, so this is also the way to present a deck you are still changing. To edit on the slides instead, use [`deck editor`](editor.md), the same server with the editor.
27
+
28
+ ## Checking a deck: `deck check`
29
+
30
+ `deck check talk.md` renders every slide in headless Chrome at 1280×720 and reports what the Markdown can't show you, with the source line of each slide:
31
+
32
+ ```text
33
+ talk.md:42: error: slide 7 "Why it matters": content runs 49px past the bottom edge, from li "Reviews focus on intent"
34
+ talk.md:57: error: slide 9 "The query": code is cut off at the right even at 12px (shorten its longest line)
35
+ talk.md:80: warning: slide 12 "Setup": code shrank to 13px to fit (shorten its longest line, or give it more width)
36
+ ```
37
+
38
+ It flags content past any edge of the slide body (into the footer, for example), text wider than its column (a long URL), code panels that are still clipped after the runtime shrinks them, and broken Mermaid diagrams. Warnings cover code shrunk below 14px, diagram labels scaled below 13px (a wide diagram in a narrow column), fitted slides below 16px text, and slides with a title and nothing else. It exits 1 on errors, so it fits in CI.
39
+
40
+ - `--toc` also checks every slide with the table of contents column shown. (The column no longer changes a slide's layout, so this finds the same problems; it is kept for scripts that pass it.)
41
+ - `--snapshots dir` writes one PNG per slide (`dir/slide-NN.png`), to look at what a clean check can't tell you: a mostly empty slide, uneven cards, a diagram that reads poorly.
42
+
43
+ Run it before sharing; it is also the loop Claude uses before calling a deck done.
44
+
45
+ ## Sharing: `deck build`, `deck pdf`
46
+
47
+ ```sh
48
+ deck build talk.md # → talk.html (-o to name it)
49
+ deck pdf talk.md # → talk.pdf (-o to name it); needs Chrome, CHROME_PATH overrides
50
+ deck pdf talk.md --vector # every layer as vectors
51
+ ```
52
+
53
+ `deck build` writes one self-contained HTML file: CSS, the runtime, images, videos, and pre-rendered diagrams inlined. Fonts load from Google Fonts. It warns when the page is over about 9 MB, which Apps Script won't publish, and names the files that weigh most.
54
+
55
+ ```sh
56
+ deck build talk.md --media-dir talk-media # videos as files in talk-media/, linked from the page
57
+ ```
58
+
59
+ With `--media-dir`, local videos are copied into that folder (relative to the current directory), named with a hash of their contents (an older copy of a clip that changed is removed), and linked by a relative path, so the page and the folder go together: a static host, a shared folder, or opened from disk. A page that defines `window.__DECK_MEDIA__(path)` before the deck's script supplies each linked video's URL itself (a string or a promise of one), given its path relative to the page, the first time its slide is shown, in the presenter window too; Treasure Work's publishing can use it to keep videos out of Apps Script.
60
+
61
+ A built deck reports anonymous access metrics to Treasure Data. It loads the TD JS SDK from Treasure Data's CDN in anonymous mode, which sets no cookie and assigns no client or global ID, and records rows in `treasure_deck.views` on us01:
62
+
63
+ - **`open`:** once per page load, with the page count.
64
+ - **`slide`:** a slide viewed (`slide`, `slide_title`) and how long it was on screen (`dwell_ms`). It's sent when the viewer moves on or the page is hidden (another tab, closed, a phone locked). Slides passed in the overview don't count.
65
+ - **`action`:** a feature used, and on which slide. The actions are `fullscreen`, `presenter`, `overview`, `notes`, `toc`, `share`, `copy_link`, `copy_slide`, `copy_embed`, `print`, `mode`, `laser`, and `help`.
66
+
67
+ Every row also carries:
68
+
69
+ - **The deck:** its title, a `deck_id`, the treasure-deck version, the theme, and the build date. The `deck_id` is a hash of the deck file's path, so it doesn't change with the title and doesn't reveal the path.
70
+ - **The viewing:** `host` (`apps_script`, `file`, or `web`) and a `view_id`. The `view_id` is a random ID made for each page load and never stored, which groups one viewing's rows.
71
+
72
+ The SDK adds the page URL, referrer, screen size, and user agent. The presenter window sends nothing, so a talk counts once. `deck dev`, `deck editor`, `deck pdf`, and `deck check` never add the SDK, and a deck that can't reach the CDN works as before. These are usage data under the [Treasure AI Labs Terms of Use](https://www.treasure.ai/terms/labs-terms-of-use). See [ADR: anonymous access metrics in built decks](adrs/2026-10-07-anonymous-access-metrics.md).
73
+
74
+ `deck pdf` prints the deck with headless Chrome: it waits until fonts and diagrams have rendered, then prints one 1280×720 page per slide. Each slide's background layer (gradients, glass, grain, ornaments) is captured as a 2× image, and text, tables, code, images, and diagrams print as vectors on top, so the PDF looks like the HTML in every viewer (including macOS Preview) while text stays sharp and selectable. `--vector` skips the capture. Printing from the browser (share panel → Print, or ⌘P) keeps backgrounds too, but large translucent gradients may band in some PDF viewers; `deck pdf` is the faithful path. See [ADR: hybrid PDF over the DevTools protocol](adrs/2026-10-03-hybrid-pdf-over-devtools.md).
75
+
76
+ ## Themes: `deck themes`, `deck theme init`, `deck theme check`
77
+
78
+ See [Themes](themes.md).
79
+
80
+ ## Presenting
81
+
82
+ The built page, `deck dev`, and the editor's `/present` all present the same way.
83
+
84
+ | Key | Action |
85
+ |---|---|
86
+ | `→` `Space` `PgDn` / `←` `PgUp` | Next / previous slide |
87
+ | `Home` / `End`, digits + `Enter` | First / last slide, go to slide n |
88
+ | `f` | Full screen |
89
+ | `o` / `Esc` | Overview grid (click to jump) |
90
+ | `t` | Table of contents column |
91
+ | `p` | Notes panel: notes, elapsed time and clock, next slide's title |
92
+ | `P` | Presenter window |
93
+ | `k` / `r` | Pause or resume / reset the timer (presenter window, or with the notes shown) |
94
+ | `b` / `.` | Black screen |
95
+ | `d` | Light / dark (slides with their own `{mode=…}` keep it) |
96
+ | `l` | Laser pointer |
97
+ | `s` | Share panel |
98
+ | `?` | Shortcut help |
99
+
100
+ Touch: swipe to navigate, pinch out for the overview. On portrait phones the deck becomes a vertical scroll of slides. `#/12` links to slide 12; under Apps Script this goes through `google.script.history`.
101
+
102
+ **Presenter window:** `P` (or the share panel) opens the deck in a second window for your screen: the current slide, the next one, the speaker notes, the elapsed time (`k` or Pause stops it and Resume goes on; `r` or Reset restarts it), and the clock. Put the first window on the projector. The windows follow each other: navigating, `b` (black screen), `d` (light/dark), and `t` in either one updates both.
103
+
104
+ **Share panel (`s`):** copy the deck link or a link to the current slide, show a QR code full screen (for the audience to follow on their phones), print or save as PDF, and copy an `<iframe>` embed snippet for Google Sites.
package/docs/editor.md ADDED
@@ -0,0 +1,114 @@
1
+ # Editor (`deck editor`)
2
+
3
+ ```sh
4
+ pnpm deck editor talk.md # opens http://127.0.0.1:4300 (this machine only)
5
+ pnpm deck editor talk.md --no-open --port 4301 # serve it without opening a browser
6
+ ```
7
+
8
+ `deck editor` opens the deck for editing in your browser. Like `deck dev`, it takes port 4300 or the next free one unless `--port` names one. Treasure Work shows the same page in its right dock (it starts it as `deck dev --embed`, the same server without opening a browser). It listens on 127.0.0.1 only. `examples/playground/playground.md` is a deck for trying it; copy it somewhere first, since edits save to the file.
9
+
10
+ Edits save on their own as you type, after a short pause, and each one changes only the lines it touched: the rest of the file stays exactly as written, and a change made elsewhere meanwhile (Claude, another editor) is never overwritten. See [ADR: edits are line-range patches](adrs/2026-10-04-edits-are-line-range-patches.md).
11
+
12
+ The page, top to bottom:
13
+
14
+ ## Thumbnails
15
+
16
+ Every slide in a strip; click one to go to it, and scroll it with the mouse wheel or a sideways swipe. The numbers are the slides' numbers as presented. Hidden slides are there too, dimmed, with **Unhide** (on a hidden slide, the toolbar's Hide button unhides it too, and for a slide hidden by its section, the whole section).
17
+
18
+ In edit mode:
19
+
20
+ - **Drag** a thumbnail to move its slide; a slot shows where it will land.
21
+ - **Right-click** one for Cut, Copy, Paste before or after, Duplicate, Hide or Unhide, and Delete. On a focused thumbnail, ⌘X, ⌘C, and ⌘V do the same; a cut slide is outlined dashed until it is pasted or Escape is pressed.
22
+ - Slides move and paste within their own file (for a deck with `parts:`).
23
+
24
+ **Deck settings** (the first tile) opens the deck's settings as a form: the theme, picked from cards that show the current slide in each theme, light or dark, the accent color, title, author, date, footer, section slides, and the table of contents. Each change rewrites one line of the frontmatter (comments and other keys stay as written), and **Edit as Markdown** opens the frontmatter itself.
25
+
26
+ ## The slide
27
+
28
+ The current slide, as large as the space allows. ←/→, PageUp/PageDown, or the mouse wheel over it move between slides; in a host app, the slide follows the source's cursor. Click a block to edit it in the editor below.
29
+
30
+ ### Images
31
+
32
+ Click an image on the slide to pick it. The toolbar's second row then shows:
33
+
34
+ | Control | Does |
35
+ |---|---|
36
+ | Left, Center, Right | Alignment in the flow (one at a time) |
37
+ | Shadow, Round, Border | Decorations |
38
+ | Markdown | Opens the image's Markdown |
39
+ | In flow | Shown for a pinned image: puts it back in the flow (removes `at=`) |
40
+ | The size and position as written | `w=300`, `at=top-right`, updated while dragging |
41
+
42
+ - **Resize:** drag the corner handle. The width snaps to 25, 33, 50, 66, 75, or 100% of the column, with a guide, and is otherwise written in canvas px rounded to 10. An image sized by `h=` alone resizes by `h=`, in 50px steps. For an image too big for its slide, the handle sits at the corner of the part that shows.
43
+ - **Move:** drag the picked image itself. It is pinned where you drop it, as `at=x%,y%` of the slide body, or as an anchor (`at=top-right`) when it lands on one of the nine (each axis snaps to an edge or the middle, and a guide names the anchor). A `fit` or `cover` image keeps the size it shows, written as `w=` (and `h=` for `cover`). A click that wobbles a few pixels is still a click.
44
+ - **Delete:** Backspace or Delete on a picked image takes it out.
45
+ - **Paste:** an image on the clipboard (a screenshot, a copied image) pastes in either view. It is saved as `images/pasted-<date>-<time>.png` next to the deck and written into the Markdown: at the cursor in the Markdown view, or as a paragraph after the block you are editing (or at the end of the slide) in the formatted view.
46
+ - **Drop:** image and video files dragged in from your file manager are saved the same way (a video as `media/pasted-<date>-<time>.mp4`) and written after the block they land on, on the slide or in the formatted view, where they land in the Markdown view, or at the end of the slide. Several files dropped together go in one paragraph, as a row.
47
+ - **Videos** are picked, sized, moved, aligned, and decorated like images. Their toolbar adds **Autoplay**, **Loop**, and **Controls**.
48
+
49
+ A Mermaid diagram is picked and resized the same way, written as `{w=…}` on its ` ```mermaid ` line (or `{h=…}`, for one sized by height).
50
+
51
+ ## The editor
52
+
53
+ Below the slide, in edit mode (in a host app, the app turns it on; on its own it starts on, and `e` toggles it). Drag its top edge to resize it.
54
+
55
+ ### Toolbar
56
+
57
+ - **New slide** (at its left) adds a slide after the current one.
58
+ - For the current slide: move up and down, hide, delete (a second click confirms), and its **layout**, picked from pictures of each layout and column widths. A layout with more columns than the slide has adds empty ones to type in (in a slide with rows, to its first row); columns are never taken away. **Add a row below** adds a full-width row, or one of two or three empty columns.
59
+ - The slide's style: **Dark slide** (or Light slide in a dark deck), **Fit to slide** (content and columns slides), and **No number** (section slides).
60
+ - **Preview** opens the deck as presented (`/present`) on the current slide: in a host app, where the app opens it, else in a new window. Its ▾ menu also opens it in your default browser or copies its link.
61
+ - **Undo** and **Redo**, and the switch between the two views below.
62
+ - A second row shows the controls for what is selected: the text row while typing, or an image's or diagram's controls.
63
+
64
+ ### Formatted view
65
+
66
+ Every slide's content as one document, a numbered rule before each, with classes shown as chips, columns and rows as dividers, and speaker notes after each slide. Scrolling it shows the slide you are reading.
67
+
68
+ Click text to type into it. There is no edit box: you type where the text is. The block you are in shows its own Markdown (`**bold**`, `[link](url)`), what you type is saved as typed, and it shows formatted again when you leave it, as in Obsidian. Selecting text with the mouse edits that block too, with the selection kept. An edit that would cut through formatting, or a block that can't be typed into (code, diagrams), opens its Markdown in place.
69
+
70
+ **The text row** (also while typing a new block) has bold, italic, code, strikethrough, highlight, and link, headings, lists, quotes, and a **Style** menu for classes such as `.lead` or `.center`. A mark button is lit when the selection is in that mark, and pressing it takes the mark off.
71
+
72
+ **Markdown shortcuts**, typed at the start of a paragraph, as in other block editors:
73
+
74
+ | Type | Becomes |
75
+ |---|---|
76
+ | `# ` … `### ` | A heading |
77
+ | `- ` (or `* `, `+ `), `1. ` | A list; so does Enter on a paragraph of just `-` or `1.` |
78
+ | `> ` | A quote |
79
+ | `---` (then Enter, on a new paragraph) | A new slide, starting there; the rest of the paragraph opens it |
80
+
81
+ **Keys:**
82
+
83
+ | Key | Does |
84
+ |---|---|
85
+ | Enter | At the end of a block: a new paragraph after it, or the next list item. Inside a block: splits it at the cursor. At the start of a list item: an empty item above it. On an empty new item: moves it out a level, and at the top level out of the list. On an empty line: adds a blank line (kept in the file, a small gap on the slide). |
86
+ | Shift+Enter | A line break in a paragraph or list item (in a quote, Enter does this) |
87
+ | Tab / Shift+Tab | Nest a list item / move it out (Shift+Tab on a top-level item turns it into a paragraph) |
88
+ | Backspace | At a block's start: joins it to the block before (at the start of a slide's first block, joins the slide to the one before). In an empty block or line: removes it. |
89
+ | Delete | At a block's end: joins the block after it |
90
+ | ↑ ↓ ← → | Go on past a block's edge into the next one, stopping on every block as in a text editor: a wrapped paragraph is typed in place as its lines, code and diagrams open their Markdown in place, an image is picked (then Enter opens its Markdown, Backspace takes it out), and each slide break shows the slide's header (`---`, `--- columns 3:2`) to edit there |
91
+ | Shift+↑ ↓, or a drag | Select across blocks; Backspace or Delete takes the selection out |
92
+ | PageUp / PageDown | Move the cursor a view up or down (they never turn slides while typing) |
93
+ | ⌘B, ⌘I | Bold, italic |
94
+ | Escape | Undoes the edit in progress |
95
+
96
+ A click on the blank space below a slide's last block starts a new paragraph there. A slide's numbered rule, once clicked, joins the slide to the one before on Backspace.
97
+
98
+ **Right-click** on a block opens a menu: **Edit Markdown** (its Markdown in place), then Cut, Copy, Paste, and the slide's layouts, which a right-click on the slide also offers. A double-click selects a word. Cut and copy keep the formatting: the clipboard gets the Markdown, so part of a bold word copies as `**bold**` and pastes bold, a cut through a mark closes it again rather than leaving its markers behind, and a selection across blocks copies as their Markdown.
99
+
100
+ When a change reloads the page (adding, joining, or removing slides), the cursor comes back where it was.
101
+
102
+ ### Markdown view
103
+
104
+ The whole file holding the current slide (a part, for `parts:`), editable, with the current slide's lines marked. Scrolling it, or moving the cursor into another slide's lines, shows that slide; while you type in it, it stays where it is. A change made elsewhere comes in while nothing typed is unsaved. Switching between the two views keeps your place: what was at the top of the view stays there, and the cursor goes along to the same line and column (into the same block, in the formatted view).
105
+
106
+ ## Undo
107
+
108
+ ⌘Z (Ctrl+Z) undoes a pause in typing or an action at a time, and ⇧⌘Z (Ctrl+Y) redoes, in either view, with the cursor going back to the change; the toolbar has Undo and Redo too. Inside Treasure Work, the keys go to its editor, which keeps the file's undo history. On its own, `deck editor` keeps up to 200 steps, and they survive a reload. An undo never overwrites a change made since by someone else: it is refused and the page reloads. See [ADR: the host owns undo](adrs/2026-10-05-host-owns-undo.md).
109
+
110
+ ## Presenting from the editor
111
+
112
+ `/present` on the same server (for example `http://127.0.0.1:4300/present#/9`) is the deck to present, with no editor, updating on every save. A host app opens it in its own window, so you can present while you or Claude keep editing. The editor follows the slides you present, and `e` in the presenting window goes back to editing: it closes the window (or, opened on its own, switches the tab to the editor) on the same slide. The keys for presenting are in [Commands](commands.md#presenting).
113
+
114
+ The host-app protocol is in `docs/design.md` (Treasure Work integration) in the source repository.