feat: F5 본문 블록 선택 모드 + F3 영역 확장 선택 (#220)#811
Conversation
한컴 HWP F5/F3 블록 선택 기능 구현: F5 (본문): - 블록 선택 모드 진입 — 현재 위치에 anchor 설정 - 이후 화살표 키로 선택 영역 확장 (Shift 없이도) - F5 재입력 또는 Esc로 모드 해제 F3 (선택 영역 확장): - 단계적 확장: 단어 → 문단 → 구역 → 문서 전체 - F3 첫 입력 시 블록 모드 자동 진입 - findWordAt() 헬퍼 (Hangul/Latin/Digit 분류) 기존 F5 표 셀 선택 모드는 그대로 유지 (isInCell 분기). wasm-bridge에 getSectionCount() 메서드 추가. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
한컴 HWP 스타일의 본문 블록 선택(F5)과 선택 영역 단계 확장(F3)을 rhwp-studio 편집 엔진 입력/커서 계층에 추가해, 키보드 기반 선택 UX를 강화하는 PR입니다.
Changes:
F5로 본문 블록 선택 모드 진입/해제(표 셀 내부는 기존 셀 선택 모드 유지)F3로 선택 영역을 단계적으로 확장하는 커서 로직(expandSelection,findWordAt) 추가- 문서 전체 선택을 위해
WasmBridge.getSectionCount()브리지 메서드 추가
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| rhwp-studio/src/engine/input-handler-keyboard.ts | F5/F3/Esc 키 입력 처리에 본문 블록 선택 모드 진입/확장/해제 로직 추가 |
| rhwp-studio/src/engine/cursor.ts | 블록 선택 모드 상태 및 F3 확장 선택 로직, 단어 경계 탐지 헬퍼 추가 |
| rhwp-studio/src/core/wasm-bridge.ts | 문서 전체 선택에 필요한 섹션 개수 조회 API 추가 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 본문 블록 선택 모드 (#220) | ||
| if (this.cursor.isInBlockSelectionMode()) { | ||
| this.cursor.exitBlockSelectionMode(); | ||
| this.selectionRenderer.clear(); | ||
| this.updateCaret(); | ||
| } else { | ||
| this.cursor.enterBlockSelectionMode(); | ||
| this.updateSelection(); | ||
| } |
| enterBlockSelectionMode(): void { | ||
| this._blockSelectionMode = true; | ||
| this._expandPhase = 0; | ||
| this.setAnchor(); |
| expandSelection(): void { | ||
| this._expandPhase++; | ||
| const pos = this.position; | ||
| const sec = pos.sectionIndex; | ||
| const para = pos.paragraphIndex; | ||
| try { | ||
| if (this._expandPhase === 1) { | ||
| // 단어 선택 — 현재 위치의 단어 범위 | ||
| const paraLen = this.wasm.getParagraphLength(sec, para); | ||
| const text = this.wasm.getTextRange(sec, para, 0, paraLen); | ||
| const { start, end } = findWordAt(text, pos.charOffset); | ||
| this.anchor = { ...pos, charOffset: start }; | ||
| this.position = { ...pos, charOffset: end }; | ||
| } else if (this._expandPhase === 2) { | ||
| // 문단 전체 선택 | ||
| const paraLen = this.wasm.getParagraphLength(sec, para); | ||
| this.anchor = { ...pos, charOffset: 0 }; | ||
| this.position = { ...pos, charOffset: paraLen }; | ||
| } else if (this._expandPhase === 3) { | ||
| // 구역 전체 선택 | ||
| const paraCount = this.wasm.getParagraphCount(sec); | ||
| const lastParaLen = this.wasm.getParagraphLength(sec, paraCount - 1); | ||
| this.anchor = { sectionIndex: sec, paragraphIndex: 0, charOffset: 0 }; | ||
| this.position = { sectionIndex: sec, paragraphIndex: paraCount - 1, charOffset: lastParaLen }; | ||
| } else { | ||
| // 문서 전체 선택 | ||
| const secCount = this.wasm.getSectionCount(); | ||
| const lastSec = secCount - 1; | ||
| const lastParaCount = this.wasm.getParagraphCount(lastSec); | ||
| const lastParaLen = this.wasm.getParagraphLength(lastSec, lastParaCount - 1); | ||
| this.anchor = { sectionIndex: 0, paragraphIndex: 0, charOffset: 0 }; | ||
| this.position = { sectionIndex: lastSec, paragraphIndex: lastParaCount - 1, charOffset: lastParaLen }; | ||
| this._expandPhase = 4; // cap |
| private _expandPhase = 0; // F3 확장 단계: 0=none, 1=word, 2=paragraph, 3=section, 4=document | ||
|
|
| if (!text || offset >= text.length) return { start: offset, end: offset }; | ||
| const atWord = isWordChar(text[offset] ?? ''); | ||
| let start = offset; | ||
| let end = offset; |
기존 setAnchor()는 anchor가 이미 있으면 스킵하여, 이전 선택 상태에서 블록 선택 모드 진입 시 stale anchor 유지 문제. 현재 위치를 직접 anchor에 할당하여 항상 올바른 기준점 설정. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@oksure — Issue #220 (한컴 F5/F3 블록 선택) 영역 4단계 정합. 5단계 영역 영역 문장 단계 영역 별 Issue 분리 후속. 본질 (2 PR commits + 1 정정 commit): - cursor.ts (+85): _blockSelectionMode + _expandPhase 상태 + enterBlockSelectionMode / exitBlockSelectionMode / expandSelection 메서드 + isWordChar / findWordAt 헬퍼 (Hangul AC00-D7AF + Hangul Jamo 3131-318E + Digit + Latin) - input-handler-keyboard.ts (+30/-2): F5 토글 (본문/셀 isInCell() 분기) + F3 확장 + Escape 분기 - Copilot 리뷰 반영 (59a01de): enterBlockSelectionMode anchor 강제 설정 (this.anchor = { ...this.position }) F3 4단계 확장 (Issue #220 5단계 영역 영역 문장 단계 누락): - F3 1회: 단어 (findWordAt) - F3 2회: 문단 전체 - F3 3회: 구역 전체 - F3 4회: 문서 전체 (phase 4 cap) 본 환경 충돌 수동 해결 (1 파일): - cursor.ts 파일 끝 영역 영역 PR #794 (findWordBoundaryForward/Backward, Alt+Arrow 단어 이동) + PR #811 (findWordAt, F3 단어 선택) 두 유틸 양측 보존 정정 commit (dc6aa7a): - wasm-bridge.ts 영역 영역 getSectionCount 중복 정의 제거 (PR #808 의 라인 231 보존, PR #811 영역 영역 추가본 제거) 자기 검증: tsc + cargo test ALL GREEN, WASM 재빌드 불필요 (TypeScript 단일) 시각 판정: 작업지시자 인터랙션 검증 ✅ 통과 (F5 본문/셀 + F3 4단계 + 회귀 부재) CI: ✅ Build & Test + CodeQL + Canvas visual diff 별 Issue 후속 — F3 문장 단계 (Issue #220 5단계 영역 영역 문장 단계)
|
@oksure 머지 완료 (commit F5 본문 블록 선택 + F3 4단계 확장 정합. Copilot 리뷰 반영 (enterBlockSelectionMode anchor 강제 설정) 정확. 본 환경 충돌 + 정정:
Issue #220 영역 영역 5단계 vs PR 4단계 — Issue 본문 영역 영역 5단계 (단어 → 문장 → 문단 → 섹션 → 문서) 명시, 본 PR 영역 영역 4단계 (문장 단계 누락). 별 Issue 영역 영역 분리 후속 정정 권장 — Issue #220 영역 영역 OPEN 유지. 자기 검증 tsc + cargo test ALL GREEN. 작업지시자 인터랙션 검증 통과 (F5 본문/셀 + F3 4단계 + 기존 단축키 회귀 부재). 수고하셨습니다. |
변경 내용
한컴 HWP의 F5 블록 선택 + F3 영역 확장 기능 구현.
F5 블록 선택 모드 (본문)
isInCell()분기)F3 선택 영역 확장
findWordAt()헬퍼: Hangul/Latin/Digit 분류 기반 단어 경계 감지추가 변경
wasm-bridge.ts:getSectionCount()메서드 추가테스트
cargo clippy -- -D warnings통과tsc --noEmit통과closes #220
감사합니다.