@props([
'label' => 'Details',
'rows' => 10,
'placeholder' => 'Write your message...',
])
@php($model = $attributes->wire('model')->value())
except(['wire:model'])->merge(['class' => 'space-y-2']) }}
x-data="{
value: @entangle($model),
command(action, value = null) {
document.execCommand(action, false, value);
this.sync();
},
sync() {
this.value = this.$refs.editor.innerHTML;
},
init() {
this.$refs.editor.innerHTML = this.value || '';
this.$watch('value', (nextValue) => {
if (document.activeElement !== this.$refs.editor && this.$refs.editor.innerHTML !== (nextValue || '')) {
this.$refs.editor.innerHTML = nextValue || '';
}
});
}
}"
>
@error($model)
{{ $message }}
@enderror