@props([
'label' => 'Details',
'rows' => 10,
'placeholder' => 'Write your message...',
])
@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()"
x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) sync()" x-data="{
model: @js($model),
value: @js($initialValue),
sync() {
this.value = this.$refs.editor.innerHTML;
if (this.model) {
this.$wire.set(this.model, this.value);
}
},
command(action, value = null) {
this.$refs.editor.focus();
document.execCommand(action, false, value);
this.sync();
},
clear() {
this.value = '';
this.$refs.editor.innerHTML = '';
if (this.model) {
this.$wire.set(this.model, '');
}
},
init() {
this.$refs.editor.innerHTML = this.value || '';
}
}">
@if ($model)
@endif
@if ($model)
@error($model)
{{ $message }}
@enderror
@endif