fixed creation

This commit is contained in:
Mark Gregory
2026-06-24 09:25:02 +01:00
parent d9b472e651
commit 42f1d10f45
5 changed files with 62 additions and 23 deletions
@@ -14,29 +14,49 @@
<div {{ $attributes->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="{
x-on:helpdesk-editor-sync.window="if ($event.detail.model === model) syncToLivewire()"
x-data="{
model: @js($model),
value: @js($initialValue),
sync() {
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);
this.$wire.set(this.model, this.value, live);
}
},
command(action, value = null) {
this.$refs.editor.focus();
document.execCommand(action, false, value);
this.sync();
this.syncToHiddenInput();
},
clear() {
this.value = '';
this.$refs.editor.innerHTML = '';
if (this.model) {
this.$wire.set(this.model, '');
this.$wire.set(this.model, '', 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 });
}
}
}">
<label class="block text-sm font-medium text-zinc-700 dark:text-zinc-200">{{ $label }}</label>
@@ -66,16 +86,15 @@
class="rounded-lg px-2 py-1 text-sm hover:bg-zinc-200 dark:hover:bg-zinc-800">Clear</button>
</div>
<div x-ref="editor" contenteditable="true" spellcheck="true" lang="en-GB" autocapitalize="sentences" autocorrect="on" autocomplete="on" inputmode="text"
<div x-ref="editor" contenteditable="true" spellcheck="true" lang="en-GB" autocapitalize="sentences" autocorrect="on" autocomplete="off" inputmode="text"
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
x-on:input.debounce.150ms="sync" x-on:keyup="sync" x-on:paste="$nextTick(() => sync())" x-on:blur="sync"
class="prose prose-sm min-h-[{{ (int) $rows * 28 }}px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
x-on:paste="$nextTick(() => syncToHiddenInput())" x-on:blur="syncToHiddenInput()"
class="helpdesk-rich-editor prose prose-sm min-h-[{{ (int) $rows * 28 }}px] max-w-none bg-white p-4 text-sm text-zinc-900 outline-none dark:prose-invert dark:bg-zinc-950 dark:text-zinc-100"
data-placeholder="{{ $placeholder }}"></div>
</div>
<p class="text-xs font-semibold text-zinc-500 dark:text-zinc-400">
Browser spellcheck is enabled for this rich editor. Use your browser or operating-system spelling menu for suggestions.
Browser spellcheck is enabled for this rich editor. Misspelled words are checked by the browser/operating system while typing.
</p>
@if ($model)
@@ -7,7 +7,7 @@
'Raise a new support request with priority, product/service, project, category, team and full details.',
])
<form wire:submit.prevent="save" enctype="multipart/form-data" class="helpdesk-ticket-form space-y-6">
<form wire:submit.prevent="save" x-on:submit.capture="$dispatch('helpdesk-editor-sync', { model: 'body' })" enctype="multipart/form-data" class="helpdesk-ticket-form space-y-6">
<div class="overflow-hidden rounded-2xl border border-zinc-700 bg-zinc-900 shadow-sm">
<div class="border-b border-zinc-700 bg-zinc-800/80 px-6 py-4">
<h2 class="text-lg font-semibold text-zinc-100">Ticket details</h2>