Loading...
Loading...
Установите, создайте редактор и отобразите сохраненный контент.
<!-- 1. Include CSS -->
<link href="https://cdn.jsdelivr.net/npm/suneditor@3.4.3/dist/suneditor.min.css" rel="stylesheet">
<!-- 2. Include JS -->
<script src="https://cdn.jsdelivr.net/npm/suneditor@3.4.3/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.4.3/dist/suneditor-contents.min.css" rel="stylesheet">
<!-- 2. sun-editor-editable Wrap with class -->
<div class="sun-editor-editable">
<!-- HTML from editor.$.html.get() -->
</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Реальный импорт npm, полноценный сборщик — редактируйте код и мгновенно видите результат.
Playground