diff --git a/README.md b/README.md index 3d58c58..8e775d4 100644 --- a/README.md +++ b/README.md @@ -214,8 +214,8 @@ it looks. - Click an element, click the background to pin a spot, or drag a box around an area, then type the suggestion. - **Copy prompt** puts every suggestion on the clipboard as one Markdown prompt, - each with its slide, its position and a selector for its element, ready to - paste into Claude Code or another coding agent. + each with its slide and a selector for its element, and a position for a + point or an area, ready to paste into Claude Code or another coding agent. - Suggestions are kept per deck in the browser's `localStorage`. One whose element has changed since is labelled **Changed**. diff --git a/skills/deck/assets/template.html b/skills/deck/assets/template.html index e609a49..c5555c7 100644 --- a/skills/deck/assets/template.html +++ b/skills/deck/assets/template.html @@ -564,7 +564,7 @@

Copy prompt collects every suggestion

Paste it into Claude Code or another coding agent. It names the file, the slide and the element.

## 1. Slide 8: Speaker notes live inside the slide -Where: box x 120-1520, y 176-255, on `h2` "Speaker notes live inside the slide" +On `h2` "Speaker notes live inside the slide" Element: `#stage > section:nth-child(8) > h2:nth-child(2)` @@ -1979,14 +1979,17 @@

Start from template.html

