<?php $__env->startSection('css'); ?>
    <!-- Froala Editor CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/froala-editor@3.2.6/css/froala_style.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/froala-editor@3.2.6/css/froala_editor.pkgd.min.css">
    <!-- Froala Editor JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/froala-editor@3.2.6/js/froala_editor.pkgd.min.js"></script>
<?php $__env->stopSection(); ?>

<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag; ?>
<?php foreach($attributes->onlyProps(['height', 'full', 'form_id', 'id', 'validate']) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
} ?>
<?php $attributes = $attributes->exceptProps(['height', 'full', 'form_id', 'id', 'validate']); ?>
<?php foreach (array_filter((['height', 'full', 'form_id', 'id', 'validate']), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
} ?>
<?php $__defined_vars = get_defined_vars(); ?>
<?php foreach ($attributes as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
} ?>
<?php unset($__defined_vars); ?>
<textarea <?php echo e($attributes->merge(['id' => $id])); ?>>
               
</textarea>


<script>
    var height = <?php echo json_encode($height, 15, 512) ?>;
    var editor = new FroalaEditor('#<?php echo e($id); ?>', {
        <?php if(!$full): ?>
            toolbarButtons: {
                'moreText': {
                    'buttons': ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript',
                        'fontFamily', 'fontSize', 'textColor', 'backgroundColor', 'inlineClass',
                        'inlineStyle', 'clearFormatting'
                    ]
                },
                'moreParagraph': {
                    'buttons': ['alignLeft', 'alignCenter', 'alignRight', 'alignJustify', 'indent',
                        'outdent', 'lineHeight'
                    ]
                }
            },
            imageInsertButtons: ['imageBack', '|', 'imageUpload', 'imageByURL'],
            imageUpload: false,
            imageUploadURL: '/your-file-upload-endpoint',
        <?php endif; ?>

        height: height
    });
</script>

<?php if($validate): ?>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var form = document.getElementById('<?php echo e($form_id); ?>');
            if (form) {
                form.addEventListener('submit', function(event) {
                    var editorContent = new FroalaEditor('#<?php echo e($id); ?>').html.get();
                    var validationMessage = document.querySelector('.validation-message');

                    if (editorContent.trim().length === 0) {
                        // Create a new span element for the validation message
                        var span = document.createElement('span');
                        span.textContent = 'Editor must be required';
                        span.className = 'help-block validation-message';

                        // Check if a validation message already exists
                        if (validationMessage) {
                            // Replace the existing validation message with the new one
                            validationMessage.replaceWith(span);
                        } else {
                            // Append the new validation message after the editor tag
                            var editor = document.querySelector('#<?php echo e($id); ?>');
                            editor.parentNode.insertBefore(span, editor.nextSibling);
                        }

                        // Prevent form submission
                        event.preventDefault();
                    } else {
                        // Remove any existing validation message
                        if (validationMessage) {
                            validationMessage.remove();
                        }

                        // Form submission will proceed normally
                    }
                });
            }
        });
    </script>
<?php endif; ?>
<?php /**PATH /home/khawajashipping/mrglogisticsbd.com/resources/views/components/backend/editor.blade.php ENDPATH**/ ?>