Menu โ–พ โ–ด

Getting Started

neikiri

๐Ÿš€ Getting Started

Get Neiki's Editor running in your project in under 2 minutes.


๐Ÿ“ฆ Installation

One line. CSS is bundled automatically. Always loads the latest version:

<script src="https://cdn.neikiri.dev/neiki-editor/neiki-editor.min.js"></script>

Option 2 โ€” Pin a Specific Version

<script src="https://cdn.neikiri.dev/neiki-editor/3.0.3/neiki-editor.min.js"></script>

Option 3 โ€” Separate CSS + JS

<!-- Latest -->
<link rel="stylesheet" href="https://cdn.neikiri.dev/neiki-editor/neiki-editor.css">
<script src="https://cdn.neikiri.dev/neiki-editor/neiki-editor.js"></script>

<!-- Pinned to 3.0.3 -->
<link rel="stylesheet" href="https://cdn.neikiri.dev/neiki-editor/3.0.3/neiki-editor.css">
<script src="https://cdn.neikiri.dev/neiki-editor/3.0.3/neiki-editor.js"></script>

Option 4 โ€” jsDelivr (Alternative CDN)

<!-- Latest -->
<script src="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@latest/dist/neiki-editor.min.js"></script>

<!-- Pinned -->
<script src="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@3.0.3/dist/neiki-editor.min.js"></script>

Option 5 โ€” Self-Hosted

Download the files from GitHub Releases and serve them locally:

<script src="/assets/neiki-editor.min.js"></script>

Option 6 โ€” npm / Package Manager

npm install neiki-editor
# or
yarn add neiki-editor

Option 7 โ€” PHP Helper

<?php require_once 'php/neiki-editor.php'; ?>
<head>
    <?= NeikiEditor::assets() ?>
</head>

[!NOTE]
The PHP helper outputs both CSS and JS tags and prevents duplicate includes. See the Integration Guide for full PHP details.


โšก Quick Start

Step 1 โ€” Add a <textarea>

<textarea id="my-editor">
    <p>Hello, world!</p>
</textarea>

Any HTML content inside the textarea is loaded automatically.

Step 2 โ€” Initialize

<script>
    const editor = new NeikiEditor('#my-editor');
</script>

That's it. The textarea is replaced with a full WYSIWYG editor.

[!IMPORTANT]
Always load the CSS before the JS file. The editor needs styles to render correctly during initialization.


๐Ÿงช Complete Working Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neiki's Editor Demo</title>
    <script src="https://cdn.neikiri.dev/neiki-editor/neiki-editor.min.js"></script>
</head>
<body>
    <h1>My Editor</h1>
    <textarea id="editor">
        <p>Start writing something amazing...</p>
    </textarea>

    <script>
        const editor = new NeikiEditor('#editor', {
            placeholder: 'Type here...',
            minHeight: 400,
            theme: 'light',
            onChange: function(content) {
                console.log('Content changed!');
            }
        });
    </script>
</body>
</html>

๐ŸŽฏ Initialization Targets

The editor can be attached to different element types:

Textarea (most common)

<textarea id="editor"></textarea>
<script>new NeikiEditor('#editor');</script>

Div with existing content

<div id="editor"><p>Existing content</p></div>
<script>new NeikiEditor('#editor');</script>

By DOM reference

const element = document.getElementById('editor');
const editor = new NeikiEditor(element);

Multiple editors on one page

const editor1 = new NeikiEditor('#editor-1', { theme: 'light' });
const editor2 = new NeikiEditor('#editor-2', { theme: 'dark', minHeight: 200 });

๐Ÿ”„ Getting Content Back

Retrieve the edited content for saving or processing:

// Get HTML string
const html = editor.getContent();

// Get plain text (no HTML tags)
const text = editor.getText();

// Check if editor is empty
const empty = editor.isEmpty();

// Get structured JSON
const json = editor.getJSON();

Common Pattern โ€” Save on Form Submit

<form id="my-form">
    <textarea id="editor"></textarea>
    <button type="submit">Save</button>
</form>

<script>
    const editor = new NeikiEditor('#editor');

    document.getElementById('my-form').addEventListener('submit', function(e) {
        e.preventDefault();
        const content = editor.getContent();
        // send content to your backend...
    });
</script>

Common Pattern โ€” Real-time Sync via onChange

const editor = new NeikiEditor('#editor', {
    onChange: function(content) {
        document.getElementById('preview').innerHTML = content;
    }
});

๐Ÿ”— What's Next?

โš™๏ธ Configuration Customize every aspect of the editor
๐Ÿ”ง Toolbar Reference See all 30+ toolbar buttons
๐Ÿ“‹ API Reference All methods and callbacks
๐Ÿ”— Integration Guide PHP, Vue.js, React examples