Skip to content

[FE] Canvas 리팩토링#358

Open
tjsdn052 wants to merge 17 commits intodevfrom
refactor/canvas
Open

[FE] Canvas 리팩토링#358
tjsdn052 wants to merge 17 commits intodevfrom
refactor/canvas

Conversation

@tjsdn052
Copy link
Collaborator

@tjsdn052 tjsdn052 commented Mar 3, 2026

✅ 작업 내용

Canvas.tsx 리팩토링

  • 렌더링 책임을 레이어 단위로 분리
    • BackgroundLayer – 화이트보드 배경
    • ItemRenderingLayer – 뷰포트에 포함된 아이템 렌더링
    • CollaborationLayer – 다른 사용자 커서 및 선택 표시
    • InteractionLayer – 내 선택 박스, Transformer, 화살표/라인 핸들
    • TextEditorLayer – 캔버스 상 텍스트 에디터 (Portal 기반)
      return (
        <div>
          <Stage {...stageProps}>
            <Layer>
              <BackgroundLayer canvasWidth={width} canvasHeight={height} />
              <ItemRenderingLayer items={visibleItems} isDraggingArrow={...} />
              <CollaborationLayer items={items} stageRef={stageRef} />
              <InteractionLayer selectedItem={selectedItem} isDraggingHandle={...} />
            </Layer>
          </Stage>
      
          <TextEditorLayer editingTextId={editingTextId} />
        </div>
      );
  • 내부 로직 커스텀훅으로 분리

    • useViewportController.ts : 뷰포트 계산, 줌, 컬링, pixelRatio 관리 분리
    • useCanvasGlobalEvents.ts : 마우스/터치/휠/핀치 줌 등 캔버스 이벤트 통합
    • useCanvasShortcuts.ts : 화살표 핸들 상태를 local store로 이동 및 단축키 처리
  • 화살표 / 라인 핸들 조작시 성능 개선

    • 핸들 드래그 시 원본 아이템을 숨김 처리
    • InteractionLayer에서 임시 객체만 렌더링하도록 변경

🤔 리뷰 요구사항

  • Konva의 물리적 Layer 분리 대신, Canvas.tsx 컴포넌트의 복잡도 완화와 관심사 분리를 우선시하여 하나의 Layer 내부에서 논리적인 컴포넌트 단위로 분리했습니다.
  • 기존과 동일하게 동작하는지 확인 부탁드립니다.

tjsdn052 added 17 commits March 3, 2026 15:58
- Canvas.tsx에서 렌더링 로직 분리
- visibleItems.map 기반 RenderItem 호출 로직을 ItemRenderingLayer로 이동함
- Canvas.tsx 분리
- RemoteSelectionLayer 로직 분리
- RemoteSelectionIndicator를 CollaborationLayer로 통합
Canvas.tsx에서 분리
- 텍스트 편집 로직 분리
Canvas.tsx 에서 분리
- ArrowHandles, SnapIndicator, SelectionBox, ItemTransformer 렌더링을  InteractionLayer로 이동
- 라인 더블클릭시 핸들 정상적으로 추가되도록 수정
- 화살표 부착 및 해제 로직 개선(핸들 기존 부착 정보 currentSnapTarget에 채워지도록)
@tjsdn052 tjsdn052 self-assigned this Mar 3, 2026
@tjsdn052 tjsdn052 changed the title [FE] canvas 컴포넌트 리팩토링 [FE] Canvas 리팩토링 Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant