Skip to content

feat: 이미지 파일 드래그 앤 드롭 삽입 (#307)#830

Open
oksure wants to merge 2 commits into
edwardkim:develfrom
oksure:contrib/image-drop
Open

feat: 이미지 파일 드래그 앤 드롭 삽입 (#307)#830
oksure wants to merge 2 commits into
edwardkim:develfrom
oksure:contrib/image-drop

Conversation

@oksure
Copy link
Copy Markdown
Contributor

@oksure oksure commented May 11, 2026

변경 내용

Closes #307

편집 영역(scroll-container)에 이미지 파일을 드래그 앤 드롭하면 기존 insert:image 커맨드와 동일한 이미지 배치 모드로 진입합니다.

동작

  1. 이미지 파일(png, jpg, jpeg, gif, bmp, webp)을 편집 영역에 드롭
  2. Image 엘리먼트로 원본 크기를 측정
  3. enterImagePlacementMode() 호출 → 마우스로 삽입 위치/크기 지정

변경 파일

파일 변경
main.ts drop 이벤트 핸들러에 이미지 확장자 감지 + 배치 모드 진입 로직 추가

기존 HWP/HWPX 파일 드롭 동작은 그대로 유지됩니다. 문서가 열려있지 않으면 이미지 드롭은 무시됩니다.

테스트

  • cargo test 통과
  • cargo clippy -- -D warnings 경고 없음

감사합니다.

- scroll-container 영역에 이미지 파일(png, jpg, gif, bmp, webp) 드롭 시
  기존 insert:image와 동일한 이미지 배치 모드로 진입
- 기존 HWP/HWPX 파일 드롭 동작은 그대로 유지
- 문서가 열려있지 않으면 드롭 무시
Copilot AI review requested due to automatic review settings May 11, 2026 08:38
Copy link
Copy Markdown
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

Adds drag-and-drop image insertion into the editor area (scroll-container) so that dropping a supported image file enters the same interactive placement mode as the existing insert:image command (Issue #307).

Changes:

  • Detects common image extensions on drop and enters image placement mode when a document is open.
  • Loads dropped image bytes and measures intrinsic dimensions before calling enterImagePlacementMode(...).
  • Updates the unsupported-drop alert message to include image files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rhwp-studio/src/main.ts Outdated
Comment on lines +260 to +263
img.src = URL.createObjectURL(file);
await new Promise<void>(r => { img.onload = () => r(); });
URL.revokeObjectURL(img.src);
inputHandler.enterImagePlacementMode(data, ext, img.naturalWidth, img.naturalHeight, file.name);
Copilot 리뷰 반영: img.onload 대신 img.decode()로 디코딩 실패 감지,
URL.revokeObjectURL을 finally 블록에서 호출하여 에러 시에도 정리.
@oksure
Copy link
Copy Markdown
Contributor Author

oksure commented May 11, 2026

Copilot 리뷰 반영 (b2462e6): try/finally로 blob URL 누수 방지 + img.decode()로 디코딩 실패 처리

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.

2 participants