Search code examples
laraveltoast-ui-editor

Laravel 8.x - Creating copies of a toast markdown editor in laravel blade


This is a noobie question . I am trying to create multiple copies of toastui editor using the following code, but i am not getting the desired output. Please tell me what i am doing wrong here.

<div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            @for($i=0;$i<10;$i++)
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="flex flex-col space-y-2">
    <label for="editor" class="text-gray-600 font-semibold">Content</label>
    <div id="editor" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"></div>
</div>
            </div>
            @endfor
        </div>
    </div>

Solution

  •         @for($i=0;$i<10;$i++)
                <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                    <div class="flex flex-col space-y-2">
                        <label for="editor" class="text-gray-600 font-semibold">Content</label>
                        <div id="editor-{{$i}}" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm"></div>
                    </div>
                </div>
            @endfor
    

    In script tag :

     for(let i=0; i<10; i++){
          const editor = new toastui.Editor({
            el: document.querySelector('#editor'+i),
            previewStyle: 'vertical',
            height: '500px',
            initialValue: content
          });
        }