Compare commits

...
2 Commits
Author SHA1 Message Date
dahyeon d3ca3a6e34 Initializes @dahyeon/editor library
Initializes the `@dahyeon/editor` library, a React 19-based rich text editor component.

This commit introduces the library with features like table editing, code highlighting, custom styles, and hybrid WYSIWYG/Markdown functionality.

It also includes installation instructions, font loading requirements, usage examples, and details about CSS inclusion and requirements.

Removes font imports from the library's CSS to enforce external font loading.
2025-11-18 08:29:22 +00:00
dahyeon 6fd28b87b3 0.0.2 2025-11-18 08:26:21 +00:00
4 changed files with 154 additions and 63 deletions

No files matched your search

+150 -59
View File
@@ -1,73 +1,164 @@
# React + TypeScript + Vite # `@dahyeon/editor`
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. React 19 기반의 **고급 Lexical Editor 컴포넌트 라이브러리**입니다.
풍부한 텍스트 편집 기능, 코드 블록 하이라이팅, 표 편집, 커스텀 스타일 등 **WYSIWYG + Markdown 성격을 섞은 Hybrid Editor**를 제공합니다.
Currently, two official plugins are available: 이 라이브러리는 독립적으로 패키징되어 있으며 Tailwind 기반 스타일을 포함합니다.
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh ---
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## React Compiler ## ✨ Features
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). * **Lexical 기반 Rich Editor**
* **표 삽입 / 셀 병합 / 셀 색상 변경**
* **폰트 패밀리 / 크기 지정**
* **Headings / Lists / Inline code / Code block**
* **Code highlight plugin** (Prism 기반)
* **Undo/Redo (HistoryPlugin)**
* **자동 Heading ID 생성 (TOC용)**
* **초기 콘텐츠 JSON/Plain Text 자동 파싱**
* **Tailwind 스타일 포함**
## Expanding the ESLint configuration ---
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: ## 📦 Installation
```js 먼저 Gitea npm 레지스트리를 설정해야 합니다.
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this 프로젝트 루트에 `.npmrc` 작성:
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs... ```ini
], @dahyeon:registry=https://git.dahyeon.us/api/packages/dahyeon/npm/
languageOptions: { //git.dahyeon.us/api/packages/dahyeon/npm/:_authToken=YOUR_TOKEN
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
``` ```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: 설치:
```js ```bash
// eslint.config.js npm install @dahyeon/editor
import reactX from 'eslint-plugin-react-x' # 또는
import reactDom from 'eslint-plugin-react-dom' pnpm add @dahyeon/editor
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
``` ```
---
## 🔤 폰트 로딩은 **호스트 애플리케이션에서 처리해야 합니다**
이 라이브러리는 편집기 내부에서 다음과 같은 `font-family`를 사용합니다:
* Noto Sans KR
* Noto Serif KR
* Gothic A1
* Gowun Batang
* Gowun Dodum
* Asta Sans
* Chiron GoRound TC
하지만 **라이브러리 내부에서는 폰트를 포함하거나 로딩하지 않습니다.**
따라서 애플리케이션에서 직접 `<link>` 또는 `@import`로 폰트를 불러와야 합니다.
### 예: index.html (권장)
```html
<link
href="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"
rel="stylesheet"
/>
```
### 또는: 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 (
<LexicalEditor
initialContent={content}
onChange={setContent}
placeholder="여기에 내용을 입력하세요…"
/>
);
}
```
---
## 🛠 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 환경 예시”
같은 상세 문서도 추가해줄게.
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@dahyeon/editor", "name": "@dahyeon/editor",
"version": "0.0.1", "version": "0.0.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@dahyeon/editor", "name": "@dahyeon/editor",
"version": "0.0.1", "version": "0.0.2",
"dependencies": { "dependencies": {
"@lexical/html": "^0.38.2", "@lexical/html": "^0.38.2",
"@lexical/list": "^0.38.2", "@lexical/list": "^0.38.2",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@dahyeon/editor", "name": "@dahyeon/editor",
"private": false, "private": false,
"version": "0.0.1", "version": "0.0.2",
"type": "module", "type": "module",
"publishConfig": { "publishConfig": {
"registry": "https://git.dahyeon.us/api/packages/dahyeon/npm/" "registry": "https://git.dahyeon.us/api/packages/dahyeon/npm/"
+1 -1
View File
@@ -1,4 +1,4 @@
@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'); /* @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'); */
@import "tailwindcss"; @import "tailwindcss";