const parts = decodeURIComponent(location.pathname).split('/'); const last = parts.pop() || 'index.html'; const file = last === 'index.html' ? [parts.filter(Boolean).pop(), last].filter(Boolean).join('/') : last; + // A position only for a point or an area drawn on the slide: an element clicked is found by its selector and its text, + // and its box in pixels would only be noise for the agent + const items = ed.items.filter(s => s.note.trim()), placed = s => !s.picked; return `Improve the deck \`${file}\` with the suggestions below. Slides are the \`
\` elements, ` + - 'numbered from 1 in document order. Positions are in the 1920×1080 slide frame, origin top left. ' + + 'numbered from 1 in document order. ' + (items.some(placed) ? 'Positions are in the 1920×1080 slide frame, origin top left. ' : '') + 'Each Element is a CSS selector for it in the deck as it was when suggested. ' + "Keep to the deck's existing conventions.\n\n" + - ed.items.filter(s => s.note.trim()).map((s, n) => + items.map((s, n) => `## ${n + 1}. Slide ${s.slide + 1}${s.heading ? ': ' + s.heading : ''}\n\n` + - `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` + - `on \`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + + (placed(s) ? `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` : 'On ') + + `\`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + `Element: \`${s.path}\`\n\n` + (s.stale ? 'This element has changed since the suggestion was made, so it may already be done.\n\n' : '') + `Suggestion: ${s.note.trim()}`).join('\n\n') + '\n'; diff --git a/src/deck.js b/src/deck.js index 64ed6d0..12c0f6f 100644 --- a/src/deck.js +++ b/src/deck.js @@ -1370,14 +1370,17 @@ const parts = decodeURIComponent(location.pathname).split('/'); const last = parts.pop() || 'index.html'; const file = last === 'index.html' ? [parts.filter(Boolean).pop(), last].filter(Boolean).join('/') : last; + // A position only for a point or an area drawn on the slide: an element clicked is found by its selector and its text, + // and its box in pixels would only be noise for the agent + const items = ed.items.filter(s => s.note.trim()), placed = s => !s.picked; return `Improve the deck \`${file}\` with the suggestions below. Slides are the \`
\` elements, ` + - 'numbered from 1 in document order. Positions are in the 1920×1080 slide frame, origin top left. ' + + 'numbered from 1 in document order. ' + (items.some(placed) ? 'Positions are in the 1920×1080 slide frame, origin top left. ' : '') + 'Each Element is a CSS selector for it in the deck as it was when suggested. ' + "Keep to the deck's existing conventions.\n\n" + - ed.items.filter(s => s.note.trim()).map((s, n) => + items.map((s, n) => `## ${n + 1}. Slide ${s.slide + 1}${s.heading ? ': ' + s.heading : ''}\n\n` + - `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` + - `on \`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + + (placed(s) ? `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` : 'On ') + + `\`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + `Element: \`${s.path}\`\n\n` + (s.stale ? 'This element has changed since the suggestion was made, so it may already be done.\n\n' : '') + `Suggestion: ${s.note.trim()}`).join('\n\n') + '\n'; diff --git a/template.html b/template.html index e609a49..c5555c7 100644 --- a/template.html +++ b/template.html @@ -564,7 +564,7 @@

Copy prompt collects every suggestion

Paste it into Claude Code or another coding agent. It names the file, the slide and the element.

## 1. Slide 8: Speaker notes live inside the slide -Where: box x 120-1520, y 176-255, on `h2` "Speaker notes live inside the slide" +On `h2` "Speaker notes live inside the slide" Element: `#stage > section:nth-child(8) > h2:nth-child(2)` @@ -1979,14 +1979,17 @@

Start from template.html

const parts = decodeURIComponent(location.pathname).split('/'); const last = parts.pop() || 'index.html'; const file = last === 'index.html' ? [parts.filter(Boolean).pop(), last].filter(Boolean).join('/') : last; + // A position only for a point or an area drawn on the slide: an element clicked is found by its selector and its text, + // and its box in pixels would only be noise for the agent + const items = ed.items.filter(s => s.note.trim()), placed = s => !s.picked; return `Improve the deck \`${file}\` with the suggestions below. Slides are the \`
\` elements, ` + - 'numbered from 1 in document order. Positions are in the 1920×1080 slide frame, origin top left. ' + + 'numbered from 1 in document order. ' + (items.some(placed) ? 'Positions are in the 1920×1080 slide frame, origin top left. ' : '') + 'Each Element is a CSS selector for it in the deck as it was when suggested. ' + "Keep to the deck's existing conventions.\n\n" + - ed.items.filter(s => s.note.trim()).map((s, n) => + items.map((s, n) => `## ${n + 1}. Slide ${s.slide + 1}${s.heading ? ': ' + s.heading : ''}\n\n` + - `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` + - `on \`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + + (placed(s) ? `Where: ${s.kind === 'pin' ? `point x ${s.x}, y ${s.y}` : `box x ${s.x}-${s.x + s.w}, y ${s.y}-${s.y + s.h}`}, ` : 'On ') + + `\`${s.el}\`${s.text ? ` "${s.text}"` : ''}\n\n` + `Element: \`${s.path}\`\n\n` + (s.stale ? 'This element has changed since the suggestion was made, so it may already be done.\n\n' : '') + `Suggestion: ${s.note.trim()}`).join('\n\n') + '\n'; diff --git a/test/deck.spec.mjs b/test/deck.spec.mjs index dc23f85..4d6159d 100644 --- a/test/deck.spec.mjs +++ b/test/deck.spec.mjs @@ -950,8 +950,11 @@ test.describe('suggest', () => { expect(prompt).toContain('`' + fileName + '`'); expect(prompt).toContain('## 1. Slide 1'); expect(prompt).toContain('Suggestion: Make the heading shorter'); - expect(prompt).toMatch(new RegExp('Where: box x \\d+-\\d+, y \\d+-\\d+, on `' + tag)); + // an element clicked has no position, a point or an area drawn has one + expect(prompt).toMatch(new RegExp('\\nOn `' + tag)); expect(prompt).toMatch(/Where: point x \d+, y \d+/); + expect(prompt).toMatch(/Where: box x \d+-\d+, y \d+-\d+, `/); + expect(prompt).toContain('Positions are in the 1920×1080 slide frame'); expect(prompt).not.toContain('```'); // the selector and the text find it; no copy of its HTML expect(prompt).not.toMatch(/e-hover|e-mark|edit-layer/); @@ -1022,7 +1025,7 @@ test.describe('suggest', () => { await expect(at).toHaveText('div.stat'); await page.keyboard.press('Enter'); const prompt = await copied(page); - expect(prompt).toContain('on `div.stat'); + expect(prompt).toContain('On `div.stat'); expect(prompt).toContain('Suggestion: Make it bigger'); await expect(page.locator('.e-item')).toHaveCount(1);