Skip to content

feat: edit mode — in-browser editing with save-back to file (?edit) - #27

Open
Ynchnnnn wants to merge 1 commit into
lewislulu:mainfrom
Ynchnnnn:feat/edit-mode
Open

feat: edit mode — in-browser editing with save-back to file (?edit)#27
Ynchnnnn wants to merge 1 commit into
lewislulu:mainfrom
Ynchnnnn:feat/edit-mode

Conversation

@Ynchnnnn

@Ynchnnnn Ynchnnnn commented Jul 9, 2026

Copy link
Copy Markdown

What

A new self-contained assets/edit-mode.js (~800 lines, zero dependencies) that lets you edit any deck in the browser and save straight back to the html file — no build step, no local server, works on plain file:// double-click.

<!-- last script tag in <body>, after runtime.js -->
<script src="../../assets/edit-mode.js"></script>

Open the deck with ?edit appended. Without ?edit the script is completely inert — playback, keyboard nav, presenter mode and overview are untouched.

Features

  • Text — double-click any text element to edit in place (paste forced to plain text; arrow keys stay out of deck navigation while typing)
  • ✨ Animations — pick an element, choose one of the 26 data-anim entry animations; hovering a panel item live-previews it
  • 🎇 Canvas FX — pick one of the 20 data-fx effects for the current slide
  • 🧩 Components — click a card / list item / pill to hide/show it, duplicate it (placeholder text), or delete it (two-click confirm); the nearest repeating ancestor (same tag+class sibling) is auto-selected, with a parent-widening button
  • 💾 Save — File System Access API writes the file directly (Chrome, works on file://: pick this html file once, later saves are silent). Falls back to a download when FSA is unavailable or the user cancels the picker.

How clean output is guaranteed

The script runs synchronously at the end of <body> and snapshots the pristine DOM into a detached copy before runtime.js's DOMContentLoaded work injects chrome (progress bar, overview slide clones, is-active classes, counter rewrites). Every committed edit is mirrored onto that clean copy and saving serializes it — runtime state never reaches the file, and a second save is always a zero diff. (The first save normalizes the HTML through one DOM parse/serialize round-trip, e.g. bare attributes gain ="".)

Hidden components persist as data-em-hidden plus a self-contained <style> rule injected/removed at save time, so saved decks need no external CSS for hiding.

fx-runtime.js gets one supporting line: its loader <script> tags are stamped data-runtime-injected so edit-mode can strip them from the snapshot (they are injected at parse time, before the snapshot).

Docs

README.md and README.zh-CN.md gain a matching "Edit Mode" section.

Verification

  • 27-check CDP e2e suite with real input events: pick clicks, double-click editing, keyboard typing, save → overwrite → reload persistence, roundtrip idempotency (second serialize is byte-identical), and no-?edit playback regression (no toolbar, keyboard nav intact, zero DOM markers).
  • An adversarial review pass on top: overview thumbnails are boot-time clones, so the O key is disabled inside edit mode; .counter / .slide-number are excluded from placeholder text on duplicate (runtime rewrites them from data-to); fx on a duplicated element only starts when its slide is visible.

Happy to split, rename, or adapt anything (e.g. wire a mention into SKILL.md so agents surface ?edit to users) — whatever fits the project's direction.

🤖 Generated with Claude Code

New self-contained assets/edit-mode.js (~800 lines, zero dependencies).
Include it as the last script in <body> and open the deck with ?edit:

- text: double-click any text element to edit in place (paste is forced
  to plain text; arrow keys stay out of deck navigation while typing)
- ✨ animations: pick an element, choose one of the 26 data-anim entry
  animations with hover live-preview
- 🎇 canvas fx: pick one of the 20 data-fx effects for the current slide
- 🧩 components: hide/show, duplicate (placeholder text) or delete a
  card / list item / pill; nearest repeating ancestor is auto-selected,
  with a parent-widening escape hatch
- 💾 save: File System Access API writes the html file directly (works
  on file:// — pick the file once, later saves are silent); falls back
  to a download when FSA is unavailable

Clean output guarantee: the script runs synchronously at the end of
<body> and snapshots the pristine DOM into a detached copy BEFORE
runtime.js's DOMContentLoaded work injects chrome (progress bar,
overview clones, is-active classes, counter rewrites). Every committed
edit is mirrored onto that clean copy and saving serializes it, so
runtime state never reaches the file and a second save is a zero diff.
Hidden components persist as data-em-hidden plus a self-contained
<style> rule injected/removed at save time.

fx-runtime.js gets one supporting line: its injected loader <script>
tags are stamped data-runtime-injected so edit-mode can strip them
from the snapshot (they are added at parse time, before the snapshot).

Without ?edit the script is completely inert. Verified with a 27-check
CDP e2e suite (real input events, save→reload persistence, roundtrip
idempotency, playback regression) plus an adversarial two-reviewer pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants