Skip to content

워크벤치 쉘 & 컨텍스트 메뉴 ​

1. 6-슬롯 EdgeBar · TopBar · StatusBar ​

text
┌───────────────────────────────────────────────────────────────────┐
│ TopBar (logo · title · menus · left / right custom slots)         │
├──┬───────────────┬─────────────────────────────┬───────────────┬──┤
│LT│  leftTop      │                             │  rightTop     │RT│
│LB│  leftBottom   │   Protected Contents Stage  │  rightBottom  │RB│
│  ├───────────────┴─────────────────────────────┴───────────────┤  │
│BL│        bottomLeft         │         bottomRight             │BR│
├──┴───────────────────────────┴─────────────────────────────────┴──┤
│ StatusBar (left / right custom slots)                             │
└───────────────────────────────────────────────────────────────────┘
  • 6-슬롯 EdgeBar: 외곽 6개 슬롯(leftTopEdgeBar, leftBottomEdgeBar, rightTopEdgeBar, rightBottomEdgeBar, bottomLeftEdgeBar, bottomRightEdgeBar)에 접이식 도구 패널을 배치하고 클릭·드래그로 전환합니다.
  • EdgeBar 아이콘 우클릭 메뉴: 숨기기, 6-슬롯 간 이동(controller.moveViewToEdgeSlot()), 플로팅/팝아웃 분리, 도구 창 라벨 표시 토글(controller.setEdgeBarLabelsVisible())을 기본 제공합니다.
  • TopBar & StatusBar: topBar.menus에 메뉴 배열만 선언하면 다단계 서브메뉴(items), 니모닉 밑줄 표기('File(F)'), 단축키 힌트(shortcut), 클릭 액션(action(controller))을 갖춘 데스크톱 메뉴바가 자동 생성되며, 좌/우 커스텀 슬롯(left, right)에 프레임워크 컴포넌트를 주입할 수 있습니다.
ts
import { RedDokiaIcons, type RedDokiaLayoutSchema } from 'reddokia';
import TopBarRight from './TopBarRight';
import StatusBarRight from './StatusBarRight';

export const layoutSchema: RedDokiaLayoutSchema = {
  topBar: {
    logoText: 'RD',
    title: 'RedDokia Studio',
    menus: [
      {
        label: 'File(F)',
        items: [
          {
            label: 'New Tab(N)',
            icon: RedDokiaIcons.Plus,
            shortcut: 'Ctrl+N',
            action: (ctrl) =>
              ctrl.openView(`doc-${Date.now()}`, {
                templateId: 'editor',
                title: 'Untitled.ts',
              }),
          },
          {
            label: 'Reset Layout',
            dividerBefore: true,
            action: (ctrl) => ctrl.resetLayout(),
          },
        ],
      },
      {
        label: 'View(V)',
        items: [
          {
            label: 'Theme',
            items: [
              { label: 'Dark', action: (ctrl) => ctrl.setTheme('dark') },
              { label: 'Light', action: (ctrl) => ctrl.setTheme('light') },
            ],
          },
        ],
      },
    ],
    right: TopBarRight,
  },
  contents: ['editor', 'preview'],
  statusBar: {
    right: StatusBarRight,
  },
};

2. 그룹 헤더 커스텀 액션 (groupActions) ​

전역 groupActions로 모든 그룹 헤더 우측에 공통 버튼을 배치하고, viewSchema.groupActions로 특정 뷰 활성 시 전용 액션으로 교체합니다(templateId 탭에 자동 상속).

tsx
const views = [
  { id: 'global-actions-tab', title: 'Global Actions', component: Panel },
  {
    id: 'per-view-actions-tab',
    title: 'Per-View Actions',
    groupActions: PerViewActions, // 이 탭이 활성화되면 헤더 액션 자동 전환
    component: Panel,
  },
];

<RedDokia views={views} layout={layout} groupActions={GlobalGroupActions} />;

3. 탭 우클릭 컨텍스트 메뉴 (tabContextMenu) ​

전역 tabContextMenu와 뷰별 viewSchema.tabContextMenu는 동일한 RedDokiaTabContextMenuOption 타입을 사용합니다.

  • 단축형 (append): 배열 또는 콜백을 전달하면 기본 메뉴 뒤에 추가됩니다.
  • 객체형 ({ mode: 'replace', items }): 기본 메뉴를 대체하며, 필요 시 콜백의 defaultItems에서 일부만 조합합니다.
  • 우선순위: viewSchema.tabContextMenu가 전역 설정보다 우선합니다(templateId 복제 탭에 상속).
ts
// 1) viewSchema에 뷰 전용 우클릭 메뉴 정의 (전역보다 우선 적용)
const views = [
  {
    id: 'per-view-menu-tab',
    title: 'Per-View Menu',
    tabContextMenu: {
      mode: 'replace',
      items: ({ defaultItems, viewId, controller }) => [
        {
          id: 'mark-verified',
          label: 'Mark Verified',
          icon: RedDokiaIcons.CheckCircle2,
          action: () => controller.updateView(viewId, { badge: 'OK' }),
        },
        // 필요하면 defaultItems에서 원하는 기본 항목만 선별해 조합 가능
        ...defaultItems.filter((item) => item.id === 'close-tab'),
      ],
    },
  },
];

// 2) 전역 기본 정책 (개별 정의가 없는 탭에 적용)
<RedDokia
  views={views}
  layout={layout}
  tabContextMenu={({ viewId, controller }) => [
    {
      id: 'mark-verified',
      label: 'Mark Verified',
      icon: RedDokiaIcons.CheckCircle2,
      dividerBefore: true,
      action: () => controller.updateView(viewId, { badge: 'OK' }),
    },
  ]}
/>

4. 다음 단계: 테마 & 다국어 ​

커스텀 themes, themeTokens, 다국어 설정은 테마 · 디자인 토큰 & 다국어 가이드를 참고하세요.