BarnamenevisEditor Examples

Practical examples showing different configurations and use cases

Example 1: Basic Editor

Simple editor with default settings

Show Code
$('#example1').barnamenevisEditor({ language: 'en' });

Example 2: Minimal Toolbar

Editor with minimal toolbar for simple formatting

Show Code
$('#example2').barnamenevisEditor({
    language: 'en',
    toolbar: 'minimal',
    height: '250px'
});

Example 3: Live Preview

Editor with live HTML preview

Preview:
Show Code
$('#example3').barnamenevisEditor({
    language: 'en',
    height: '250px',
    onChange: function(content) {
        $('#preview3').html(content);
    }
});

Example 4: Custom Toolbar Configuration

Editor with custom toolbar buttons

Show Code
$('#example4').barnamenevisEditor({
    height: '250px',
    toolbar: [
        ['bold', 'italic', 'underline'],
        ['forecolor', 'backcolor'],
        ['insertLink'],
        ['undo', 'redo']
    ]
});

Example 5: Blog Post Editor

Full-featured editor for blog posts

Show Code
$('#example5').barnamenevisEditor({
    height: '400px',
    toolbar: 'full'
});

$('#saveBlogPost').on('click', function() {
    var title = $('#postTitle').val();
    var content = $('#example5').barnamenevisEditor('getContent');
    console.log('Title:', title);
    console.log('Content:', content);
    showBootstrapAlert('success', window.BarnamenevisEditor.lang.en.messages.blogPostSaved);
});

Example 6: Email Composer

Email-style editor with recipient fields

Show Code
$('#example6').barnamenevisEditor({
    height: '300px',
    toolbar: 'basic'
});

Example 7: Comment Editor (Compact)

Compact editor for comments

Show Code
$('#example7').barnamenevisEditor({
    height: '150px',
    toolbar: 'minimal'
});

$('#postComment').on('click', function() {
    var comment = $('#example7').barnamenevisEditor('getContent');
    $('#commentsDisplay').append(
        '<div class="alert alert-secondary">' + comment + '</div>'
    );
    $('#example7').barnamenevisEditor('clear');
});

Example 8: Read-Only Mode

Editor in read-only mode (disabled)

Show Code
$('#example8').barnamenevisEditor({
    height: '200px'
});

// Disable on load
$('#example8').barnamenevisEditor('disable');

// Toggle edit mode
$('#toggleEdit').on('click', function() {
    // Toggle between enable and disable
});

Example 9: Dark Theme

Editor with dark theme

Show Code
$('#example9').barnamenevisEditor({
    height: '200px',
    theme: 'dark'
});

Example 10: Form Integration

Editor integrated with a form submission

Show Code
$('#example10').barnamenevisEditor({
    height: '250px'
});

$('#contentForm').on('submit', function(e) {
    e.preventDefault();
    var formData = {
        name: $('[name="name"]').val(),
        email: $('[name="email"]').val(),
        message: $('#example10').barnamenevisEditor('getContent')
    };
    console.log('Form Data:', formData);
    $('#formResult').html(
        '<div class="alert alert-success">Form submitted successfully!</div>'
    );
});

Example 11: Persian (RTL) Editor with Custom Fonts

ویرایشگر فارسی با پشتیبانی کامل از راست‌به‌چپ و فونت‌های سفارشی

نمایش کد
// Include Persian language file
<script src="js/lang/fa.js"></script>

// Load custom Persian fonts
<link rel="stylesheet" href="fonts/mikhak/Mikhak.css">
<link rel="stylesheet" href="fonts/sahel/Sahel.css">

// Initialize with Persian language and custom fonts
$('#example11').barnamenevisEditor({
    language: 'fa',
    height: '500px',
    toolbar: 'full',
    fontFamilies: [
        'Tahoma',
        'Arial',
        { displayName: 'میخک (Mikhak)', value: 'Mikhak, Tahoma, sans-serif' },
        { displayName: 'ساحل (Sahel)', value: 'Sahel, Tahoma, sans-serif' },
        { displayName: 'وزیر (Vazir)', value: 'Vazirmatn, Tahoma, sans-serif' }
    ]
});