added support for legacy tickets, fixed switching of modes and also style updates
This commit is contained in:
Executable → Regular
+15
-14
@@ -10,10 +10,11 @@
|
|||||||
class="space-y-2"
|
class="space-y-2"
|
||||||
x-data="{
|
x-data="{
|
||||||
model: @js($model),
|
model: @js($model),
|
||||||
value: @entangle($model),
|
value: '',
|
||||||
init() {
|
init() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.writeEditorValue(this.value || '');
|
this.value = this.$wire.get(this.model) || '';
|
||||||
|
this.writeEditorValue(this.value);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
writeEditorValue(value) {
|
writeEditorValue(value) {
|
||||||
@@ -30,29 +31,29 @@
|
|||||||
|
|
||||||
this.$refs.editor.textContent = nextValue;
|
this.$refs.editor.textContent = nextValue;
|
||||||
},
|
},
|
||||||
syncToLivewire(live = true) {
|
syncToLivewire(live = false) {
|
||||||
this.value = this.$refs.editor?.innerText || '';
|
const text = this.$refs.editor?.innerText || '';
|
||||||
|
this.value = text;
|
||||||
if (this.$refs.input) {
|
if (this.$refs.input) {
|
||||||
this.$refs.input.value = this.value;
|
this.$refs.input.value = text;
|
||||||
}
|
}
|
||||||
|
// Update Livewire's local state before the save request is assembled.
|
||||||
this.$wire.set(this.model, this.value, live);
|
this.$wire.set(this.model, text, live);
|
||||||
},
|
},
|
||||||
resetEditor() {
|
resetEditor() {
|
||||||
this.value = '';
|
this.value = '';
|
||||||
this.writeEditorValue('');
|
this.writeEditorValue('');
|
||||||
this.syncToLivewire(true);
|
this.syncToLivewire(false);
|
||||||
},
|
},
|
||||||
runCommand(command) {
|
runCommand(command) {
|
||||||
this.$refs.editor?.focus();
|
this.$refs.editor?.focus();
|
||||||
document.execCommand(command, false, null);
|
document.execCommand(command, false, null);
|
||||||
this.syncToLivewire(true);
|
this.syncToLivewire(false);
|
||||||
},
|
},
|
||||||
wrapBlock(tagName) {
|
wrapBlock(tagName) {
|
||||||
this.$refs.editor?.focus();
|
this.$refs.editor?.focus();
|
||||||
document.execCommand('formatBlock', false, tagName);
|
document.execCommand('formatBlock', false, tagName);
|
||||||
this.syncToLivewire(true);
|
this.syncToLivewire(false);
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
x-on:helpdesk-editor-sync.window="if (! $event.detail?.model || $event.detail.model === @js($model)) syncToLivewire($event.detail?.live ?? true)"
|
x-on:helpdesk-editor-sync.window="if (! $event.detail?.model || $event.detail.model === @js($model)) syncToLivewire($event.detail?.live ?? true)"
|
||||||
@@ -116,14 +117,14 @@
|
|||||||
data-helpdesk-sync-target="{{ $model }}"
|
data-helpdesk-sync-target="{{ $model }}"
|
||||||
data-helpdesk-editor-model="{{ $model }}"
|
data-helpdesk-editor-model="{{ $model }}"
|
||||||
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
|
@if ($editorDusk) data-dusk="{{ $editorDusk }}" dusk="{{ $editorDusk }}" @endif
|
||||||
x-on:paste="syncToLivewire(false)"
|
x-on:input="syncToLivewire(false)"
|
||||||
x-on:blur="syncToLivewire(true)"
|
x-on:paste="$nextTick(() => syncToLivewire(false))"
|
||||||
|
x-on:blur="syncToLivewire(false)"
|
||||||
class="helpdesk-rich-editor block min-h-[14rem] w-full overflow-y-auto whitespace-pre-wrap break-words border-0 bg-zinc-950 px-5 py-4 text-base leading-7 text-zinc-100 outline-none transition placeholder:text-zinc-500 empty:before:pointer-events-none empty:before:text-zinc-500 empty:before:content-[attr(data-placeholder)] focus:ring-2 focus:ring-blue-500"
|
class="helpdesk-rich-editor block min-h-[14rem] w-full overflow-y-auto whitespace-pre-wrap break-words border-0 bg-zinc-950 px-5 py-4 text-base leading-7 text-zinc-100 outline-none transition placeholder:text-zinc-500 empty:before:pointer-events-none empty:before:text-zinc-500 empty:before:content-[attr(data-placeholder)] focus:ring-2 focus:ring-blue-500"
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
x-ref="input"
|
x-ref="input"
|
||||||
wire:model.defer="{{ $model }}"
|
|
||||||
spellcheck="true"
|
spellcheck="true"
|
||||||
lang="en-GB"
|
lang="en-GB"
|
||||||
autocorrect="on"
|
autocorrect="on"
|
||||||
|
|||||||
Executable → Regular
+5
-25
@@ -18,33 +18,9 @@
|
|||||||
x-on:submit.capture="
|
x-on:submit.capture="
|
||||||
if (helpdeskAttachmentsUploading) {
|
if (helpdeskAttachmentsUploading) {
|
||||||
$event.preventDefault();
|
$event.preventDefault();
|
||||||
|
$event.stopImmediatePropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const editor = document.querySelector('[data-helpdesk-sync-target="body"], [data-helpdesk-editor-model="body"]');
|
|
||||||
const target = Array.from(document.querySelectorAll('textarea')).find(function (textarea) {
|
|
||||||
|
|
||||||
return textarea.getAttribute('wire:model.defer') === 'body'
|
|
||||||
|
|
||||||
|| textarea.getAttribute('wire:model') === 'body'
|
|
||||||
|
|
||||||
|| textarea.getAttribute('name') === 'body'
|
|
||||||
|
|
||||||
|| textarea.id === 'body';
|
|
||||||
|
|
||||||
});
|
|
||||||
const body = (editor?.innerText || editor?.textContent || editor?.value || '').trim();
|
|
||||||
|
|
||||||
if (target) {
|
|
||||||
target.value = body;
|
|
||||||
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
||||||
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($wire) {
|
|
||||||
$wire.set('body', body, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dispatch('helpdesk-editor-sync', { model: 'body', live: false });
|
$dispatch('helpdesk-editor-sync', { model: 'body', live: false });
|
||||||
"
|
"
|
||||||
class="helpdesk-ticket-form space-y-6"
|
class="helpdesk-ticket-form space-y-6"
|
||||||
@@ -245,6 +221,10 @@
|
|||||||
editor-dusk="ticket-body-editor"
|
editor-dusk="ticket-body-editor"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@error('body')
|
||||||
|
<p class="mt-2 text-sm text-red-500" role="alert">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
|
|
||||||
<p class="mt-2 flex items-center gap-2 text-xs font-medium text-zinc-400">
|
<p class="mt-2 flex items-center gap-2 text-xs font-medium text-zinc-400">
|
||||||
<i class="fa-solid fa-circle-info text-blue-400" aria-hidden="true"></i>
|
<i class="fa-solid fa-circle-info text-blue-400" aria-hidden="true"></i>
|
||||||
Rich formatting is available. Browser spelling suggestions appear by right-clicking or Ctrl-clicking red-underlined words.
|
Rich formatting is available. Browser spelling suggestions appear by right-clicking or Ctrl-clicking red-underlined words.
|
||||||
|
|||||||
Reference in New Issue
Block a user