WIP: Add edit mode — inline copy editing with auto-save [DO NOT MERGE]#11
Draft
welfvh wants to merge 4 commits intobierlingm:mainfrom
Draft
WIP: Add edit mode — inline copy editing with auto-save [DO NOT MERGE]#11welfvh wants to merge 4 commits intobierlingm:mainfrom
welfvh wants to merge 4 commits intobierlingm:mainfrom
Conversation
New widget module (edit.js) that adds contenteditable to text elements when activated via data-edit="true" on the script tag. Edits auto-save to localStorage on every keystroke and persist across reloads. Features: - Toggle via ✎ button or window.Spikes.toggleEditMode() - Green left-border on edited elements - "N edits" pill shows change count - window.Spikes.getEdits() returns structured JSON for AI agents - window.Spikes.clearEdits() resets all changes - Spike mode and edit mode are mutually exclusive - Includes test page (test-edit-mode.html) Minimal changes to spikes.js: - data-edit config attribute - loadEditMode() in init - _exitSpikeMode hook for mode coordination - _exitEditMode called when entering spike mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an edit mode to the Spikes widget — click any text element to edit it inline. Edits auto-save to localStorage and are accessible via
window.Spikes.getEdits()as structured JSON.This makes Spikes useful not just for annotating feedback, but for directly editing copy — the most natural way to suggest text changes on a page.
widget/edit.js(~370 lines, vanilla JS, zero deps)widget/spikes.js(config, init, mode coordination)widget/test-edit-mode.htmlHow it works
Add
data-edit="true"to the script tag:A
✎button appears next to the/button. Click it (or callSpikes.toggleEditMode()) to make all text elements contenteditable. Edits auto-save to localStorage on every keystroke.Visual feedback:
API:
Spikes.getEdits()— structured JSON array of{selector, original, updated, tag}Spikes.clearEdits()— reset all changes + clear localStorageSpikes.isEditMode()/Spikes.toggleEditMode()Mode coordination:
/button still works normally for feedback while in edit mode (switches to spike mode)Use case
We built this for editing landing page copy with Claude Code. The workflow:
spikes servewithdata-edit="true"Spikes.getEdits()→ paste JSON into AI agent → changes applied to sourceTest plan
widget/test-edit-mode.htmlin browser✎button appears next to/✎→ text elements become editable (gold border on hover)Spikes.getEdits()returns correct change arraySpikes.clearEdits()reverts all changes/while in edit mode → exits edit, enters spike mode✎while in spike mode → exits spike, enters edit mode🤖 Generated with Claude Code