<?php

namespace App\Http\Livewire;

use App\Rules\MaxLengthWithoutHtml;
use Livewire\Attributes\Rule;
use Livewire\Component;

class QuillEditor extends Component
{    
    public $content;

    public function mount($content)
    {
        $this->content = $content;
    }

    
    public function updatedContent()
    {
        $maxLength = timebank_config('posts.content_max_input', 1000);
        
        $this->validateOnly('content', [
            'content' => ['required', 'string', 'min:10', new MaxLengthWithoutHtml($maxLength)]
        ]);
    }

    
    public function updated()
    {
        $this->dispatch('quillEditor', $this->content);
    }

    
    public function render()
    {
        return view('livewire.quill-editor');
    }
}
