@props([ 'label' => 'Details', 'rows' => 10, 'placeholder' => 'Write your message...', 'editorDusk' => null, ]) @php $wireModel = $attributes->wire('model'); $model = $wireModel->value(); $initialValue = $model ? data_get($this, $model, '') : ''; @endphp
whereDoesntStartWith('wire:model')->merge(['class' => 'space-y-2']) }} @if ($model) data-helpdesk-editor-model="{{ $model }}" @endif x-on:helpdesk-editor-reset.window="if ($event.detail.model === model) clear($event.detail.value || '')" x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) syncToLivewire()" x-data="{ model: @js($model), value: @js($initialValue), submitHandler: null, readEditor() { this.value = this.$refs.editor.innerHTML; return this.value; }, syncToHiddenInput() { this.readEditor(); }, syncToLivewire(live = false) { this.readEditor(); if (this.model) { this.$wire.set(this.model, this.value, live); } }, command(action, value = null) { this.$refs.editor.focus(); document.execCommand(action, false, value); this.syncToHiddenInput(); }, insertCodeBlock() { this.$refs.editor.focus(); document.execCommand('formatBlock', false, 'pre'); this.syncToHiddenInput(); }, handlePaste(event) { const files = Array.from(event.clipboardData?.files || []); const images = files.filter((file) => file.type.startsWith('image/')); if (images.length > 0) { window.dispatchEvent(new CustomEvent('helpdesk-editor-files-pasted', { detail: { files: images } })); } this.$nextTick(() => this.syncToHiddenInput()); }, clear(value = '') { this.value = value || ''; this.$refs.editor.innerHTML = this.value; if (this.model) { this.$wire.set(this.model, this.value, false); } }, init() { this.$refs.editor.innerHTML = this.value || ''; this.submitHandler = () => this.syncToLivewire(false); this.$root.closest('form')?.addEventListener('submit', this.submitHandler, { capture: true }); }, destroy() { if (this.submitHandler) { this.$root.closest('form')?.removeEventListener('submit', this.submitHandler, { capture: true }); } } }"> @if ($model) @endif

Browser spellcheck is enabled. Use Code for snippets, and paste screenshots directly into the editor to attach them to the ticket.

@if ($model) @error($model)
{{ $message }}
@enderror @endif