Skip to content

feat: add screenshot export to Ruby tab#323

Merged
takaokouji merged 5 commits intodevelopfrom
feature/ruby-tab-screenshot
Mar 16, 2026
Merged

feat: add screenshot export to Ruby tab#323
takaokouji merged 5 commits intodevelopfrom
feature/ruby-tab-screenshot

Conversation

@takaokouji
Copy link

Summary

Ruby タブの Monaco エディタの内容(行番号・ふりがな含む)を PNG 画像として保存する機能を追加。

  • カメラボタンを zoom ボタンの上に追加(blocks タブと同じアイコン・デザイン)
  • html-to-image ライブラリで Monaco エディタの DOM をキャプチャ
  • 長いプログラムは一時的にエディタを全行表示に拡張してからキャプチャ
  • ふりがな(ViewZones)は DOM 要素なので自然にキャプチャされる(ON/OFF の見たまま)
  • 2x pixel ratio で高解像度出力

Implementation Steps

  • Phase 1-3: ボタン UI + キャプチャロジック + ハンドラ接続
  • Phase Final: Integration テスト
  • Phase DoD: CI + ブラウザ確認

Definition of Done

  • ユニットテスト pass(14 tests)
  • Integration テスト pass
  • lint pass
  • CI green
  • ブラウザ確認(Playwright MCP):
    • Ruby タブにカメラボタンが zoom ボタンの上に表示される
    • 短いプログラム(5行程度)でスクリーンショットが保存できる
    • 長いプログラム(50行以上)で全行がキャプチャされている
    • ふりがな ON の状態でふりがなが画像に含まれる
    • ふりがな OFF の状態でふりがなが画像に含まれない
    • 行番号が画像に含まれる

Test Plan

Type Timing Target
Unit tests (TDD) Before implementation ruby-screenshot.js のロジック
Integration tests After implementation ボタンクリック → ダウンロード
Browser verification After CI green Playwright MCP で DoD 確認

Closes #322

Add a camera button above the zoom controls in the Ruby tab that captures
the Monaco editor content (including line numbers and furigana annotations)
as a PNG image. Uses html-to-image library to capture the editor DOM,
temporarily expanding the editor to full content height for long programs.

Closes #322

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

takaokouji and others added 4 commits March 16, 2026 13:38
Temporarily disable scrollBeyondLastLine before capturing to get tight
content height without extra whitespace below the last line.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The screenshot button was added as the first child of zoomControlsWrapper,
shifting zoom button indices by 1 in integration test xpath selectors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace fragile button index selectors with data-testid attributes
for stable test targeting regardless of button order changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add skipFonts option to html-to-image to avoid SecurityError when
reading cssRules from Monaco Editor's cross-origin CDN stylesheet.
The editor fonts render correctly without web font embedding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit caabdea into develop Mar 16, 2026
9 checks passed
@takaokouji takaokouji deleted the feature/ruby-tab-screenshot branch March 16, 2026 07:54
github-actions bot pushed a commit that referenced this pull request Mar 16, 2026
…tab-screenshot

feat: add screenshot export to Ruby tab
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.

feat: add screenshot export to Ruby tab

1 participant