Skip to content

feat: add HWPX fragment paste support#880

Closed
dragonnite1221-lgtm wants to merge 1 commit into
edwardkim:develfrom
dragonnite1221-lgtm:public/hwpx-fragment-paste
Closed

feat: add HWPX fragment paste support#880
dragonnite1221-lgtm wants to merge 1 commit into
edwardkim:develfrom
dragonnite1221-lgtm:public/hwpx-fragment-paste

Conversation

@dragonnite1221-lgtm

@dragonnite1221-lgtm dragonnite1221-lgtm commented May 13, 2026

Copy link
Copy Markdown
Contributor

Adds HWPX fragment paste support, WASM bridge APIs, rhwp-studio insertion UI, and regression tests. Internal work logs, local environment paths, and operational notes were intentionally excluded from this public branch.

Architecture note: this PR intentionally keeps two paste entry points for different safety boundaries.

  • pasteHwpxFragment / fragment_paste.rs is the raw XML primitive. It performs byte-preserving section/header edits and owns HWPX ID remapping for raw snippets.
  • pasteHwpxFragmentInDocument / fragment_paste_in_document.rs is the editor-facing bridge. It reuses the raw XML primitive, then reparses the updated section back into DocumentCore so rendering and later edit commands stay in sync.
  • cross_document_migrate.rs is the IR migration primitive for future structured cross-document copy/paste. It is kept separate from the raw HWPX fragment path because it operates on Document/DocInfo IR, not byte-preserved HWPX XML. The convergence point is at the command/API layer: raw HWPX fragments use the byte-preserving path now; structured IR copy/paste can use the migration primitive once the editor exposes that workflow.

Review follow-up in this revision:

  • Rebased onto current origin/devel and preserved the HWPX external-image path fix in parse_hwpx_with_raw_xmls.
  • Removed the as any call by using the generated WASM binding type for pasteHwpxFragmentInDocument.
  • Removed local-machine yangsik smoke tests and made the remaining Document bridge tests use the bundled saved/04-blank_hwpx_empty.hwpx fixture so CI gets real regression coverage.
  • Aligned the blank HWPX seed comment with saved/04-blank_hwpx_empty.hwpx.
  • Removed the unused build_occupied_sets helper.

Validation performed locally:

  • cargo test --test fragment_paste_integration --test fragment_paste_in_document
  • cargo test fragment_paste
  • npm run build in rhwp-studio/

@dragonnite1221-lgtm

Copy link
Copy Markdown
Contributor Author

Updated the branch on top of current origin/devel and resolved conflicts in rhwp-studio/index.html, rhwp-studio/vite.config.ts, and src/document_core/mod.rs.

Current validation after rebase:

  • gitleaks detect --source . --log-opts origin/devel..HEAD --redact --no-banner --verbose: no leaks found
  • sensitive string scan on origin/devel..HEAD: no internal paths/IP/token patterns found
  • cargo test fragment_paste --tests: passed
  • docker compose --env-file .env.docker run --rm wasm: passed, local pkg regenerated for verification
  • cd rhwp-studio && npm run build: passed

