[CKEditor5] Demo ์ฌ์ฉ๋ฒ
์ถํ ํ๋ก์ ํธ์ ์ฌ์ฉํ ์์ ์ด๊ธฐ์ ๋ ๊ณต๋ถํด์ผํจ...!
1. CKEditor 5 Demo ํ์ด์ง ์ ์
: ํ๋จ Source Code ์์ ์ฝ๋ ๊ฐ์ ธ์ค๊ธฐ
2. Demo ํ์ด์ง์ *๊ฐ๋ฐ์ ๋๊ตฌ*์์ HTML ๋ฐ JS ์์ค๋ฅผ ํ์ธํ๊ณ , ์๋์ ๊ฐ์ด ๊ตฌ์ฑ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CKEditor 5 Demo</title>
<script src="https://cdn.ckeditor.com/ckeditor5/41.3.1/classic/ckeditor.js"></script>
</head>
<body>
<h2>CKEditor 5 Demo</h2>
<textarea id="editor"></textarea>
<script>
ClassicEditor
.create(document.querySelector('#editor'))
.then(editor => {
console.log('CKEditor5 ๋ก๋ ์๋ฃ!', editor);
})
.catch(error => {
console.error('์๋ฌ ๋ฐ์:', error);
});
</script>
</body>
</html>
3. ์ฝ๋ ์คํ ๋ฐฉ๋ฒ
์ HTML ํ์ผ์ ์ ์ฅํ๊ณ ๋ธ๋ผ์ฐ์ ์์ ์คํํ๋ฉด CKEditor 5 Demo ๋ฒ์ ์ด ๋ก๋๋จ
โ ํน์ง
• ๋ณ๋ ์ค์น ์์ด CDN์ ์ด์ฉํด ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅ
• ๊ธฐ๋ณธ์ ์ธ ํด๋ฐ ๊ธฐ๋ฅ ์ ๊ณต (BOD, ITALIC, LINK, UNDO, REDO ๋ฑ)
• ๊ฐ๋ฐ์ ๋๊ตฌ์์ ์ฝ์๋ก editor.getData()๋ฅผ ์คํํ๋ฉด ์ ๋ ฅ๋ ๋ฐ์ดํฐ ํ์ธ ๊ฐ๋ฅ
4. ์ถ๊ฐ ๊ธฐ๋ฅ ํ์ฅ
์ปค์คํ ํด๋ฐ ์ต์ ์ค์ ๊ฐ๋ฅ
ClassicEditor
.create(document.querySelector('#editor'), {
toolbar: ['heading', '|', 'bold', 'italic', 'link', '|', 'undo', 'redo']
})
.then(editor => {
console.log('์๋ํฐ ์ด๊ธฐํ ์๋ฃ');
})
.catch(error => console.error('์๋ฌ:', error));
5. ๋ง๋ฌด๋ฆฌ
โ CDN์ ํ์ฉํด ๊ฐํธํ๊ฒ ํ ์คํธํ ์ ์๋ ๋ฐฉ์
โ ๊ฐ๋จํ HTML ํ์ผ๋ง์ผ๋ก ์คํ ๊ฐ๋ฅ, ๊ฐ๋ฐ์ ๋๊ตฌ์์ ์์ค๋ฅผ ์ฐธ๊ณ ํด ํ์ฅ ๊ฐ๋ฅ