Compare commits
2
Commits
4e81b97e4c
...
d3ca3a6e34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3ca3a6e34 | ||
|
|
6fd28b87b3 |
No files matched your search
@@ -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
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
먼저 Gitea npm 레지스트리를 설정해야 합니다.
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
프로젝트 루트에 `.npmrc` 작성:
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```ini
|
||||
@dahyeon:registry=https://git.dahyeon.us/api/packages/dahyeon/npm/
|
||||
//git.dahyeon.us/api/packages/dahyeon/npm/:_authToken=YOUR_TOKEN
|
||||
```
|
||||
|
||||
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
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
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...
|
||||
},
|
||||
},
|
||||
])
|
||||
```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
|
||||
|
||||
하지만 **라이브러리 내부에서는 폰트를 포함하거나 로딩하지 않습니다.**
|
||||
따라서 애플리케이션에서 직접 `<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 환경 예시”
|
||||
|
||||
같은 상세 문서도 추가해줄게.
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@dahyeon/editor",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@dahyeon/editor",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"dependencies": {
|
||||
"@lexical/html": "^0.38.2",
|
||||
"@lexical/list": "^0.38.2",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@dahyeon/editor",
|
||||
"private": false,
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"registry": "https://git.dahyeon.us/api/packages/dahyeon/npm/"
|
||||
|
||||
+1
-1
@@ -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";
|
||||
|
||||
|
||||
Reference in new issue
Block a user