disallowList = explode(',', $value); } public function render(): string { $editorClass = 'w-full flex flex-col bg-elevated border-3 border-contrast rounded-lg overflow-hidden focus-within:ring-accent ' . $this->class; $this->attributes['class'] = 'bg-elevated border-none focus:border-none focus:outline-none focus:ring-0 w-full h-full'; $this->attributes['rows'] = 6; $textarea = form_textarea($this->attributes, old($this->name, $this->value)); $markdownIcon = icon( 'markdown', 'mr-1 text-lg opacity-40' ); $translations = [ 'write' => lang('Common.forms.editor.write'), 'preview' => lang('Common.forms.editor.preview'), 'help' => lang('Common.forms.editor.help'), ]; $toolbarGroups = [ [ [ 'name' => 'header', 'tag' => 'md-header', 'icon' => icon('heading'), ], [ 'name' => 'bold', 'tag' => 'md-bold', 'icon' => icon('bold'), ], [ 'name' => 'italic', 'tag' => 'md-italic', 'icon' => icon('italic'), ], ], [ [ 'name' => 'unordered-list', 'tag' => 'md-unordered-list', 'icon' => icon('list-unordered'), ], [ 'name' => 'ordered-list', 'tag' => 'md-ordered-list ', 'icon' => icon('list-ordered'), ], ], [ [ 'name' => 'quote', 'tag' => 'md-quote', 'icon' => icon('quote'), ], [ 'name' => 'link', 'tag' => 'md-link', 'icon' => icon('link'), ], [ 'name' => 'image', 'tag' => 'md-image', 'icon' => icon('image-add'), ], ], ]; $toolbarContent = ''; foreach ($toolbarGroups as $buttonsGroup) { $toolbarContent .= '
'; foreach ($buttonsGroup as $button) { if (! in_array($button['name'], $this->disallowList, true)) { $toolbarContent .= '<' . $button['tag'] . ' class="opacity-50 hover:opacity-100 focus:ring-accent focus:opacity-100">' . $button['icon'] . ''; } } $toolbarContent .= '
'; } return <<
{$toolbarContent}
{$textarea}
HTML; } }