Loading...
Loading...
설치하고, 편집기를 생성하고, 저장된 콘텐츠를 표시합니다.
<!-- 1. Include CSS -->
<link href="https://cdn.jsdelivr.net/npm/suneditor@3.0.0/dist/css/suneditor.min.css" rel="stylesheet">
<!-- 2. Include JS -->
<script src="https://cdn.jsdelivr.net/npm/suneditor@3.0.0/dist/suneditor.min.js"><\/script>
<!-- 3. Create Textarea -->
<textarea id="my-editor"></textarea>
<!-- 4. Create Editor -->
<script>
const editor = SUNEDITOR.create("my-editor", {
plugins: SUNEDITOR.plugins,
value: "<p>Hello SunEditor</p>",
buttonList: [
["undo", "redo"],
"|",
["bold", "italic", "underline"],
"|",
["list", "link", "image"]
]
});
<\/script>편집기에서 생성된 HTML을 표시할 때 CSS 및 클래스 이름이 필요합니다.
<!-- 1. SunEditor contents CSS required -->
<link href="https://cdn.jsdelivr.net/npm/suneditor@3.0.0/dist/css/suneditor-contents.min.css" rel="stylesheet">
<!-- 2. sun-editor-editable Wrap with class -->
<div class="sun-editor-editable">
<!-- HTML from editor.getContents() -->
</div>에디터 인스턴스는 모든 내부 하위 시스템(L1→L2→L3)을 포함하는 종속성 모음인 `$` 객체를 노출합니다.
const editor = SunEditor.create('textarea', { /* options */ });
// $ — dependency bag (all internals)
editor.$.selection // Selection handler
editor.$.format // Block formatting
editor.$.history // Undo/Redo stack
// ... and more