Skip to content

chore: clean up standalone editor HTML (10% reduction)#16304

Merged
Mossaka merged 3 commits intomainfrom
chore/editor-cleanup
Feb 17, 2026
Merged

chore: clean up standalone editor HTML (10% reduction)#16304
Mossaka merged 3 commits intomainfrom
chore/editor-cleanup

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 17, 2026

Summary

  • Removed wrapper divs, duplicate CSS/JS, unused variables. 1317→1187 lines.

Test plan

  • Verify the standalone editor loads correctly at /editor/
  • Check light and dark theme rendering
  • Confirm compile functionality still works

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 17, 2026 07:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .app wrapper and moved layout flex styling to body.
  • 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.

Comment on lines +1112 to +1116
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;
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 977 to 979
function syncLineNumberScroll() {
const lineNumbers = $('lineNumbers');
lineNumbers.scrollTop = editor.scrollTop;
$('lineNumbers').scrollTop = editor.scrollTop;
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Contributor

@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>
@Mossaka
Copy link
Collaborator Author

Mossaka commented Feb 17, 2026

Addressed review feedback

Comment 1 — resizePanels() cursor fix:
The mousedown handler now checks window.innerWidth < 768 and sets document.body.style.cursor to 'row-resize' for mobile (vertical layout) or 'col-resize' for desktop (horizontal layout).

Comment 2 — Cache lineNumbers element:
The lineNumbers element is now cached once at initialization (alongside all other DOM elements) and syncLineNumberScroll() uses the cached reference instead of calling getElementById('lineNumbers') on every scroll event.

Additionally — Extracted inline JS to separate file:
All JavaScript has been moved from the inline <script> block in index.html into a separate editor.js file, loaded as <script type="module" src="editor.js"></script>. Module scripts are deferred by default, so DOM references work correctly.

Verified with Playwright:

  • Desktop (1280x800): compilation works, col-resize cursor during drag
  • Mobile (375x812): vertical layout, row-resize cursor during drag
  • External editor.js loaded as module, zero inline scripts

@Mossaka Mossaka merged commit a6eb9cb into main Feb 17, 2026
1 check passed
@Mossaka Mossaka deleted the chore/editor-cleanup branch February 17, 2026 21:05
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.

3 participants