# `@dahyeon/editor`
React 19 기반의 **고급 Lexical Editor 컴포넌트 라이브러리**입니다.
풍부한 텍스트 편집 기능, 코드 블록 하이라이팅, 표 편집, 커스텀 스타일 등 **WYSIWYG + Markdown 성격을 섞은 Hybrid Editor**를 제공합니다.
이 라이브러리는 독립적으로 패키징되어 있으며 Tailwind 기반 스타일을 포함합니다.
---
## ✨ Features
* **Lexical 기반 Rich Editor**
* **표 삽입 / 셀 병합 / 셀 색상 변경**
* **폰트 패밀리 / 크기 지정**
* **Headings / Lists / Inline code / Code block**
* **Code highlight plugin** (Prism 기반)
* **Undo/Redo (HistoryPlugin)**
* **자동 Heading ID 생성 (TOC용)**
* **초기 콘텐츠 JSON/Plain Text 자동 파싱**
* **Tailwind 스타일 포함**
---
## 📦 Installation
먼저 Gitea npm 레지스트리를 설정해야 합니다.
프로젝트 루트에 `.npmrc` 작성:
```ini
@dahyeon:registry=https://git.dahyeon.us/api/packages/dahyeon/npm/
//git.dahyeon.us/api/packages/dahyeon/npm/:_authToken=YOUR_TOKEN
```
설치:
```bash
npm install @dahyeon/editor
# 또는
pnpm add @dahyeon/editor
```
---
## 🔤 폰트 로딩은 **호스트 애플리케이션에서 처리해야 합니다**
이 라이브러리는 편집기 내부에서 다음과 같은 `font-family`를 사용합니다:
* Noto Sans KR
* Noto Serif KR
* Gothic A1
* Gowun Batang
* Gowun Dodum
* Asta Sans
* Chiron GoRound TC
하지만 **라이브러리 내부에서는 폰트를 포함하거나 로딩하지 않습니다.**
따라서 애플리케이션에서 직접 `` 또는 `@import`로 폰트를 불러와야 합니다.
### 예: index.html (권장)
```html
```
### 또는: global.css
```css
@import url('https://fonts.googleapis.com/css2?family=Asta+Sans:wght@300..800&family=Chiron+GoRound+TC:wght@200..900&family=Gothic+A1&family=Gowun+Batang&family=Gowun+Dodum&family=Noto+Sans+KR:wght@100..900&family=Noto+Serif+KR:wght@200..900&display=swap');
```
---
## 🧩 Usage
```tsx
import { useState } from 'react';
import { LexicalEditor } from '@dahyeon/editor';
export default function Page() {
const [content, setContent] = useState('');
return (
);
}
```
---
## 🛠 Props
### `initialContent?: string`
* JSON(lexical editor state) 또는 plain text
* 컴포넌트 최초 mount 시 **1회만** 적용됨
### `onChange: (content: string) => void`
* content는 **JSON 문자열**로 반환됩니다
* plain text로 저장하려면 JSON 파싱 후 필요한 값만 사용하세요
### `placeholder?: string`
* 사용자 입력 없을 때 표시되는 placeholder 텍스트
---
## 📁 CSS 포함 정보
라이브러리는 자체적으로 다음을 포함합니다:
* Tailwind로 빌드된 최종 CSS
* Lexical 테마 스타일
* 코드 하이라이트 스타일
하지만 다음은 **포함하지 않습니다**:
* Google Fonts
→ 호스트 앱이 로딩해야 합니다.
---
## ⚙️ Requirements
* React 19+
* ReactDOM 19+
* Tailwind를 프로젝트에서 사용하지 않아도 됩니다 (CSS는 라이브러리에 포함됨)
---
## 🚀 Publishing / Versioning (Maintainer Only)
```bash
npm version patch
npm run build
npm publish
```
Gitea Packages에서 자동 등록됩니다.
---
## 📄 License
MIT
---
원하면:
* “TOC 플러그인 예시”
* “JSON → HTML 변환 가이드”
* “SSR에서 사용할 때 주의 사항”
* “Next.js + Vite + React 19 환경 예시”
같은 상세 문서도 추가해줄게.