Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 컨디셔널 렌더링
- nextjs .env
- createGlobalStyle
- react env
- react typescript
- npm styled-reset
- API 토큰
- rewrites
- dart 변수
- fetch
- There isn’t anything to compare
- getModifierState
- github io
- styled components
- Git
- next.js css
- CSS
- ngrok설치
- SCSS
- bootstrap
- icon
- nextjs 설치
- react
- API token
- nextjs
- git lab
- github
- ngrok실행
- typescript react
- input type=file
Archives
- Today
- Total
꾸준히 성장하는 개발자
[React] React editor 적용하기 - CKEditor 본문
https://ckeditor.com/docs/ckeditor5/latest/installation/getting-started/frameworks/react.html
React component - CKEditor 5 Documentation
Learn how to install, integrate and configure CKEditor 5 Builds and how to work with CKEditor 5 Framework, customize it, create your own plugins and custom editors, change the UI or even bring your own UI to the editor. API reference and examples included.
ckeditor.com
프로젝트 중 안에 에디터로 글 쓸 수 있는 게 필요하여
에디터를 찾아보는데 CKEditor 가 있어 사용하게 되었다
적용 과정 정리한다.
위 페이지를 들어가면 아래처럼 나오는데 React component로 들어가면 설치하는
명령어가 나온다
npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-classic

터미널에 입력하고 설치를 진행한다.
그리고 그 아래 상자를 보면
사용하는 예시가 작성되어 있다. 아래처럼 되어 있는데
import React, { Component } from 'react';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
class App extends Component {
render() {
return (
<div className="App">
<h2>Using CKEditor 5 build in React</h2>
<CKEditor
editor={ ClassicEditor }
data="<p>Hello from CKEditor 5!</p>"
onReady={ editor => {
// You can store the "editor" and use when it is needed.
console.log( 'Editor is ready to use!', editor );
} }
onChange={ ( event, editor ) => {
const data = editor.getData();
console.log( { event, editor, data } );
} }
onBlur={ ( event, editor ) => {
console.log( 'Blur.', editor );
} }
onFocus={ ( event, editor ) => {
console.log( 'Focus.', editor );
} }
/>
</div>
);
}
}
export default App;
보면 위에서 먼저 import를 해주는건 이렇게 두 가지를 해주도록 한다.
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
그리고 원하는 위치에 <CKEditor / > 태그로 넣어주며 작성해주면 된다.
<CKEditor
editor={ ClassicEditor }
data="<p>Hello from CKEditor 5!</p>"
onReady={ editor => {
// You can store the "editor" and use when it is needed.
console.log( 'Editor is ready to use!', editor );
} }
onChange={ ( event, editor ) => {
const data = editor.getData();
console.log( { event, editor, data } );
} }
onBlur={ ( event, editor ) => {
console.log( 'Blur.', editor );
} }
onFocus={ ( event, editor ) => {
console.log( 'Focus.', editor );
} }
/>
'React' 카테고리의 다른 글
| [React-Router] 로그인 권한에 따른 페이지 접근 막기 (0) | 2022.07.22 |
|---|---|
| [React] Login 페이지 - password CapsLock 표시 (0) | 2022.06.29 |
| [React] Login 페이지 - password 보기 기능 (0) | 2022.06.29 |
| [React] npm i path --save (0) | 2022.06.23 |
| .env 파일을 통한 환경변수 관리하기 (0) | 2022.06.22 |