@ubermensch1218/hwpxeditor 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -0
- package/dist/index.cjs +9866 -1583
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +266 -8
- package/dist/index.d.ts +266 -8
- package/dist/index.js +9879 -1592
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# @ubermensch1218/hwpxeditor
|
|
2
|
+
|
|
3
|
+
한글 워드프로세서 스타일의 UI를 제공하는 React 에디터 컴포넌트 라이브러리입니다.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@ubermensch1218/hwpxeditor)
|
|
6
|
+
|
|
7
|
+
## 설치
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @ubermensch1218/hwpxeditor react react-dom
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
또는 yarn:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @ubermensch1218/hwpxeditor react react-dom
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 동료 의존성 (Peer Dependencies)
|
|
20
|
+
|
|
21
|
+
- `react` >= 18
|
|
22
|
+
- `react-dom` >= 18
|
|
23
|
+
|
|
24
|
+
## 주요 기능
|
|
25
|
+
|
|
26
|
+
- **리본 툴바** - MS Word 스타일의 리본 인터페이스로 자주 사용하는 기능에 빠르게 접근
|
|
27
|
+
- **문자/문단 포맷 사이드바** - 오른쪽 사이드바에서 세밀한 포맷 설정 가능
|
|
28
|
+
- **수평 자** - 문단 들여쓰기와 탭 위치 시각화 및 조정
|
|
29
|
+
- **WYSIWYG 편집** - 실제 출력 형태 그대로 보며 편집
|
|
30
|
+
- **표 지원** - 표 생성, 셀 병합, 행/열 추가/삭제
|
|
31
|
+
- **이미지 삽입** - 문서에 이미지 삽입 가능
|
|
32
|
+
- **내장 상태 관리** - Zustand를 기반한 통합 상태 관리
|
|
33
|
+
- **RSC 호환** - Next.js App Router 지원 ("use client" 배너 포함)
|
|
34
|
+
|
|
35
|
+
## 사용 예제
|
|
36
|
+
|
|
37
|
+
### 기본 사용 (Full Editor)
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Editor } from '@ubermensch1218/hwpxeditor';
|
|
41
|
+
|
|
42
|
+
export default function App() {
|
|
43
|
+
return (
|
|
44
|
+
<div className="w-full h-screen">
|
|
45
|
+
<Editor />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Next.js App Router에서 사용
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
'use client';
|
|
55
|
+
|
|
56
|
+
import { Editor } from '@ubermensch1218/hwpxeditor';
|
|
57
|
+
|
|
58
|
+
export default function EditorPage() {
|
|
59
|
+
return <Editor />;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Tailwind CSS 설정
|
|
64
|
+
|
|
65
|
+
이 라이브러리는 Tailwind CSS 유틸리티 클래스를 사용합니다. Tailwind CSS를 설정한 후 `tailwind.config.js`의 `content` 배열에 라이브러리 경로를 추가하세요:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// tailwind.config.js
|
|
69
|
+
export default {
|
|
70
|
+
content: [
|
|
71
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
72
|
+
'./node_modules/@ubermensch1218/hwpxeditor/dist/**/*.js',
|
|
73
|
+
],
|
|
74
|
+
theme: {
|
|
75
|
+
extend: {},
|
|
76
|
+
},
|
|
77
|
+
plugins: [],
|
|
78
|
+
};
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**중요:** `content` 설정이 없으면 에디터의 스타일이 적용되지 않습니다.
|
|
82
|
+
|
|
83
|
+
## 개별 컴포넌트 사용
|
|
84
|
+
|
|
85
|
+
전체 에디터를 사용하지 않고 개별 컴포넌트만 사용할 수도 있습니다:
|
|
86
|
+
|
|
87
|
+
### 에디터 컴포넌트
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import {
|
|
91
|
+
PageView,
|
|
92
|
+
ParagraphBlock,
|
|
93
|
+
TableBlock
|
|
94
|
+
} from '@ubermensch1218/hwpxeditor';
|
|
95
|
+
|
|
96
|
+
export function CustomEditor() {
|
|
97
|
+
return (
|
|
98
|
+
<div className="flex gap-4">
|
|
99
|
+
<div className="flex-1">
|
|
100
|
+
<PageView />
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 툴바 컴포넌트
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import {
|
|
111
|
+
RibbonToolbar,
|
|
112
|
+
SecondaryToolbar,
|
|
113
|
+
ToolbarButton,
|
|
114
|
+
ToolbarDropdown
|
|
115
|
+
} from '@ubermensch1218/hwpxeditor';
|
|
116
|
+
|
|
117
|
+
export function MyToolbar() {
|
|
118
|
+
return (
|
|
119
|
+
<div>
|
|
120
|
+
<RibbonToolbar />
|
|
121
|
+
<SecondaryToolbar />
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 사이드바 컴포넌트
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { FormatSidebar } from '@ubermensch1218/hwpxeditor';
|
|
131
|
+
|
|
132
|
+
export function MySidebar() {
|
|
133
|
+
return <FormatSidebar />;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 자 컴포넌트
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
import { HorizontalRuler } from '@ubermensch1218/hwpxeditor';
|
|
141
|
+
|
|
142
|
+
export function MyRuler() {
|
|
143
|
+
return <HorizontalRuler />;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 주요 내보내기 (Exports)
|
|
148
|
+
|
|
149
|
+
### 에디터 컴포넌트
|
|
150
|
+
|
|
151
|
+
- `Editor` - 전체 에디터 (완전 통합)
|
|
152
|
+
- `PageView` - 페이지 뷰
|
|
153
|
+
- `Page` - 단일 페이지
|
|
154
|
+
- `ParagraphBlock` - 문단 렌더링
|
|
155
|
+
- `RunSpan` - 텍스트 실행 (문자 속성)
|
|
156
|
+
- `ImageBlock` - 이미지 렌더링
|
|
157
|
+
- `TableBlock` - 표 렌더링
|
|
158
|
+
- `TableCell` - 표 셀
|
|
159
|
+
|
|
160
|
+
### 툴바 컴포넌트
|
|
161
|
+
|
|
162
|
+
- `RibbonToolbar` - 리본 툴바
|
|
163
|
+
- `SecondaryToolbar` - 2차 포맷 툴바
|
|
164
|
+
- `ToolbarButton` - 툴바 버튼
|
|
165
|
+
- `ToolbarDropdown` - 드롭다운 메뉴
|
|
166
|
+
- `ColorPicker` - 색상 선택기
|
|
167
|
+
- `RibbonGroup` - 리본 그룹
|
|
168
|
+
- `ClipboardGroup` - 복사/붙여넣기 그룹
|
|
169
|
+
- `InsertGroup` - 삽입 그룹
|
|
170
|
+
- `StyleSelector` - 스타일 선택
|
|
171
|
+
- `FontSelector` - 글꼴 선택
|
|
172
|
+
- `FontSizeInput` - 글자 크기 입력
|
|
173
|
+
- `CharFormatButtons` - 문자 포맷 버튼 (굵게, 기울임 등)
|
|
174
|
+
- `AlignmentButtons` - 정렬 버튼
|
|
175
|
+
- `LineSpacingControl` - 줄간격 제어
|
|
176
|
+
|
|
177
|
+
### 사이드바 컴포넌트
|
|
178
|
+
|
|
179
|
+
- `FormatSidebar` - 포맷 사이드바
|
|
180
|
+
- `SidebarSection` - 사이드바 섹션
|
|
181
|
+
- `SidebarField` - 사이드바 필드
|
|
182
|
+
- `CharFormatPanel` - 문자 포맷 패널
|
|
183
|
+
- `ParaFormatPanel` - 문단 포맷 패널
|
|
184
|
+
- `BorderSettings` - 테두리 설정
|
|
185
|
+
- `BackgroundSettings` - 배경 설정
|
|
186
|
+
|
|
187
|
+
### 기타
|
|
188
|
+
|
|
189
|
+
- `HorizontalRuler` - 수평 자
|
|
190
|
+
- `FileUpload` - 파일 업로드
|
|
191
|
+
- `NewDocumentButton` - 새 문서 버튼
|
|
192
|
+
- `useEditorStore` - 에디터 상태 관리 훅
|
|
193
|
+
- `buildViewModel` - 뷰 모델 생성
|
|
194
|
+
|
|
195
|
+
### 상수 및 유틸리티
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import {
|
|
199
|
+
FONT_FAMILIES, // 사용 가능한 글꼴 목록
|
|
200
|
+
FONT_SIZES, // 사용 가능한 글자 크기
|
|
201
|
+
STYLE_PRESETS, // 스타일 프리셋
|
|
202
|
+
ALIGNMENT_OPTIONS, // 정렬 옵션
|
|
203
|
+
LINE_SPACING_OPTIONS,// 줄간격 옵션
|
|
204
|
+
UNDERLINE_TYPES, // 밑줄 종류
|
|
205
|
+
COLOR_PRESETS, // 색상 프리셋
|
|
206
|
+
HIGHLIGHT_COLORS, // 형광펜 색상
|
|
207
|
+
} from '@ubermensch1218/hwpxeditor';
|
|
208
|
+
|
|
209
|
+
import {
|
|
210
|
+
hwpToPx, // hwp 단위를 픽셀로 변환
|
|
211
|
+
pxToHwp, // 픽셀을 hwp 단위로 변환
|
|
212
|
+
hwpToMm, // hwp 단위를 mm로 변환
|
|
213
|
+
mmToHwp, // mm를 hwp 단위로 변환
|
|
214
|
+
extractImages, // 문서에서 이미지 추출
|
|
215
|
+
ensureSkeletonLoaded,// 템플릿 미리로드
|
|
216
|
+
createNewDocument, // 새 문서 생성
|
|
217
|
+
} from '@ubermensch1218/hwpxeditor';
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## 상태 관리 (Store)
|
|
221
|
+
|
|
222
|
+
에디터는 `useEditorStore` 훅으로 상태를 관리합니다:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import { useEditorStore } from '@ubermensch1218/hwpxeditor';
|
|
226
|
+
|
|
227
|
+
export function MyComponent() {
|
|
228
|
+
const doc = useEditorStore((s) => s.doc);
|
|
229
|
+
const loading = useEditorStore((s) => s.loading);
|
|
230
|
+
const selection = useEditorStore((s) => s.selection);
|
|
231
|
+
const toggleBold = useEditorStore((s) => s.toggleBold);
|
|
232
|
+
const saveDocument = useEditorStore((s) => s.saveDocument);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<div>
|
|
236
|
+
{loading && <p>로딩 중...</p>}
|
|
237
|
+
{doc && <p>문서 로드됨: {doc.sections.length} 섹션</p>}
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Store 주요 메서드
|
|
244
|
+
|
|
245
|
+
- `setDocument(doc)` - HwpxDocument 설정
|
|
246
|
+
- `saveDocument()` - 문서 저장 (hwpx 파일 다운로드)
|
|
247
|
+
- `addParagraph(text)` - 문단 추가
|
|
248
|
+
- `addTable(sectionIndex, paragraphIndex, rows, cols)` - 표 추가
|
|
249
|
+
- `insertImage(data, mediaType, widthMm, heightMm)` - 이미지 삽입
|
|
250
|
+
- `toggleBold()`, `toggleItalic()`, `toggleUnderline()` - 스타일 토글
|
|
251
|
+
- `toggleSidebar()`, `setSidebarTab(tab)` - UI 상태 관리
|
|
252
|
+
|
|
253
|
+
## 의존성
|
|
254
|
+
|
|
255
|
+
### 직접 의존성
|
|
256
|
+
|
|
257
|
+
- `@ubermensch1218/hwpxcore` - HWPX 문서 처리 (같은 모노레포)
|
|
258
|
+
- `lucide-react` - 아이콘 라이브러리
|
|
259
|
+
- `zustand` - 상태 관리 라이브러리
|
|
260
|
+
|
|
261
|
+
### 개발 의존성 (필요시만)
|
|
262
|
+
|
|
263
|
+
- `react` >= 18
|
|
264
|
+
- `react-dom` >= 18
|
|
265
|
+
- `tailwindcss` >= 4
|
|
266
|
+
- `next` >= 16 (Next.js 사용 시)
|
|
267
|
+
|
|
268
|
+
## 라이선스
|
|
269
|
+
|
|
270
|
+
MIT License
|