I also added a local pre-push guard in my working copy to prevent accidentally pushing local/*, archive/internal/*, or public branches containing internal paths such as mydocs/.

@edwardkim

Copy link
Copy Markdown
Owner

Welcome to the rhwp project, @dragonnite1221-lgtm! 🎉 This is your first PR and the scope is impressive — HWPX fragment paste with both raw XML and IR migration paths, a yangsik dialog, and thorough test coverage.

We've completed a detailed code review. The overall quality is good, but there are a few items to address before we can merge.

What we liked

  • Dual approach (raw XML path + IR migration path) with independent tests for each
  • Byte-preserving principle consistently applied
  • Path traversal defense in vite-plugin-yangsik-fragments.ts
  • ~40 unit tests + 4 integration tests — solid coverage

Requested changes

1. Dual implementation overlap (medium)

fragment_paste.rs (raw XML ID remap) and cross_document_migrate.rs (IR ID remap) implement the same purpose with separate IdRemap structs. The WASM bridge exposes two entry points (pasteHwpxFragment + pasteHwpxFragmentInDocument) but the PR description doesn't explain why both are needed or how they'll converge.

Ask: Please add a note in the PR description explaining the intent, or consolidate into one path if the other is experimental.

2. Type cast in wasm-bridge.ts (medium)

(this.doc as any).pasteHwpxFragmentInDocument(...)

This bypasses compile-time type safety. Please add the method to the WASM binding type definition instead of using as any.

3. Environment-dependent tests (medium)

fragment_paste_in_document_yangsik.rs depends on ~/rhwp-layout-profiles/personal-templates/양식_3bf55ee3.hwpx — a path that only exists on your local machine. These tests are always skipped in CI and provide no regression protection.

Ask: Either bundle a small test fixture in saved/ or samples/, or remove the environment-dependent tests and keep only the self-contained ones.

4. Comment/code mismatch (low)

wasm_api.rs comments reference saved/03-blank_hwpx.hwpx but the actual added file is saved/04-blank_hwpx_empty.hwpx. Please align the comment.

5. Unused function (low)

build_occupied_sets in fragment_paste.rs appears to be defined but the same logic is reimplemented inline in recompute_one_table. This may trigger dead_code warnings. Please remove the unused function or use it.

How to proceed

  1. Address items baseline/line_height/line_spacing 역공학 #1cellzoneList(셀 영역 배경) 미지원으로 표 배경 누락 #5 above
  2. Rebase onto current devel to resolve the conflict
  3. Push the updated branch — we'll re-review

We're also happy to discuss architecture decisions (e.g., the dual-path approach) in a GitHub Discussion or Issue if that would help.

Thank you for the contribution, and looking forward to the updated PR!

@dragonnite1221-lgtm dragonnite1221-lgtm force-pushed the public/hwpx-fragment-paste branch from 44ca568 to 29c7cdb Compare May 14, 2026 14:10
@dragonnite1221-lgtm dragonnite1221-lgtm force-pushed the public/hwpx-fragment-paste branch from 29c7cdb to dd430bf Compare May 14, 2026 14:17
@edwardkim edwardkim self-requested a review May 14, 2026 22:38
@edwardkim edwardkim added this to the v1.0.0 milestone May 14, 2026
@edwardkim edwardkim added the enhancement New feature or request label May 14, 2026
@edwardkim

Copy link
Copy Markdown
Owner

Thanks for the rebase and conflict resolution. We've tested the code locally — cargo test 1306 passed and tsc --noEmit clean. The paste engine and dialog infrastructure work well.

However, we can't merge in the current state because there are no example yangsik fragment files included. When a user clicks "양식 부품" in the menu, they see "양식 부품 카탈로그가 비어있습니다" — the feature has no usable content.

We need the PR to be end-to-end testable by a maintainer in the web editor, not only through unit/integration tests with inline XML.

What's needed

Please add 1–2 example .hwpx fragment files in rhwp-studio/public/yangsik-fragments/ so that:

  1. vite-plugin-yangsik-fragments.ts generates a non-empty manifest.json at build time
  2. The "양식 부품" dialog shows the example entries
  3. Clicking an entry actually pastes the fragment into the document

A simple table or a standard form header would be sufficient as a demo.

Summary of pending items

# Item Status
1 Dual implementation clarification Pending (from previous review)
2 (this.doc as any) type cast Pending
3 Environment-dependent tests Pending
4 Comment/code mismatch Pending
5 Unused function Pending
6 Example yangsik fragments for end-to-end demo New — required for merge

Once the example fragments are added and items #1–5 are addressed (or explained), we'll re-review and proceed with the merge.

Thank you!

@edwardkim

Copy link
Copy Markdown
Owner

One more question — the feature is named "HWPX fragment paste", but rhwp-studio also opens HWP5 (.hwp) files.

Does this feature work when the active document is an HWP5 file? HWP5 uses OLE compound binary format while the fragments are HWPX XML. If fragment paste only works with HWPX documents, the canExecute guard should check the document format (e.g., ctx.sourceFormat === 'hwpx') to prevent users from attempting an unsupported operation.

Please clarify:

  1. Is fragment paste supported for HWP5 documents?
  2. If not, does the code gracefully handle it (error message) or silently fail?
  3. Should the menu item be disabled for HWP5 documents?

edwardkim pushed a commit that referenced this pull request May 15, 2026
PR #880 (@dragonnite1221-lgtm, rhwp 첫 PR) GitHub diff 기반 cherry-pick.
mydocs 거버넌스 산출물 제외. insert.ts 충돌 수동 해결.

신규 모듈:
- document_core/commands/cross_document_migrate.rs — IR 경로 ID remap
- document_core/commands/fragment_paste.rs — raw XML 경로 fragment paste
- document_core/commands/fragment_paste_in_document.rs — 문서 내 paste
- document_core/queries/raw_xml.rs — XML 쿼리

WASM API: pasteHwpxFragment + pasteHwpxFragmentInDocument + createBlankDocument
rhwp-studio: YangsikPartsDialog + vite-plugin-yangsik-fragments + insert:yangsik-parts
fixture: saved/04-blank_hwpx_empty.hwpx

검증:
- cargo test --release --lib: 1306 passed (+60 신규)
- fragment_paste_in_document + fragment_paste_integration: 6 passed
- tsc --noEmit: 에러 0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
edwardkim pushed a commit that referenced this pull request May 15, 2026
@edwardkim

Copy link
Copy Markdown
Owner

Closing this PR as there has been no response to the review feedback.

The code quality was good and the fragment paste infrastructure was well-designed. If you'd like to revisit this in the future, please address the items listed in the previous review comments (example yangsik fragments, dual implementation clarification, HWP5 compatibility, etc.) and open a new PR.

Thank you for the contribution!

@edwardkim edwardkim closed this May 17, 2026
edwardkim pushed a commit that referenced this pull request May 21, 2026
HWPX fragment paste support — 메인테이너 hands-on 테스트에서 동작
결함 2건 발견으로 close. 컨트리뷰터에게 재제출 권고.

발견 결함:
- B1: 빈 HWPX 문서에서 after_para_idx 1 out of range
- B2: 확인 버튼 무동작 — onConfirm() 항상 false 반환

기타 수정요청 항목 (재제출 시 권고):
- M1: 비공개 task 참조 주석 (task_local_yangsik_paste_*) 제거
- M2: cross_document_migrate.rs (미사용 1011줄) 별도 PR 분리
- R1: yangsik 명명 UI ↔ 코드 불일치 해소

PR #880 잔존 6 항목 중 코드 측은 대부분 성실 반영 (예시 fragment,
HWP5 비호환 guard, 카탈로그 보안 강화). 핵심 기능 설계도 양호.
그러나 end-to-end UX 게이트 미통과로 close.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants