chore: clean up standalone editor HTML (10% reduction)#16304
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Cleans up the standalone playground editor HTML/CSS/JS to reduce overall file size and remove redundant markup/styling while preserving the editor’s functionality and layout.
Changes:
- Removed the
.appwrapper and moved layout flex styling tobody. - Consolidated/trimmed CSS rules (combined selectors, shared scrollbar styling, removed unused CSS variables).
- Simplified/refactored JS (default content as a template literal, extracted copy feedback helper, factored divider resize logic).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/public/editor/index.html
Outdated
| function resizePanels(clientX, clientY) { | ||
| const rect = panels.getBoundingClientRect(); | ||
| const isMobile = window.innerWidth < 768; | ||
| const pos = isMobile ? clientY - rect.top : clientX - rect.left; | ||
| const size = isMobile ? rect.height : rect.width; |
There was a problem hiding this comment.
resizePanels() computes isMobile (window.innerWidth < 768) to switch between horizontal vs vertical resizing, but the drag start handler sets document.body.style.cursor = 'col-resize' unconditionally. On narrow viewports where panels are stacked vertically, this can show the wrong cursor during drag; consider basing the cursor on the same breakpoint logic so the cursor matches the resize direction.
docs/public/editor/index.html
Outdated
| function syncLineNumberScroll() { | ||
| const lineNumbers = $('lineNumbers'); | ||
| lineNumbers.scrollTop = editor.scrollTop; | ||
| $('lineNumbers').scrollTop = editor.scrollTop; | ||
| } |
There was a problem hiding this comment.
syncLineNumberScroll() now does a fresh getElementById('lineNumbers') lookup on every editor scroll event. Since this runs frequently, it would be more efficient to cache the element once alongside the other DOM element constants and reuse it here.
See below for a potential fix:
const lineNumbersElement = $('lineNumbers');
function syncLineNumberScroll() {
lineNumbersElement.scrollTop = editor.scrollTop;
|
@Mossaka move the js code in own file for sanity. |
Move all inline JavaScript from editor/index.html into editor/editor.js, loaded as an ES module. Also addresses PR review feedback: - Fix drag cursor: use row-resize on mobile (<768px), col-resize on desktop - Cache lineNumbers DOM element at init instead of querying on every scroll Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addressed review feedbackComment 1 — Comment 2 — Cache Additionally — Extracted inline JS to separate file: Verified with Playwright:
|
Summary
Test plan
/editor/🤖 Generated with Claude Code