-
-
Notifications
You must be signed in to change notification settings - Fork 581
feat: createEmpty가 기본 A4 구역 1개 + 빈 문단을 포함해 즉시 편집 가능 (#1386)#1399
feat: createEmpty가 기본 A4 구역 1개 + 빈 문단을 포함해 즉시 편집 가능 (#1386) #1399oksure wants to merge 3 commits into
Conversation
...1386) 구역 0개 문서는 모든 편집/조회 API가 "구역 인덱스 0 범위 초과"로 실패해 createEmpty가 사실상 사용 불가했다. 한컴 새 문서 기본 용지 (A4, 여백 좌우 30/위 20/아래 15mm)로 구역 1개 + 빈 문단 1개를 구성해 set_document로 초기화한다. - 회귀 테스트: 구역 수/insertText/getTextRange/exportHwp/exportHwpx/ 재파싱 보존 단언 (test_create_empty_document_is_editable) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Ensures createEmpty returns an immediately usable document (at least 1 section + 1 paragraph) and adds a regression test to prevent "0 sections → all edit/read APIs fail" behavior (#1386).
Changes:
- Add a wasm API regression test verifying edit/read/export/roundtrip after
createEmpty. - Update
HwpDocument::create_emptyto construct a default A4 section and an empty paragraph instead of returning a 0-section document.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/wasm_api/tests.rs | Adds regression test covering edit/read/export and reparse behavior for createEmpty. |
| src/wasm_api.rs | Modifies create_empty to build a minimal editable document structure (A4 section + empty paragraph). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paginate는 누락이 아니라 set_document 내부로 이동했습니다 — set_document()가 styles/composed 재구성 후 mark_all_sections_dirty() + self.paginate()까지 수행합니다 (document_core/commands/document.rs). 기존 계약을 고정하는 test_create_empty_document(page_count()==1)와 SVG/HTML 렌더 테스트들이 전부 통과합니다. 호출 흐름이 코드에서 안 보이는 점은 주석으로 명시해 두었습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a88189f 에서 반영했습니다 — A4 기본 용지를 PageDef::a4_default() 모델 생성자로 이동해 단일 출처화했습니다. (renderer/page_layout.rs의 a4_page_def는 #[cfg(test)] 모듈 내부 헬퍼라 프로덕션에서 직접 재사용이 불가해 모델 쪽을 공용 출처로 삼았습니다.)
createEmpty에 하드코딩했던 한컴 새 문서 기본 용지 값을 모델 생성자로 이동해 단일 출처화. set_document가 paginate까지 수행함을 주석으로 명시. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
문제 (#1386)
HwpDocument.createEmpty()가 구역 0개 문서를 생성해getSectionCount() === 0이고, 모든 편집/조회 API가 "구역 인덱스 0 범위 초과"로 실패합니다. addSection류 API도 없어 사실상 사용 불가한 반쪽 API였습니다.수정
이슈의 기대 1안:
createEmpty가 기본 구역 1개(+빈 문단 1개)를 포함하도록 수정.PageDef구성 —renderer/page_layout.rs의a4_page_def테스트 헬퍼와 동일 값Paragraph::new_empty()문단 1개 포함,set_document()로 styles/composed/pagination 일괄 초기화DocumentCore::new_empty()는 변경하지 않음 — 내부 테스트 다수가 빈 코어에 직접 구역을 push하는 스캐폴딩으로 사용하므로, 공개 API 경계(wasm_api::create_empty)에서만 보강검증
test_create_empty_document_is_editable:getSectionCount()==1, insertText, getTextRange, exportHwp, exportHwpx, export→재파싱 텍스트 보존 단언page_count()==1, SVG/HTML 렌더, layer tree export 테스트 전부 통과cargo fmt -- --check/cargo clippy --all-targets -- -D warnings/cargo test전체 통과Closes #1386